Patchwork pci: fix pci_find_space()

login
register
mail settings
Submitter Isaku Yamahata
Date April 9, 2010, 10:20 a.m.
Message ID <20100409102048.GD14603@valinux.co.jp>
Download mbox | patch
Permalink /patch/49817/
State New
Headers show

Comments

Isaku Yamahata - April 9, 2010, 10:20 a.m.
pci capability must be in PCI space.
It can't lay in PCIe extended config space.

Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Michael S. Tsirkin - April 11, 2010, 9:19 a.m.
On Fri, Apr 09, 2010 at 07:20:48PM +0900, Isaku Yamahata wrote:
> pci capability must be in PCI space.
> It can't lay in PCIe extended config space.
> 
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

I guess the point is that we'll need another API to allocate
extended capabilities?

> ---
>  hw/pci.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 2f6907b..f50568c 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -1701,10 +1701,9 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
>  
>  static int pci_find_space(PCIDevice *pdev, uint8_t size)
>  {
> -    int config_size = pci_config_size(pdev);
>      int offset = PCI_CONFIG_HEADER_SIZE;
>      int i;
> -    for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i)
> +    for (i = PCI_CONFIG_HEADER_SIZE; i < PCI_CONFIG_SPACE_SIZE - size; ++i)
>          if (pdev->used[i])
>              offset = i + 1;
>          else if (i - offset + 1 == size)
> -- 
> 1.6.6.1
Isaku Yamahata - April 12, 2010, 1:59 a.m.
On Sun, Apr 11, 2010 at 12:19:30PM +0300, Michael S. Tsirkin wrote:
> On Fri, Apr 09, 2010 at 07:20:48PM +0900, Isaku Yamahata wrote:
> > pci capability must be in PCI space.
> > It can't lay in PCIe extended config space.
> > 
> > Cc: "Michael S. Tsirkin" <mst@redhat.com>
> > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> 
> I guess the point is that we'll need another API to allocate
> extended capabilities?

That's right. I have those in my local repo.

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 2f6907b..f50568c 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1701,10 +1701,9 @@  PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
 
 static int pci_find_space(PCIDevice *pdev, uint8_t size)
 {
-    int config_size = pci_config_size(pdev);
     int offset = PCI_CONFIG_HEADER_SIZE;
     int i;
-    for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i)
+    for (i = PCI_CONFIG_HEADER_SIZE; i < PCI_CONFIG_SPACE_SIZE - size; ++i)
         if (pdev->used[i])
             offset = i + 1;
         else if (i - offset + 1 == size)