All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer
@ 2021-04-23 23:36 Philippe Mathieu-Daudé
  2021-04-23 23:36 ` [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset() Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-23 23:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Edgar E. Iglesias, Paolo Bonzini,
	Philippe Mathieu-Daudé,
	Michael S. Tsirkin

Remove qemu_register_reset() when a qdev type has a qbus parent.

Philippe Mathieu-Daudé (2):
  hw/timer/etraxfs_timer: Qdev'ify reset()
  hw/rtc/mc146818rtc: Qdev'ify reset()

 hw/rtc/mc146818rtc.c     | 35 +++++++++++++++--------------------
 hw/timer/etraxfs_timer.c |  6 +++---
 2 files changed, 18 insertions(+), 23 deletions(-)

-- 
2.26.3



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

* [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset()
  2021-04-23 23:36 [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé
@ 2021-04-23 23:36 ` Philippe Mathieu-Daudé
  2021-05-01 16:46   ` Laurent Vivier
  2021-04-23 23:36 ` [PATCH 2/2] hw/rtc/mc146818rtc: " Philippe Mathieu-Daudé
  2021-05-01 10:17 ` [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé
  2 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-23 23:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Edgar E. Iglesias, Paolo Bonzini,
	Philippe Mathieu-Daudé,
	Michael S. Tsirkin

TYPE_ETRAX_FS_TIMER is a sysbus device, so its DeviceClass::reset()
handler is called automatically when its qbus parent is reset.
Convert the generic reset to a qdev one, and remove the
qemu_register_reset() call.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/timer/etraxfs_timer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index 5379006086f..3cfab3e3284 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -309,9 +309,9 @@ static const MemoryRegionOps timer_ops = {
     }
 };
 
-static void etraxfs_timer_reset(void *opaque)
+static void etraxfs_timer_reset(DeviceState *dev)
 {
-    ETRAXTimerState *t = opaque;
+    ETRAXTimerState *t = ETRAX_TIMER(dev);
 
     ptimer_transaction_begin(t->ptimer_t0);
     ptimer_stop(t->ptimer_t0);
@@ -343,7 +343,6 @@ static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
     memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
                           "etraxfs-timer", 0x5c);
     sysbus_init_mmio(sbd, &t->mmio);
-    qemu_register_reset(etraxfs_timer_reset, t);
 }
 
 static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
@@ -351,6 +350,7 @@ static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = etraxfs_timer_realize;
+    dc->reset = etraxfs_timer_reset;
 }
 
 static const TypeInfo etraxfs_timer_info = {
-- 
2.26.3



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

* [PATCH 2/2] hw/rtc/mc146818rtc: Qdev'ify reset()
  2021-04-23 23:36 [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé
  2021-04-23 23:36 ` [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset() Philippe Mathieu-Daudé
@ 2021-04-23 23:36 ` Philippe Mathieu-Daudé
  2021-05-01 10:17 ` [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé
  2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-23 23:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Edgar E. Iglesias, Paolo Bonzini,
	Philippe Mathieu-Daudé,
	Michael S. Tsirkin

TYPE_MC146818_RTC is an ISA device, so its DeviceClass::reset()
handler is called automatically when its qbus parent is reset.

We have 2 reset() methods: a generic one and the qdev one.
Merge them into the qdev reset handler, rename it, and remove
the qemu_register_reset() call.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/rtc/mc146818rtc.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index 5d0fcacd0c0..710adeb9aaa 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -872,22 +872,6 @@ static void rtc_notify_suspend(Notifier *notifier, void *data)
     rtc_set_memory(ISA_DEVICE(s), 0xF, 0xFE);
 }
 
-static void rtc_reset(void *opaque)
-{
-    RTCState *s = opaque;
-
-    s->cmos_data[RTC_REG_B] &= ~(REG_B_PIE | REG_B_AIE | REG_B_SQWE);
-    s->cmos_data[RTC_REG_C] &= ~(REG_C_UF | REG_C_IRQF | REG_C_PF | REG_C_AF);
-    check_update_timer(s);
-
-    qemu_irq_lower(s->irq);
-
-    if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
-        s->irq_coalesced = 0;
-        s->irq_reinject_on_ack_count = 0;
-    }
-}
-
 static const MemoryRegionOps cmos_ops = {
     .read = cmos_ioport_read,
     .write = cmos_ioport_write,
@@ -962,7 +946,6 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)
     memory_region_add_coalescing(&s->coalesced_io, 0, 1);
 
     qdev_set_legacy_instance_id(dev, RTC_ISA_BASE, 3);
-    qemu_register_reset(rtc_reset, s);
 
     object_property_add_tm(OBJECT(s), "date", rtc_get_date);
 
@@ -998,17 +981,29 @@ static Property mc146818rtc_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static void rtc_resetdev(DeviceState *d)
+static void rtc_reset(DeviceState *dev)
 {
-    RTCState *s = MC146818_RTC(d);
+    RTCState *s = MC146818_RTC(dev);
 
     /* Reason: VM do suspend self will set 0xfe
      * Reset any values other than 0xfe(Guest suspend case) */
     if (s->cmos_data[0x0f] != 0xfe) {
         s->cmos_data[0x0f] = 0x00;
     }
+
+    s->cmos_data[RTC_REG_B] &= ~(REG_B_PIE | REG_B_AIE | REG_B_SQWE);
+    s->cmos_data[RTC_REG_C] &= ~(REG_C_UF | REG_C_IRQF | REG_C_PF | REG_C_AF);
+    check_update_timer(s);
+
+    qemu_irq_lower(s->irq);
+
+    if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
+        s->irq_coalesced = 0;
+        s->irq_reinject_on_ack_count = 0;
+    }
 }
 
+
 static void rtc_build_aml(ISADevice *isadev, Aml *scope)
 {
     Aml *dev;
@@ -1036,7 +1031,7 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
     ISADeviceClass *isa = ISA_DEVICE_CLASS(klass);
 
     dc->realize = rtc_realizefn;
-    dc->reset = rtc_resetdev;
+    dc->reset = rtc_reset;
     dc->vmsd = &vmstate_rtc;
     isa->build_aml = rtc_build_aml;
     device_class_set_props(dc, mc146818rtc_properties);
-- 
2.26.3



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

* Re: [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer
  2021-04-23 23:36 [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé
  2021-04-23 23:36 ` [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset() Philippe Mathieu-Daudé
  2021-04-23 23:36 ` [PATCH 2/2] hw/rtc/mc146818rtc: " Philippe Mathieu-Daudé
@ 2021-05-01 10:17 ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-01 10:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Edgar E. Iglesias, Michael S. Tsirkin, Paolo Bonzini

ping?

On 4/24/21 1:36 AM, Philippe Mathieu-Daudé wrote:
> Remove qemu_register_reset() when a qdev type has a qbus parent.
> 
> Philippe Mathieu-Daudé (2):
>   hw/timer/etraxfs_timer: Qdev'ify reset()
>   hw/rtc/mc146818rtc: Qdev'ify reset()
> 
>  hw/rtc/mc146818rtc.c     | 35 +++++++++++++++--------------------
>  hw/timer/etraxfs_timer.c |  6 +++---
>  2 files changed, 18 insertions(+), 23 deletions(-)
> 


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

* Re: [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset()
  2021-04-23 23:36 ` [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset() Philippe Mathieu-Daudé
@ 2021-05-01 16:46   ` Laurent Vivier
  2021-05-01 21:49     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Vivier @ 2021-05-01 16:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: qemu-trivial, Edgar E. Iglesias, Michael S. Tsirkin, Paolo Bonzini

Le 24/04/2021 à 01:36, Philippe Mathieu-Daudé a écrit :
> TYPE_ETRAX_FS_TIMER is a sysbus device, so its DeviceClass::reset()
> handler is called automatically when its qbus parent is reset.
> Convert the generic reset to a qdev one, and remove the
> qemu_register_reset() call.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/timer/etraxfs_timer.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
> index 5379006086f..3cfab3e3284 100644
> --- a/hw/timer/etraxfs_timer.c
> +++ b/hw/timer/etraxfs_timer.c
> @@ -309,9 +309,9 @@ static const MemoryRegionOps timer_ops = {
>      }
>  };
>  
> -static void etraxfs_timer_reset(void *opaque)
> +static void etraxfs_timer_reset(DeviceState *dev)
>  {
> -    ETRAXTimerState *t = opaque;
> +    ETRAXTimerState *t = ETRAX_TIMER(dev);
>  
>      ptimer_transaction_begin(t->ptimer_t0);
>      ptimer_stop(t->ptimer_t0);
> @@ -343,7 +343,6 @@ static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
>      memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
>                            "etraxfs-timer", 0x5c);
>      sysbus_init_mmio(sbd, &t->mmio);
> -    qemu_register_reset(etraxfs_timer_reset, t);
>  }
>  
>  static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
> @@ -351,6 +350,7 @@ static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>  
>      dc->realize = etraxfs_timer_realize;
> +    dc->reset = etraxfs_timer_reset;
>  }
>  
>  static const TypeInfo etraxfs_timer_info = {
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

But according to the comment in DeviceClass, we should use the resettable interface now:

docs/devel/reset.rst

Thanks,
Laurent


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

* Re: [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset()
  2021-05-01 16:46   ` Laurent Vivier
@ 2021-05-01 21:49     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-01 21:49 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel
  Cc: qemu-trivial, Edgar E. Iglesias, Paolo Bonzini, Michael S. Tsirkin

On 5/1/21 6:46 PM, Laurent Vivier wrote:
> Le 24/04/2021 à 01:36, Philippe Mathieu-Daudé a écrit :
>> TYPE_ETRAX_FS_TIMER is a sysbus device, so its DeviceClass::reset()
>> handler is called automatically when its qbus parent is reset.
>> Convert the generic reset to a qdev one, and remove the
>> qemu_register_reset() call.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  hw/timer/etraxfs_timer.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
>> index 5379006086f..3cfab3e3284 100644
>> --- a/hw/timer/etraxfs_timer.c
>> +++ b/hw/timer/etraxfs_timer.c
>> @@ -309,9 +309,9 @@ static const MemoryRegionOps timer_ops = {
>>      }
>>  };
>>  
>> -static void etraxfs_timer_reset(void *opaque)
>> +static void etraxfs_timer_reset(DeviceState *dev)
>>  {
>> -    ETRAXTimerState *t = opaque;
>> +    ETRAXTimerState *t = ETRAX_TIMER(dev);
>>  
>>      ptimer_transaction_begin(t->ptimer_t0);
>>      ptimer_stop(t->ptimer_t0);
>> @@ -343,7 +343,6 @@ static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
>>      memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
>>                            "etraxfs-timer", 0x5c);
>>      sysbus_init_mmio(sbd, &t->mmio);
>> -    qemu_register_reset(etraxfs_timer_reset, t);
>>  }
>>  
>>  static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
>> @@ -351,6 +350,7 @@ static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
>>      DeviceClass *dc = DEVICE_CLASS(klass);
>>  
>>      dc->realize = etraxfs_timer_realize;
>> +    dc->reset = etraxfs_timer_reset;
>>  }
>>  
>>  static const TypeInfo etraxfs_timer_info = {
>>
> 
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> 
> But according to the comment in DeviceClass, we should use the resettable interface now:
> 
> docs/devel/reset.rst

Eh... As a first step, I think we gain in removing the
qemu_register_reset() call.

It seems overkill to use the 3-state reset interface,
but if it is deprecated, then OK.

Thanks for reviewing,

Phil.


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

end of thread, other threads:[~2021-05-01 21:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 23:36 [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé
2021-04-23 23:36 ` [PATCH 1/2] hw/timer/etraxfs_timer: Qdev'ify reset() Philippe Mathieu-Daudé
2021-05-01 16:46   ` Laurent Vivier
2021-05-01 21:49     ` Philippe Mathieu-Daudé
2021-04-23 23:36 ` [PATCH 2/2] hw/rtc/mc146818rtc: " Philippe Mathieu-Daudé
2021-05-01 10:17 ` [PATCH 0/2] hw: Qdev'ify reset() for mc146818rtc & etraxfs_timer Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.