Skip to content

Commit d41e583

Browse files
committed
Merge tag 'cxl-for-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull CXL updates from Dave Jiang: "The most significant changes in this pull request is the series that introduces ACQUIRE() and ACQUIRE_ERR() macros to replace conditional locking and ease the pain points of scoped_cond_guard(). The series also includes follow on changes that refactor the CXL sub-system to utilize the new macros. Detail summary: - Add documentation template for CXL conventions to document CXL platform quirks - Replace mutex_lock_io() with mutex_lock() for mailbox - Add location limit for fake CFMWS range for cxl_test, ARM platform enabling - CXL documentation typo and clarity fixes - Use correct format specifier for function cxl_set_ecs_threshold() - Make cxl_bus_type constant - Introduce new helper cxl_resource_contains_addr() to check address availability - Fix wrong DPA checking for PPR operation - Remove core/acpi.c and CXL core dependency on ACPI - Introduce ACQUIRE() and ACQUIRE_ERR() for conditional locks - Add CXL updates utilizing ACQUIRE() macro to remove gotos and improve readability - Add return for the dummy version of cxl_decoder_detach() without CONFIG_CXL_REGION - CXL events updates for spec r3.2 - Fix return of __cxl_decoder_detach() error path - CXL debugfs documentation fix" * tag 'cxl-for-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: (28 commits) Documentation/ABI/testing/debugfs-cxl: Add 'cxl' to clear_poison path cxl/region: Fix an ERR_PTR() vs NULL bug cxl/events: Trace Memory Sparing Event Record cxl/events: Add extra validity checks for CVME count in DRAM Event Record cxl/events: Add extra validity checks for corrected memory error count in General Media Event Record cxl/events: Update Common Event Record to CXL spec rev 3.2 cxl: Fix -Werror=return-type in cxl_decoder_detach() cleanup: Fix documentation build error for ACQUIRE updates cxl: Convert to ACQUIRE() for conditional rwsem locking cxl/region: Consolidate cxl_decoder_kill_region() and cxl_region_detach() cxl/region: Move ready-to-probe state check to a helper cxl/region: Split commit_store() into __commit() and queue_reset() helpers cxl/decoder: Drop pointless locking cxl/decoder: Move decoder register programming to a helper cxl/mbox: Convert poison list mutex to ACQUIRE() cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() for conditional locks cxl: Remove core/acpi.c and cxl core dependency on ACPI cxl/core: Using cxl_resource_contains_addr() to check address availability cxl/edac: Fix wrong dpa checking for PPR operation cxl/core: Introduce a new helper cxl_resource_contains_addr() ...
2 parents 1118574 + f11a5f8 commit d41e583

File tree

28 files changed

+827
-453
lines changed

28 files changed

+827
-453
lines changed

Documentation/ABI/testing/debugfs-cxl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Description:
2020
visible for devices supporting the capability.
2121

2222

23-
What: /sys/kernel/debug/memX/clear_poison
23+
What: /sys/kernel/debug/cxl/memX/clear_poison
2424
Date: April, 2023
2525
KernelVersion: v6.4
2626
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
.. include:: <isonum.txt>
3+
4+
=======================================
5+
Compute Express Link: Linux Conventions
6+
=======================================
7+
8+
There exists shipping platforms that bend or break CXL specification
9+
expectations. Record the details and the rationale for those deviations.
10+
Borrow the ACPI Code First template format to capture the assumptions
11+
and tradeoffs such that multiple platform implementations can follow the
12+
same convention.
13+
14+
<(template) Title>
15+
==================
16+
17+
Document
18+
--------
19+
CXL Revision <rev>, Version <ver>
20+
21+
License
22+
-------
23+
SPDX-License Identifier: CC-BY-4.0
24+
25+
Creator/Contributors
26+
--------------------
27+
28+
Summary of the Change
29+
---------------------
30+
31+
<Detail the conflict with the specification and where available the
32+
assumptions and tradeoffs taken by the hardware platform.>
33+
34+
35+
Benefits of the Change
36+
----------------------
37+
38+
<Detail what happens if platforms and Linux do not adopt this
39+
convention.>
40+
41+
References
42+
----------
43+
44+
Detailed Description of the Change
45+
----------------------------------
46+
47+
<Propose spec language that corrects the conflict.>

Documentation/driver-api/cxl/devices/device-types.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ A Type-2 CXL Device:
6363

6464
* Supports cxl.io, cxl.cache, and cxl.mem protocols
6565
* Optionally implements coherent cache and Host-Managed Device Memory
66-
* Is typically an accelerator device w/ high bandwidth memory.
66+
* Is typically an accelerator device with high bandwidth memory.
6767

6868
The primary difference between a type-1 and type-2 device is the presence
6969
of host-managed device memory, which allows the device to operate on a
70-
local memory bank - while the CPU sill has coherent DMA to the same memory.
70+
local memory bank - while the CPU still has coherent DMA to the same memory.
7171

72-
The allows things like GPUs to expose their memory via DAX devices or file
72+
This allows things like GPUs to expose their memory via DAX devices or file
7373
descriptors, allows drivers and programs direct access to device memory
7474
rather than use block-transfer semantics.
7575

@@ -89,7 +89,7 @@ basic coherent DMA.
8989
Switch
9090
------
9191

92-
A CXL switch is a device capacity of routing any CXL (and by extension, PCIe)
92+
A CXL switch is a device capable of routing any CXL (and by extension, PCIe)
9393
protocol between an upstream, downstream, or peer devices. Many devices, such
9494
as Multi-Logical Devices, imply the presence of switching in some manner.
9595

@@ -103,7 +103,7 @@ A Single-Logical Device (SLD) is a device which presents a single device to
103103
one or more heads.
104104

105105
A Multi-Logical Device (MLD) is a device which may present multiple devices
106-
to one or more devices.
106+
to one or more upstream devices.
107107

108108
A Single-Headed Device exposes only a single physical connection.
109109

Documentation/driver-api/cxl/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ that have impacts on each other. The docs here break up configurations steps.
1414

1515
theory-of-operation
1616
maturity-map
17+
conventions
1718

1819
.. toctree::
1920
:maxdepth: 2

Documentation/driver-api/cxl/linux/cxl-driver.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The CXL driver is split into a number of drivers.
2020
* cxl_port - initializes root and provides port enumeration interface.
2121
* cxl_acpi - initializes root decoders and interacts with ACPI data.
2222
* cxl_p/mem - initializes memory devices
23-
* cxl_pci - uses cxl_port to enumates the actual fabric hierarchy.
23+
* cxl_pci - uses cxl_port to enumerate the actual fabric hierarchy.
2424

2525
Driver Devices
2626
==============

Documentation/driver-api/cxl/theory-of-operation.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Platform firmware enumerates a menu of interleave options at the "CXL root port"
2929
(Linux term for the top of the CXL decode topology). From there, PCIe topology
3030
dictates which endpoints can participate in which Host Bridge decode regimes.
3131
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
32+
at which the interleave can be split. For example, platform firmware may say a
33+
given range only decodes to one Host Bridge, but that Host Bridge may in turn
3434
interleave cycles across multiple Root Ports. An intervening Switch between a
3535
port and an endpoint may interleave cycles across multiple Downstream Switch
3636
Ports, etc.
@@ -187,7 +187,7 @@ decodes them to "ports", "ports" decode to "endpoints", and "endpoints"
187187
represent the decode from SPA (System Physical Address) to DPA (Device Physical
188188
Address).
189189

190-
Continuing the RAID analogy, disks have both topology metadata and on device
190+
Continuing the RAID analogy, disks have both topology metadata and on-device
191191
metadata that determine RAID set assembly. CXL Port topology and CXL Port link
192192
status is metadata for CXL.mem set assembly. The CXL Port topology is enumerated
193193
by the arrival of a CXL.mem device. I.e. unless and until the PCIe core attaches
@@ -197,7 +197,7 @@ the Linux PCI core to tear down switch-level CXL resources because the endpoint
197197
->remove() event cleans up the port data that was established to support that
198198
Memory Expander.
199199

200-
The port metadata and potential decode schemes that a give memory device may
200+
The port metadata and potential decode schemes that a given memory device may
201201
participate can be determined via a command like::
202202

203203
# cxl list -BDMu -d root -m mem3
@@ -249,8 +249,8 @@ participate can be determined via a command like::
249249
...which queries the CXL topology to ask "given CXL Memory Expander with a kernel
250250
device name of 'mem3' which platform level decode ranges may this device
251251
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
252+
sets simultaneously depending on how many decoder resources it has. In this
253+
example mem3 can participate in one or more of a PMEM interleave that spans two
254254
Host Bridges, a PMEM interleave that targets a single Host Bridge, a Volatile
255255
memory interleave that spans 2 Host Bridges, and a Volatile memory interleave
256256
that only targets a single Host Bridge.

drivers/cxl/acpi.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,63 @@ static int add_or_reset_cxl_resource(struct resource *parent, struct resource *r
335335
return rc;
336336
}
337337

338+
static int cxl_acpi_set_cache_size(struct cxl_root_decoder *cxlrd)
339+
{
340+
struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld;
341+
struct range *hpa = &cxld->hpa_range;
342+
resource_size_t size = range_len(hpa);
343+
resource_size_t start = hpa->start;
344+
resource_size_t cache_size;
345+
struct resource res;
346+
int nid, rc;
347+
348+
res = DEFINE_RES(start, size, 0);
349+
nid = phys_to_target_node(start);
350+
351+
rc = hmat_get_extended_linear_cache_size(&res, nid, &cache_size);
352+
if (rc)
353+
return rc;
354+
355+
/*
356+
* The cache range is expected to be within the CFMWS.
357+
* Currently there is only support cache_size == cxl_size. CXL
358+
* size is then half of the total CFMWS window size.
359+
*/
360+
size = size >> 1;
361+
if (cache_size && size != cache_size) {
362+
dev_warn(&cxld->dev,
363+
"Extended Linear Cache size %pa != CXL size %pa. No Support!",
364+
&cache_size, &size);
365+
return -ENXIO;
366+
}
367+
368+
cxlrd->cache_size = cache_size;
369+
370+
return 0;
371+
}
372+
373+
static void cxl_setup_extended_linear_cache(struct cxl_root_decoder *cxlrd)
374+
{
375+
int rc;
376+
377+
rc = cxl_acpi_set_cache_size(cxlrd);
378+
if (!rc)
379+
return;
380+
381+
if (rc != -EOPNOTSUPP) {
382+
/*
383+
* Failing to support extended linear cache region resize does not
384+
* prevent the region from functioning. Only causes cxl list showing
385+
* incorrect region size.
386+
*/
387+
dev_warn(cxlrd->cxlsd.cxld.dev.parent,
388+
"Extended linear cache calculation failed rc:%d\n", rc);
389+
}
390+
391+
/* Ignoring return code */
392+
cxlrd->cache_size = 0;
393+
}
394+
338395
DEFINE_FREE(put_cxlrd, struct cxl_root_decoder *,
339396
if (!IS_ERR_OR_NULL(_T)) put_device(&_T->cxlsd.cxld.dev))
340397
DEFINE_FREE(del_cxl_resource, struct resource *, if (_T) del_cxl_resource(_T))
@@ -394,6 +451,8 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
394451
ig = CXL_DECODER_MIN_GRANULARITY;
395452
cxld->interleave_granularity = ig;
396453

454+
cxl_setup_extended_linear_cache(cxlrd);
455+
397456
if (cfmws->interleave_arithmetic == ACPI_CEDT_CFMWS_ARITHMETIC_XOR) {
398457
if (ways != 1 && ways != 3) {
399458
cxims_ctx = (struct cxl_cxims_context) {

drivers/cxl/core/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ cxl_core-y += hdm.o
1515
cxl_core-y += pmu.o
1616
cxl_core-y += cdat.o
1717
cxl_core-y += ras.o
18-
cxl_core-y += acpi.o
1918
cxl_core-$(CONFIG_TRACING) += trace.o
2019
cxl_core-$(CONFIG_CXL_REGION) += region.o
2120
cxl_core-$(CONFIG_CXL_MCE) += mce.o

drivers/cxl/core/acpi.c

Lines changed: 0 additions & 11 deletions
This file was deleted.

drivers/cxl/core/cdat.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int match_cxlrd_hb(struct device *dev, void *data)
336336
cxlrd = to_cxl_root_decoder(dev);
337337
cxlsd = &cxlrd->cxlsd;
338338

339-
guard(rwsem_read)(&cxl_region_rwsem);
339+
guard(rwsem_read)(&cxl_rwsem.region);
340340
for (int i = 0; i < cxlsd->nr_targets; i++) {
341341
if (host_bridge == cxlsd->target[i]->dport_dev)
342342
return 1;
@@ -987,7 +987,7 @@ void cxl_region_shared_upstream_bandwidth_update(struct cxl_region *cxlr)
987987
bool is_root;
988988
int rc;
989989

990-
lockdep_assert_held(&cxl_dpa_rwsem);
990+
lockdep_assert_held(&cxl_rwsem.dpa);
991991

992992
struct xarray *usp_xa __free(free_perf_xa) =
993993
kzalloc(sizeof(*usp_xa), GFP_KERNEL);
@@ -1057,7 +1057,7 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
10571057
{
10581058
struct cxl_dpa_perf *perf;
10591059

1060-
lockdep_assert_held(&cxl_dpa_rwsem);
1060+
lockdep_assert_held(&cxl_rwsem.dpa);
10611061

10621062
perf = cxled_get_dpa_perf(cxled);
10631063
if (IS_ERR(perf))

0 commit comments

Comments
 (0)