From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1I5x-0001DS-QT for qemu-devel@nongnu.org; Mon, 22 Jul 2013 11:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1I5s-0000oM-CC for qemu-devel@nongnu.org; Mon, 22 Jul 2013 11:32:17 -0400 Received: from cantor2.suse.de ([195.135.220.15]:59859 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1I5s-0000ni-3K for qemu-devel@nongnu.org; Mon, 22 Jul 2013 11:32:12 -0400 Message-ID: <51ED5078.1050806@suse.de> Date: Mon, 22 Jul 2013 17:32:08 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1374501278-31549-1-git-send-email-pbonzini@redhat.com> <1374501278-31549-21-git-send-email-pbonzini@redhat.com> In-Reply-To: <1374501278-31549-21-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 20/28] sparc64: unbreak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: aliguori@us.ibm.com, aik@ozlabs.ru, jan.kiszka@siemens.com, qemu-devel@nongnu.org, agraf@suse.de, hpoussin@reactos.org, aurelien@aurel32.net Am 22.07.2013 15:54, schrieb Paolo Bonzini: > ... by making apb a subclass of TYPE_PCI_HOST_BRIDGE. Any chance to get that into the subject somehow? :) >=20 > Signed-off-by: Paolo Bonzini > --- > hw/pci-host/apb.c | 47 ++++++++++++++++++++++++++++------------------- > 1 file changed, 28 insertions(+), 19 deletions(-) >=20 > diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c > index 208ac85..3756ce9 100644 > --- a/hw/pci-host/apb.c > +++ b/hw/pci-host/apb.c > @@ -70,9 +70,14 @@ do { printf("APB: " fmt , ## __VA_ARGS__); } while (= 0) > #define MAX_IVEC 0x40 > #define NO_IRQ_REQUEST (MAX_IVEC + 1) > =20 > +#define TYPE_APB "pbm" > + > +#define APB_DEVICE(obj) \ > + OBJECT_CHECK(APBState, (obj), TYPE_APB) Was APB() already taken? > + > typedef struct APBState { > - SysBusDevice busdev; > - PCIBus *bus; > + PCIHostState parent_obj; > + > MemoryRegion apb_config; > MemoryRegion pci_config; > MemoryRegion pci_mmio; Thanks for fixing this. > @@ -284,10 +289,11 @@ static void apb_pci_config_write(void *opaque, hw= addr addr, > uint64_t val, unsigned size) > { > APBState *s =3D opaque; > + PCIHostState *phb =3D PCI_HOST_BRIDGE(s); > =20 > val =3D qemu_bswap_len(val, size); > APB_DPRINTF("%s: addr " TARGET_FMT_plx " val %" PRIx64 "\n", __fun= c__, addr, val); > - pci_data_write(s->bus, addr, val, size); > + pci_data_write(phb->bus, addr, val, size); > } > =20 > static uint64_t apb_pci_config_read(void *opaque, hwaddr addr, > @@ -295,8 +301,9 @@ static uint64_t apb_pci_config_read(void *opaque, h= waddr addr, > { > uint32_t ret; > APBState *s =3D opaque; > + PCIHostState *phb =3D PCI_HOST_BRIDGE(s); > =20 > - ret =3D pci_data_read(s->bus, addr, size); > + ret =3D pci_data_read(phb->bus, addr, size); > ret =3D qemu_bswap_len(ret, size); > APB_DPRINTF("%s: addr " TARGET_FMT_plx " -> %x\n", __func__, addr,= ret); > return ret; > @@ -381,12 +388,13 @@ PCIBus *pci_apb_init(hwaddr special_base, > { > DeviceState *dev; > SysBusDevice *s; > + PCIHostState *phb; > APBState *d; > PCIDevice *pci_dev; > PCIBridge *br; > =20 > /* Ultrasparc PBM main bus */ > - dev =3D qdev_create(NULL, "pbm"); > + dev =3D qdev_create(NULL, TYPE_APB); > qdev_init_nofail(dev); > s =3D SYS_BUS_DEVICE(dev); > /* apb_config */ > @@ -395,24 +403,25 @@ PCIBus *pci_apb_init(hwaddr special_base, > sysbus_mmio_map(s, 1, special_base + 0x1000000ULL); > /* pci_ioport */ > sysbus_mmio_map(s, 2, special_base + 0x2000000ULL); > - d =3D FROM_SYSBUS(APBState, s); > + d =3D APB_DEVICE(dev); > =20 > memory_region_init(&d->pci_mmio, OBJECT(s), "pci-mmio", 0x10000000= 0ULL); > memory_region_add_subregion(get_system_memory(), mem_base, &d->pci= _mmio); > =20 > - d->bus =3D pci_register_bus(&d->busdev.qdev, "pci", > - pci_apb_set_irq, pci_pbm_map_irq, d, > - &d->pci_mmio, > - get_system_io(), > - 0, 32, TYPE_PCI_BUS); > + phb =3D PCI_HOST_BRIDGE(dev); > + phb->bus =3D pci_register_bus(DEVICE(phb), "pci", > + pci_apb_set_irq, pci_pbm_map_irq, d, > + &d->pci_mmio, > + get_system_io(), > + 0, 32, TYPE_PCI_BUS); > =20 > *pbm_irqs =3D d->pbm_irqs; > d->ivec_irqs =3D ivec_irqs; > =20 > - pci_create_simple(d->bus, 0, "pbm-pci"); > + pci_create_simple(phb->bus, 0, "pbm-pci"); > =20 > /* APB secondary busses */ > - pci_dev =3D pci_create_multifunction(d->bus, PCI_DEVFN(1, 0), true= , > + pci_dev =3D pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), tr= ue, > "pbm-bridge"); Adjust indentation here ... > br =3D DO_UPCAST(PCIBridge, dev, pci_dev); > pci_bridge_map_irq(br, "Advanced PCI Bus secondary bridge 1", > @@ -420,7 +429,7 @@ PCIBus *pci_apb_init(hwaddr special_base, > qdev_init_nofail(&pci_dev->qdev); > *bus2 =3D pci_bridge_get_sec_bus(br); > =20 > - pci_dev =3D pci_create_multifunction(d->bus, PCI_DEVFN(1, 1), true= , > + pci_dev =3D pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), tr= ue, > "pbm-bridge"); ... and here while at it? > br =3D DO_UPCAST(PCIBridge, dev, pci_dev); > pci_bridge_map_irq(br, "Advanced PCI Bus secondary bridge 2", > @@ -428,13 +437,13 @@ PCIBus *pci_apb_init(hwaddr special_base, > qdev_init_nofail(&pci_dev->qdev); > *bus3 =3D pci_bridge_get_sec_bus(br); > =20 > - return d->bus; > + return phb->bus; > } > =20 > static void pci_pbm_reset(DeviceState *d) > { > unsigned int i; > - APBState *s =3D container_of(d, APBState, busdev.qdev); > + APBState *s =3D APB_DEVICE(d); > =20 > for (i =3D 0; i < 8; i++) { > s->pci_irq_map[i] &=3D PBM_PCI_IMR_MASK; > @@ -463,7 +472,7 @@ static int pci_pbm_init_device(SysBusDevice *dev) > APBState *s; > unsigned int i; > =20 > - s =3D FROM_SYSBUS(APBState, dev); > + s =3D APB_DEVICE(dev); > for (i =3D 0; i < 8; i++) { > s->pci_irq_map[i] =3D (0x1f << 6) | (i << 2); > } > @@ -531,8 +540,8 @@ static void pbm_host_class_init(ObjectClass *klass,= void *data) > } > =20 > static const TypeInfo pbm_host_info =3D { > - .name =3D "pbm", > - .parent =3D TYPE_SYS_BUS_DEVICE, > + .name =3D TYPE_APB, > + .parent =3D TYPE_PCI_HOST_BRIDGE, > .instance_size =3D sizeof(APBState), > .class_init =3D pbm_host_class_init, > }; Otherwise looks fine, one FROM_SYSBUS() less. :) Note that this will conflict trivially with my PCIBridge series. 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