diff mbox series

[8/8] hw/m68k/mcf5208.c: Switch to transaction-based ptimer API

Message ID 20191017132905.5604-9-peter.maydell@linaro.org
State New
Headers show
Series Convert misc-arch devices to new ptimer API | expand

Commit Message

Peter Maydell Oct. 17, 2019, 1:29 p.m. UTC
Switch the mcf5208 code away from bottom-half based ptimers to
the new transaction-based ptimer API.  This just requires adding
begin/commit calls around the various places that modify the ptimer
state, and using the new ptimer_init() function to create the timer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/m68k/mcf5208.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Richard Henderson Oct. 17, 2019, 3:08 p.m. UTC | #1
On 10/17/19 6:29 AM, Peter Maydell wrote:
> Switch the mcf5208 code away from bottom-half based ptimers to
> the new transaction-based ptimer API.  This just requires adding
> begin/commit calls around the various places that modify the ptimer
> state, and using the new ptimer_init() function to create the timer.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/m68k/mcf5208.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Philippe Mathieu-Daudé Oct. 17, 2019, 3:49 p.m. UTC | #2
On 10/17/19 3:29 PM, Peter Maydell wrote:
> Switch the mcf5208 code away from bottom-half based ptimers to
> the new transaction-based ptimer API.  This just requires adding
> begin/commit calls around the various places that modify the ptimer
> state, and using the new ptimer_init() function to create the timer.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/m68k/mcf5208.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
> index 34d34eba17c..158c5e4be75 100644
> --- a/hw/m68k/mcf5208.c
> +++ b/hw/m68k/mcf5208.c
> @@ -9,7 +9,6 @@
>   #include "qemu/osdep.h"
>   #include "qemu/units.h"
>   #include "qemu/error-report.h"
> -#include "qemu/main-loop.h"
>   #include "qapi/error.h"
>   #include "qemu-common.h"
>   #include "cpu.h"
> @@ -79,6 +78,7 @@ static void m5208_timer_write(void *opaque, hwaddr offset,
>               return;
>           }
>   
> +        ptimer_transaction_begin(s->timer);
>           if (s->pcsr & PCSR_EN)
>               ptimer_stop(s->timer);
>   
> @@ -94,8 +94,10 @@ static void m5208_timer_write(void *opaque, hwaddr offset,
>   
>           if (s->pcsr & PCSR_EN)
>               ptimer_run(s->timer, 0);
> +        ptimer_transaction_commit(s->timer);
>           break;
>       case 2:
> +        ptimer_transaction_begin(s->timer);
>           s->pmr = value;
>           s->pcsr &= ~PCSR_PIF;
>           if ((s->pcsr & PCSR_RLD) == 0) {
> @@ -104,6 +106,7 @@ static void m5208_timer_write(void *opaque, hwaddr offset,
>           } else {
>               ptimer_set_limit(s->timer, value, s->pcsr & PCSR_OVW);
>           }
> +        ptimer_transaction_commit(s->timer);
>           break;
>       case 4:
>           break;
> @@ -182,7 +185,6 @@ static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic)
>   {
>       MemoryRegion *iomem = g_new(MemoryRegion, 1);
>       m5208_timer_state *s;
> -    QEMUBH *bh;
>       int i;
>   
>       /* SDRAMC.  */
> @@ -191,8 +193,7 @@ static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic)
>       /* Timers.  */
>       for (i = 0; i < 2; i++) {
>           s = g_new0(m5208_timer_state, 1);
> -        bh = qemu_bh_new(m5208_timer_trigger, s);
> -        s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT);
> +        s->timer = ptimer_init(m5208_timer_trigger, s, PTIMER_POLICY_DEFAULT);
>           memory_region_init_io(&s->iomem, NULL, &m5208_timer_ops, s,
>                                 "m5208-timer", 0x00004000);
>           memory_region_add_subregion(address_space, 0xfc080000 + 0x4000 * i,
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Thomas Huth Oct. 19, 2019, 10:52 a.m. UTC | #3
Am Thu, 17 Oct 2019 14:29:05 +0100
schrieb Peter Maydell <peter.maydell@linaro.org>:

> Switch the mcf5208 code away from bottom-half based ptimers to
> the new transaction-based ptimer API.  This just requires adding
> begin/commit calls around the various places that modify the ptimer
> state, and using the new ptimer_init() function to create the timer.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/m68k/mcf5208.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

This patch seems to work fine.

Tested-by: Thomas Huth <huth@tuxfamily.org>
diff mbox series

Patch

diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index 34d34eba17c..158c5e4be75 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -9,7 +9,6 @@ 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "qemu/error-report.h"
-#include "qemu/main-loop.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -79,6 +78,7 @@  static void m5208_timer_write(void *opaque, hwaddr offset,
             return;
         }
 
+        ptimer_transaction_begin(s->timer);
         if (s->pcsr & PCSR_EN)
             ptimer_stop(s->timer);
 
@@ -94,8 +94,10 @@  static void m5208_timer_write(void *opaque, hwaddr offset,
 
         if (s->pcsr & PCSR_EN)
             ptimer_run(s->timer, 0);
+        ptimer_transaction_commit(s->timer);
         break;
     case 2:
+        ptimer_transaction_begin(s->timer);
         s->pmr = value;
         s->pcsr &= ~PCSR_PIF;
         if ((s->pcsr & PCSR_RLD) == 0) {
@@ -104,6 +106,7 @@  static void m5208_timer_write(void *opaque, hwaddr offset,
         } else {
             ptimer_set_limit(s->timer, value, s->pcsr & PCSR_OVW);
         }
+        ptimer_transaction_commit(s->timer);
         break;
     case 4:
         break;
@@ -182,7 +185,6 @@  static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic)
 {
     MemoryRegion *iomem = g_new(MemoryRegion, 1);
     m5208_timer_state *s;
-    QEMUBH *bh;
     int i;
 
     /* SDRAMC.  */
@@ -191,8 +193,7 @@  static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic)
     /* Timers.  */
     for (i = 0; i < 2; i++) {
         s = g_new0(m5208_timer_state, 1);
-        bh = qemu_bh_new(m5208_timer_trigger, s);
-        s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT);
+        s->timer = ptimer_init(m5208_timer_trigger, s, PTIMER_POLICY_DEFAULT);
         memory_region_init_io(&s->iomem, NULL, &m5208_timer_ops, s,
                               "m5208-timer", 0x00004000);
         memory_region_add_subregion(address_space, 0xfc080000 + 0x4000 * i,