From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: qemu-devel@nongnu.org, mst@redhat.com, armbru@redhat.com,
marcel@redhat.com
Subject: [Qemu-devel] [PATCH 1/3] pci: move check for existing devfn into new pci_bus_devfn_available() helper
Date: Fri, 7 Jul 2017 08:44:00 +0100 [thread overview]
Message-ID: <1499413442-5053-2-git-send-email-mark.cave-ayland@ilande.co.uk> (raw)
In-Reply-To: <1499413442-5053-1-git-send-email-mark.cave-ayland@ilande.co.uk>
Also touch up the logic in do_pci_register_device() accordingly.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/pci/pci.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 0c6f74a..04e6edb 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -951,6 +951,15 @@ uint16_t pci_requester_id(PCIDevice *dev)
return pci_req_id_cache_extract(&dev->requester_id_cache);
}
+static bool pci_bus_devfn_available(PCIBus *bus, int devfn)
+{
+ if (bus->devices[devfn]) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
/* -1 for devfn means auto assign */
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn,
@@ -974,14 +983,15 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
- if (!bus->devices[devfn])
+ if (pci_bus_devfn_available(bus, devfn)) {
goto found;
+ }
}
error_setg(errp, "PCI: no slot/function available for %s, all in use",
name);
return NULL;
found: ;
- } else if (bus->devices[devfn]) {
+ } else if (!pci_bus_devfn_available(bus, devfn)) {
error_setg(errp, "PCI: slot %d function %d not available for %s,"
" in use by %s",
PCI_SLOT(devfn), PCI_FUNC(devfn), name,
--
1.7.10.4
next prev parent reply other threads:[~2017-07-07 7:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 7:43 [Qemu-devel] [PATCH 0/3] pci: allow PCI bus slots to be marked as reserved Mark Cave-Ayland
2017-07-07 7:44 ` Mark Cave-Ayland [this message]
2017-07-10 7:24 ` [Qemu-devel] [PATCH 1/3] pci: move check for existing devfn into new pci_bus_devfn_available() helper Marcel Apfelbaum
2017-07-10 12:44 ` Mark Cave-Ayland
2017-07-07 7:44 ` [Qemu-devel] [PATCH 2/3] pci: add dev_reserved_mask property to PCIBus Mark Cave-Ayland
2017-07-10 7:27 ` Marcel Apfelbaum
2017-07-10 12:49 ` Mark Cave-Ayland
2017-07-07 7:44 ` [Qemu-devel] [PATCH 3/3] pci: add reserved slot check to do_pci_register_device() Mark Cave-Ayland
2017-07-10 7:35 ` Marcel Apfelbaum
2017-07-10 13:05 ` Mark Cave-Ayland
2017-07-11 13:37 ` Marcel Apfelbaum
2017-07-11 15:31 ` [Qemu-devel] [PATCH 0/3] pci: allow PCI bus slots to be marked as reserved Michael S. Tsirkin
2017-07-11 15:51 ` Marcel Apfelbaum
2017-07-11 15:57 ` Michael S. Tsirkin
2017-07-11 17:59 ` Mark Cave-Ayland
2017-07-11 22:03 ` Mark Cave-Ayland
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=1499413442-5053-2-git-send-email-mark.cave-ayland@ilande.co.uk \
--to=mark.cave-ayland@ilande.co.uk \
--cc=armbru@redhat.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).