[PATCH 26/50] pckbd: implement i8042_mmio_init() function

Mark Cave-Ayland posted 50 patches 3 years, 8 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Hervé Poussineau" <hpoussin@reactos.org>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>
There is a newer version of this series
[PATCH 26/50] pckbd: implement i8042_mmio_init() function
Posted by Mark Cave-Ayland 3 years, 8 months ago
This enables use to expose the register memory region of the I8042_MMIO device
using sysbus_init_mmio().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/input/pckbd.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index addd1f058a..c407c082e2 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -683,6 +683,13 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp)
                           "i8042", s->size);
 }
 
+static void i8042_mmio_init(Object *obj)
+{
+    MMIOKBDState *s = I8042_MMIO(obj);
+
+    sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region);
+}
+
 static Property i8042_mmio_properties[] = {
     DEFINE_PROP_UINT64("mask", MMIOKBDState, kbd.mask, UINT64_MAX),
     DEFINE_PROP_UINT32("size", MMIOKBDState, size, -1),
@@ -726,6 +733,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
 static const TypeInfo i8042_mmio_info = {
     .name          = TYPE_I8042_MMIO,
     .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_init = i8042_mmio_init,
     .instance_size = sizeof(MMIOKBDState),
     .class_init    = i8042_mmio_class_init
 };
-- 
2.20.1
Re: [PATCH 26/50] pckbd: implement i8042_mmio_init() function
Posted by Peter Maydell 3 years, 8 months ago
On Sun, 22 May 2022 at 19:19, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
>
> This enables use to expose the register memory region of the I8042_MMIO device
> using sysbus_init_mmio().
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/input/pckbd.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
> index addd1f058a..c407c082e2 100644
> --- a/hw/input/pckbd.c
> +++ b/hw/input/pckbd.c
> @@ -683,6 +683,13 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp)
>                            "i8042", s->size);
>  }
>
> +static void i8042_mmio_init(Object *obj)
> +{
> +    MMIOKBDState *s = I8042_MMIO(obj);
> +
> +    sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region);
> +}

You don't initialize s->region until your device realize function;
you should only call sysbus_init_mmio() after that, so this line
belongs in the realize function too.

thanks
-- PMM
Re: [PATCH 26/50] pckbd: implement i8042_mmio_init() function
Posted by Mark Cave-Ayland 3 years, 8 months ago
On 09/06/2022 11:53, Peter Maydell wrote:

> On Sun, 22 May 2022 at 19:19, Mark Cave-Ayland
> <mark.cave-ayland@ilande.co.uk> wrote:
>>
>> This enables use to expose the register memory region of the I8042_MMIO device
>> using sysbus_init_mmio().
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> ---
>>   hw/input/pckbd.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
>> index addd1f058a..c407c082e2 100644
>> --- a/hw/input/pckbd.c
>> +++ b/hw/input/pckbd.c
>> @@ -683,6 +683,13 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp)
>>                             "i8042", s->size);
>>   }
>>
>> +static void i8042_mmio_init(Object *obj)
>> +{
>> +    MMIOKBDState *s = I8042_MMIO(obj);
>> +
>> +    sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region);
>> +}
> 
> You don't initialize s->region until your device realize function;
> you should only call sysbus_init_mmio() after that, so this line
> belongs in the realize function too.

Yes indeed, I can fix this fairly easily.


ATB,

Mark.