From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGTv4-0008NA-8Y for qemu-devel@nongnu.org; Fri, 15 Mar 2013 08:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGTv2-0000Dm-Ao for qemu-devel@nongnu.org; Fri, 15 Mar 2013 08:39:34 -0400 Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <1363226008-26639-3-git-send-email-david@gibson.dropbear.id.au> Date: Fri, 15 Mar 2013 13:39:30 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1363226008-26639-1-git-send-email-david@gibson.dropbear.id.au> <1363226008-26639-3-git-send-email-david@gibson.dropbear.id.au> Subject: Re: [Qemu-devel] [PATCH 2/5] pseries: Remove "busname" property for PCI host bridge List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, qemu-devel@nongnu.org On 14.03.2013, at 02:53, David Gibson wrote: > Currently the "spapr-pci-host-bridge" device has a "busname" property = which > can be used to override the default assignment of qbus names for the = bus > subordinate to the PHB. We use that for the default primary PCI bus, = to > make libvirt happy, which expects there to be a bus named simply = "pci". > The default qdev core logic would name the bus "pci.0", and the = pseries > code would otherwise name it "pci@800000020000000" which is the name = it > is given in the device tree based on its BUID. >=20 > The "busname" property is rather clunky though, so this patch = simplifies > things by just using a special case hack for the default PHB, setting > busname to "pci" when index=3D0. >=20 > Signed-off-by: Alexey Kardashevskiy > Signed-off-by: David Gibson Thanks, applied to ppc-next. Alex > --- > hw/ppc/spapr.c | 2 +- > hw/spapr_pci.c | 30 ++++++++++++++++++++++-------- > hw/spapr_pci.h | 4 +--- > 3 files changed, 24 insertions(+), 12 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index fd24113..9a13697 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -852,7 +852,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs = *args) > /* Set up PCI */ > spapr_pci_rtas_init(); >=20 > - phb =3D spapr_create_phb(spapr, 0, "pci"); > + phb =3D spapr_create_phb(spapr, 0); >=20 > for (i =3D 0; i < nb_nics; i++) { > NICInfo *nd =3D &nd_table[i]; > diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c > index 36adbc5..42c8b61 100644 > --- a/hw/spapr_pci.c > +++ b/hw/spapr_pci.c > @@ -518,6 +518,7 @@ static int spapr_phb_init(SysBusDevice *s) > { > sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(s); > PCIHostState *phb =3D PCI_HOST_BRIDGE(s); > + const char *busname; > char *namebuf; > int i; > PCIBus *bus; > @@ -575,9 +576,6 @@ static int spapr_phb_init(SysBusDevice *s) > } >=20 > sphb->dtbusname =3D g_strdup_printf("pci@%" PRIx64, sphb->buid); > - if (!sphb->busname) { > - sphb->busname =3D sphb->dtbusname; > - } >=20 > namebuf =3D alloca(strlen(sphb->dtbusname) + 32); >=20 > @@ -621,7 +619,26 @@ static int spapr_phb_init(SysBusDevice *s) > &sphb->msiwindow); > } >=20 > - bus =3D pci_register_bus(DEVICE(s), sphb->busname, > + /* > + * Selecting a busname is more complex than you'd think, due to > + * interacting constraints. If the user has specified an id > + * explicitly for the phb , then we want to use the qdev default > + * of naming the bus based on the bridge device (so the user can > + * then assign devices to it in the way they expect). For the > + * first / default PCI bus (index=3D0) we want to use just "pci" > + * because libvirt expects there to be a bus called, simply, > + * "pci". Otherwise, we use the same name as in the device tree, > + * since it's unique by construction, and makes the guest visible > + * BUID clear. > + */ > + if (s->qdev.id) { > + busname =3D NULL; > + } else if (sphb->index =3D=3D 0) { > + busname =3D "pci"; > + } else { > + busname =3D sphb->dtbusname; > + } > + bus =3D pci_register_bus(DEVICE(s), busname, > pci_spapr_set_irq, pci_spapr_map_irq, sphb, > &sphb->memspace, &sphb->iospace, > PCI_DEVFN(0, 0), PCI_NUM_PINS); > @@ -663,7 +680,6 @@ static void spapr_phb_reset(DeviceState *qdev) > } >=20 > static Property spapr_phb_properties[] =3D { > - DEFINE_PROP_STRING("busname", sPAPRPHBState, busname), > DEFINE_PROP_INT32("index", sPAPRPHBState, index, -1), > DEFINE_PROP_HEX64("buid", sPAPRPHBState, buid, -1), > DEFINE_PROP_HEX32("liobn", sPAPRPHBState, dma_liobn, -1), > @@ -694,14 +710,12 @@ static const TypeInfo spapr_phb_info =3D { > .class_init =3D spapr_phb_class_init, > }; >=20 > -PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index, > - const char *busname) > +PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index) > { > DeviceState *dev; >=20 > dev =3D qdev_create(NULL, TYPE_SPAPR_PCI_HOST_BRIDGE); > qdev_prop_set_uint32(dev, "index", index); > - qdev_prop_set_string(dev, "busname", busname); > qdev_init_nofail(dev); >=20 > return PCI_HOST_BRIDGE(dev); > diff --git a/hw/spapr_pci.h b/hw/spapr_pci.h > index 8bb3c62..8bd8a66 100644 > --- a/hw/spapr_pci.h > +++ b/hw/spapr_pci.h > @@ -39,7 +39,6 @@ typedef struct sPAPRPHBState { >=20 > int32_t index; > uint64_t buid; > - char *busname; > char *dtbusname; >=20 > MemoryRegion memspace, iospace; > @@ -82,8 +81,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct = sPAPRPHBState *phb, int pin) > return xics_get_qirq(spapr->icp, phb->lsi_table[pin].irq); > } >=20 > -PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index, > - const char *busname); > +PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index); >=20 > int spapr_populate_pci_dt(sPAPRPHBState *phb, > uint32_t xics_phandle, > --=20 > 1.7.10.4 >=20