pci: Workaround Stratus broken PCIE hierarchy
Subsystems (2)
PATCH 1/1 pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check in only_one_child() causes all the bridges to be enumerated and the system to function properly.
Unfortunately this hardware is currently available so we should at least keep it functional.
--- drivers/pci/probe.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
drivers/pci/probe.c +10 -1
@@ -10,6 +10,7 @@#include <linux/module.h> #include <linux/cpumask.h> #include <linux/pci-aspm.h> +#include <linux/dmi.h> #include "pci.h" #define CARDBUS_LATENCY_TIMER 176/* secondary latency timer */
@@ -1275,7 +1276,15 @@ static int only_one_child(struct pci_bus *bus)struct pci_dev *parent = bus->self;if (!parent || !pci_is_pcie (parent))return 0 ; -if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT || +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which +* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check here results in a +* functional system. +*/ +if (!dmi_name_in_vendors ("ftServer" ) && parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM )return 1 ;return 0 ;
Signature · 1 line
1.7.1
Quoted 14 lines · Prarit Bhargava
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check in
only_one_child()causes all the bridges to be enumerated and the system to function properly.drivers/pci/probe.c +2
-1@@ -1275,7 +1276,15 @@ static int only_one_child(struct pci_bus *bus)struct pci_dev *parent = bus->self;if (!parent || !pci_is_pcie (parent))return 0 ; - if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT || +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ;
drivers/pci/probe.c static int only_one_child(struct pci_bus *bus) · line 1290
Quoted 10 lines
drivers/pci/probe.c +7
-0+/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which +* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check here results in a +* functional system. +*/ +if (!dmi_name_in_vendors ("ftServer" ) && parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM )return 1 ;return 0 ;
dmi_name_in_vendors is relatively expensive, so the order of these two should be swapped, at least:
Quoted 2 lines
if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM &&!dmi_name_in_vendors("ftServer"))
Plus, this gets called for every PCI bridge. We should be caching it somewhere, so it's only called once.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 29 lines · Matthew Wilcox
Quoted 14 lines · Prarit Bhargava
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check in
only_one_child()causes all the bridges to be enumerated and the system to function properly.drivers/pci/probe.c +2
-1@@ -1275,7 +1276,15 @@ static int only_one_child(struct pci_bus *bus)struct pci_dev *parent = bus->self;if (!parent || !pci_is_pcie (parent))return 0 ; - if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT || +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ;drivers/pci/probe.c static int only_one_child(struct pci_bus *bus) · line 1290
Quoted 10 lines
drivers/pci/probe.c +7
-0+/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which +* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check here results in a +* functional system. +*/ +if (!dmi_name_in_vendors ("ftServer" )&& parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM )return 1 ;return 0 ;
dmi_name_in_vendorsis relatively expensive, so the order of these two should be swapped, at least:
Quoted 6 lines
Quoted 2 lines
if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM&&!dmi_name_in_vendors("ftServer"))
Plus, this gets called for every PCI bridge. We should be caching it somewhere, so it's only called once.
Then i recommend a dmi_name_in_vendors() check at init; stick result in global (or local static), and then it's not exec'd on each bridge, just a simple flag check.
If that's the case, I'd re-cast my vote for putting the code in pci_quirks with an export, so it is tracked as a quirk. that may get messy wrt other arches though (the export in common code; not sure if quirks is included on all arches).
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running into similar issues... if we don't know exactly which systems these are then maybe a boot parameter would be a more flexible approach...
--jim
----- Original Message -----
Quoted 59 lines · Matthew Wilcox
Quoted 38 lines · Prarit Bhargava
Quoted 25 lines
Stratus systems have a hierarchy that includes a PCIE Downstream bridge
connected to a PCIE Upstream bridge and a PCI Downstream bridge.
The system
boots with this wrong hierarchy into a crippled mode (USB doesn't work,
network doesn't work ...). Avoiding the Downstream bridge check inonly_one_child()causes all the bridges to be enumerated and the system
to function properly.drivers/pci/probe.c +4
-1@@ -1275,7 +1276,15 @@ static int only_one_child(struct pci_bus *bus)struct pci_dev *parent = bus->self;if (!parent || !pci_is_pcie (parent))return 0 ; - if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT || +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which
(quoted diff) +1
-0+ * one upstream and one downstream port are plugged into adownstream
drivers/pci/probe.c static int only_one_child(struct pci_bus *bus) · line 1290
Quoted 7 lines
drivers/pci/probe.c +4
-0+* port. Avoiding the downstream port check here results in a +* functional system. +*/ +if (!dmi_name_in_vendors ("ftServer" )&& parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM )return 1 ;return 0 ;
dmi_name_in_vendorsis relatively expensive, so the order of these two
should be swapped, at least:Quoted 7 lines
Quoted 2 lines
if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM&&!dmi_name_in_vendors("ftServer"))
Plus, this gets called for every PCI bridge. We should be caching it
somewhere, so it's only called once.Then i recommend a
dmi_name_in_vendors()check at init; stick result in
global (or local static), and then it's not exec'd on each bridge, just
a simple flag check.
If that's the case, I'd re-cast my vote for putting the code inpci_quirks
with an export, so it is tracked as a quirk. that may get messy wrt other arches though (the export in common code; not sure if quirks is
included on all arches).
Quoted 2 lines · James Paradis
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running
Hearsay? if you have definite cases, then please share them,
so folks know when to flip the boot parameter on. note: it would have to be an early boot param as well.
Quoted 70 lines
into similar issues... if we don't know exactly which systems these are then maybe a boot parameter would be a more flexible approach...
--jim
----- Original Message -----
Quoted 46 lines · Matthew Wilcox
Quoted 38 lines · Prarit Bhargava
Quoted 25 lines
Stratus systems have a hierarchy that includes a PCIE Downstream bridge
connected to a PCIE Upstream bridge and a PCI Downstream bridge.
The system
boots with this wrong hierarchy into a crippled mode (USB doesn't work,
network doesn't work ...). Avoiding the Downstream bridge check inonly_one_child()causes all the bridges to be enumerated and the system
to function properly.drivers/pci/probe.c +4
-1@@ -1275,7 +1276,15 @@ static int only_one_child(struct pci_bus *bus)struct pci_dev *parent = bus->self;if (!parent || !pci_is_pcie (parent))return 0 ; - if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT || +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which
(quoted diff) +1
-0+ * one upstream and one downstream port are plugged into adownstream
drivers/pci/probe.c static int only_one_child(struct pci_bus *bus) · line 1290
Quoted 7 lines
drivers/pci/probe.c +4
-0+* port. Avoiding the downstream port check here results in a +* functional system. +*/ +if (!dmi_name_in_vendors ("ftServer" )&& parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM )return 1 ;return 0 ;
dmi_name_in_vendorsis relatively expensive, so the order of these two
should be swapped, at least:Quoted 7 lines
Quoted 2 lines
if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM&&!dmi_name_in_vendors("ftServer"))
Plus, this gets called for every PCI bridge. We should be caching it
somewhere, so it's only called once.Quoted 13 lines
Then i recommend a
dmi_name_in_vendors()check at init; stick result in
global (or local static), and then it's not exec'd on each bridge, just
a simple flag check.
If that's the case, I'd re-cast my vote for putting the code inpci_quirks
with an export, so it is tracked as a quirk. that may get messy wrt other arches though (the export in common code; not sure if quirks is
included on all arches).--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas
maintainerQuoted 8 lines · Don Dutile
Quoted 3 lines · James Paradis
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running
Hearsay? if you have definite cases, then please share them,
so folks know when to flip the boot parameter on. note: it would have to be an early boot param as well.
It'd definitely be good to know all the specific cases.
But merely sharing them so folks will know when to use the parameter is a broken model. We should make it work automatically, either with some sort of machine-dependent quirk, or (preferably) with a change to the generic algorithm so it can handle these "broken" topologies along with all the correct ones.
Bjorn
Quoted 12 lines · Bjorn Helgaas
Quoted 8 lines · Don Dutile
Quoted 3 lines · James Paradis
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running
Hearsay? if you have definite cases, then please share them,
so folks know when to flip the boot parameter on. note: it would have to be an early boot param as well.It'd definitely be good to know all the specific cases.
Quoted 7 lines
But merely sharing them so folks will know when to use the parameter is a broken model. We should make it work automatically, either with some sort of machine-dependent quirk, or (preferably) with a change to the generic algorithm so it can handle these "broken" topologies along with all the correct ones.
Bjorn
In this case, doing a check that the parent is downstream PPB and the child is downstream PPB could be done to identify the broken topology and automatically scan dev nums > 0.
Quoted 7 lines · Don Dutile
Quoted 6 lines · Bjorn Helgaas
Quoted 5 lines · Don Dutile
Quoted 3 lines · James Paradis
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Hearsay? if you have definite cases, then please share them,
so folks know when to flip the boot parameter on. note: it would have to be an early boot param as well.It'd definitely be good to know all the specific cases.
But merely sharing them so folks will know when to use the parameter is a broken model.
Yeah -- I'd rather do something that "works", but I'm not sure we can without dropping the only_one_child() check.
We should make it work automatically, either with
Quoted 3 lines
Quoted 3 lines
some sort of machine-dependent quirk, or (preferably) with a change to the generic algorithm so it can handle these "broken" topologies along with all the correct ones.
The problem is when I'm examining "this" PCIE bridge I have no knowledge of the remaining hierarchy below it. In order to find the broken topology we need to do a two pass enumeration (NO.) or minimally query all possible devices immediately connected to it. If we do that then what is the purpose of the only_one_child() check?
Quoted 3 lines
In this case, doing a check that the parent is downstream PPB and the child is downstream PPB could be done to identify the broken topology and automatically scan dev nums > 0.
I'm in favor of adding a kernel parameter that in addition to implementing the workaround Stratus will have, will also dump out a HW_ERR broken message of some sort. I don't want to see a stack trace.
... maybe we need to add in a pci_bridge_quirk() or something?
P.
Quoted 7 lines · Prarit Bhargava
On 11/11/2011 03:35 PM, Don Dutile wrote:
We should make it work automatically, either withQuoted 3 lines
Quoted 3 lines
some sort of machine-dependent quirk, or (preferably) with a change to the generic algorithm so it can handle these "broken" topologies along with all the correct ones.
The problem is when I'm examining "this" PCIE bridge I have no knowledge of the remaining hierarchy below it. In order to find the broken topology we need to do a two pass enumeration (NO.) or minimally query all possible devices immediately connected to it. If we do that then what is the purpose of the
only_one_child()check?
We have enough information to do this quirk.
pci_scan_slot calls pci_scan_single_device() for the devfn 0. We can look at the device we found and quirk the parent device. Something like this ...
int pci_scan_slot(struct pci_bus *bus, int devfn)
[...]
dev = pci_scan_single_device(bus, devfn); if (!dev) return 0; if (!dev->is_added) nr++;
+ /* Quirk to fix NEC/Stratus broken PCIe topologies */
+ if ((dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) &&
+ (bus->self->pcie_type == PCI_EXP_TYPE_DOWNSTREAM))
+ bus->self->pcie_type = PCI_EXP_TYPE_UPSTREAM;
if (pci_ari_enabled(bus)) next_fn = next_ari_fn;
[...]
As an aside, I'm quite shocked that this patch has been in the kernel for almost two years and this is the first time anybody's tested it on one of these systems.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 22 lines · Matthew Wilcox
Quoted 7 lines · Prarit Bhargava
On 11/11/2011 03:35 PM, Don Dutile wrote:
We should make it work automatically, either withQuoted 3 lines
Quoted 3 lines
some sort of machine-dependent quirk, or (preferably) with a change to the generic algorithm so it can handle these "broken" topologies along with all the correct ones.
The problem is when I'm examining "this" PCIE bridge I have no knowledge of the remaining hierarchy below it. In order to find the broken topology we need to do a two pass enumeration (NO.) or minimally query all possible devices immediately connected to it. If we do that then what is the purpose of the
only_one_child()check?We have enough information to do this quirk.
pci_scan_slotcallspci_scan_single_device()for the devfn 0. We can look at the device we found and quirk the parent device. Something like this ...int
pci_scan_slot(struct pci_bus *bus, int devfn)
[...]dev = pci_scan_single_device(bus, devfn); if (!dev) return 0; if (!dev->is_added) nr++;
Review
Quoted 4 lines
(quoted diff) +4
-0+ /* Quirk to fix NEC/Stratus broken PCIe topologies */ + if ((dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) && + (bus->self->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) + bus->self->pcie_type = PCI_EXP_TYPE_UPSTREAM;
I'm undoubtedly missing something obvious here, or I'm being dense.
This only works if there is a single Down bridge connected to a single Down bridge. What Stratus/NEC has is a single Up bridge (02:00.0) connected to a Up bridge (03:00.0) and a Down bridge (03:01.0), which we know to be illegal in PCIE. So the scan of the first bridge, 03:00.0 works and no fixup is done. The code still misses the second bridge, 03:01.0.
Again -- I'm likely not seeing the bigger picture here or I'm missing something obvious why your patch works ... care to explain in detail?
Quoted 5 lines
As an aside, I'm quite shocked that this patch has been in the kernel for almost two years and this is the first time anybody's tested it on one of these systems.
Heh ... we recently have asked some of our partners to monitor upstream more closely to avoid last minute "gotchyas" exactly like this one.
P.
Trying [v2]....
pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check in only_one_child() causes all the bridges to be enumerated and the system to function properly.
Unfortunately this hardware is currently available so we should at least keep it functional.
[v2]
- [email protected] requested drivers/pci/quirks.c code
- [email protected] requested that dmi_name_in_vendors() be called only once with a static var check
- added a kernel parameter to enable scanning of all PCIE devices.
Documentation/kernel-parameters.txt +1 -0
@@ -2069,6 +2069,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. on: Turn ECRC on. realloc reallocate PCI resources if allocations done by BIOS are erroneous. + pcie_scan_all Scan all possible PCIE devices. pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management.
drivers/pci/pci.c +3 -0
@@ -3589,6 +3589,9 @@ static int __init pci_setup(char *str) pcie_bus_config =PCIE_BUS_PERFORMANCE ; }else if (!strncmp (str,"pcie_bus_peer2peer" ,18 )) { pcie_bus_config =PCIE_BUS_PEER2PEER ; + }else if (!strncmp (str,"pcie_scan_all" ,13 )) { + printk(KERN_ERR HW_ERR "PCIE: Scanning all devices.\n"); + pcie_scan_all =1 ; }else {printk (KERN_ERR "PCI: Unknown option `%s'\n" , str);
drivers/pci/pci.h +5 -0
@@ -309,11 +309,16 @@ struct pci_dev_reset_methods {#ifdef CONFIG_PCI_QUIRKS extern int pci_dev_specific_reset (struct pci_dev *dev,int probe); +extern int is_broken_pcie_port (void );#else static inline int pci_dev_specific_reset (struct pci_dev *dev,int probe) {return -ENOTTY ; } +static inline int is_broken_pcie_port (void ) +{ +return 0 ; +}#endif #endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +7 -2
@@ -1270,13 +1270,18 @@ static unsigned no_next_fn(struct pci_dev *dev, unsigned fn)return 0 ; } +int pcie_scan_all =0 ;/* set via pci=pcie_scan_all */ static int only_one_child (struct pci_bus *bus) {struct pci_dev *parent = bus->self; +if (pcie_scan_all) +return 0 ;if (!parent || !pci_is_pcie (parent))return 0 ; -if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT || - parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM ) +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +if (parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM && + !is_broken_pcie_port ())return 1 ;return 0 ; }
drivers/pci/quirks.c +18 -0
@@ -3092,3 +3092,21 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)return -ENOTTY ; } + +static int _is_broken_pcie_port =-1 ; +int is_broken_pcie_port (void ) +{ +if (_is_broken_pcie_port >=0 ) +return _is_broken_pcie_port; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which +* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check in only_one_child() results +* in a functional system. +*/ +if (dmi_name_in_vendors ("ftServer" )) + _is_broken_pcie_port =1 ; +else + _is_broken_pcie_port =0 ; +return _is_broken_pcie_port; +}
include/linux/pci.h +2 -0
@@ -1647,5 +1647,7 @@ static inline void pci_release_bus_of_node(struct pci_bus *bus) { }*/ struct pci_dev *pci_find_upstream_pcie_bridge (struct pci_dev *pdev); +/* set via pci=pcie_scan_all in order to enumerate all possible PCIE busses */ +extern int pcie_scan_all;#endif /* __KERNEL__ */ #endif /* LINUX_PCI_H */
Quoted 29 lines
Trying [v2]....
pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system
boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check inonly_one_child()causes all the bridges to be enumerated and the system to function properly.Unfortunately this hardware is currently available so we should at least keep it functional.
[v2]
- [email protected] requesteddrivers/pci/quirks.ccode
- [email protected] requested thatdmi_name_in_vendors()be called only once with a static var check
- added a kernel parameter to enable scanning of all PCIE devices.Signed-off-by Prarit Bhargava <[email protected]>drivers/pci/pci.c +0
-0
drivers/pci/pci.c static int __init pci_setup(char *str) · line 3597
Quoted 9 lines
drivers/pci/pci.c +3
-0@@ -3589,6 +3589,9 @@ static int __init pci_setup(char *str) pcie_bus_config =PCIE_BUS_PERFORMANCE ; }else if (!strncmp (str,"pcie_bus_peer2peer" ,18 )) { pcie_bus_config =PCIE_BUS_PEER2PEER ; + }else if (!strncmp (str,"pcie_scan_all" ,13 )) { + printk(KERN_ERR HW_ERR "PCIE: Scanning all devices.\n"); + pcie_scan_all =1 ; }else {printk (KERN_ERR "PCI: Unknown option `%s'\n" , str);
To scan all devices isn't an error, is it? The user has requested this, so KERN_INFO should be enough.
Eike
Bjorn Helgaas
maintainerQuoted 42 lines · Rolf Eike Beer
Quoted 29 lines
Trying [v2]....
pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system
boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check inonly_one_child()causes all the bridges to be enumerated and the system to function properly.Unfortunately this hardware is currently available so we should at least keep it functional.
[v2]
- [email protected] requesteddrivers/pci/quirks.ccode
- [email protected] requested thatdmi_name_in_vendors()be called only once with a static var check
- added a kernel parameter to enable scanning of all PCIE devices.Signed-off-by Prarit Bhargava <[email protected]>drivers/pci/pci.c +0
-0drivers/pci/pci.c static int __init pci_setup(char *str) · line 3597
Quoted 9 lines
drivers/pci/pci.c +3
-0@@ -3589,6 +3589,9 @@ static int __init pci_setup(char *str) pcie_bus_config = PCIE_BUS_PERFORMANCE; } else if (!strncmp(str, "pcie_bus_peer2peer", 18)) { pcie_bus_config = PCIE_BUS_PEER2PEER; + } else if (!strncmp(str, "pcie_scan_all", 13)) { + printk(KERN_ERR HW_ERR "PCIE: Scanning all devices.\n"); + pcie_scan_all = 1; } else { printk(KERN_ERR "PCI: Unknown option `%s'\n", str);To scan all devices isn't an error, is it? The user has requested this, so
KERN_INFOshould be enough.
Quoted 1 line
Eike
Is this problem a regression? If so, what commit caused it? f07852d6442, which introduced only_one_child()?
Does Windows work on this system?
Is this something that could be fixed by a firmware upgrade? If so, is there a Stratus/NEC bug report?
Is there a Red Hat bugzilla URL you could include?
What bad things would happen if we just turned on this Stratus-specific behavior all the time on all systems? It looks like f07852d6442 is basically an optimization that makes pci_scan_slot() faster, so I assume one effect would be to slow down PCI enumeration for everybody. By how much?
Bjorn
Bjorn,
Quoted 3 lines
Is this problem a regression? If so, what commit caused it?
f07852d6442, which introducedonly_one_child()?
That's a tough question to answer. AFAICT the broken (HARDWARE broken) Stratus systems only enumerated properly by chance. Did they work prior to f07852d6? From what jparadis told me, yes. Is it a regression? ... depends on how you look at it.
Quoted 2 lines
Does Windows work on this system?
I don't know. jparadis? Any clue?
Quoted 3 lines
Is this something that could be fixed by a firmware upgrade? If so, is there a Stratus/NEC bug report?
Hmmm, the idea of a FW upgrade somehow fixing this never occurred to me. jparadis? Is that possible?
Quoted 2 lines
Is there a Red Hat bugzilla URL you could include?
Only happens upstream.
Quoted 6 lines
What bad things would happen if we just turned on this Stratus-specific behavior all the time on all systems? It looks like
f07852d6442is basically an optimization that makespci_scan_slot()faster, so I assume one effect would be to slow down PCI enumeration for everybody. By how much?
Not a huge amount -- estimated lt 0.5 seconds on this Stratus system. As for other systems, it obviously depends on how complicated the PCIE hierarchy is.
P.
Quoted 41 lines · Prarit Bhargava
drivers/pci/probe.c +7
-2@@ -1270,13 +1270,18 @@ static unsigned no_next_fn(struct pci_dev *dev, unsigned fn)return 0 ; } +int pcie_scan_all =0 ;/* set via pci=pcie_scan_all */ static int only_one_child (struct pci_bus *bus) {struct pci_dev *parent = bus->self; +if (pcie_scan_all) +return 0 ;if (!parent || !pci_is_pcie (parent))return 0 ; -if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT || - parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM ) +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +if (parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM && + !is_broken_pcie_port ())return 1 ;return 0 ; }drivers/pci/quirks.c +8
-0@@ -3092,3 +3092,21 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)return -ENOTTY ; } + +static int _is_broken_pcie_port =-1 ; +int is_broken_pcie_port (void ) +{ +if (_is_broken_pcie_port >=0 ) +return _is_broken_pcie_port; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which
drivers/pci/quirks.c int pci_dev_specific_reset(struct pci_dev *dev, int probe) · line 3112
Quoted 10 lines
drivers/pci/quirks.c +10
-0+* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check in only_one_child() results +* in a functional system. +*/ +if (dmi_name_in_vendors ("ftServer" )) + _is_broken_pcie_port =1 ; +else + _is_broken_pcie_port =0 ; +return _is_broken_pcie_port; +}
This feels like belt-and-braces. Why don't you just set pcie_scan_all if the DMI string contains ftServer?
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 1 line · Prarit Bhargava
This only works if there is a single Down bridge connected to a single Down bridge. What Stratus/NEC has is a single Up bridge (02:00.0) connected to a Up bridge (03:00.0) and a Down bridge (03:01.0), which we know to be illegal in PCIE. So the scan of the first bridge, 03:00.0 works and no fixup is done. The code still misses the second bridge, 03:01.0.
I'd forgotten that the Down - Down link was at slot 1; I thought it was at slot 0. So this won't help.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 11 lines
Bjorn,
Quoted 3 lines
Is this problem a regression? If so, what commit caused it?
f07852d6442, which introducedonly_one_child()?That's a tough question to answer. AFAICT the broken (HARDWARE broken) Stratus systems only enumerated properly by chance. Did they work prior to
f07852d6? From what jparadis told me, yes. Is it a regression? ... depends on how you look at it.
Yes, that is the commit that caused the problem.
Quoted 3 lines
Quoted 1 line
Does Windows work on this system?
I don't know. jparadis? Any clue?
Windows works just fine on this system, probably because they don't optimize the PCIE scan in this way...
Quoted 6 lines
Quoted 3 lines
Is this something that could be fixed by a firmware upgrade? If so,
is there a Stratus/NEC bug report?Hmmm, the idea of a FW upgrade somehow fixing this never occurred to me. jparadis? Is that possible?
I seriously doubt it, but I can ask the hardware folks at Stratus. I believe that at least some of this topology is baked in...
Quoted 3 lines
Quoted 1 line
Is there a Red Hat bugzilla URL you could include?
Only happens upstream.
Well, to be fair, we actually saw this behavior beginning with Fedora 14, but never pursued the matter until now. I suppose we could have filed a Fedora bug, but we wanted to root-cause the problem first.
--jim
Quoted 24 lines · James Paradis
Quoted 10 lines
Bjorn,
Quoted 3 lines
Is this problem a regression? If so, what commit caused it?
f07852d6442, which introducedonly_one_child()?That's a tough question to answer. AFAICT the broken (HARDWARE broken) Stratus systems only enumerated properly by chance. Did they work prior to
f07852d6? From what jparadis told me, yes. Is it a regression? ... depends on how you look at it.Yes, that is the commit that caused the problem.
Quoted 3 lines
Quoted 1 line
Does Windows work on this system?
I don't know. jparadis? Any clue?
Windows works just fine on this system, probably because they don't optimize the PCIE scan in this way...
Quoted 4 lines
Quoted 3 lines
Is this something that could be fixed by a firmware upgrade? If so,
is there a Stratus/NEC bug report?
Quoted 5 lines
Quoted 2 lines
Hmmm, the idea of a FW upgrade somehow fixing this never occurred to me. jparadis? Is that possible?
I seriously doubt it, but I can ask the hardware folks at Stratus. I believe that at least some of this topology is baked in...
James,
I think a lot of people are wondering why this is only now coming up as the patch in question has been upstream for a couple of years.
While the system has been in the field for awhile - has the I/O subsystem that exhibits this issue been there since the introduction of this type of system -or- is there a new, PCI Express based, I/O subsystem now being introduced that can be used with the original platform and this is why we are just now seeing the issue?
Myron
Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
Is there a Red Hat bugzilla URL you could include?
Only happens upstream.
Well, to be fair, we actually saw this behavior beginning with Fedora 14, but never pursued the matter until now. I suppose we could have filed a Fedora bug, but we wanted to root-cause the problem first.
--jim
Prarit,
FYI, this patch does the trick on Draco. I'll try it in the Stratus lab as well, but I'm 99.99% sure that it will work there too.
There was one concern when we had a meeting at Stratus to talk about this: we're not sure if the NEC-branded systems have the same DMI string or not... I'm trying to find out.
--jim
----- Original Message -----
Quoted 150 lines
Trying [v2]....
pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge
connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system
boots with this wrong hierarchy into a crippled mode (USB doesn't work,
network doesn't work ...). Avoiding the Downstream bridge check inonly_one_child()causes all the bridges to be enumerated and the system
to function properly.Unfortunately this hardware is currently available so we should at least
keep it functional.[v2]
- [email protected] requesteddrivers/pci/quirks.ccode
- [email protected] requested thatdmi_name_in_vendors()be called only once with a static var check
- added a kernel parameter to enable scanning of all PCIE devices.Signed-off-by Prarit Bhargava <[email protected]>Documentation/kernel-parameters.txt +0
-0@@ -2069,6 +2069,7 @@ bytes respectively. Such letter suffixes canalso be entirely omitted.
Documentation/kernel-parameters.txt +1
-0on: Turn ECRC on. realloc reallocate PCI resources if allocations done by BIOS are erroneous. + pcie_scan_all Scan all possible PCIE devices. pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management.drivers/pci/pci.c +3
-0@@ -3589,6 +3589,9 @@ static int __init pci_setup(char *str) pcie_bus_config =PCIE_BUS_PERFORMANCE ; }else if (!strncmp (str,"pcie_bus_peer2peer" ,18 )) { pcie_bus_config =PCIE_BUS_PEER2PEER ; + }else if (!strncmp (str,"pcie_scan_all" ,13 )) { + printk(KERN_ERR HW_ERR "PCIE: Scanning all devices.\n"); + pcie_scan_all =1 ; }else {printk (KERN_ERR "PCI: Unknown option `%s'\n" , str);drivers/pci/pci.h +5
-0@@ -309,11 +309,16 @@ struct pci_dev_reset_methods {#ifdef CONFIG_PCI_QUIRKS extern int pci_dev_specific_reset (struct pci_dev *dev,int probe); +extern int is_broken_pcie_port (void );#else static inline int pci_dev_specific_reset (struct pci_dev *dev,int probe) {return -ENOTTY ; } +static inline int is_broken_pcie_port (void ) +{ +return 0 ; +}#endif #endif /*
DRIVERS_PCI_H*/drivers/pci/probe.c +7
-2@@ -1270,13 +1270,18 @@ static unsigned no_next_fn(struct pci_dev *dev, unsigned fn)return 0 ; } +int pcie_scan_all =0 ;/* set via pci=pcie_scan_all */ static int only_one_child (struct pci_bus *bus) {struct pci_dev *parent = bus->self; +if (pcie_scan_all) +return 0 ;if (!parent || !pci_is_pcie (parent))return 0 ; -if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT || - parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM ) +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +if (parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM && + !is_broken_pcie_port ())return 1 ;return 0 ;}
drivers/pci/quirks.c +8
-0@@ -3092,3 +3092,21 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)return -ENOTTY ; } + +static int _is_broken_pcie_port =-1 ; +int is_broken_pcie_port (void ) +{ +if (_is_broken_pcie_port >=0 ) +return _is_broken_pcie_port; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which
drivers/pci/quirks.c +1
-0+* one upstream and one downstream port are plugged into a downstream
drivers/pci/quirks.c +1
-0+* port. Avoiding the downstream port check in only_one_child() results
drivers/pci/quirks.c +8
-0+* in a functional system. +*/ +if (dmi_name_in_vendors ("ftServer" )) + _is_broken_pcie_port =1 ; +else + _is_broken_pcie_port =0 ; +return _is_broken_pcie_port; +}include/linux/pci.h +1
-0@@ -1647,5 +1647,7 @@ static inline voidpci_release_bus_of_node(struct pci_bus *bus) { } */ struct pci_dev *pci_find_upstream_pcie_bridge (struct pci_dev *pdev); +/* set via pci=pcie_scan_all in order to enumerate all possible PCIE busses */
+extern intpcie_scan_all;
#endif /*__KERNEL__*/
#endif /*LINUX_PCI_H*/
Quoted 6 lines
James,
I think a lot of people are wondering why this is only now coming up as
the patch in question has been upstream for a couple of years.
Quoted 6 lines
While the system has been in the field for awhile - has the I/O subsystem that exhibits this issue been there since the introduction of
this type of system -or- is there a new, PCI Express based, I/O subsystem now being introduced that can be used with the original platform and this is why we are just now seeing the issue?
This system has been available since late 2009, and the I/O subsystem has not changed since its introduction. One reason we haven't seen this problem until now is that RHEL6 (kernel 2.6.32) is the only supported Linux operating system for this platform, and this problem surfaced in 2.6.34. I found this problem because I recently started thinking ahead to RHEL7 and so started trying to work with recent Fedora releases. It looks like from now on I'm going to be banging on upstream kernels as soon as they come out so we catch this sort of thing sooner...
--jim
BTW - for everyone's edification, here is a report on fedoraforum.org that looks suspiciously like the same problem we're dealing with:
http://forums.fedoraforum.org/showthread.php?t=255025
The mobo worked with F13, broke with F14, nothing he did seemed to bring the keyboard back, ended up fixing it by getting another brand of motherboard. I'm going to see if I can find a copy of that motherboard for testing...
--jim
----- Original Message -----
Quoted 24 lines
Quoted 9 lines · Don Dutile
Quoted 3 lines · James Paradis
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running
Hearsay? if you have definite cases, then please share them, so folks know when to flip the boot parameter on. note: it would have to be
an early boot param as well.It'd definitely be good to know all the specific cases.
But merely sharing them so folks will know when to use the parameter is a broken model. We should make it work automatically, either with some sort of machine-dependent quirk, or (preferably) with a change to
the generic algorithm so it can handle these "broken" topologies along
with all the correct ones.Bjorn
Quoted 4 lines · James Paradis
BTW - for everyone's edification, here is a report on fedoraforum.org that looks suspiciously like the same problem we're dealing with:
Quoted 9 lines
http://forums.fedoraforum.org/showthread.php?t=255025
The mobo worked with F13, broke with F14, nothing he did seemed to bring the keyboard back, ended up fixing it by getting another brand of motherboard. I'm going to see if I can find a copy of that motherboard for testing...
--jim
No, the original mobo worked on F13; new mobo broken on f13 & f14. It sounds like an intr-rewiring problem; note, that he got it booted once, (in the thread) and it took 30mins to do so.
Quoted 25 lines
----- Original Message -----
Quoted 24 lines
Quoted 9 lines · Don Dutile
Quoted 3 lines · James Paradis
Hmmm... would it be better to do this as a quirk or as a boot parameter? I've heard reports that other systems may be running
Hearsay? if you have definite cases, then please share them, so folks know when to flip the boot parameter on. note: it would have to be
an early boot param as well.It'd definitely be good to know all the specific cases.
But merely sharing them so folks will know when to use the parameter is a broken model. We should make it work automatically, either with some sort of machine-dependent quirk, or (preferably) with a change to
the generic algorithm so it can handle these "broken" topologies along
with all the correct ones.Bjorn
pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check in only_one_child() causes all the bridges to be enumerated and the system to function properly.
Unfortunately this hardware is currently available so we should at least keep it functional.
[v2]
- [email protected] requested drivers/pci/quirks.c code
- [email protected] requested that dmi_name_in_vendors() be called only once with a static var check
- added a kernel parameter to enable scanning of all PCIE devices.
[v3]
- [email protected] requested a clean up of is_broken_pcie_port(
- [email protected] requested a clean up of the printk level and message
Documentation/kernel-parameters.txt +1 -0
@@ -2069,6 +2069,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. on: Turn ECRC on. realloc reallocate PCI resources if allocations done by BIOS are erroneous. + pcie_scan_all Scan all possible PCIE devices. pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management.
drivers/pci/pci.c +3 -0
@@ -3589,6 +3589,9 @@ static int __init pci_setup(char *str) pcie_bus_config =PCIE_BUS_PERFORMANCE ; }else if (!strncmp (str,"pcie_bus_peer2peer" ,18 )) { pcie_bus_config =PCIE_BUS_PEER2PEER ; + }else if (!strncmp (str,"pcie_scan_all" ,13 )) { + printk(KERN_INFO HW_ERR "PCIE: User request scan of all PCIE devices. Your PCIE hardware is broken if you require this to boot.\n"); + pcie_scan_all =1 ; }else {printk (KERN_ERR "PCI: Unknown option `%s'\n" , str);
drivers/pci/pci.h +5 -0
@@ -309,11 +309,16 @@ struct pci_dev_reset_methods {#ifdef CONFIG_PCI_QUIRKS extern int pci_dev_specific_reset (struct pci_dev *dev,int probe); +extern int is_broken_pcie_port (void );#else static inline int pci_dev_specific_reset (struct pci_dev *dev,int probe) {return -ENOTTY ; } +static inline int is_broken_pcie_port (void ) +{ +return 0 ; +}#endif #endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +7 -2
@@ -1270,13 +1270,18 @@ static unsigned no_next_fn(struct pci_dev *dev, unsigned fn)return 0 ; } +int pcie_scan_all =0 ;/* set via pci=pcie_scan_all */ static int only_one_child (struct pci_bus *bus) {struct pci_dev *parent = bus->self; +if (pcie_scan_all) +return 0 ;if (!parent || !pci_is_pcie (parent))return 0 ; -if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT || - parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM ) +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +if (parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM && + !is_broken_pcie_port ())return 1 ;return 0 ; }
drivers/pci/quirks.c +14 -0
@@ -3092,3 +3092,17 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)return -ENOTTY ; } + +int is_broken_pcie_port (void ) +{ +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which +* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check in only_one_child() results +* in a functional system. +*/ +if (dmi_name_in_vendors ("ftServer" )) + pcie_scan_all =1 ; + +return pcie_scan_all; +}
include/linux/pci.h +2 -0
@@ -1647,5 +1647,7 @@ static inline void pci_release_bus_of_node(struct pci_bus *bus) { }*/ struct pci_dev *pci_find_upstream_pcie_bridge (struct pci_dev *pdev); +/* set via pci=pcie_scan_all in order to enumerate all possible PCIE busses */ +extern int pcie_scan_all;#endif /* __KERNEL__ */ #endif /* LINUX_PCI_H */
[v2]
- [email protected] requested drivers/pci/quirks.c code
- [email protected] requested that dmi_name_in_vendors() be called only once with a static var check
- added a kernel parameter to enable scanning of all PCIE devices.
[v3]
- [email protected] requested a clean up of is_broken_pcie_port(
- [email protected] requested a clean up of the printk level and message
[v4]
- ddutile pointed out a logic error in is_broken_pcie_port. It was no longer being called only once on failure.
----8<----
pci: Workaround Stratus broken PCIE hierarchy
Stratus systems have a hierarchy that includes a PCIE Downstream bridge connected to a PCIE Upstream bridge and a PCI Downstream bridge. The system boots with this wrong hierarchy into a crippled mode (USB doesn't work, network doesn't work ...). Avoiding the Downstream bridge check in only_one_child() causes all the bridges to be enumerated and the system to function properly.
Unfortunately this hardware is currently available so we should at least keep it functional.
Documentation/kernel-parameters.txt +1 -0
@@ -2069,6 +2069,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. on: Turn ECRC on. realloc reallocate PCI resources if allocations done by BIOS are erroneous. + pcie_scan_all Scan all possible PCIE devices. pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management.
drivers/pci/pci.c +3 -0
@@ -3589,6 +3589,9 @@ static int __init pci_setup(char *str) pcie_bus_config =PCIE_BUS_PERFORMANCE ; }else if (!strncmp (str,"pcie_bus_peer2peer" ,18 )) { pcie_bus_config =PCIE_BUS_PEER2PEER ; + }else if (!strncmp (str,"pcie_scan_all" ,13 )) { + printk(KERN_INFO HW_ERR "PCIE: User request scan of all PCIE devices. Your PCIE hardware is broken if you require this to boot.\n"); + pcie_scan_all =1 ; }else {printk (KERN_ERR "PCI: Unknown option `%s'\n" , str);
drivers/pci/pci.h +5 -0
@@ -309,11 +309,16 @@ struct pci_dev_reset_methods {#ifdef CONFIG_PCI_QUIRKS extern int pci_dev_specific_reset (struct pci_dev *dev,int probe); +extern int is_broken_pcie_port (void );#else static inline int pci_dev_specific_reset (struct pci_dev *dev,int probe) {return -ENOTTY ; } +static inline int is_broken_pcie_port (void ) +{ +return 0 ; +}#endif #endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +7 -2
@@ -1270,13 +1270,18 @@ static unsigned no_next_fn(struct pci_dev *dev, unsigned fn)return 0 ; } +int pcie_scan_all =0 ;/* set via pci=pcie_scan_all */ static int only_one_child (struct pci_bus *bus) {struct pci_dev *parent = bus->self; +if (pcie_scan_all) +return 0 ;if (!parent || !pci_is_pcie (parent))return 0 ; -if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT || - parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM ) +if (parent->pcie_type ==PCI_EXP_TYPE_ROOT_PORT ) +return 1 ; +if (parent->pcie_type ==PCI_EXP_TYPE_DOWNSTREAM && + !is_broken_pcie_port ())return 1 ;return 0 ; }
drivers/pci/quirks.c +18 -0
@@ -3092,3 +3092,21 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)return -ENOTTY ; } + +static int is_broken_pcie_port_called; +int is_broken_pcie_port (void ) +{ +if (is_broken_pcie_port_called) +return pcie_scan_all; +/* +* Stratus/NEC ftServer systems have a broken PCIE hierarchy in which +* one upstream and one downstream port are plugged into a downstream +* port. Avoiding the downstream port check in only_one_child() results +* in a functional system. +*/ +if (dmi_name_in_vendors ("ftServer" )) + pcie_scan_all =1 ; + + is_broken_pcie_port_called =1 ; +return pcie_scan_all; +}
include/linux/pci.h +2 -0
@@ -1647,5 +1647,7 @@ static inline void pci_release_bus_of_node(struct pci_bus *bus) { }*/ struct pci_dev *pci_find_upstream_pcie_bridge (struct pci_dev *pdev); +/* set via pci=pcie_scan_all in order to enumerate all possible PCIE busses */ +extern int pcie_scan_all;#endif /* __KERNEL__ */ #endif /* LINUX_PCI_H */