.. | .. |
---|
36 | 36 | |
---|
37 | 37 | static int ohci_mem_init (struct ohci_hcd *ohci) |
---|
38 | 38 | { |
---|
| 39 | + /* |
---|
| 40 | + * HCs with local memory allocate from localmem_pool so there's |
---|
| 41 | + * no need to create the below dma pools. |
---|
| 42 | + */ |
---|
| 43 | + if (ohci_to_hcd(ohci)->localmem_pool) |
---|
| 44 | + return 0; |
---|
| 45 | + |
---|
39 | 46 | ohci->td_cache = dma_pool_create ("ohci_td", |
---|
40 | 47 | ohci_to_hcd(ohci)->self.controller, |
---|
41 | 48 | sizeof (struct td), |
---|
.. | .. |
---|
57 | 64 | |
---|
58 | 65 | static void ohci_mem_cleanup (struct ohci_hcd *ohci) |
---|
59 | 66 | { |
---|
60 | | - if (ohci->td_cache) { |
---|
61 | | - dma_pool_destroy (ohci->td_cache); |
---|
62 | | - ohci->td_cache = NULL; |
---|
63 | | - } |
---|
64 | | - if (ohci->ed_cache) { |
---|
65 | | - dma_pool_destroy (ohci->ed_cache); |
---|
66 | | - ohci->ed_cache = NULL; |
---|
67 | | - } |
---|
| 67 | + dma_pool_destroy(ohci->td_cache); |
---|
| 68 | + ohci->td_cache = NULL; |
---|
| 69 | + dma_pool_destroy(ohci->ed_cache); |
---|
| 70 | + ohci->ed_cache = NULL; |
---|
68 | 71 | } |
---|
69 | 72 | |
---|
70 | 73 | /*-------------------------------------------------------------------------*/ |
---|
.. | .. |
---|
88 | 91 | { |
---|
89 | 92 | dma_addr_t dma; |
---|
90 | 93 | struct td *td; |
---|
| 94 | + struct usb_hcd *hcd = ohci_to_hcd(hc); |
---|
91 | 95 | |
---|
92 | | - td = dma_pool_zalloc (hc->td_cache, mem_flags, &dma); |
---|
| 96 | + if (hcd->localmem_pool) |
---|
| 97 | + td = gen_pool_dma_zalloc_align(hcd->localmem_pool, |
---|
| 98 | + sizeof(*td), &dma, 32); |
---|
| 99 | + else |
---|
| 100 | + td = dma_pool_zalloc(hc->td_cache, mem_flags, &dma); |
---|
93 | 101 | if (td) { |
---|
94 | 102 | /* in case hc fetches it, make it look dead */ |
---|
95 | 103 | td->hwNextTD = cpu_to_hc32 (hc, dma); |
---|
.. | .. |
---|
103 | 111 | td_free (struct ohci_hcd *hc, struct td *td) |
---|
104 | 112 | { |
---|
105 | 113 | struct td **prev = &hc->td_hash [TD_HASH_FUNC (td->td_dma)]; |
---|
| 114 | + struct usb_hcd *hcd = ohci_to_hcd(hc); |
---|
106 | 115 | |
---|
107 | 116 | while (*prev && *prev != td) |
---|
108 | 117 | prev = &(*prev)->td_hash; |
---|
.. | .. |
---|
110 | 119 | *prev = td->td_hash; |
---|
111 | 120 | else if ((td->hwINFO & cpu_to_hc32(hc, TD_DONE)) != 0) |
---|
112 | 121 | ohci_dbg (hc, "no hash for td %p\n", td); |
---|
113 | | - dma_pool_free (hc->td_cache, td, td->td_dma); |
---|
| 122 | + |
---|
| 123 | + if (hcd->localmem_pool) |
---|
| 124 | + gen_pool_free(hcd->localmem_pool, (unsigned long)td, |
---|
| 125 | + sizeof(*td)); |
---|
| 126 | + else |
---|
| 127 | + dma_pool_free(hc->td_cache, td, td->td_dma); |
---|
114 | 128 | } |
---|
115 | 129 | |
---|
116 | 130 | /*-------------------------------------------------------------------------*/ |
---|
.. | .. |
---|
121 | 135 | { |
---|
122 | 136 | dma_addr_t dma; |
---|
123 | 137 | struct ed *ed; |
---|
| 138 | + struct usb_hcd *hcd = ohci_to_hcd(hc); |
---|
124 | 139 | |
---|
125 | | - ed = dma_pool_zalloc (hc->ed_cache, mem_flags, &dma); |
---|
| 140 | + if (hcd->localmem_pool) |
---|
| 141 | + ed = gen_pool_dma_zalloc_align(hcd->localmem_pool, |
---|
| 142 | + sizeof(*ed), &dma, 16); |
---|
| 143 | + else |
---|
| 144 | + ed = dma_pool_zalloc(hc->ed_cache, mem_flags, &dma); |
---|
126 | 145 | if (ed) { |
---|
127 | 146 | INIT_LIST_HEAD (&ed->td_list); |
---|
128 | 147 | ed->dma = dma; |
---|
.. | .. |
---|
133 | 152 | static void |
---|
134 | 153 | ed_free (struct ohci_hcd *hc, struct ed *ed) |
---|
135 | 154 | { |
---|
136 | | - dma_pool_free (hc->ed_cache, ed, ed->dma); |
---|
| 155 | + struct usb_hcd *hcd = ohci_to_hcd(hc); |
---|
| 156 | + |
---|
| 157 | + if (hcd->localmem_pool) |
---|
| 158 | + gen_pool_free(hcd->localmem_pool, (unsigned long)ed, |
---|
| 159 | + sizeof(*ed)); |
---|
| 160 | + else |
---|
| 161 | + dma_pool_free(hc->ed_cache, ed, ed->dma); |
---|
137 | 162 | } |
---|
138 | 163 | |
---|