From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Bxu-0005zr-QQ for qemu-devel@nongnu.org; Mon, 22 Jun 2015 20:21:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7Bxt-0003WS-U3 for qemu-devel@nongnu.org; Mon, 22 Jun 2015 20:21:26 -0400 From: John Snow Date: Mon, 22 Jun 2015 20:21:06 -0400 Message-Id: <1435018875-22527-8-git-send-email-jsnow@redhat.com> In-Reply-To: <1435018875-22527-1-git-send-email-jsnow@redhat.com> References: <1435018875-22527-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 07/16] ahci: kick NCQ queue List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, John Snow , qemu-devel@nongnu.org, stefanha@redhat.com Upon a VM state change, retry the halted NCQ commands. Signed-off-by: John Snow --- hw/ide/ahci.c | 18 ++++++++++++++++++ hw/ide/core.c | 7 +++++++ hw/ide/internal.h | 1 + 3 files changed, 26 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index a838317..6233059 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1332,6 +1332,23 @@ static void ahci_restart_dma(IDEDMA *dma) } /** + * IDE/PIO restarts are handled by the core layer, but NCQ commands + * need an extra kick from the AHCI HBA. + */ +static void ahci_restart(IDEDMA *dma) +{ + AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); + int i; + + for (i = 0; i < AHCI_MAX_CMDS; i++) { + NCQTransferState *ncq_tfs = &ad->ncq_tfs[i]; + if (ncq_tfs->halt) { + execute_ncq_command(ncq_tfs); + } + } +} + +/** * Called in DMA R/W chains to read the PRDT, utilizing ahci_populate_sglist. * Not currently invoked by PIO R/W chains, * which invoke ahci_populate_sglist via ahci_start_transfer. @@ -1419,6 +1436,7 @@ static void ahci_irq_set(void *opaque, int n, int level) static const IDEDMAOps ahci_dma_ops = { .start_dma = ahci_start_dma, + .restart = ahci_restart, .restart_dma = ahci_restart_dma, .start_transfer = ahci_start_transfer, .prepare_buf = ahci_dma_prepare_buf, diff --git a/hw/ide/core.c b/hw/ide/core.c index 6eefb30..8c271cc 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2372,6 +2372,13 @@ static void ide_restart_bh(void *opaque) * called function can set a new error status. */ bus->error_status = 0; + /* The HBA has generically asked to be kicked on retry */ + if (error_status & IDE_RETRY_HBA) { + if (s->bus->dma->ops->restart) { + s->bus->dma->ops->restart(s->bus->dma); + } + } + if (error_status & IDE_RETRY_DMA) { if (error_status & IDE_RETRY_TRIM) { ide_restart_dma(s, IDE_DMA_TRIM); diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 5abee19..adb968c 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -436,6 +436,7 @@ struct IDEDMAOps { DMAInt32Func *prepare_buf; DMAu32Func *commit_buf; DMAIntFunc *rw_buf; + DMAVoidFunc *restart; DMAVoidFunc *restart_dma; DMAStopFunc *set_inactive; DMAVoidFunc *cmd_done; -- 2.1.0