From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60591 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhTfT-0000w7-Kf for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:09:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhTfR-0007Nt-3m for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:09:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhTfQ-0007Nf-Rx for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:09:41 -0500 From: Kevin Wolf Date: Mon, 24 Jan 2011 22:10:37 +0100 Message-Id: <1295903452-18017-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1295903452-18017-1-git-send-email-kwolf@redhat.com> References: <1295903452-18017-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 08/23] ide: kill ide_dma_submit_check List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Christoph Hellwig Merge ide_dma_submit_check into it's only caller. Also use tail recursion using a goto instead of a real recursion - this avoid overflowing the stack in the pathological situation of an recurring error that is ignored. We'll still be busy looping in ide_dma_cb, but at least won't eat up all stack space after this. Signed-off-by: Christoph Hellwig Signed-off-by: Kevin Wolf --- hw/ide/core.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 12b9c53..e698c13 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -321,14 +321,6 @@ static inline void ide_abort_command(IDEState *s) s->error = ABRT_ERR; } -static inline void ide_dma_submit_check(IDEState *s, - BlockDriverCompletionFunc *dma_cb) -{ - if (s->bus->dma->aiocb) - return; - dma_cb(s, -1); -} - /* prepare data transfer and tell what to do after */ static void ide_transfer_start(IDEState *s, uint8_t *buf, int size, EndTransferFunc *end_transfer_func) @@ -493,6 +485,7 @@ void ide_dma_cb(void *opaque, int ret) int n; int64_t sector_num; +handle_rw_error: if (ret < 0) { int op = BM_STATUS_DMA_RETRY; @@ -538,7 +531,11 @@ void ide_dma_cb(void *opaque, int ret) s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num, ide_dma_cb, s); } - ide_dma_submit_check(s, ide_dma_cb); + + if (!s->bus->dma->aiocb) { + ret = -1; + goto handle_rw_error; + } return; eot: -- 1.7.2.3