From: Marcel Apfelbaum <marcel@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>, qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 5/6] hw/core: explicit OFW unit address property for SysBusDevice
Date: Thu, 11 Jun 2015 12:12:24 +0300 [thread overview]
Message-ID: <557950F8.8080609@redhat.com> (raw)
In-Reply-To: <1433983083-4636-6-git-send-email-lersek@redhat.com>
On 06/11/2015 03:38 AM, Laszlo Ersek wrote:
> The sysbus_get_fw_dev_path() function formats OpenFirmware device path
> nodes ("driver-name@unit-address") for sysbus devices. The first choice
> for "unit-address" is the base address of the device's first MMIO region.
> The second choice is its first IO port.
>
> However, if two sysbus devices with the same "driver-name" lack both MMIO
> and PIO resources, then there is no good way to distinguish them based on
> their OFW nodes, because in this case unit-address is omitted completely
> for both devices.
>
> For such devices, delegate a fallback property,
> "explicit_ofw_unit_address", to whoever creates the device. The creator
> can set the property to any appropriate value.
>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Marcel Apfelbaum <marcel@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>
> Notes:
> v3:
> - new in v3
> - new approach
>
> include/hw/sysbus.h | 8 ++++++++
> hw/core/sysbus.c | 11 +++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index d1f3f00..de41b06 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -55,6 +55,14 @@ struct SysBusDevice {
> } mmio[QDEV_MAX_MMIO];
> int num_pio;
> pio_addr_t pio[QDEV_MAX_PIO];
> +
> + /*
> + * Sometimes a SysBusDevice has neither MMIO nor PIO resources, yet it
> + * would like to distinguish itself, in OpenFirmware device paths, from
> + * other instances of the same class on the same sysbus. For that end we
> + * expose this property.
> + */
> + char *explicit_ofw_unit_address;
> };
>
> typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 0ebb4e2..6e9af1c 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -289,6 +289,10 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev)
> if (s->num_pio) {
> return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]);
> }
> + if (s->explicit_ofw_unit_address) {
> + return g_strdup_printf("%s@%s", qdev_fw_name(dev),
> + s->explicit_ofw_unit_address);
> + }
> return g_strdup(qdev_fw_name(dev));
> }
>
> @@ -303,11 +307,18 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> return get_system_memory();
> }
>
> +static Property sysbus_device_properties[] = {
> + DEFINE_PROP_STRING("explicit_ofw_unit_address", SysBusDevice,
> + explicit_ofw_unit_address),
> + DEFINE_PROP_END_OF_LIST()
> +};
> +
> static void sysbus_device_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *k = DEVICE_CLASS(klass);
> k->init = sysbus_device_init;
> k->bus_type = TYPE_SYSTEM_BUS;
> + k->props = sysbus_device_properties;
> }
>
> static const TypeInfo sysbus_device_type_info = {
>
Better than previous approach.
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
next prev parent reply other threads:[~2015-06-11 9:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 0:37 [Qemu-devel] [PATCH v3 0/6] PXB tweaks and fixes Laszlo Ersek
2015-06-11 0:37 ` [Qemu-devel] [PATCH v3 1/6] i386/acpi-build: more traditional _UID and _HID for PXB root buses Laszlo Ersek
2015-06-11 0:37 ` [Qemu-devel] [PATCH v3 2/6] i386/acpi-build: fix PXB workarounds for unsupported BIOSes Laszlo Ersek
2015-06-11 0:38 ` [Qemu-devel] [PATCH v3 3/6] hw/pci-bridge: create interrupt-less, hotplug-less bridge for PXB Laszlo Ersek
2015-06-11 0:38 ` [Qemu-devel] [PATCH v3 4/6] hw/core: rebase sysbus_get_fw_dev_path() to g_strdup_printf() Laszlo Ersek
2015-06-11 9:08 ` Marcel Apfelbaum
2015-06-11 0:38 ` [Qemu-devel] [PATCH v3 5/6] hw/core: explicit OFW unit address property for SysBusDevice Laszlo Ersek
2015-06-11 9:12 ` Marcel Apfelbaum [this message]
2015-06-11 0:38 ` [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST Laszlo Ersek
2015-06-11 9:15 ` Marcel Apfelbaum
2015-06-11 9:50 ` Laszlo Ersek
2015-06-11 10:21 ` Marcel Apfelbaum
2015-06-11 10:26 ` Laszlo Ersek
2015-06-11 10:29 ` Marcel Apfelbaum
2015-06-11 10:45 ` Laszlo Ersek
2015-06-11 10:55 ` Marcel Apfelbaum
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=557950F8.8080609@redhat.com \
--to=marcel@redhat.com \
--cc=armbru@redhat.com \
--cc=lersek@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).