From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JfykC-0004Df-4v for qemu-devel@nongnu.org; Sun, 30 Mar 2008 10:42:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JfykA-0004DT-Cc for qemu-devel@nongnu.org; Sun, 30 Mar 2008 10:42:46 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JfykA-0004DQ-5v for qemu-devel@nongnu.org; Sun, 30 Mar 2008 10:42:46 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jfyk9-0000i9-Op for qemu-devel@nongnu.org; Sun, 30 Mar 2008 10:42:45 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e35.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m2UEgicL004705 for ; Sun, 30 Mar 2008 10:42:44 -0400 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m2UEgiZf178574 for ; Sun, 30 Mar 2008 08:42:44 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m2UEghJA017197 for ; Sun, 30 Mar 2008 08:42:43 -0600 Message-ID: <47EFA6E1.7020401@us.ibm.com> Date: Sun, 30 Mar 2008 09:42:41 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/6] PCI DMA API References: <1206827760-4566-1-git-send-email-aliguori@us.ibm.com> <1206827760-4566-2-git-send-email-aliguori@us.ibm.com> <200803301118.15663.paul@codesourcery.com> In-Reply-To: <200803301118.15663.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: kvm-devel@lists.sourceforge.net, Marcelo Tosatti , qemu-devel@nongnu.org, Aurelien Jarno Paul Brook wrote: > On Saturday 29 March 2008, Anthony Liguori wrote: > >> This patch introduces a PCI DMA API and some generic code to support other >> DMA APIs. Two types are introduced: PhysIOVector and IOVector. A DMA API >> maps a PhysIOVector, which is composed of target_phys_addr_t, into an >> IOVector, which is composed of void *. >> > > Devices should not be using IOVector. They should either use the DMA copy > routines to copy from a PhysIOVector into a local buffer, or they should pass > a PhysIOVector to a block/network read/write routine. The DMA API should > allow devices to be agnostic about how DMA is implemented. They should not be > trying to manually implement zero copy. > Someone has to do the translation of PhysIOVector => IOVector. It doesn't seem logical to me to do it in the IO backend level because the block subsystem doesn't know how to do that translation. You would have to pass the PhysIOVector although with a translation function and an opaque pointer. What could work is if the DMA API functions mapped PhysIOVector => PhysIOVector and then the network and block subsystems could operate on a PhysIOVector. I have patches that implement vector IO for net and block but didn't want to include them in this series to keep things simple. >> This enables zero-copy IO to be preformed without introducing assumptions >> of phys_ram_base. This API is at the PCI device level to enable support of >> per-device IOMMU remapping. >> > > By my reading it *requires* bridges be zero-copy. For big-endian targets we > need to ability to byteswap accesses. > You mean via ld/st_phys? I can add a set of ld/st_vec functions (and even use them in hw/virtio.c). I think operating on a translated vec is the right thing to do as it avoids the translation to be cached. To make ld/st_phys just work, we would have to have some sort of global DMA context. That gets tricky for drivers that use timer callbacks. > Some description (in the form of source comments) of how it's meant to be used > would also be helpful. > Will do for the next round. Thanks, Anthony Liguori > Paul >