Skip to content

Commit bcdb6fd

Browse files
palibjorn-helgaas
authored andcommitted
PCI: aardvark: Fix reporting Slot capabilities on emulated bridge
Slot capabilities are currently not reported because emulated bridge does not report the PCI_EXP_FLAGS_SLOT flag. Set PCI_EXP_FLAGS_SLOT to let the kernel know that PCI_EXP_SLT* registers are supported. Move setting of PCI_EXP_SLTCTL register from "dynamic" pcie_conf_read function to static buffer as it is only statically filled the PCI_EXP_SLTSTA_PDS flag and dynamic read callback is not needed for this register. Set Presence State Bit to 1 since there is no support for unplugging the card and there is currently no platform able to detect presence of a card - in such a case the bit needs to be set to 1. Finally correctly set Physical Slot Number to 1 since there is only one port and zero value is reserved for ports within the same silicon as Root Port which is not our case for Aardvark HW. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Marek Behún <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 1326b49 commit bcdb6fd

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

drivers/pci/controller/pci-aardvark.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Author: Hezi Shahmoon <[email protected]>
99
*/
1010

11+
#include <linux/bitfield.h>
1112
#include <linux/delay.h>
1213
#include <linux/gpio/consumer.h>
1314
#include <linux/interrupt.h>
@@ -858,14 +859,11 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
858859

859860

860861
switch (reg) {
861-
case PCI_EXP_SLTCTL:
862-
*value = PCI_EXP_SLTSTA_PDS << 16;
863-
return PCI_BRIDGE_EMUL_HANDLED;
864-
865862
/*
866-
* PCI_EXP_RTCTL and PCI_EXP_RTSTA are also supported, but do not need
867-
* to be handled here, because their values are stored in emulated
868-
* config space buffer, and we read them from there when needed.
863+
* PCI_EXP_SLTCAP, PCI_EXP_SLTCTL, PCI_EXP_RTCTL and PCI_EXP_RTSTA are
864+
* also supported, but do not need to be handled here, because their
865+
* values are stored in emulated config space buffer, and we read them
866+
* from there when needed.
869867
*/
870868

871869
case PCI_EXP_LNKCAP: {
@@ -1056,8 +1054,25 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie)
10561054
/* Support interrupt A for MSI feature */
10571055
bridge->conf.intpin = PCI_INTERRUPT_INTA;
10581056

1059-
/* Aardvark HW provides PCIe Capability structure in version 2 */
1060-
bridge->pcie_conf.cap = cpu_to_le16(2);
1057+
/*
1058+
* Aardvark HW provides PCIe Capability structure in version 2 and
1059+
* indicate slot support, which is emulated.
1060+
*/
1061+
bridge->pcie_conf.cap = cpu_to_le16(2 | PCI_EXP_FLAGS_SLOT);
1062+
1063+
/*
1064+
* Set Presence Detect State bit permanently since there is no support
1065+
* for unplugging the card nor detecting whether it is plugged. (If a
1066+
* platform exists in the future that supports it, via a GPIO for
1067+
* example, it should be implemented via this bit.)
1068+
*
1069+
* Set physical slot number to 1 since there is only one port and zero
1070+
* value is reserved for ports within the same silicon as Root Port
1071+
* which is not our case.
1072+
*/
1073+
bridge->pcie_conf.slotcap = cpu_to_le32(FIELD_PREP(PCI_EXP_SLTCAP_PSN,
1074+
1));
1075+
bridge->pcie_conf.slotsta = cpu_to_le16(PCI_EXP_SLTSTA_PDS);
10611076

10621077
/* Indicates supports for Completion Retry Status */
10631078
bridge->pcie_conf.rootcap = cpu_to_le16(PCI_EXP_RTCAP_CRSVIS);

0 commit comments

Comments
 (0)