All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ACPI/PCI/CXL: Enforce _DEP ordering between ACPI0016 and ACPI0017
@ 2026-05-26  2:51 Chen Pei
  2026-05-26  2:51 ` [PATCH 1/2] ACPI: PCI: Clear _DEP dependencies after PCI root bridge attach Chen Pei
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Chen Pei @ 2026-05-26  2:51 UTC (permalink / raw)
  To: dave.jiang, alison.schofield, djbw, icheng, bhelgaas, rafael,
	lenb, guoren
  Cc: linux-pci, linux-cxl, linux-acpi, linux-kernel, Chen Pei

On platforms whose ACPI namespace exposes a CXL host bridge (ACPI0016)
with an ACPI0017 CXL root device declaring _DEP on the host bridge,
cxl_acpi can probe before acpi_pci_root has attached the PCI root.
acpi_pci_find_root() then returns NULL, decoder targets read as 0,
and no port/endpoint device shows up under /sys/bus/cxl/devices/.

The root cause is twofold:

  1. acpi_pci_root_add() never calls acpi_dev_clear_dependencies(),
     so _DEP suppliers downstream of a PCI root are never released.

  2. ACPI0016 is not on acpi_honor_dep_ids[], so even when ACPI0017
     declares _DEP on it, acpi_dev_ready_for_enumeration() bypasses
     the dep_unmet check and lets cxl_acpi probe early.

On x86 the bug is usually masked by link order (acpi_pci_root is
built in and probed before cxl_acpi). On architectures like RISC-V
that ordering is not guaranteed, so the standard ACPI _DEP mechanism
must actually work.

This series fixes both sides and the two patches must be applied
together; applying only patch 2 would prevent cxl_acpi from ever
probing on ACPI0016 systems, because the supplier would never clear
the dependency.

  Patch 1 makes acpi_pci_root_add() clear _DEP on the supplier once
          the PCI root bus has been added.
  Patch 2 adds ACPI0016 to acpi_honor_dep_ids[] so the dependency
          declared by ACPI0017 is enforced.

The approach in this series follows the discussion of an earlier
posting:
https://lore.kernel.org/linux-cxl/20260514023238.49984-1-cp0613@linux.alibaba.com/

Chen Pei (2):
  ACPI: PCI: clear _DEP dependencies after PCI root bridge attach
  ACPI: scan: honor _DEP for ACPI0016 PCI/CXL host bridge

 drivers/acpi/pci_root.c | 4 ++++
 drivers/acpi/scan.c     | 1 +
 2 files changed, 5 insertions(+)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 21+ messages in thread
* [PATCH] cxl/acpi: Defer probe when ACPI0016 PCI root bridge is not ready
@ 2026-05-14  2:32 Chen Pei
  2026-05-14  7:31 ` Richard Cheng
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Chen Pei @ 2026-05-14  2:32 UTC (permalink / raw)
  To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma,
	ira.weiny, djbw, guoren
  Cc: linux-cxl, linux-kernel, Chen Pei

On some platforms (e.g., RISC-V and ARM64) that use the generic
pci_acpi_scan_root() implementation, cxl_acpi_probe may run before
acpi_pci_root driver has bound to ACPI0016 (CXL host bridge) devices.
In this case, acpi_pci_find_root() returns NULL, causing
to_cxl_host_bridge() to skip the device silently. This results in
incomplete CXL port enumeration on first boot.

Fix this by detecting the case where an ACPI0016 device exists but its
PCI root bridge is not yet ready, and returning -EPROBE_DEFER to trigger
a deferred probe retry.

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
---
 drivers/cxl/acpi.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index 127537628817..9952d0cff903 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -631,8 +631,21 @@ static int add_host_bridge_dport(struct device *match, void *arg)
 	struct acpi_pci_root *pci_root;
 	struct cxl_port *root_port = arg;
 	struct device *host = root_port->dev.parent;
-	struct acpi_device *hb = to_cxl_host_bridge(host, match);
+	struct acpi_device *adev = to_acpi_device(match);
+	struct acpi_device *hb;
 
+	/*
+	 * If this is an ACPI0016 device but acpi_pci_find_root() hasn't
+	 * found the PCI root yet (driver not probed), defer the probe
+	 * to allow acpi_pci_root to bind first.
+	 */
+	if (strcmp(acpi_device_hid(adev), "ACPI0016") == 0 &&
+	    !acpi_pci_find_root(adev->handle)) {
+		dev_dbg(host, "deferring probe, ACPI0016 PCI root not ready\n");
+		return -EPROBE_DEFER;
+	}
+
+	hb = to_cxl_host_bridge(host, match);
 	if (!hb)
 		return 0;
 
@@ -688,7 +701,8 @@ static int add_host_bridge_uport(struct device *match, void *arg)
 {
 	struct cxl_port *root_port = arg;
 	struct device *host = root_port->dev.parent;
-	struct acpi_device *hb = to_cxl_host_bridge(host, match);
+	struct acpi_device *adev = to_acpi_device(match);
+	struct acpi_device *hb;
 	struct acpi_pci_root *pci_root;
 	struct cxl_dport *dport;
 	struct cxl_port *port;
@@ -697,6 +711,14 @@ static int add_host_bridge_uport(struct device *match, void *arg)
 	resource_size_t component_reg_phys;
 	int rc;
 
+	/* Same deferral check as in add_host_bridge_dport() */
+	if (strcmp(acpi_device_hid(adev), "ACPI0016") == 0 &&
+	    !acpi_pci_find_root(adev->handle)) {
+		dev_dbg(host, "deferring probe, ACPI0016 PCI root not ready\n");
+		return -EPROBE_DEFER;
+	}
+
+	hb = to_cxl_host_bridge(host, match);
 	if (!hb)
 		return 0;
 
-- 
2.50.1


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

end of thread, other threads:[~2026-06-01 17:27 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26  2:51 [PATCH 0/2] ACPI/PCI/CXL: Enforce _DEP ordering between ACPI0016 and ACPI0017 Chen Pei
2026-05-26  2:51 ` [PATCH 1/2] ACPI: PCI: Clear _DEP dependencies after PCI root bridge attach Chen Pei
2026-05-26  3:12   ` sashiko-bot
2026-05-26  9:26     ` [PATCH] cxl/acpi: Defer probe when ACPI0016 PCI root bridge is not ready Chen Pei
2026-05-26  2:51 ` [PATCH 2/2] ACPI: scan: Honor _DEP for ACPI0016 PCI/CXL host bridge Chen Pei
2026-05-27 11:38   ` Rafael J. Wysocki
2026-05-26 15:01 ` [PATCH 0/2] ACPI/PCI/CXL: Enforce _DEP ordering between ACPI0016 and ACPI0017 Dave Jiang
2026-05-27  1:14 ` Alison Schofield
2026-06-01 17:27   ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2026-05-14  2:32 [PATCH] cxl/acpi: Defer probe when ACPI0016 PCI root bridge is not ready Chen Pei
2026-05-14  7:31 ` Richard Cheng
2026-05-15 13:46   ` Chen Pei
2026-05-15 19:24     ` Dan Williams (nvidia)
2026-05-19  1:55       ` Chen Pei
2026-05-21 17:13         ` Dave Jiang
2026-05-14 17:10 ` Dave Jiang
2026-05-15 13:53   ` Chen Pei
2026-05-14 17:19 ` Alison Schofield
2026-05-15 13:56   ` Chen Pei
2026-05-15 15:38 ` Dave Jiang
2026-05-19  1:50   ` Chen Pei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.