Skip to content

Commit 8f0220a

Browse files
committed
Revert "cxl/port: Enable the HDM decoder capability for switch ports"
commit eb0764b ("cxl/port: Enable the HDM decoder capability for switch ports") ...was added on the observation of CXL memory not being accessible after setting up a region on a "cold-plugged" device. A "cold-plugged" CXL device is one that was not present at boot, so platform-firmware/BIOS has no chance to set it up. While it is true that the debug found the enable bit clear in the host-bridge's instance of the global control register (CXL 3.0 8.2.4.19.2 CXL HDM Decoder Global Control Register), that bit is described as: "This bit is only applicable to CXL.mem devices and shall return 0 on CXL Host Bridges and Upstream Switch Ports." So it is meant to be zero, and further testing confirmed that this "fix" had no effect on the failure. Revert it, and be more vigilant about proposed fixes in the future. Since the original copied stable@, flag this revert for stable@ as well. Cc: <stable@vger.kernel.org> Fixes: eb0764b ("cxl/port: Enable the HDM decoder capability for switch ports") Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/168685882012.3475336.16733084892658264991.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 516b300 commit 8f0220a

5 files changed

Lines changed: 9 additions & 49 deletions

File tree

drivers/cxl/core/pci.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -308,36 +308,17 @@ static void disable_hdm(void *_cxlhdm)
308308
hdm + CXL_HDM_DECODER_CTRL_OFFSET);
309309
}
310310

311-
int devm_cxl_enable_hdm(struct cxl_port *port, struct cxl_hdm *cxlhdm)
311+
static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm)
312312
{
313-
void __iomem *hdm;
313+
void __iomem *hdm = cxlhdm->regs.hdm_decoder;
314314
u32 global_ctrl;
315315

316-
/*
317-
* If the hdm capability was not mapped there is nothing to enable and
318-
* the caller is responsible for what happens next. For example,
319-
* emulate a passthrough decoder.
320-
*/
321-
if (IS_ERR(cxlhdm))
322-
return 0;
323-
324-
hdm = cxlhdm->regs.hdm_decoder;
325316
global_ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET);
326-
327-
/*
328-
* If the HDM decoder capability was enabled on entry, skip
329-
* registering disable_hdm() since this decode capability may be
330-
* owned by platform firmware.
331-
*/
332-
if (global_ctrl & CXL_HDM_DECODER_ENABLE)
333-
return 0;
334-
335317
writel(global_ctrl | CXL_HDM_DECODER_ENABLE,
336318
hdm + CXL_HDM_DECODER_CTRL_OFFSET);
337319

338-
return devm_add_action_or_reset(&port->dev, disable_hdm, cxlhdm);
320+
return devm_add_action_or_reset(host, disable_hdm, cxlhdm);
339321
}
340-
EXPORT_SYMBOL_NS_GPL(devm_cxl_enable_hdm, CXL);
341322

342323
int cxl_dvsec_rr_decode(struct device *dev, int d,
343324
struct cxl_endpoint_dvsec_info *info)
@@ -511,7 +492,7 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
511492
if (info->mem_enabled)
512493
return 0;
513494

514-
rc = devm_cxl_enable_hdm(port, cxlhdm);
495+
rc = devm_cxl_enable_hdm(&port->dev, cxlhdm);
515496
if (rc)
516497
return rc;
517498

drivers/cxl/cxl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ struct cxl_endpoint_dvsec_info {
710710
struct cxl_hdm;
711711
struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
712712
struct cxl_endpoint_dvsec_info *info);
713-
int devm_cxl_enable_hdm(struct cxl_port *port, struct cxl_hdm *cxlhdm);
714713
int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
715714
struct cxl_endpoint_dvsec_info *info);
716715
int devm_cxl_add_passthrough_decoder(struct cxl_port *port);

drivers/cxl/port.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,13 @@ static int discover_region(struct device *dev, void *root)
6060
static int cxl_switch_port_probe(struct cxl_port *port)
6161
{
6262
struct cxl_hdm *cxlhdm;
63-
int rc, nr_dports;
64-
65-
nr_dports = devm_cxl_port_enumerate_dports(port);
66-
if (nr_dports < 0)
67-
return nr_dports;
63+
int rc;
6864

69-
cxlhdm = devm_cxl_setup_hdm(port, NULL);
70-
rc = devm_cxl_enable_hdm(port, cxlhdm);
71-
if (rc)
65+
rc = devm_cxl_port_enumerate_dports(port);
66+
if (rc < 0)
7267
return rc;
7368

69+
cxlhdm = devm_cxl_setup_hdm(port, NULL);
7470
if (!IS_ERR(cxlhdm))
7571
return devm_cxl_enumerate_decoders(cxlhdm, NULL);
7672

@@ -79,7 +75,7 @@ static int cxl_switch_port_probe(struct cxl_port *port)
7975
return PTR_ERR(cxlhdm);
8076
}
8177

82-
if (nr_dports == 1) {
78+
if (rc == 1) {
8379
dev_dbg(&port->dev, "Fallback to passthrough decoder\n");
8480
return devm_cxl_add_passthrough_decoder(port);
8581
}

tools/testing/cxl/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ldflags-y += --wrap=acpi_pci_find_root
66
ldflags-y += --wrap=nvdimm_bus_register
77
ldflags-y += --wrap=devm_cxl_port_enumerate_dports
88
ldflags-y += --wrap=devm_cxl_setup_hdm
9-
ldflags-y += --wrap=devm_cxl_enable_hdm
109
ldflags-y += --wrap=devm_cxl_add_passthrough_decoder
1110
ldflags-y += --wrap=devm_cxl_enumerate_decoders
1211
ldflags-y += --wrap=cxl_await_media_ready

tools/testing/cxl/test/mock.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,6 @@ struct cxl_hdm *__wrap_devm_cxl_setup_hdm(struct cxl_port *port,
149149
}
150150
EXPORT_SYMBOL_NS_GPL(__wrap_devm_cxl_setup_hdm, CXL);
151151

152-
int __wrap_devm_cxl_enable_hdm(struct cxl_port *port, struct cxl_hdm *cxlhdm)
153-
{
154-
int index, rc;
155-
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
156-
157-
if (ops && ops->is_mock_port(port->uport))
158-
rc = 0;
159-
else
160-
rc = devm_cxl_enable_hdm(port, cxlhdm);
161-
put_cxl_mock_ops(index);
162-
163-
return rc;
164-
}
165-
EXPORT_SYMBOL_NS_GPL(__wrap_devm_cxl_enable_hdm, CXL);
166-
167152
int __wrap_devm_cxl_add_passthrough_decoder(struct cxl_port *port)
168153
{
169154
int rc, index;

0 commit comments

Comments
 (0)