qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
@ 2016-05-19  3:43 xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 1/4] hw/char: QOM'ify escc.c xiaoqiang zhao
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-19  3:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, peter.maydell, agraf, michael, edgar.iglesias

This patch set trys to QOM'ify hw/char files, see commit messages 
for more details

Thanks Paolo <pbonzini@redhat.com> for your suggestions.

Note:
* CRIS axis_dev88 broad related test is passed and looks ok.
* lm32 test is needed.

Changes in v4:
* add wrapper functions to create char device
* drop the sysbus_create_simple function and
  use the new qdev_create stuff

Changes in v3: 
* use chardev property instead of qemu_char_get_next_serial
* call the functions that touch globals in the realize callback

Changes in v2: 
* rename TYPE_SCLP_LM_CONSOLE to TYPE_SCLPLM_CONSOLE which is suggested by  
  Cornelia Huck <cornelia.huck@de.ibm.com>
* rebase on the current master

xiaoqiang zhao (4):
  hw/char: QOM'ify escc.c
  hw/char: QOM'ify etraxfs_ser.c
  hw/char: QOM'ify lm32_juart.c
  hw/char: QOM'ify lm32_uart.c

 hw/char/escc.c            | 30 +++++++++++++++++++-----------
 hw/char/etraxfs_ser.c     | 27 +++++++++++++++++----------
 hw/char/lm32_juart.c      | 17 ++++++++---------
 hw/char/lm32_uart.c       | 28 +++++++++++++++++-----------
 hw/cris/axis_dev88.c      |  4 ++--
 hw/lm32/lm32.h            | 20 ++++++++++++++++++++
 hw/lm32/lm32_boards.c     |  4 ++--
 include/hw/cris/etraxfs.h | 16 ++++++++++++++++
 8 files changed, 101 insertions(+), 45 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v4 1/4] hw/char: QOM'ify escc.c
  2016-05-19  3:43 [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices xiaoqiang zhao
@ 2016-05-19  3:43 ` xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 2/4] hw/char: QOM'ify etraxfs_ser.c xiaoqiang zhao
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-19  3:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, peter.maydell, agraf, michael, edgar.iglesias

* Drop the old SysBus init function and use instance_init
* Call qemu_chr_add_handlers in the realize callback

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/char/escc.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 7bf09a0..8e6a7df 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -983,9 +983,10 @@ void slavio_serial_ms_kbd_init(hwaddr base, qemu_irq irq,
     sysbus_mmio_map(s, 0, base);
 }
 
-static int escc_init1(SysBusDevice *dev)
+static void escc_init1(Object *obj)
 {
-    ESCCState *s = ESCC(dev);
+    ESCCState *s = ESCC(obj);
+    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
     unsigned int i;
 
     s->chn[0].disabled = s->disabled;
@@ -994,17 +995,26 @@ static int escc_init1(SysBusDevice *dev)
         sysbus_init_irq(dev, &s->chn[i].irq);
         s->chn[i].chn = 1 - i;
         s->chn[i].clock = s->frequency / 2;
-        if (s->chn[i].chr) {
-            qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
-                                  serial_receive1, serial_event, &s->chn[i]);
-        }
     }
     s->chn[0].otherchn = &s->chn[1];
     s->chn[1].otherchn = &s->chn[0];
 
-    memory_region_init_io(&s->mmio, OBJECT(s), &escc_mem_ops, s, "escc",
+    memory_region_init_io(&s->mmio, obj, &escc_mem_ops, s, "escc",
                           ESCC_SIZE << s->it_shift);
     sysbus_init_mmio(dev, &s->mmio);
+}
+
+static void escc_realize(DeviceState *dev, Error **errp)
+{
+    ESCCState *s = ESCC(dev);
+    unsigned int i;
+
+    for (i = 0; i < 2; i++) {
+        if (s->chn[i].chr) {
+            qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
+                                  serial_receive1, serial_event, &s->chn[i]);
+        }
+    }
 
     if (s->chn[0].type == mouse) {
         qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0], 0,
@@ -1014,8 +1024,6 @@ static int escc_init1(SysBusDevice *dev)
         s->chn[1].hs = qemu_input_handler_register((DeviceState *)(&s->chn[1]),
                                                    &sunkbd_handler);
     }
-
-    return 0;
 }
 
 static Property escc_properties[] = {
@@ -1032,10 +1040,9 @@ static Property escc_properties[] = {
 static void escc_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = escc_init1;
     dc->reset = escc_reset;
+    dc->realize = escc_realize;
     dc->vmsd = &vmstate_escc;
     dc->props = escc_properties;
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
@@ -1045,6 +1052,7 @@ static const TypeInfo escc_info = {
     .name          = TYPE_ESCC,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(ESCCState),
+    .instance_init = escc_init1,
     .class_init    = escc_class_init,
 };
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v4 2/4] hw/char: QOM'ify etraxfs_ser.c
  2016-05-19  3:43 [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 1/4] hw/char: QOM'ify escc.c xiaoqiang zhao
@ 2016-05-19  3:43 ` xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 3/4] hw/char: QOM'ify lm32_juart.c xiaoqiang zhao
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-19  3:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, peter.maydell, agraf, michael, edgar.iglesias

* Drop the old SysBus init function and use instance_init
* Call qemu_chr_add_handlers in the realize callback
* Use qdev chardev prop instead of qemu_char_get_next_serial
* Add etraxfs_ser_create function to create etraxfs serial device

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/char/etraxfs_ser.c     | 27 +++++++++++++++++----------
 hw/cris/axis_dev88.c      |  4 ++--
 include/hw/cris/etraxfs.h | 16 ++++++++++++++++
 3 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c
index 146b387..04ca04f 100644
--- a/hw/char/etraxfs_ser.c
+++ b/hw/char/etraxfs_ser.c
@@ -159,6 +159,11 @@ static const MemoryRegionOps ser_ops = {
     }
 };
 
+static Property etraxfs_ser_properties[] = {
+    DEFINE_PROP_CHR("chardev", ETRAXSerial, chr),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void serial_receive(void *opaque, const uint8_t *buf, int size)
 {
     ETRAXSerial *s = opaque;
@@ -209,40 +214,42 @@ static void etraxfs_ser_reset(DeviceState *d)
 
 }
 
-static int etraxfs_ser_init(SysBusDevice *dev)
+static void etraxfs_ser_init(Object *obj)
 {
-    ETRAXSerial *s = ETRAX_SERIAL(dev);
+    ETRAXSerial *s = ETRAX_SERIAL(obj);
+    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
     sysbus_init_irq(dev, &s->irq);
-    memory_region_init_io(&s->mmio, OBJECT(s), &ser_ops, s,
+    memory_region_init_io(&s->mmio, obj, &ser_ops, s,
                           "etraxfs-serial", R_MAX * 4);
     sysbus_init_mmio(dev, &s->mmio);
+}
+
+static void etraxfs_ser_realize(DeviceState *dev, Error **errp)
+{
+    ETRAXSerial *s = ETRAX_SERIAL(dev);
 
-    /* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */
-    s->chr = qemu_char_get_next_serial();
     if (s->chr) {
         qemu_chr_add_handlers(s->chr,
                               serial_can_receive, serial_receive,
                               serial_event, s);
     }
-    return 0;
 }
 
 static void etraxfs_ser_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = etraxfs_ser_init;
     dc->reset = etraxfs_ser_reset;
-    /* Reason: init() method uses qemu_char_get_next_serial() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->props = etraxfs_ser_properties;
+    dc->realize = etraxfs_ser_realize;
 }
 
 static const TypeInfo etraxfs_ser_info = {
     .name          = TYPE_ETRAX_FS_SERIAL,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(ETRAXSerial),
+    .instance_init = etraxfs_ser_init,
     .class_init    = etraxfs_ser_class_init,
 };
 
diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c
index 9f58658..9f60a13 100644
--- a/hw/cris/axis_dev88.c
+++ b/hw/cris/axis_dev88.c
@@ -37,6 +37,7 @@
 #include "sysemu/block-backend.h"
 #include "exec/address-spaces.h"
 #include "sysemu/qtest.h"
+#include "sysemu/char.h"
 
 #define D(x)
 #define DNAND(x)
@@ -341,8 +342,7 @@ void axisdev88_init(MachineState *machine)
     sysbus_create_varargs("etraxfs,timer", 0x3005e000, irq[0x1b], nmi[1], NULL);
 
     for (i = 0; i < 4; i++) {
-        sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
-                             irq[0x14 + i]);
+        etraxfs_ser_create(0x3002600 + i * 0x2000, irq[0x14 + i], qemu_char_get_next_serial());
     }
 
     if (kernel_filename) {
diff --git a/include/hw/cris/etraxfs.h b/include/hw/cris/etraxfs.h
index 73a6134..fce57e5 100644
--- a/include/hw/cris/etraxfs.h
+++ b/include/hw/cris/etraxfs.h
@@ -46,4 +46,20 @@ etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr,
     return dev;
 }
 
+static inline DeviceState *etraxfs_ser_create(hwaddr addr,
+                                              qemu_irq irq,
+                                              CharDriverState *chr)
+{
+    DeviceState *dev;
+    SysBusDevice *s;
+
+    dev = qdev_create(NULL, "extrafs,serial");
+    s = SYS_BUS_DEVICE(dev);
+    qdev_prop_set_chr(dev, "chardev", chr);
+    qdev_init_nofail(dev);
+    sysbus_mmio_map(s, 0, addr);
+    sysbus_connect_irq(s, 0, irq);
+    return dev;
+}
+
 #endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v4 3/4] hw/char: QOM'ify lm32_juart.c
  2016-05-19  3:43 [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 1/4] hw/char: QOM'ify escc.c xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 2/4] hw/char: QOM'ify etraxfs_ser.c xiaoqiang zhao
@ 2016-05-19  3:43 ` xiaoqiang zhao
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 4/4] hw/char: QOM'ify lm32_uart.c xiaoqiang zhao
  2016-05-19 11:32 ` [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices Paolo Bonzini
  4 siblings, 0 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-19  3:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, peter.maydell, agraf, michael, edgar.iglesias

* Drop the old SysBus init function
* Call qemu_chr_add_handlers in the realize callback
* Use qdev chardev prop instead of qemu_char_get_next_serial

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/char/lm32_juart.c | 17 ++++++++---------
 hw/lm32/lm32.h       |  4 ++++
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c
index 5bf8acf..28c2cf7 100644
--- a/hw/char/lm32_juart.c
+++ b/hw/char/lm32_juart.c
@@ -114,17 +114,13 @@ static void juart_reset(DeviceState *d)
     s->jrx = 0;
 }
 
-static int lm32_juart_init(SysBusDevice *dev)
+static void lm32_juart_realize(DeviceState *dev, Error **errp)
 {
     LM32JuartState *s = LM32_JUART(dev);
 
-    /* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */
-    s->chr = qemu_char_get_next_serial();
     if (s->chr) {
         qemu_chr_add_handlers(s->chr, juart_can_rx, juart_rx, juart_event, s);
     }
-
-    return 0;
 }
 
 static const VMStateDescription vmstate_lm32_juart = {
@@ -138,16 +134,19 @@ static const VMStateDescription vmstate_lm32_juart = {
     }
 };
 
+static Property lm32_juart_properties[] = {
+    DEFINE_PROP_CHR("chardev", LM32JuartState, chr),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void lm32_juart_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = lm32_juart_init;
     dc->reset = juart_reset;
     dc->vmsd = &vmstate_lm32_juart;
-    /* Reason: init() method uses qemu_char_get_next_serial() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->props = lm32_juart_properties;
+    dc->realize = lm32_juart_realize;
 }
 
 static const TypeInfo lm32_juart_info = {
diff --git a/hw/lm32/lm32.h b/hw/lm32/lm32.h
index 18aa6fd..3b33ed4 100644
--- a/hw/lm32/lm32.h
+++ b/hw/lm32/lm32.h
@@ -2,6 +2,7 @@
 #define HW_LM32_H 1
 
 #include "hw/char/lm32_juart.h"
+#include "sysemu/char.h"
 
 static inline DeviceState *lm32_pic_init(qemu_irq cpu_irq)
 {
@@ -19,8 +20,11 @@ static inline DeviceState *lm32_pic_init(qemu_irq cpu_irq)
 static inline DeviceState *lm32_juart_init(void)
 {
     DeviceState *dev;
+    CharDriverState *chr;
 
+    chr = qemu_char_get_next_serial();
     dev = qdev_create(NULL, TYPE_LM32_JUART);
+    qdev_prop_set_chr(dev, "chardev", chr);
     qdev_init_nofail(dev);
 
     return dev;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v4 4/4] hw/char: QOM'ify lm32_uart.c
  2016-05-19  3:43 [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices xiaoqiang zhao
                   ` (2 preceding siblings ...)
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 3/4] hw/char: QOM'ify lm32_juart.c xiaoqiang zhao
@ 2016-05-19  3:43 ` xiaoqiang zhao
  2016-05-19 11:32 ` [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices Paolo Bonzini
  4 siblings, 0 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-19  3:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, peter.maydell, agraf, michael, edgar.iglesias

* Drop the old SysBus init function and use instance_init
* Call qemu_chr_add_handlers in the realize callback
* Use qdev chardev prop instead of qemu_char_get_next_serial
* Add lm32_uart_create function to create lm32 uart device

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/char/lm32_uart.c   | 28 +++++++++++++++++-----------
 hw/lm32/lm32.h        | 16 ++++++++++++++++
 hw/lm32/lm32_boards.c |  4 ++--
 3 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/hw/char/lm32_uart.c b/hw/char/lm32_uart.c
index 036813d..b5c760d 100644
--- a/hw/char/lm32_uart.c
+++ b/hw/char/lm32_uart.c
@@ -249,23 +249,25 @@ static void uart_reset(DeviceState *d)
     s->regs[R_LSR] = LSR_THRE | LSR_TEMT;
 }
 
-static int lm32_uart_init(SysBusDevice *dev)
+static void lm32_uart_init(Object *obj)
 {
-    LM32UartState *s = LM32_UART(dev);
+    LM32UartState *s = LM32_UART(obj);
+    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
     sysbus_init_irq(dev, &s->irq);
 
-    memory_region_init_io(&s->iomem, OBJECT(s), &uart_ops, s,
+    memory_region_init_io(&s->iomem, obj, &uart_ops, s,
                           "uart", R_MAX * 4);
     sysbus_init_mmio(dev, &s->iomem);
+}
+
+static void lm32_uart_realize(DeviceState *dev, Error **errp)
+{
+    LM32UartState *s = LM32_UART(dev);
 
-    /* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */
-    s->chr = qemu_char_get_next_serial();
     if (s->chr) {
         qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
     }
-
-    return 0;
 }
 
 static const VMStateDescription vmstate_lm32_uart = {
@@ -278,22 +280,26 @@ static const VMStateDescription vmstate_lm32_uart = {
     }
 };
 
+static Property lm32_uart_properties[] = {
+    DEFINE_PROP_CHR("chardev", LM32UartState, chr),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void lm32_uart_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = lm32_uart_init;
     dc->reset = uart_reset;
     dc->vmsd = &vmstate_lm32_uart;
-    /* Reason: init() method uses qemu_char_get_next_serial() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->props = lm32_uart_properties;
+    dc->realize = lm32_uart_realize;
 }
 
 static const TypeInfo lm32_uart_info = {
     .name          = TYPE_LM32_UART,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(LM32UartState),
+    .instance_init = lm32_uart_init,
     .class_init    = lm32_uart_class_init,
 };
 
diff --git a/hw/lm32/lm32.h b/hw/lm32/lm32.h
index 3b33ed4..e6a6b2a 100644
--- a/hw/lm32/lm32.h
+++ b/hw/lm32/lm32.h
@@ -30,4 +30,20 @@ static inline DeviceState *lm32_juart_init(void)
     return dev;
 }
 
+static inline DeviceState *lm32_uart_create(hwaddr addr,
+                                            qemu_irq irq,
+                                            CharDriverState *chr)
+{
+    DeviceState *dev;
+    SysBusDevice *s;
+
+    dev = qdev_create(NULL, "lm32-uart");
+    s = SYS_BUS_DEVICE(dev);
+    qdev_prop_set_chr(dev, "chardev", chr);
+    qdev_init_nofail(dev);
+    sysbus_mmio_map(s, 0, addr);
+    sysbus_connect_irq(s, 0, irq);
+    return dev;
+}
+
 #endif
diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c
index c029056..ec3d659 100644
--- a/hw/lm32/lm32_boards.c
+++ b/hw/lm32/lm32_boards.c
@@ -131,7 +131,7 @@ static void lm32_evr_init(MachineState *machine)
         irq[i] = qdev_get_gpio_in(env->pic_state, i);
     }
 
-    sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]);
+    lm32_uart_create(uart0_base, irq[uart0_irq], qemu_char_get_next_serial());
     sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
     sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
 
@@ -232,7 +232,7 @@ static void lm32_uclinux_init(MachineState *machine)
         irq[i] = qdev_get_gpio_in(env->pic_state, i);
     }
 
-    sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]);
+    lm32_uart_create(uart0_base, irq[uart0_irq], qemu_char_get_next_serial());
     sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
     sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
     sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq]);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-19  3:43 [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices xiaoqiang zhao
                   ` (3 preceding siblings ...)
  2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 4/4] hw/char: QOM'ify lm32_uart.c xiaoqiang zhao
@ 2016-05-19 11:32 ` Paolo Bonzini
  2016-05-19 11:51   ` michael
  2016-05-19 13:45   ` michael
  4 siblings, 2 replies; 13+ messages in thread
From: Paolo Bonzini @ 2016-05-19 11:32 UTC (permalink / raw)
  To: xiaoqiang zhao, qemu-devel; +Cc: michael, edgar.iglesias, agraf, peter.maydell



On 19/05/2016 05:43, xiaoqiang zhao wrote:
> This patch set trys to QOM'ify hw/char files, see commit messages 
> for more details
> 
> Thanks Paolo <pbonzini@redhat.com> for your suggestions.
> 
> Note:
> * CRIS axis_dev88 broad related test is passed and looks ok.
> * lm32 test is needed.

Michael, can you test patches 3 and 4?

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-19 11:32 ` [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices Paolo Bonzini
@ 2016-05-19 11:51   ` michael
  2016-05-19 13:45   ` michael
  1 sibling, 0 replies; 13+ messages in thread
From: michael @ 2016-05-19 11:51 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: xiaoqiang zhao, qemu-devel, edgar.iglesias, agraf, peter.maydell,
	Paolo Bonzini

Am 2016-05-19 13:32, schrieb Paolo Bonzini:
> On 19/05/2016 05:43, xiaoqiang zhao wrote:
>> This patch set trys to QOM'ify hw/char files, see commit messages
>> for more details
>> 
>> Thanks Paolo <pbonzini@redhat.com> for your suggestions.
>> 
>> Note:
>> * CRIS axis_dev88 broad related test is passed and looks ok.
>> * lm32 test is needed.
> 
> Michael, can you test patches 3 and 4?

Yes, already on my todo list.

-michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-19 11:32 ` [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices Paolo Bonzini
  2016-05-19 11:51   ` michael
@ 2016-05-19 13:45   ` michael
  2016-05-20  2:41     ` xiaoqiang zhao
  1 sibling, 1 reply; 13+ messages in thread
From: michael @ 2016-05-19 13:45 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: xiaoqiang zhao, qemu-devel, edgar.iglesias, agraf, peter.maydell,
	Paolo Bonzini

Am 2016-05-19 13:32, schrieb Paolo Bonzini:
> Michael, can you test patches 3 and 4?

Doesn't work for me:
   $ qemu-system-lm32 -kernel serial.bin -serial vc -serial vc
Unexpected error in parse_chr() at 
/home/mwalle/repos/qemu/hw/core/qdev-properties-system.c:149:
qemu-system-lm32: Property 'lm32-uart.chardev' can't take value 
'serial0', it's in use

serial0 seems already be claimed. Please note that even
   $ qemu-system-lm32 -kernel serial.bin
and
   $ qemu-system-lm32
does not work.

"-serial .. -serial --" should still work, shouldn't it?

I've uploaded a small test binary to http://milkymist.walle.cc/tests/ 
which should prints 'A' and 'U' characters on the UARTs.

-michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-19 13:45   ` michael
@ 2016-05-20  2:41     ` xiaoqiang zhao
  2016-05-20 11:08       ` Paolo Bonzini
  2016-05-20 14:52       ` Markus Armbruster
  0 siblings, 2 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-20  2:41 UTC (permalink / raw)
  To: michael, Paolo Bonzini
  Cc: qemu-devel, edgar.iglesias, agraf, peter.maydell, Paolo Bonzini



在 2016年05月19日 21:45, michael@walle.cc 写道:
> Am 2016-05-19 13:32, schrieb Paolo Bonzini:
>> Michael, can you test patches 3 and 4?
>
> Doesn't work for me:
>   $ qemu-system-lm32 -kernel serial.bin -serial vc -serial vc
> Unexpected error in parse_chr() at 
> /home/mwalle/repos/qemu/hw/core/qdev-properties-system.c:149:
> qemu-system-lm32: Property 'lm32-uart.chardev' can't take value 
> 'serial0', it's in use
>
> serial0 seems already be claimed. Please note that even
>   $ qemu-system-lm32 -kernel serial.bin
> and
>   $ qemu-system-lm32
> does not work.
>
> "-serial .. -serial --" should still work, shouldn't it?
>
> I've uploaded a small test binary to http://milkymist.walle.cc/tests/ 
> which should prints 'A' and 'U' characters on the UARTs.
>
> -michael

Hi, michael:

It seems that qemu_char_get_next_serial()  call the qemu_chr_fe_claim, 
which is also called by
qdev_prop_set_chr ! This cause chr->avail_connectinos less than 1. as 
the error message said:
"it's in use".
A stright fix is to call the qemu_chr_fe_release after 
qemu_char_get_next_serial and the call the
qdev_prop_set_chr, the error is gone! I have test with your test cases 
and it works.

Or another way, can we modify qemu_char_get_next_serial and just skip 
the call of qemu_chr_fe_claim?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-20  2:41     ` xiaoqiang zhao
@ 2016-05-20 11:08       ` Paolo Bonzini
  2016-05-20 12:27         ` xiaoqiang zhao
  2016-05-20 14:52       ` Markus Armbruster
  1 sibling, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2016-05-20 11:08 UTC (permalink / raw)
  To: xiaoqiang zhao, michael
  Cc: qemu-devel, edgar.iglesias, agraf, peter.maydell, Paolo Bonzini



On 20/05/2016 04:41, xiaoqiang zhao wrote:
> 
> It seems that qemu_char_get_next_serial()  call the qemu_chr_fe_claim,
> which is also called by
> qdev_prop_set_chr ! This cause chr->avail_connectinos less than 1. as
> the error message said:
> "it's in use".
> A stright fix is to call the qemu_chr_fe_release after
> qemu_char_get_next_serial and the call the
> qdev_prop_set_chr, the error is gone! I have test with your test cases
> and it works.
> 
> Or another way, can we modify qemu_char_get_next_serial and just skip
> the call of qemu_chr_fe_claim?

You can replace calls to qemu_char_get_next_serial() with direct access
to serial_hds[0], serial_hds[1], etc.  Please do this for etrax_ser too.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-20 11:08       ` Paolo Bonzini
@ 2016-05-20 12:27         ` xiaoqiang zhao
  0 siblings, 0 replies; 13+ messages in thread
From: xiaoqiang zhao @ 2016-05-20 12:27 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: michael, peter.maydell, edgar.iglesias, Paolo Bonzini, qemu-devel,
	agraf



> 在 2016年5月20日,19:08,Paolo Bonzini <pbonzini@redhat.com> 写道:
> 
> 
> 
>> On 20/05/2016 04:41, xiaoqiang zhao wrote:
>> 
>> It seems that qemu_char_get_next_serial()  call the qemu_chr_fe_claim,
>> which is also called by
>> qdev_prop_set_chr ! This cause chr->avail_connectinos less than 1. as
>> the error message said:
>> "it's in use".
>> A stright fix is to call the qemu_chr_fe_release after
>> qemu_char_get_next_serial and the call the
>> qdev_prop_set_chr, the error is gone! I have test with your test cases
>> and it works.
>> 
>> Or another way, can we modify qemu_char_get_next_serial and just skip
>> the call of qemu_chr_fe_claim?
> 
> You can replace calls to qemu_char_get_next_serial() with direct access
> to serial_hds[0], serial_hds[1], etc.  Please do this for etrax_ser too.
> 
> Paolo
> 

OK,fix in the next version!

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-20  2:41     ` xiaoqiang zhao
  2016-05-20 11:08       ` Paolo Bonzini
@ 2016-05-20 14:52       ` Markus Armbruster
  2016-05-20 15:01         ` Paolo Bonzini
  1 sibling, 1 reply; 13+ messages in thread
From: Markus Armbruster @ 2016-05-20 14:52 UTC (permalink / raw)
  To: xiaoqiang zhao
  Cc: michael, Paolo Bonzini, peter.maydell, edgar.iglesias,
	Paolo Bonzini, qemu-devel, agraf

xiaoqiang zhao <zxq_yx_007@163.com> writes:

> 在 2016年05月19日 21:45, michael@walle.cc 写道:
>> Am 2016-05-19 13:32, schrieb Paolo Bonzini:
>>> Michael, can you test patches 3 and 4?
>>
>> Doesn't work for me:
>>   $ qemu-system-lm32 -kernel serial.bin -serial vc -serial vc
>> Unexpected error in parse_chr() at
>> /home/mwalle/repos/qemu/hw/core/qdev-properties-system.c:149:
>> qemu-system-lm32: Property 'lm32-uart.chardev' can't take value
>> 'serial0', it's in use
>>
>> serial0 seems already be claimed. Please note that even
>>   $ qemu-system-lm32 -kernel serial.bin
>> and
>>   $ qemu-system-lm32
>> does not work.
>>
>> "-serial .. -serial --" should still work, shouldn't it?
>>
>> I've uploaded a small test binary to
>> http://milkymist.walle.cc/tests/ which should prints 'A' and 'U'
>> characters on the UARTs.
>>
>> -michael
>
> Hi, michael:
>
> It seems that qemu_char_get_next_serial()  call the qemu_chr_fe_claim,
> which is also called by
> qdev_prop_set_chr ! This cause chr->avail_connectinos less than 1. as
> the error message said:
> "it's in use".
> A stright fix is to call the qemu_chr_fe_release after
> qemu_char_get_next_serial and the call the
> qdev_prop_set_chr, the error is gone! I have test with your test cases
> and it works.
>
> Or another way, can we modify qemu_char_get_next_serial and just skip
> the call of qemu_chr_fe_claim?

Uh, how come qemu_char_get_next_serial() gets called?
QOMified/qdevified devices should never call it.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices
  2016-05-20 14:52       ` Markus Armbruster
@ 2016-05-20 15:01         ` Paolo Bonzini
  0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2016-05-20 15:01 UTC (permalink / raw)
  To: Markus Armbruster, xiaoqiang zhao
  Cc: michael, peter.maydell, edgar.iglesias, Paolo Bonzini, qemu-devel,
	agraf



On 20/05/2016 16:52, Markus Armbruster wrote:
> xiaoqiang zhao <zxq_yx_007@163.com> writes:
> 
>> 在 2016年05月19日 21:45, michael@walle.cc 写道:
>>> Am 2016-05-19 13:32, schrieb Paolo Bonzini:
>>>> Michael, can you test patches 3 and 4?
>>>
>>> Doesn't work for me:
>>>   $ qemu-system-lm32 -kernel serial.bin -serial vc -serial vc
>>> Unexpected error in parse_chr() at
>>> /home/mwalle/repos/qemu/hw/core/qdev-properties-system.c:149:
>>> qemu-system-lm32: Property 'lm32-uart.chardev' can't take value
>>> 'serial0', it's in use
>>>
>>> serial0 seems already be claimed. Please note that even
>>>   $ qemu-system-lm32 -kernel serial.bin
>>> and
>>>   $ qemu-system-lm32
>>> does not work.
>>>
>>> "-serial .. -serial --" should still work, shouldn't it?
>>>
>>> I've uploaded a small test binary to
>>> http://milkymist.walle.cc/tests/ which should prints 'A' and 'U'
>>> characters on the UARTs.
>>
>> It seems that qemu_char_get_next_serial()  call the qemu_chr_fe_claim,
>> which is also called by
>> qdev_prop_set_chr ! This cause chr->avail_connectinos less than 1. as
>> the error message said:
>> "it's in use".
>> A stright fix is to call the qemu_chr_fe_release after
>> qemu_char_get_next_serial and the call the
>> qdev_prop_set_chr, the error is gone! I have test with your test cases
>> and it works.
>>
>> Or another way, can we modify qemu_char_get_next_serial and just skip
>> the call of qemu_chr_fe_claim?
> 
> Uh, how come qemu_char_get_next_serial() gets called?
> QOMified/qdevified devices should never call it.

It's called by the board.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-05-20 15:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-19  3:43 [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices xiaoqiang zhao
2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 1/4] hw/char: QOM'ify escc.c xiaoqiang zhao
2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 2/4] hw/char: QOM'ify etraxfs_ser.c xiaoqiang zhao
2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 3/4] hw/char: QOM'ify lm32_juart.c xiaoqiang zhao
2016-05-19  3:43 ` [Qemu-devel] [PATCH v4 4/4] hw/char: QOM'ify lm32_uart.c xiaoqiang zhao
2016-05-19 11:32 ` [Qemu-devel] [PATCH v4 0/4] QOM'ify hw/char devices Paolo Bonzini
2016-05-19 11:51   ` michael
2016-05-19 13:45   ` michael
2016-05-20  2:41     ` xiaoqiang zhao
2016-05-20 11:08       ` Paolo Bonzini
2016-05-20 12:27         ` xiaoqiang zhao
2016-05-20 14:52       ` Markus Armbruster
2016-05-20 15:01         ` Paolo Bonzini

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).