From patchwork Mon Feb 23 16:17:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 442590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 09EC31400EA for ; Tue, 24 Feb 2015 03:19:05 +1100 (AEDT) Received: from localhost ([::1]:44268 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPvip-00013l-4w for incoming@patchwork.ozlabs.org; Mon, 23 Feb 2015 11:19:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPvi7-0008Gh-8p for qemu-devel@nongnu.org; Mon, 23 Feb 2015 11:18:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPvhz-00052n-Qk for qemu-devel@nongnu.org; Mon, 23 Feb 2015 11:18:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPvhz-00052b-Fp for qemu-devel@nongnu.org; Mon, 23 Feb 2015 11:18:11 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1NGIAvt013810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 23 Feb 2015 11:18:10 -0500 Received: from scv.usersys.redhat.com (dhcp-17-161.bos.redhat.com [10.18.17.161]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1NGI84l023604; Mon, 23 Feb 2015 11:18:10 -0500 From: John Snow To: qemu-devel@nongnu.org Date: Mon, 23 Feb 2015 11:17:50 -0500 Message-Id: <1424708286-16483-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1424708286-16483-1-git-send-email-jsnow@redhat.com> References: <1424708286-16483-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow Subject: [Qemu-devel] [PATCH v4 01/17] ide: start extracting ide_restart_dma out of bmdma_restart_dma 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 From: Paolo Bonzini This patch begins refactoring the restart dma functions out of bmdma to be shared with AHCI and other future IDE HBA implementations. Signed-off-by: Paolo Bonzini Signed-off-by: John Snow --- hw/ide/pci.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index e3f2054..da3e392 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -184,18 +184,24 @@ static void bmdma_set_inactive(IDEDMA *dma, bool more) } } -static void bmdma_restart_dma(BMDMAState *bm, enum ide_dma_cmd dma_cmd) +static void bmdma_restart_dma(BMDMAState *bm) { IDEState *s = bmdma_active_if(bm); ide_set_sector(s, bm->sector_num); - s->io_buffer_index = 0; - s->io_buffer_size = 0; s->nsector = bm->nsector; - s->dma_cmd = dma_cmd; bm->cur_addr = bm->addr; - bm->dma_cb = ide_dma_cb; - bmdma_start_dma(&bm->dma, s, bm->dma_cb); +} + +static void ide_restart_dma(IDEState *s, enum ide_dma_cmd dma_cmd) +{ + BMDMAState *bm = DO_UPCAST(BMDMAState, dma, s->bus->dma); + + bmdma_restart_dma(bm); + s->io_buffer_index = 0; + s->io_buffer_size = 0; + s->dma_cmd = dma_cmd; + bmdma_start_dma(&bm->dma, s, ide_dma_cb); } /* TODO This should be common IDE code */ @@ -203,6 +209,7 @@ static void bmdma_restart_bh(void *opaque) { BMDMAState *bm = opaque; IDEBus *bus = bm->bus; + IDEState *s; bool is_read; int error_status; @@ -213,6 +220,7 @@ static void bmdma_restart_bh(void *opaque) return; } + s = bmdma_active_if(bm); is_read = (bus->error_status & IDE_RETRY_READ) != 0; /* The error status must be cleared before resubmitting the request: The @@ -223,18 +231,18 @@ static void bmdma_restart_bh(void *opaque) if (error_status & IDE_RETRY_DMA) { if (error_status & IDE_RETRY_TRIM) { - bmdma_restart_dma(bm, IDE_DMA_TRIM); + ide_restart_dma(s, IDE_DMA_TRIM); } else { - bmdma_restart_dma(bm, is_read ? IDE_DMA_READ : IDE_DMA_WRITE); + ide_restart_dma(s, is_read ? IDE_DMA_READ : IDE_DMA_WRITE); } } else if (error_status & IDE_RETRY_PIO) { if (is_read) { - ide_sector_read(bmdma_active_if(bm)); + ide_sector_read(s); } else { - ide_sector_write(bmdma_active_if(bm)); + ide_sector_write(s); } } else if (error_status & IDE_RETRY_FLUSH) { - ide_flush_cache(bmdma_active_if(bm)); + ide_flush_cache(s); } else { IDEState *s = bmdma_active_if(bm);