* [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges
@ 2019-01-23 8:24 David Hildenbrand
2019-01-23 14:23 ` David Hildenbrand
2019-01-24 2:48 ` Alexey Kardashevskiy
0 siblings, 2 replies; 5+ messages in thread
From: David Hildenbrand @ 2019-01-23 8:24 UTC (permalink / raw)
To: qemu-devel; +Cc: David Gibson, Nikunj A Dadhania, qemu-ppc, David Hildenbrand
While looking at the s390x implementation, looks like spapr has a
similar BUG when building the topology.
The primary bus number corresponds always to the bus number of the
bus the bridge is attached to.
Right now, if we have two bridges attached to the same bus (e.g. root
bus) this is however not the case. The first bridge will have primary
bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment.
While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff.
Setting it temporarily to that value (as discussed e.g. in [1]), is
only relevant for a running system that probes the buses. The value is
effectively unused for us just doing a DFS.
[1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html
Note: Is hotplug of bridges supported? I can't find where the topology
is fixed up when hotplugging a PCI bridge. (e.g. bus numbers assigned
and PCI_SUBORDINATE_BUS of path to the root updated). But maybe we are
excluding bridges or this is not necessary for some reason.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/ppc/spapr_pci.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index b74f2632ec..5cdc98513d 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -2030,8 +2030,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
void *opaque)
{
unsigned int *bus_no = opaque;
- unsigned int primary = *bus_no;
- unsigned int subordinate = 0xff;
PCIBus *sec_bus = NULL;
if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=
@@ -2040,7 +2038,7 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
}
(*bus_no)++;
- pci_default_write_config(pdev, PCI_PRIMARY_BUS, primary, 1);
+ pci_default_write_config(pdev, PCI_PRIMARY_BUS, pci_dev_bus_num(pdev), 1);
pci_default_write_config(pdev, PCI_SECONDARY_BUS, *bus_no, 1);
pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
@@ -2049,7 +2047,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
return;
}
- pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, subordinate, 1);
pci_for_each_device(sec_bus, pci_bus_num(sec_bus),
spapr_phb_pci_enumerate_bridge, bus_no);
pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
--
2.17.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges
2019-01-23 8:24 [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges David Hildenbrand
@ 2019-01-23 14:23 ` David Hildenbrand
2019-01-24 2:48 ` Alexey Kardashevskiy
1 sibling, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2019-01-23 14:23 UTC (permalink / raw)
To: qemu-devel; +Cc: David Gibson, Nikunj A Dadhania, qemu-ppc
On 23.01.19 09:24, David Hildenbrand wrote:
> While looking at the s390x implementation, looks like spapr has a
> similar BUG when building the topology.
>
> The primary bus number corresponds always to the bus number of the
> bus the bridge is attached to.
>
> Right now, if we have two bridges attached to the same bus (e.g. root
> bus) this is however not the case. The first bridge will have primary
> bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment.
>
> While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff.
> Setting it temporarily to that value (as discussed e.g. in [1]), is
> only relevant for a running system that probes the buses. The value is
> effectively unused for us just doing a DFS.
>
> [1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html
>
> Note: Is hotplug of bridges supported? I can't find where the topology
> is fixed up when hotplugging a PCI bridge. (e.g. bus numbers assigned
> and PCI_SUBORDINATE_BUS of path to the root updated). But maybe we are
> excluding bridges or this is not necessary for some reason.
This note can be dropped. I learned that this is under guest control.
(which has to reserve bus numbers and rebuild the topology)
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> hw/ppc/spapr_pci.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index b74f2632ec..5cdc98513d 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -2030,8 +2030,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> void *opaque)
> {
> unsigned int *bus_no = opaque;
> - unsigned int primary = *bus_no;
> - unsigned int subordinate = 0xff;
> PCIBus *sec_bus = NULL;
>
> if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=
> @@ -2040,7 +2038,7 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> }
>
> (*bus_no)++;
> - pci_default_write_config(pdev, PCI_PRIMARY_BUS, primary, 1);
> + pci_default_write_config(pdev, PCI_PRIMARY_BUS, pci_dev_bus_num(pdev), 1);
> pci_default_write_config(pdev, PCI_SECONDARY_BUS, *bus_no, 1);
> pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
>
> @@ -2049,7 +2047,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> return;
> }
>
> - pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, subordinate, 1);
> pci_for_each_device(sec_bus, pci_bus_num(sec_bus),
> spapr_phb_pci_enumerate_bridge, bus_no);
> pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges
2019-01-23 8:24 [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges David Hildenbrand
2019-01-23 14:23 ` David Hildenbrand
@ 2019-01-24 2:48 ` Alexey Kardashevskiy
2019-01-25 9:28 ` David Hildenbrand
2019-01-26 1:42 ` David Gibson
1 sibling, 2 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2019-01-24 2:48 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel; +Cc: qemu-ppc, Nikunj A Dadhania, David Gibson
On 23/01/2019 19:24, David Hildenbrand wrote:
> While looking at the s390x implementation, looks like spapr has a
> similar BUG when building the topology.
>
> The primary bus number corresponds always to the bus number of the
> bus the bridge is attached to.
>
> Right now, if we have two bridges attached to the same bus (e.g. root
> bus) this is however not the case. The first bridge will have primary
> bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment.
>
> While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff.
> Setting it temporarily to that value (as discussed e.g. in [1]), is
> only relevant for a running system that probes the buses. The value is
> effectively unused for us just doing a DFS.
What is DFS?
>
> [1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html
>
> Note: Is hotplug of bridges supported? I can't find where the topology
> is fixed up when hotplugging a PCI bridge. (e.g. bus numbers assigned
> and PCI_SUBORDINATE_BUS of path to the root updated). But maybe we are
> excluding bridges or this is not necessary for some reason.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> hw/ppc/spapr_pci.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index b74f2632ec..5cdc98513d 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -2030,8 +2030,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> void *opaque)
> {
> unsigned int *bus_no = opaque;
> - unsigned int primary = *bus_no;
> - unsigned int subordinate = 0xff;
> PCIBus *sec_bus = NULL;
>
> if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=
> @@ -2040,7 +2038,7 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> }
>
> (*bus_no)++;
> - pci_default_write_config(pdev, PCI_PRIMARY_BUS, primary, 1);
> + pci_default_write_config(pdev, PCI_PRIMARY_BUS, pci_dev_bus_num(pdev), 1);
> pci_default_write_config(pdev, PCI_SECONDARY_BUS, *bus_no, 1);
> pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
>
> @@ -2049,7 +2047,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> return;
> }
>
> - pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, subordinate, 1);
> pci_for_each_device(sec_bus, pci_bus_num(sec_bus),
> spapr_phb_pci_enumerate_bridge, bus_no);
> pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
>
--
Alexey
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges
2019-01-24 2:48 ` Alexey Kardashevskiy
@ 2019-01-25 9:28 ` David Hildenbrand
2019-01-26 1:42 ` David Gibson
1 sibling, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2019-01-25 9:28 UTC (permalink / raw)
To: Alexey Kardashevskiy, qemu-devel
Cc: qemu-ppc, Nikunj A Dadhania, David Gibson
On 24.01.19 03:48, Alexey Kardashevskiy wrote:
>
>
> On 23/01/2019 19:24, David Hildenbrand wrote:
>> While looking at the s390x implementation, looks like spapr has a
>> similar BUG when building the topology.
>>
>> The primary bus number corresponds always to the bus number of the
>> bus the bridge is attached to.
>>
>> Right now, if we have two bridges attached to the same bus (e.g. root
>> bus) this is however not the case. The first bridge will have primary
>> bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment.
>>
>> While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff.
>> Setting it temporarily to that value (as discussed e.g. in [1]), is
>> only relevant for a running system that probes the buses. The value is
>> effectively unused for us just doing a DFS.
>
> What is DFS?
Depth-first search :)
>
>>
>> [1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html
>>
>> Note: Is hotplug of bridges supported? I can't find where the topology
>> is fixed up when hotplugging a PCI bridge. (e.g. bus numbers assigned
>> and PCI_SUBORDINATE_BUS of path to the root updated). But maybe we are
>> excluding bridges or this is not necessary for some reason.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>
>
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
>
Thanks!
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges
2019-01-24 2:48 ` Alexey Kardashevskiy
2019-01-25 9:28 ` David Hildenbrand
@ 2019-01-26 1:42 ` David Gibson
1 sibling, 0 replies; 5+ messages in thread
From: David Gibson @ 2019-01-26 1:42 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: David Hildenbrand, qemu-devel, qemu-ppc, Nikunj A Dadhania
[-- Attachment #1: Type: text/plain, Size: 3185 bytes --]
On Thu, Jan 24, 2019 at 01:48:36PM +1100, Alexey Kardashevskiy wrote:
>
>
> On 23/01/2019 19:24, David Hildenbrand wrote:
> > While looking at the s390x implementation, looks like spapr has a
> > similar BUG when building the topology.
> >
> > The primary bus number corresponds always to the bus number of the
> > bus the bridge is attached to.
> >
> > Right now, if we have two bridges attached to the same bus (e.g. root
> > bus) this is however not the case. The first bridge will have primary
> > bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment.
> >
> > While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff.
> > Setting it temporarily to that value (as discussed e.g. in [1]), is
> > only relevant for a running system that probes the buses. The value is
> > effectively unused for us just doing a DFS.
>
> What is DFS?
>
> >
> > [1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html
> >
> > Note: Is hotplug of bridges supported? I can't find where the topology
> > is fixed up when hotplugging a PCI bridge. (e.g. bus numbers assigned
> > and PCI_SUBORDINATE_BUS of path to the root updated). But maybe we are
> > excluding bridges or this is not necessary for some reason.
> >
> > Signed-off-by: David Hildenbrand <david@redhat.com>
>
>
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Applied, thanks.
>
>
> > ---
> > hw/ppc/spapr_pci.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> > index b74f2632ec..5cdc98513d 100644
> > --- a/hw/ppc/spapr_pci.c
> > +++ b/hw/ppc/spapr_pci.c
> > @@ -2030,8 +2030,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> > void *opaque)
> > {
> > unsigned int *bus_no = opaque;
> > - unsigned int primary = *bus_no;
> > - unsigned int subordinate = 0xff;
> > PCIBus *sec_bus = NULL;
> >
> > if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=
> > @@ -2040,7 +2038,7 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> > }
> >
> > (*bus_no)++;
> > - pci_default_write_config(pdev, PCI_PRIMARY_BUS, primary, 1);
> > + pci_default_write_config(pdev, PCI_PRIMARY_BUS, pci_dev_bus_num(pdev), 1);
> > pci_default_write_config(pdev, PCI_SECONDARY_BUS, *bus_no, 1);
> > pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
> >
> > @@ -2049,7 +2047,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev,
> > return;
> > }
> >
> > - pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, subordinate, 1);
> > pci_for_each_device(sec_bus, pci_bus_num(sec_bus),
> > spapr_phb_pci_enumerate_bridge, bus_no);
> > pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1);
> >
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-27 1:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-23 8:24 [Qemu-devel] [PATCH v1] spapr/pci: Fix primary bus number for PCI bridges David Hildenbrand
2019-01-23 14:23 ` David Hildenbrand
2019-01-24 2:48 ` Alexey Kardashevskiy
2019-01-25 9:28 ` David Hildenbrand
2019-01-26 1:42 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).