diff mbox series

[2/4] cxl/core: Add more decoder attributes to sysfs

Message ID 20220127212911.127741-3-ben.widawsky@intel.com
State New, archived
Headers show
Series Unify meaning of interleave attributes | expand

Commit Message

Ben Widawsky Jan. 27, 2022, 9:29 p.m. UTC
The decoder attributes are consumed by userspace in order to program and
verify the CXL topology.

An example of the new attributes is with x1 and 8192 granularity:
archlinux ~ # cat /sys/bus/cxl/devices/decoder0.0/interleave_{ways,granularity}
1
8192

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
---
 drivers/cxl/core/port.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Dan Williams Jan. 27, 2022, 10:45 p.m. UTC | #1
On Thu, Jan 27, 2022 at 1:29 PM Ben Widawsky <ben.widawsky@intel.com> wrote:
>
> The decoder attributes are consumed by userspace in order to program and
> verify the CXL topology.
>
> An example of the new attributes is with x1 and 8192 granularity:
> archlinux ~ # cat /sys/bus/cxl/devices/decoder0.0/interleave_{ways,granularity}
> 1
> 8192
>
> Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
> ---
>  drivers/cxl/core/port.c | 21 +++++++++++++++++++++

Looks good, just missing the update to Documentation/ABI/testing/sysfs-bus-cxl
diff mbox series

Patch

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index f49783d8c845..631dec0fa79e 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -99,6 +99,25 @@  static ssize_t size_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(size);
 
+static ssize_t interleave_ways_show(struct device *dev,
+				    struct device_attribute *attr, char *buf)
+{
+	struct cxl_decoder *cxld = to_cxl_decoder(dev);
+
+	return sysfs_emit(buf, "%d\n", cxld->interleave_ways);
+}
+static DEVICE_ATTR_RO(interleave_ways);
+
+static ssize_t interleave_granularity_show(struct device *dev,
+					   struct device_attribute *attr,
+					   char *buf)
+{
+	struct cxl_decoder *cxld = to_cxl_decoder(dev);
+
+	return sysfs_emit(buf, "%d\n", cxld->interleave_granularity);
+}
+static DEVICE_ATTR_RO(interleave_granularity);
+
 #define CXL_DECODER_FLAG_ATTR(name, flag)                            \
 static ssize_t name##_show(struct device *dev,                       \
 			   struct device_attribute *attr, char *buf) \
@@ -186,6 +205,8 @@  static struct attribute *cxl_decoder_base_attrs[] = {
 	&dev_attr_start.attr,
 	&dev_attr_size.attr,
 	&dev_attr_locked.attr,
+	&dev_attr_interleave_ways.attr,
+	&dev_attr_interleave_granularity.attr,
 	NULL,
 };