Skip to content

Commit b39cb10

Browse files
committed
cxl/mem: Register CXL memX devices
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) * 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. However, going forward it will provide a mechanism to coordinate cross-device interleave. Signed-off-by: Ben Widawsky <ben.widawsky@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> (v2) Link: https://lore.kernel.org/r/20210217040958.1354670-4-ben.widawsky@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 8adaf74 commit b39cb10

6 files changed

Lines changed: 349 additions & 2 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
What: /sys/bus/cxl/devices/memX/firmware_version
2+
Date: December, 2020
3+
KernelVersion: v5.12
4+
Contact: linux-cxl@vger.kernel.org
5+
Description:
6+
(RO) "FW Revision" string as reported by the Identify
7+
Memory Device Output Payload in the CXL-2.0
8+
specification.
9+
10+
What: /sys/bus/cxl/devices/memX/ram/size
11+
Date: December, 2020
12+
KernelVersion: v5.12
13+
Contact: linux-cxl@vger.kernel.org
14+
Description:
15+
(RO) "Volatile Only Capacity" as bytes. Represents the
16+
identically named field in the Identify Memory Device Output
17+
Payload in the CXL-2.0 specification.
18+
19+
What: /sys/bus/cxl/devices/memX/pmem/size
20+
Date: December, 2020
21+
KernelVersion: v5.12
22+
Contact: linux-cxl@vger.kernel.org
23+
Description:
24+
(RO) "Persistent Only Capacity" as bytes. Represents the
25+
identically named field in the Identify Memory Device Output
26+
Payload in the CXL-2.0 specification.

‎Documentation/driver-api/cxl/memory-devices.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ CXL Memory Device
2727

2828
.. kernel-doc:: drivers/cxl/mem.c
2929
:internal:
30+
31+
CXL Bus
32+
-------
33+
.. kernel-doc:: drivers/cxl/bus.c
34+
:doc: cxl bus

‎drivers/cxl/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
obj-$(CONFIG_CXL_BUS) += cxl_bus.o
23
obj-$(CONFIG_CXL_MEM) += cxl_mem.o
34

5+
ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=CXL
6+
cxl_bus-y := bus.o
47
cxl_mem-y := mem.o

‎drivers/cxl/bus.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/* Copyright(c) 2020 Intel Corporation. All rights reserved. */
3+
#include <linux/device.h>
4+
#include <linux/module.h>
5+
6+
/**
7+
* DOC: cxl bus
8+
*
9+
* The CXL bus provides namespace for control devices and a rendezvous
10+
* point for cross-device interleave coordination.
11+
*/
12+
struct bus_type cxl_bus_type = {
13+
.name = "cxl",
14+
};
15+
EXPORT_SYMBOL_GPL(cxl_bus_type);
16+
17+
static __init int cxl_bus_init(void)
18+
{
19+
return bus_register(&cxl_bus_type);
20+
}
21+
22+
static void cxl_bus_exit(void)
23+
{
24+
bus_unregister(&cxl_bus_type);
25+
}
26+
27+
module_init(cxl_bus_init);
28+
module_exit(cxl_bus_exit);
29+
MODULE_LICENSE("GPL v2");

‎drivers/cxl/cxl.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
(FIELD_GET(CXLMDEV_RESET_NEEDED_MASK, status) != \
5858
CXLMDEV_RESET_NEEDED_NOT)
5959

60+
struct cxl_memdev;
6061
/**
6162
* struct cxl_mem - A CXL memory device
6263
* @pdev: The PCI device associated with this CXL device.
@@ -74,6 +75,7 @@
7475
struct cxl_mem {
7576
struct pci_dev *pdev;
7677
void __iomem *regs;
78+
struct cxl_memdev *cxlmd;
7779

7880
void __iomem *status_regs;
7981
void __iomem *mbox_regs;
@@ -87,4 +89,5 @@ struct cxl_mem {
8789
struct range ram_range;
8890
};
8991

92+
extern struct bus_type cxl_bus_type;
9093
#endif /* __CXL_H__ */

0 commit comments

Comments
 (0)