Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KU3w1-000609-Os for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:22:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KU3w1-0005zN-3Z for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:22:01 -0400 Received: from [199.232.76.173] (port=57078 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KU3w0-0005zE-Uk for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:22:00 -0400 Received: from savannah.gnu.org ([199.232.41.3]:36366 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KU3w0-0004DW-MJ for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:22:00 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KU3vy-0006WP-OU for qemu-devel@nongnu.org; Fri, 15 Aug 2008 18:21:58 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KU3vy-0006WJ-FV for qemu-devel@nongnu.org; Fri, 15 Aug 2008 18:21:58 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Fri, 15 Aug 2008 18:21:58 +0000 Subject: [Qemu-devel] [5011] Cancel IDE outstanding IO on device reset (Gleb Natapov) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5011 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5011 Author: aliguori Date: 2008-08-15 18:21:58 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Cancel IDE outstanding IO on device reset (Gleb Natapov) Cancel AIO in IDE layer on device rest in order to be in deterministic state during next boot. Signed-off-by: Gleb Natapov Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/hw/ide.c Modified: trunk/hw/ide.c =================================================================== --- trunk/hw/ide.c 2008-08-15 18:20:52 UTC (rev 5010) +++ trunk/hw/ide.c 2008-08-15 18:21:58 UTC (rev 5011) @@ -2844,6 +2844,23 @@ } } +static void ide_dma_cancel(BMDMAState *bm) +{ + if (bm->status & BM_STATUS_DMAING) { + bm->status &= ~BM_STATUS_DMAING; + /* cancel DMA request */ + bm->ide_if = NULL; + bm->dma_cb = NULL; + if (bm->aiocb) { +#ifdef DEBUG_AIO + printf("aio_cancel\n"); +#endif + bdrv_aio_cancel(bm->aiocb); + bm->aiocb = NULL; + } + } +} + static void bmdma_cmd_writeb(void *opaque, uint32_t addr, uint32_t val) { BMDMAState *bm = opaque; @@ -2852,19 +2869,7 @@ #endif if (!(val & BM_CMD_START)) { /* XXX: do it better */ - if (bm->status & BM_STATUS_DMAING) { - bm->status &= ~BM_STATUS_DMAING; - /* cancel DMA request */ - bm->ide_if = NULL; - bm->dma_cb = NULL; - if (bm->aiocb) { -#ifdef DEBUG_AIO - printf("aio_cancel\n"); -#endif - bdrv_aio_cancel(bm->aiocb); - bm->aiocb = NULL; - } - } + ide_dma_cancel(bm); bm->cmd = val & 0x09; } else { if (!(bm->status & BM_STATUS_DMAING)) { @@ -3188,10 +3193,15 @@ return 0; } -static void piix3_reset(PCIIDEState *d) +static void piix3_reset(void *opaque) { + PCIIDEState *d = opaque; uint8_t *pci_conf = d->dev.config; + int i; + for (i = 0; i < 2; i++) + ide_dma_cancel(&d->bmdma[i]); + pci_conf[0x04] = 0x00; pci_conf[0x05] = 0x00; pci_conf[0x06] = 0x80; /* FBC */ @@ -3224,6 +3234,7 @@ pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage pci_conf[0x0e] = 0x00; // header_type + qemu_register_reset(piix3_reset, d); piix3_reset(d); pci_register_io_region((PCIDevice *)d, 4, 0x10, @@ -3262,6 +3273,7 @@ pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage pci_conf[0x0e] = 0x00; // header_type + qemu_register_reset(piix3_reset, d); piix3_reset(d); pci_register_io_region((PCIDevice *)d, 4, 0x10,