Skip to content

Commit 97e4a50

Browse files
jnurminegregkh
authored andcommitted
PCI: xilinx-nwl: Fix ECAM programming
commit 98a4f5b upstream. When PCIe has been set up by the bootloader, the ecam_size field in the E_ECAM_CONTROL register already contains a value. The driver previously programmed it to 0xc (for 16 busses; 16 MB), but bumped to 0x10 (for 256 busses; 256 MB) by the commit 2fccd11 ("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: 2fccd11 ("PCI: xilinx-nwl: Modify ECAM size to enable support for 256 buses") Signed-off-by: Jani Nurminen <[email protected]> [mani: added stable tag] Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8662366 commit 97e4a50

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/pci/controller/pcie-xilinx-nwl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,10 @@ static int nwl_pcie_bridge_init(struct nwl_pcie *pcie)
721721
nwl_bridge_writel(pcie, nwl_bridge_readl(pcie, E_ECAM_CONTROL) |
722722
E_ECAM_CR_ENABLE, E_ECAM_CONTROL);
723723

724-
nwl_bridge_writel(pcie, nwl_bridge_readl(pcie, E_ECAM_CONTROL) |
725-
(NWL_ECAM_MAX_SIZE << E_ECAM_SIZE_SHIFT),
726-
E_ECAM_CONTROL);
724+
ecam_val = nwl_bridge_readl(pcie, E_ECAM_CONTROL);
725+
ecam_val &= ~E_ECAM_SIZE_LOC;
726+
ecam_val |= NWL_ECAM_MAX_SIZE << E_ECAM_SIZE_SHIFT;
727+
nwl_bridge_writel(pcie, ecam_val, E_ECAM_CONTROL);
727728

728729
nwl_bridge_writel(pcie, lower_32_bits(pcie->phys_ecam_base),
729730
E_ECAM_BASE_LO);

0 commit comments

Comments
 (0)