Skip to contentSkip to conversation

pci: fix pci_find_space()

PATCH In review Isaku Yamahata 2 participants 3 messages Apr 9, 2010 – Apr 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: fix pci_find_space()

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

Cc "Michael S. Tsirkin" <[email protected]>
---
 hw/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
hw/pci.c +1 -2
index 2f6907b..f50568c 100644
@@ -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)
Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 5 lines · Isaku Yamahata

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

Cc "Michael S. Tsirkin" <[email protected]>

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

Quoted 22 lines
---
 hw/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
hw/pci.c +1 -2
index 2f6907b..f50568c 100644
@@ -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)
Signature · 1 line
1.6.6.1
#2 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 5 lines · Isaku Yamahata

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

Cc "Michael S. Tsirkin" <[email protected]>

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.

Signature · 1 line
yamahata