Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/port: Disable decoder setup for endpoints in RCD mode
@ 2023-02-08  7:17 Robert Richter
  2023-02-09 17:07 ` Dan Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Richter @ 2023-02-08  7:17 UTC (permalink / raw)
  To: Alison Schofield, Vishal Verma, Ira Weiny, Ben Widawsky,
	Dan Williams
  Cc: Jonathan Cameron, Dave Jiang, Robert Richter, linux-cxl,
	linux-kernel

In RCD mode the HDM decoder capability is optional for endpoints and
may not exist. The HDM range registers are used instead. Since the
driver relies on the existence of an HDM decoder capability, its
absence will cause the initialization of a memory card to fail.

Moreover, the driver also tries to enable or reuse enabled memory
ranges. In the worst case this may lead to a system hang due to
disabling system memory that was previously provided and setup by
system firmware.

To solve the issues described, disable decoder setup for RCD endpoints
and instead rely exclusively on system firmware to enable those memory
ranges. Decoders are used by the kernel to setup and configure CXL
memory regions, esp. to enable and disable them. Since Hot-plug is not
supported for devices in RCD mode, the ability to disable that memory
by the kernel using a decoder is not a necessarily requirement,
decoders are not needed then.

Fixes: 34e37b4c432c ("cxl/port: Enable HDM Capability after validating DVSEC Ranges")
Signed-off-by: Robert Richter <rrichter@amd.com>
---
 drivers/cxl/port.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
index 5453771bf330..19591d904bdf 100644
--- a/drivers/cxl/port.c
+++ b/drivers/cxl/port.c
@@ -43,11 +43,11 @@ static int cxl_port_probe(struct device *dev)
 			return rc;
 		if (rc == 1)
 			return devm_cxl_add_passthrough_decoder(port);
-	}
 
-	cxlhdm = devm_cxl_setup_hdm(port);
-	if (IS_ERR(cxlhdm))
-		return PTR_ERR(cxlhdm);
+		cxlhdm = devm_cxl_setup_hdm(port);
+		if (IS_ERR(cxlhdm))
+			return PTR_ERR(cxlhdm);
+	}
 
 	if (is_cxl_endpoint(port)) {
 		struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport);
@@ -61,6 +61,19 @@ static int cxl_port_probe(struct device *dev)
 		if (rc)
 			return rc;
 
+		/*
+		 * The HDM decoder capability may not exist. Do not
+		 * use decoders in RCD mode, instead rely on firmware
+		 * to setup the range or decoder registers and to
+		 * enable memory.
+		 */
+		if (cxlds->rcd)
+			return cxl_await_media_ready(cxlds);
+
+		cxlhdm = devm_cxl_setup_hdm(port);
+		if (IS_ERR(cxlhdm))
+			return PTR_ERR(cxlhdm);
+
 		rc = cxl_hdm_decode_init(cxlds, cxlhdm);
 		if (rc)
 			return rc;

base-commit: 623c0751336e4035ab0047f2c152a02bd26b612b
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-15 16:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-08  7:17 [PATCH] cxl/port: Disable decoder setup for endpoints in RCD mode Robert Richter
2023-02-09 17:07 ` Dan Williams
2023-02-13 14:49   ` Robert Richter
2023-02-14 22:28     ` Dan Williams
2023-02-15 16:32       ` Robert Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox