[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <28d78d2b-c17d-4910-9f28-67af1fbb10ee@intel.com>
Date: Wed, 24 Sep 2025 13:47:21 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Neeraj Kumar <s.neeraj@...sung.com>, linux-cxl@...r.kernel.org,
nvdimm@...ts.linux.dev, linux-kernel@...r.kernel.org, gost.dev@...sung.com
Cc: a.manzanares@...sung.com, vishak.g@...sung.com, neeraj.kernel@...il.com,
cpgs@...sung.com
Subject: Re: [PATCH V3 20/20] cxl/pmem: Add CXL LSA 2.1 support in cxl pmem
On 9/17/25 6:41 AM, Neeraj Kumar wrote:
> Add support of CXL LSA 2.1 using NDD_REGION_LABELING flag. It creates
> cxl region based on region information parsed from LSA.
>
> Signed-off-by: Neeraj Kumar <s.neeraj@...sung.com>
> ---
> drivers/cxl/core/pmem_region.c | 53 ++++++++++++++++++++++++++++++++++
> drivers/cxl/cxl.h | 4 +++
> drivers/cxl/pmem.c | 2 ++
> 3 files changed, 59 insertions(+)
>
> diff --git a/drivers/cxl/core/pmem_region.c b/drivers/cxl/core/pmem_region.c
> index 665b603c907b..3ef9c7d15041 100644
> --- a/drivers/cxl/core/pmem_region.c
> +++ b/drivers/cxl/core/pmem_region.c
> @@ -290,3 +290,56 @@ int devm_cxl_add_pmem_region(struct cxl_region *cxlr)
> return rc;
> }
> EXPORT_SYMBOL_NS_GPL(devm_cxl_add_pmem_region, "CXL");
> +
> +static int match_free_ep_decoder(struct device *dev, const void *data)
> +{
> + struct cxl_decoder *cxld = to_cxl_decoder(dev);
I think this is needed if the function is match_free_ep_decoder().
if (!is_endpoint_decoder(dev))
return 0;
> +
> + return !cxld->region;
> +}
May want to borrow some code from match_free_decoder() in core/region.c. I think the decoder commit order matters?
> +
> +static struct cxl_decoder *cxl_find_free_ep_decoder(struct cxl_port *port)
> +{
> + struct device *dev;
> +
> + dev = device_find_child(&port->dev, NULL, match_free_ep_decoder);
> + if (!dev)
> + return NULL;
> +
> + /* Release device ref taken via device_find_child() */
> + put_device(dev);
Should have the caller put the device.
> + return to_cxl_decoder(dev);
> +}
> +
> +void create_pmem_region(struct nvdimm *nvdimm)
> +{
> + struct cxl_nvdimm *cxl_nvd;
> + struct cxl_memdev *cxlmd;
> + struct cxl_pmem_region_params *params;
> + struct cxl_root_decoder *cxlrd;
> + struct cxl_decoder *cxld;
> + struct cxl_region *cxlr;
> +
> + if (!nvdimm_has_cxl_region(nvdimm))
> + return;
> +
> + lockdep_assert_held(&cxl_rwsem.region);
> + cxl_nvd = nvdimm_provider_data(nvdimm);
> + params = nvdimm_get_cxl_region_param(nvdimm);
> + cxlmd = cxl_nvd->cxlmd;
> + cxlrd = cxlmd->cxlrd;
> +
> + /* TODO: Region creation support only for interleave way == 1 */
> + if (!(params->nlabel == 1))
> + dev_info(&cxlmd->dev,
> + "Region Creation is not supported with iw > 1\n");
Why not just exit here. Then the else is not necessary.
Also maybe deb_dbg().
> + else {
> + cxld = cxl_find_free_ep_decoder(cxlmd->endpoint);
> + cxlr = cxl_create_region(cxlrd, CXL_PARTMODE_PMEM,
> + atomic_read(&cxlrd->region_id),
> + params, cxld);
> + if (IS_ERR(cxlr))
> + dev_info(&cxlmd->dev, "Region Creation failed\n");
dev_warn()
> + }
> +}
> +EXPORT_SYMBOL_NS_GPL(create_pmem_region, "CXL");
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index f01f8c942fdf..0a87ea79742a 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -910,6 +910,7 @@ cxl_create_region(struct cxl_root_decoder *cxlrd,
> bool is_cxl_pmem_region(struct device *dev);
> struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev);
> int devm_cxl_add_pmem_region(struct cxl_region *cxlr);
> +void create_pmem_region(struct nvdimm *nvdimm);
> #else
> static inline bool is_cxl_pmem_region(struct device *dev)
> {
> @@ -923,6 +924,9 @@ static inline int devm_cxl_add_pmem_region(struct cxl_region *cxlr)
> {
> return 0;
> }
> +static inline void create_pmem_region(struct nvdimm *nvdimm)
> +{
> +}
> #endif
>
> void cxl_endpoint_parse_cdat(struct cxl_port *port);
> diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> index 38a5bcdc68ce..0cdef01dbc68 100644
> --- a/drivers/cxl/pmem.c
> +++ b/drivers/cxl/pmem.c
> @@ -135,6 +135,7 @@ static int cxl_nvdimm_probe(struct device *dev)
> return rc;
>
> set_bit(NDD_LABELING, &flags);
> + set_bit(NDD_REGION_LABELING, &flags);
> set_bit(NDD_REGISTER_SYNC, &flags);
> set_bit(ND_CMD_GET_CONFIG_SIZE, &cmd_mask);
> set_bit(ND_CMD_GET_CONFIG_DATA, &cmd_mask);
> @@ -155,6 +156,7 @@ static int cxl_nvdimm_probe(struct device *dev)
> return -ENOMEM;
>
> dev_set_drvdata(dev, nvdimm);
> + create_pmem_region(nvdimm);
> return devm_add_action_or_reset(dev, unregister_nvdimm, nvdimm);
> }
>
Powered by blists - more mailing lists