All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
@ 2013-03-07 23:16 Alex Williamson
  2013-03-07 23:16 ` [Qemu-devel] [PATCH 1/2] pci_bridge: Use a default map_irq function Alex Williamson
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Alex Williamson @ 2013-03-07 23:16 UTC (permalink / raw)
  To: mst; +Cc: qemu-devel

Rather than have everyone call pci_bridge_map_irq() themselves and
come up with incorrect mapping functions let's use the default PCI
defined swizzle function unless told otherwise.  Then we can also
clean out the duplicate function in pci_bridge_dev.  Tested with an
assigned device behind a PCIe switch behind a PCIe root port at
addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
option to find devices behind PCIe ports if not addr=0.0.  Windows
finds them but won't use them (code 10).

This replaces the ioh3420 & xio3130 upstream/downstream patches.
Thanks,

Alex

---

Alex Williamson (2):
      pci_bridge: Use a default map_irq function
      pci_bridge: Remove duplicate IRQ swizzle function


 hw/pci/pci_bridge.c |    2 +-
 hw/pci_bridge_dev.c |    9 ---------
 2 files changed, 1 insertion(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 1/2] pci_bridge: Use a default map_irq function
  2013-03-07 23:16 [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Alex Williamson
@ 2013-03-07 23:16 ` Alex Williamson
  2013-03-07 23:17 ` [Qemu-devel] [PATCH 2/2] pci_bridge: Remove duplicate IRQ swizzle function Alex Williamson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Alex Williamson @ 2013-03-07 23:16 UTC (permalink / raw)
  To: mst; +Cc: qemu-devel

The PCI bridge spec defines a default swizzle for translating INTx
IRQs from secondary bus to primary.  Use this by default for any
bridge that doesn't set a function.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/pci/pci_bridge.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 84e7c19..5d27fa2 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -367,7 +367,7 @@ int pci_bridge_initfn(PCIDevice *dev)
     qbus_create_inplace(&sec_bus->qbus, TYPE_PCI_BUS, &dev->qdev,
                         br->bus_name);
     sec_bus->parent_dev = dev;
-    sec_bus->map_irq = br->map_irq;
+    sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn;
     sec_bus->address_space_mem = &br->address_space_mem;
     memory_region_init(&br->address_space_mem, "pci_bridge_pci", INT64_MAX);
     sec_bus->address_space_io = &br->address_space_io;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/2] pci_bridge: Remove duplicate IRQ swizzle function
  2013-03-07 23:16 [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Alex Williamson
  2013-03-07 23:16 ` [Qemu-devel] [PATCH 1/2] pci_bridge: Use a default map_irq function Alex Williamson
@ 2013-03-07 23:17 ` Alex Williamson
  2013-03-10 16:16 ` [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Michael S. Tsirkin
  2013-03-10 16:17 ` Michael S. Tsirkin
  3 siblings, 0 replies; 9+ messages in thread
From: Alex Williamson @ 2013-03-07 23:17 UTC (permalink / raw)
  To: mst; +Cc: qemu-devel

pci_bridge_dev_map_irq_fn() is identical to pci_swizzle_map_irq_fn(),
which is now the default for all PCI bridges.  We can therefore remove
this function and the pci_bridge_map_irq() call that used it.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/pci_bridge_dev.c |    9 ---------
 1 file changed, 9 deletions(-)

diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c
index 1124c53..710f688 100644
--- a/hw/pci_bridge_dev.c
+++ b/hw/pci_bridge_dev.c
@@ -36,21 +36,12 @@ struct PCIBridgeDev {
 };
 typedef struct PCIBridgeDev PCIBridgeDev;
 
-/* Mapping mandated by PCI-to-PCI Bridge architecture specification,
- * revision 1.2 */
-/* Table 9-1: Interrupt Binding for Devices Behind a Bridge */
-static int pci_bridge_dev_map_irq_fn(PCIDevice *dev, int irq_num)
-{
-    return (irq_num + PCI_SLOT(dev->devfn)) % PCI_NUM_PINS;
-}
-
 static int pci_bridge_dev_initfn(PCIDevice *dev)
 {
     PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
     PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br);
     int err;
 
-    pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn);
     err = pci_bridge_initfn(dev);
     if (err) {
         goto bridge_error;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
  2013-03-07 23:16 [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Alex Williamson
  2013-03-07 23:16 ` [Qemu-devel] [PATCH 1/2] pci_bridge: Use a default map_irq function Alex Williamson
  2013-03-07 23:17 ` [Qemu-devel] [PATCH 2/2] pci_bridge: Remove duplicate IRQ swizzle function Alex Williamson
@ 2013-03-10 16:16 ` Michael S. Tsirkin
  2013-03-10 18:13   ` Alex Williamson
  2013-03-10 16:17 ` Michael S. Tsirkin
  3 siblings, 1 reply; 9+ messages in thread
From: Michael S. Tsirkin @ 2013-03-10 16:16 UTC (permalink / raw)
  To: Alex Williamson; +Cc: qemu-devel

On Thu, Mar 07, 2013 at 04:16:48PM -0700, Alex Williamson wrote:
> Rather than have everyone call pci_bridge_map_irq() themselves and
> come up with incorrect mapping functions let's use the default PCI
> defined swizzle function unless told otherwise.  Then we can also
> clean out the duplicate function in pci_bridge_dev.  Tested with an
> assigned device behind a PCIe switch behind a PCIe root port at
> addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
> option to find devices behind PCIe ports if not addr=0.0.  Windows
> finds them but won't use them (code 10).

I'm guessing this only applies to downstream ports right?
The spec IIRC says that slot is ignored.
The real way is probably by making a device an endpoint
integrated into the switch, so it's behind the upstream port.

> This replaces the ioh3420 & xio3130 upstream/downstream patches.
> Thanks,
> 
> Alex
> 
> ---
> 
> Alex Williamson (2):
>       pci_bridge: Use a default map_irq function
>       pci_bridge: Remove duplicate IRQ swizzle function
> 
> 
>  hw/pci/pci_bridge.c |    2 +-
>  hw/pci_bridge_dev.c |    9 ---------
>  2 files changed, 1 insertion(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
  2013-03-07 23:16 [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Alex Williamson
                   ` (2 preceding siblings ...)
  2013-03-10 16:16 ` [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Michael S. Tsirkin
@ 2013-03-10 16:17 ` Michael S. Tsirkin
  3 siblings, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2013-03-10 16:17 UTC (permalink / raw)
  To: Alex Williamson; +Cc: qemu-devel

On Thu, Mar 07, 2013 at 04:16:48PM -0700, Alex Williamson wrote:
> Rather than have everyone call pci_bridge_map_irq() themselves and
> come up with incorrect mapping functions let's use the default PCI
> defined swizzle function unless told otherwise.  Then we can also
> clean out the duplicate function in pci_bridge_dev.  Tested with an
> assigned device behind a PCIe switch behind a PCIe root port at
> addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
> option to find devices behind PCIe ports if not addr=0.0.  Windows
> finds them but won't use them (code 10).
> 
> This replaces the ioh3420 & xio3130 upstream/downstream patches.
> Thanks,
> 
> Alex

Applied, thanks.

> ---
> 
> Alex Williamson (2):
>       pci_bridge: Use a default map_irq function
>       pci_bridge: Remove duplicate IRQ swizzle function
> 
> 
>  hw/pci/pci_bridge.c |    2 +-
>  hw/pci_bridge_dev.c |    9 ---------
>  2 files changed, 1 insertion(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
  2013-03-10 16:16 ` [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Michael S. Tsirkin
@ 2013-03-10 18:13   ` Alex Williamson
  2013-03-10 18:15     ` Alex Williamson
  2013-03-10 20:29     ` Michael S. Tsirkin
  0 siblings, 2 replies; 9+ messages in thread
From: Alex Williamson @ 2013-03-10 18:13 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

On Sun, 2013-03-10 at 18:16 +0200, Michael S. Tsirkin wrote:
> On Thu, Mar 07, 2013 at 04:16:48PM -0700, Alex Williamson wrote:
> > Rather than have everyone call pci_bridge_map_irq() themselves and
> > come up with incorrect mapping functions let's use the default PCI
> > defined swizzle function unless told otherwise.  Then we can also
> > clean out the duplicate function in pci_bridge_dev.  Tested with an
> > assigned device behind a PCIe switch behind a PCIe root port at
> > addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
> > option to find devices behind PCIe ports if not addr=0.0.  Windows
> > finds them but won't use them (code 10).
> 
> I'm guessing this only applies to downstream ports right?
> The spec IIRC says that slot is ignored.
> The real way is probably by making a device an endpoint
> integrated into the switch, so it's behind the upstream port.

I think that's wrong.  The upstream device of an endpoint behind a
switch should be the downstream port, followed by the upstream port.
That's how we model it today and I think it's accurate.  Slot is
undefined for an upstream port, but that's the PCIe slot, not the
PCI_SLOT(devfn), aka "device", slot.  So I'm not sure how that's
relevant here.

If there's something you want me to change please let me know, otherwise
I'm at a loss how to incorporate changes based on this feedback.
Thanks,

Alex

> > This replaces the ioh3420 & xio3130 upstream/downstream patches.
> > Thanks,
> > 
> > Alex
> > 
> > ---
> > 
> > Alex Williamson (2):
> >       pci_bridge: Use a default map_irq function
> >       pci_bridge: Remove duplicate IRQ swizzle function
> > 
> > 
> >  hw/pci/pci_bridge.c |    2 +-
> >  hw/pci_bridge_dev.c |    9 ---------
> >  2 files changed, 1 insertion(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
  2013-03-10 18:13   ` Alex Williamson
@ 2013-03-10 18:15     ` Alex Williamson
  2013-03-10 20:31       ` Michael S. Tsirkin
  2013-03-10 20:29     ` Michael S. Tsirkin
  1 sibling, 1 reply; 9+ messages in thread
From: Alex Williamson @ 2013-03-10 18:15 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

On Sun, 2013-03-10 at 12:13 -0600, Alex Williamson wrote:
> On Sun, 2013-03-10 at 18:16 +0200, Michael S. Tsirkin wrote:
> > On Thu, Mar 07, 2013 at 04:16:48PM -0700, Alex Williamson wrote:
> > > Rather than have everyone call pci_bridge_map_irq() themselves and
> > > come up with incorrect mapping functions let's use the default PCI
> > > defined swizzle function unless told otherwise.  Then we can also
> > > clean out the duplicate function in pci_bridge_dev.  Tested with an
> > > assigned device behind a PCIe switch behind a PCIe root port at
> > > addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
> > > option to find devices behind PCIe ports if not addr=0.0.  Windows
> > > finds them but won't use them (code 10).
> > 
> > I'm guessing this only applies to downstream ports right?
> > The spec IIRC says that slot is ignored.
> > The real way is probably by making a device an endpoint
> > integrated into the switch, so it's behind the upstream port.
> 
> I think that's wrong.  The upstream device of an endpoint behind a
> switch should be the downstream port, followed by the upstream port.
> That's how we model it today and I think it's accurate.  Slot is
> undefined for an upstream port, but that's the PCIe slot, not the
> PCI_SLOT(devfn), aka "device", slot.  So I'm not sure how that's
> relevant here.
> 
> If there's something you want me to change please let me know, otherwise
> I'm at a loss how to incorporate changes based on this feedback.

D'oh, and now I see you've applied it.  If there's any follow-up you're
looking for from the above, let me know.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
  2013-03-10 18:13   ` Alex Williamson
  2013-03-10 18:15     ` Alex Williamson
@ 2013-03-10 20:29     ` Michael S. Tsirkin
  1 sibling, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2013-03-10 20:29 UTC (permalink / raw)
  To: Alex Williamson; +Cc: qemu-devel

On Sun, Mar 10, 2013 at 12:13:27PM -0600, Alex Williamson wrote:
> On Sun, 2013-03-10 at 18:16 +0200, Michael S. Tsirkin wrote:
> > On Thu, Mar 07, 2013 at 04:16:48PM -0700, Alex Williamson wrote:
> > > Rather than have everyone call pci_bridge_map_irq() themselves and
> > > come up with incorrect mapping functions let's use the default PCI
> > > defined swizzle function unless told otherwise.  Then we can also
> > > clean out the duplicate function in pci_bridge_dev.  Tested with an
> > > assigned device behind a PCIe switch behind a PCIe root port at
> > > addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
> > > option to find devices behind PCIe ports if not addr=0.0.  Windows
> > > finds them but won't use them (code 10).
> > 
> > I'm guessing this only applies to downstream ports right?
> > The spec IIRC says that slot is ignored.
> > The real way is probably by making a device an endpoint
> > integrated into the switch, so it's behind the upstream port.
> 
> I think that's wrong.  The upstream device of an endpoint behind a
> switch should be the downstream port, followed by the upstream port.
> That's how we model it today and I think it's accurate.  Slot is
> undefined for an upstream port, but that's the PCIe slot, not the
> PCI_SLOT(devfn), aka "device", slot.  So I'm not sure how that's
> relevant here.
> 
> If there's something you want me to change please let me know, otherwise
> I'm at a loss how to incorporate changes based on this feedback.
> Thanks,
> 
> Alex

I applied the patch, no need to change anything.

I was only talking about testing this: while the spec says it's illegal,
you might be able to test this code by making an endpoint appear on the
switch's internal bus.  This isn't very useful except for testing
because it's out of spec.

> > > This replaces the ioh3420 & xio3130 upstream/downstream patches.
> > > Thanks,
> > > 
> > > Alex
> > > 
> > > ---
> > > 
> > > Alex Williamson (2):
> > >       pci_bridge: Use a default map_irq function
> > >       pci_bridge: Remove duplicate IRQ swizzle function
> > > 
> > > 
> > >  hw/pci/pci_bridge.c |    2 +-
> > >  hw/pci_bridge_dev.c |    9 ---------
> > >  2 files changed, 1 insertion(+), 10 deletions(-)
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions
  2013-03-10 18:15     ` Alex Williamson
@ 2013-03-10 20:31       ` Michael S. Tsirkin
  0 siblings, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2013-03-10 20:31 UTC (permalink / raw)
  To: Alex Williamson; +Cc: qemu-devel

On Sun, Mar 10, 2013 at 12:15:11PM -0600, Alex Williamson wrote:
> On Sun, 2013-03-10 at 12:13 -0600, Alex Williamson wrote:
> > On Sun, 2013-03-10 at 18:16 +0200, Michael S. Tsirkin wrote:
> > > On Thu, Mar 07, 2013 at 04:16:48PM -0700, Alex Williamson wrote:
> > > > Rather than have everyone call pci_bridge_map_irq() themselves and
> > > > come up with incorrect mapping functions let's use the default PCI
> > > > defined swizzle function unless told otherwise.  Then we can also
> > > > clean out the duplicate function in pci_bridge_dev.  Tested with an
> > > > assigned device behind a PCIe switch behind a PCIe root port at
> > > > addresses 0-3.  Note that Linux requires the pci=pcie_scan_all boot
> > > > option to find devices behind PCIe ports if not addr=0.0.  Windows
> > > > finds them but won't use them (code 10).
> > > 
> > > I'm guessing this only applies to downstream ports right?
> > > The spec IIRC says that slot is ignored.
> > > The real way is probably by making a device an endpoint
> > > integrated into the switch, so it's behind the upstream port.
> > 
> > I think that's wrong.  The upstream device of an endpoint behind a
> > switch should be the downstream port, followed by the upstream port.
> > That's how we model it today and I think it's accurate.  Slot is
> > undefined for an upstream port, but that's the PCIe slot, not the
> > PCI_SLOT(devfn), aka "device", slot.  So I'm not sure how that's
> > relevant here.
> > 
> > If there's something you want me to change please let me know, otherwise
> > I'm at a loss how to incorporate changes based on this feedback.
> 
> D'oh, and now I see you've applied it.  If there's any follow-up you're
> looking for from the above, let me know.  Thanks,
> 
> Alex

No, not as such. We should look at PCI bridges now and see what map
function they have and whether it can be removed.  For example,
hw/dec_pci.c has a different one, and I'm guessing it's just a bug.
Need to test and if true, remove it.

-- 
MST

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-03-10 20:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-07 23:16 [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Alex Williamson
2013-03-07 23:16 ` [Qemu-devel] [PATCH 1/2] pci_bridge: Use a default map_irq function Alex Williamson
2013-03-07 23:17 ` [Qemu-devel] [PATCH 2/2] pci_bridge: Remove duplicate IRQ swizzle function Alex Williamson
2013-03-10 16:16 ` [Qemu-devel] [PATCH 0/2] pci_bridge: Fixup/Cleanup bridge map_irq functions Michael S. Tsirkin
2013-03-10 18:13   ` Alex Williamson
2013-03-10 18:15     ` Alex Williamson
2013-03-10 20:31       ` Michael S. Tsirkin
2013-03-10 20:29     ` Michael S. Tsirkin
2013-03-10 16:17 ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.