qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] dma: Avoid reentrancy in DMA transfer handlers
Date: Fri, 28 Oct 2011 18:35:00 +0200	[thread overview]
Message-ID: <4EAAD9B4.7040206@redhat.com> (raw)
In-Reply-To: <1319811501-6823-1-git-send-email-kwolf@redhat.com>

On 10/28/2011 04:18 PM, Kevin Wolf wrote:
> With the conversion of the block layer to coroutines, bdrv_read/write
> have changed to run a nested event loop that calls qemu_bh_poll.
> Consequently a scheduled BH can be called while a DMA transfer handler
> runs and this means that DMA_run becomes reentrant.
>
> Devices haven't been designed to cope with that, so instead of running a
> nested transfer handler just wait for the next invocation of the BH from the
> main loop.
>
> This fixes some problems with the floppy device.
>
> Signed-off-by: Kevin Wolf<kwolf@redhat.com>
> ---
>   hw/dma.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/hw/dma.c b/hw/dma.c
> index 8a7302a..e8d6341 100644
> --- a/hw/dma.c
> +++ b/hw/dma.c
> @@ -358,6 +358,13 @@ static void DMA_run (void)
>       struct dma_cont *d;
>       int icont, ichan;
>       int rearm = 0;
> +    static int running = 0;
> +
> +    if (running) {
> +        goto out;
> +    } else {
> +        running = 1;
> +    }
>
>       d = dma_controllers;
>
> @@ -374,6 +381,8 @@ static void DMA_run (void)
>           }
>       }
>
> +out:
> +    running = 0;
>       if (rearm)
>           qemu_bh_schedule_idle(dma_bh);
>   }

Hmm, I think you should set rearm = 1 to ensure the BH is run when 
ultimately you leave the sync read.  Sorry for not spotting this before.

Paolo

  reply	other threads:[~2011-10-28 16:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28 14:18 [Qemu-devel] [PATCH] dma: Avoid reentrancy in DMA transfer handlers Kevin Wolf
2011-10-28 16:35 ` Paolo Bonzini [this message]
2011-10-31 14:46   ` Kevin Wolf
2011-10-31 15:34     ` Paolo Bonzini
2011-10-31 16:00       ` Kevin Wolf
2011-10-31 16:40         ` Kevin Wolf

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=4EAAD9B4.7040206@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).