[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <45c254fe-fd74-46e7-bf06-5614810f7193@intel.com>
Date: Thu, 10 Jul 2025 10:18:27 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Neeraj Kumar <s.neeraj@...sung.com>, dan.j.williams@...el.com,
dave@...olabs.net, jonathan.cameron@...wei.com, alison.schofield@...el.com,
vishal.l.verma@...el.com, ira.weiny@...el.com
Cc: a.manzanares@...sung.com, nifan.cxl@...il.com, anisa.su@...sung.com,
vishak.g@...sung.com, krish.reddy@...sung.com, arun.george@...sung.com,
alok.rathore@...sung.com, neeraj.kernel@...il.com,
linux-kernel@...r.kernel.org, linux-cxl@...r.kernel.org,
nvdimm@...ts.linux.dev, gost.dev@...sung.com, cpgs@...sung.com
Subject: Re: [RFC PATCH 18/20] cxl/pmem: Add support of cxl lsa 2.1 support in
cxl pmem
On 6/17/25 5:39 AM, Neeraj Kumar wrote:
> Add support of cxl lsa 2.1 using NDD_CXL_LABEL flag. It also creates cxl
> region based on region information parsed from LSA.
>
> Signed-off-by: Neeraj Kumar <s.neeraj@...sung.com>
> ---
> drivers/cxl/pmem.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
>
> diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> index ffcebb8d382f..2733d79b32d5 100644
> --- a/drivers/cxl/pmem.c
> +++ b/drivers/cxl/pmem.c
> @@ -58,6 +58,63 @@ static const struct attribute_group *cxl_dimm_attribute_groups[] = {
> NULL
> };
>
> +static int match_ep_decoder(struct device *dev, void *data)
> +{
> + struct cxl_decoder *cxld = to_cxl_decoder(dev);
> +
> + if (!cxld->region)
> + return 1;
> + else
> + return 0;
> +}
return !cxld->region;
> +
> +static struct cxl_decoder *cxl_find_free_decoder(struct cxl_port *port)
> +{
> + struct device *dev;
> +
> + dev = device_find_child(&port->dev, NULL, match_ep_decoder);
> + if (!dev)
> + return NULL;
> +
> + return to_cxl_decoder(dev);
> +}
> +
> +static int create_pmem_region(struct nvdimm *nvdimm)
> +{
> + struct cxl_nvdimm *cxl_nvd;
> + struct cxl_memdev *cxlmd;
> + struct cxl_nvdimm_bridge *cxl_nvb;
> + struct cxl_pmem_region_params *params;
> + struct cxl_root_decoder *cxlrd;
> + struct cxl_decoder *cxld;
> + struct cxl_region *cxlr;
> +
probably need a lockdep_assert_held(&cxl_region_rwsem).
> + if (!nvdimm)
> + return -ENOTTY;
-ENODEV?
> +
> + if (!nvdimm_has_cxl_region(nvdimm))
> + return 0;
> +
> + cxl_nvd = nvdimm_provider_data(nvdimm);
> + params = nvdimm_get_cxl_region_param(nvdimm);
> + cxlmd = cxl_nvd->cxlmd;
> + cxl_nvb = cxlmd->cxl_nvb;
> + cxlrd = cxlmd->cxlrd;
> +
> + /* FIXME: Limitation: Region creation only when interleave way == 1 */
> + if (params->nlabel == 1) {
> + cxld = cxl_find_free_decoder(cxlmd->endpoint);
> + cxlr = cxl_create_pmem_region(cxlrd, cxld, params,
> + atomic_read(&cxlrd->region_id));
> + if (IS_ERR(cxlr))
> + dev_dbg(&cxlmd->dev, "Region Creation failed\n");
return PTR_ERR(cxlr); ?
> + } else {
> + dev_dbg(&cxlmd->dev, "Region Creation is not supported with iw > 1\n");
> + }
> +
> + return 0;
> +}
> +
> static int cxl_nvdimm_probe(struct device *dev)
> {
> struct cxl_nvdimm *cxl_nvd = to_cxl_nvdimm(dev);
> @@ -74,6 +131,7 @@ static int cxl_nvdimm_probe(struct device *dev)
> return rc;
>
> set_bit(NDD_LABELING, &flags);
> + set_bit(NDD_CXL_LABEL, &flags);
Ok here's the NDD_CXL_LABEL set. I think the driver should be probing the label index block and retrieve the label version and determine how to support from there instead of hard coding a flag.
> set_bit(NDD_REGISTER_SYNC, &flags);
> set_bit(ND_CMD_GET_CONFIG_SIZE, &cmd_mask);
> set_bit(ND_CMD_GET_CONFIG_DATA, &cmd_mask);
> @@ -86,6 +144,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