From patchwork Mon Oct 28 16:43:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 286609 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D61B62C0085 for ; Tue, 29 Oct 2013 03:53:12 +1100 (EST) Received: from localhost ([::1]:42239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vaq3y-0003jQ-Om for incoming@patchwork.ozlabs.org; Mon, 28 Oct 2013 12:53:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VapvV-0007py-TS for qemu-devel@nongnu.org; Mon, 28 Oct 2013 12:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VapvN-0000Sa-B0 for qemu-devel@nongnu.org; Mon, 28 Oct 2013 12:44:25 -0400 Received: from mail-qa0-x232.google.com ([2607:f8b0:400d:c00::232]:56467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VapvN-0000SU-7G for qemu-devel@nongnu.org; Mon, 28 Oct 2013 12:44:17 -0400 Received: by mail-qa0-f50.google.com with SMTP id cm18so2238566qab.2 for ; Mon, 28 Oct 2013 09:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ppwGLpSsjpX3NOe7hBCpoSZdOoklFMiNeiv0+Q+xmC4=; b=J9kx45lEGivRLPeQWsqCw4VhTytb5a38zxPNmo4I9ryu6FSBOYjD8aFFp7c76vrm9L CxokHTPiTegzSHxeZeNOs5DFTo0kmHxDLnA0CFyoY3VcAMIVEx1YTyiPl3WDTDBE/x07 NbSDXo3Ip24sAeoWHRX2rPyzYXPEc29fQZevVeOC2tdYZsNvfxebvysoDhwmse/AxyxI DLeqlu2Dylv4TORgErGX70Nu1R2kvzhyyEAy8OlNICHwpl8AiFHznq0kT11HsH+WS/UE 3JcM4HfLZrdInqpZYM5C0uwkzpjvvgVQMVpQL6+U5EgRnGxJNvKSfQnVrf9ttWZPjgWJ ajgg== X-Received: by 10.229.16.137 with SMTP id o9mr30489282qca.0.1382978656824; Mon, 28 Oct 2013 09:44:16 -0700 (PDT) Received: from yakj.usersys.redhat.com (net-37-117-137-113.cust.dsl.vodafone.it. [37.117.137.113]) by mx.google.com with ESMTPSA id x1sm54751857qai.6.2013.10.28.09.44.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Oct 2013 09:44:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 28 Oct 2013 17:43:30 +0100 Message-Id: <1382978620-16641-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1382978620-16641-1-git-send-email-pbonzini@redhat.com> References: <1382978620-16641-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::232 Cc: mst@redhat.com Subject: [Qemu-devel] [PATCH 14/24] 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 Signed-off-by: Paolo Bonzini --- hw/ide/pci.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index cc910de..c7fbe51 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -175,18 +175,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->nsector = bm->nsector; + bm->cur_addr = bm->addr; +} + +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->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); + bmdma_start_dma(&bm->dma, s, ide_dma_cb); } /* TODO This should be common IDE code */ @@ -194,6 +200,7 @@ static void bmdma_restart_bh(void *opaque) { BMDMAState *bm = opaque; IDEBus *bus = bm->bus; + IDEState *s; bool is_read; int error_status; @@ -204,6 +211,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 @@ -214,18 +222,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); } }