Skip to contentSkip to conversation

aspeed: simplify using the 'unimplemented device' for aspeed_soc.io

PATCH Superseded Philippe Mathieu-Daudé 4 participants 9 messages Feb 8, 2018 – Feb 9, 2018 Arm/Aspeed machine support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover aspeed: simplify using the 'unimplemented device' for aspeed_soc.io

The diffstat prooves it :)

Philippe Mathieu-Daudé (2):
hw/arm/aspeed: directly map the serial device to the system address space hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io

 include/hw/arm/aspeed_soc.h |  1 -
 hw/arm/aspeed_soc.c         | 34 ++++------------------------------
 2 files changed, 4 insertions(+), 31 deletions(-)
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/2 hw/arm/aspeed: directly map the serial device to the system address space

---
 hw/arm/aspeed_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/aspeed_soc.c +1 -1
index c83b7e207b..a786750e14 100644
@@ -257,7 +257,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     /* UART - attach an 8250 to the IO space as our UART5 */
     if (serial_hds[0]) {
         qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
-        serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
+        serial_mm_init(get_system_memory(), ASPEED_SOC_UART_5_BASE, 2,
                        uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
     }
 
Signature · 1 line
2.16.1
#2 lore raw

Re: [Qemu-arm] [PATCH 1/2] hw/arm/aspeed: directly map the serial device to the system address space

Quoted 10 lines · Philippe Mathieu-Daudé
---
 hw/arm/aspeed_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/aspeed_soc.c +0 -0
index c83b7e207b..a786750e14 100644

hw/arm/aspeed_soc.c static void aspeed_soc_realize(DeviceState *dev, Error **errp) · line 262

Quoted 7 lines
hw/arm/aspeed_soc.c +1 -1
@@ -257,7 +257,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     /* UART - attach an 8250 to the IO space as our UART5 */
     if (serial_hds[0]) {
         qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
-        serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
+        serial_mm_init(get_system_memory(), ASPEED_SOC_UART_5_BASE, 2,
                        uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
     }

Is this a bug fix? It certainly changes behaviour, which suggests that a fuller commit message would be useful.

thanks
-- PMM

#3 lore raw

Re: [Qemu-arm] [PATCH 1/2] hw/arm/aspeed: directly map the serial device to the system address space

Quoted 6 lines · Peter Maydell
Quoted 5 lines · Philippe Mathieu-Daudé
---
 hw/arm/aspeed_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

hw/arm/aspeed_soc.c static void aspeed_soc_realize(DeviceState *dev, Error **errp) · line 262

Quoted 12 lines
hw/arm/aspeed_soc.c +1 -1
index c83b7e207b..a786750e14 100644
@@ -257,7 +257,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     /* UART - attach an 8250 to the IO space as our UART5 */
     if (serial_hds[0]) {
         qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
-        serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
+        serial_mm_init(get_system_memory(), ASPEED_SOC_UART_5_BASE, 2,
                        uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
     }

Is this a bug fix? It certainly changes behaviour, which suggests that a fuller commit message would be useful.

This patch is buggy indeed, using system_memory the serial address should be ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE.

Thanks!

Phil.

#4 lore raw

Re: [Qemu-arm] [PATCH 1/2] hw/arm/aspeed: directly map the serial device to the system address space

Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Philippe Mathieu-Daudé
---
 hw/arm/aspeed_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

hw/arm/aspeed_soc.c static void aspeed_soc_realize(DeviceState *dev, Error **errp) · line 262

Quoted 12 lines
hw/arm/aspeed_soc.c +1 -1
index c83b7e207b..a786750e14 100644
@@ -257,7 +257,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     /* UART - attach an 8250 to the IO space as our UART5 */
     if (serial_hds[0]) {
         qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
-        serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
+        serial_mm_init(get_system_memory(), ASPEED_SOC_UART_5_BASE, 2,
                        uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
     }

Is this a bug fix? It certainly changes behaviour, which suggests that a fuller commit message would be useful.

Quoted 3 lines

This patch is buggy indeed, using system_memory the serial address should be ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE.

If you'd like to test, you can grab images from here:

https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=romulus/

For example (without the patch):

    $ wget     https://openpower.xyz/job/openbmc-build/1240/distro=ubuntu,target=romulus/artifact/deploy/images/romulus/image-bmc
...
$ qemu-system-arm -M romulus-bmc -m 512 -drive file=image-bmc,if=mtd,format=raw -nographic

U-Boot 2016.07 (Jan 25 2018 - 16:31:27 +0000)

Watchdog enabled

DRAM:  496 MiB                                  
Flash: 32 MiB                                   

*** Warning - bad CRC, using default environment

In:    serial                                   
Out:   serial                                   
Err:   serial                                   
Net:   aspeednic#0                              
Error: aspeednic#0 address not set.             

Hit any key to stop autoboot: 0
## Loading kernel from FIT Image at 20080000 ...
...

And yeah, this patch breaks output.

Thanks for the cleanup though.

Andrew

#5 lore raw

Re: [Qemu-devel] [Qemu-arm] [PATCH 1/2] hw/arm/aspeed: directly map the serial device to the system address space

Quoted 28 lines · Andrew Jeffery
Quoted 23 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Philippe Mathieu-Daudé
---
 hw/arm/aspeed_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

hw/arm/aspeed_soc.c static void aspeed_soc_realize(DeviceState *dev, Error **errp) · line 262

Quoted 12 lines
hw/arm/aspeed_soc.c +1 -1
index c83b7e207b..a786750e14 100644
@@ -257,7 +257,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     /* UART - attach an 8250 to the IO space as our UART5 */
     if (serial_hds[0]) {
         qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
-        serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2,
+        serial_mm_init(get_system_memory(), ASPEED_SOC_UART_5_BASE, 2,
                        uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN);
     }

Is this a bug fix? It certainly changes behaviour, which suggests that a fuller commit message would be useful.

Quoted 3 lines

This patch is buggy indeed, using system_memory the serial address should be ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE.

Quoted 7 lines

If you'd like to test, you can grab images from here:

https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=romulus/

For example (without the patch):

    $ wget     https://openpower.xyz/job/openbmc-build/1240/distro=ubuntu,target=romulus/artifact/deploy/images/romulus/image-bmc

Thanks for this useful link!

Quoted 2 lines

...

$ qemu-system-arm -M romulus-bmc -m 512 -drive file=image-bmc,if=mtd,format=raw -nographic

good candidate for an Avocado / pyexpect test...

Quoted 15 lines

U-Boot 2016.07 (Jan 25 2018 - 16:31:27 +0000)

Watchdog enabled

DRAM:  496 MiB                                  
Flash: 32 MiB                                   

*** Warning - bad CRC, using default environment

In:    serial                                   
Out:   serial                                   
Err:   serial                                   
Net:   aspeednic#0                              
Error: aspeednic#0 address not set.             
Quoted 5 lines

Hit any key to stop autoboot: 0
## Loading kernel from FIT Image at 20080000 ...
...

And yeah, this patch breaks output.

Sorry I didn't care enough testing this series :|

Quoted 5 lines

Thanks for the cleanup though.

Andrew

#6 lore raw

PATCH 2/2 hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io

In reply to Philippe Mathieu-Daudé
---
 include/hw/arm/aspeed_soc.h |  1 -
 hw/arm/aspeed_soc.c         | 32 +++-----------------------------
 2 files changed, 3 insertions(+), 30 deletions(-)
include/hw/arm/aspeed_soc.h +0 -1
index f26914a2b9..11ec0179db 100644
@@ -31,7 +31,6 @@ typedef struct AspeedSoCState {
 
     /*< public >*/
     ARMCPU cpu;
-    MemoryRegion iomem;
     MemoryRegion sram;
     AspeedVICState vic;
     AspeedTimerCtrlState timerctrl;
hw/arm/aspeed_soc.c +3 -29
index a786750e14..3d21128d47 100644
@@ -15,6 +15,7 @@
 #include "qemu-common.h"
 #include "cpu.h"
 #include "exec/address-spaces.h"
+#include "hw/misc/unimp.h"
 #include "hw/arm/aspeed_soc.h"
 #include "hw/char/serial.h"
 #include "qemu/log.h"
@@ -99,31 +100,6 @@ static const AspeedSoCInfo aspeed_socs[] = {
     },
 };
 
-/*
- * IO handlers: simply catch any reads/writes to IO addresses that aren't
- * handled by a device mapping.
- */
-
-static uint64_t aspeed_soc_io_read(void *p, hwaddr offset, unsigned size)
-{
-    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
-                  __func__, offset, size);
-    return 0;
-}
-
-static void aspeed_soc_io_write(void *opaque, hwaddr offset, uint64_t value,
-                unsigned size)
-{
-    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n",
-                  __func__, offset, value, size);
-}
-
-static const MemoryRegionOps aspeed_soc_io_ops = {
-    .read = aspeed_soc_io_read,
-    .write = aspeed_soc_io_write,
-    .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
 static void aspeed_soc_init(Object *obj)
 {
     AspeedSoCState *s = ASPEED_SOC(obj);
@@ -199,10 +175,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     Error *err = NULL, *local_err = NULL;
 
     /* IO space */
-    memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL,
-            "aspeed_soc.io", ASPEED_SOC_IOMEM_SIZE);
-    memory_region_add_subregion_overlap(get_system_memory(),
-                                        ASPEED_SOC_IOMEM_BASE, &s->iomem, -1);
+    create_unimplemented_device("aspeed_soc.io",
+                                ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE);
 
     /* CPU */
     object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
Signature · 1 line
2.16.1
Reviewed-by on v1 2/2
#7 lore raw

Re: [Qemu-arm] [PATCH 2/2] hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io

Quoted 1 line · Philippe Mathieu-Daudé

This looks like a good idea. (Have you actually tried it ? just asking)

Thanks,

C.

Quoted 75 lines
---
 include/hw/arm/aspeed_soc.h |  1 -
 hw/arm/aspeed_soc.c         | 32 +++-----------------------------
 2 files changed, 3 insertions(+), 30 deletions(-)
include/hw/arm/aspeed_soc.h +0 -1
index f26914a2b9..11ec0179db 100644
@@ -31,7 +31,6 @@ typedef struct AspeedSoCState {
 
     /*< public >*/
     ARMCPU cpu;
-    MemoryRegion iomem;
     MemoryRegion sram;
     AspeedVICState vic;
     AspeedTimerCtrlState timerctrl;
hw/arm/aspeed_soc.c +3 -29
index a786750e14..3d21128d47 100644
@@ -15,6 +15,7 @@
 #include "qemu-common.h"
 #include "cpu.h"
 #include "exec/address-spaces.h"
+#include "hw/misc/unimp.h"
 #include "hw/arm/aspeed_soc.h"
 #include "hw/char/serial.h"
 #include "qemu/log.h"
@@ -99,31 +100,6 @@ static const AspeedSoCInfo aspeed_socs[] = {
     },
 };
 
-/*
- * IO handlers: simply catch any reads/writes to IO addresses that aren't
- * handled by a device mapping.
- */
-
-static uint64_t aspeed_soc_io_read(void *p, hwaddr offset, unsigned size)
-{
-    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
-                  __func__, offset, size);
-    return 0;
-}
-
-static void aspeed_soc_io_write(void *opaque, hwaddr offset, uint64_t value,
-                unsigned size)
-{
-    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n",
-                  __func__, offset, value, size);
-}
-
-static const MemoryRegionOps aspeed_soc_io_ops = {
-    .read = aspeed_soc_io_read,
-    .write = aspeed_soc_io_write,
-    .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
 static void aspeed_soc_init(Object *obj)
 {
     AspeedSoCState *s = ASPEED_SOC(obj);
@@ -199,10 +175,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     Error *err = NULL, *local_err = NULL;
 
     /* IO space */
-    memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL,
-            "aspeed_soc.io", ASPEED_SOC_IOMEM_SIZE);
-    memory_region_add_subregion_overlap(get_system_memory(),
-                                        ASPEED_SOC_IOMEM_BASE, &s->iomem, -1);
+    create_unimplemented_device("aspeed_soc.io",
+                                ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE);
 
     /* CPU */
     object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
#8 lore raw

Re: [Qemu-arm] [PATCH 2/2] hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io

Quoted 5 lines · Cédric Le Goater
Quoted 1 line · Philippe Mathieu-Daudé

This looks like a good idea. (Have you actually tried it ? just asking)

v1 obviously not :S v2 yes!

Quoted 2 lines

Thanks :)

Quoted 82 lines

Thanks,

C.

Quoted 75 lines
---
 include/hw/arm/aspeed_soc.h |  1 -
 hw/arm/aspeed_soc.c         | 32 +++-----------------------------
 2 files changed, 3 insertions(+), 30 deletions(-)
include/hw/arm/aspeed_soc.h +0 -1
index f26914a2b9..11ec0179db 100644
@@ -31,7 +31,6 @@ typedef struct AspeedSoCState {
 
     /*< public >*/
     ARMCPU cpu;
-    MemoryRegion iomem;
     MemoryRegion sram;
     AspeedVICState vic;
     AspeedTimerCtrlState timerctrl;
hw/arm/aspeed_soc.c +3 -29
index a786750e14..3d21128d47 100644
@@ -15,6 +15,7 @@
 #include "qemu-common.h"
 #include "cpu.h"
 #include "exec/address-spaces.h"
+#include "hw/misc/unimp.h"
 #include "hw/arm/aspeed_soc.h"
 #include "hw/char/serial.h"
 #include "qemu/log.h"
@@ -99,31 +100,6 @@ static const AspeedSoCInfo aspeed_socs[] = {
     },
 };
 
-/*
- * IO handlers: simply catch any reads/writes to IO addresses that aren't
- * handled by a device mapping.
- */
-
-static uint64_t aspeed_soc_io_read(void *p, hwaddr offset, unsigned size)
-{
-    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
-                  __func__, offset, size);
-    return 0;
-}
-
-static void aspeed_soc_io_write(void *opaque, hwaddr offset, uint64_t value,
-                unsigned size)
-{
-    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n",
-                  __func__, offset, value, size);
-}
-
-static const MemoryRegionOps aspeed_soc_io_ops = {
-    .read = aspeed_soc_io_read,
-    .write = aspeed_soc_io_write,
-    .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
 static void aspeed_soc_init(Object *obj)
 {
     AspeedSoCState *s = ASPEED_SOC(obj);
@@ -199,10 +175,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     Error *err = NULL, *local_err = NULL;
 
     /* IO space */
-    memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL,
-            "aspeed_soc.io", ASPEED_SOC_IOMEM_SIZE);
-    memory_region_add_subregion_overlap(get_system_memory(),
-                                        ASPEED_SOC_IOMEM_BASE, &s->iomem, -1);
+    create_unimplemented_device("aspeed_soc.io",
+                                ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE);
 
     /* CPU */
     object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);