Received: from eggs.gnu.org ([2001:4830:134:3::10]:55967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcaQm-0001kH-2D for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcaQh-000247-Lr for qemu-devel@nongnu.org; Mon, 30 Mar 2015 10:12:44 -0400 From: Markus Armbruster References: <1427651603-9210-1-git-send-email-afaerber@suse.de> <1427651603-9210-3-git-send-email-afaerber@suse.de> Date: Mon, 30 Mar 2015 16:12:35 +0200 In-Reply-To: <1427651603-9210-3-git-send-email-afaerber@suse.de> ("Andreas =?utf-8?Q?F=C3=A4rber=22's?= message of "Sun, 29 Mar 2015 19:53:17 +0200") Message-ID: <87619ik20c.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC for-2.3? 2/8] pc87312: Create isa-parallel in-place and add alias par0-chardev property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, Alexander Graf , Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-ppc@nongnu.org, hpoussin@reactos.org, jsnow@redhat.com Andreas F=C3=A4rber writes: > Move the parallel_hds[] code to the PReP machine. Could use a brief explanation *why* we move it. > Signed-off-by: Andreas F=C3=A4rber > --- > hw/isa/pc87312.c | 25 +++++++++++++++---------- > hw/ppc/prep.c | 9 +++++++++ > include/hw/isa/pc87312.h | 5 ++--- > 3 files changed, 26 insertions(+), 13 deletions(-) > > diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c > index 40a1106..ded6c01 100644 > --- a/hw/isa/pc87312.c > +++ b/hw/isa/pc87312.c > @@ -268,6 +268,7 @@ static void pc87312_realize(DeviceState *dev, Error *= *errp) > ISABus *bus; > CharDriverState *chr; > DriveInfo *drive; > + Error *local_err =3D NULL; > char name[5]; > int i; >=20=20 > @@ -278,20 +279,19 @@ static void pc87312_realize(DeviceState *dev, Error= **errp) > pc87312_hard_reset(s); >=20=20 > if (is_parallel_enabled(s)) { > - chr =3D parallel_hds[0]; > - if (chr =3D=3D NULL) { > - chr =3D qemu_chr_new("par0", "null", NULL); > - } > - isa =3D isa_create(bus, "isa-parallel"); > - d =3D DEVICE(isa); > - qdev_prop_set_uint32(d, "index", 0); > + d =3D DEVICE(&s->parallel); > + qdev_set_parent_bus(d, BUS(bus)); > qdev_prop_set_uint32(d, "iobase", get_parallel_iobase(s)); > qdev_prop_set_uint32(d, "irq", get_parallel_irq(s)); > - qdev_prop_set_chr(d, "chardev", chr); > - qdev_init_nofail(d); > - s->parallel.dev =3D isa; > trace_pc87312_info_parallel(get_parallel_iobase(s), > get_parallel_irq(s)); > + object_property_set_bool(OBJECT(&s->parallel), true, "realized", > + &local_err); > + object_unref(OBJECT(&s->parallel)); Ignorant question: why unref here? > + if (local_err) { > + error_propagate(errp, local_err); > + return; > + } > } >=20=20 > for (i =3D 0; i < 2; i++) { > @@ -351,6 +351,11 @@ static void pc87312_initfn(Object *obj) > PC87312State *s =3D PC87312(obj); >=20=20 > memory_region_init_io(&s->io, obj, &pc87312_io_ops, s, "pc87312", 2); > + > + object_initialize(&s->parallel, sizeof(s->parallel), TYPE_ISA_PARALL= EL); > + object_property_add_alias(obj, "par0-chardev", > + OBJECT(&s->parallel), "chardev", &error_ab= ort); > + qdev_prop_set_uint32(DEVICE(&s->parallel), "index", 0); > } >=20=20 > static const VMStateDescription vmstate_pc87312 =3D { > diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c > index 7f52662..1dfa051 100644 > --- a/hw/ppc/prep.c > +++ b/hw/ppc/prep.c > @@ -40,6 +40,7 @@ > #include "hw/isa/pc87312.h" > #include "sysemu/block-backend.h" > #include "sysemu/arch_init.h" > +#include "sysemu/char.h" > #include "sysemu/qtest.h" > #include "exec/address-spaces.h" > #include "elf.h" > @@ -528,6 +529,7 @@ static void ppc_prep_init(MachineState *machine) > PCIDevice *pci; > ISABus *isa_bus; > ISADevice *isa; > + CharDriverState *chr; > qemu_irq *cpu_exit_irq; > int ppc_boot_device; > DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; > @@ -639,6 +641,13 @@ static void ppc_prep_init(MachineState *machine) > /* Super I/O (parallel + serial ports) */ > isa =3D isa_create(isa_bus, TYPE_PC87312); > dev =3D DEVICE(isa); > + chr =3D parallel_hds[0]; > + if (chr =3D=3D NULL) { > + chr =3D qemu_chr_new("par0", "null", NULL); > + } > + if (chr !=3D NULL) { > + qdev_prop_set_chr(dev, "par0-chardev", chr); > + } > qdev_prop_set_uint8(dev, "config", 13); /* fdc, ser0, ser1, par0 */ > qdev_init_nofail(dev); >=20=20 Unlike the old code, this checks for qemu_chr_new() failure. Can this happen? If it does, property "par0-chardev" remains null. parallel_isa_realizefn() will then fail. Worth a comment, I think. I don't like boards creating backends with IDs on their own as long as we don't have a ID namespace reserved for the system. However, this is preexisting, so let's not worry about it now. > diff --git a/include/hw/isa/pc87312.h b/include/hw/isa/pc87312.h > index bf74470..b473b3b 100644 > --- a/include/hw/isa/pc87312.h > +++ b/include/hw/isa/pc87312.h > @@ -26,6 +26,7 @@ > #define QEMU_PC87312_H >=20=20 > #include "hw/isa/isa.h" > +#include "hw/char/parallel.h" >=20=20 >=20=20 > #define TYPE_PC87312 "pc87312" > @@ -37,9 +38,7 @@ typedef struct PC87312State { > uint32_t iobase; > uint8_t config; /* initial configuration */ >=20=20 > - struct { > - ISADevice *dev; > - } parallel; > + ISAParallelState parallel; >=20=20 > struct { > ISADevice *dev;