hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/usb/host/ohci-sm501.c
....@@ -49,7 +49,7 @@
4949 * generic hardware linkage
5050 */
5151 .irq = ohci_irq,
52
- .flags = HCD_USB11 | HCD_MEMORY | HCD_LOCAL_MEM,
52
+ .flags = HCD_USB11 | HCD_MEMORY,
5353
5454 /*
5555 * basic lifecycle operations
....@@ -110,41 +110,18 @@
110110 goto err0;
111111 }
112112
113
- /* The sm501 chip is equipped with local memory that may be used
114
- * by on-chip devices such as the video controller and the usb host.
115
- * This driver uses dma_declare_coherent_memory() to make sure
116
- * usb allocations with dma_alloc_coherent() allocate from
117
- * this local memory. The dma_handle returned by dma_alloc_coherent()
118
- * will be an offset starting from 0 for the first local memory byte.
119
- *
120
- * So as long as data is allocated using dma_alloc_coherent() all is
121
- * fine. This is however not always the case - buffers may be allocated
122
- * using kmalloc() - so the usb core needs to be told that it must copy
123
- * data into our local memory if the buffers happen to be placed in
124
- * regular memory. The HCD_LOCAL_MEM flag does just that.
125
- */
126
-
127
- retval = dma_declare_coherent_memory(dev, mem->start,
128
- mem->start - mem->parent->start,
129
- resource_size(mem),
130
- DMA_MEMORY_EXCLUSIVE);
131
- if (retval) {
132
- dev_err(dev, "cannot declare coherent memory\n");
133
- goto err1;
134
- }
135
-
136113 /* allocate, reserve and remap resources for registers */
137114 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
138115 if (res == NULL) {
139116 dev_err(dev, "no resource definition for registers\n");
140117 retval = -ENOENT;
141
- goto err2;
118
+ goto err1;
142119 }
143120
144121 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
145122 if (!hcd) {
146123 retval = -ENOMEM;
147
- goto err2;
124
+ goto err1;
148125 }
149126
150127 hcd->rsrc_start = res->start;
....@@ -165,6 +142,26 @@
165142
166143 ohci_hcd_init(hcd_to_ohci(hcd));
167144
145
+ /* The sm501 chip is equipped with local memory that may be used
146
+ * by on-chip devices such as the video controller and the usb host.
147
+ * This driver uses genalloc so that usb allocations with
148
+ * gen_pool_dma_alloc() allocate from this local memory. The dma_handle
149
+ * returned by gen_pool_dma_alloc() will be an offset starting from 0
150
+ * for the first local memory byte.
151
+ *
152
+ * So as long as data is allocated using gen_pool_dma_alloc() all is
153
+ * fine. This is however not always the case - buffers may be allocated
154
+ * using kmalloc() - so the usb core needs to be told that it must copy
155
+ * data into our local memory if the buffers happen to be placed in
156
+ * regular memory. A non-null hcd->localmem_pool initialized by the
157
+ * the call to usb_hcd_setup_local_mem() below does just that.
158
+ */
159
+
160
+ retval = usb_hcd_setup_local_mem(hcd, mem->start,
161
+ mem->start - mem->parent->start,
162
+ resource_size(mem));
163
+ if (retval < 0)
164
+ goto err5;
168165 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
169166 if (retval)
170167 goto err5;
....@@ -182,8 +179,6 @@
182179 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
183180 err3:
184181 usb_put_hcd(hcd);
185
-err2:
186
- dma_release_declared_memory(dev);
187182 err1:
188183 release_mem_region(mem->start, resource_size(mem));
189184 err0:
....@@ -199,7 +194,6 @@
199194 iounmap(hcd->regs);
200195 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
201196 usb_put_hcd(hcd);
202
- dma_release_declared_memory(&pdev->dev);
203197 mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
204198 if (mem)
205199 release_mem_region(mem->start, resource_size(mem));