qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] dma: Avoid reentrancy in DMA transfer handlers
Date: Mon, 31 Oct 2011 17:40:37 +0100	[thread overview]
Message-ID: <4EAECF85.2010303@redhat.com> (raw)
In-Reply-To: <4EAEC62C.9000600@redhat.com>

Am 31.10.2011 17:00, schrieb Kevin Wolf:
> Am 31.10.2011 16:34, schrieb Paolo Bonzini:
>> On 10/31/2011 03:46 PM, Kevin Wolf wrote:
>>>>  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.
>>>
>>> I was about to agree, but in fact adding a rearm = 1; line leads to
>>> crashes, whereas in the version I posted it just works. So it looks like
>>> something is wrong with doing it, even though it seemed to make perfect
>>> sense at the first sight.
>>
>> But what will restart the DMA at the end of the synchronous I/O, then?
> 
> bdrv_read/write are called inside fdctrl_read_data(), so the outer
> DMA_run() already has rearm = 1.
> 
> I think the more interesting question is why rescheduling can break
> anything. Where would we schedule the BH additionally when it isn't
> already scheduled anyway?

I think I found the problem:

> @@ -374,6 +381,8 @@ static void DMA_run (void)
>          }
>      }
>  
> +out:
> +    running = 0;
>      if (rearm)
>          qemu_bh_schedule_idle(dma_bh);
>  }

We should only reset running to 0 in the outermost instance. Moving the
out: label a line down seems to fix the crashes.

Kevin

      reply	other threads:[~2011-10-31 17:53 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
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 [this message]

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=4EAECF85.2010303@redhat.com \
    --to=kwolf@redhat.com \
    --cc=pbonzini@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).