Skip to content

Commit 45f667e

Browse files
committed
Merge tag 'cxl-fixes-7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull Compute Express Link (CXL) fixes from Dave Jiang: - Adjust the startup priority of cxl_pmem to be higher than that of cxl_acpi - Use proper endpoint validity check upon sanitize - Avoid incorrect DVSEC fallback when HDM decoders are enabled - Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch - Fix leakage in __construct_region() - Fix use after free of parent_port in cxl_detach_ep() * tag 'cxl-fixes-7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: cxl: Adjust the startup priority of cxl_pmem to be higher than that of cxl_acpi cxl/mbox: Use proper endpoint validity check upon sanitize cxl/hdm: Avoid incorrect DVSEC fallback when HDM decoders are enabled cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch cxl/region: Fix leakage in __construct_region() cxl/port: Fix use after free of parent_port in cxl_detach_ep()
2 parents e3c33bc + be5c528 commit 45f667e

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

drivers/cxl/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ config CXL_ACPI
5959
tristate "CXL ACPI: Platform Support"
6060
depends on ACPI
6161
depends on ACPI_NUMA
62+
depends on CXL_PMEM || !CXL_PMEM
6263
default CXL_BUS
6364
select ACPI_TABLE_LIB
6465
select ACPI_HMAT

drivers/cxl/core/hdm.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info)
9494
struct cxl_hdm *cxlhdm;
9595
void __iomem *hdm;
9696
u32 ctrl;
97-
int i;
9897

9998
if (!info)
10099
return false;
@@ -113,22 +112,16 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info)
113112
return false;
114113

115114
/*
116-
* If any decoders are committed already, there should not be any
117-
* emulated DVSEC decoders.
115+
* If HDM decoders are globally enabled, do not fall back to DVSEC
116+
* range emulation. Zeroed decoder registers after region teardown
117+
* do not imply absence of HDM capability.
118+
*
119+
* Falling back to DVSEC here would treat the decoder as AUTO and
120+
* may incorrectly latch default interleave settings.
118121
*/
119-
for (i = 0; i < cxlhdm->decoder_count; i++) {
120-
ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(i));
121-
dev_dbg(&info->port->dev,
122-
"decoder%d.%d: committed: %ld base: %#x_%.8x size: %#x_%.8x\n",
123-
info->port->id, i,
124-
FIELD_GET(CXL_HDM_DECODER0_CTRL_COMMITTED, ctrl),
125-
readl(hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(i)),
126-
readl(hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(i)),
127-
readl(hdm + CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(i)),
128-
readl(hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(i)));
129-
if (FIELD_GET(CXL_HDM_DECODER0_CTRL_COMMITTED, ctrl))
130-
return false;
131-
}
122+
ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET);
123+
if (ctrl & CXL_HDM_DECODER_ENABLE)
124+
return false;
132125

133126
return true;
134127
}

drivers/cxl/core/mbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ int cxl_mem_sanitize(struct cxl_memdev *cxlmd, u16 cmd)
13011301
* Require an endpoint to be safe otherwise the driver can not
13021302
* be sure that the device is unmapped.
13031303
*/
1304-
if (endpoint && cxl_num_decoders_committed(endpoint) == 0)
1304+
if (cxlmd->dev.driver && cxl_num_decoders_committed(endpoint) == 0)
13051305
return __cxl_mem_sanitize(mds, cmd);
13061306

13071307
return -EBUSY;

drivers/cxl/core/port.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,13 @@ static void cxl_port_release(struct device *dev)
552552
xa_destroy(&port->dports);
553553
xa_destroy(&port->regions);
554554
ida_free(&cxl_port_ida, port->id);
555-
if (is_cxl_root(port))
555+
556+
if (is_cxl_root(port)) {
556557
kfree(to_cxl_root(port));
557-
else
558+
} else {
559+
put_device(dev->parent);
558560
kfree(port);
561+
}
559562
}
560563

561564
static ssize_t decoders_committed_show(struct device *dev,
@@ -707,6 +710,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev,
707710
struct cxl_port *iter;
708711

709712
dev->parent = &parent_port->dev;
713+
get_device(dev->parent);
710714
port->depth = parent_port->depth + 1;
711715
port->parent_dport = parent_dport;
712716

drivers/cxl/core/region.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3854,8 +3854,10 @@ static int __construct_region(struct cxl_region *cxlr,
38543854
}
38553855

38563856
rc = sysfs_update_group(&cxlr->dev.kobj, &cxl_region_group);
3857-
if (rc)
3857+
if (rc) {
3858+
kfree(res);
38583859
return rc;
3860+
}
38593861

38603862
rc = insert_resource(cxlrd->res, res);
38613863
if (rc) {

drivers/cxl/pmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static __exit void cxl_pmem_exit(void)
554554

555555
MODULE_DESCRIPTION("CXL PMEM: Persistent Memory Support");
556556
MODULE_LICENSE("GPL v2");
557-
module_init(cxl_pmem_init);
557+
subsys_initcall(cxl_pmem_init);
558558
module_exit(cxl_pmem_exit);
559559
MODULE_IMPORT_NS("CXL");
560560
MODULE_ALIAS_CXL(CXL_DEVICE_NVDIMM_BRIDGE);

0 commit comments

Comments
 (0)