Skip to content

Commit 05e37b2

Browse files
davejiangdjbw
authored andcommitted
cxl: Add decoders_committed sysfs attribute to cxl_port
This attribute allows cxl-cli to determine whether there are decoders committed to a memdev. This is only a snapshot of the state, and doesn't offer any protection or serialization against a concurrent disable-region operation. Reviewed-by: Jim Harris <jim.harris@samsung.com> Suggested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/169747907439.272156.10261062080830155662.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 458ba81 commit 05e37b2

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Documentation/ABI/testing/sysfs-bus-cxl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,21 @@ Description:
178178
hardware decoder target list.
179179

180180

181+
What: /sys/bus/cxl/devices/portX/decoders_committed
182+
Date: October, 2023
183+
KernelVersion: v6.7
184+
Contact: linux-cxl@vger.kernel.org
185+
Description:
186+
(RO) A memory device is considered active when any of its
187+
decoders are in the "committed" state (See CXL 3.0 8.2.4.19.7
188+
CXL HDM Decoder n Control Register). Hotplug and destructive
189+
operations like "sanitize" are blocked while device is actively
190+
decoding a Host Physical Address range. Note that this number
191+
may be elevated without any regionX objects active or even
192+
enumerated, as this may be due to decoders established by
193+
platform firwmare or a previous kernel (kexec).
194+
195+
181196
What: /sys/bus/cxl/devices/decoderX.Y
182197
Date: June, 2021
183198
KernelVersion: v5.14

drivers/cxl/core/port.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,33 @@ static void cxl_port_release(struct device *dev)
534534
kfree(port);
535535
}
536536

537+
static ssize_t decoders_committed_show(struct device *dev,
538+
struct device_attribute *attr, char *buf)
539+
{
540+
struct cxl_port *port = to_cxl_port(dev);
541+
int rc;
542+
543+
down_read(&cxl_region_rwsem);
544+
rc = sysfs_emit(buf, "%d\n", cxl_num_decoders_committed(port));
545+
up_read(&cxl_region_rwsem);
546+
547+
return rc;
548+
}
549+
550+
static DEVICE_ATTR_RO(decoders_committed);
551+
552+
static struct attribute *cxl_port_attrs[] = {
553+
&dev_attr_decoders_committed.attr,
554+
NULL,
555+
};
556+
557+
static struct attribute_group cxl_port_attribute_group = {
558+
.attrs = cxl_port_attrs,
559+
};
560+
537561
static const struct attribute_group *cxl_port_attribute_groups[] = {
538562
&cxl_base_attribute_group,
563+
&cxl_port_attribute_group,
539564
NULL,
540565
};
541566

0 commit comments

Comments
 (0)