From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3tuV-00013v-9D for qemu-devel@nongnu.org; Sat, 03 Mar 2012 13:42:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3tuR-0006A6-1C for qemu-devel@nongnu.org; Sat, 03 Mar 2012 13:42:26 -0500 Message-ID: <4F526601.4020502@suse.de> Date: Sat, 03 Mar 2012 19:42:09 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1330399093-20384-1-git-send-email-david@gibson.dropbear.id.au> <1330399093-20384-8-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1330399093-20384-8-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 7/7] pseries: Configure PCI bridge using properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, agraf@suse.de, anthony@codemonkey.ws, qemu-devel@nongnu.org Am 28.02.2012 04:18, schrieb David Gibson: > From: Alexey Kardashevskiy >=20 > Currently, the function spapr_create_phb() uses its parameters to > initialize the correct memory windows for the new PCI Host Bridge > (PHB). This is not the way things are supposed to be done with qdevs, > and means you can't create extra PHBs easily using -device. >=20 > Since pSeries machines can and do have many PHBs with various > configurations, this is a real limitation, not just a theoretical. > This patch, therefore, alters the PHB initialization code to use qdev > properties to set these parameters of the new bridge, moving most of > the code from spapr_create_phb() to spapr_phb_init(). >=20 > While we're at it, we change the naming of each PCI bus and its > associated memory regions to be less arbitrary and make it easier to > relate the guest and qemu views of memory to each other. >=20 > Signed-off-by: Alexey Kardashevskiy > Signed-off-by: David Gibson > --- > hw/spapr.c | 2 +- > hw/spapr_pci.c | 149 ++++++++++++++++++++++++++++++------------------= ------- > hw/spapr_pci.h | 5 +- > 3 files changed, 84 insertions(+), 72 deletions(-) > diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c > index b0254ee..654cb56 100644 > --- a/hw/spapr_pci.c > +++ b/hw/spapr_pci.c > @@ -161,49 +161,6 @@ static void pci_spapr_set_irq(void *opaque, int ir= q_num, int level) > qemu_set_irq(phb->lsi_table[irq_num].qirq, level); > } > =20 > -static int spapr_phb_init(SysBusDevice *s) > -{ > - sPAPRPHBState *phb =3D FROM_SYSBUS(sPAPRPHBState, s); > - int i; > - > - /* Initialize the LSI table */ > - for (i =3D 0; i < SPAPR_PCI_NUM_LSI; i++) { > - qemu_irq qirq; > - uint32_t num; > - > - qirq =3D spapr_allocate_lsi(0, &num); > - if (!qirq) { > - return -1; > - } > - > - phb->lsi_table[i].dt_irq =3D num; > - phb->lsi_table[i].qirq =3D qirq; > - } > - > - return 0; > -} > - > -static void spapr_phb_class_init(ObjectClass *klass, void *data) > -{ > - SysBusDeviceClass *sdc =3D SYS_BUS_DEVICE_CLASS(klass); > - > - sdc->init =3D spapr_phb_init; > -} > - > -static TypeInfo spapr_phb_info =3D { > - .name =3D "spapr-pci-host-bridge", > - .parent =3D TYPE_SYS_BUS_DEVICE, > - .instance_size =3D sizeof(sPAPRPHBState), > - .class_init =3D spapr_phb_class_init, > -}; > - > -static void spapr_register_types(void) > -{ > - type_register_static(&spapr_phb_info); > -} > - > -type_init(spapr_register_types) > - > static uint64_t spapr_io_read(void *opaque, target_phys_addr_t addr, > unsigned size) > { > @@ -297,14 +248,76 @@ void spapr_create_phb(sPAPREnvironment *spapr, > PCI_DEVFN(0, 0), > SPAPR_PCI_NUM_LSI); > =20 > + QLIST_INSERT_HEAD(&spapr->phbs, phb, list); > + > + /* Initialize the LSI table */ > + for (i =3D 0; i < SPAPR_PCI_NUM_LSI; i++) { > + qemu_irq qirq; > + uint32_t num; > + > + qirq =3D spapr_allocate_lsi(0, &num); > + if (!qirq) { > + return -1; > + } > + > + phb->lsi_table[i].dt_irq =3D num; > + phb->lsi_table[i].qirq =3D qirq; > + } > + > + return 0; > +} > + > +static Property spapr_phb_properties[] =3D { > + DEFINE_PROP_HEX64("buid", sPAPRPHBState, buid, 0), > + DEFINE_PROP_HEX64("mem_win_addr", sPAPRPHBState, mem_win_addr, 0), > + DEFINE_PROP_HEX64("mem_win_size", sPAPRPHBState, mem_win_size, 0x2= 0000000), > + DEFINE_PROP_HEX64("io_win_addr", sPAPRPHBState, io_win_addr, 0), > + DEFINE_PROP_HEX64("io_win_size", sPAPRPHBState, io_win_size, 0x100= 00), > + DEFINE_PROP_END_OF_LIST(), > +}; > + > +static void spapr_phb_class_init(ObjectClass *klass, void *data) > +{ > + SysBusDeviceClass *sdc =3D SYS_BUS_DEVICE_CLASS(klass); > + DeviceClass *dc =3D DEVICE_CLASS(klass); > + > + sdc->init =3D spapr_phb_init; > + dc->props =3D spapr_phb_properties; > +} > + > +static TypeInfo spapr_phb_info =3D { > + .name =3D "spapr-pci-host-bridge", > + .parent =3D TYPE_SYS_BUS_DEVICE, > + .instance_size =3D sizeof(sPAPRPHBState), > + .class_init =3D spapr_phb_class_init, > +}; > + > +static void spapr_register_pci_type(void) > +{ > + type_register_static(&spapr_phb_info); > + > spapr_rtas_register("read-pci-config", rtas_read_pci_config); > spapr_rtas_register("write-pci-config", rtas_write_pci_config); > spapr_rtas_register("ibm,read-pci-config", rtas_ibm_read_pci_confi= g); > spapr_rtas_register("ibm,write-pci-config", rtas_ibm_write_pci_con= fig); > +} > =20 > - QLIST_INSERT_HEAD(&spapr->phbs, phb, list); > +type_init(spapr_register_pci_type) Please respect the recently enforced convention of naming the function ..._register_types as before and best putting it and type_init() in the bottom so that we don't end up with multiple ones per file. And registering types is all such a function can safely do since the call of these constructors is about to be moved (spapr_rtas_register looks fishy in that aspect). Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg