From: Peter Maydell <peter.maydell@linaro.org>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-ppc <qemu-ppc@nongnu.org>,
Magnus Damm <magnus.damm@gmail.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH v4 21/37] sm501: make SerialMM a child, export chardev property
Date: Thu, 21 Nov 2019 14:00:54 +0000 [thread overview]
Message-ID: <CAFEAcA-YYiKtFxegF4cqGNwVbEWk2xpPHEXHk1knTNr7x0HRyg@mail.gmail.com> (raw)
In-Reply-To: <20191120152442.26657-22-marcandre.lureau@redhat.com>
On Wed, 20 Nov 2019 at 15:31, Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> Embed the SerialMM sybus device, and re-export its "chardev" property.
> That way, we can get rid of PROP_PTR "chr-state" and better track
> devices relationship.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/display/sm501.c | 33 ++++++++++++++++++++++++---------
> hw/sh4/r2d.c | 2 +-
> 2 files changed, 25 insertions(+), 10 deletions(-)
>
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 1f33c87e65..c4445b28f9 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -1930,13 +1930,14 @@ typedef struct {
> SM501State state;
> uint32_t vram_size;
> uint32_t base;
> - void *chr_state;
> + SerialMM serial;
> } SM501SysBusState;
>
> static void sm501_realize_sysbus(DeviceState *dev, Error **errp)
> {
> SM501SysBusState *s = SYSBUS_SM501(dev);
> SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> + SerialState *ss = &s->serial.serial;
> DeviceState *usb_dev;
>
> sm501_init(&s->state, dev, s->vram_size);
> @@ -1958,17 +1959,19 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)
> sysbus_pass_irq(sbd, SYS_BUS_DEVICE(usb_dev));
>
> /* bridge to serial emulation module */
> - if (s->chr_state) {
> - serial_mm_init(&s->state.mmio_region, SM501_UART0, 2,
> - NULL, /* TODO : chain irq to IRL */
> - 115200, s->chr_state, DEVICE_LITTLE_ENDIAN);
> + /* FIXME: SM501_UART0 is always mapped, no need to check for the backend */
> + if (qemu_chr_fe_backend_connected(&ss->chr)) {
> + MemoryRegion *mr;
> + qdev_init_nofail(DEVICE(&s->serial));
> + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->serial), 0);
> + memory_region_add_subregion(&s->state.mmio_region, SM501_UART0, mr);
> + /* TODO : chain irq to IRL */
> }
I don't really understand what the FIXME is trying to
tell me here. If we don't need to check for the backend,
why is the code checking for it ? It means we have to fish
around inside the SerialMM's implementation, which seems odd.
Only mapping the UART registers if there happens to be a backend
connected also doesn't conceptually seem like the right behaviour,
because the registers should always exist. Since commit
12051d82f004024d5d the chardev mid-layer has correctly handled
the backend not being connected (ie having a NULL chardev),
so there's no longer any need for board/device code to special
case the lack of a chardev.
> }
>
> static Property sm501_sysbus_properties[] = {
> DEFINE_PROP_UINT32("vram-size", SM501SysBusState, vram_size, 0),
> DEFINE_PROP_UINT32("base", SM501SysBusState, base, 0),
> - DEFINE_PROP_PTR("chr-state", SM501SysBusState, chr_state),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> @@ -1999,9 +2002,20 @@ static void sm501_sysbus_class_init(ObjectClass *klass, void *data)
> dc->props = sm501_sysbus_properties;
> dc->reset = sm501_reset_sysbus;
> dc->vmsd = &vmstate_sm501_sysbus;
> - /* Note: pointer property "chr-state" may remain null, thus
> - * no need for dc->user_creatable = false;
> - */
> +}
> +
> +static void sm501_sysbus_init(Object *o)
> +{
> + SM501SysBusState *sm501 = SYSBUS_SM501(o);
> + SerialMM *smm = &sm501->serial;
> +
> + sysbus_init_child_obj(o, "serial", smm, sizeof(SerialMM), TYPE_SERIAL_MM);
> + qdev_set_legacy_instance_id(DEVICE(smm), SM501_UART0, 2);
The only board we use the sm501 sysbus device is the sh4 r2d
board, and we don't care about migration compatibility there
(indeed I would be unsurprised to find that it doesn't even work ;-))
So I think we can reasonably not set the legacy-instance-ID
and just declare in the commit message that this is a migration
compat break for that board.
> + qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
> + qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
> +
> + object_property_add_alias(o, "chardev",
> + OBJECT(smm), "chardev", &error_abort);
> }
>
> static const TypeInfo sm501_sysbus_info = {
> @@ -2009,6 +2023,7 @@ static const TypeInfo sm501_sysbus_info = {
> .parent = TYPE_SYS_BUS_DEVICE,
> .instance_size = sizeof(SM501SysBusState),
> .class_init = sm501_sysbus_class_init,
> + .instance_init = sm501_sysbus_init,
> };
>
> #define TYPE_PCI_SM501 "sm501"
> diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
> index ee0840f380..72bb5285cc 100644
> --- a/hw/sh4/r2d.c
> +++ b/hw/sh4/r2d.c
> @@ -272,7 +272,7 @@ static void r2d_init(MachineState *machine)
> busdev = SYS_BUS_DEVICE(dev);
> qdev_prop_set_uint32(dev, "vram-size", SM501_VRAM_SIZE);
> qdev_prop_set_uint32(dev, "base", 0x10000000);
> - qdev_prop_set_ptr(dev, "chr-state", serial_hd(2));
> + qdev_prop_set_chr(dev, "chardev", serial_hd(2));
> qdev_init_nofail(dev);
> sysbus_mmio_map(busdev, 0, 0x10000000);
> sysbus_mmio_map(busdev, 1, 0x13e00000);
> --
> 2.24.0
thanks
-- PMM
next prev parent reply other threads:[~2019-11-21 14:06 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 15:24 [PATCH v4 00/37] Clean-ups: qom-ify serial and remove QDEV_PROP_PTR Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 01/37] qdev: remove unused qdev_prop_int64 Marc-André Lureau
2019-12-02 5:22 ` Markus Armbruster
2019-12-02 10:29 ` Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 02/37] sysbus: remove unused sysbus_try_create* Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 03/37] sysbus: remove outdated comment Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 04/37] chardev: generate an internal id when none given Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 05/37] serial-pci-multi: factor out multi_serial_get_port_count() Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 06/37] serial: initial qom-ification Marc-André Lureau
2019-11-20 16:40 ` Philippe Mathieu-Daudé
2019-11-20 16:45 ` Marc-André Lureau
2019-11-21 13:39 ` Peter Maydell
2019-11-20 15:24 ` [PATCH v4 07/37] serial: register vmsd with DeviceClass Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 08/37] serial: add "chardev" property Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 09/37] serial: add "baudbase" property Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 10/37] serial: realize the serial device Marc-André Lureau
2019-11-20 16:12 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 11/37] serial: replace serial_exit_core() with unrealize Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 12/37] serial: start making SerialMM a sysbus device Marc-André Lureau
2019-11-21 13:47 ` Peter Maydell
2019-11-21 18:15 ` Marc-André Lureau
2019-11-21 18:24 ` Peter Maydell
2019-11-21 18:51 ` Marc-André Lureau
2019-11-22 10:10 ` Peter Maydell
2019-11-22 12:02 ` Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 13/37] serial-mm: add "regshift" property Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 14/37] serial-mm: add endianness property Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 15/37] serial-mm: use sysbus facilities Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 16/37] serial: make SerialIO a sysbus device Marc-André Lureau
2019-11-20 16:18 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 17/37] mips: inline serial_init() Marc-André Lureau
2019-11-20 16:17 ` Philippe Mathieu-Daudé
2019-11-25 10:12 ` Aleksandar Markovic
2019-11-25 10:15 ` Marc-André Lureau
2019-11-25 13:33 ` Aleksandar Markovic
2019-11-25 19:13 ` Marc-André Lureau
2019-11-27 12:22 ` Aleksandar Markovic
2019-11-20 15:24 ` [PATCH v4 18/37] mips: baudbase is 115200 by default Marc-André Lureau
2019-11-21 13:39 ` Peter Maydell
2019-11-25 10:07 ` Aleksandar Markovic
2019-11-25 10:12 ` Marc-André Lureau
2019-11-25 11:26 ` Philippe Mathieu-Daudé
2019-11-25 12:22 ` Aleksandar Markovic
2019-11-25 12:54 ` Philippe Mathieu-Daudé
2019-11-25 13:03 ` Philippe Mathieu-Daudé
2019-11-27 12:07 ` Marc-André Lureau
2019-11-27 12:20 ` Aleksandar Markovic
2019-11-20 15:24 ` [PATCH v4 19/37] mips: use sysbus_add_io() Marc-André Lureau
2019-11-21 13:40 ` Peter Maydell
2019-11-27 12:28 ` Aleksandar Markovic
2019-12-15 5:40 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 20/37] mips: use sysbus_mmio_get_region() instead of internal fields Marc-André Lureau
2019-11-21 13:48 ` Peter Maydell
2019-11-27 12:23 ` Aleksandar Markovic
2019-12-15 5:39 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 21/37] sm501: make SerialMM a child, export chardev property Marc-André Lureau
2019-11-21 14:00 ` Peter Maydell [this message]
2019-11-25 19:47 ` Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 22/37] vmmouse: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 23/37] lance: " Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 24/37] etraxfs: remove PROP_PTR usage Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 25/37] dp8393x: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-11-20 22:58 ` Laurent Vivier
2019-11-20 15:24 ` [PATCH v4 26/37] leon3: use qemu_irq framework instead of callback as property Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 27/37] leon3: use qdev gpio facilities for the PIL Marc-André Lureau
2019-11-21 13:51 ` Peter Maydell
2019-12-15 6:10 ` Philippe Mathieu-Daudé
2019-12-19 12:44 ` Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 28/37] qdev: use g_strcmp0() instead of open-coding it Marc-André Lureau
2019-11-20 16:25 ` Philippe Mathieu-Daudé
2019-11-20 17:10 ` Eduardo Habkost
2019-11-20 15:24 ` [PATCH v4 29/37] RFC: mips/cps: fix setting saar property Marc-André Lureau
2019-12-15 5:56 ` Philippe Mathieu-Daudé
2019-12-16 19:36 ` [EXTERNAL]Re: " Aleksandar Markovic
2019-12-19 13:04 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 30/37] cris: improve passing PIC interrupt vector to the CPU Marc-André Lureau
2019-11-20 16:32 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 31/37] smbus-eeprom: remove PROP_PTR Marc-André Lureau
2019-11-21 22:43 ` Corey Minyard
2019-11-29 9:06 ` Marc-André Lureau
2019-11-29 14:39 ` Corey Minyard
2019-11-22 11:07 ` Philippe Mathieu-Daudé
2019-11-22 11:12 ` Marc-André Lureau
2019-11-22 11:15 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 32/37] omap-intc: " Marc-André Lureau
2019-12-15 5:42 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 33/37] omap-i2c: " Marc-André Lureau
2019-12-15 5:43 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 34/37] omap-gpio: " Marc-André Lureau
2019-12-15 5:44 ` Philippe Mathieu-Daudé
2019-11-20 15:24 ` [PATCH v4 35/37] qdev: remove PROP_MEMORY_REGION Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 36/37] qdev: remove QDEV_PROP_PTR Marc-André Lureau
2019-11-20 15:24 ` [PATCH v4 37/37] qdev/qom: remove some TODO limitations now that PROP_PTR is gone Marc-André Lureau
2019-12-01 10:19 ` [PATCH v4 00/37] Clean-ups: qom-ify serial and remove QDEV_PROP_PTR Marc-André Lureau
2019-12-01 12:15 ` [PATCH v6 " Aleksandar Markovic
2019-12-01 15:35 ` Marc-André Lureau
2019-12-01 19:05 ` Aleksandar Markovic
2019-12-01 19:28 ` Aleksandar Markovic
2019-12-01 17:18 ` [PATCH v4 " Peter Maydell
2019-12-01 17:27 ` Marc-André Lureau
2019-12-01 18:10 ` Peter Maydell
2019-12-02 11:17 ` Marc-André Lureau
2019-12-12 20:17 ` Dr. David Alan Gilbert
2019-12-13 16:34 ` Marc-André Lureau
2019-12-11 12:01 ` Marc-André Lureau
2019-12-15 6:11 ` Philippe Mathieu-Daudé
2019-12-19 13:53 ` Marc-André Lureau
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=CAFEAcA-YYiKtFxegF4cqGNwVbEWk2xpPHEXHk1knTNr7x0HRyg@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=aurelien@aurel32.net \
--cc=magnus.damm@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).