[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1983025922.01750944303051.JavaMail.epsvc@epcpadp1new>
Date: Thu, 26 Jun 2025 16:11:27 +0530
From: Neeraj Kumar <s.neeraj@...sung.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: dan.j.williams@...el.com, dave@...olabs.net, dave.jiang@...el.com,
alison.schofield@...el.com, vishal.l.verma@...el.com, ira.weiny@...el.com,
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 23/06/25 10:48AM, Jonathan Cameron wrote:
>On Tue, 17 Jun 2025 18:09:42 +0530
>Neeraj Kumar <s.neeraj@...sung.com> 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;
>> +}
>> +
>> +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;
>> +
>> + if (!nvdimm)
>> + return -ENOTTY;
>
>As with other checks like this, it is useful to add a comment on when you can
>call this function with a null parameter.
>
Sure, Will fix it accordingly
>> +
>> + 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");
>> + } else {
>> + dev_dbg(&cxlmd->dev, "Region Creation is not supported with iw > 1\n");
>> + }
>
>Flip logic to check for unhandled case first and also return an error if this happens
>rather than silently carrying on. dev_info() is appropriate here.
>
Thanks, Will fix it in V1
>> +
>> + 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);
>> 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