From patchwork Wed Dec 17 01:36:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 422152 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 EB4A31400D2 for ; Wed, 17 Dec 2014 12:41:37 +1100 (AEDT) Received: from localhost ([::1]:47515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13cO-00085p-3X for incoming@patchwork.ozlabs.org; Tue, 16 Dec 2014 20:41:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13Xh-0007ub-5u for qemu-devel@nongnu.org; Tue, 16 Dec 2014 20:36:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y13Xa-0002Wi-SM for qemu-devel@nongnu.org; Tue, 16 Dec 2014 20:36:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35735) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13Xa-0002WX-JP for qemu-devel@nongnu.org; Tue, 16 Dec 2014 20:36:38 -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 sBH1acpT014082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 16 Dec 2014 20:36:38 -0500 Received: from scv.usersys.redhat.com ([10.18.17.51]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBH1aQcl016670; Tue, 16 Dec 2014 20:36:37 -0500 From: John Snow To: qemu-devel@nongnu.org Date: Tue, 16 Dec 2014 20:36:01 -0500 Message-Id: <1418780167-16231-12-git-send-email-jsnow@redhat.com> In-Reply-To: <1418780167-16231-1-git-send-email-jsnow@redhat.com> References: <1418780167-16231-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 v2 11/17] ide: commonize io_buffer_index initialization 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 Resetting the io_buffer_index to 0 is commonized, with the exception of the case within ide_atapi_cmd_reply, where we need to reset this index to 0 prior to the ide_atapi_cmd_reply_end call. Note that not all calls to ide_atapi_cmd_reply_end expect the index to be 0, so setting it there is not appropriate. Signed-off-by: Paolo Bonzini Signed-off-by: John Snow --- hw/ide/atapi.c | 3 +-- hw/ide/core.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index c63b7e5..ef620e8 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -252,7 +252,6 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size) s->packet_transfer_size = size; s->io_buffer_size = size; /* dma: send the reply data as one chunk */ s->elementary_transfer_size = 0; - s->io_buffer_index = 0; if (s->atapi_dma) { block_acct_start(blk_get_stats(s->blk), &s->acct, size, @@ -261,6 +260,7 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size) ide_start_dma(s, ide_atapi_cmd_read_dma_cb); } else { s->status = READY_STAT | SEEK_STAT; + s->io_buffer_index = 0; ide_atapi_cmd_reply_end(s); } } @@ -368,7 +368,6 @@ static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors, { s->lba = lba; s->packet_transfer_size = nb_sectors * sector_size; - s->io_buffer_index = 0; s->io_buffer_size = 0; s->cd_sector_size = sector_size; diff --git a/hw/ide/core.c b/hw/ide/core.c index 0459ea1..b89cde0 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -780,7 +780,6 @@ eot: static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd) { s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT; - s->io_buffer_index = 0; s->io_buffer_size = 0; s->dma_cmd = dma_cmd; @@ -802,6 +801,7 @@ static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd) void ide_start_dma(IDEState *s, BlockCompletionFunc *cb) { + s->io_buffer_index = 0; s->bus->retry_unit = s->unit; s->bus->retry_sector_num = ide_get_sector(s); s->bus->retry_nsector = s->nsector; @@ -2341,7 +2341,6 @@ static void ide_restart_dma(IDEState *s, enum ide_dma_cmd dma_cmd) ide_set_sector(s, s->bus->retry_sector_num); s->nsector = s->bus->retry_nsector; s->bus->dma->ops->restart_dma(s->bus->dma); - s->io_buffer_index = 0; s->io_buffer_size = 0; s->dma_cmd = dma_cmd; ide_start_dma(s, ide_dma_cb);