From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrVK7-0004To-Ek for qemu-devel@nongnu.org; Thu, 11 Aug 2011 09:29:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrVK4-0002hz-Sq for qemu-devel@nongnu.org; Thu, 11 Aug 2011 09:29:23 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:58177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrVK4-0002hv-Nr for qemu-devel@nongnu.org; Thu, 11 Aug 2011 09:29:20 -0400 Received: by gxk26 with SMTP id 26so1571629gxk.4 for ; Thu, 11 Aug 2011 06:29:20 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4E43C6CE.9070008@redhat.com> References: <1312478089-806-1-git-send-email-pbonzini@redhat.com> <1312478089-806-6-git-send-email-pbonzini@redhat.com> <20110811075836.GB29542@stefanha-thinkpad.localdomain> <4E43C6CE.9070008@redhat.com> Date: Thu, 11 Aug 2011 14:29:19 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 05/10] dma-helpers: add dma_buf_read and dma_buf_write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-devel@nongnu.org On Thu, Aug 11, 2011 at 1:10 PM, Paolo Bonzini wrote: > On 08/11/2011 09:58 AM, Stefan Hajnoczi wrote: >> >> On Thu, Aug 04, 2011 at 07:14:43PM +0200, Paolo Bonzini wrote: >>> >>> These helpers do a full transfer from an in-memory buffer to >>> target memory, with full support for MMIO areas. =A0It will be used to >>> store >>> the reply of an emulated command into a QEMUSGList provided by the >>> adapter. >>> >>> Signed-off-by: Paolo Bonzini >>> --- >>> =A0cutils.c =A0 =A0 =A0| =A0 =A08 +++--- >>> =A0dma-helpers.c | =A0 63 >>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >>> =A0dma.h =A0 =A0 =A0 =A0 | =A0 =A05 ++++ >>> =A03 files changed, 72 insertions(+), 4 deletions(-) >> >> I don't understand this patch. =A0If we have a memory buffer that needs = to >> be transferred to target memory, then there is no need for bounce >> buffers or cpu_physical_memory_map(). >> >> Can we use cpu_physical_memory_rw() on each sglist element instead? =A0N= o >> -EAGAIN necessary because the memory buffer already acts as the local >> bounce buffer. > > Doh, you're obviously right. =A0I don't know what I was thinking. :) > > What do you think about passing the residual bytes for short transfers? > =A0Should I look into updating BlockDriverCompletionFunc, or is the appro= ach > of patch 2 okay? =A0If I have an excuse to learn more about Coccinelle, t= hat > can be fun. :) The bdrv_aio_readv() and bdrv_aio_writev() functions don't have the concept of residual bytes. They only work on fully completed I/O operations. If there is an error they pass -errno. Therefore I don't think BlockDriverCompletionFunc is the right type to add residual bytes to. It seems that residual bytes are a SCSI layer concept that the block layer does not deal with. Stefan