cxl/pmem: add provider name to cxl pmem dimm attribute group
authorDave Jiang <dave.jiang@intel.com>
Wed, 30 Nov 2022 19:23:01 +0000 (12:23 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 1 Dec 2022 20:42:35 +0000 (12:42 -0800)
Add provider name in order to associate cxl test dimm from cxl_test to the
cxl pmem device when going through sysfs for security testing.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/166983618174.2734609.15600031015423828810.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Documentation/ABI/testing/sysfs-bus-nvdimm
drivers/cxl/pmem.c

index 178ce207413dab6ff8c3b36932e25a1bcabdfc16..de8c5a59c77fed4afb7e76fdac60d9782805d817 100644 (file)
@@ -47,3 +47,11 @@ Date:                November 2022
 KernelVersion: 6.2
 Contact:       Dave Jiang <dave.jiang@intel.com>
 Description:   (RO) Show the id (serial) of the device. This is CXL specific.
+
+What:          /sys/bus/nd/devices/nmemX/cxl/provider
+Date:          November 2022
+KernelVersion: 6.2
+Contact:       Dave Jiang <dave.jiang@intel.com>
+Description:   (RO) Shows the CXL bridge device that ties to a CXL memory device
+               to this NVDIMM device. I.e. the parent of the device returned is
+               a /sys/bus/cxl/devices/memX instance.
index 0493ddcfe32c89138e4dbb628ed9f6fec0a95ab6..403e41bcbf2bfa7146ea16702bd40539cbf59e9b 100644 (file)
@@ -51,6 +51,15 @@ static void unregister_nvdimm(void *nvdimm)
        cxl_nvd->bridge = NULL;
 }
 
+static ssize_t provider_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct nvdimm *nvdimm = to_nvdimm(dev);
+       struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
+
+       return sysfs_emit(buf, "%s\n", dev_name(&cxl_nvd->dev));
+}
+static DEVICE_ATTR_RO(provider);
+
 static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct nvdimm *nvdimm = to_nvdimm(dev);
@@ -63,6 +72,7 @@ static DEVICE_ATTR_RO(id);
 
 static struct attribute *cxl_dimm_attributes[] = {
        &dev_attr_id.attr,
+       &dev_attr_provider.attr,
        NULL
 };