• Henry Lin's avatar
    xhci: update bounce buffer with correct sg num · 597c56e3
    Henry Lin authored
    This change fixes a data corruption issue occurred on USB hard disk for
    the case that bounce buffer is used during transferring data.
    
    While updating data between sg list and bounce buffer, current
    implementation passes mapped sg number (urb->num_mapped_sgs) to
    sg_pcopy_from_buffer() and sg_pcopy_to_buffer(). This causes data
    not get copied if target buffer is located in the elements after
    mapped sg elements. This change passes sg number for full list to
    fix issue.
    
    Besides, for copying data from bounce buffer, calling dma_unmap_single()
    on the bounce buffer before copying data to sg list can avoid cache issue.
    
    Fixes: f9c589e1 ("xhci: TD-fragment, align the unsplittable case with a bounce buffer")
    Cc: <stable@vger.kernel.org> # v4.8+
    Signed-off-by: default avatarHenry Lin <henryl@nvidia.com>
    Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    597c56e3
xhci-ring.c 124 KB