[1/3] hw/net/fsl_etsec/etsec.c: Switch to transaction-based ptimer API

Message ID 20191017132122.4402-2-peter.maydell@linaro.org
State Superseded
Headers show
Series
  • Convert ppc and microblaze devices to new ptimer API
Related show

Commit Message

Peter Maydell Oct. 17, 2019, 1:21 p.m.
Switch the fsl_etsec 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/net/fsl_etsec/etsec.h | 1 -
 hw/net/fsl_etsec/etsec.c | 9 +++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.20.1

Comments

Richard Henderson Oct. 17, 2019, 2:13 p.m. | #1
On 10/17/19 6:21 AM, Peter Maydell wrote:
> Switch the fsl_etsec 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/net/fsl_etsec/etsec.h | 1 -

>  hw/net/fsl_etsec/etsec.c | 9 +++++----

>  2 files changed, 5 insertions(+), 5 deletions(-)


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



r~
Philippe Mathieu-Daudé Oct. 17, 2019, 2:57 p.m. | #2
On 10/17/19 3:21 PM, Peter Maydell wrote:
> Switch the fsl_etsec 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/net/fsl_etsec/etsec.h | 1 -

>   hw/net/fsl_etsec/etsec.c | 9 +++++----

>   2 files changed, 5 insertions(+), 5 deletions(-)

> 

> diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h

> index 09d05c21338..7951c3ad65f 100644

> --- a/hw/net/fsl_etsec/etsec.h

> +++ b/hw/net/fsl_etsec/etsec.h

> @@ -141,7 +141,6 @@ typedef struct eTSEC {

>       uint16_t phy_control;

>   

>       /* Polling */

> -    QEMUBH *bh;

>       struct ptimer_state *ptimer;

>   

>       /* Whether we should flush the rx queue when buffer becomes available. */

> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c

> index d9b3e8c691e..717de76569a 100644

> --- a/hw/net/fsl_etsec/etsec.c

> +++ b/hw/net/fsl_etsec/etsec.c

> @@ -34,7 +34,6 @@

>   #include "etsec.h"

>   #include "registers.h"

>   #include "qemu/log.h"

> -#include "qemu/main-loop.h"

>   #include "qemu/module.h"

>   

>   /* #define HEX_DUMP */

> @@ -195,9 +194,11 @@ static void write_dmactrl(eTSEC          *etsec,

>   

>       if (!(value & DMACTRL_WOP)) {

>           /* Start polling */

> +        ptimer_transaction_begin(etsec->ptimer);

>           ptimer_stop(etsec->ptimer);

>           ptimer_set_count(etsec->ptimer, 1);

>           ptimer_run(etsec->ptimer, 1);

> +        ptimer_transaction_commit(etsec->ptimer);

>       }

>   }

>   

> @@ -391,10 +392,10 @@ static void etsec_realize(DeviceState *dev, Error **errp)

>                                 object_get_typename(OBJECT(dev)), dev->id, etsec);

>       qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a);

>   

> -

> -    etsec->bh     = qemu_bh_new(etsec_timer_hit, etsec);

> -    etsec->ptimer = ptimer_init_with_bh(etsec->bh, PTIMER_POLICY_DEFAULT);

> +    etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DEFAULT);

> +    ptimer_transaction_begin(etsec->ptimer);

>       ptimer_set_freq(etsec->ptimer, 100);

> +    ptimer_transaction_commit(etsec->ptimer);

>   }

>   

>   static void etsec_instance_init(Object *obj)

> 


Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Alistair Francis Oct. 17, 2019, 10 p.m. | #3
On Thu, Oct 17, 2019 at 6:42 AM Peter Maydell <peter.maydell@linaro.org> wrote:
>

> Switch the fsl_etsec 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>


Reviewed-by: Alistair Francis <alistair.francis@wdc.com>


Alistair

> ---

>  hw/net/fsl_etsec/etsec.h | 1 -

>  hw/net/fsl_etsec/etsec.c | 9 +++++----

>  2 files changed, 5 insertions(+), 5 deletions(-)

>

> diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h

> index 09d05c21338..7951c3ad65f 100644

> --- a/hw/net/fsl_etsec/etsec.h

> +++ b/hw/net/fsl_etsec/etsec.h

> @@ -141,7 +141,6 @@ typedef struct eTSEC {

>      uint16_t phy_control;

>

>      /* Polling */

> -    QEMUBH *bh;

>      struct ptimer_state *ptimer;

>

>      /* Whether we should flush the rx queue when buffer becomes available. */

> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c

> index d9b3e8c691e..717de76569a 100644

> --- a/hw/net/fsl_etsec/etsec.c

> +++ b/hw/net/fsl_etsec/etsec.c

> @@ -34,7 +34,6 @@

>  #include "etsec.h"

>  #include "registers.h"

>  #include "qemu/log.h"

> -#include "qemu/main-loop.h"

>  #include "qemu/module.h"

>

>  /* #define HEX_DUMP */

> @@ -195,9 +194,11 @@ static void write_dmactrl(eTSEC          *etsec,

>

>      if (!(value & DMACTRL_WOP)) {

>          /* Start polling */

> +        ptimer_transaction_begin(etsec->ptimer);

>          ptimer_stop(etsec->ptimer);

>          ptimer_set_count(etsec->ptimer, 1);

>          ptimer_run(etsec->ptimer, 1);

> +        ptimer_transaction_commit(etsec->ptimer);

>      }

>  }

>

> @@ -391,10 +392,10 @@ static void etsec_realize(DeviceState *dev, Error **errp)

>                                object_get_typename(OBJECT(dev)), dev->id, etsec);

>      qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a);

>

> -

> -    etsec->bh     = qemu_bh_new(etsec_timer_hit, etsec);

> -    etsec->ptimer = ptimer_init_with_bh(etsec->bh, PTIMER_POLICY_DEFAULT);

> +    etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DEFAULT);

> +    ptimer_transaction_begin(etsec->ptimer);

>      ptimer_set_freq(etsec->ptimer, 100);

> +    ptimer_transaction_commit(etsec->ptimer);

>  }

>

>  static void etsec_instance_init(Object *obj)

> --

> 2.20.1

>

>

Patch

diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h
index 09d05c21338..7951c3ad65f 100644
--- a/hw/net/fsl_etsec/etsec.h
+++ b/hw/net/fsl_etsec/etsec.h
@@ -141,7 +141,6 @@  typedef struct eTSEC {
     uint16_t phy_control;
 
     /* Polling */
-    QEMUBH *bh;
     struct ptimer_state *ptimer;
 
     /* Whether we should flush the rx queue when buffer becomes available. */
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index d9b3e8c691e..717de76569a 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -34,7 +34,6 @@ 
 #include "etsec.h"
 #include "registers.h"
 #include "qemu/log.h"
-#include "qemu/main-loop.h"
 #include "qemu/module.h"
 
 /* #define HEX_DUMP */
@@ -195,9 +194,11 @@  static void write_dmactrl(eTSEC          *etsec,
 
     if (!(value & DMACTRL_WOP)) {
         /* Start polling */
+        ptimer_transaction_begin(etsec->ptimer);
         ptimer_stop(etsec->ptimer);
         ptimer_set_count(etsec->ptimer, 1);
         ptimer_run(etsec->ptimer, 1);
+        ptimer_transaction_commit(etsec->ptimer);
     }
 }
 
@@ -391,10 +392,10 @@  static void etsec_realize(DeviceState *dev, Error **errp)
                               object_get_typename(OBJECT(dev)), dev->id, etsec);
     qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a);
 
-
-    etsec->bh     = qemu_bh_new(etsec_timer_hit, etsec);
-    etsec->ptimer = ptimer_init_with_bh(etsec->bh, PTIMER_POLICY_DEFAULT);
+    etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DEFAULT);
+    ptimer_transaction_begin(etsec->ptimer);
     ptimer_set_freq(etsec->ptimer, 100);
+    ptimer_transaction_commit(etsec->ptimer);
 }
 
 static void etsec_instance_init(Object *obj)