Skip to content

Commit ea0bdf2

Browse files
committed
Merge tag 'cxl-fixes-6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull Compute Express Link fixes from Dave Jiang: "A small collection of CXL fixes. In addition to some misc fixes for the CXL subsystem, a number of fixes for CXL extended linear cache support are included to make it functional again. - Avoid missing port component registers setup due to dport enumeration failure - Add check for no entries in cxl_feature_info to address accessing invalid pointer. - Use %pa printk format to emit resource_size_t in validate_region_offset() CXL extended linear cache support fixes: - Fix setup of memory resource in cxl_acpi_set_cache_size() - Set range param for region_res_match_cxl_range() as const (addresses a compile warning for match_region_by_range() fix) - Fix match_region_by_range() to use region_res_match_cxl_range() - Subtract to find an hpa_alias0 in cxl_poison events to correct the alias math calculation" * tag 'cxl-fixes-6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: cxl/trace: Subtract to find an hpa_alias0 in cxl_poison events cxl/region: Use %pa printk format to emit resource_size_t cxl: Fix match_region_by_range() to use region_res_match_cxl_range() cxl: Set range param for region_res_match_cxl_range() as const cxl/acpi: Fix setup of memory resource in cxl_acpi_set_cache_size() cxl/features: Add check for no entries in cxl_feature_info cxl/port: Avoid missing port component registers setup
2 parents 2953fb6 + a4bbb49 commit ea0bdf2

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

drivers/cxl/acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int cxl_acpi_set_cache_size(struct cxl_root_decoder *cxlrd)
348348
struct resource res;
349349
int nid, rc;
350350

351-
res = DEFINE_RES(start, size, 0);
351+
res = DEFINE_RES_MEM(start, size);
352352
nid = phys_to_target_node(start);
353353

354354
rc = hmat_get_extended_linear_cache_size(&res, nid, &cache_size);

drivers/cxl/core/features.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ cxl_feature_info(struct cxl_features_state *cxlfs,
371371
{
372372
struct cxl_feat_entry *feat;
373373

374+
if (!cxlfs || !cxlfs->entries)
375+
return ERR_PTR(-EOPNOTSUPP);
376+
374377
for (int i = 0; i < cxlfs->entries->num_features; i++) {
375378
feat = &cxlfs->entries->ent[i];
376379
if (uuid_equal(uuid, &feat->uuid))

drivers/cxl/core/port.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,20 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,
11821182
if (rc)
11831183
return ERR_PTR(rc);
11841184

1185+
/*
1186+
* Setup port register if this is the first dport showed up. Having
1187+
* a dport also means that there is at least 1 active link.
1188+
*/
1189+
if (port->nr_dports == 1 &&
1190+
port->component_reg_phys != CXL_RESOURCE_NONE) {
1191+
rc = cxl_port_setup_regs(port, port->component_reg_phys);
1192+
if (rc) {
1193+
xa_erase(&port->dports, (unsigned long)dport->dport_dev);
1194+
return ERR_PTR(rc);
1195+
}
1196+
port->component_reg_phys = CXL_RESOURCE_NONE;
1197+
}
1198+
11851199
get_device(dport_dev);
11861200
rc = devm_add_action_or_reset(host, cxl_dport_remove, dport);
11871201
if (rc)
@@ -1200,18 +1214,6 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,
12001214

12011215
cxl_debugfs_create_dport_dir(dport);
12021216

1203-
/*
1204-
* Setup port register if this is the first dport showed up. Having
1205-
* a dport also means that there is at least 1 active link.
1206-
*/
1207-
if (port->nr_dports == 1 &&
1208-
port->component_reg_phys != CXL_RESOURCE_NONE) {
1209-
rc = cxl_port_setup_regs(port, port->component_reg_phys);
1210-
if (rc)
1211-
return ERR_PTR(rc);
1212-
port->component_reg_phys = CXL_RESOURCE_NONE;
1213-
}
1214-
12151217
return dport;
12161218
}
12171219

drivers/cxl/core/region.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static int match_free_decoder(struct device *dev, const void *data)
839839
}
840840

841841
static bool region_res_match_cxl_range(const struct cxl_region_params *p,
842-
struct range *range)
842+
const struct range *range)
843843
{
844844
if (!p->res)
845845
return false;
@@ -3398,10 +3398,7 @@ static int match_region_by_range(struct device *dev, const void *data)
33983398
p = &cxlr->params;
33993399

34003400
guard(rwsem_read)(&cxl_rwsem.region);
3401-
if (p->res && p->res->start == r->start && p->res->end == r->end)
3402-
return 1;
3403-
3404-
return 0;
3401+
return region_res_match_cxl_range(p, r);
34053402
}
34063403

34073404
static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,
@@ -3666,14 +3663,14 @@ static int validate_region_offset(struct cxl_region *cxlr, u64 offset)
36663663

36673664
if (offset < p->cache_size) {
36683665
dev_err(&cxlr->dev,
3669-
"Offset %#llx is within extended linear cache %pr\n",
3666+
"Offset %#llx is within extended linear cache %pa\n",
36703667
offset, &p->cache_size);
36713668
return -EINVAL;
36723669
}
36733670

36743671
region_size = resource_size(p->res);
36753672
if (offset >= region_size) {
3676-
dev_err(&cxlr->dev, "Offset %#llx exceeds region size %pr\n",
3673+
dev_err(&cxlr->dev, "Offset %#llx exceeds region size %pa\n",
36773674
offset, &region_size);
36783675
return -EINVAL;
36793676
}

drivers/cxl/core/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ TRACE_EVENT(cxl_poison,
10681068
__entry->hpa = cxl_dpa_to_hpa(cxlr, cxlmd,
10691069
__entry->dpa);
10701070
if (__entry->hpa != ULLONG_MAX && cxlr->params.cache_size)
1071-
__entry->hpa_alias0 = __entry->hpa +
1071+
__entry->hpa_alias0 = __entry->hpa -
10721072
cxlr->params.cache_size;
10731073
else
10741074
__entry->hpa_alias0 = ULLONG_MAX;

0 commit comments

Comments
 (0)