From patchwork Wed Jun 15 13:43:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 100519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 13972B6F9E for ; Wed, 15 Jun 2011 23:44:12 +1000 (EST) Received: from localhost ([::1]:52236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWqO8-00075f-Jz for incoming@patchwork.ozlabs.org; Wed, 15 Jun 2011 09:44:08 -0400 Received: from eggs.gnu.org ([140.186.70.92]:38477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWqKU-000751-Sg for qemu-devel@nongnu.org; Wed, 15 Jun 2011 09:40:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWqKK-00016N-Ty for qemu-devel@nongnu.org; Wed, 15 Jun 2011 09:40:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWqKK-00015y-AP for qemu-devel@nongnu.org; Wed, 15 Jun 2011 09:40:12 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5FDeB6l016499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 Jun 2011 09:40:11 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5FDeAWB015513; Wed, 15 Jun 2011 09:40:10 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 15 Jun 2011 15:43:03 +0200 Message-Id: <1308145383-18232-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH v2] ide: Clear error_status after restarting flush X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Clearing the error status flag was missing for restarting flushes. Now that the error status is separate from the BM status register, we can simply set it to 0 after restarting the request. This ensures that we never forget to clear a bit. Signed-off-by: Kevin Wolf --- hw/ide/pci.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index c940375..9f3050a 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -189,6 +189,7 @@ static void bmdma_restart_bh(void *opaque) BMDMAState *bm = opaque; IDEBus *bus = bm->bus; int is_read; + int error_status; qemu_bh_delete(bm->bh); bm->bh = NULL; @@ -199,22 +200,25 @@ static void bmdma_restart_bh(void *opaque) is_read = !!(bus->error_status & BM_STATUS_RETRY_READ); - if (bus->error_status & BM_STATUS_DMA_RETRY) { - if (bus->error_status & BM_STATUS_RETRY_TRIM) { - bus->error_status &= ~BM_STATUS_RETRY_TRIM; + /* The error status must be cleared before resubmitting the request: The + * request may fail again, and this case can only be distinguished if the + * called function can set a new error status. */ + error_status = bus->error_status; + bus->error_status = 0; + + if (error_status & BM_STATUS_DMA_RETRY) { + if (error_status & BM_STATUS_RETRY_TRIM) { bmdma_restart_dma(bm, IDE_DMA_TRIM); } else { - bus->error_status &= ~(BM_STATUS_DMA_RETRY | BM_STATUS_RETRY_READ); bmdma_restart_dma(bm, is_read ? IDE_DMA_READ : IDE_DMA_WRITE); } - } else if (bus->error_status & BM_STATUS_PIO_RETRY) { - bus->error_status &= ~(BM_STATUS_PIO_RETRY | BM_STATUS_RETRY_READ); + } else if (error_status & BM_STATUS_PIO_RETRY) { if (is_read) { ide_sector_read(bmdma_active_if(bm)); } else { ide_sector_write(bmdma_active_if(bm)); } - } else if (bus->error_status & BM_STATUS_RETRY_FLUSH) { + } else if (error_status & BM_STATUS_RETRY_FLUSH) { ide_flush_cache(bmdma_active_if(bm)); } }