lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250623104816.00005075@huawei.com>
Date: Mon, 23 Jun 2025 10:48:16 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Neeraj Kumar <s.neeraj@...sung.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 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.

> +
> +	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.

> +
> +	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

Powered by Openwall GNU/*/Linux Powered by OpenVZ