summaryrefslogtreecommitdiffstats
path: root/debian/patches/bugfix/all/usb-host-ohci-sm501-init-genalloc-for-local-memory.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/bugfix/all/usb-host-ohci-sm501-init-genalloc-for-local-memory.patch')
-rw-r--r--debian/patches/bugfix/all/usb-host-ohci-sm501-init-genalloc-for-local-memory.patch105
1 files changed, 105 insertions, 0 deletions
diff --git a/debian/patches/bugfix/all/usb-host-ohci-sm501-init-genalloc-for-local-memory.patch b/debian/patches/bugfix/all/usb-host-ohci-sm501-init-genalloc-for-local-memory.patch
new file mode 100644
index 000000000..39d46e009
--- /dev/null
+++ b/debian/patches/bugfix/all/usb-host-ohci-sm501-init-genalloc-for-local-memory.patch
@@ -0,0 +1,105 @@
+From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
+Date: Wed, 29 May 2019 13:28:41 +0300
+Subject: usb: host: ohci-sm501: init genalloc for local memory
+Origin: https://git.kernel.org/linus/7d9e6f5aebe8c03f1a5199ca5c30f0c53042af23
+
+In preparation for dropping the existing "coherent" dma mem declaration
+APIs, replace the current dma_declare_coherent_memory() based mechanism
+with the creation of a genalloc pool that will be used in the OHCI
+subsystem as replacement for the DMA APIs.
+
+Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+---
+ drivers/usb/host/ohci-sm501.c | 47 +++++++++++++++--------------------
+ 1 file changed, 20 insertions(+), 27 deletions(-)
+
+--- a/drivers/usb/host/ohci-sm501.c
++++ b/drivers/usb/host/ohci-sm501.c
+@@ -110,41 +110,18 @@
+ goto err0;
+ }
+
+- /* The sm501 chip is equipped with local memory that may be used
+- * by on-chip devices such as the video controller and the usb host.
+- * This driver uses dma_declare_coherent_memory() to make sure
+- * usb allocations with dma_alloc_coherent() allocate from
+- * this local memory. The dma_handle returned by dma_alloc_coherent()
+- * will be an offset starting from 0 for the first local memory byte.
+- *
+- * So as long as data is allocated using dma_alloc_coherent() all is
+- * fine. This is however not always the case - buffers may be allocated
+- * using kmalloc() - so the usb core needs to be told that it must copy
+- * data into our local memory if the buffers happen to be placed in
+- * regular memory. The HCD_LOCAL_MEM flag does just that.
+- */
+-
+- retval = dma_declare_coherent_memory(dev, mem->start,
+- mem->start - mem->parent->start,
+- resource_size(mem),
+- DMA_MEMORY_EXCLUSIVE);
+- if (retval) {
+- dev_err(dev, "cannot declare coherent memory\n");
+- goto err1;
+- }
+-
+ /* allocate, reserve and remap resources for registers */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res == NULL) {
+ dev_err(dev, "no resource definition for registers\n");
+ retval = -ENOENT;
+- goto err2;
++ goto err1;
+ }
+
+ hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
+ if (!hcd) {
+ retval = -ENOMEM;
+- goto err2;
++ goto err1;
+ }
+
+ hcd->rsrc_start = res->start;
+@@ -165,6 +142,24 @@
+
+ ohci_hcd_init(hcd_to_ohci(hcd));
+
++ /* The sm501 chip is equipped with local memory that may be used
++ * by on-chip devices such as the video controller and the usb host.
++ * This driver uses genalloc so that usb allocations with
++ * gen_pool_dma_alloc() allocate from this local memory. The dma_handle
++ * returned by gen_pool_dma_alloc() will be an offset starting from 0
++ * for the first local memory byte.
++ *
++ * So as long as data is allocated using gen_pool_dma_alloc() all is
++ * fine. This is however not always the case - buffers may be allocated
++ * using kmalloc() - so the usb core needs to be told that it must copy
++ * data into our local memory if the buffers happen to be placed in
++ * regular memory. The HCD_LOCAL_MEM flag does just that.
++ */
++
++ if (usb_hcd_setup_local_mem(hcd, mem->start,
++ mem->start - mem->parent->start,
++ resource_size(mem)) < 0)
++ goto err5;
+ retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
+ if (retval)
+ goto err5;
+@@ -182,8 +177,6 @@
+ release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+ err3:
+ usb_put_hcd(hcd);
+-err2:
+- dma_release_declared_memory(dev);
+ err1:
+ release_mem_region(mem->start, resource_size(mem));
+ err0:
+@@ -199,7 +192,6 @@
+ iounmap(hcd->regs);
+ release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+ usb_put_hcd(hcd);
+- dma_release_declared_memory(&pdev->dev);
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ if (mem)
+ release_mem_region(mem->start, resource_size(mem));