From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:32888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGlAg-0000YY-0O for qemu-devel@nongnu.org; Wed, 26 Sep 2012 02:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGlAf-0002X3-0v for qemu-devel@nongnu.org; Wed, 26 Sep 2012 02:32:33 -0400 Message-ID: <5062A17A.9070401@redhat.com> Date: Wed, 26 Sep 2012 08:32:26 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1348628371-6828-1-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1348628371-6828-1-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] usb: Fix usb_packet_map() in the presence of IOMMUs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org On 09/26/12 04:59, David Gibson wrote: > With the IOMMU infrastructure introduced before 1.2, we need to use > dma_memory_map() to obtain a qemu pointer to memory from an IO bus address. > However, dma_memory_map() alters the given length to reflect the length > over which the used DMA translation is valid - which could be either more > or less than the requested length. > > usb_packet_map() does not correctly handle these cases, simply failing if > dma_memory_map() alters the requested length. If dma_memory_map() > increased the length, we just need to use the requested length for the > qemu_iovec_add(). However, if it decreased the length, it means that a > single DMA translation is not valid for the whole sglist element, and so > we need to loop, splitting it up into multiple iovec entries for each > piece with a DMA translation (in practice >2 pieces is unlikely). > > This patch implements the correct behaviour Patch added to usb patch queue. thanks, Gerd