public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
* [git.ipfire.org] IPFire 2.x development tree branch, master, updated. ed4bbe44d121480e56c817f42f797423507c7630
@ 2018-12-11  7:01 Arne Fitzenreiter
  0 siblings, 0 replies; only message in thread
From: Arne Fitzenreiter @ 2018-12-11  7:01 UTC (permalink / raw)
  To: ipfire-scm

[-- Attachment #1: Type: text/plain, Size: 5864 bytes --]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".

The branch, master has been updated
       via  ed4bbe44d121480e56c817f42f797423507c7630 (commit)
      from  ede4314397661889ce05f6a9d4dcdd5cc88ffb40 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ed4bbe44d121480e56c817f42f797423507c7630
Author: Arne Fitzenreiter <arne_f(a)ipfire.org>
Date:   Mon Dec 10 20:45:54 2018 +0100

    kernel: fix dwc2 (usb) dma crashes on RPi1-3
    
    Signed-off-by: Arne Fitzenreiter <arne_f(a)ipfire.org>

-----------------------------------------------------------------------

Summary of changes:
 lfs/linux                                          |  3 +
 ...ux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch | 99 ++++++++++++++++++++++
 2 files changed, 102 insertions(+)
 create mode 100644 src/patches/linux/linux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch

Difference in files:
diff --git a/lfs/linux b/lfs/linux
index 0994e3e56..346378819 100644
--- a/lfs/linux
+++ b/lfs/linux
@@ -157,10 +157,13 @@ endif
 ifeq "$(KCFG)" "-multi"
 	# Apply Arm-multiarch kernel patches.
 	cd $(DIR_APP) && xzcat $(DIR_DL)/arm-multi-patches-$(ARM_PATCHES).patch.xz | patch -Np1
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch
+
 endif
 ifeq "$(BUILD_ARCH)" "aarch64"
 	# Apply Arm-multiarch kernel patches.
 	cd $(DIR_APP) && xzcat $(DIR_DL)/arm-multi-patches-$(ARM_PATCHES).patch.xz | patch -Np1
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch
 endif
 	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/linux-3.14.79-amba-fix.patch
 
diff --git a/src/patches/linux/linux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch b/src/patches/linux/linux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch
new file mode 100644
index 000000000..e4c8b9982
--- /dev/null
+++ b/src/patches/linux/linux-4.14-Revert-usb-dwc2-Fix-DMA-alignment.patch
@@ -0,0 +1,99 @@
+From a44147a09baf8c46cc0b02332df3a4656e0659d5 Mon Sep 17 00:00:00 2001
+From: Arne Fitzenreiter <arne_f(a)ipfire.org>
+Date: Mon, 10 Dec 2018 13:12:00 +0100
+Subject: [PATCH] Revert "usb: dwc2: Fix DMA alignment to start at allocated
+ boundary"
+
+This reverts commit 68fc92a0f3913d539d1ac68a861f895e34099e46.
+---
+ drivers/usb/dwc2/hcd.c | 44 +++++++++++++++++++++-----------------------
+ 1 file changed, 21 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
+index fa20ec4..4b81d08 100644
+--- a/drivers/usb/dwc2/hcd.c
++++ b/drivers/usb/dwc2/hcd.c
+@@ -2644,29 +2644,34 @@ static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
+ 
+ #define DWC2_USB_DMA_ALIGN 4
+ 
++struct dma_aligned_buffer {
++	void *kmalloc_ptr;
++	void *old_xfer_buffer;
++	u8 data[0];
++};
++
+ static void dwc2_free_dma_aligned_buffer(struct urb *urb)
+ {
+-	void *stored_xfer_buffer;
++	struct dma_aligned_buffer *temp;
+ 
+ 	if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
+ 		return;
+ 
+-	/* Restore urb->transfer_buffer from the end of the allocated area */
+-	memcpy(&stored_xfer_buffer, urb->transfer_buffer +
+-	       urb->transfer_buffer_length, sizeof(urb->transfer_buffer));
++	temp = container_of(urb->transfer_buffer,
++			    struct dma_aligned_buffer, data);
+ 
+ 	if (usb_urb_dir_in(urb))
+-		memcpy(stored_xfer_buffer, urb->transfer_buffer,
++		memcpy(temp->old_xfer_buffer, temp->data,
+ 		       urb->transfer_buffer_length);
+-	kfree(urb->transfer_buffer);
+-	urb->transfer_buffer = stored_xfer_buffer;
++	urb->transfer_buffer = temp->old_xfer_buffer;
++	kfree(temp->kmalloc_ptr);
+ 
+ 	urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
+ }
+ 
+ static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
+ {
+-	void *kmalloc_ptr;
++	struct dma_aligned_buffer *temp, *kmalloc_ptr;
+ 	size_t kmalloc_size;
+ 
+ 	if (urb->num_sgs || urb->sg ||
+@@ -2674,29 +2679,22 @@ static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
+ 	    !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
+ 		return 0;
+ 
+-	/*
+-	 * Allocate a buffer with enough padding for original transfer_buffer
+-	 * pointer. This allocation is guaranteed to be aligned properly for
+-	 * DMA
+-	 */
++	/* Allocate a buffer with enough padding for alignment */
+ 	kmalloc_size = urb->transfer_buffer_length +
+-		sizeof(urb->transfer_buffer);
++		sizeof(struct dma_aligned_buffer) + DWC2_USB_DMA_ALIGN - 1;
+ 
+ 	kmalloc_ptr = kmalloc(kmalloc_size, mem_flags);
+ 	if (!kmalloc_ptr)
+ 		return -ENOMEM;
+ 
+-	/*
+-	 * Position value of original urb->transfer_buffer pointer to the end
+-	 * of allocation for later referencing
+-	 */
+-	memcpy(kmalloc_ptr + urb->transfer_buffer_length,
+-	       &urb->transfer_buffer, sizeof(urb->transfer_buffer));
+-
++	/* Position our struct dma_aligned_buffer such that data is aligned */
++	temp = PTR_ALIGN(kmalloc_ptr + 1, DWC2_USB_DMA_ALIGN) - 1;
++	temp->kmalloc_ptr = kmalloc_ptr;
++	temp->old_xfer_buffer = urb->transfer_buffer;
+ 	if (usb_urb_dir_out(urb))
+-		memcpy(kmalloc_ptr, urb->transfer_buffer,
++		memcpy(temp->data, urb->transfer_buffer,
+ 		       urb->transfer_buffer_length);
+-	urb->transfer_buffer = kmalloc_ptr;
++	urb->transfer_buffer = temp->data;
+ 
+ 	urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;
+ 
+-- 
+2.7.4
+


hooks/post-receive
--
IPFire 2.x development tree

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-11  7:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11  7:01 [git.ipfire.org] IPFire 2.x development tree branch, master, updated. ed4bbe44d121480e56c817f42f797423507c7630 Arne Fitzenreiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox