From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 9A64A2192E1; Mon, 23 Jun 2025 09:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750672424; cv=none; b=p/NNwsjRFAx34VJjEfXxT5VRXqBVHKpTIIiT73QWrdKJypyOuAxSdPhvmU6HadS1bj/rQ1cry9FHPjHC24RAxzgh/QrhdRfRBvOBCpz8fQrZitmWp+gcieePaJn+sBkwfsDQTQbukagXh8xfoo8a9ZE0MZw2PlMe/fESvJ9W7HA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750672424; c=relaxed/simple; bh=yZ4aShi2PgqttO51YDngWhE0TfGZrUMxSGZEgqbAZ4E=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bgiNPMB62UgrS4sDgPQ5xxUNCyO26T0fmBp7Fcux53DPEDDnM3zZPTUg9RdLLOGw90+XjsmA9aUX5JXdA8ifwsnRpLI6by6BwUnYzbDvwqr91BM3pO3X2P7lHL2ucM92Pve/QyTFVeZbiAQCacV0K7CIytP5XtpwSfRdKHRoIOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bQk0T46T3z6M4vR; Mon, 23 Jun 2025 17:52:57 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 160F21402EF; Mon, 23 Jun 2025 17:53:40 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 23 Jun 2025 11:53:39 +0200 Date: Mon, 23 Jun 2025 10:53:37 +0100 From: Jonathan Cameron To: Neeraj Kumar CC: , , , , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH 19/20] cxl/pmem_region: Prep patch to accommodate pmem_region attributes Message-ID: <20250623105337.000028c6@huawei.com> In-Reply-To: <1997287019.101750165383025.JavaMail.epsvc@epcpadp2new> References: <20250617123944.78345-1-s.neeraj@samsung.com> <1997287019.101750165383025.JavaMail.epsvc@epcpadp2new> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100005.china.huawei.com (7.191.160.25) To frapeml500008.china.huawei.com (7.182.85.71) On Tue, 17 Jun 2025 18:09:43 +0530 Neeraj Kumar wrote: > Created a separate file core/pmem_region.c along with CONFIG_PMEM_REGION > Moved pmem_region related code from core/region.c to core/pmem_region.c > For region label update, need to create device attribute, which calls > nvdimm exported function thus making pmem_region dependent on libnvdimm. > Because of this dependency of pmem region on libnvdimm, segregated pmem segregate > region related code from core/region.c > > Signed-off-by: Neeraj Kumar > --- > drivers/cxl/Kconfig | 12 ++ > drivers/cxl/core/Makefile | 1 + > drivers/cxl/core/core.h | 8 +- > drivers/cxl/core/pmem_region.c | 222 +++++++++++++++++++++++++++++++++ > drivers/cxl/core/port.c | 2 +- > drivers/cxl/core/region.c | 217 ++------------------------------ > drivers/cxl/cxl.h | 42 +++++-- > tools/testing/cxl/Kbuild | 1 + > 8 files changed, 283 insertions(+), 222 deletions(-) > create mode 100644 drivers/cxl/core/pmem_region.c > > diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig > index 876469e23f7a..f0cbb096bfe7 100644 > --- a/drivers/cxl/Kconfig > +++ b/drivers/cxl/Kconfig > @@ -128,6 +128,18 @@ config CXL_REGION > > If unsure say 'y' > > +config CXL_PMEM_REGION > + bool "CXL: Pmem Region Support" > + default CXL_BUS > + depends on CXL_REGION > + select LIBNVDIMM if CXL_BUS = y This is in the block covered by if CXL_BUS so I think you can simplify this check. > + help > + Enable the CXL core to enumerate and provision CXL pmem regions. > + A CXL pmem region need to update region label into LSA. For LSA > + updation/deletion libnvdimm is required. > + > + If unsure say 'y' > + > config CXL_REGION_INVALIDATION_TEST > bool "CXL: Region Cache Management Bypass (TEST)" > depends on CXL_REGION > diff --git a/drivers/cxl/core/pmem_region.c b/drivers/cxl/core/pmem_region.c > new file mode 100644 > index 000000000000..a29526c27d40 > --- /dev/null > +++ b/drivers/cxl/core/pmem_region.c > @@ -0,0 +1,222 @@ > @@ -3273,92 +3155,6 @@ static struct cxl_dax_region *cxl_dax_region_alloc(struct cxl_region *cxlr) > return cxlr_dax; > } > static void cxlr_dax_unregister(void *_cxlr_dax) > { > struct cxl_dax_region *cxlr_dax = _cxlr_dax; > @@ -3646,7 +3442,10 @@ static int cxl_region_probe(struct device *dev) > > switch (cxlr->mode) { > case CXL_DECODER_PMEM: > - return devm_cxl_add_pmem_region(cxlr); > + if (IS_ENABLED(CONFIG_CXL_PMEM_REGION)) > + return devm_cxl_add_pmem_region(cxlr); > + else > + return -EINVAL; if (!IS_ENABLED(CONFIG_CXL_PMEM_REGION)) return -EINVAL; return devm_cxl_add_pmem_region() Where ever possible keep the error conditions as the out of line ones. That generally improves code readability and is common practice in the kernel. > case CXL_DECODER_RAM: > /* > * The region can not be manged by CXL if any portion of