From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVJp9-0001iS-SH for qemu-devel@nongnu.org; Tue, 10 Mar 2015 09:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVJp3-0007Lc-Kn for qemu-devel@nongnu.org; Tue, 10 Mar 2015 09:03:51 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:46958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVJp3-0007L4-BU for qemu-devel@nongnu.org; Tue, 10 Mar 2015 09:03:45 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Mar 2015 13:03:43 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id BDB5F17D805F for ; Tue, 10 Mar 2015 13:04:03 +0000 (GMT) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2AD3f0L10879294 for ; Tue, 10 Mar 2015 13:03:41 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2AD3cV8022940 for ; Tue, 10 Mar 2015 07:03:40 -0600 From: Frank Blaschka Date: Tue, 10 Mar 2015 14:03:33 +0100 Message-Id: <1425992614-8938-2-git-send-email-blaschka@linux.vnet.ibm.com> In-Reply-To: <1425992614-8938-1-git-send-email-blaschka@linux.vnet.ibm.com> References: <1425992614-8938-1-git-send-email-blaschka@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/2 RFC] pci: detangle Sysbus PCI bridge from PCIBus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 , fiuczy@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 --- 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