From patchwork Fri Oct 6 17:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Harris X-Patchwork-Id: 13411766 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D90CBE4F for ; Fri, 6 Oct 2023 17:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="aBVnjH4E" Received: from mailout2.w2.samsung.com (mailout2.w2.samsung.com [211.189.100.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1803EB for ; Fri, 6 Oct 2023 10:03:41 -0700 (PDT) Received: from uscas1p2.samsung.com (unknown [182.198.245.207]) by mailout2.w2.samsung.com (KnoxPortal) with ESMTP id 20231006170340usoutp02813ef1a94344ce8ad4159c0b1110f2c0~Lk3Y_mpyv0408704087usoutp02l for ; Fri, 6 Oct 2023 17:03:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w2.samsung.com 20231006170340usoutp02813ef1a94344ce8ad4159c0b1110f2c0~Lk3Y_mpyv0408704087usoutp02l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1696611820; bh=3ThDriuG8zINOfnQ9DPOOEKX2kcs0V63BuySaeHd9Is=; h=From:To:Subject:Date:References:From; b=aBVnjH4EP0vFEd2/Lr7ssoeooD1Qk8y5TxHbrmA4QStNTJXWCTNdOtDm2djv1bb+e 9udbO5d4BHoPo28hkSshdbTUvJsKe135x6k7Gf69Rg2ZOLYf3IDjRZrfSuoetz/uGt LTAb8ha1n4EntJ24Ks8R508AZbqmWfvA7eNeE3Cg= Received: from ussmges3new.samsung.com (u112.gpu85.samsung.co.kr [203.254.195.112]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20231006170340uscas1p193babcb4e72bf78f68f3da0402bf6850~Lk3Y6cmVy2034420344uscas1p1t for ; Fri, 6 Oct 2023 17:03:40 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges3new.samsung.com (USCPEMTA) with SMTP id 08.A1.62237.CED30256; Fri, 6 Oct 2023 13:03:40 -0400 (EDT) Received: from ussmgxs1new.samsung.com (u89.gpu85.samsung.co.kr [203.254.195.89]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20231006170340uscas1p1cb7a65c371984266b3fe06ffce9d7d55~Lk3YpPZ122411224112uscas1p1o for ; Fri, 6 Oct 2023 17:03:40 +0000 (GMT) X-AuditID: cbfec370-b17ff7000001f31d-4c-65203dec4cad Received: from SSI-EX1.ssi.samsung.com ( [105.128.2.146]) by ussmgxs1new.samsung.com (USCPEXMTA) with SMTP id 0C.5E.28590.CED30256; Fri, 6 Oct 2023 13:03:40 -0400 (EDT) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX1.ssi.samsung.com (105.128.2.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Fri, 6 Oct 2023 10:03:39 -0700 Received: from SSI-EX2.ssi.samsung.com ([105.128.2.227]) by SSI-EX2.ssi.samsung.com ([105.128.2.227]) with mapi id 15.01.2375.024; Fri, 6 Oct 2023 10:03:39 -0700 From: Jim Harris To: "linux-cxl@vger.kernel.org" Subject: [PATCH ndctl] libcxl: don't calculate max_available_extent when start == ULLONG_MAX Thread-Topic: [PATCH ndctl] libcxl: don't calculate max_available_extent when start == ULLONG_MAX Thread-Index: AQHZ+HcNJ3f5Nhx0J0CNVMPUROcjHA== Date: Fri, 6 Oct 2023 17:03:39 +0000 Message-ID: <169661181914.694957.3925873284580708486.stgit@bgt-140510-bm03.eng.stellus.in> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [105.128.2.176] Content-ID: <9C338EE2BE693446884855C0028693E0@ssi.samsung.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA02Sa0hTYRjHfXfOtuNyclwrn2akjggUnEoFgSYFsSQSvGQfBKvTPExzzrWp XQiaRLGsoOZEPGpeMHKhaEaZVuC8sjSnXbzF0ImpI7u51sTKap1Ffvs//+f2e15eAhO5cQmR oy6gtWpKJeUJ8Ef9blvU0t4wOmbOELbHxjzH96FEV9u2ZJQhiM+iVTlFtDY64YQg2/zejmlM AWffeuZ5erS0oQT5E0DuAkfPDF6CBISINCOobi7lssEdDpQ3G/j/qgY6niE20YygfdjIZ4Mv COy9s77gDoIug4XrbeGREbD6uonj1WIyDm7qG3gliCA2ksfAtXCStRVQXXqL47XFpAw6jIle Gye3w/yHMZ5XC8kMqHS7kVcjcjN4nrMTMTIYpuZqOCxcENRXPsVYvRnWOh08VofDtMfJ947H /tC0dEazrQmg/zDEZ3U4mK45+OyqILBWzOFs6xawNE78fRUgnXzoHbX6Egfg7a8fvvkh8Ga8 zLc3F8wthr+nAKkBfW8qa8dB3Y8WH3Ig/FydRWyJEAxXRDeRlFl3DPMflFkHyqwDZdaB1iLu PRRcqNPlKWndTjV9Rqaj8nSFaqVMkZ/Xhv78jMG1Hs1jNDX1RdaNOATqRkBgUrFQqd9Ki4RZ 1LnztDb/uLZQReu6UQiBS4OFsXutChGppAroXJrW0Np/WQ7hL9FzWq1l7a9n2obk9tsR6a2u U/6jAlf4L1Pid+Vcmj4l3nnJ1V4hwfoPGOWT8tnqrqZ3jtVnbwYuCr6dHRs6c/1qelb5IcMa WZB5YXmwQk0xwzw/G9CBGTtMiXX1XUm1PcmTVJHDFLLovj8gHYmb5InxKk9d4cguVW/L/rSd 86kpGlJy5Mgxc9XDSgUzSh0t1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yqWje9ePhjA3Hkl67rntpIrauWImlOCPRUIu5qDgRAGvKt7IE AwAA X-CMS-MailID: 20231006170340uscas1p1cb7a65c371984266b3fe06ffce9d7d55 CMS-TYPE: 301P X-CMS-RootMailID: 20231006170340uscas1p1cb7a65c371984266b3fe06ffce9d7d55 References: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net `cxl list` can be run as non-root, but some sysfs entries such as decoderX.Y/start are only root-readable. In this case, decoder->start gets set to ULLONG_MAX and cxl_decoder_max_available_extent() would try to calculate a size based on the value. This would result in a value slightly less than ULLONG_MAX which would emit odd (and obviously incorrect) values for max_available_extent. If we just return ULLONG_MAX in this case, the max_available_extent is not emitted which is the desirable behavior in this case. If users need the value, they can run `cxl list` as root. Signed-off-by: Jim Harris --- cxl/lib/libcxl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index af4ca44..eb9ccf1 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -2002,6 +2002,9 @@ cxl_decoder_calc_max_available_extent(struct cxl_decoder *decoder) return ULLONG_MAX; } + if (decoder->start == ULLONG_MAX) + return ULLONG_MAX; + /* * Preload prev_end with an imaginary region that ends just before * the decoder's start, so that the extent calculation for the