USB: use genalloc for USB HCs with local memory
[platform/kernel/linux-starfive.git] / drivers / usb / host / ohci-hcd.c
index 210181f..b200b19 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/dmapool.h>
 #include <linux/workqueue.h>
 #include <linux/debugfs.h>
+#include <linux/genalloc.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -505,8 +506,15 @@ static int ohci_init (struct ohci_hcd *ohci)
        timer_setup(&ohci->io_watchdog, io_watchdog_func, 0);
        ohci->prev_frame_no = IO_WATCHDOG_OFF;
 
-       ohci->hcca = dma_alloc_coherent (hcd->self.controller,
-                       sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL);
+       if (hcd->localmem_pool)
+               ohci->hcca = gen_pool_dma_alloc(hcd->localmem_pool,
+                                               sizeof(*ohci->hcca),
+                                               &ohci->hcca_dma);
+       else
+               ohci->hcca = dma_alloc_coherent(hcd->self.controller,
+                                               sizeof(*ohci->hcca),
+                                               &ohci->hcca_dma,
+                                               GFP_KERNEL);
        if (!ohci->hcca)
                return -ENOMEM;
 
@@ -990,9 +998,14 @@ static void ohci_stop (struct usb_hcd *hcd)
        remove_debug_files (ohci);
        ohci_mem_cleanup (ohci);
        if (ohci->hcca) {
-               dma_free_coherent (hcd->self.controller,
-                               sizeof *ohci->hcca,
-                               ohci->hcca, ohci->hcca_dma);
+               if (hcd->localmem_pool)
+                       gen_pool_free(hcd->localmem_pool,
+                                     (unsigned long)ohci->hcca,
+                                     sizeof(*ohci->hcca));
+               else
+                       dma_free_coherent(hcd->self.controller,
+                                         sizeof(*ohci->hcca),
+                                         ohci->hcca, ohci->hcca_dma);
                ohci->hcca = NULL;
                ohci->hcca_dma = 0;
        }