From patchwork Tue Aug 13 15:10:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 266840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (unknown [IPv6:2001:4830:134:3::12]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 20F5C2C0120 for ; Wed, 14 Aug 2013 01:21:25 +1000 (EST) Received: from localhost ([::1]:45641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GPS-00075W-Ee for incoming@patchwork.ozlabs.org; Tue, 13 Aug 2013 11:21:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GGp-0005RX-Rk for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9GGg-0003zX-BA for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:12:27 -0400 Received: from mail-ob0-x232.google.com ([2607:f8b0:4003:c01::232]:53556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GGg-0003zA-4S; Tue, 13 Aug 2013 11:12:18 -0400 Received: by mail-ob0-f178.google.com with SMTP id ef5so2729393obb.37 for ; Tue, 13 Aug 2013 08:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7tYvJI4+pnRCKD5m/tI+TSh7K09PW22w/VmPP4nu8fw=; b=IiqbrLQGZRgzJMRwVWusTzpI8dLeFNpblKgKSPDyPv71uF2efwOXw5SEAg5ppZ48ju bH6m/VMlQt54nOuSglWTZBjQ6HDiHpYQPizDv2ZM+DRjj/5dHzlEJoow7lMzEiTvC6YG QhnXG8ifIbMoLa4D9v2RSjzCCmHiAAn+xksTe2WRu275bcPwlRsKIt6Nqu8cnrbFEyxA JoHypg9blw47imjs2p6p3dDRq+oDaWdLIbP/vO+mY/swMDEzd2G2LZHjA/HZfvc7dRf8 b2cGXFKjDiKtVcBhhYma4DjvW166ZivBTpPssWvfotvJP5WMylHuWhmKPelhkSoPT2E3 XBYw== X-Received: by 10.60.84.147 with SMTP id z19mr4876470oey.21.1376406737566; Tue, 13 Aug 2013 08:12:17 -0700 (PDT) Received: from loki.austin.ibm.com ([32.97.110.51]) by mx.google.com with ESMTPSA id uz16sm12947878obc.5.2013.08.13.08.12.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Aug 2013 08:12:16 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 13 Aug 2013 10:10:52 -0500 Message-Id: <1376406680-16302-29-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::232 Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 28/56] ahci: Fix FLUSH command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: 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 f68ec837, FLUSH commands would seem to have completed immediately even if they were still running on the host. After the commit, they would simply hang and never unset the BSY bit, rendering AHCI unusable on any OS sending flushes. 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. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi (cherry picked from commit a62eaa26c1d6d48fbdc3ac1d32bd1314f5fdc8c9) Signed-off-by: Michael Roth --- hw/ide/ahci.c | 8 +++++++- hw/ide/core.c | 9 +++++++++ hw/ide/internal.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index eab6096..ade9f64 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1104,9 +1104,14 @@ static int ahci_dma_add_status(IDEDMA *dma, int status) static int ahci_dma_set_inactive(IDEDMA *dma) { + return 0; +} + +static int ahci_async_cmd_done(IDEDMA *dma) +{ AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); - DPRINTF(ad->port_no, "dma done\n"); + DPRINTF(ad->port_no, "async cmd done\n"); /* update d2h status */ ahci_write_fis_d2h(ad, NULL); @@ -1141,6 +1146,7 @@ static const IDEDMAOps ahci_dma_ops = { .set_unit = ahci_dma_set_unit, .add_status = ahci_dma_add_status, .set_inactive = ahci_dma_set_inactive, + .async_cmd_done = ahci_async_cmd_done, .restart_cb = ahci_dma_restart_cb, .reset = ahci_dma_reset, }; diff --git a/hw/ide/core.c b/hw/ide/core.c index 9926d92..8b3dde6 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); } +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 = NULL; s->bus->dma->ops->set_inactive(s->bus->dma); + ide_async_cmd_done(s); } void ide_dma_error(IDEState *s) @@ -804,6 +812,7 @@ static void ide_flush_cb(void *opaque, int ret) bdrv_acct_done(s->bs, &s->acct); s->status = READY_STAT | SEEK_STAT; + ide_async_cmd_done(s); ide_set_irq(s->bus); } 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; };