All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>,
	Alistair Francis <alistair@alistair23.me>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>, qemu-ppc <qemu-ppc@nongnu.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH 3/3] hw/dma/xilinx_axidma.c: Switch to transaction-based ptimer API
Date: Thu, 17 Oct 2019 16:06:19 +0100	[thread overview]
Message-ID: <CAFEAcA_zz=SYwD=iDgwVZcvPF4seZW9qdvfGKfmK_UaaUDF7Vg@mail.gmail.com> (raw)
In-Reply-To: <d9e7dd55-01e5-d852-bbab-84f5209abb6f@redhat.com>

On Thu, 17 Oct 2019 at 16:01, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Hi Peter,
>
> On 10/17/19 3:21 PM, Peter Maydell wrote:
> > Switch the xilinx_axidma 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/dma/xilinx_axidma.c | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
> > index e035d1f7504..fb3a978e282 100644
> > --- a/hw/dma/xilinx_axidma.c
> > +++ b/hw/dma/xilinx_axidma.c
> > @@ -31,7 +31,6 @@
> >   #include "hw/ptimer.h"
> >   #include "hw/qdev-properties.h"
> >   #include "qemu/log.h"
> > -#include "qemu/main-loop.h"
> >   #include "qemu/module.h"
> >
> >   #include "hw/stream.h"
> > @@ -104,7 +103,6 @@ enum {
> >   };
> >
> >   struct Stream {
> > -    QEMUBH *bh;
> >       ptimer_state *ptimer;
> >       qemu_irq irq;
> >
> > @@ -242,6 +240,7 @@ static void stream_complete(struct Stream *s)
> >       unsigned int comp_delay;
> >
> >       /* Start the delayed timer.  */
> > +    ptimer_transaction_begin(s->ptimer);
> >       comp_delay = s->regs[R_DMACR] >> 24;
> >       if (comp_delay) {
> >           ptimer_stop(s->ptimer);
> > @@ -255,6 +254,7 @@ static void stream_complete(struct Stream *s)
> >           s->regs[R_DMASR] |= DMASR_IOC_IRQ;
> >           stream_reload_complete_cnt(s);
> >       }
> > +    ptimer_transaction_commit(s->ptimer);
>
> I'd restrict the transaction here within the if() statement:
>
> -- >8 --
> @@ -244,9 +244,11 @@ static void stream_complete(struct Stream *s)
>       /* Start the delayed timer.  */
>       comp_delay = s->regs[R_DMACR] >> 24;
>       if (comp_delay) {
> +        ptimer_transaction_begin(s->ptimer);
>           ptimer_stop(s->ptimer);
>           ptimer_set_count(s->ptimer, comp_delay);
>           ptimer_run(s->ptimer, 1);
> +        ptimer_transaction_commit(s->ptimer);
>       }
>
>       s->complete_cnt--;

The timer_hit callback function itself writes to
s->complete_cnt, so we don't want to allow it to
be called (via the commit()) before stream_complete()
is done with changing that state.

thanks
-- PMM


  reply	other threads:[~2019-10-17 16:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 13:21 [PATCH 0/3] Convert ppc and microblaze devices to new ptimer API Peter Maydell
2019-10-17 13:21 ` [PATCH 1/3] hw/net/fsl_etsec/etsec.c: Switch to transaction-based " Peter Maydell
2019-10-17 14:13   ` Richard Henderson
2019-10-17 14:57   ` Philippe Mathieu-Daudé
2019-10-17 22:00   ` Alistair Francis
2019-10-17 13:21 ` [PATCH 2/3] hw/timer/xilinx_timer.c: " Peter Maydell
2019-10-17 14:14   ` Richard Henderson
2019-10-17 14:56   ` Philippe Mathieu-Daudé
2019-10-17 15:03     ` Peter Maydell
2019-10-17 15:24       ` Philippe Mathieu-Daudé
2019-10-17 22:00   ` Alistair Francis
2019-10-17 13:21 ` [PATCH 3/3] hw/dma/xilinx_axidma.c: " Peter Maydell
2019-10-17 14:16   ` Richard Henderson
2019-10-17 15:01   ` Philippe Mathieu-Daudé
2019-10-17 15:06     ` Peter Maydell [this message]
2019-10-17 15:25       ` Philippe Mathieu-Daudé
2019-10-17 22:02   ` Alistair Francis
2019-10-24 12:16 ` [PATCH 0/3] Convert ppc and microblaze devices to new " Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA_zz=SYwD=iDgwVZcvPF4seZW9qdvfGKfmK_UaaUDF7Vg@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=alistair@alistair23.me \
    --cc=david@gibson.dropbear.id.au \
    --cc=edgar.iglesias@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.