From patchwork Fri May 28 18:01:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 53947 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 91141B6EFF for ; Sat, 29 May 2010 04:19:56 +1000 (EST) Received: from localhost ([127.0.0.1]:59852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OI49N-0006JC-OO for incoming@patchwork.ozlabs.org; Fri, 28 May 2010 14:19:17 -0400 Received: from [140.186.70.92] (port=52029 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OI3tu-0007DN-Em for qemu-devel@nongnu.org; Fri, 28 May 2010 14:03:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OI3sZ-0002UQ-01 for qemu-devel@nongnu.org; Fri, 28 May 2010 14:01:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27624) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OI3sY-0002U7-KC for qemu-devel@nongnu.org; Fri, 28 May 2010 14:01:54 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4SI1qjx009540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 May 2010 14:01:52 -0400 Received: from localhost.localdomain (vpn1-4-101.ams2.redhat.com [10.36.4.101]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4SI1m6A000489; Fri, 28 May 2010 14:01:51 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 28 May 2010 20:01:27 +0200 Message-Id: <1275069692-5756-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1275069692-5756-1-git-send-email-kwolf@redhat.com> References: <1275069692-5756-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [STABLE PATCH 1/6] ide: Fix ide_dma_cancel 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 When cancelling a request, bdrv_aio_cancel may decide that it waits for completion of a request rather than for cancellation. IDE therefore can't abandon its DMA status before calling bdrv_aio_cancel; otherwise the callback of a completed request would use invalid data. Signed-off-by: Kevin Wolf (cherry picked from commit 38d8dfa193e9a45f0f08b06aab2ba2a94f40a041) --- hw/ide/core.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 64aebc2..f9bb338 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2827,10 +2827,6 @@ static void ide_dma_restart(IDEState *s, int is_read) void ide_dma_cancel(BMDMAState *bm) { if (bm->status & BM_STATUS_DMAING) { - bm->status &= ~BM_STATUS_DMAING; - /* cancel DMA request */ - bm->unit = -1; - bm->dma_cb = NULL; if (bm->aiocb) { #ifdef DEBUG_AIO printf("aio_cancel\n"); @@ -2838,6 +2834,10 @@ void ide_dma_cancel(BMDMAState *bm) bdrv_aio_cancel(bm->aiocb); bm->aiocb = NULL; } + bm->status &= ~BM_STATUS_DMAING; + /* cancel DMA request */ + bm->unit = -1; + bm->dma_cb = NULL; } }