diff mbox

hw/char: QOM'ify escc.c (fix)

Message ID 1464767898-30526-1-git-send-email-zxq_yx_007@163.com
State New
Headers show

Commit Message

zhao xiao qiang June 1, 2016, 7:58 a.m. UTC
The previous commit e7c9136977cb99c6eb52c9139f7b8d8b5fa87db9
(hw/char: QOM'ify escc.c) cause qemu-system-ppc/ppc64
OpenBIOS to freeze on startup, this commit fix it.

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

Comments

Mark Cave-Ayland June 1, 2016, 12:33 p.m. UTC | #1
On 01/06/16 08:58, xiaoqiang zhao wrote:

> The previous commit e7c9136977cb99c6eb52c9139f7b8d8b5fa87db9
> (hw/char: QOM'ify escc.c) cause qemu-system-ppc/ppc64
> OpenBIOS to freeze on startup, this commit fix it.
> 
> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
> ---
>  hw/char/escc.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 8e6a7df..31a5f90 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -989,18 +989,13 @@ static void escc_init1(Object *obj)
>      SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>      unsigned int i;
>  
> -    s->chn[0].disabled = s->disabled;
> -    s->chn[1].disabled = s->disabled;
>      for (i = 0; i < 2; i++) {
>          sysbus_init_irq(dev, &s->chn[i].irq);
>          s->chn[i].chn = 1 - i;
> -        s->chn[i].clock = s->frequency / 2;
>      }
>      s->chn[0].otherchn = &s->chn[1];
>      s->chn[1].otherchn = &s->chn[0];
>  
> -    memory_region_init_io(&s->mmio, obj, &escc_mem_ops, s, "escc",
> -                          ESCC_SIZE << s->it_shift);
>      sysbus_init_mmio(dev, &s->mmio);
>  }
>  
> @@ -1009,8 +1004,15 @@ static void escc_realize(DeviceState *dev, Error **errp)
>      ESCCState *s = ESCC(dev);
>      unsigned int i;
>  
> +    s->chn[0].disabled = s->disabled;
> +    s->chn[1].disabled = s->disabled;
> +
> +    memory_region_init_io(&s->mmio, OBJECT(dev), &escc_mem_ops, s, "escc",
> +                          ESCC_SIZE << s->it_shift);
> +
>      for (i = 0; i < 2; i++) {
>          if (s->chn[i].chr) {
> +            s->chn[i].clock = s->frequency / 2;

Should this not still be in escc_init1() since s->frequency is set by a
property?

>              qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
>                                    serial_receive1, serial_event, &s->chn[i]);
>          }
> 

Otherwise, thanks for the patch - I'll try it this evening on both
qemu-system-ppc and qemu-system-sparc since both of them use ESCC serial
ports and report back.


ATB,

Mark.
zhao xiao qiang June 1, 2016, 12:38 p.m. UTC | #2
在 2016年6月1日,20:33,Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> 写道:

>>     for (i = 0; i < 2; i++) {
>>         if (s->chn[i].chr) {
>> +            s->chn[i].clock = s->frequency / 2;
> 
> Should this not still be in escc_init1() since s->frequency is set by a
> property?

You are right!
Paolo Bonzini June 1, 2016, 1:13 p.m. UTC | #3
On 01/06/2016 14:33, Mark Cave-Ayland wrote:
> > +
> > +    memory_region_init_io(&s->mmio, OBJECT(dev), &escc_mem_ops, s, "escc",
> > +                          ESCC_SIZE << s->it_shift);
> > +
> >      for (i = 0; i < 2; i++) {
> >          if (s->chn[i].chr) {
> > +            s->chn[i].clock = s->frequency / 2;
> 
> Should this not still be in escc_init1() since s->frequency is set by a
> property?

It's the other way round, escc_init1 is for things that do _not_ depend
on property values.  So I think this should be fine.

Thanks,

Paolo
Mark Cave-Ayland June 1, 2016, 7:44 p.m. UTC | #4
On 01/06/16 08:58, xiaoqiang zhao wrote:

> The previous commit e7c9136977cb99c6eb52c9139f7b8d8b5fa87db9
> (hw/char: QOM'ify escc.c) cause qemu-system-ppc/ppc64
> OpenBIOS to freeze on startup, this commit fix it.
> 
> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
> ---
>  hw/char/escc.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/char/escc.c b/hw/char/escc.c
> index 8e6a7df..31a5f90 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -989,18 +989,13 @@ static void escc_init1(Object *obj)
>      SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>      unsigned int i;
>  
> -    s->chn[0].disabled = s->disabled;
> -    s->chn[1].disabled = s->disabled;
>      for (i = 0; i < 2; i++) {
>          sysbus_init_irq(dev, &s->chn[i].irq);
>          s->chn[i].chn = 1 - i;
> -        s->chn[i].clock = s->frequency / 2;
>      }
>      s->chn[0].otherchn = &s->chn[1];
>      s->chn[1].otherchn = &s->chn[0];
>  
> -    memory_region_init_io(&s->mmio, obj, &escc_mem_ops, s, "escc",
> -                          ESCC_SIZE << s->it_shift);
>      sysbus_init_mmio(dev, &s->mmio);
>  }
>  
> @@ -1009,8 +1004,15 @@ static void escc_realize(DeviceState *dev, Error **errp)
>      ESCCState *s = ESCC(dev);
>      unsigned int i;
>  
> +    s->chn[0].disabled = s->disabled;
> +    s->chn[1].disabled = s->disabled;
> +
> +    memory_region_init_io(&s->mmio, OBJECT(dev), &escc_mem_ops, s, "escc",
> +                          ESCC_SIZE << s->it_shift);
> +
>      for (i = 0; i < 2; i++) {
>          if (s->chn[i].chr) {
> +            s->chn[i].clock = s->frequency / 2;
>              qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
>                                    serial_receive1, serial_event, &s->chn[i]);
>          }
> 

Thanks a lot for this patch, I can confirm that it fixes the problem
under qemu-system-ppc for me:

Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
zhao xiao qiang June 1, 2016, 11:20 p.m. UTC | #5
> 在 2016年6月2日,03:44,Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> 写道:
> 
>> On 01/06/16 08:58, xiaoqiang zhao wrote:
>> 
>> The previous commit e7c9136977cb99c6eb52c9139f7b8d8b5fa87db9
>> (hw/char: QOM'ify escc.c) cause qemu-system-ppc/ppc64
>> OpenBIOS to freeze on startup, this commit fix it.
>> 
>> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
>> ---
>> hw/char/escc.c | 12 +++++++-----
>> 1 file changed, 7 insertions(+), 5 deletions(-)
>> 
>> diff --git a/hw/char/escc.c b/hw/char/escc.c
>> index 8e6a7df..31a5f90 100644
>> --- a/hw/char/escc.c
>> +++ b/hw/char/escc.c
>> @@ -989,18 +989,13 @@ static void escc_init1(Object *obj)
>>     SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>>     unsigned int i;
>> 
>> -    s->chn[0].disabled = s->disabled;
>> -    s->chn[1].disabled = s->disabled;
>>     for (i = 0; i < 2; i++) {
>>         sysbus_init_irq(dev, &s->chn[i].irq);
>>         s->chn[i].chn = 1 - i;
>> -        s->chn[i].clock = s->frequency / 2;
>>     }
>>     s->chn[0].otherchn = &s->chn[1];
>>     s->chn[1].otherchn = &s->chn[0];
>> 
>> -    memory_region_init_io(&s->mmio, obj, &escc_mem_ops, s, "escc",
>> -                          ESCC_SIZE << s->it_shift);
>>     sysbus_init_mmio(dev, &s->mmio);
>> }
>> 
>> @@ -1009,8 +1004,15 @@ static void escc_realize(DeviceState *dev, Error **errp)
>>     ESCCState *s = ESCC(dev);
>>     unsigned int i;
>> 
>> +    s->chn[0].disabled = s->disabled;
>> +    s->chn[1].disabled = s->disabled;
>> +
>> +    memory_region_init_io(&s->mmio, OBJECT(dev), &escc_mem_ops, s, "escc",
>> +                          ESCC_SIZE << s->it_shift);
>> +
>>     for (i = 0; i < 2; i++) {
>>         if (s->chn[i].chr) {
>> +            s->chn[i].clock = s->frequency / 2;
>>             qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
>>                                   serial_receive1, serial_event, &s->chn[i]);
>>         }
> 
> Thanks a lot for this patch, I can confirm that it fixes the problem
> under qemu-system-ppc for me:
> 
> Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> 
> 
> ATB,
> 
> Mark.
> 
> 

That's OK :-)
diff mbox

Patch

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 8e6a7df..31a5f90 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -989,18 +989,13 @@  static void escc_init1(Object *obj)
     SysBusDevice *dev = SYS_BUS_DEVICE(obj);
     unsigned int i;
 
-    s->chn[0].disabled = s->disabled;
-    s->chn[1].disabled = s->disabled;
     for (i = 0; i < 2; i++) {
         sysbus_init_irq(dev, &s->chn[i].irq);
         s->chn[i].chn = 1 - i;
-        s->chn[i].clock = s->frequency / 2;
     }
     s->chn[0].otherchn = &s->chn[1];
     s->chn[1].otherchn = &s->chn[0];
 
-    memory_region_init_io(&s->mmio, obj, &escc_mem_ops, s, "escc",
-                          ESCC_SIZE << s->it_shift);
     sysbus_init_mmio(dev, &s->mmio);
 }
 
@@ -1009,8 +1004,15 @@  static void escc_realize(DeviceState *dev, Error **errp)
     ESCCState *s = ESCC(dev);
     unsigned int i;
 
+    s->chn[0].disabled = s->disabled;
+    s->chn[1].disabled = s->disabled;
+
+    memory_region_init_io(&s->mmio, OBJECT(dev), &escc_mem_ops, s, "escc",
+                          ESCC_SIZE << s->it_shift);
+
     for (i = 0; i < 2; i++) {
         if (s->chn[i].chr) {
+            s->chn[i].clock = s->frequency / 2;
             qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
                                   serial_receive1, serial_event, &s->chn[i]);
         }