diff mbox

[v2,03/21] pci: pci capability must be in PCI space

Message ID 267c819bbf776d4938d67545c9bdef6b4f03bcb0.1349749915.git.jbaron@redhat.com
State New
Headers show

Commit Message

Jason Baron Oct. 9, 2012, 3:30 a.m. UTC
From: Isaku Yamahata <yamahata@valinux.co.jp>

pci capability must be in PCI space.
It can't lay in PCIe extended config space.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 hw/pci.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Comments

Paolo Bonzini Oct. 9, 2012, 7:36 a.m. UTC | #1
Il 09/10/2012 05:30, Jason Baron ha scritto:
> From: Isaku Yamahata <yamahata@valinux.co.jp>
> 
> pci capability must be in PCI space.
> It can't lay in PCIe extended config space.
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---
>  hw/pci.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index f855cf3..85ebef6 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -1626,12 +1626,11 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
>      return pci_create_simple_multifunction(bus, devfn, false, name);
>  }
>  
> -static int pci_find_space(PCIDevice *pdev, uint8_t size)
> +static uint8_t 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; ++i)
>          if (pdev->used[i])
>              offset = i + 1;
>          else if (i - offset + 1 == size)
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Blue Swirl Oct. 13, 2012, 8:29 a.m. UTC | #2
On Tue, Oct 9, 2012 at 3:30 AM, Jason Baron <jbaron@redhat.com> wrote:
> From: Isaku Yamahata <yamahata@valinux.co.jp>
>
> pci capability must be in PCI space.
> It can't lay in PCIe extended config space.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---
>  hw/pci.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/hw/pci.c b/hw/pci.c
> index f855cf3..85ebef6 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -1626,12 +1626,11 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
>      return pci_create_simple_multifunction(bus, devfn, false, name);
>  }
>
> -static int pci_find_space(PCIDevice *pdev, uint8_t size)
> +static uint8_t 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; ++i)

Please add braces.

>          if (pdev->used[i])
>              offset = i + 1;
>          else if (i - offset + 1 == size)
> --
> 1.7.1
>
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index f855cf3..85ebef6 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1626,12 +1626,11 @@  PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
     return pci_create_simple_multifunction(bus, devfn, false, name);
 }
 
-static int pci_find_space(PCIDevice *pdev, uint8_t size)
+static uint8_t 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; ++i)
         if (pdev->used[i])
             offset = i + 1;
         else if (i - offset + 1 == size)