From patchwork Mon Dec 20 12:46:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 76203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 67946B7080 for ; Mon, 20 Dec 2010 23:50:00 +1100 (EST) Received: from localhost ([127.0.0.1]:41374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUfBd-00006W-Jh for incoming@patchwork.ozlabs.org; Mon, 20 Dec 2010 07:49:57 -0500 Received: from [140.186.70.92] (port=38899 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUf8E-00078z-SP for qemu-devel@nongnu.org; Mon, 20 Dec 2010 07:46:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PUf7y-0007zF-LQ for qemu-devel@nongnu.org; Mon, 20 Dec 2010 07:46:24 -0500 Received: from verein.lst.de ([213.95.11.210]:38325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PUf7y-0007z2-Bt for qemu-devel@nongnu.org; Mon, 20 Dec 2010 07:46:10 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id oBKCk9E5006451 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 20 Dec 2010 13:46:09 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id oBKCk92L006450 for qemu-devel@nongnu.org; Mon, 20 Dec 2010 13:46:09 +0100 Date: Mon, 20 Dec 2010 13:46:09 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20101220124609.GB6423@lst.de> References: <20101220124548.GA6395@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101220124548.GA6395@lst.de> User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 3/3] ide: kill ide_dma_submit_check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Index: qemu/hw/ide/core.c =================================================================== --- qemu.orig/hw/ide/core.c 2010-12-20 13:16:11.379004054 +0100 +++ qemu/hw/ide/core.c 2010-12-20 13:16:11.000000000 +0100 @@ -321,14 +321,6 @@ static inline void ide_abort_command(IDE 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: