[PATCH v2] PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range

From: Felipe Infante de Castro

Date: Thu Nov 26 2026 - 14:41:50 EST



From 3998bb6c6f965ccc9b5ead4fd7c2e7862fa513d5 Mon Sep 17 00:00:00 2001
From: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>
Date: Thu, 26 Nov 2026 13:54:01 -0500
Subject: [PATCH v2] PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range

With the iATU-based ECAM mechanism and a host bus resource of [bus 00-01]
(bus-range = <0 1> in a device tree), dw_pcie_config_ecam_iatu() programs
the CFG0 window for bus 1 and then requests a CFG1 window of zero bytes:

atu.size = (SZ_1M * bus_range_max) - SZ_2M;

dw_pcie_prog_outbound_atu() rejects a zero-size window with -EINVAL, the
error propagates through dw_pcie_host_init() and the host bridge is never
registered.

resource_size() counts both ends of the range, so [bus 00-01] holds two
buses. Bus 0 uses the DBI registers and bus 1 uses the CFG0 window. A
CFG1 window is needed only from bus 2 on, that is for three buses or
more. The early return tests "bus_range_max < 2", which lets the two-bus
case through.

Return early for two buses as well.

Tested by replaying dw_pcie_config_ecam_iatu() and
dw_pcie_prog_outbound_atu() in user space against memory-backed
registers, for every bus count from 2 to 256 at two ECAM bases. Without
the change the two-bus case fails with -EINVAL; with it all 510 cases
pass and the CFG1 window for three or more buses is unchanged. Not
tested on hardware with a two-bus range.

Fixes: f6fd357f7afb ("PCI: dwc: Prepare the driver for enabling ECAM mechanism using iATU 'CFG Shift Feature'")
Assisted-by: OpenAI Codex
Assisted-by: Claude Fable 5.2
Signed-off-by: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>
---
Changes in v2:
- Resent with an empty mail body. v1 carried a greeting and
a second copy of the changelog in the body, which tooling folded
into the commit message. No change to the patch itself.

drivers/pci/controller/dwc/pcie-designware-host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index bbb0245..0ab8074 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -447,7 +447,7 @@ static int dw_pcie_config_ecam_iatu(struct dw_pcie_rp *pp)

bus_range_max = resource_size(bus->res);

- if (bus_range_max < 2)
+ if (bus_range_max <= 2)
return 0;

/* Configure remaining buses in type 1 iATU configuration */
--
2.56.1