From patchwork Tue Dec 6 11:01:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 129613 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 B67C71007D7 for ; Tue, 6 Dec 2011 22:02:27 +1100 (EST) Received: from localhost ([::1]:51521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXsmv-0002oJ-K7 for incoming@patchwork.ozlabs.org; Tue, 06 Dec 2011 06:02:17 -0500 Received: from eggs.gnu.org ([140.186.70.92]:41077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXsmh-0002YW-D4 for qemu-devel@nongnu.org; Tue, 06 Dec 2011 06:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXsmZ-0005MN-NA for qemu-devel@nongnu.org; Tue, 06 Dec 2011 06:02:03 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:56351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXsmZ-0005L0-Iq for qemu-devel@nongnu.org; Tue, 06 Dec 2011 06:01:55 -0500 Received: by mail-iy0-f173.google.com with SMTP id k32so11725126iak.4 for ; Tue, 06 Dec 2011 03:01:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ESC4T4MwD8YH36IbJp5cu5SPFVhdnSYRGepuL+nEbhQ=; b=NitFUP4dxkUraVMNWV/sJvgmFeSZ1c6CtxT5kLp97Lwq3qID66NMhP4G2rXm68ka1R Ble8fM/KrnFYTjzFhO91uL3aLGUJMKFG6+2tSPdopkWv4g5KV76614EF0jzQkt2EHbCK UL3/ZGE04BuLxFddvLnlzWlQE8VZvgVU/F9FE= Received: by 10.43.50.67 with SMTP id vd3mr13674041icb.10.1323169315333; Tue, 06 Dec 2011 03:01:55 -0800 (PST) Received: from localhost.localdomain (93-34-178-147.ip50.fastwebnet.it. [93.34.178.147]) by mx.google.com with ESMTPS id a2sm48932443igj.7.2011.12.06.03.01.53 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 06 Dec 2011 03:01:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Dec 2011 12:01:25 +0100 Message-Id: <1323169292-21661-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.1 In-Reply-To: <1323169292-21661-1-git-send-email-pbonzini@redhat.com> References: <1323169292-21661-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.173 Cc: stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 04/11] dma-helpers: add accounting wrappers 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 The length of the transfer is already in the sglist, so add a wrapper that fetches it. Signed-off-by: Paolo Bonzini --- dma-helpers.c | 6 ++++++ dma.h | 3 +++ hw/ide/ahci.c | 10 ++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dma-helpers.c b/dma-helpers.c index f53a51f..a773489 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -234,3 +234,9 @@ uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg) { return dma_buf_rw(ptr, len, sg, 1); } + +void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, + QEMUSGList *sg, enum BlockAcctType type) +{ + bdrv_acct_start(bs, cookie, sg->size, type); +} diff --git a/dma.h b/dma.h index 346ac4f..20e86d2 100644 --- a/dma.h +++ b/dma.h @@ -61,4 +61,7 @@ BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg); uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); +void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, + QEMUSGList *sg, enum BlockAcctType type); + #endif diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 0af201d..28f32cc 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -794,9 +794,8 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis, DPRINTF(port, "tag %d aio read %"PRId64"\n", ncq_tfs->tag, ncq_tfs->lba); - bdrv_acct_start(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct, - (ncq_tfs->sector_count-1) * BDRV_SECTOR_SIZE, - BDRV_ACCT_READ); + dma_acct_start(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct, + &ncq_tfs->sglist, BDRV_ACCT_READ); ncq_tfs->aiocb = dma_bdrv_read(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->sglist, ncq_tfs->lba, ncq_cb, ncq_tfs); @@ -808,9 +807,8 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis, DPRINTF(port, "tag %d aio write %"PRId64"\n", ncq_tfs->tag, ncq_tfs->lba); - bdrv_acct_start(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct, - (ncq_tfs->sector_count-1) * BDRV_SECTOR_SIZE, - BDRV_ACCT_WRITE); + dma_acct_start(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct, + &ncq_tfs->sglist, BDRV_ACCT_WRITE); ncq_tfs->aiocb = dma_bdrv_write(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->sglist, ncq_tfs->lba, ncq_cb, ncq_tfs);