Skip to content

Commit 9d23ccd

Browse files
committed
Merge: cxl: Update CXL subsystem with content from v6.14
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6895 cxl: Update CXL subsystem with content from v6.14 JIRA: https://issues.redhat.com/browse/RHEL-88727 Back-port kernel's CXL subsystem core content from upstream v6.14. Signed-off-by: John W. Linville <linville@redhat.com> Approved-by: Charles Mirabile <cmirabil@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents 4c35918 + 1543222 commit 9d23ccd

File tree

30 files changed

+1228
-761
lines changed

30 files changed

+1228
-761
lines changed

Documentation/ABI/testing/debugfs-cxl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ Description:
1414
event to its internal Informational Event log, updates the
1515
Event Status register, and if configured, interrupts the host.
1616
It is not an error to inject poison into an address that
17-
already has poison present and no error is returned. The
18-
inject_poison attribute is only visible for devices supporting
19-
the capability.
17+
already has poison present and no error is returned. If the
18+
device returns 'Inject Poison Limit Reached' an -EBUSY error
19+
is returned to the user. The inject_poison attribute is only
20+
visible for devices supporting the capability.
2021

2122

2223
What: /sys/kernel/debug/memX/clear_poison

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,6 +4857,7 @@ M: Dan Williams <dan.j.williams@intel.com>
48574857
L: linux-cxl@vger.kernel.org
48584858
S: Maintained
48594859
F: drivers/cxl/
4860+
F: include/cxl/
48604861
F: include/linux/cxl-einj.h
48614862
F: include/linux/cxl-event.h
48624863
F: include/uapi/linux/cxl_mem.h

drivers/acpi/apei/einj-cxl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*
88
* Author: Ben Cheatham <benjamin.cheatham@amd.com>
99
*/
10-
#include <linux/einj-cxl.h>
1110
#include <linux/seq_file.h>
1211
#include <linux/pci.h>
12+
#include <cxl/einj.h>
1313

1414
#include "apei-internal.h"
1515

drivers/acpi/apei/ghes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/timer.h>
2828
#include <linux/cper.h>
2929
#include <linux/cleanup.h>
30-
#include <linux/cxl-event.h>
3130
#include <linux/platform_device.h>
3231
#include <linux/mutex.h>
3332
#include <linux/ratelimit.h>
@@ -50,6 +49,7 @@
5049
#include <acpi/apei.h>
5150
#include <asm/fixmap.h>
5251
#include <asm/tlbflush.h>
52+
#include <cxl/event.h>
5353
#include <ras/ras_event.h>
5454

5555
#include "apei-internal.h"

drivers/cxl/acpi.c

Lines changed: 32 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,6 @@ static const guid_t acpi_cxl_qtg_id_guid =
2222
GUID_INIT(0xF365F9A6, 0xA7DE, 0x4071,
2323
0xA6, 0x6A, 0xB4, 0x0C, 0x0B, 0x4F, 0x8E, 0x52);
2424

25-
/*
26-
* Find a targets entry (n) in the host bridge interleave list.
27-
* CXL Specification 3.0 Table 9-22
28-
*/
29-
static int cxl_xor_calc_n(u64 hpa, struct cxl_cxims_data *cximsd, int iw,
30-
int ig)
31-
{
32-
int i = 0, n = 0;
33-
u8 eiw;
34-
35-
/* IW: 2,4,6,8,12,16 begin building 'n' using xormaps */
36-
if (iw != 3) {
37-
for (i = 0; i < cximsd->nr_maps; i++)
38-
n |= (hweight64(hpa & cximsd->xormaps[i]) & 1) << i;
39-
}
40-
/* IW: 3,6,12 add a modulo calculation to 'n' */
41-
if (!is_power_of_2(iw)) {
42-
if (ways_to_eiw(iw, &eiw))
43-
return -1;
44-
hpa &= GENMASK_ULL(51, eiw + ig);
45-
n |= do_div(hpa, 3) << i;
46-
}
47-
return n;
48-
}
49-
50-
static struct cxl_dport *cxl_hb_xor(struct cxl_root_decoder *cxlrd, int pos)
51-
{
52-
struct cxl_cxims_data *cximsd = cxlrd->platform_data;
53-
struct cxl_switch_decoder *cxlsd = &cxlrd->cxlsd;
54-
struct cxl_decoder *cxld = &cxlsd->cxld;
55-
int ig = cxld->interleave_granularity;
56-
int iw = cxld->interleave_ways;
57-
int n = 0;
58-
u64 hpa;
59-
60-
if (dev_WARN_ONCE(&cxld->dev,
61-
cxld->interleave_ways != cxlsd->nr_targets,
62-
"misconfigured root decoder\n"))
63-
return NULL;
64-
65-
hpa = cxlrd->res->start + pos * ig;
66-
67-
/* Entry (n) is 0 for no interleave (iw == 1) */
68-
if (iw != 1)
69-
n = cxl_xor_calc_n(hpa, cximsd, iw, ig);
70-
71-
if (n < 0)
72-
return NULL;
73-
74-
return cxlrd->cxlsd.target[n];
75-
}
7625

7726
static u64 cxl_xor_hpa_to_spa(struct cxl_root_decoder *cxlrd, u64 hpa)
7827
{
@@ -398,7 +347,6 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
398347
struct cxl_port *root_port = ctx->root_port;
399348
struct cxl_cxims_context cxims_ctx;
400349
struct device *dev = ctx->dev;
401-
cxl_calc_hb_fn cxl_calc_hb;
402350
struct cxl_decoder *cxld;
403351
unsigned int ways, i, ig;
404352
int rc;
@@ -426,13 +374,9 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
426374
if (rc)
427375
return rc;
428376

429-
if (cfmws->interleave_arithmetic == ACPI_CEDT_CFMWS_ARITHMETIC_MODULO)
430-
cxl_calc_hb = cxl_hb_modulo;
431-
else
432-
cxl_calc_hb = cxl_hb_xor;
433-
434377
struct cxl_root_decoder *cxlrd __free(put_cxlrd) =
435-
cxl_root_decoder_alloc(root_port, ways, cxl_calc_hb);
378+
cxl_root_decoder_alloc(root_port, ways);
379+
436380
if (IS_ERR(cxlrd))
437381
return PTR_ERR(cxlrd);
438382

@@ -522,6 +466,8 @@ struct cxl_chbs_context {
522466
unsigned long long uid;
523467
resource_size_t base;
524468
u32 cxl_version;
469+
int nr_versions;
470+
u32 saved_version;
525471
};
526472

527473
static int cxl_get_chbs_iter(union acpi_subtable_headers *header, void *arg,
@@ -530,22 +476,31 @@ static int cxl_get_chbs_iter(union acpi_subtable_headers *header, void *arg,
530476
struct cxl_chbs_context *ctx = arg;
531477
struct acpi_cedt_chbs *chbs;
532478

533-
if (ctx->base != CXL_RESOURCE_NONE)
534-
return 0;
535-
536479
chbs = (struct acpi_cedt_chbs *) header;
537480

538-
if (ctx->uid != chbs->uid)
481+
if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11 &&
482+
chbs->length != CXL_RCRB_SIZE)
539483
return 0;
540484

541-
ctx->cxl_version = chbs->cxl_version;
542485
if (!chbs->base)
543486
return 0;
544487

545-
if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11 &&
546-
chbs->length != CXL_RCRB_SIZE)
488+
if (ctx->saved_version != chbs->cxl_version) {
489+
/*
490+
* cxl_version cannot be overwritten before the next two
491+
* checks, then use saved_version
492+
*/
493+
ctx->saved_version = chbs->cxl_version;
494+
ctx->nr_versions++;
495+
}
496+
497+
if (ctx->base != CXL_RESOURCE_NONE)
498+
return 0;
499+
500+
if (ctx->uid != chbs->uid)
547501
return 0;
548502

503+
ctx->cxl_version = chbs->cxl_version;
549504
ctx->base = chbs->base;
550505

551506
return 0;
@@ -569,10 +524,19 @@ static int cxl_get_chbs(struct device *dev, struct acpi_device *hb,
569524
.uid = uid,
570525
.base = CXL_RESOURCE_NONE,
571526
.cxl_version = UINT_MAX,
527+
.saved_version = UINT_MAX,
572528
};
573529

574530
acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs_iter, ctx);
575531

532+
if (ctx->nr_versions > 1) {
533+
/*
534+
* Disclaim eRCD support given some component register may
535+
* only be found via CHBCR
536+
*/
537+
dev_info(dev, "Unsupported platform config, mixed Virtual Host and Restricted CXL Host hierarchy.");
538+
}
539+
576540
return 0;
577541
}
578542

@@ -958,7 +922,8 @@ static void __exit cxl_acpi_exit(void)
958922
cxl_bus_drain();
959923
}
960924

961-
module_init(cxl_acpi_init);
925+
/* load before dax_hmem sees 'Soft Reserved' CXL ranges */
926+
subsys_initcall(cxl_acpi_init);
962927

963928
/*
964929
* Arrange for host-bridge ports to be active synchronous with
@@ -967,6 +932,7 @@ module_init(cxl_acpi_init);
967932
MODULE_SOFTDEP("pre: cxl_port");
968933

969934
module_exit(cxl_acpi_exit);
935+
MODULE_DESCRIPTION("CXL ACPI: Platform Support");
970936
MODULE_LICENSE("GPL v2");
971937
MODULE_IMPORT_NS(CXL);
972938
MODULE_IMPORT_NS(ACPI);

drivers/cxl/core/cdat.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "cxlmem.h"
1010
#include "core.h"
1111
#include "cxl.h"
12-
#include "core.h"
1312

1413
struct dsmas_entry {
1514
struct range dpa_range;
@@ -248,8 +247,8 @@ static void update_perf_entry(struct device *dev, struct dsmas_entry *dent,
248247
dpa_perf->dpa_range = dent->dpa_range;
249248
dpa_perf->qos_class = dent->qos_class;
250249
dev_dbg(dev,
251-
"DSMAS: dpa: %#llx qos: %d read_bw: %d write_bw %d read_lat: %d write_lat: %d\n",
252-
dent->dpa_range.start, dpa_perf->qos_class,
250+
"DSMAS: dpa: %pra qos: %d read_bw: %d write_bw %d read_lat: %d write_lat: %d\n",
251+
&dent->dpa_range, dpa_perf->qos_class,
253252
dent->coord[ACCESS_COORDINATE_CPU].read_bandwidth,
254253
dent->coord[ACCESS_COORDINATE_CPU].write_bandwidth,
255254
dent->coord[ACCESS_COORDINATE_CPU].read_latency,
@@ -280,8 +279,8 @@ static void cxl_memdev_set_qos_class(struct cxl_dev_state *cxlds,
280279
range_contains(&pmem_range, &dent->dpa_range))
281280
update_perf_entry(dev, dent, &mds->pmem_perf);
282281
else
283-
dev_dbg(dev, "no partition for dsmas dpa: %#llx\n",
284-
dent->dpa_range.start);
282+
dev_dbg(dev, "no partition for dsmas dpa: %pra\n",
283+
&dent->dpa_range);
285284
}
286285
}
287286

drivers/cxl/core/core.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ int cxl_region_init(void);
2626
void cxl_region_exit(void);
2727
int cxl_get_poison_by_endpoint(struct cxl_port *port);
2828
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa);
29-
u64 cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
30-
u64 dpa);
29+
u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
30+
u64 dpa);
3131

3232
#else
33-
static inline u64
34-
cxl_trace_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa)
33+
static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
34+
const struct cxl_memdev *cxlmd, u64 dpa)
3535
{
3636
return ULLONG_MAX;
3737
}
@@ -86,6 +86,11 @@ resource_size_t __rcrb_to_component(struct device *dev,
8686
enum cxl_rcrb which);
8787
u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb);
8888

89+
#define PCI_RCRB_CAP_LIST_ID_MASK GENMASK(7, 0)
90+
#define PCI_RCRB_CAP_HDR_ID_MASK GENMASK(7, 0)
91+
#define PCI_RCRB_CAP_HDR_NEXT_MASK GENMASK(15, 8)
92+
#define PCI_CAP_EXP_SIZEOF 0x3c
93+
8994
extern struct rw_semaphore cxl_dpa_rwsem;
9095
extern struct rw_semaphore cxl_region_rwsem;
9196

drivers/cxl/core/hdm.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
424424
struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
425425
struct cxl_dev_state *cxlds = cxlmd->cxlds;
426426
struct device *dev = &cxled->cxld.dev;
427-
int rc;
428427

429428
switch (mode) {
430429
case CXL_DECODER_RAM:
@@ -435,33 +434,25 @@ int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
435434
return -EINVAL;
436435
}
437436

438-
down_write(&cxl_dpa_rwsem);
439-
if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) {
440-
rc = -EBUSY;
441-
goto out;
442-
}
437+
guard(rwsem_write)(&cxl_dpa_rwsem);
438+
if (cxled->cxld.flags & CXL_DECODER_F_ENABLE)
439+
return -EBUSY;
443440

444441
/*
445442
* Only allow modes that are supported by the current partition
446443
* configuration
447444
*/
448445
if (mode == CXL_DECODER_PMEM && !resource_size(&cxlds->pmem_res)) {
449446
dev_dbg(dev, "no available pmem capacity\n");
450-
rc = -ENXIO;
451-
goto out;
447+
return -ENXIO;
452448
}
453449
if (mode == CXL_DECODER_RAM && !resource_size(&cxlds->ram_res)) {
454450
dev_dbg(dev, "no available ram capacity\n");
455-
rc = -ENXIO;
456-
goto out;
451+
return -ENXIO;
457452
}
458453

459454
cxled->mode = mode;
460-
rc = 0;
461-
out:
462-
up_write(&cxl_dpa_rwsem);
463-
464-
return rc;
455+
return 0;
465456
}
466457

467458
int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size)

0 commit comments

Comments
 (0)