From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbqUC-0003Jd-N1 for qemu-devel@nongnu.org; Thu, 31 Oct 2013 07:32:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbqU7-000653-4U for qemu-devel@nongnu.org; Thu, 31 Oct 2013 07:32:24 -0400 Received: from mail-qe0-x235.google.com ([2607:f8b0:400d:c02::235]:45672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbqU6-00064A-Vp for qemu-devel@nongnu.org; Thu, 31 Oct 2013 07:32:19 -0400 Received: by mail-qe0-f53.google.com with SMTP id cy11so1608221qeb.40 for ; Thu, 31 Oct 2013 04:32:18 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <52723FBC.1010803@redhat.com> Date: Thu, 31 Oct 2013 12:32:12 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20131028190151.GA1994@redhat.com> In-Reply-To: <20131028190151.GA1994@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH repost] ahci: fix win7 hang on boot List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Kevin Wolf , agraf@suse.de, qemu-devel@nongnu.org, Anthony Liguori , =?ISO-8859-1?Q?Andreas_F=E4rber?= Il 28/10/2013 20:01, Michael S. Tsirkin ha scritto: > From: Alexander Graf > > When AHCI executes an asynchronous IDE command, it checked DRDY without > checking either DRQ or BSY. This sometimes caused interrupt to be sent > before command is actually completed. > > This resulted in a race condition: if guest then managed to access the > device before command has completed, it would hang waiting for an > interrupt. > This was observed with windows 7 guests. > > To fix, check for DRQ or BSY in additiona to DRDY, if set, > the command is asynchronous so delay the interrupt until > asynchronous done callback is invoked. > > Reported-by: Michael S. Tsirkin > Reviewed-by: Michael S. Tsirkin > Tested-by: Michael S. Tsirkin > Signed-off-by: Michael S. Tsirkin > > --- > hw/ide/ahci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > index a8be62c..fbea9e8 100644 > --- a/hw/ide/ahci.c > +++ b/hw/ide/ahci.c > @@ -961,7 +961,8 @@ static int handle_cmd(AHCIState *s, int port, int slot) > /* We're ready to process the command in FIS byte 2. */ > ide_exec_cmd(&s->dev[port].port, cmd_fis[2]); > > - if (s->dev[port].port.ifs[0].status & READY_STAT) { > + if ((s->dev[port].port.ifs[0].status & (READY_STAT|DRQ_STAT|BUSY_STAT)) == > + READY_STAT) { > ahci_write_fis_d2h(&s->dev[port], cmd_fis); > } > } > While the patch fixes the symptom, I think it is only a bandaid. There is no reason why the async_cmd_done should be restricted to asynchronous commands. If synchronous commands are made to go through the async_cmd_done callback, you'll automatically get the D2H FIS written for all commands. It's good for 1.7, but let's revisit it for 1.8. Paolo