Skip to contentSkip to conversation

Enable DSM pass thru for root functions

PATCH Superseded Jerry Hoemann 2 participants 15 messages Jun 20, 2017 – Jun 28, 2017

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enable DSM pass thru for root functions

The new ACPI 6.2 spec has added new NVDIMM root DSM functions that managibility and test software needs to call.

This patch set enables the calling root functions DSM via the pass thru mechanism.

Changes v2
----------
1. Add bus_dsm_mask to filter root pass thru calls.

2. Add bus_dsm_mask_show to display bus_dsm_mask in sysfs

3. Extend override_dsm_mask to be used for bus_dms_mask also.

Details v1
----------

__nd_ioctl:
Check pass thru functions against nd_cmd_clear_to_send.

acpi_nfit_init_dsms:
Set additional bits in cmd_mask for new functions.

ndctl.h:
Define data structure for the new 6.2 functions.
Add new function names to nvdimm_bus_cmd_name.

Jerry Hoemann (7):
libnvdimm: passthru functions clear to send acpi, nfit: Enable DSM pass thru for root functions.
libnvdimm: Add bus level dsm mask.
acpi, nfit: Use bus_dsm_mask for passthru acpi, nfit: Show bus_dsm_mask
libnvdimm: New ACPI 6.2 DSM functions
acpi, nfit: override mask

 drivers/acpi/nfit/core.c   | 20 ++++++++++++++++++++
 drivers/nvdimm/bus.c       |  4 +++-
 include/linux/libnvdimm.h  |  1 +
 include/uapi/linux/ndctl.h | 41 ++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 64 insertions(+), 2 deletions(-)
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw

PATCH v2 1/7 libnvdimm: passthru functions clear to send

Have dsm functions called via the pass thru mechanism also be checked against clear to send.

---
 drivers/nvdimm/bus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvdimm/bus.c +3 -1
index e9361bf..e16427d 100644
@@ -907,6 +907,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 	static char in_env[ND_CMD_MAX_ENVELOPE];
 	const struct nd_cmd_desc *desc = NULL;
 	unsigned int cmd = _IOC_NR(ioctl_cmd);
+	unsigned int func = cmd;
 	void __user *p = (void __user *) arg;
 	struct device *dev = &nvdimm_bus->dev;
 	struct nd_cmd_pkg pkg;
@@ -972,6 +973,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 	}
 
 	if (cmd == ND_CMD_CALL) {
+		func = pkg.nd_command;
 		dev_dbg(dev, "%s:%s, idx: %llu, in: %zu, out: %zu, len %zu\n",
 				__func__, dimm_name, pkg.nd_command,
 				in_len, out_len, buf_len);
@@ -1020,7 +1022,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 	}
 
 	nvdimm_bus_lock(&nvdimm_bus->dev);
-	rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, cmd, buf);
+	rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, func, buf);
 	if (rc)
 		goto out_unlock;
 
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#2 lore raw

PATCH v2 2/7 acpi, nfit: Enable DSM pass thru for root functions.

In reply to Jerry Hoemann

Set ND_CMD_CALL in the cmd_mask to enable calling root functions via the pass trhu mechanism.

---
 drivers/acpi/nfit/core.c   | 1 +
 include/uapi/linux/ndctl.h | 1 +
 2 files changed, 2 insertions(+)
drivers/acpi/nfit/core.c +1 -0
index 656acb5..b46fca2 100644
@@ -1623,6 +1623,7 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 	for (i = ND_CMD_ARS_CAP; i <= ND_CMD_CLEAR_ERROR; i++)
 		if (acpi_check_dsm(adev->handle, uuid, 1, 1ULL << i))
 			set_bit(i, &nd_desc->cmd_mask);
+	set_bit(ND_CMD_CALL, &nd_desc->cmd_mask);
 }
 
 static ssize_t range_index_show(struct device *dev,
include/uapi/linux/ndctl.h +1 -0
index 7ad3863..e23c37f 100644
@@ -179,6 +179,7 @@ static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
 		[ND_CMD_ARS_START] = "ars_start",
 		[ND_CMD_ARS_STATUS] = "ars_status",
 		[ND_CMD_CLEAR_ERROR] = "clear_error",
+		[ND_CMD_CALL] = "cmd_call",
 	};
 
 	if (cmd < ARRAY_SIZE(names) && names[cmd])
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#3 lore raw

PATCH v2 3/7 libnvdimm: Add bus level dsm mask.

In reply to Jerry Hoemann

Add a bus level dsm_mask to nvdimm_bus_descriptor to allow the passthru calling mechanism to specify a different mask from the cmd_mask.

---
 include/linux/libnvdimm.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/libnvdimm.h +1 -0
index 6c80701..f8b8f43 100644
@@ -54,6 +54,7 @@ typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc,
 
 struct nvdimm_bus_descriptor {
 	const struct attribute_group **attr_groups;
+	unsigned long bus_dsm_mask;
 	unsigned long cmd_mask;
 	struct module *module;
 	char *provider_name;
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#4 lore raw

PATCH v2 4/7 acpi, nfit: Use bus_dsm_mask for passthru

In reply to Jerry Hoemann

Populate bus_dsm_mask and use it to filter dsm calls that user can make through the pass thru interface.

---
 drivers/acpi/nfit/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/nfit/core.c +4 -0
index b46fca2..9d281a4 100644
@@ -253,6 +253,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
 		cmd_name = nvdimm_bus_cmd_name(cmd);
 		cmd_mask = nd_desc->cmd_mask;
 		dsm_mask = cmd_mask;
+		if (cmd == ND_CMD_CALL) dsm_mask = nd_desc->bus_dsm_mask;
 		desc = nd_cmd_bus_desc(cmd);
 		uuid = to_nfit_uuid(NFIT_DEV_BUS);
 		handle = adev->handle;
@@ -1624,6 +1625,9 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 		if (acpi_check_dsm(adev->handle, uuid, 1, 1ULL << i))
 			set_bit(i, &nd_desc->cmd_mask);
 	set_bit(ND_CMD_CALL, &nd_desc->cmd_mask);
+	for (i = 0; i < ND_CMD_CALL; i++)
+		if (acpi_check_dsm(adev->handle, uuid, 1, 1ULL << i))
+			set_bit(i, &nd_desc->bus_dsm_mask);
 }
 
 static ssize_t range_index_show(struct device *dev,
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#6 lore raw

PATCH v2 5/7 acpi, nfit: Show bus_dsm_mask

In reply to Jerry Hoemann

Add bus_dsm_mask to sysfs display under /sys/bus/nd/devices/ndbusX/nfit.

---
 drivers/acpi/nfit/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/nfit/core.c +10 -0
index 9d281a4..f133b3e 100644
@@ -928,6 +928,15 @@ static int nfit_mem_init(struct acpi_nfit_desc *acpi_desc)
 	return 0;
 }
 
+static ssize_t bus_dsm_mask_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
+	struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus);
+	return sprintf(buf, "%#lx\n", nd_desc->bus_dsm_mask);
+}
+static DEVICE_ATTR_RO(bus_dsm_mask);
+
 static ssize_t revision_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
@@ -1064,6 +1073,7 @@ static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n)
 	&dev_attr_revision.attr,
 	&dev_attr_scrub.attr,
 	&dev_attr_hw_error_scrub.attr,
+	&dev_attr_bus_dsm_mask.attr,
 	NULL,
 };
 
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#11 lore raw

PATCH v2 6/7 libnvdimm: New ACPI 6.2 DSM functions

In reply to Jerry Hoemann

ACPI 6.2 added new NVDIMM root DSM functions. Define their data structures.

Update the definition of nd_cmd_ars_cap to match the 6.2 spec.

Add the new 6.2 functions names to nvdimm_bus_cmd_name.

---
 include/uapi/linux/ndctl.h | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
include/uapi/linux/ndctl.h +39 -1
index e23c37f..e15768f 100644
@@ -105,7 +105,8 @@ struct nd_cmd_ars_cap {
 	__u32 status;
 	__u32 max_ars_out;
 	__u32 clear_err_unit;
-	__u32 reserved;
+	__u16 flags;
+	__u16 reserved;
 } __packed;
 
 struct nd_cmd_ars_start {
@@ -144,6 +145,43 @@ struct nd_cmd_clear_error {
 	__u64 cleared;
 } __packed;
 
+struct nd_cmd_trans_spa {
+	__u64 spa;
+	__u32 status;
+	__u8  flags;
+	__u8  _reserved[3];
+	__u64 trans_length;
+	__u32 num_nvdimms;
+	struct nd_nvdimm_device {
+		__u32 nfit_device_handle;
+		__u32 _reserved;
+		__u64 dpa;
+	} __packed devices[0];
+
+} __packed;
+
+struct nd_cmd_ars_err_inj {
+	__u64 err_inj_spa_range_base;
+	__u64 err_inj_spa_range_length;
+	__u8  err_inj_options;
+	__u32 status;
+} __packed;
+
+struct nd_cmd_ars_err_inj_clr {
+	__u64 err_inj_clr_spa_range_base;
+	__u64 err_inj_clr_spa_range_length;
+	__u32 status;
+} __packed;
+
+struct nd_cmd_ars_err_inj_stat {
+	__u32 status;
+	__u32 inj_err_rec_count;
+	struct nd_error_stat_query_record {
+		__u64 err_inj_stat_spa_range_base;
+		__u64 err_inj_stat_spa_range_length;
+	} __packed record[0];
+} __packed;
+
 enum {
 	ND_CMD_IMPLEMENTED = 0,
 
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#13 lore raw

PATCH v2 7/7 acpi, nfit: override mask

In reply to Jerry Hoemann

Add module parameter override_dsm_mask_root for overriding the dsm_mask like we do for non-root dsm calls.

---
 drivers/acpi/nfit/core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/acpi/nfit/core.c +6 -1
index f133b3e..456fcc2 100644
@@ -1624,6 +1624,7 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 	struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc;
 	const u8 *uuid = to_nfit_uuid(NFIT_DEV_BUS);
 	struct acpi_device *adev;
+	unsigned long dsm_mask;
 	int i;
 
 	nd_desc->cmd_mask = acpi_desc->bus_cmd_force_en;
@@ -1635,7 +1636,11 @@ static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc)
 		if (acpi_check_dsm(adev->handle, uuid, 1, 1ULL << i))
 			set_bit(i, &nd_desc->cmd_mask);
 	set_bit(ND_CMD_CALL, &nd_desc->cmd_mask);
-	for (i = 0; i < ND_CMD_CALL; i++)
+
+	dsm_mask = 0x3bf;
+	if (override_dsm_mask)
+		dsm_mask = override_dsm_mask;
+	for_each_set_bit(i, &dsm_mask, BITS_PER_LONG)
 		if (acpi_check_dsm(adev->handle, uuid, 1, 1ULL << i))
 			set_bit(i, &nd_desc->bus_dsm_mask);
 }
Signature · 6 lines
1.8.5.6

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#14 lore raw
In reply to Jerry Hoemann
Quoted 6 lines · Jerry Hoemann

The new ACPI 6.2 spec has added new NVDIMM root DSM functions that managibility and test software needs to call.

This patch set enables the calling root functions DSM via the pass thru mechanism.

Quoted 8 lines

Changes v2
----------
1. Add bus_dsm_mask to filter root pass thru calls.

2. Add bus_dsm_mask_show to display bus_dsm_mask in sysfs

3. Extend override_dsm_mask to be used for bus_dms_mask also.

Dan,

Did you have any feedback?

Thanks

Jerry

Quoted 35 lines

Details v1
----------

__nd_ioctl:
Check pass thru functions against nd_cmd_clear_to_send.

acpi_nfit_init_dsms:
Set additional bits in cmd_mask for new functions.

ndctl.h:
Define data structure for the new 6.2 functions.
Add new function names to nvdimm_bus_cmd_name.

Jerry Hoemann (7):
libnvdimm: passthru functions clear to send acpi, nfit: Enable DSM pass thru for root functions.
libnvdimm: Add bus level dsm mask.
acpi, nfit: Use bus_dsm_mask for passthru acpi, nfit: Show bus_dsm_mask
libnvdimm: New ACPI 6.2 DSM functions
acpi, nfit: override mask

 drivers/acpi/nfit/core.c   | 20 ++++++++++++++++++++
 drivers/nvdimm/bus.c       |  4 +++-
 include/linux/libnvdimm.h  |  1 +
 include/uapi/linux/ndctl.h | 41 ++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 64 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.5.6
Signature · 7 lines
-----------------------------------------------------------------------------
Jerry Hoemann                  Software Engineer   Hewlett Packard Enterprise
-----------------------------------------------------------------------------
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#7 lore raw

Re: [PATCH v2 5/7] acpi, nfit: Show bus_dsm_mask

In reply to Jerry Hoemann
Quoted 28 lines · Jerry Hoemann

Add bus_dsm_mask to sysfs display under /sys/bus/nd/devices/ndbusX/nfit.

---
 drivers/acpi/nfit/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/nfit/core.c +9 -0
index 9d281a4..f133b3e 100644
@@ -928,6 +928,15 @@ static int nfit_mem_init(struct acpi_nfit_desc *acpi_desc)
        return 0;
 }
 
+static ssize_t bus_dsm_mask_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
+       struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus);
+       return sprintf(buf, "%#lx\n", nd_desc->bus_dsm_mask);
+}
+static DEVICE_ATTR_RO(bus_dsm_mask);
+
 static ssize_t revision_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {

drivers/acpi/nfit/core.c static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n) · line 1078

Quoted 6 lines
drivers/acpi/nfit/core.c +1 -0
@@ -1064,6 +1073,7 @@ static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n)
        &dev_attr_revision.attr,
        &dev_attr_scrub.attr,
        &dev_attr_hw_error_scrub.attr,
+       &dev_attr_bus_dsm_mask.attr,
        NULL,
 };

I think it's redundant to keep 'bus_' in the name of the attribute since 'bus' is included in the sysfs path. You can use DEVICE_ATTR() instead of DEVICE_ATTR_RO() to specify the attribute name manually, and get around the collision with the existing dsm_mash_show() routine.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#5 lore raw

Re: [PATCH v2 4/7] acpi, nfit: Use bus_dsm_mask for passthru

In reply to Jerry Hoemann
Quoted 13 lines · Jerry Hoemann

Populate bus_dsm_mask and use it to filter dsm calls that user can make through the pass thru interface.

---
 drivers/acpi/nfit/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/nfit/core.c +0 -0
index b46fca2..9d281a4 100644

drivers/acpi/nfit/core.c int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, · line 256

Quoted 4 lines
drivers/acpi/nfit/core.c +1 -0
@@ -253,6 +253,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
                cmd_name = nvdimm_bus_cmd_name(cmd);
                cmd_mask = nd_desc->cmd_mask;
                dsm_mask = cmd_mask;
+               if (cmd == ND_CMD_CALL) dsm_mask = nd_desc->bus_dsm_mask;

Checkpatch complains about this:

ERROR: trailing statements should be on next line #118: FILE: drivers/acpi/nfit/core.c:256:
+ if (cmd == ND_CMD_CALL) dsm_mask = nd_desc->bus_dsm_mask;
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#12 lore raw

Re: [PATCH v2 6/7] libnvdimm: New ACPI 6.2 DSM functions

In reply to Jerry Hoemann
Quoted 6 lines · Jerry Hoemann

ACPI 6.2 added new NVDIMM root DSM functions. Define their data structures.

Update the definition of nd_cmd_ars_cap to match the 6.2 spec.

Add the new 6.2 functions names to nvdimm_bus_cmd_name.

This part of the changelog is stale, just trim it when you resend the series with the other fixups.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#8 lore raw

Re: [PATCH v2 5/7] acpi, nfit: Show bus_dsm_mask

In reply to Dan Williams
Quoted 33 lines · Dan Williams
Quoted 32 lines · Jerry Hoemann

Add bus_dsm_mask to sysfs display under /sys/bus/nd/devices/ndbusX/nfit.

---
 drivers/acpi/nfit/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/nfit/core.c +10 -0
index 9d281a4..f133b3e 100644
@@ -928,6 +928,15 @@ static int nfit_mem_init(struct acpi_nfit_desc *acpi_desc)
        return 0;
 }
 
+static ssize_t bus_dsm_mask_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
+       struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus);
+       return sprintf(buf, "%#lx\n", nd_desc->bus_dsm_mask);
+}
+static DEVICE_ATTR_RO(bus_dsm_mask);
+
 static ssize_t revision_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
@@ -1064,6 +1073,7 @@ static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n)
        &dev_attr_revision.attr,
        &dev_attr_scrub.attr,
        &dev_attr_hw_error_scrub.attr,
+       &dev_attr_bus_dsm_mask.attr,
Quoted 8 lines

drivers/acpi/nfit/core.c static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n) · line 1078

Quoted 2 lines
drivers/acpi/nfit/core.c +0 -0
        NULL,
 };

I think it's redundant to keep 'bus_' in the name of the attribute since 'bus' is included in the sysfs path. You can use DEVICE_ATTR() instead of DEVICE_ATTR_RO() to specify the attribute name manually, and get around the collision with the existing dsm_mash_show() routine.

DEVICE_ATTR and DEVICE_ATTR_RO uses the same tokenization & stringification schemes, so that doesn't disambiguate. They need to be different case sensitive names if they are to be in same source file.

Do you want me to change name to root_dsm_mask? or change case: DSM_MASK?

Signature · 7 lines
-----------------------------------------------------------------------------
Jerry Hoemann                  Software Engineer   Hewlett Packard Enterprise
-----------------------------------------------------------------------------
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#9 lore raw

Re: [PATCH v2 5/7] acpi, nfit: Show bus_dsm_mask

Quoted 43 lines · Jerry Hoemann
Quoted 33 lines · Dan Williams
Quoted 32 lines · Jerry Hoemann

Add bus_dsm_mask to sysfs display under /sys/bus/nd/devices/ndbusX/nfit.

---
 drivers/acpi/nfit/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/nfit/core.c +10 -0
index 9d281a4..f133b3e 100644
@@ -928,6 +928,15 @@ static int nfit_mem_init(struct acpi_nfit_desc *acpi_desc)
        return 0;
 }
 
+static ssize_t bus_dsm_mask_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
+       struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus);
+       return sprintf(buf, "%#lx\n", nd_desc->bus_dsm_mask);
+}
+static DEVICE_ATTR_RO(bus_dsm_mask);
+
 static ssize_t revision_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
@@ -1064,6 +1073,7 @@ static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n)
        &dev_attr_revision.attr,
        &dev_attr_scrub.attr,
        &dev_attr_hw_error_scrub.attr,
+       &dev_attr_bus_dsm_mask.attr,
Quoted 8 lines

drivers/acpi/nfit/core.c static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n) · line 1078

Quoted 2 lines
drivers/acpi/nfit/core.c +0 -0
        NULL,
 };

I think it's redundant to keep 'bus_' in the name of the attribute since 'bus' is included in the sysfs path. You can use DEVICE_ATTR() instead of DEVICE_ATTR_RO() to specify the attribute name manually, and get around the collision with the existing dsm_mash_show() routine.

Quoted 5 lines

DEVICE_ATTR and DEVICE_ATTR_RO uses the same tokenization & stringification schemes, so that doesn't disambiguate. They need to be different case sensitive names if they are to be in same source file.

Do you want me to change name to root_dsm_mask? or change case: DSM_MASK?

I'm saying do something like this:

DEVICE_ATTR(dsm_mask, 0444, bus_dsm_mask_show, NULL)

...so that the attribute name in sysfs is just 'dsm_mask'.
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#10 lore raw

Re: [PATCH v2 5/7] acpi, nfit: Show bus_dsm_mask

Quoted 48 lines · Dan Williams
Quoted 47 lines · Jerry Hoemann
Quoted 33 lines · Dan Williams
Quoted 32 lines · Jerry Hoemann

Add bus_dsm_mask to sysfs display under /sys/bus/nd/devices/ndbusX/nfit.

---
 drivers/acpi/nfit/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/nfit/core.c +10 -0
index 9d281a4..f133b3e 100644
@@ -928,6 +928,15 @@ static int nfit_mem_init(struct acpi_nfit_desc *acpi_desc)
        return 0;
 }
 
+static ssize_t bus_dsm_mask_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
+       struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus);
+       return sprintf(buf, "%#lx\n", nd_desc->bus_dsm_mask);
+}
+static DEVICE_ATTR_RO(bus_dsm_mask);
+
 static ssize_t revision_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
@@ -1064,6 +1073,7 @@ static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n)
        &dev_attr_revision.attr,
        &dev_attr_scrub.attr,
        &dev_attr_hw_error_scrub.attr,
+       &dev_attr_bus_dsm_mask.attr,
Quoted 8 lines

drivers/acpi/nfit/core.c static umode_t nfit_visible(struct kobject *kobj, struct attribute *a, int n) · line 1078

Quoted 2 lines
drivers/acpi/nfit/core.c +0 -0
        NULL,
 };

I think it's redundant to keep 'bus_' in the name of the attribute since 'bus' is included in the sysfs path. You can use DEVICE_ATTR() instead of DEVICE_ATTR_RO() to specify the attribute name manually, and get around the collision with the existing dsm_mash_show() routine.

DEVICE_ATTR and DEVICE_ATTR_RO uses the same tokenization & stringification schemes, so that doesn't disambiguate. They need to be different case sensitive names if they are to be in same source file.

Quoted 7 lines
Quoted 1 line

Do you want me to change name to root_dsm_mask? or change case: DSM_MASK?

I'm saying do something like this:

   DEVICE_ATTR(dsm_mask, 0444, bus_dsm_mask_show, NULL)

...so that the attribute name in sysfs is just 'dsm_mask'.

Actually, you'll need to go further and use __ATTR() directly to initialize a bus_dsm_mask_attr.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm