hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/usb/host/ohci-hcd.c
....@@ -16,7 +16,7 @@
1616 * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller
1717 * interfaces (though some non-x86 Intel chips use it). It supports
1818 * smarter hardware than UHCI. A download link for the spec available
19
- * through the http://www.usb.org website.
19
+ * through the https://www.usb.org website.
2020 *
2121 * This file is licenced under the GPL.
2222 */
....@@ -40,6 +40,7 @@
4040 #include <linux/dmapool.h>
4141 #include <linux/workqueue.h>
4242 #include <linux/debugfs.h>
43
+#include <linux/genalloc.h>
4344
4445 #include <asm/io.h>
4546 #include <asm/irq.h>
....@@ -384,7 +385,7 @@
384385 ed_free (ohci, ed);
385386 break;
386387 }
387
- /* fall through */
388
+ fallthrough;
388389 default:
389390 /* caller was supposed to have unlinked any requests;
390391 * that's not our job. can't recover; must leak ed.
....@@ -456,7 +457,7 @@
456457 struct usb_hcd *hcd = ohci_to_hcd(ohci);
457458
458459 /* Accept arbitrarily long scatter-gather lists */
459
- if (!(hcd->driver->flags & HCD_LOCAL_MEM))
460
+ if (!hcd->localmem_pool)
460461 hcd->self.sg_tablesize = ~0;
461462
462463 if (distrust_firmware)
....@@ -514,8 +515,15 @@
514515 timer_setup(&ohci->io_watchdog, io_watchdog_func, 0);
515516 ohci->prev_frame_no = IO_WATCHDOG_OFF;
516517
517
- ohci->hcca = dma_alloc_coherent (hcd->self.controller,
518
- sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL);
518
+ if (hcd->localmem_pool)
519
+ ohci->hcca = gen_pool_dma_alloc_align(hcd->localmem_pool,
520
+ sizeof(*ohci->hcca),
521
+ &ohci->hcca_dma, 256);
522
+ else
523
+ ohci->hcca = dma_alloc_coherent(hcd->self.controller,
524
+ sizeof(*ohci->hcca),
525
+ &ohci->hcca_dma,
526
+ GFP_KERNEL);
519527 if (!ohci->hcca)
520528 return -ENOMEM;
521529
....@@ -1003,9 +1011,14 @@
10031011 remove_debug_files (ohci);
10041012 ohci_mem_cleanup (ohci);
10051013 if (ohci->hcca) {
1006
- dma_free_coherent (hcd->self.controller,
1007
- sizeof *ohci->hcca,
1008
- ohci->hcca, ohci->hcca_dma);
1014
+ if (hcd->localmem_pool)
1015
+ gen_pool_free(hcd->localmem_pool,
1016
+ (unsigned long)ohci->hcca,
1017
+ sizeof(*ohci->hcca));
1018
+ else
1019
+ dma_free_coherent(hcd->self.controller,
1020
+ sizeof(*ohci->hcca),
1021
+ ohci->hcca, ohci->hcca_dma);
10091022 ohci->hcca = NULL;
10101023 ohci->hcca_dma = 0;
10111024 }
....@@ -1042,7 +1055,7 @@
10421055 ed->ed_next = ohci->ed_rm_list;
10431056 ed->ed_prev = NULL;
10441057 ohci->ed_rm_list = ed;
1045
- /* FALLTHROUGH */
1058
+ fallthrough;
10461059 case ED_UNLINK:
10471060 break;
10481061 default:
....@@ -1178,7 +1191,7 @@
11781191 * generic hardware linkage
11791192 */
11801193 .irq = ohci_irq,
1181
- .flags = HCD_MEMORY | HCD_USB11,
1194
+ .flags = HCD_MEMORY | HCD_DMA | HCD_USB11,
11821195
11831196 /*
11841197 * basic lifecycle operations