Skip to content

Commit 9b10e87

Browse files
floatiousbjorn-helgaas
authored andcommitted
PCI: dwc: ep: Enforce DWC specific 64-bit BAR limitation
From the DWC EP databook 5.96a, section "3.5.7.1.4 General Rules for BAR Setup (Fixed Mask or Programmable Mask Schemes Only)": "Any pair (for example BARs 0 and 1) can be configured as one 64-bit BAR, two 32-bit BARs, or one 32-bit BAR." "BAR pairs cannot overlap to form a 64-bit BAR. For example, you cannot combine BARs 1 and 2 to form a 64-bit BAR." While this limitation does exist in some other PCI endpoint controllers, e.g. cdns_pcie_ep_set_bar(), the limitation does not appear to be defined in the PCIe specification itself, thus add an explicit check for this in dw_pcie_ep_set_bar() (rather than pci_epc_set_bar()). Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent b8747e1 commit 9b10e87

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
215215
int ret, type;
216216
u32 reg;
217217

218+
/*
219+
* DWC does not allow BAR pairs to overlap, e.g. you cannot combine BARs
220+
* 1 and 2 to form a 64-bit BAR.
221+
*/
222+
if ((flags & PCI_BASE_ADDRESS_MEM_TYPE_64) && (bar & 1))
223+
return -EINVAL;
224+
218225
reg = PCI_BASE_ADDRESS_0 + (4 * bar);
219226

220227
if (!(flags & PCI_BASE_ADDRESS_SPACE))

0 commit comments

Comments
 (0)