Skip to content

Commit

Permalink
usb: musb: fix inefficient copy of unaligned buffers
Browse files Browse the repository at this point in the history
Make sure only to copy any actual data rather than the whole buffer,
when releasing the temporary buffer used for unaligned non-isochronous
transfers.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Johan Hovold authored and Felipe Balbi committed Apr 27, 2015
1 parent 2d9c7f3 commit d72348f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/usb/musb/musb_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,7 @@ static void musb_free_temp_buffer(struct urb *urb)
{
enum dma_data_direction dir;
struct musb_temp_buffer *temp;
size_t length;

if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
return;
Expand All @@ -2522,8 +2523,12 @@ static void musb_free_temp_buffer(struct urb *urb)
data);

if (dir == DMA_FROM_DEVICE) {
memcpy(temp->old_xfer_buffer, temp->data,
urb->transfer_buffer_length);
if (usb_pipeisoc(urb->pipe))
length = urb->transfer_buffer_length;
else
length = urb->actual_length;

memcpy(temp->old_xfer_buffer, temp->data, length);
}
urb->transfer_buffer = temp->old_xfer_buffer;
kfree(temp->kmalloc_ptr);
Expand Down

0 comments on commit d72348f

Please sign in to comment.