On 23/06/25 10:56AM, Jonathan Cameron wrote:
On Tue, 17 Jun 2025 18:09:44 +0530
Neeraj Kumar <s.nee...@samsung.com> wrote:

Using these attributes region label is added/deleted into LSA. These
attributes are called from userspace (ndctl) after region creation.

These need documentation. Documentation/ABI/testing/sysfs-bus-cxl
is probably the right place.


Sure, Will update this in Documentation as well as update it in commit
message



Signed-off-by: Neeraj Kumar <s.nee...@samsung.com>
---
 drivers/cxl/core/pmem_region.c | 103 +++++++++++++++++++++++++++++++++
 drivers/cxl/cxl.h              |   1 +
 2 files changed, 104 insertions(+)

diff --git a/drivers/cxl/core/pmem_region.c b/drivers/cxl/core/pmem_region.c
index a29526c27d40..f582d796c21b 100644
--- a/drivers/cxl/core/pmem_region.c
+++ b/drivers/cxl/core/pmem_region.c
@@ -45,8 +45,111 @@ 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;
+       struct cxl_region_params *p = &cxlr->params;
+       ssize_t rc;
+       bool update;
+
+       rc = kstrtobool(buf, &update);
+       if (rc)
+               return rc;
+
+       rc = down_write_killable(&cxl_region_rwsem);

Another use case for ACQUIRE()


Sure, I will look at Dan's new ACQUIRE() series. I will update it in V1

+       if (rc)
+               return rc;
+
+       /* Region not yet committed */
+       if (update && p->state != CXL_CONFIG_COMMIT) {
+               dev_dbg(dev, "region not committed, can't update into LSA\n");
+               rc = -ENXIO;
+               goto out;
+       }
+
+       if (cxlr && cxlr->cxlr_pmem && cxlr->cxlr_pmem->nd_region) {
+               rc = nd_region_label_update(cxlr->cxlr_pmem->nd_region);
+
+               if (!rc)
+                       p->region_label_state = 1;
+       }
+
+out:
+       up_write(&cxl_region_rwsem);
+
+       if (rc)
+               return rc;
+
+       return len;
+}

+
+static struct attribute *cxl_pmem_region_attrs[] = {
+       &dev_attr_region_label_update.attr,
+       &dev_attr_region_label_delete.attr,
+       NULL,
No need for trailing commas on terminating entries as we don't want it to be 
easy
to put something after them.


Sure, Will fix it in V1

+};
+
+struct attribute_group cxl_pmem_region_group = {
+       .attrs = cxl_pmem_region_attrs,
+};
+
 static const struct attribute_group *cxl_pmem_region_attribute_groups[] = {
        &cxl_base_attribute_group,
+       &cxl_pmem_region_group,
        NULL,
Hmm. Drop this trailing comma perhaps whilst here.
 };


Sure, I will update it in V1




Reply via email to