summaryrefslogtreecommitdiff
path: root/target/linux/generic/pending-4.14/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/generic/pending-4.14/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch')
-rw-r--r--target/linux/generic/pending-4.14/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/target/linux/generic/pending-4.14/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch b/target/linux/generic/pending-4.14/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch
new file mode 100644
index 0000000..78e6a7e
--- /dev/null
+++ b/target/linux/generic/pending-4.14/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch
@@ -0,0 +1,50 @@
+From 81da1738eee68f1961e03bdeb2d60cf0eb4dd713 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= <a.seppala@gmail.com>
+Date: Thu, 5 Jul 2018 12:06:18 +0300
+Subject: [PATCH 2/2] usb: dwc2: Fix inefficient copy of unaligned buffers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Make sure only to copy any actual data rather than the whole buffer,
+when releasing the temporary buffer used for unaligned non-isochronous
+transfers.
+
+Taken directly from commit 0efd937e27d5e ("USB: ehci-tegra: fix inefficient
+copy of unaligned buffers")
+
+Tested with Lantiq xRX200 (MIPS) and RPi Model B Rev 2 (ARM)
+
+Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
+---
+ drivers/usb/dwc2/hcd.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+--- a/drivers/usb/dwc2/hcd.c
++++ b/drivers/usb/dwc2/hcd.c
+@@ -2631,6 +2631,7 @@ static void dwc2_hc_init_xfer(struct dwc
+ static void dwc2_free_dma_aligned_buffer(struct urb *urb)
+ {
+ void *stored_xfer_buffer;
++ size_t length;
+
+ if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
+ return;
+@@ -2639,9 +2640,14 @@ static void dwc2_free_dma_aligned_buffer
+ memcpy(&stored_xfer_buffer, urb->transfer_buffer +
+ urb->transfer_buffer_length, sizeof(urb->transfer_buffer));
+
+- if (usb_urb_dir_in(urb))
+- memcpy(stored_xfer_buffer, urb->transfer_buffer,
+- urb->transfer_buffer_length);
++ if (usb_urb_dir_in(urb)) {
++ if (usb_pipeisoc(urb->pipe))
++ length = urb->transfer_buffer_length;
++ else
++ length = urb->actual_length;
++
++ memcpy(stored_xfer_buffer, urb->transfer_buffer, length);
++ }
+ kfree(urb->transfer_buffer);
+ urb->transfer_buffer = stored_xfer_buffer;
+