pci-hotplug: make them aware of pci domain.
PATCH v2 1/1 pci-hotplug: make them aware of pci domain.
add helper function which converts root bus to pci domain. make them aware of pci domain.
---
Changes: V1 -> V2
- removed pci_find_bus()
- renamed pci_find_bus_by_bus() to pci_find_bus()
- add abort()
--- hw/pci-hotplug.c | 7 ++++--- hw/pci.c | 22 +++++++++++++++++++++- hw/pci.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-)
hw/pci-hotplug.c +4 -3
@@ -124,7 +124,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)if (pci_read_devaddr (mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev =pci_find_device (pci_find_root_bus (0 ), pci_bus, slot,0 ); + dev =pci_find_device (pci_find_root_bus (dom), pci_bus, slot,0 );if (!dev) {monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err;
@@ -252,7 +252,8 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)if (dev) {monitor_printf (mon,"OK domain %d, bus %d, slot %d, function %d\n" , -0 ,pci_bus_num (dev->bus),PCI_SLOT (dev->devfn), +pci_find_domain (dev->bus), +pci_bus_num (dev->bus),PCI_SLOT (dev->devfn),PCI_FUNC (dev->devfn)); }else monitor_printf (mon,"failed to add %s\n" , opts);
@@ -269,7 +270,7 @@ int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } - d =pci_find_device (pci_find_root_bus (0 ), bus, slot,0 ); + d =pci_find_device (pci_find_root_bus (dom), bus, slot,0 );if (!d) {monitor_printf (mon,"slot %d empty\n" , slot);return -1 ;
hw/pci.c +21 -1
@@ -200,6 +200,26 @@ PCIBus *pci_find_root_bus(int domain)return NULL ; } +int pci_find_domain (const PCIBus *bus) +{ +PCIDevice *d; +struct PCIHostBus *host; + +/* obtain root bus */ +while ((d = bus->parent_dev) !=NULL ) { + bus = d->bus; + } + + QLIST_FOREACH(host, &host_buses, next) { +if (host->bus == bus) { +return host->domain; + } + } + +abort ();/* should not be reached */ +return -1 ; +} +void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent,const char *name,int devfn_min) {
@@ -505,7 +525,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) } *devfnp = slot <<3 ; -return pci_find_bus (pci_find_root_bus (0 ), bus); +return pci_find_bus (pci_find_root_bus (dom), bus); }static void pci_init_cmask (PCIDevice *dev)
hw/pci.h +1 -0
@@ -218,6 +218,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,int pci_bus_num (PCIBus *s);void pci_for_each_device (PCIBus *bus,int bus_num,void (*fn)(PCIBus *bus,PCIDevice *d));PCIBus *pci_find_root_bus (int domain); +int pci_find_domain (const PCIBus *bus);PCIBus *pci_find_bus (PCIBus *bus,int bus_num);PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function);PCIBus *pci_get_bus_devfn (int *devfnp,const char *devaddr);
Signature · 6 lines
1.6.6.1 -- yamahata
Quoted 4 lines · Isaku Yamahata
add helper function which converts root bus to pci domain. make them aware of pci domain.
Signed-off-by Isaku Yamahata <[email protected]>
Doesn't seem to apply to master.
Quoted 102 lines
---
Changes: V1 -> V2
- removedpci_find_bus()
- renamedpci_find_bus_by_bus()topci_find_bus()
- addabort()--- hw/pci-hotplug.c | 7 ++++--- hw/pci.c | 22 +++++++++++++++++++++- hw/pci.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-)hw/pci-hotplug.c +4
-3@@ -124,7 +124,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)if (pci_read_devaddr (mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev =pci_find_device (pci_find_root_bus (0 ), pci_bus, slot,0 ); + dev =pci_find_device (pci_find_root_bus (dom), pci_bus, slot,0 );if (!dev) {monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err;@@ -252,7 +252,8 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)if (dev) {monitor_printf (mon,"OK domain %d, bus %d, slot %d, function %d\n" , -0 ,pci_bus_num (dev->bus),PCI_SLOT (dev->devfn), +pci_find_domain (dev->bus), +pci_bus_num (dev->bus),PCI_SLOT (dev->devfn),PCI_FUNC (dev->devfn)); }else monitor_printf (mon,"failed to add %s\n" , opts);@@ -269,7 +270,7 @@ int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } - d =pci_find_device (pci_find_root_bus (0 ), bus, slot,0 ); + d =pci_find_device (pci_find_root_bus (dom), bus, slot,0 );if (!d) {monitor_printf (mon,"slot %d empty\n" , slot);return -1 ;hw/pci.c +21
-1@@ -200,6 +200,26 @@ PCIBus *pci_find_root_bus(int domain)return NULL ; } +int pci_find_domain (const PCIBus *bus) +{ +PCIDevice *d; +struct PCIHostBus *host; + +/* obtain root bus */ +while ((d = bus->parent_dev) !=NULL ) { + bus = d->bus; + } + + QLIST_FOREACH(host, &host_buses, next) { +if (host->bus == bus) { +return host->domain; + } + } + +abort ();/* should not be reached */ +return -1 ; +} +void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent,const char *name,int devfn_min) {@@ -505,7 +525,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) } *devfnp = slot <<3 ; -return pci_find_bus (pci_find_root_bus (0 ), bus); +return pci_find_bus (pci_find_root_bus (dom), bus); }static void pci_init_cmask (PCIDevice *dev)hw/pci.h +1
-0@@ -218,6 +218,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,int pci_bus_num (PCIBus *s);void pci_for_each_device (PCIBus *bus,int bus_num,void (*fn)(PCIBus *bus,PCIDevice *d));PCIBus *pci_find_root_bus (int domain); +int pci_find_domain (const PCIBus *bus);PCIBus *pci_find_bus (PCIBus *bus,int bus_num);PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function);PCIBus *pci_get_bus_devfn (int *devfnp,const char *devaddr);Signature · 6 lines
1.6.6.1 -- yamahata
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Isaku Yamahata
add helper function which converts root bus to pci domain. make them aware of pci domain.
Signed-off-by Isaku Yamahata <[email protected]>Doesn't seem to apply to master.
Do you mean
master == pci branch
of git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git
Here is the version rebased to 4cecb52f3370d9c1a4251eef7c9331253c9f9719 of the branch.
The previous one applies to the change set of aa6f63fff62faf2fe9ffba5a789675d49293614d in qemu.org main branch which does include 6c6a58aee425338bf67ec8faffdcda56b0b82090, but the pci branch doesn't include it.
Quoted 1 line
From
389ec34a80d2630ff4ad3e491328c2e1fb53be6fMon Sep 17 00:00:00 2001
Message-Id: <389ec34a80d2630ff4ad3e491328c2e1fb53be6f.1275273565.git.yamahata@valinux.co.jp>
In-Reply-To: <[email protected]>
References: <[email protected]>
From: Isaku Yamahata <[email protected]>
Date: Mon, 31 May 2010 11:32:52 +0900
Subject: [PATCH] pci-hotplug: make them aware of pci domain.
add helper function which converts root bus to pci domain. make them aware of pci domain.
---
Changes: V1 -> V2
- removed pci_find_bus()
- renamed pci_find_bus_by_bus() to pci_find_bus()
- add abort()
--- hw/pci-hotplug.c | 9 +++++---- hw/pci.c | 22 +++++++++++++++++++++- hw/pci.h | 1 + 3 files changed, 27 insertions(+), 5 deletions(-)
hw/pci-hotplug.c +5 -4
@@ -125,7 +125,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)if (pci_read_devaddr (mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev =pci_find_device (pci_find_root_bus (0 ), pci_bus, slot,0 ); + dev =pci_find_device (pci_find_root_bus (dom), pci_bus, slot,0 );if (!dev) {monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err;
@@ -283,8 +283,9 @@ int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)if (dev) { *ret_data = -qobject_from_jsonf ("{ 'domain': 0, 'bus': %d, 'slot': %d, " -"'function': %d }" ,pci_bus_num (dev->bus), +qobject_from_jsonf ("{ 'domain': %d, 'bus': %d, 'slot': %d, " +"'function': %d }" , +pci_find_domain (dev->bus),pci_bus_num (dev->bus),PCI_SLOT (dev->devfn),PCI_FUNC (dev->devfn)); }else {monitor_printf (mon,"failed to add %s\n" , opts);
@@ -305,7 +306,7 @@ int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } - d =pci_find_device (pci_find_root_bus (0 ), bus, slot,0 ); + d =pci_find_device (pci_find_root_bus (dom), bus, slot,0 );if (!d) {monitor_printf (mon,"slot %d empty\n" , slot);return -1 ;
hw/pci.c +21 -1
@@ -200,6 +200,26 @@ PCIBus *pci_find_root_bus(int domain)return NULL ; } +int pci_find_domain (const PCIBus *bus) +{ +PCIDevice *d; +struct PCIHostBus *host; + +/* obtain root bus */ +while ((d = bus->parent_dev) !=NULL ) { + bus = d->bus; + } + + QLIST_FOREACH(host, &host_buses, next) { +if (host->bus == bus) { +return host->domain; + } + } + +abort ();/* should not be reached */ +return -1 ; +} +void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent,const char *name,int devfn_min) {
@@ -505,7 +525,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) } *devfnp = slot <<3 ; -return pci_find_bus (pci_find_root_bus (0 ), bus); +return pci_find_bus (pci_find_root_bus (dom), bus); }static void pci_init_cmask (PCIDevice *dev)
hw/pci.h +1 -0
@@ -218,6 +218,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,int pci_bus_num (PCIBus *s);void pci_for_each_device (PCIBus *bus,int bus_num,void (*fn)(PCIBus *bus,PCIDevice *d));PCIBus *pci_find_root_bus (int domain); +int pci_find_domain (const PCIBus *bus);PCIBus *pci_find_bus (PCIBus *bus,int bus_num);PCIDevice *pci_find_device (PCIBus *bus,int bus_num,int slot,int function);PCIBus *pci_get_bus_devfn (int *devfnp,const char *devaddr);
Signature · 6 lines
1.6.6.1 -- yamahata