Skip to contentSkip to conversation

milkymist-uart fixes

PATCH Applied Antony Pavlov 4 participants 10 messages Aug 31, 2013 – Sep 17, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover milkymist-uart fixes

This patch series based on DIGIC support adding comments:
http://lists.nongnu.org/archive/html/qemu-devel/2013-08/msg04748.html

[PATCH v2 1/2] milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write() [PATCH v2 2/2] milkymist-uart: use Device::realize instead of SysBusDevice::init

Changes since v1:
* remove xml-styled quotes from patch comments;
* introduce TypeInfo::instance_init milkymist_uart_init().

#1 lore raw

PATCH v2 1/2 milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()

qemu_chr_fe_write() is capable of returning 0
to indicate EAGAIN (and friends) and we don't
handle this.

Just change it to qemu_chr_fe_write_all() to fix.

CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/milkymist-uart.c +1 -1
index 2e4b5c5..6e4bc20 100644
@@ -124,7 +124,7 @@ static void uart_write(void *opaque, hwaddr addr, uint64_t value,
     switch (addr) {
     case R_RXTX:
         if (s->chr) {
-            qemu_chr_fe_write(s->chr, &ch, 1);
+            qemu_chr_fe_write_all(s->chr, &ch, 1);
         }
         s->regs[R_STAT] |= STAT_TX_EVT;
         break;
Signature · 1 line
1.8.4.rc3
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()

Quoted 7 lines · Antony Pavlov

qemu_chr_fe_write() is capable of returning 0 to indicate EAGAIN (and friends) and we don't handle this.

Just change it to qemu_chr_fe_write_all() to fix.

Acked-by Peter Crosthwaite <[email protected]>

Quoted 25 lines
CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/milkymist-uart.c +1 -2
index 2e4b5c5..6e4bc20 100644
@@ -124,7 +124,7 @@ static void uart_write(void *opaque, hwaddr addr, uint64_t value,
     switch (addr) {
     case R_RXTX:
         if (s->chr) {
-            qemu_chr_fe_write(s->chr, &ch, 1);
+            qemu_chr_fe_write_all(s->chr, &ch, 1);
         }
         s->regs[R_STAT] |= STAT_TX_EVT;
         break;
--

1.8.4.rc3

#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()

Am Montag, 2. September 2013, 00:58:42 schrieb Peter Crosthwaite:

Quoted 1 line

On Sun, Sep 1, 2013 at 3:22 AM, Antony Pavlov <[email protected]>

Quoted 34 lines · wrote:
Quoted 7 lines

qemu_chr_fe_write() is capable of returning 0 to indicate EAGAIN (and friends) and we don't handle this.

Just change it to qemu_chr_fe_write_all() to fix.

Acked-by Peter Crosthwaite <[email protected]>

Quoted 24 lines
CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>

---

 hw/char/milkymist-uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/milkymist-uart.c +1 -1
index 2e4b5c5..6e4bc20 100644
@@ -124,7 +124,7 @@ static void uart_write(void *opaque, hwaddr addr,
 uint64_t value,
 
     switch (addr) {
 
     case R_RXTX:
         if (s->chr) {
 
-            qemu_chr_fe_write(s->chr, &ch, 1);
+            qemu_chr_fe_write_all(s->chr, &ch, 1);
Quoted 6 lines
Quoted 6 lines
         }
         s->regs[R_STAT] |= STAT_TX_EVT;
         break;

--
1.8.4.rc3

I'll pick this one. Thank you.

Signature · 1 line
michael
Acked-by on v2 1/2
#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()

In reply to Antony Pavlov

Am Samstag, 31. August 2013, 19:22:39 schrieb Antony Pavlov:

Quoted 20 lines

qemu_chr_fe_write() is capable of returning 0
to indicate EAGAIN (and friends) and we don't
handle this.

Just change it to qemu_chr_fe_write_all() to fix.

CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/milkymist-uart.c +0 -0
index 2e4b5c5..6e4bc20 100644

hw/char/milkymist-uart.c static void uart_write(void *opaque, hwaddr addr, · line 130

Quoted 8 lines
hw/char/milkymist-uart.c +1 -1
@@ -124,7 +124,7 @@ static void uart_write(void *opaque, hwaddr addr,
 uint64_t value, switch (addr) {
     case R_RXTX:
         if (s->chr) {
-            qemu_chr_fe_write(s->chr, &ch, 1);
+            qemu_chr_fe_write_all(s->chr, &ch, 1);
         }
         s->regs[R_STAT] |= STAT_TX_EVT;
         break;
Signature · 1 line
Michael
#5 lore raw

PATCH v2 2/2 milkymist-uart: use Device::realize instead of SysBusDevice::init

In reply to Antony Pavlov

Use of SysBusDevice::init is deprecated. Use Device::realize instead of SysBusDevice::init. Check dma/pl330.c for an example of the pattern.

Also introduce TypeInfo::instance_init milkymist_uart_init() as char/pl011.c does.

CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
hw/char/milkymist-uart.c +14 -10
index 6e4bc20..da51f82 100644
@@ -195,22 +195,26 @@ static void milkymist_uart_reset(DeviceState *d)
     s->regs[R_STAT] = STAT_THRE;
 }
 
-static int milkymist_uart_init(SysBusDevice *dev)
+static void milkymist_uart_realize(DeviceState *dev, Error **errp)
 {
     MilkymistUartState *s = MILKYMIST_UART(dev);
 
-    sysbus_init_irq(dev, &s->irq);
-
-    memory_region_init_io(&s->regs_region, OBJECT(s), &uart_mmio_ops, s,
-                          "milkymist-uart", R_MAX * 4);
-    sysbus_init_mmio(dev, &s->regs_region);
-
     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 void milkymist_uart_init(Object *obj)
+{
+    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+    MilkymistUartState *s = MILKYMIST_UART(obj);
+
+    sysbus_init_irq(sbd, &s->irq);
+
+    memory_region_init_io(&s->regs_region, OBJECT(s), &uart_mmio_ops, s,
+                          "milkymist-uart", R_MAX * 4);
+    sysbus_init_mmio(sbd, &s->regs_region);
 }
 
 static const VMStateDescription vmstate_milkymist_uart = {
@@ -227,9 +231,8 @@ static const VMStateDescription vmstate_milkymist_uart = {
 static void milkymist_uart_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = milkymist_uart_init;
+    dc->realize = milkymist_uart_realize;
     dc->reset = milkymist_uart_reset;
     dc->vmsd = &vmstate_milkymist_uart;
 }
@@ -238,6 +241,7 @@ static const TypeInfo milkymist_uart_info = {
     .name          = TYPE_MILKYMIST_UART,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(MilkymistUartState),
+    .instance_init = milkymist_uart_init,
     .class_init    = milkymist_uart_class_init,
 };
 
Signature · 1 line
1.8.4.rc3
#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] milkymist-uart: use Device::realize instead of SysBusDevice::init

Am 31.08.2013 19:22, schrieb Antony Pavlov:

Quoted 7 lines

Use of SysBusDevice::init is deprecated. Use Device::realize instead of SysBusDevice::init. Check dma/pl330.c for an example of the pattern.

Also introduce TypeInfo::instance_init milkymist_uart_init() as char/pl011.c does.

Quoted 8 lines
CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

Thanks, applied to qom-next (with shortened commit message):
https://github.com/afaerber/qemu-cpu/commits/qom-next

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] milkymist-uart: use Device::realize instead of SysBusDevice::init

Quoted 17 lines · On Sat, 31 Aug 2013 21:09:20 +0200 Andreas Färber <[email protected]> wrote:

Am 31.08.2013 19:22, schrieb Antony Pavlov:

Quoted 7 lines

Use of SysBusDevice::init is deprecated. Use Device::realize instead of SysBusDevice::init. Check dma/pl330.c for an example of the pattern.

Also introduce TypeInfo::instance_init milkymist_uart_init() as char/pl011.c does.

Quoted 8 lines
CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
Quoted 3 lines

Thanks, applied to qom-next (with shortened commit message):
https://github.com/afaerber/qemu-cpu/commits/qom-next

That's about the patch number 1 ( milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()) ?

--
Best regards,
  Antony Pavlov

#8 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] milkymist-uart: use Device::realize instead of SysBusDevice::init

Am 01.09.2013 20:28, schrieb Antony Pavlov:

Quoted 20 lines
Quoted 17 lines · On Sat, 31 Aug 2013 21:09:20 +0200 Andreas Färber <[email protected]> wrote:

Am 31.08.2013 19:22, schrieb Antony Pavlov:

Quoted 15 lines

Use of SysBusDevice::init is deprecated. Use Device::realize instead of SysBusDevice::init. Check dma/pl330.c for an example of the pattern.

Also introduce TypeInfo::instance_init milkymist_uart_init() as char/pl011.c does.

CC Peter Crosthwaite <[email protected]>
CC Michael Walle <[email protected]>
CC Andreas Färber <[email protected]>
---
 hw/char/milkymist-uart.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
Quoted 5 lines
Quoted 3 lines

Thanks, applied to qom-next (with shortened commit message):
https://github.com/afaerber/qemu-cpu/commits/qom-next

That's about the patch number 1 ( milkymist-uart: use qemu_chr_fe_write_all() instead of qemu_chr_fe_write()) ?

No, it's about patch 2, which I replied to. Patch 1 is not a QOM conversion but an unrelated bug fix - it can be handled either by the lm32 maintainer or by whomever takes care of the char layer these days (Anthony/Gerd).

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#9 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] milkymist-uart: use Device::realize instead of SysBusDevice::init

In reply to Antony Pavlov
Quoted 4 lines · Antony Pavlov

Use of SysBusDevice::init is deprecated. Use Device::realize instead of SysBusDevice::init. Check dma/pl330.c for an example of the pattern.

I think Andreas may have fixed in enqueue, but informal suggestion of change patterns arent really suitable for commit messages. So drop sentances like this one.

Regards,
Peter