lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250107035708.1134954-3-ming.li@zohomail.com>
Date: Tue,  7 Jan 2025 11:57:02 +0800
From: Li Ming <ming.li@...omail.com>
To: dave@...olabs.net,
	jonathan.cameron@...wei.com,
	dave.jiang@...el.com,
	alison.schofield@...el.com,
	vishal.l.verma@...el.com,
	ira.weiny@...el.com,
	dan.j.williams@...el.com
Cc: linux-cxl@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Li Ming <ming.li@...omail.com>
Subject: [RFC PATCH 2/8] cxl/port: Delay port HDM setup until port component regs setup done

Currently, devm_cxl_add_endpoint() is responsible for all CXL ports
component registers enumeration. so HDM setup for the port of host
bridge/switch also needs to be delayed until componeng registers setup
finished. So moving CXL host bridge/switch HDM setup implementation out
of cxl_switch_port_probe(), and let devm_cxl_add_endpoint() help to
setup HDM on such ports.

Signed-off-by: Li Ming <ming.li@...omail.com>
---
 drivers/cxl/port.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
index ae09bbbe0a17..c59f198f6cb0 100644
--- a/drivers/cxl/port.c
+++ b/drivers/cxl/port.c
@@ -59,7 +59,6 @@ static int discover_region(struct device *dev, void *root)
 
 static int cxl_switch_port_probe(struct cxl_port *port)
 {
-	struct cxl_hdm *cxlhdm;
 	int rc;
 
 	/* Cache the data early to ensure is_visible() works */
@@ -71,6 +70,18 @@ static int cxl_switch_port_probe(struct cxl_port *port)
 
 	cxl_switch_parse_cdat(port);
 
+	return 0;
+}
+
+static int cxl_switch_port_setup_hdm(struct cxl_port *port)
+{
+	struct cxl_hdm *cxlhdm;
+	int rc;
+
+	/* Skip hdm setup if there is a cxlhdm on the port */
+	if (dev_get_drvdata(&port->dev))
+		return 0;
+
 	cxlhdm = devm_cxl_setup_hdm(port, NULL);
 	if (!IS_ERR(cxlhdm))
 		return devm_cxl_enumerate_decoders(cxlhdm, NULL);
@@ -89,6 +100,17 @@ static int cxl_switch_port_probe(struct cxl_port *port)
 	return -ENXIO;
 }
 
+static int cxl_switch_port_setup(struct cxl_port *port)
+{
+	int rc;
+
+	rc = cxl_port_setup_regs(port);
+	if (rc)
+		return rc;
+
+	return cxl_switch_port_setup_hdm(port);
+}
+
 static int cxl_endpoint_port_probe(struct cxl_port *port)
 {
 	struct cxl_port *iter, *parent_port = to_cxl_port(port->dev.parent);
@@ -109,9 +131,9 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
 		 */
 		if (iter != parent_port) {
 			guard(device)(&iter->dev);
-			rc = cxl_port_setup_regs(iter);
+			rc = cxl_switch_port_setup(iter);
 		} else {
-			rc = cxl_port_setup_regs(iter);
+			rc = cxl_switch_port_setup(iter);
 		}
 		if (rc)
 			return rc;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ