Re: [RFC PATCH v3 08/16] cxl/mem: Register CXL memX devices
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Date: 2021-01-14 16:30:01
Also in:
linux-pci, lkml
On Mon, 11 Jan 2021 14:51:12 -0800 Ben Widawsky [off-list ref] wrote:
From: Dan Williams <redacted> Create the /sys/bus/cxl hierarchy to enumerate memory devices (per-endpoint control devices), memory address space devices (platform address ranges with interleaving, performance, and persistence attributes), and memory regions (active provisioned memory from an address space device that is in use as System RAM or delegated to libnvdimm as Persistent Memory regions). For now, only the per-endpoint control devices are registered on the 'cxl' bus. Signed-off-by: Dan Williams <redacted> Signed-off-by: Ben Widawsky <redacted>
Don't hide the driver core change inside a patch doing other stuff. (it is a nice change though!) Otherwise, just a request for units in the sysfs ABI docs. Jonathan
quoted hunk ↗ jump to hunk
--- Documentation/ABI/testing/sysfs-bus-cxl | 26 +++ Documentation/cxl/memory-devices.rst | 3 + drivers/base/core.c | 14 ++ drivers/cxl/Makefile | 2 + drivers/cxl/bus.c | 54 +++++ drivers/cxl/bus.h | 8 + drivers/cxl/cxl.h | 3 + drivers/cxl/mem.c | 282 +++++++++++++++++++++++- include/linux/device.h | 1 + 9 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-cxl create mode 100644 drivers/cxl/bus.c create mode 100644 drivers/cxl/bus.hdiff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl new file mode 100644 index 000000000000..fe7b87eba988 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-cxl@@ -0,0 +1,26 @@ +What: /sys/bus/cxl/devices/memX/firmware_version +Date: December, 2020 +KernelVersion: v5.12 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) "FW Revision" string as reported by the Identify + Memory Device Output Payload in the CXL-2.0 + specification. + +What: /sys/bus/cxl/devices/memX/ram/size +Date: December, 2020 +KernelVersion: v5.12 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) "Volatile Only Capacity" as reported by the + Identify Memory Device Output Payload in the CXL-2.0 + specification.
Nice to see the format /units of these described in this doc as well as the spec. Section number etc also good if you can add it to these docs.
quoted hunk ↗ jump to hunk
+ +What: /sys/bus/cxl/devices/memX/pmem/size +Date: December, 2020 +KernelVersion: v5.12 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) "Persistent Only Capacity" as reported by the + Identify Memory Device Output Payload in the CXL-2.0 + specification.diff --git a/Documentation/cxl/memory-devices.rst b/Documentation/cxl/memory-devices.rst index 134c9b6b4ff4..5f723c25382b 100644 --- a/Documentation/cxl/memory-devices.rst +++ b/Documentation/cxl/memory-devices.rst@@ -37,3 +37,6 @@ External Interfaces .. kernel-doc:: drivers/cxl/acpi.c :export: + +.. kernel-doc:: drivers/cxl/bus.c + :export:diff --git a/drivers/base/core.c b/drivers/base/core.c index 25e08e5f40bd..33432a4cbe23 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c@@ -3179,6 +3179,20 @@ struct device *get_device(struct device *dev) } EXPORT_SYMBOL_GPL(get_device); +/** + * get_live_device() - increment reference count for device iff !dead + * @dev: device. + * + * Forward the call to get_device() if the device is still alive. If + * this is called with the device_lock() held then the device is + * guaranteed to not die until the device_lock() is dropped. + */
I like the idea of a nice generic wrapper for this but definitely not deep inside a patch doing something else.
+struct device *get_live_device(struct device *dev)
+{
+ return dev && !dev->p->dead ? get_device(dev) : NULL;
+}
+EXPORT_SYMBOL_GPL(get_live_device);
+...