Skip to content

Commit 1f1050c

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: pci-bridge-emul: Correctly set PCIe capabilities
Older mvebu hardware provides PCIe Capability structure only in version 1. New mvebu and aardvark hardware provides it in version 2. So do not force version to 2 in pci_bridge_emul_init() and rather allow drivers to set correct version. Drivers need to set version in pcie_conf.cap field without overwriting PCI_CAP_LIST_ID register. Both drivers (mvebu and aardvark) do not provide slot support yet, so do not set PCI_EXP_FLAGS_SLOT flag. Link: https://lore.kernel.org/r/[email protected] Fixes: 23a5fba ("PCI: Introduce PCI bridge emulated config space common logic") Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Cc: [email protected]
1 parent 1299808 commit 1f1050c

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

drivers/pci/controller/pci-aardvark.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
881881
return PCI_BRIDGE_EMUL_HANDLED;
882882
}
883883

884-
case PCI_CAP_LIST_ID:
885884
case PCI_EXP_DEVCAP:
886885
case PCI_EXP_DEVCTL:
887886
*value = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + reg);
@@ -962,6 +961,9 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie)
962961
/* Support interrupt A for MSI feature */
963962
bridge->conf.intpin = PCIE_CORE_INT_A_ASSERT_ENABLE;
964963

964+
/* Aardvark HW provides PCIe Capability structure in version 2 */
965+
bridge->pcie_conf.cap = cpu_to_le16(2);
966+
965967
/* Indicates supports for Completion Retry Status */
966968
bridge->pcie_conf.rootcap = cpu_to_le16(PCI_EXP_RTCAP_CRSVIS);
967969

drivers/pci/controller/pci-mvebu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ static struct pci_bridge_emul_ops mvebu_pci_bridge_emul_ops = {
573573
static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
574574
{
575575
struct pci_bridge_emul *bridge = &port->bridge;
576+
u32 pcie_cap = mvebu_readl(port, PCIE_CAP_PCIEXP);
577+
u8 pcie_cap_ver = ((pcie_cap >> 16) & PCI_EXP_FLAGS_VERS);
576578

577579
bridge->conf.vendor = PCI_VENDOR_ID_MARVELL;
578580
bridge->conf.device = mvebu_readl(port, PCIE_DEV_ID_OFF) >> 16;
@@ -585,6 +587,12 @@ static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
585587
bridge->conf.iolimit = PCI_IO_RANGE_TYPE_32;
586588
}
587589

590+
/*
591+
* Older mvebu hardware provides PCIe Capability structure only in
592+
* version 1. New hardware provides it in version 2.
593+
*/
594+
bridge->pcie_conf.cap = cpu_to_le16(pcie_cap_ver);
595+
588596
bridge->has_pcie = true;
589597
bridge->data = port;
590598
bridge->ops = &mvebu_pci_bridge_emul_ops;

drivers/pci/pci-bridge-emul.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,7 @@ int pci_bridge_emul_init(struct pci_bridge_emul *bridge,
297297
if (bridge->has_pcie) {
298298
bridge->conf.capabilities_pointer = PCI_CAP_PCIE_START;
299299
bridge->pcie_conf.cap_id = PCI_CAP_ID_EXP;
300-
/* Set PCIe v2, root port, slot support */
301-
bridge->pcie_conf.cap =
302-
cpu_to_le16(PCI_EXP_TYPE_ROOT_PORT << 4 | 2 |
303-
PCI_EXP_FLAGS_SLOT);
300+
bridge->pcie_conf.cap |= cpu_to_le16(PCI_EXP_TYPE_ROOT_PORT << 4);
304301
bridge->pcie_cap_regs_behavior =
305302
kmemdup(pcie_cap_regs_behavior,
306303
sizeof(pcie_cap_regs_behavior),

0 commit comments

Comments
 (0)