From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZSog-0006lj-Iz for qemu-devel@nongnu.org; Wed, 01 Oct 2014 18:56:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XZSoV-0001AE-M3 for qemu-devel@nongnu.org; Wed, 01 Oct 2014 18:56:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZSoV-0001AA-DT for qemu-devel@nongnu.org; Wed, 01 Oct 2014 18:56:03 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s91Mu2mW028885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 1 Oct 2014 18:56:02 -0400 From: John Snow Date: Wed, 1 Oct 2014 18:55:49 -0400 Message-Id: <1412204151-18117-5-git-send-email-jsnow@redhat.com> In-Reply-To: <1412204151-18117-1-git-send-email-jsnow@redhat.com> References: <1412204151-18117-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 4/6] ahci: unify sglist preparation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow The intent of this patch is to further unify the creation and deletion of the sglist used for all AHCI transfers, including emulated PIO, ATAPI R/W, and native DMA R/W. By replacing ahci_start_transfer's call to ahci_populate_sglist with ahci_dma_prepare_buf, we reduce the number of direct calls where we manipulate the scatter-gather list in the AHCI code. To make this switch, the constant "0" passed as an offset in ahci_dma_prepare_buf is adjusted to use io_buffer_offset. For DMA pathways, this has no effect: io_buffer_offset is always updated to 0 at the beginning of a DMA transfer loop regardless. DMA pathways through ide_dma_cb() update the io_buffer_offset accordingly, and for circumstances where we might make several trips through this loop, this may actually correct a design flaw. For PIO pathways, the newly updated ahci_dma_prepare_buf will now prepare the sglist at the correct offset. It will also set io_buffer_size, but this is not used in the cmd_read_pio or cmd_write_pio pathways. Signed-off-by: John Snow --- hw/ide/ahci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index db1d226..16cd248 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1091,7 +1091,7 @@ static void ahci_start_transfer(IDEDMA *dma) goto out; } - if (!ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset)) { + if (ahci_dma_prepare_buf(dma, is_write)) { has_sglist = 1; } @@ -1143,7 +1143,7 @@ static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write) AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); IDEState *s = &ad->port.ifs[0]; - ahci_populate_sglist(ad, &s->sg, 0); + ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset); s->io_buffer_size = s->sg.size; DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size); -- 1.9.3