Skip to contentSkip to conversation

hw/char: Remove TYPE_SERIAL_IO

PATCH Superseded Philippe Mathieu-Daudé 2 participants 6 messages Jul 30, 2020 – Sep 2, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hw/char: Remove TYPE_SERIAL_IO

Remove the TYPE_SERIAL_IO which is simply a superset of TYPE_SERIAL_MM, as suggested by Paolo and Peter here:
https://www.mail-archive.com/[email protected]/msg721806.html

Philippe Mathieu-Daudé (2):
hw/mips/mipssim: Use MMIO serial device on fake ISA I/O hw/char/serial: Remove TYPE_SERIAL_IO (superset of TYPE_SERIAL_MM)

 include/hw/char/serial.h |  9 ---------
 hw/char/serial.c         | 41 ----------------------------------------
 hw/mips/mipssim.c        |  4 +++-
 3 files changed, 3 insertions(+), 51 deletions(-)
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/2 hw/mips/mipssim: Use MMIO serial device on fake ISA I/O

The 'mipssim' is not a real hardware, it is a simulator.

There is an ISA MMIO space mapped at 0x1fd00000, however this is not a real ISA bus (no ISA IRQ). So can not use the TYPE_ISA_SERIAL device...
Instead we have been using a plain MMIO device, but named it IO.

TYPE_SERIAL_IO is a superset of TYPE_SERIAL_MM, using regshift=0 and endianness=DEVICE_LITTLE_ENDIAN.

Directly use the TYPE_SERIAL_MM device, enforcing the regshift/endianness values. 'regshift' default is already '0'. 'endianness' is meaningless for 8-bit accesses.

Note, there is no migration problem, because TYPE_SERIAL_IO was not migrated.

---
 hw/mips/mipssim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/mips/mipssim.c +3 -1
index 1b3b762203..853bbaca58 100644
@@ -216,9 +216,11 @@ mips_mipssim_init(MachineState *machine)
      * MIPS CPU INT2, which is interrupt 4.
      */
     if (serial_hd(0)) {
-        DeviceState *dev = qdev_new(TYPE_SERIAL_IO);
+        DeviceState *dev = qdev_new(TYPE_SERIAL_MM);
 
         qdev_prop_set_chr(dev, "chardev", serial_hd(0));
+        qdev_prop_set_uint8(dev, "regshift", 0);
+        qdev_prop_set_uint8(dev, "endianness", DEVICE_LITTLE_ENDIAN);
         qdev_set_legacy_instance_id(dev, 0x3f8, 2);
         sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]);
Signature · 1 line
2.21.3
#2 lore raw

Re: [PATCH-for-5.2 1/2] hw/mips/mipssim: Use MMIO serial device on fake ISA I/O

Hi

Quoted 11 lines · Philippe Mathieu-Daudé

The 'mipssim' is not a real hardware, it is a simulator.

There is an ISA MMIO space mapped at 0x1fd00000, however this is not a real ISA bus (no ISA IRQ). So can not use the TYPE_ISA_SERIAL device...
Instead we have been using a plain MMIO device, but named it IO.

TYPE_SERIAL_IO is a superset of TYPE_SERIAL_MM, using regshift=0 and endianness=DEVICE_LITTLE_ENDIAN.

Quoted 7 lines

Directly use the TYPE_SERIAL_MM device, enforcing the regshift/endianness values. 'regshift' default is already '0'. 'endianness' is meaningless for 8-bit accesses.

Note, there is no migration problem, because TYPE_SERIAL_IO was not migrated.

I am not so sure about that. It has:

    /* No dc->vmsd: class has no migratable state */

but that doesn't mean it's not migratable I think.

Quoted 28 lines
---
 hw/mips/mipssim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/mips/mipssim.c +3 -2
index 1b3b762203..853bbaca58 100644
@@ -216,9 +216,11 @@ mips_mipssim_init(MachineState *machine)
      * MIPS CPU INT2, which is interrupt 4.
      */
     if (serial_hd(0)) {
-        DeviceState *dev = qdev_new(TYPE_SERIAL_IO);
+        DeviceState *dev = qdev_new(TYPE_SERIAL_MM);
 
         qdev_prop_set_chr(dev, "chardev", serial_hd(0));
+        qdev_prop_set_uint8(dev, "regshift", 0);
+        qdev_prop_set_uint8(dev, "endianness", DEVICE_LITTLE_ENDIAN);
         qdev_set_legacy_instance_id(dev, 0x3f8, 2);
         sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]);
--

2.21.3

Signature · 1 line
Marc-André Lureau
#3 lore raw

Re: [PATCH-for-5.2 1/2] hw/mips/mipssim: Use MMIO serial device on fake ISA I/O

Quoted 20 lines · Marc-André Lureau

Hi

On Thu, Jul 30, 2020 at 9:04 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

The 'mipssim' is not a real hardware, it is a simulator.

There is an ISA MMIO space mapped at 0x1fd00000, however this is not a real ISA bus (no ISA IRQ). So can not use the TYPE_ISA_SERIAL device...
Instead we have been using a plain MMIO device, but named it IO.

TYPE_SERIAL_IO is a superset of TYPE_SERIAL_MM, using regshift=0 and endianness=DEVICE_LITTLE_ENDIAN.

Directly use the TYPE_SERIAL_MM device, enforcing the regshift/endianness values. 'regshift' default is already '0'. 'endianness' is meaningless for 8-bit accesses.

Quoted 8 lines

Note, there is no migration problem, because TYPE_SERIAL_IO was not migrated.

I am not so sure about that. It has:
    /* No dc->vmsd: class has no migratable state */

but that doesn't mean it's not migratable I think.

Can you be more verbose... I don't understand what I should do. Reword the patch description or modify the patch? Thanks.

Quoted 35 lines

    Suggested-by: Peter Maydell <[email protected]
    <mailto:[email protected]>>
    Signed-off-by: Philippe Mathieu-Daudé <[email protected]
    <mailto:[email protected]>>
    ---
     hw/mips/mipssim.c | 4 +++-
     1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
    index 1b3b762203..853bbaca58 100644
    --- a/hw/mips/mipssim.c
    +++ b/hw/mips/mipssim.c
    @@ -216,9 +216,11 @@ mips_mipssim_init(MachineState *machine)
          * MIPS CPU INT2, which is interrupt 4.
          */
         if (serial_hd(0)) {
    -        DeviceState *dev = qdev_new(TYPE_SERIAL_IO);
    +        DeviceState *dev = qdev_new(TYPE_SERIAL_MM);

             qdev_prop_set_chr(dev, "chardev", serial_hd(0));
    +        qdev_prop_set_uint8(dev, "regshift", 0);
    +        qdev_prop_set_uint8(dev, "endianness", DEVICE_LITTLE_ENDIAN);
             qdev_set_legacy_instance_id(dev, 0x3f8, 2);
             sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
             sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]);
    -- 
    2.21.3
Signature · 1 line
Marc-André Lureau
#4 lore raw

PATCH 2/2 hw/char/serial: Remove TYPE_SERIAL_IO (superset of TYPE_SERIAL_MM)

In reply to Philippe Mathieu-Daudé

TYPE_SERIAL_IO is a superset of TYPE_SERIAL_MM, and it is not used anymore. Remove it.

---
 include/hw/char/serial.h |  9 ---------
 hw/char/serial.c         | 41 ----------------------------------------
 2 files changed, 50 deletions(-)
include/hw/char/serial.h +0 -9
index 535fa23a2b..81d7ba1917 100644
@@ -88,12 +88,6 @@ typedef struct SerialMM {
     uint8_t endianness;
 } SerialMM;
 
-typedef struct SerialIO {
-    SysBusDevice parent;
-
-    SerialState serial;
-} SerialIO;
-
 extern const VMStateDescription vmstate_serial;
 extern const MemoryRegionOps serial_io_ops;
 
@@ -105,9 +99,6 @@ void serial_set_frequency(SerialState *s, uint32_t frequency);
 #define TYPE_SERIAL_MM "serial-mm"
 #define SERIAL_MM(s) OBJECT_CHECK(SerialMM, (s), TYPE_SERIAL_MM)
 
-#define TYPE_SERIAL_IO "serial-io"
-#define SERIAL_IO(s) OBJECT_CHECK(SerialIO, (s), TYPE_SERIAL_IO)
-
 SerialMM *serial_mm_init(MemoryRegion *address_space,
                          hwaddr base, int regshift,
                          qemu_irq irq, int baudbase,
hw/char/serial.c +0 -41

53 lines not on this page · raw message

Signature · 1 line
2.21.3
#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

Remove the TYPE_SERIAL_IO which is simply a superset of TYPE_SERIAL_MM, as suggested by Paolo and Peter here:
https://www.mail-archive.com/[email protected]/msg721806.html

Quoted 9 lines

Philippe Mathieu-Daudé (2):
hw/mips/mipssim: Use MMIO serial device on fake ISA I/O hw/char/serial: Remove TYPE_SERIAL_IO (superset of TYPE_SERIAL_MM)

 include/hw/char/serial.h |  9 ---------
 hw/char/serial.c         | 41 ----------------------------------------
 hw/mips/mipssim.c        |  4 +++-
 3 files changed, 3 insertions(+), 51 deletions(-)

ping? ...