From mboxrd@z Thu Jan 1 00:00:00 1970 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) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 6 Dec 2011 12:01:25 +0100 Message-Id: <1323169292-21661-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1323169292-21661-1-git-send-email-pbonzini@redhat.com> References: <1323169292-21661-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 04/11] dma-helpers: add accounting wrappers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@linux.vnet.ibm.com 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); -- 1.7.7.1