From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/5] pci: move initialization of pci's conf_addr and conf_data to common place
Date: Tue, 04 Nov 2014 16:21:41 +0200 [thread overview]
Message-ID: <1415110901.2327.54.camel@localhost.localdomain> (raw)
In-Reply-To: <51f88e8c944034037eba3835ced2763880ac4c10.1415091929.git.hutao@cn.fujitsu.com>
On Tue, 2014-11-04 at 17:12 +0800, Hu Tao wrote:
> So that standard pci host device can share them.
>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
> hw/pci-host/piix.c | 20 --------------------
> hw/pci-host/q35.c | 7 -------
> hw/pci/pci_host.c | 32 ++++++++++++++++++++++++++++++++
> 3 files changed, 32 insertions(+), 27 deletions(-)
>
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index eb92bde..683465c 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -256,14 +256,8 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
>
> static void i440fx_pcihost_initfn(Object *obj)
> {
> - PCIHostState *s = PCI_HOST_BRIDGE(obj);
> I440FXState *d = I440FX_PCI_HOST_BRIDGE(obj);
>
> - memory_region_init_io(&s->conf_mem, obj, &pci_host_conf_le_ops, s,
> - "pci-conf-idx", 4);
> - memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s,
> - "pci-conf-data", 4);
> -
> object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "int",
> i440fx_pcihost_get_pci_hole_start,
> NULL, NULL, NULL, NULL);
> @@ -283,18 +277,6 @@ static void i440fx_pcihost_initfn(Object *obj)
> d->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
> }
>
> -static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
> -{
> - PCIHostState *s = PCI_HOST_BRIDGE(dev);
> - SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> -
> - sysbus_add_io(sbd, PC_PCI_CONFIG_ADDR, &s->conf_mem);
> - sysbus_init_ioports(sbd, PC_PCI_CONFIG_ADDR, 4);
> -
> - sysbus_add_io(sbd, PC_PCI_CONFIG_DATA, &s->data_mem);
> - sysbus_init_ioports(sbd, PC_PCI_CONFIG_DATA, 4);
> -}
> -
> static int i440fx_initfn(PCIDevice *dev)
> {
> PCII440FXState *d = I440FX_PCI_DEVICE(dev);
> @@ -755,8 +737,6 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
> PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
>
> hc->root_bus_path = i440fx_pcihost_root_bus_path;
> - dc->realize = i440fx_pcihost_realize;
> - dc->fw_name = "pci";
> dc->props = i440fx_props;
> }
>
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index 9e66835..81eddd7 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -138,18 +138,11 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
> dc->realize = q35_host_realize;
> dc->props = mch_props;
> set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
> - dc->fw_name = "pci";
> }
>
> static void q35_host_initfn(Object *obj)
> {
> Q35PCIHost *s = Q35_HOST_DEVICE(obj);
> - PCIHostState *phb = PCI_HOST_BRIDGE(obj);
> -
> - memory_region_init_io(&phb->conf_mem, obj, &pci_host_conf_le_ops, phb,
> - "pci-conf-idx", 4);
> - memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb,
> - "pci-conf-data", 4);
>
> object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE);
> object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL);
> diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
> index f2a69ea..406c747 100644
> --- a/hw/pci/pci_host.c
> +++ b/hw/pci/pci_host.c
> @@ -176,12 +176,44 @@ const MemoryRegionOps pci_host_data_be_ops = {
> .endianness = DEVICE_BIG_ENDIAN,
> };
>
> +static void pci_host_initfn(Object *obj)
> +{
> + PCIHostState *phb = PCI_HOST_BRIDGE(obj);
> +
> + memory_region_init_io(&phb->conf_mem, obj, &pci_host_conf_le_ops, phb,
> + "pci-conf-idx", 4);
> + memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb,
> + "pci-conf-data", 4);
> +}
> +
> +static void pci_host_realize(DeviceState *dev, Error **errp)
> +{
> + PCIHostState *s = PCI_HOST_BRIDGE(dev);
> + SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> +
> + sysbus_add_io(sbd, PC_PCI_CONFIG_ADDR, &s->conf_mem);
> + sysbus_init_ioports(sbd, PC_PCI_CONFIG_ADDR, 4);
> +
> + sysbus_add_io(sbd, PC_PCI_CONFIG_DATA, &s->data_mem);
> + sysbus_init_ioports(sbd, PC_PCI_CONFIG_DATA, 4);
Hi,
If I got this right, now we have this pci_host_realize run
for each object of classes deriving from TYPE_PCI_HOST_BRIDGE.
Please correct me if I am wrong.
The machines PC and Q35 share the same code, however
we have other host bridges deriving that I think they behave different:
hw/mips/gt64xxx_pci.c:1207: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-bridge/dec.c:150: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/apb.c:839: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/bonito.c:832: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/grackle.c:156: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/ppce500.c:440: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/prep.c:392: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/uninorth.c:456: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/uninorth.c:470: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/uninorth.c:484: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/uninorth.c:498: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci-host/versatile.c:508: .parent = TYPE_PCI_HOST_BRIDGE,
hw/pci/pci_host.c:179: .name = TYPE_PCI_HOST_BRIDGE,
hw/ppc/ppc4xx_pci.c:405: .parent = TYPE_PCI_HOST_BRIDGE,
hw/ppc/spapr_pci.c:801: .parent = TYPE_PCI_HOST_BRIDGE,
hw/sh4/sh_pci.c:193: .parent = TYPE_PCI_HOST_BRIDGE,
If I am right, putting this so "high" in the hierarchy
may not be the right solution.
Thanks,
Marcel
> +}
> +
> +static void pci_host_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> +
> + dc->realize = pci_host_realize;
> + dc->fw_name = "pci";
> +}
> +
> static const TypeInfo pci_host_type_info = {
> .name = TYPE_PCI_HOST_BRIDGE,
> .parent = TYPE_SYS_BUS_DEVICE,
> .abstract = true,
> .class_size = sizeof(PCIHostBridgeClass),
> + .class_init = pci_host_class_init,
> .instance_size = sizeof(PCIHostState),
> + .instance_init = pci_host_initfn,
> };
>
> static void pci_host_register_types(void)
next prev parent reply other threads:[~2014-11-04 14:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 9:12 [Qemu-devel] [PATCH 0/5] Some PCI related cleanup patches Hu Tao
2014-11-04 9:12 ` [Qemu-devel] [PATCH 1/5] pci: introduce PC_PCI_CONFIG_ENABLED() Hu Tao
2014-11-04 13:41 ` Marcel Apfelbaum
2014-11-05 5:57 ` Hu Tao
2014-11-04 9:12 ` [Qemu-devel] [PATCH 2/5] pc: define PC_PCI_CONFIG_ADDR and PC_PCI_CONFIG_DATA Hu Tao
2014-11-04 13:44 ` Marcel Apfelbaum
2014-11-05 7:58 ` Hu Tao
2014-11-04 9:12 ` [Qemu-devel] [PATCH 3/5] pci: move initialization of pci's conf_addr and conf_data to common place Hu Tao
2014-11-04 14:21 ` Marcel Apfelbaum [this message]
2014-11-05 6:03 ` Hu Tao
2014-11-04 9:12 ` [Qemu-devel] [PATCH 4/5] pci: remove the limit parameter of pci_host_config_read_common Hu Tao
2014-11-04 9:12 ` [Qemu-devel] [PATCH 5/5] pci: remove the limit parameter of pci_host_config_write_common Hu Tao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415110901.2327.54.camel@localhost.localdomain \
--to=marcel.apfelbaum@gmail.com \
--cc=hutao@cn.fujitsu.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).