From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eK02t-0005KB-2w for qemu-devel@nongnu.org; Wed, 29 Nov 2017 05:56:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eK02q-0006tq-0q for qemu-devel@nongnu.org; Wed, 29 Nov 2017 05:56:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eK02p-0006rv-Oz for qemu-devel@nongnu.org; Wed, 29 Nov 2017 05:56:47 -0500 References: <20171129084628.12336-1-david@gibson.dropbear.id.au> <20171129084628.12336-8-david@gibson.dropbear.id.au> From: Marcel Apfelbaum Message-ID: <7849e19d-e90b-2069-7708-6616c607dfe4@redhat.com> Date: Wed, 29 Nov 2017 12:56:42 +0200 MIME-Version: 1.0 In-Reply-To: <20171129084628.12336-8-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [for-2.12 7/7] pci: Eliminate pci_find_primary_bus() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , "Michael S . Tsirkin" , Eduardo Habkost , Igor Mammedov Cc: qemu-devel@nongnu.org On 29/11/2017 10:46, David Gibson wrote: > pci_find_primary_bus() only has one user, in pc_xen_hvm_init(). That's > inside the machine construction code, so it already has easy access to the > machine's primary PCI bus. > > Get it directly, and thereby remove pci_find_primary_bus(). This removes > one of only a handful of users of the ugly pci_host_bridges global. > > Signed-off-by: David Gibson > --- > hw/i386/pc_piix.c | 8 ++------ > hw/pci/pci.c | 16 ---------------- > include/hw/pci/pci.h | 1 - > 3 files changed, 2 insertions(+), 23 deletions(-) > > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > index 5e47528993..2febd0e136 100644 > --- a/hw/i386/pc_piix.c > +++ b/hw/i386/pc_piix.c > @@ -394,7 +394,7 @@ static void pc_xen_hvm_init_pci(MachineState *machine) > > static void pc_xen_hvm_init(MachineState *machine) > { > - PCIBus *bus; > + PCMachineState *pcms = PC_MACHINE(machine); > > if (!xen_enabled()) { > error_report("xenfv machine requires the xen accelerator"); > @@ -402,11 +402,7 @@ static void pc_xen_hvm_init(MachineState *machine) > } > > pc_xen_hvm_init_pci(machine); > - > - bus = pci_find_primary_bus(); > - if (bus != NULL) { > - pci_create_simple(bus, -1, "xen-platform"); > - } > + pci_create_simple(pcms->bus, -1, "xen-platform"); > } > #endif > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index cd4d9d7ecd..ab76c4f3f1 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -324,22 +324,6 @@ static void pci_host_bus_register(DeviceState *host) > QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next); > } > > -PCIBus *pci_find_primary_bus(void) > -{ > - PCIBus *primary_bus = NULL; > - PCIHostState *host; > - > - QLIST_FOREACH(host, &pci_host_bridges, next) { > - if (primary_bus) { > - /* We have multiple root buses, refuse to select a primary */ > - return NULL; > - } > - primary_bus = host->bus; > - } > - > - return primary_bus; > -} > - > PCIBus *pci_device_root_bus(const PCIDevice *d) > { > PCIBus *bus = pci_get_bus(d); > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h > index 50034157fd..867b1ee175 100644 > --- a/include/hw/pci/pci.h > +++ b/include/hw/pci/pci.h > @@ -519,7 +519,6 @@ void pci_for_each_bus(PCIBus *bus, > pci_for_each_bus_depth_first(bus, NULL, fn, opaque); > } > > -PCIBus *pci_find_primary_bus(void); > PCIBus *pci_device_root_bus(const PCIDevice *d); > const char *pci_root_bus_path(PCIDevice *dev); > PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); > Reviewed-by: Marcel Apfelbaum Thanks, Marcel