* [PATCH] PCI: xilinx-nwl: Fix ECAM programming
@ 2025-09-12 9:09 Jani Nurminen
2025-09-29 18:12 ` Manivannan Sadhasivam
0 siblings, 1 reply; 2+ messages in thread
From: Jani Nurminen @ 2025-09-12 9:09 UTC (permalink / raw)
To: bhelgaas, michal.simek, thippeswamy.havalige, kwilczynski,
lpieralisi, mani, robh
Cc: linux-pci, linux-arm-kernel
When PCIe has been set up by the bootloader, the ecam_size field in the
E_ECAM_CONTROL register already contains a value.
The value used to be 0xc (for 16 busses; 16 MB), but was bumped to 0x10
(for 256 busses; 256 MB) by the commit 2fccd11518f1 ("PCI: xilinx-nwl:
Modify ECAM size to enable support for 256 buses").
Regardless of what the bootloader has programmed, the driver ORs in a
new maximal value without doing a proper RMW sequence. This can lead to
problems.
For example, if the bootloader programs in 0xc and the driver uses 0x10,
the ORed result is 0x1c, which is beyond the ecam_max_size limit of 0x10
(from E_ECAM_CAPABILITIES).
Avoid the problems by doing a proper RMW.
Fixes: 2fccd11518f1 ("PCI: xilinx-nwl: Modify ECAM size to enable support for 256 buses")
Signed-off-by: Jani Nurminen <jani.nurminen@windriver.com>
---
drivers/pci/controller/pcie-xilinx-nwl.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c
index 05b8c205493c..7db2c96c6cec 100644
--- a/drivers/pci/controller/pcie-xilinx-nwl.c
+++ b/drivers/pci/controller/pcie-xilinx-nwl.c
@@ -718,9 +718,10 @@ static int nwl_pcie_bridge_init(struct nwl_pcie *pcie)
nwl_bridge_writel(pcie, nwl_bridge_readl(pcie, E_ECAM_CONTROL) |
E_ECAM_CR_ENABLE, E_ECAM_CONTROL);
- nwl_bridge_writel(pcie, nwl_bridge_readl(pcie, E_ECAM_CONTROL) |
- (NWL_ECAM_MAX_SIZE << E_ECAM_SIZE_SHIFT),
- E_ECAM_CONTROL);
+ ecam_val = nwl_bridge_readl(pcie, E_ECAM_CONTROL);
+ ecam_val &= ~E_ECAM_SIZE_LOC;
+ ecam_val |= NWL_ECAM_MAX_SIZE << E_ECAM_SIZE_SHIFT;
+ nwl_bridge_writel(pcie, ecam_val, E_ECAM_CONTROL);
nwl_bridge_writel(pcie, lower_32_bits(pcie->phys_ecam_base),
E_ECAM_BASE_LO);
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] PCI: xilinx-nwl: Fix ECAM programming
2025-09-12 9:09 [PATCH] PCI: xilinx-nwl: Fix ECAM programming Jani Nurminen
@ 2025-09-29 18:12 ` Manivannan Sadhasivam
0 siblings, 0 replies; 2+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-29 18:12 UTC (permalink / raw)
To: bhelgaas, michal.simek, thippeswamy.havalige, kwilczynski,
lpieralisi, robh, Jani Nurminen
Cc: linux-pci, linux-arm-kernel
On Fri, 12 Sep 2025 11:09:48 +0200, Jani Nurminen wrote:
> When PCIe has been set up by the bootloader, the ecam_size field in the
> E_ECAM_CONTROL register already contains a value.
>
> The value used to be 0xc (for 16 busses; 16 MB), but was bumped to 0x10
> (for 256 busses; 256 MB) by the commit 2fccd11518f1 ("PCI: xilinx-nwl:
> Modify ECAM size to enable support for 256 buses").
>
> [...]
Applied, thanks!
[1/1] PCI: xilinx-nwl: Fix ECAM programming
commit: 9f0fd0b2f7a4aa1925ddfa4aed537a195879e0fa
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-29 18:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 9:09 [PATCH] PCI: xilinx-nwl: Fix ECAM programming Jani Nurminen
2025-09-29 18:12 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox