From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] pci-hotplug: make them aware of pci domain.
Date: Thu, 27 May 2010 17:19:36 +0300 [thread overview]
Message-ID: <20100527141936.GF8287@redhat.com> (raw)
In-Reply-To: <20100527054742.GJ31807@valinux.co.jp>
On Thu, May 27, 2010 at 02:47:42PM +0900, Isaku Yamahata wrote:
> add helper function which converts root bus to pci domain.
> make functions which ignored domain aware of pci domain.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> hw/pci-hotplug.c | 7 ++++---
> hw/pci.c | 24 +++++++++++++++++++++++-
> hw/pci.h | 2 ++
> 3 files changed, 29 insertions(+), 4 deletions(-)
>
> diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
> index 37ac015..cbde02c 100644
> --- a/hw/pci-hotplug.c
> +++ b/hw/pci-hotplug.c
> @@ -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_by_bus(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;
> diff --git a/hw/pci.c b/hw/pci.c
> index 39a6206..459593d 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -200,6 +200,28 @@ PCIBus *pci_find_root_bus(int domain)
> return NULL;
> }
>
> +int pci_find_domain(const PCIBus *root_bus)
> +{
> + struct PCIHostBus *host;
> +
> + QLIST_FOREACH(host, &host_buses, next) {
> + if (host->bus == root_bus) {
> + return host->domain;
> + }
> + }
> +
> + return -1;
assert? Each bus is in some domain, after all.
> +}
> +
> +int pci_find_domain_by_bus(const PCIBus *bus)
> +{
> + PCIDevice *d;
> + while ((d = bus->parent_dev) != NULL) {
> + bus = d->bus;
> + }
> + return pci_find_domain(bus);
> +}
> +
I suggest removing pci_find_domain and renaming
pci_find_domain_by_bus to pci_find_domain.
> void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
> const char *name, int devfn_min)
> {
> @@ -505,7 +527,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)
> diff --git a/hw/pci.h b/hw/pci.h
> index b803593..c2b2188 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -218,6 +218,8 @@ 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 *root_bus);
> +int pci_find_domain_by_bus(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);
> --
> 1.6.6.1
>
prev parent reply other threads:[~2010-05-27 14:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-27 5:47 [Qemu-devel] [PATCH] pci-hotplug: make them aware of pci domain Isaku Yamahata
2010-05-27 14:19 ` Michael S. Tsirkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100527141936.GF8287@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yamahata@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.