* [PATCH] PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range
@ 2026-11-26 19:28 Felipe Infante de Castro
2026-11-26 19:33 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Felipe Infante de Castro @ 2026-11-26 19:28 UTC (permalink / raw)
To: mani, jingoohan1, lpieralisi, kwilczynski, bhelgaas, robh
Cc: linux-pci, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]
Hi,
The patch is attached as a file rather than inline, because my mail
client cannot send it inline without wrapping lines and converting
tabs. Apologies for that. The commit message is repeated below for
review.
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. The patch returns 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. The patch also
builds cleanly on a 7.3.6 tree with W=1.
The code was introduced by f6fd357f7afb ("PCI: dwc: Prepare the driver
for enabling ECAM mechanism using iATU 'CFG Shift Feature'") and is
unchanged in v7.4-rc4.
Thanks,
Felipe
[-- Attachment #2: 0001-PCI-dwc-Skip-the-empty-CFG1-window-for-a-two-bus-ECA.patch --]
[-- Type: text/x-patch, Size: 2267 bytes --]
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] 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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range
2026-11-26 19:28 [PATCH] PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range Felipe Infante de Castro
@ 2026-11-26 19:33 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 19:33 UTC (permalink / raw)
To: Felipe Infante de Castro; +Cc: linux-pci
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] PCI: dwc: commit message includes email greeting and duplicates
changelog
--
commit 7a5d39707aeeca95411c9f51ba2051ccdefb49e1
Author: Felipe Infante de Castro <felipe.infante.de.castro@gmail.com>
> PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range
>
> Hi,
>
> The patch is attached as a file rather than inline, because my mail
> client cannot send it inline without wrapping lines and converting
> tabs. Apologies for that. The commit message is repeated below for
> review.
>
> 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. The patch returns 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. The patch also
> builds cleanly on a 7.3.6 tree with W=1.
>
> The code was introduced by f6fd357f7afb ("PCI: dwc: Prepare the driver
> for enabling ECAM mechanism using iATU 'CFG Shift Feature'") and is
> unchanged in v7.4-rc4.
>
> Thanks,
> Felipe
>
> 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>
[Severity: Low]
This isn't a bug in the code, but the commit message includes the email
greeting ("Hi," ... "Thanks, Felipe") and repeats the entire changelog
body twice. Any mail-client commentary belongs below the "---" separator
so it is not recorded in git history, and the duplicate copy of the
changelog should be dropped.
--
Sashiko AI review · https://sashiko.dev/#/patchset/CADy1qsYumu=QY34qDxL2dPjQc4teadMaMgFS4rR2iAr3rMiqag@mail.gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 19:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 19:28 [PATCH] PCI: dwc: Skip the empty CFG1 window for a two-bus ECAM range Felipe Infante de Castro
2026-11-26 19:33 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox