1 .. SPDX-License-Identifier: GPL-2.0
2 .. include:: <isonum.txt>
4 ===================================
5 Compute Express Link Memory Devices
6 ===================================
8 A Compute Express Link Memory Device is a CXL component that implements the
9 CXL.mem protocol. It contains some amount of volatile memory, persistent memory,
10 or both. It is enumerated as a PCI device for configuration and passing
11 messages over an MMIO mailbox. Its contribution to the System Physical
12 Address space is handled via HDM (Host Managed Device Memory) decoders
13 that optionally define a device's contribution to an interleaved address
14 range across multiple devices underneath a host-bridge or interleaved
17 CXL Bus: Theory of Operation
18 ============================
19 Similar to how a RAID driver takes disk objects and assembles them into a new
20 logical device, the CXL subsystem is tasked to take PCIe and ACPI objects and
21 assemble them into a CXL.mem decode topology. The need for runtime configuration
22 of the CXL.mem topology is also similar to RAID in that different environments
23 with the same hardware configuration may decide to assemble the topology in
24 contrasting ways. One may choose performance (RAID0) striping memory across
25 multiple Host Bridges and endpoints while another may opt for fault tolerance
26 and disable any striping in the CXL.mem topology.
28 Platform firmware enumerates a menu of interleave options at the "CXL root port"
29 (Linux term for the top of the CXL decode topology). From there, PCIe topology
30 dictates which endpoints can participate in which Host Bridge decode regimes.
31 Each PCIe Switch in the path between the root and an endpoint introduces a point
32 at which the interleave can be split. For example platform firmware may say at a
33 given range only decodes to 1 one Host Bridge, but that Host Bridge may in turn
34 interleave cycles across multiple Root Ports. An intervening Switch between a
35 port and an endpoint may interleave cycles across multiple Downstream Switch
38 Here is a sample listing of a CXL topology defined by 'cxl_test'. The 'cxl_test'
39 module generates an emulated CXL topology of 2 Host Bridges each with 2 Root
40 Ports. Each of those Root Ports are connected to 2-way switches with endpoints
41 connected to those downstream ports for a total of 8 endpoints::
43 # cxl list -BEMPu -b cxl_test
46 "provider":"cxl_test",
50 "host":"cxl_host_bridge.1",
54 "host":"cxl_switch_uport.1",
57 "endpoint":"endpoint9",
61 "pmem_size":"256.00 MiB (268.44 MB)",
62 "ram_size":"256.00 MiB (268.44 MB)",
69 "endpoint":"endpoint15",
73 "pmem_size":"256.00 MiB (268.44 MB)",
74 "ram_size":"256.00 MiB (268.44 MB)",
84 "host":"cxl_switch_uport.3",
87 "endpoint":"endpoint17",
91 "pmem_size":"256.00 MiB (268.44 MB)",
92 "ram_size":"256.00 MiB (268.44 MB)",
99 "endpoint":"endpoint13",
103 "pmem_size":"256.00 MiB (268.44 MB)",
104 "ram_size":"256.00 MiB (268.44 MB)",
116 "host":"cxl_host_bridge.0",
120 "host":"cxl_switch_uport.0",
123 "endpoint":"endpoint7",
127 "pmem_size":"256.00 MiB (268.44 MB)",
128 "ram_size":"256.00 MiB (268.44 MB)",
135 "endpoint":"endpoint14",
139 "pmem_size":"256.00 MiB (268.44 MB)",
140 "ram_size":"256.00 MiB (268.44 MB)",
150 "host":"cxl_switch_uport.2",
153 "endpoint":"endpoint16",
157 "pmem_size":"256.00 MiB (268.44 MB)",
158 "ram_size":"256.00 MiB (268.44 MB)",
165 "endpoint":"endpoint11",
169 "pmem_size":"256.00 MiB (268.44 MB)",
170 "ram_size":"256.00 MiB (268.44 MB)",
183 In that listing each "root", "port", and "endpoint" object correspond a kernel
184 'struct cxl_port' object. A 'cxl_port' is a device that can decode CXL.mem to
185 its descendants. So "root" claims non-PCIe enumerable platform decode ranges and
186 decodes them to "ports", "ports" decode to "endpoints", and "endpoints"
187 represent the decode from SPA (System Physical Address) to DPA (Device Physical
190 Continuing the RAID analogy, disks have both topology metadata and on device
191 metadata that determine RAID set assembly. CXL Port topology and CXL Port link
192 status is metadata for CXL.mem set assembly. The CXL Port topology is enumerated
193 by the arrival of a CXL.mem device. I.e. unless and until the PCIe core attaches
194 the cxl_pci driver to a CXL Memory Expander there is no role for CXL Port
195 objects. Conversely for hot-unplug / removal scenarios, there is no need for
196 the Linux PCI core to tear down switch-level CXL resources because the endpoint
197 ->remove() event cleans up the port data that was established to support that
200 The port metadata and potential decode schemes that a give memory device may
201 participate can be determined via a command like::
203 # cxl list -BDMu -d root -m mem3
206 "provider":"cxl_test",
209 "decoder":"decoder3.1",
210 "resource":"0x8030000000",
211 "size":"512.00 MiB (536.87 MB)",
212 "volatile_capable":true,
216 "decoder":"decoder3.3",
217 "resource":"0x8060000000",
218 "size":"512.00 MiB (536.87 MB)",
223 "decoder":"decoder3.0",
224 "resource":"0x8020000000",
225 "size":"256.00 MiB (268.44 MB)",
226 "volatile_capable":true,
230 "decoder":"decoder3.2",
231 "resource":"0x8050000000",
232 "size":"256.00 MiB (268.44 MB)",
240 "pmem_size":"256.00 MiB (268.44 MB)",
241 "ram_size":"256.00 MiB (268.44 MB)",
249 ...which queries the CXL topology to ask "given CXL Memory Expander with a kernel
250 device name of 'mem3' which platform level decode ranges may this device
251 participate". A given expander can participate in multiple CXL.mem interleave
252 sets simultaneously depending on how many decoder resource it has. In this
253 example mem3 can participate in one or more of a PMEM interleave that spans to
254 Host Bridges, a PMEM interleave that targets a single Host Bridge, a Volatile
255 memory interleave that spans 2 Host Bridges, and a Volatile memory interleave
256 that only targets a single Host Bridge.
258 Conversely the memory devices that can participate in a given platform level
259 decode scheme can be determined via a command like the following::
261 # cxl list -MDu -d 3.2
267 "pmem_size":"256.00 MiB (268.44 MB)",
268 "ram_size":"256.00 MiB (268.44 MB)",
275 "pmem_size":"256.00 MiB (268.44 MB)",
276 "ram_size":"256.00 MiB (268.44 MB)",
283 "pmem_size":"256.00 MiB (268.44 MB)",
284 "ram_size":"256.00 MiB (268.44 MB)",
291 "pmem_size":"256.00 MiB (268.44 MB)",
292 "ram_size":"256.00 MiB (268.44 MB)",
302 "decoder":"decoder3.2",
303 "resource":"0x8050000000",
304 "size":"256.00 MiB (268.44 MB)",
312 ...where the naming scheme for decoders is "decoder<port_id>.<instance_id>".
314 Driver Infrastructure
315 =====================
317 This section covers the driver infrastructure for a CXL memory device.
322 .. kernel-doc:: drivers/cxl/pci.c
325 .. kernel-doc:: drivers/cxl/pci.c
328 .. kernel-doc:: drivers/cxl/mem.c
333 .. kernel-doc:: drivers/cxl/port.c
338 .. kernel-doc:: drivers/cxl/cxl.h
341 .. kernel-doc:: drivers/cxl/cxl.h
344 .. kernel-doc:: drivers/cxl/core/port.c
347 .. kernel-doc:: drivers/cxl/core/port.c
350 .. kernel-doc:: drivers/cxl/core/pci.c
353 .. kernel-doc:: drivers/cxl/core/pci.c
356 .. kernel-doc:: drivers/cxl/core/pmem.c
359 .. kernel-doc:: drivers/cxl/core/regs.c
362 .. kernel-doc:: drivers/cxl/core/mbox.c
371 .. kernel-doc:: include/uapi/linux/cxl_mem.h
374 .. kernel-doc:: include/uapi/linux/cxl_mem.h