Skip to content

Commit 01ecadb

Browse files
committed
Merge tag 'cxl-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull Compute Express Link (CXL) updates from Dave Jiang: - Add support for Global Persistent Flush (GPF) - Cleanup of DPA partition metadata handling: - Remove the CXL_DECODER_MIXED enum that's not needed anymore - Introduce helpers to access resource and perf meta data - Introduce 'struct cxl_dpa_partition' and 'struct cxl_range_info' - Make cxl_dpa_alloc() DPA partition number agnostic - Remove cxl_decoder_mode - Cleanup partition size and perf helpers - Remove unused CXL partition values - Add logging support for CXL CPER endpoint and port protocol errors: - Prefix protocol error struct and function names with cxl_ - Move protocol error definitions and structures to a common location - Remove drivers/firmware/efi/cper_cxl.h to include/linux/cper.h - Add support in GHES to process CXL CPER protocol errors - Process CXL CPER protocol errors - Add trace logging for CXL PCIe port RAS errors - Remove redundant gp_port init - Add validation of cxl device serial number - CXL ABI documentation updates/fixups - A series that uses guard() to clean up open coded mutex lockings and remove gotos for error handling. - Some followup patches to support dirty shutdown accounting: - Add helper to retrieve DVSEC offset for dirty shutdown registers - Rename cxl_get_dirty_shutdown() to cxl_arm_dirty_shutdown() - Add support for dirty shutdown count via sysfs - cxl_test support for dirty shutdown - A series to support CXL mailbox Features commands. Mostly in preparation for CXL EDAC code to utilize the Features commands. It's also in preparation for CXL fwctl support to utilize the CXL Features. The commands include "Get Supported Features", "Get Feature", and "Set Feature". - A series to support extended linear cache support described by the ACPI HMAT table. The addition helps enumerate the cache and also provides additional RAS reporting support for configuration with extended linear cache. (and related fixes for the series). - An update to cxl_test to support a 3-way capable CFMWS - A documentation fix to remove unused "mixed mode" * tag 'cxl-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: (39 commits) cxl/region: Fix the first aliased address miscalculation cxl/region: Quiet some dev_warn()s in extended linear cache setup cxl/Documentation: Remove 'mixed' from sysfs mode doc cxl: Fix warning from emitting resource_size_t as long long int on 32bit systems cxl/test: Define a CFMWS capable of a 3 way HB interleave cxl/mem: Do not return error if CONFIG_CXL_MCE unset tools/testing/cxl: Set Shutdown State support cxl/pmem: Export dirty shutdown count via sysfs cxl/pmem: Rename cxl_dirty_shutdown_state() cxl/pci: Introduce cxl_gpf_get_dvsec() cxl/pci: Support Global Persistent Flush (GPF) cxl: Document missing sysfs files cxl: Plug typos in ABI doc cxl/pmem: debug invalid serial number data cxl/cdat: Remove redundant gp_port initialization cxl/memdev: Remove unused partition values cxl/region: Drop goto pattern of construct_region() cxl/region: Drop goto pattern in cxl_dax_region_alloc() cxl/core: Use guard() to drop goto pattern of cxl_dpa_alloc() cxl/core: Use guard() to drop the goto pattern of cxl_dpa_free() ...
2 parents a1b5bd4 + aae0594 commit 01ecadb

File tree

38 files changed

+1645
-588
lines changed

38 files changed

+1645
-588
lines changed

Documentation/ABI/stable/sysfs-devices-node

+6
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ Description:
177177
The cache write policy: 0 for write-back, 1 for write-through,
178178
other or unknown.
179179

180+
What: /sys/devices/system/node/nodeX/memory_side_cache/indexY/address_mode
181+
Date: March 2025
182+
Contact: Dave Jiang <[email protected]>
183+
Description:
184+
The address mode: 0 for reserved, 1 for extended-linear.
185+
180186
What: /sys/devices/system/node/nodeX/x86/sgx_total_bytes
181187
Date: November 2021
182188
Contact: Jarkko Sakkinen <[email protected]>

Documentation/ABI/testing/sysfs-bus-cxl

+41-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
What: /sys/bus/cxl/flush
2-
Date: Januarry, 2022
2+
Date: January, 2022
33
KernelVersion: v5.18
44
55
Description:
@@ -18,6 +18,24 @@ Description:
1818
specification.
1919

2020

21+
What: /sys/bus/cxl/devices/memX/payload_max
22+
Date: December, 2020
23+
KernelVersion: v5.12
24+
25+
Description:
26+
(RO) Maximum size (in bytes) of the mailbox command payload
27+
registers. Linux caps this at 1MB if the device reports a
28+
larger size.
29+
30+
31+
What: /sys/bus/cxl/devices/memX/label_storage_size
32+
Date: May, 2021
33+
KernelVersion: v5.13
34+
35+
Description:
36+
(RO) Size (in bytes) of the Label Storage Area (LSA).
37+
38+
2139
What: /sys/bus/cxl/devices/memX/ram/size
2240
Date: December, 2020
2341
KernelVersion: v5.12
@@ -33,7 +51,7 @@ Date: May, 2023
3351
KernelVersion: v6.8
3452
3553
Description:
36-
(RO) For CXL host platforms that support "QoS Telemmetry"
54+
(RO) For CXL host platforms that support "QoS Telemetry"
3755
this attribute conveys a comma delimited list of platform
3856
specific cookies that identifies a QoS performance class
3957
for the volatile partition of the CXL mem device. These
@@ -60,7 +78,7 @@ Date: May, 2023
6078
KernelVersion: v6.8
6179
6280
Description:
63-
(RO) For CXL host platforms that support "QoS Telemmetry"
81+
(RO) For CXL host platforms that support "QoS Telemetry"
6482
this attribute conveys a comma delimited list of platform
6583
specific cookies that identifies a QoS performance class
6684
for the persistent partition of the CXL mem device. These
@@ -321,14 +339,13 @@ KernelVersion: v6.0
321339
322340
Description:
323341
(RW) When a CXL decoder is of devtype "cxl_decoder_endpoint" it
324-
translates from a host physical address range, to a device local
325-
address range. Device-local address ranges are further split
326-
into a 'ram' (volatile memory) range and 'pmem' (persistent
327-
memory) range. The 'mode' attribute emits one of 'ram', 'pmem',
328-
'mixed', or 'none'. The 'mixed' indication is for error cases
329-
when a decoder straddles the volatile/persistent partition
330-
boundary, and 'none' indicates the decoder is not actively
331-
decoding, or no DPA allocation policy has been set.
342+
translates from a host physical address range, to a device
343+
local address range. Device-local address ranges are further
344+
split into a 'ram' (volatile memory) range and 'pmem'
345+
(persistent memory) range. The 'mode' attribute emits one of
346+
'ram', 'pmem', or 'none'. The 'none' indicates the decoder is
347+
not actively decoding, or no DPA allocation policy has been
348+
set.
332349

333350
'mode' can be written, when the decoder is in the 'disabled'
334351
state, with either 'ram' or 'pmem' to set the boundaries for the
@@ -423,7 +440,7 @@ Date: May, 2023
423440
KernelVersion: v6.5
424441
425442
Description:
426-
(RO) For CXL host platforms that support "QoS Telemmetry" this
443+
(RO) For CXL host platforms that support "QoS Telemetry" this
427444
root-decoder-only attribute conveys a platform specific cookie
428445
that identifies a QoS performance class for the CXL Window.
429446
This class-id can be compared against a similar "qos_class"
@@ -586,3 +603,15 @@ Description:
586603
See Documentation/ABI/stable/sysfs-devices-node. access0 provides
587604
the number to the closest initiator and access1 provides the
588605
number to the closest CPU.
606+
607+
608+
What: /sys/bus/cxl/devices/nvdimm-bridge0/ndbusX/nmemY/cxl/dirty_shutdown
609+
Date: Feb, 2025
610+
KernelVersion: v6.15
611+
612+
Description:
613+
(RO) The device dirty shutdown count value, which is the number
614+
of times the device could have incurred in potential data loss.
615+
The count is persistent across power loss and wraps back to 0
616+
upon overflow. If this file is not present, the device does not
617+
have the necessary support for dirty tracking.

Documentation/driver-api/cxl/maturity-map.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Mailbox commands
130130
* [0] Switch CCI
131131
* [3] Timestamp
132132
* [1] PMEM labels
133-
* [0] PMEM GPF / Dirty Shutdown
133+
* [3] PMEM GPF / Dirty Shutdown
134134
* [0] Scan Media
135135

136136
PMU

arch/x86/mm/pat/set_memory.c

+1
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,7 @@ int set_mce_nospec(unsigned long pfn)
22742274
pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn);
22752275
return rc;
22762276
}
2277+
EXPORT_SYMBOL_GPL(set_mce_nospec);
22772278

22782279
/* Restore full speculative operation to the pfn. */
22792280
int clear_mce_nospec(unsigned long pfn)

drivers/acpi/apei/ghes.c

+103
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,105 @@ static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
674674
schedule_work(&entry->work);
675675
}
676676

677+
/* Room for 8 entries */
678+
#define CXL_CPER_PROT_ERR_FIFO_DEPTH 8
679+
static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,
680+
CXL_CPER_PROT_ERR_FIFO_DEPTH);
681+
682+
/* Synchronize schedule_work() with cxl_cper_prot_err_work changes */
683+
static DEFINE_SPINLOCK(cxl_cper_prot_err_work_lock);
684+
struct work_struct *cxl_cper_prot_err_work;
685+
686+
static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
687+
int severity)
688+
{
689+
#ifdef CONFIG_ACPI_APEI_PCIEAER
690+
struct cxl_cper_prot_err_work_data wd;
691+
u8 *dvsec_start, *cap_start;
692+
693+
if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) {
694+
pr_err_ratelimited("CXL CPER invalid agent type\n");
695+
return;
696+
}
697+
698+
if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
699+
pr_err_ratelimited("CXL CPER invalid protocol error log\n");
700+
return;
701+
}
702+
703+
if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) {
704+
pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n",
705+
prot_err->err_len);
706+
return;
707+
}
708+
709+
if (!(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER))
710+
pr_warn(FW_WARN "CXL CPER no device serial number\n");
711+
712+
guard(spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
713+
714+
if (!cxl_cper_prot_err_work)
715+
return;
716+
717+
switch (prot_err->agent_type) {
718+
case RCD:
719+
case DEVICE:
720+
case LD:
721+
case FMLD:
722+
case RP:
723+
case DSP:
724+
case USP:
725+
memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err));
726+
727+
dvsec_start = (u8 *)(prot_err + 1);
728+
cap_start = dvsec_start + prot_err->dvsec_len;
729+
730+
memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap));
731+
wd.severity = cper_severity_to_aer(severity);
732+
break;
733+
default:
734+
pr_err_ratelimited("CXL CPER invalid agent type: %d\n",
735+
prot_err->agent_type);
736+
return;
737+
}
738+
739+
if (!kfifo_put(&cxl_cper_prot_err_fifo, wd)) {
740+
pr_err_ratelimited("CXL CPER kfifo overflow\n");
741+
return;
742+
}
743+
744+
schedule_work(cxl_cper_prot_err_work);
745+
#endif
746+
}
747+
748+
int cxl_cper_register_prot_err_work(struct work_struct *work)
749+
{
750+
if (cxl_cper_prot_err_work)
751+
return -EINVAL;
752+
753+
guard(spinlock)(&cxl_cper_prot_err_work_lock);
754+
cxl_cper_prot_err_work = work;
755+
return 0;
756+
}
757+
EXPORT_SYMBOL_NS_GPL(cxl_cper_register_prot_err_work, "CXL");
758+
759+
int cxl_cper_unregister_prot_err_work(struct work_struct *work)
760+
{
761+
if (cxl_cper_prot_err_work != work)
762+
return -EINVAL;
763+
764+
guard(spinlock)(&cxl_cper_prot_err_work_lock);
765+
cxl_cper_prot_err_work = NULL;
766+
return 0;
767+
}
768+
EXPORT_SYMBOL_NS_GPL(cxl_cper_unregister_prot_err_work, "CXL");
769+
770+
int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data *wd)
771+
{
772+
return kfifo_get(&cxl_cper_prot_err_fifo, wd);
773+
}
774+
EXPORT_SYMBOL_NS_GPL(cxl_cper_prot_err_kfifo_get, "CXL");
775+
677776
/* Room for 8 entries for each of the 4 event log queues */
678777
#define CXL_CPER_FIFO_DEPTH 32
679778
DEFINE_KFIFO(cxl_cper_fifo, struct cxl_cper_work_data, CXL_CPER_FIFO_DEPTH);
@@ -777,6 +876,10 @@ static bool ghes_do_proc(struct ghes *ghes,
777876
}
778877
else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
779878
queued = ghes_handle_arm_hw_error(gdata, sev, sync);
879+
} else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
880+
struct cxl_cper_sec_prot_err *prot_err = acpi_hest_get_payload(gdata);
881+
882+
cxl_cper_post_prot_err(prot_err, gdata->error_severity);
780883
} else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
781884
struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
782885

drivers/acpi/numa/hmat.c

+44
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,45 @@ static struct memory_target *find_mem_target(unsigned int mem_pxm)
108108
return NULL;
109109
}
110110

111+
/**
112+
* hmat_get_extended_linear_cache_size - Retrieve the extended linear cache size
113+
* @backing_res: resource from the backing media
114+
* @nid: node id for the memory region
115+
* @cache_size: (Output) size of extended linear cache.
116+
*
117+
* Return: 0 on success. Errno on failure.
118+
*
119+
*/
120+
int hmat_get_extended_linear_cache_size(struct resource *backing_res, int nid,
121+
resource_size_t *cache_size)
122+
{
123+
unsigned int pxm = node_to_pxm(nid);
124+
struct memory_target *target;
125+
struct target_cache *tcache;
126+
struct resource *res;
127+
128+
target = find_mem_target(pxm);
129+
if (!target)
130+
return -ENOENT;
131+
132+
list_for_each_entry(tcache, &target->caches, node) {
133+
if (tcache->cache_attrs.address_mode !=
134+
NODE_CACHE_ADDR_MODE_EXTENDED_LINEAR)
135+
continue;
136+
137+
res = &target->memregions;
138+
if (!resource_contains(res, backing_res))
139+
continue;
140+
141+
*cache_size = tcache->cache_attrs.size;
142+
return 0;
143+
}
144+
145+
*cache_size = 0;
146+
return 0;
147+
}
148+
EXPORT_SYMBOL_NS_GPL(hmat_get_extended_linear_cache_size, "CXL");
149+
111150
static struct memory_target *acpi_find_genport_target(u32 uid)
112151
{
113152
struct memory_target *target;
@@ -506,6 +545,11 @@ static __init int hmat_parse_cache(union acpi_subtable_headers *header,
506545
switch ((attrs & ACPI_HMAT_CACHE_ASSOCIATIVITY) >> 8) {
507546
case ACPI_HMAT_CA_DIRECT_MAPPED:
508547
tcache->cache_attrs.indexing = NODE_CACHE_DIRECT_MAP;
548+
/* Extended Linear mode is only valid if cache is direct mapped */
549+
if (cache->address_mode == ACPI_HMAT_CACHE_MODE_EXTENDED_LINEAR) {
550+
tcache->cache_attrs.address_mode =
551+
NODE_CACHE_ADDR_MODE_EXTENDED_LINEAR;
552+
}
509553
break;
510554
case ACPI_HMAT_CA_COMPLEX_CACHE_INDEXING:
511555
tcache->cache_attrs.indexing = NODE_CACHE_INDEXED;

drivers/base/node.c

+2
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,14 @@ CACHE_ATTR(size, "%llu")
244244
CACHE_ATTR(line_size, "%u")
245245
CACHE_ATTR(indexing, "%u")
246246
CACHE_ATTR(write_policy, "%u")
247+
CACHE_ATTR(address_mode, "%#x")
247248

248249
static struct attribute *cache_attrs[] = {
249250
&dev_attr_indexing.attr,
250251
&dev_attr_size.attr,
251252
&dev_attr_line_size.attr,
252253
&dev_attr_write_policy.attr,
254+
&dev_attr_address_mode.attr,
253255
NULL,
254256
};
255257
ATTRIBUTE_GROUPS(cache);

drivers/cxl/Kconfig

+4
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,8 @@ config CXL_REGION_INVALIDATION_TEST
158158
If unsure, or if this kernel is meant for production environments,
159159
say N.
160160

161+
config CXL_MCE
162+
def_bool y
163+
depends on X86_MCE && MEMORY_FAILURE
164+
161165
endif

drivers/cxl/core/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ cxl_core-y += pci.o
1414
cxl_core-y += hdm.o
1515
cxl_core-y += pmu.o
1616
cxl_core-y += cdat.o
17+
cxl_core-y += ras.o
18+
cxl_core-y += acpi.o
1719
cxl_core-$(CONFIG_TRACING) += trace.o
1820
cxl_core-$(CONFIG_CXL_REGION) += region.o
21+
cxl_core-$(CONFIG_CXL_MCE) += mce.o
1922
cxl_core-$(CONFIG_CXL_FEATURES) += features.o

drivers/cxl/core/acpi.c

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/* Copyright(c) 2024 Intel Corporation. All rights reserved. */
3+
#include <linux/acpi.h>
4+
#include "cxl.h"
5+
#include "core.h"
6+
7+
int cxl_acpi_get_extended_linear_cache_size(struct resource *backing_res,
8+
int nid, resource_size_t *size)
9+
{
10+
return hmat_get_extended_linear_cache_size(backing_res, nid, size);
11+
}

0 commit comments

Comments
 (0)