qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges
@ 2013-08-16 11:09 Alexey Kardashevskiy
  2013-08-16 13:04 ` Alexander Graf
  2013-08-19  7:25 ` Michael S. Tsirkin
  0 siblings, 2 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2013-08-16 11:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S . Tsirkin, Alexey Kardashevskiy, Alexander Graf,
	qemu-ppc, Paul Mackerras, Andreas Färber

spapr-pci config space accessors use find_dev() to find a PCI device.
However find_dev() only searched on a primary bus and did not do
recursive search through secondary buses so config space access was not
possible for devices other that on a primary bus.

This fixed find_dev() by using the PCI API pci_find_device() function.
This effectively enabled pci bridges on spapr.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Does not it make sense to move spapr_pci.c from hw/ppc to hw/pci? We already
do move interrupt controllers to hw/intc.


---
Changes:
v2:
* fixed coding style
* config space access traces moved out
---
 hw/ppc/spapr_pci.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 1ca35a0..91d78a6 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -65,22 +65,13 @@ static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid,
 {
     sPAPRPHBState *sphb = find_phb(spapr, buid);
     PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
-    BusState *bus = BUS(phb->bus);
-    BusChild *kid;
     int devfn = (config_addr >> 8) & 0xFF;
 
     if (!phb) {
         return NULL;
     }
 
-    QTAILQ_FOREACH(kid, &bus->children, sibling) {
-        PCIDevice *dev = (PCIDevice *)kid->child;
-        if (dev->devfn == devfn) {
-            return dev;
-        }
-    }
-
-    return NULL;
+    return pci_find_device(phb->bus, (config_addr >> 16) & 0xff, devfn);
 }
 
 static uint32_t rtas_pci_cfgaddr(uint32_t arg)
-- 
1.8.3.2

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

* Re: [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges
  2013-08-16 11:09 [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges Alexey Kardashevskiy
@ 2013-08-16 13:04 ` Alexander Graf
  2013-08-19  7:25 ` Michael S. Tsirkin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2013-08-16 13:04 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: Michael S . Tsirkin, qemu-devel, qemu-ppc, Paul Mackerras,
	Andreas Färber


On 16.08.2013, at 13:09, Alexey Kardashevskiy wrote:

> spapr-pci config space accessors use find_dev() to find a PCI device.
> However find_dev() only searched on a primary bus and did not do
> recursive search through secondary buses so config space access was not
> possible for devices other that on a primary bus.
> 
> This fixed find_dev() by using the PCI API pci_find_device() function.
> This effectively enabled pci bridges on spapr.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> 
> Does not it make sense to move spapr_pci.c from hw/ppc to hw/pci? We already
> do move interrupt controllers to hw/intc.
> 
> 
> ---
> Changes:
> v2:
> * fixed coding style
> * config space access traces moved out
> ---
> hw/ppc/spapr_pci.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 1ca35a0..91d78a6 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -65,22 +65,13 @@ static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid,
> {
>     sPAPRPHBState *sphb = find_phb(spapr, buid);
>     PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
> -    BusState *bus = BUS(phb->bus);
> -    BusChild *kid;
>     int devfn = (config_addr >> 8) & 0xFF;
> 
>     if (!phb) {
>         return NULL;
>     }
> 
> -    QTAILQ_FOREACH(kid, &bus->children, sibling) {
> -        PCIDevice *dev = (PCIDevice *)kid->child;
> -        if (dev->devfn == devfn) {
> -            return dev;
> -        }
> -    }
> -
> -    return NULL;
> +    return pci_find_device(phb->bus, (config_addr >> 16) & 0xff, devfn);

Please put the (config_addr >> 16) into a separate variable so it's obvious what we're passing in here. Otherwise looks like a reasonably straight forward change to me, but I'd like to see an ack from Michael.


Alex

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

* Re: [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges
  2013-08-16 11:09 [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges Alexey Kardashevskiy
  2013-08-16 13:04 ` Alexander Graf
@ 2013-08-19  7:25 ` Michael S. Tsirkin
  1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2013-08-19  7:25 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: Alexander Graf, qemu-devel, qemu-ppc, Paul Mackerras,
	Andreas Färber

On Fri, Aug 16, 2013 at 09:09:38PM +1000, Alexey Kardashevskiy wrote:
> spapr-pci config space accessors use find_dev() to find a PCI device.
> However find_dev() only searched on a primary bus and did not do
> recursive search through secondary buses so config space access was not
> possible for devices other that on a primary bus.
> 
> This fixed find_dev() by using the PCI API pci_find_device() function.
> This effectively enabled pci bridges on spapr.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> 
> Does not it make sense to move spapr_pci.c from hw/ppc to hw/pci?

It's a pci host bridge, isn't it?
If yes you can put it in hw/pci-host.
hw/pci is core code.

> We already
> do move interrupt controllers to hw/intc.
> 
> 
> ---
> Changes:
> v2:
> * fixed coding style
> * config space access traces moved out
> ---
>  hw/ppc/spapr_pci.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 1ca35a0..91d78a6 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -65,22 +65,13 @@ static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid,
>  {
>      sPAPRPHBState *sphb = find_phb(spapr, buid);
>      PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
> -    BusState *bus = BUS(phb->bus);
> -    BusChild *kid;
>      int devfn = (config_addr >> 8) & 0xFF;
>  
>      if (!phb) {
>          return NULL;
>      }
>  
> -    QTAILQ_FOREACH(kid, &bus->children, sibling) {
> -        PCIDevice *dev = (PCIDevice *)kid->child;
> -        if (dev->devfn == devfn) {
> -            return dev;
> -        }
> -    }
> -
> -    return NULL;
> +    return pci_find_device(phb->bus, (config_addr >> 16) & 0xff, devfn);
>  }
>  
>  static uint32_t rtas_pci_cfgaddr(uint32_t arg)
> -- 
> 1.8.3.2

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

end of thread, other threads:[~2013-08-19  7:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-16 11:09 [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges Alexey Kardashevskiy
2013-08-16 13:04 ` Alexander Graf
2013-08-19  7:25 ` Michael S. Tsirkin

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).