qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Corey Minyard" <cminyard@mvista.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"KONRAD Frederic" <frederic.konrad@adacore.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Aleksandar Rikalo" <arikalo@wavecomp.com>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Fabien Chouteau" <chouteau@adacore.com>,
	qemu-arm <qemu-arm@nongnu.org>,
	"Richard Henderson" <rth@twiddle.net>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-ppc <qemu-ppc@nongnu.org>,
	"Aleksandar Markovic" <amarkovic@wavecomp.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: Re: [PATCH 01/14] sm501: replace PROP_PTR with PROP_LINK
Date: Fri, 18 Oct 2019 18:36:43 +0200	[thread overview]
Message-ID: <CAMxuvaw2CMqOuGXVq4Gk+GDNrjq++Ho+460WN9yo-pJFPVZhjw@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA_7zxe6YfM6c8v_SQ+qh2L7Q5RS_xEPvy01q9aPZ6YyiQ@mail.gmail.com>

Hi

On Fri, Oct 18, 2019 at 6:22 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Fri, 18 Oct 2019 at 16:42, Marc-André Lureau
> <marcandre.lureau@redhat.com> wrote:
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  hw/display/sm501.c | 5 +++--
> >  hw/sh4/r2d.c       | 3 ++-
> >  2 files changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> > index 1f33c87e65..a87d18efab 100644
> > --- a/hw/display/sm501.c
> > +++ b/hw/display/sm501.c
> > @@ -1930,7 +1930,7 @@ typedef struct {
> >      SM501State state;
> >      uint32_t vram_size;
> >      uint32_t base;
> > -    void *chr_state;
> > +    Chardev *chr_state;
> >  } SM501SysBusState;
> >
> >  static void sm501_realize_sysbus(DeviceState *dev, Error **errp)
> > @@ -1968,7 +1968,8 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)
> >  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_LINK("chr-state", SM501SysBusState, chr_state,
> > +                     TYPE_CHARDEV, Chardev *),
> >      DEFINE_PROP_END_OF_LIST(),
> >  };
> >
> > diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
> > index ee0840f380..5780ee85d9 100644
> > --- a/hw/sh4/r2d.c
> > +++ b/hw/sh4/r2d.c
> > @@ -272,7 +272,8 @@ 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));
> > +    object_property_set_link(OBJECT(dev), OBJECT(serial_hd(2)),
> > +                             "chr-state", &error_abort);
> >      qdev_init_nofail(dev);
> >      sysbus_mmio_map(busdev, 0, 0x10000000);
> >      sysbus_mmio_map(busdev, 1, 0x13e00000);
>
> We have a typed way of passing a Chardev to devices:
> use qdev_prop_set_chr(). Unfortunately it's not trivially
> easy to drop in here, because it sets a property defined
> with DEFINE_PROP_CHR to set a field of type CharBackend
> (note, not Chardev, and not a pointer) in the device struct.
> But serial_mm_init() wants a Chardev*, because it is a
> non-QOM interface to the serial device and is manually
> doing the qemu_chr_fe_init() that connects the Chardev
> to its own CharBackend. The QOM CHR property setter wants
> to do that qemu_chr_fe_init() itself.
>
> So I think the right fix here is to properly QOMify the
> code which is not QOMified, ie hw/char/serial.c, in a
> way that means that the various "memory mapped 16650-ish
> devices" we have can use it and can define a
> TYPE_CHARDEV property.

I see, I can look at that.

> In general I think our uses of PROP_PTR are code smells
> that indicate places where we have not properly converted
> code over to the general approach that the QOM/qdev
> design desires; but we should be getting rid of PROP_PTR
> by actually doing all those (difficult) conversions.

I think all user_creatable = false are smelly in that regard.

> Merely removing PROP_PTR itself by rephrasing the dubious
> inter-device connections in a way that makes them harder
> to grep for doesn't seem to me to be necessarily worth

grep for user_creatable = false

> doing. Is the existence of PROP_PTR getting in your way
> for a change you want to make ?

Yes, I am looking at improving the qdev vs object and class vs
instance properties. I have a larger series of wip refactoring. This
initial series is preliminary cleanup that would help.


  reply	other threads:[~2019-10-18 16:37 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 15:41 [PATCH 00/14] Clean-ups: remove QDEV_PROP_PTR Marc-André Lureau
2019-10-18 15:41 ` [PATCH 01/14] sm501: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-10-18 16:22   ` Peter Maydell
2019-10-18 16:36     ` Marc-André Lureau [this message]
2019-10-18 16:50       ` Peter Maydell
2019-10-18 15:42 ` [PATCH 02/14] vmmouse: " Marc-André Lureau
2019-10-21 10:10   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 03/14] lance: " Marc-André Lureau
2019-10-21 10:05   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 04/14] etraxfs: remove PROP_PTR usage Marc-André Lureau
2019-10-18 15:59   ` Peter Maydell
2019-10-18 16:11     ` Marc-André Lureau
2019-10-18 16:34       ` Peter Maydell
2019-10-21 10:41   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 05/14] dp8393x: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-10-18 17:49   ` Peter Maydell
2019-10-18 18:14   ` Aleksandar Markovic
2019-10-18 15:42 ` [PATCH 06/14] leon3: " Marc-André Lureau
2019-10-18 17:45   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 07/14] RFC: mips/cps: fix setting saar property Marc-André Lureau
2019-10-18 17:04   ` Philippe Mathieu-Daudé
2019-10-18 17:42   ` Aleksandar Markovic
2019-10-18 15:42 ` [PATCH 08/14] cris: replace PROP_PTR with PROP_LINK for interrupt vector Marc-André Lureau
2019-10-18 17:37   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 09/14] smbus-eeprom: remove PROP_PTR Marc-André Lureau
2019-10-18 17:20   ` Peter Maydell
2019-10-21 14:52     ` Corey Minyard
2019-10-21 21:28   ` Marc-André Lureau
2019-10-18 15:42 ` [PATCH 10/14] omap-intc: " Marc-André Lureau
2019-10-18 16:55   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 11/14] omap-i2c: " Marc-André Lureau
2019-10-18 16:56   ` Peter Maydell
2019-10-21 15:03   ` Corey Minyard
2019-10-18 15:42 ` [PATCH 12/14] omap-gpio: " Marc-André Lureau
2019-10-18 16:58   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 13/14] qdev: remove PROP_MEMORY_REGION Marc-André Lureau
2019-10-18 16:58   ` Peter Maydell
2019-10-18 15:42 ` [PATCH 14/14] Remove QDEV_PROP_PTR Marc-André Lureau
2019-10-18 16:59   ` Peter Maydell

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=CAMxuvaw2CMqOuGXVq4Gk+GDNrjq++Ho+460WN9yo-pJFPVZhjw@mail.gmail.com \
    --to=marcandre.lureau@redhat.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=atar4qemu@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=berrange@redhat.com \
    --cc=chouteau@adacore.com \
    --cc=cminyard@mvista.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=frederic.konrad@adacore.com \
    --cc=hpoussin@reactos.org \
    --cc=jasowang@redhat.com \
    --cc=magnus.damm@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /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).