• D
    usb: Fix usb_packet_map() in the presence of IOMMUs · 39c138c8
    David Gibson 提交于
    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
    Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
    Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
    39c138c8
libhw.c 2.3 KB