Re: [PATCH V4 15/17] cxl/pmem_region: Add sysfs attribute cxl region label updation/deletion
From: Jonathan Cameron
Date: Wed Dec 17 2025 - 10:41:59 EST
On Wed, 19 Nov 2025 13:22:53 +0530
Neeraj Kumar <s.neeraj@xxxxxxxxxxx> wrote:
> Using these attributes region label is added/deleted into LSA. These
> attributes are called from userspace (ndctl) after region creation.
>
> Signed-off-by: Neeraj Kumar <s.neeraj@xxxxxxxxxxx>
One quick addition to what Dave called out.
Thanks,
Jonathan
> diff --git a/drivers/cxl/core/pmem_region.c b/drivers/cxl/core/pmem_region.c
> index b45e60f04ff4..be4feb73aafc 100644
> --- a/drivers/cxl/core/pmem_region.c
> +++ b/drivers/cxl/core/pmem_region.c
> @@ -30,9 +30,100 @@ static void cxl_pmem_region_release(struct device *dev)
> kfree(cxlr_pmem);
> }
>
> +static ssize_t region_label_update_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct cxl_pmem_region *cxlr_pmem = to_cxl_pmem_region(dev);
> + struct cxl_region *cxlr = cxlr_pmem->cxlr;
> + ssize_t rc;
> + bool update;
> +
> + rc = kstrtobool(buf, &update);
> + if (rc)
> + return rc;
> +
> + ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
> + rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem);
> + if (rc)
I'd stick to one style for these. Elsewhere you have
if ((rc = ACQUIRE_ERR())
> + return rc;
> +
> + /* Region not yet committed */
> + if (update && cxlr && cxlr->params.state != CXL_CONFIG_COMMIT) {
> + dev_dbg(dev, "region not committed, can't update into LSA\n");
> + return -ENXIO;
> + }
> +
> + if (!cxlr || !cxlr->cxlr_pmem || !cxlr->cxlr_pmem->nd_region)
> + return 0;
> +
> + rc = nd_region_label_update(cxlr->cxlr_pmem->nd_region);
> + if (rc)
> + return rc;
> +
> + cxlr->params.state_region_label = CXL_REGION_LABEL_ACTIVE;
> +
> + return len;
> +}