qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Frank Blaschka <blaschka@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org, cornelia.huck@de.ibm.com,
	borntraeger@de.ibm.com, agraf@suse.de, mst@redhat.com
Cc: MIHAJLOV@de.ibm.com, Frank Blaschka <blaschka@linux.vnet.ibm.com>,
	fiuczy@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 1/2 RFC] pci: detangle Sysbus PCI bridge from PCIBus
Date: Tue, 10 Mar 2015 14:03:33 +0100	[thread overview]
Message-ID: <1425992614-8938-2-git-send-email-blaschka@linux.vnet.ibm.com> (raw)
In-Reply-To: <1425992614-8938-1-git-send-email-blaschka@linux.vnet.ibm.com>

This patch detangle Sysbus PCI bridge from PCIBus. The pci host
bridge is derived from sysbus device and therefore it is not possible
to hotplug a host bridge. This change makes it possible to develop
hotplugable devices creating a pci bus on the fly.

Signed-off-by: Frank Blaschka <blaschka@linux.vnet.ibm.com>
---
 hw/pci/pci.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index cc5d946..553a130 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -253,9 +253,11 @@ static void pcibus_reset(BusState *qbus)
 
 static void pci_host_bus_register(PCIBus *bus, DeviceState *parent)
 {
-    PCIHostState *host_bridge = PCI_HOST_BRIDGE(parent);
-
-    QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
+    PCIHostState *host_bridge = (PCIHostState *)object_dynamic_cast(
+                                OBJECT(parent), TYPE_PCI_HOST_BRIDGE);
+    if (host_bridge) {
+        QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
+    }
 }
 
 PCIBus *pci_find_primary_bus(void)
@@ -288,14 +290,20 @@ PCIBus *pci_device_root_bus(const PCIDevice *d)
 const char *pci_root_bus_path(PCIDevice *dev)
 {
     PCIBus *rootbus = pci_device_root_bus(dev);
-    PCIHostState *host_bridge = PCI_HOST_BRIDGE(rootbus->qbus.parent);
-    PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_GET_CLASS(host_bridge);
+    PCIHostState *host_bridge;
+    PCIHostBridgeClass *hc;
+
+    host_bridge = (PCIHostState *)object_dynamic_cast(
+                  OBJECT(rootbus->qbus.parent), TYPE_PCI_HOST_BRIDGE);
 
     assert(!rootbus->parent_dev);
-    assert(host_bridge->bus == rootbus);
 
-    if (hc->root_bus_path) {
-        return (*hc->root_bus_path)(host_bridge, rootbus);
+    if (host_bridge) {
+        assert(host_bridge->bus == rootbus);
+        hc = PCI_HOST_BRIDGE_GET_CLASS(host_bridge);
+        if (hc->root_bus_path) {
+            return (*hc->root_bus_path)(host_bridge, rootbus);
+        }
     }
 
     return rootbus->qbus.name;
-- 
2.1.4

  reply	other threads:[~2015-03-10 13:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 13:03 [Qemu-devel] [PATCH 0/2 RFC] Extend s390 pci representation in qemu V2 Frank Blaschka
2015-03-10 13:03 ` Frank Blaschka [this message]
2015-03-10 13:03 ` [Qemu-devel] [PATCH 2/2 RFC] s390x/pci: rework pci infrastructure modeling Frank Blaschka
2015-03-10 14:26   ` Michael S. Tsirkin
2015-03-11 14:38     ` Frank Blaschka
2015-03-11 14:57       ` Michael S. Tsirkin
2015-03-12  8:46         ` Frank Blaschka
2015-03-12  9:26           ` Michael S. Tsirkin
2015-03-11 17:42       ` Michael S. Tsirkin
2015-03-12  9:54         ` Frank Blaschka
2015-03-12 10:03           ` Michael S. Tsirkin
2015-03-12 10:50             ` Frank Blaschka
2015-03-12 13:16               ` Frank Blaschka
2015-03-12 14:59                 ` Alexander Graf
2015-03-12 15:22                   ` Michael S. Tsirkin
2015-03-17  7:11                     ` Alexander Graf
2015-03-17 12:15                       ` Frank Blaschka
2015-03-12 15:18                 ` Michael S. Tsirkin

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=1425992614-8938-2-git-send-email-blaschka@linux.vnet.ibm.com \
    --to=blaschka@linux.vnet.ibm.com \
    --cc=MIHAJLOV@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=fiuczy@linux.vnet.ibm.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).