From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz4do-0004FK-0r for qemu-devel@nongnu.org; Tue, 16 Jul 2013 08:46:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uz4dm-00032R-Jq for qemu-devel@nongnu.org; Tue, 16 Jul 2013 08:46:03 -0400 Date: Tue, 16 Jul 2013 14:45:57 +0200 From: Kevin Wolf Message-ID: <20130716124557.GF2387@dhcp-200-207.str.redhat.com> References: <1373880871-28521-1-git-send-email-kwolf@redhat.com> <51E53CF5.9030105@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <51E53CF5.9030105@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] ahci: Fix FLUSH command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: famz@redhat.com, mst@redhat.com, qemu-stable@nongnu.org, qemu-devel@nongnu.org, alex.williamson@redhat.com, stefanha@redhat.com Am 16.07.2013 um 14:30 hat Andreas F=E4rber geschrieben: > Am 15.07.2013 11:34, schrieb Kevin Wolf: > > AHCI couldn't cope with asynchronous commands that aren't doing DMA, = it > > simply wouldn't complete them. Due to the bug fixed in commit f68ec83= 7, > > FLUSH commands would seem to have completed immediately even if they > > were still running on the host. After the commit, they would simply h= ang > > and never unset the BSY bit, rendering AHCI unusable on any OS sendin= g > > flushes. > >=20 > > This patch adds another callback for the completion of asynchronous > > commands. This is what AHCI really wants to use for its command > > completion logic rather than an DMA completion callback. > >=20 > > Cc: qemu-stable@nongnu.org > > Signed-off-by: Kevin Wolf > > --- > > hw/ide/ahci.c | 8 +++++++- > > hw/ide/core.c | 9 +++++++++ > > hw/ide/internal.h | 1 + > > 3 files changed, 17 insertions(+), 1 deletion(-) > >=20 > > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > > index 97eddec..1d863b5 100644 > > --- a/hw/ide/ahci.c > > +++ b/hw/ide/ahci.c > > @@ -1107,9 +1107,14 @@ static int ahci_dma_add_status(IDEDMA *dma, in= t status) > > =20 > > static int ahci_dma_set_inactive(IDEDMA *dma) > > { > > + return 0; >=20 > Is it intentional that this is now no-op rather than calling > dma->ops->set_inactive(dma) like core IDE does below? This _is_ the dma->ops->set_inactive() callback of AHCI that is called by the IDE code. For plain IDE commands the same IDEDMAOps function is implemented by ide_nop(). Kevin > Other than that it looks sensible to me. >=20 > Andreas >=20 > > +} > > + > > +static int ahci_async_cmd_done(IDEDMA *dma) > > +{ > > AHCIDevice *ad =3D DO_UPCAST(AHCIDevice, dma, dma); > > =20 > > - DPRINTF(ad->port_no, "dma done\n"); > > + DPRINTF(ad->port_no, "async cmd done\n"); > > =20 > > /* update d2h status */ > > ahci_write_fis_d2h(ad, NULL); > > @@ -1144,6 +1149,7 @@ static const IDEDMAOps ahci_dma_ops =3D { > > .set_unit =3D ahci_dma_set_unit, > > .add_status =3D ahci_dma_add_status, > > .set_inactive =3D ahci_dma_set_inactive, > > + .async_cmd_done =3D ahci_async_cmd_done, > > .restart_cb =3D ahci_dma_restart_cb, > > .reset =3D ahci_dma_reset, > > }; > > diff --git a/hw/ide/core.c b/hw/ide/core.c > > index 03d1cfa..a73af72 100644 > > --- a/hw/ide/core.c > > +++ b/hw/ide/core.c > > @@ -568,10 +568,18 @@ static void dma_buf_commit(IDEState *s) > > qemu_sglist_destroy(&s->sg); > > } > > =20 > > +static void ide_async_cmd_done(IDEState *s) > > +{ > > + if (s->bus->dma->ops->async_cmd_done) { > > + s->bus->dma->ops->async_cmd_done(s->bus->dma); > > + } > > +} > > + > > void ide_set_inactive(IDEState *s) > > { > > s->bus->dma->aiocb =3D NULL; > > s->bus->dma->ops->set_inactive(s->bus->dma); > > + ide_async_cmd_done(s); > > } > > =20 > > void ide_dma_error(IDEState *s) > > @@ -804,6 +812,7 @@ static void ide_flush_cb(void *opaque, int ret) > > =20 > > bdrv_acct_done(s->bs, &s->acct); > > s->status =3D READY_STAT | SEEK_STAT; > > + ide_async_cmd_done(s); > > ide_set_irq(s->bus); > > } > > =20 > > diff --git a/hw/ide/internal.h b/hw/ide/internal.h > > index 03f1489..048a052 100644 > > --- a/hw/ide/internal.h > > +++ b/hw/ide/internal.h > > @@ -433,6 +433,7 @@ struct IDEDMAOps { > > DMAIntFunc *set_unit; > > DMAIntFunc *add_status; > > DMAFunc *set_inactive; > > + DMAFunc *async_cmd_done; > > DMARestartFunc *restart_cb; > > DMAFunc *reset; > > }; > >=20 >=20 >=20 > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrn= berg