From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvy0x-0004d3-Br for qemu-devel@nongnu.org; Sun, 07 Jul 2013 19:05:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uvy0w-0003ke-0y for qemu-devel@nongnu.org; Sun, 07 Jul 2013 19:05:07 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35574 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvy0v-0003iM-Nx for qemu-devel@nongnu.org; Sun, 07 Jul 2013 19:05:05 -0400 Message-ID: <51D9F41C.4000200@suse.de> Date: Mon, 08 Jul 2013 01:05:00 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <7bdbde3da2d08d4971bdf3b3e07ba0815d1e98b3.1372673778.git.hutao@cn.fujitsu.com> In-Reply-To: <7bdbde3da2d08d4971bdf3b3e07ba0815d1e98b3.1372673778.git.hutao@cn.fujitsu.com> Content-Type: multipart/mixed; boundary="------------050301020407090200080307" Subject: Re: [Qemu-devel] [PATCH v2 06/26] q35: use type-safe cast instead of directly access of parent dev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: qemu-devel This is a multi-part message in MIME format. --------------050301020407090200080307 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 01.07.2013 12:18, schrieb Hu Tao: > And remove variables if possible. >=20 > Signed-off-by: Hu Tao > --- > hw/pci-host/q35.c | 35 ++++++++++++++++++----------------- > 1 file changed, 18 insertions(+), 17 deletions(-) Thanks, converted the remaining ones as attached and queued on qom-next: https://github.com/afaerber/qemu-cpu/commits/qom-next Do note that we will need to later touch the PCIBus again to use pci_bus_new_inplace(). 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 --------------050301020407090200080307 Content-Type: text/x-patch; name="q35.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="q35.diff" diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index e4cde04..480d981 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -59,6 +59,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) const char *boot_device = args->boot_device; ram_addr_t below_4g_mem_size, above_4g_mem_size; Q35PCIHost *q35_host; + PCIDevice *q35_pci; PCIBus *host_bus; PCIDevice *lpc; BusState *idebus[MAX_SATA_PORTS]; @@ -133,7 +134,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args) q35_host->mch.above_4g_mem_size = above_4g_mem_size; /* pci */ qdev_init_nofail(DEVICE(q35_host)); - host_bus = q35_host->host.pci.bus; + q35_pci = PCI_DEVICE(q35_host); + host_bus = q35_pci->bus; /* create ISA bus */ lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), true, diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index f92f661..beda3e6 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -62,7 +62,7 @@ static int q35_host_init(SysBusDevice *dev) } static Property mch_props[] = { - DEFINE_PROP_UINT64("MCFG", Q35PCIHost, host.base_addr, + DEFINE_PROP_UINT64("MCFG", Q35PCIHost, parent_obj.base_addr, MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT), DEFINE_PROP_END_OF_LIST(), }; @@ -102,9 +102,9 @@ static const TypeInfo q35_host_info = { /* PCIe MMCFG */ static void mch_update_pciexbar(MCHPCIState *mch) { - PCIDevice *pci_dev = &mch->d; - BusState *bus = qdev_get_parent_bus(DEVICE(pci_dev)); - DeviceState *qdev = bus->parent; + PCIDevice *pci_dev = PCI_DEVICE(mch); + BusState *bus = qdev_get_parent_bus(DEVICE(mch)); + PCIExpressHost *pehb = PCIE_HOST_BRIDGE(bus->parent); uint64_t pciexbar; int enable; @@ -136,7 +136,7 @@ static void mch_update_pciexbar(MCHPCIState *mch) break; } addr = pciexbar & addr_mask; - pcie_host_mmcfg_update(PCIE_HOST_BRIDGE(qdev), enable, addr, length); + pcie_host_mmcfg_update(pehb, enable, addr, length); } /* PAM */ @@ -220,7 +220,7 @@ static const VMStateDescription vmstate_mch = { .minimum_version_id_old = 1, .post_load = mch_post_load, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(d, MCHPCIState), + VMSTATE_PCI_DEVICE(parent_obj, MCHPCIState), VMSTATE_UINT8(smm_enabled, MCHPCIState), VMSTATE_END_OF_LIST() } diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h index e182c82..1a8ff83 100644 --- a/include/hw/pci-host/q35.h +++ b/include/hw/pci-host/q35.h @@ -43,7 +43,10 @@ OBJECT_CHECK(MCHPCIState, (obj), TYPE_MCH_PCI_DEVICE) typedef struct MCHPCIState { - PCIDevice d; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + MemoryRegion *ram_memory; MemoryRegion *pci_address_space; MemoryRegion *system_memory; @@ -58,7 +61,10 @@ typedef struct MCHPCIState { } MCHPCIState; typedef struct Q35PCIHost { - PCIExpressHost host; + /*< private >*/ + PCIExpressHost parent_obj; + /*< public >*/ + MCHPCIState mch; } Q35PCIHost; --------------050301020407090200080307 Content-Type: text/x-patch; name="q35a.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="q35a.diff" diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 480d981..bdac09e 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -59,7 +59,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) const char *boot_device = args->boot_device; ram_addr_t below_4g_mem_size, above_4g_mem_size; Q35PCIHost *q35_host; - PCIDevice *q35_pci; + PCIHostState *phb; PCIBus *host_bus; PCIDevice *lpc; BusState *idebus[MAX_SATA_PORTS]; @@ -134,8 +134,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args) q35_host->mch.above_4g_mem_size = above_4g_mem_size; /* pci */ qdev_init_nofail(DEVICE(q35_host)); - q35_pci = PCI_DEVICE(q35_host); - host_bus = q35_pci->bus; + phb = PCI_HOST_BRIDGE(q35_host); + host_bus = phb->bus; /* create ISA bus */ lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), true, --------------050301020407090200080307--