diff options
Diffstat (limited to 'drivers/usb/host')
29 files changed, 1325 insertions, 1063 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 2f529828c74..c978d622fa8 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -154,6 +154,19 @@ config USB_OHCI_HCD_PCI | |||
154 | Enables support for PCI-bus plug-in USB controller cards. | 154 | Enables support for PCI-bus plug-in USB controller cards. |
155 | If unsure, say Y. | 155 | If unsure, say Y. |
156 | 156 | ||
157 | config USB_OHCI_HCD_SSB | ||
158 | bool "OHCI support for Broadcom SSB OHCI core" | ||
159 | depends on USB_OHCI_HCD && SSB && EXPERIMENTAL | ||
160 | default n | ||
161 | ---help--- | ||
162 | Support for the Sonics Silicon Backplane (SSB) attached | ||
163 | Broadcom USB OHCI core. | ||
164 | |||
165 | This device is present in some embedded devices with | ||
166 | Broadcom based SSB bus. | ||
167 | |||
168 | If unsure, say N. | ||
169 | |||
157 | config USB_OHCI_BIG_ENDIAN_DESC | 170 | config USB_OHCI_BIG_ENDIAN_DESC |
158 | bool | 171 | bool |
159 | depends on USB_OHCI_HCD | 172 | depends on USB_OHCI_HCD |
@@ -237,7 +250,7 @@ config USB_SL811_CS | |||
237 | module will be called "sl811_cs". | 250 | module will be called "sl811_cs". |
238 | 251 | ||
239 | config USB_R8A66597_HCD | 252 | config USB_R8A66597_HCD |
240 | tristate "R8A66597 HCD suppoort" | 253 | tristate "R8A66597 HCD support" |
241 | depends on USB | 254 | depends on USB |
242 | help | 255 | help |
243 | The R8A66597 is a USB 2.0 host and peripheral controller. | 256 | The R8A66597 is a USB 2.0 host and peripheral controller. |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index 5d1b12aad77..766ef68a0b4 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
@@ -1,8 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * EHCI HCD (Host Controller Driver) for USB. | 2 | * EHCI HCD (Host Controller Driver) for USB. |
3 | * | 3 | * |
4 | * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net> | ||
5 | * | ||
6 | * Bus Glue for AMD Alchemy Au1xxx | 4 | * Bus Glue for AMD Alchemy Au1xxx |
7 | * | 5 | * |
8 | * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org> | 6 | * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org> |
@@ -196,6 +194,9 @@ static const struct hc_driver ehci_au1xxx_hc_driver = { | |||
196 | 194 | ||
197 | /* | 195 | /* |
198 | * basic lifecycle operations | 196 | * basic lifecycle operations |
197 | * | ||
198 | * FIXME -- ehci_init() doesn't do enough here. | ||
199 | * See ehci-ppc-soc for a complete implementation. | ||
199 | */ | 200 | */ |
200 | .reset = ehci_init, | 201 | .reset = ehci_init, |
201 | .start = ehci_run, | 202 | .start = ehci_run, |
@@ -219,10 +220,8 @@ static const struct hc_driver ehci_au1xxx_hc_driver = { | |||
219 | */ | 220 | */ |
220 | .hub_status_data = ehci_hub_status_data, | 221 | .hub_status_data = ehci_hub_status_data, |
221 | .hub_control = ehci_hub_control, | 222 | .hub_control = ehci_hub_control, |
222 | #ifdef CONFIG_PM | 223 | .bus_suspend = ehci_bus_suspend, |
223 | .hub_suspend = ehci_hub_suspend, | 224 | .bus_resume = ehci_bus_resume, |
224 | .hub_resume = ehci_hub_resume, | ||
225 | #endif | ||
226 | }; | 225 | }; |
227 | 226 | ||
228 | /*-------------------------------------------------------------------------*/ | 227 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index c4e15ed1405..c1514442883 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -275,58 +275,6 @@ static void ehci_work(struct ehci_hcd *ehci); | |||
275 | 275 | ||
276 | /*-------------------------------------------------------------------------*/ | 276 | /*-------------------------------------------------------------------------*/ |
277 | 277 | ||
278 | #ifdef CONFIG_CPU_FREQ | ||
279 | |||
280 | #include <linux/cpufreq.h> | ||
281 | |||
282 | static void ehci_cpufreq_pause (struct ehci_hcd *ehci) | ||
283 | { | ||
284 | unsigned long flags; | ||
285 | |||
286 | spin_lock_irqsave(&ehci->lock, flags); | ||
287 | if (!ehci->cpufreq_changing++) | ||
288 | qh_inactivate_split_intr_qhs(ehci); | ||
289 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
290 | } | ||
291 | |||
292 | static void ehci_cpufreq_unpause (struct ehci_hcd *ehci) | ||
293 | { | ||
294 | unsigned long flags; | ||
295 | |||
296 | spin_lock_irqsave(&ehci->lock, flags); | ||
297 | if (!--ehci->cpufreq_changing) | ||
298 | qh_reactivate_split_intr_qhs(ehci); | ||
299 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * ehci_cpufreq_notifier is needed to avoid MMF errors that occur when | ||
304 | * EHCI controllers that don't cache many uframes get delayed trying to | ||
305 | * read main memory during CPU frequency transitions. This can cause | ||
306 | * split interrupt transactions to not be completed in the required uframe. | ||
307 | * This has been observed on the Broadcom/ServerWorks HT1000 controller. | ||
308 | */ | ||
309 | static int ehci_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | ||
310 | void *data) | ||
311 | { | ||
312 | struct ehci_hcd *ehci = container_of(nb, struct ehci_hcd, | ||
313 | cpufreq_transition); | ||
314 | |||
315 | switch (val) { | ||
316 | case CPUFREQ_PRECHANGE: | ||
317 | ehci_cpufreq_pause(ehci); | ||
318 | break; | ||
319 | case CPUFREQ_POSTCHANGE: | ||
320 | ehci_cpufreq_unpause(ehci); | ||
321 | break; | ||
322 | } | ||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | #endif | ||
327 | |||
328 | /*-------------------------------------------------------------------------*/ | ||
329 | |||
330 | static void ehci_watchdog (unsigned long param) | 278 | static void ehci_watchdog (unsigned long param) |
331 | { | 279 | { |
332 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | 280 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; |
@@ -460,10 +408,6 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
460 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | 408 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); |
461 | spin_unlock_irq(&ehci->lock); | 409 | spin_unlock_irq(&ehci->lock); |
462 | 410 | ||
463 | #ifdef CONFIG_CPU_FREQ | ||
464 | cpufreq_unregister_notifier(&ehci->cpufreq_transition, | ||
465 | CPUFREQ_TRANSITION_NOTIFIER); | ||
466 | #endif | ||
467 | /* let companion controllers work when we aren't */ | 411 | /* let companion controllers work when we aren't */ |
468 | ehci_writel(ehci, 0, &ehci->regs->configured_flag); | 412 | ehci_writel(ehci, 0, &ehci->regs->configured_flag); |
469 | 413 | ||
@@ -569,17 +513,6 @@ static int ehci_init(struct usb_hcd *hcd) | |||
569 | } | 513 | } |
570 | ehci->command = temp; | 514 | ehci->command = temp; |
571 | 515 | ||
572 | #ifdef CONFIG_CPU_FREQ | ||
573 | INIT_LIST_HEAD(&ehci->split_intr_qhs); | ||
574 | /* | ||
575 | * If the EHCI controller caches enough uframes, this probably | ||
576 | * isn't needed unless there are so many low/full speed devices | ||
577 | * that the controller's can't cache it all. | ||
578 | */ | ||
579 | ehci->cpufreq_transition.notifier_call = ehci_cpufreq_notifier; | ||
580 | cpufreq_register_notifier(&ehci->cpufreq_transition, | ||
581 | CPUFREQ_TRANSITION_NOTIFIER); | ||
582 | #endif | ||
583 | return 0; | 516 | return 0; |
584 | } | 517 | } |
585 | 518 | ||
@@ -637,10 +570,18 @@ static int ehci_run (struct usb_hcd *hcd) | |||
637 | * are explicitly handed to companion controller(s), so no TT is | 570 | * are explicitly handed to companion controller(s), so no TT is |
638 | * involved with the root hub. (Except where one is integrated, | 571 | * involved with the root hub. (Except where one is integrated, |
639 | * and there's no companion controller unless maybe for USB OTG.) | 572 | * and there's no companion controller unless maybe for USB OTG.) |
573 | * | ||
574 | * Turning on the CF flag will transfer ownership of all ports | ||
575 | * from the companions to the EHCI controller. If any of the | ||
576 | * companions are in the middle of a port reset at the time, it | ||
577 | * could cause trouble. Write-locking ehci_cf_port_reset_rwsem | ||
578 | * guarantees that no resets are in progress. | ||
640 | */ | 579 | */ |
580 | down_write(&ehci_cf_port_reset_rwsem); | ||
641 | hcd->state = HC_STATE_RUNNING; | 581 | hcd->state = HC_STATE_RUNNING; |
642 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); | 582 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); |
643 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ | 583 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ |
584 | up_write(&ehci_cf_port_reset_rwsem); | ||
644 | 585 | ||
645 | temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); | 586 | temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); |
646 | ehci_info (ehci, | 587 | ehci_info (ehci, |
@@ -786,7 +727,6 @@ dead: | |||
786 | */ | 727 | */ |
787 | static int ehci_urb_enqueue ( | 728 | static int ehci_urb_enqueue ( |
788 | struct usb_hcd *hcd, | 729 | struct usb_hcd *hcd, |
789 | struct usb_host_endpoint *ep, | ||
790 | struct urb *urb, | 730 | struct urb *urb, |
791 | gfp_t mem_flags | 731 | gfp_t mem_flags |
792 | ) { | 732 | ) { |
@@ -801,12 +741,12 @@ static int ehci_urb_enqueue ( | |||
801 | default: | 741 | default: |
802 | if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) | 742 | if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) |
803 | return -ENOMEM; | 743 | return -ENOMEM; |
804 | return submit_async (ehci, ep, urb, &qtd_list, mem_flags); | 744 | return submit_async(ehci, urb, &qtd_list, mem_flags); |
805 | 745 | ||
806 | case PIPE_INTERRUPT: | 746 | case PIPE_INTERRUPT: |
807 | if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) | 747 | if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) |
808 | return -ENOMEM; | 748 | return -ENOMEM; |
809 | return intr_submit (ehci, ep, urb, &qtd_list, mem_flags); | 749 | return intr_submit(ehci, urb, &qtd_list, mem_flags); |
810 | 750 | ||
811 | case PIPE_ISOCHRONOUS: | 751 | case PIPE_ISOCHRONOUS: |
812 | if (urb->dev->speed == USB_SPEED_HIGH) | 752 | if (urb->dev->speed == USB_SPEED_HIGH) |
@@ -844,13 +784,18 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
844 | * completions normally happen asynchronously | 784 | * completions normally happen asynchronously |
845 | */ | 785 | */ |
846 | 786 | ||
847 | static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) | 787 | static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
848 | { | 788 | { |
849 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 789 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
850 | struct ehci_qh *qh; | 790 | struct ehci_qh *qh; |
851 | unsigned long flags; | 791 | unsigned long flags; |
792 | int rc; | ||
852 | 793 | ||
853 | spin_lock_irqsave (&ehci->lock, flags); | 794 | spin_lock_irqsave (&ehci->lock, flags); |
795 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); | ||
796 | if (rc) | ||
797 | goto done; | ||
798 | |||
854 | switch (usb_pipetype (urb->pipe)) { | 799 | switch (usb_pipetype (urb->pipe)) { |
855 | // case PIPE_CONTROL: | 800 | // case PIPE_CONTROL: |
856 | // case PIPE_BULK: | 801 | // case PIPE_BULK: |
@@ -905,7 +850,7 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) | |||
905 | } | 850 | } |
906 | done: | 851 | done: |
907 | spin_unlock_irqrestore (&ehci->lock, flags); | 852 | spin_unlock_irqrestore (&ehci->lock, flags); |
908 | return 0; | 853 | return rc; |
909 | } | 854 | } |
910 | 855 | ||
911 | /*-------------------------------------------------------------------------*/ | 856 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 8816d09903d..0431397836f 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c | |||
@@ -94,9 +94,6 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags) | |||
94 | qh->qh_dma = dma; | 94 | qh->qh_dma = dma; |
95 | // INIT_LIST_HEAD (&qh->qh_list); | 95 | // INIT_LIST_HEAD (&qh->qh_list); |
96 | INIT_LIST_HEAD (&qh->qtd_list); | 96 | INIT_LIST_HEAD (&qh->qtd_list); |
97 | #ifdef CONFIG_CPU_FREQ | ||
98 | INIT_LIST_HEAD (&qh->split_intr_qhs); | ||
99 | #endif | ||
100 | 97 | ||
101 | /* dummy td enables safe urb queuing */ | 98 | /* dummy td enables safe urb queuing */ |
102 | qh->dummy = ehci_qtd_alloc (ehci, flags); | 99 | qh->dummy = ehci_qtd_alloc (ehci, flags); |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index a7816e392a8..ad0d4965f2f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -58,8 +58,6 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) | |||
58 | if (!retval) | 58 | if (!retval) |
59 | ehci_dbg(ehci, "MWI active\n"); | 59 | ehci_dbg(ehci, "MWI active\n"); |
60 | 60 | ||
61 | ehci_port_power(ehci, 0); | ||
62 | |||
63 | return 0; | 61 | return 0; |
64 | } | 62 | } |
65 | 63 | ||
@@ -156,8 +154,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
156 | break; | 154 | break; |
157 | } | 155 | } |
158 | 156 | ||
159 | if (ehci_is_TDI(ehci)) | 157 | ehci_reset(ehci); |
160 | ehci_reset(ehci); | ||
161 | 158 | ||
162 | /* at least the Genesys GL880S needs fixup here */ | 159 | /* at least the Genesys GL880S needs fixup here */ |
163 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); | 160 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); |
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c index c2cedb09ed8..452d4b1bc85 100644 --- a/drivers/usb/host/ehci-ppc-soc.c +++ b/drivers/usb/host/ehci-ppc-soc.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Bus Glue for PPC On-Chip EHCI driver | 6 | * Bus Glue for PPC On-Chip EHCI driver |
7 | * Tested on AMCC 440EPx | 7 | * Tested on AMCC 440EPx |
8 | * | 8 | * |
9 | * Based on "ehci-au12xx.c" by David Brownell <dbrownell@users.sourceforge.net> | 9 | * Based on "ehci-au1xxx.c" by K.Boge <karsten.boge@amd.com> |
10 | * | 10 | * |
11 | * This file is licenced under the GPL. | 11 | * This file is licenced under the GPL. |
12 | */ | 12 | */ |
@@ -15,6 +15,24 @@ | |||
15 | 15 | ||
16 | extern int usb_disabled(void); | 16 | extern int usb_disabled(void); |
17 | 17 | ||
18 | /* called during probe() after chip reset completes */ | ||
19 | static int ehci_ppc_soc_setup(struct usb_hcd *hcd) | ||
20 | { | ||
21 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
22 | int retval; | ||
23 | |||
24 | retval = ehci_halt(ehci); | ||
25 | if (retval) | ||
26 | return retval; | ||
27 | |||
28 | retval = ehci_init(hcd); | ||
29 | if (retval) | ||
30 | return retval; | ||
31 | |||
32 | ehci->sbrn = 0x20; | ||
33 | return ehci_reset(ehci); | ||
34 | } | ||
35 | |||
18 | /** | 36 | /** |
19 | * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs | 37 | * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs |
20 | * Context: !in_interrupt() | 38 | * Context: !in_interrupt() |
@@ -120,7 +138,7 @@ static const struct hc_driver ehci_ppc_soc_hc_driver = { | |||
120 | /* | 138 | /* |
121 | * basic lifecycle operations | 139 | * basic lifecycle operations |
122 | */ | 140 | */ |
123 | .reset = ehci_init, | 141 | .reset = ehci_ppc_soc_setup, |
124 | .start = ehci_run, | 142 | .start = ehci_run, |
125 | .stop = ehci_stop, | 143 | .stop = ehci_stop, |
126 | .shutdown = ehci_shutdown, | 144 | .shutdown = ehci_shutdown, |
@@ -142,10 +160,8 @@ static const struct hc_driver ehci_ppc_soc_hc_driver = { | |||
142 | */ | 160 | */ |
143 | .hub_status_data = ehci_hub_status_data, | 161 | .hub_status_data = ehci_hub_status_data, |
144 | .hub_control = ehci_hub_control, | 162 | .hub_control = ehci_hub_control, |
145 | #ifdef CONFIG_PM | 163 | .bus_suspend = ehci_bus_suspend, |
146 | .hub_suspend = ehci_hub_suspend, | 164 | .bus_resume = ehci_bus_resume, |
147 | .hub_resume = ehci_hub_resume, | ||
148 | #endif | ||
149 | }; | 165 | }; |
150 | 166 | ||
151 | static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) | 167 | static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) |
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index 829fe649a98..03a6b2f4e6e 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
@@ -47,7 +47,7 @@ static int ps3_ehci_hc_reset(struct usb_hcd *hcd) | |||
47 | if (result) | 47 | if (result) |
48 | return result; | 48 | return result; |
49 | 49 | ||
50 | ehci_port_power(ehci, 0); | 50 | ehci_reset(ehci); |
51 | 51 | ||
52 | return result; | 52 | return result; |
53 | } | 53 | } |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 2284028f8aa..b10f39c047e 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -139,63 +139,65 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
139 | 139 | ||
140 | /*-------------------------------------------------------------------------*/ | 140 | /*-------------------------------------------------------------------------*/ |
141 | 141 | ||
142 | static void qtd_copy_status ( | 142 | static int qtd_copy_status ( |
143 | struct ehci_hcd *ehci, | 143 | struct ehci_hcd *ehci, |
144 | struct urb *urb, | 144 | struct urb *urb, |
145 | size_t length, | 145 | size_t length, |
146 | u32 token | 146 | u32 token |
147 | ) | 147 | ) |
148 | { | 148 | { |
149 | int status = -EINPROGRESS; | ||
150 | |||
149 | /* count IN/OUT bytes, not SETUP (even short packets) */ | 151 | /* count IN/OUT bytes, not SETUP (even short packets) */ |
150 | if (likely (QTD_PID (token) != 2)) | 152 | if (likely (QTD_PID (token) != 2)) |
151 | urb->actual_length += length - QTD_LENGTH (token); | 153 | urb->actual_length += length - QTD_LENGTH (token); |
152 | 154 | ||
153 | /* don't modify error codes */ | 155 | /* don't modify error codes */ |
154 | if (unlikely (urb->status != -EINPROGRESS)) | 156 | if (unlikely(urb->unlinked)) |
155 | return; | 157 | return status; |
156 | 158 | ||
157 | /* force cleanup after short read; not always an error */ | 159 | /* force cleanup after short read; not always an error */ |
158 | if (unlikely (IS_SHORT_READ (token))) | 160 | if (unlikely (IS_SHORT_READ (token))) |
159 | urb->status = -EREMOTEIO; | 161 | status = -EREMOTEIO; |
160 | 162 | ||
161 | /* serious "can't proceed" faults reported by the hardware */ | 163 | /* serious "can't proceed" faults reported by the hardware */ |
162 | if (token & QTD_STS_HALT) { | 164 | if (token & QTD_STS_HALT) { |
163 | if (token & QTD_STS_BABBLE) { | 165 | if (token & QTD_STS_BABBLE) { |
164 | /* FIXME "must" disable babbling device's port too */ | 166 | /* FIXME "must" disable babbling device's port too */ |
165 | urb->status = -EOVERFLOW; | 167 | status = -EOVERFLOW; |
166 | } else if (token & QTD_STS_MMF) { | 168 | } else if (token & QTD_STS_MMF) { |
167 | /* fs/ls interrupt xfer missed the complete-split */ | 169 | /* fs/ls interrupt xfer missed the complete-split */ |
168 | urb->status = -EPROTO; | 170 | status = -EPROTO; |
169 | } else if (token & QTD_STS_DBE) { | 171 | } else if (token & QTD_STS_DBE) { |
170 | urb->status = (QTD_PID (token) == 1) /* IN ? */ | 172 | status = (QTD_PID (token) == 1) /* IN ? */ |
171 | ? -ENOSR /* hc couldn't read data */ | 173 | ? -ENOSR /* hc couldn't read data */ |
172 | : -ECOMM; /* hc couldn't write data */ | 174 | : -ECOMM; /* hc couldn't write data */ |
173 | } else if (token & QTD_STS_XACT) { | 175 | } else if (token & QTD_STS_XACT) { |
174 | /* timeout, bad crc, wrong PID, etc; retried */ | 176 | /* timeout, bad crc, wrong PID, etc; retried */ |
175 | if (QTD_CERR (token)) | 177 | if (QTD_CERR (token)) |
176 | urb->status = -EPIPE; | 178 | status = -EPIPE; |
177 | else { | 179 | else { |
178 | ehci_dbg (ehci, "devpath %s ep%d%s 3strikes\n", | 180 | ehci_dbg (ehci, "devpath %s ep%d%s 3strikes\n", |
179 | urb->dev->devpath, | 181 | urb->dev->devpath, |
180 | usb_pipeendpoint (urb->pipe), | 182 | usb_pipeendpoint (urb->pipe), |
181 | usb_pipein (urb->pipe) ? "in" : "out"); | 183 | usb_pipein (urb->pipe) ? "in" : "out"); |
182 | urb->status = -EPROTO; | 184 | status = -EPROTO; |
183 | } | 185 | } |
184 | /* CERR nonzero + no errors + halt --> stall */ | 186 | /* CERR nonzero + no errors + halt --> stall */ |
185 | } else if (QTD_CERR (token)) | 187 | } else if (QTD_CERR (token)) |
186 | urb->status = -EPIPE; | 188 | status = -EPIPE; |
187 | else /* unknown */ | 189 | else /* unknown */ |
188 | urb->status = -EPROTO; | 190 | status = -EPROTO; |
189 | 191 | ||
190 | ehci_vdbg (ehci, | 192 | ehci_vdbg (ehci, |
191 | "dev%d ep%d%s qtd token %08x --> status %d\n", | 193 | "dev%d ep%d%s qtd token %08x --> status %d\n", |
192 | usb_pipedevice (urb->pipe), | 194 | usb_pipedevice (urb->pipe), |
193 | usb_pipeendpoint (urb->pipe), | 195 | usb_pipeendpoint (urb->pipe), |
194 | usb_pipein (urb->pipe) ? "in" : "out", | 196 | usb_pipein (urb->pipe) ? "in" : "out", |
195 | token, urb->status); | 197 | token, status); |
196 | 198 | ||
197 | /* if async CSPLIT failed, try cleaning out the TT buffer */ | 199 | /* if async CSPLIT failed, try cleaning out the TT buffer */ |
198 | if (urb->status != -EPIPE | 200 | if (status != -EPIPE |
199 | && urb->dev->tt && !usb_pipeint (urb->pipe) | 201 | && urb->dev->tt && !usb_pipeint (urb->pipe) |
200 | && ((token & QTD_STS_MMF) != 0 | 202 | && ((token & QTD_STS_MMF) != 0 |
201 | || QTD_CERR(token) == 0) | 203 | || QTD_CERR(token) == 0) |
@@ -212,10 +214,12 @@ static void qtd_copy_status ( | |||
212 | usb_hub_tt_clear_buffer (urb->dev, urb->pipe); | 214 | usb_hub_tt_clear_buffer (urb->dev, urb->pipe); |
213 | } | 215 | } |
214 | } | 216 | } |
217 | |||
218 | return status; | ||
215 | } | 219 | } |
216 | 220 | ||
217 | static void | 221 | static void |
218 | ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb) | 222 | ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status) |
219 | __releases(ehci->lock) | 223 | __releases(ehci->lock) |
220 | __acquires(ehci->lock) | 224 | __acquires(ehci->lock) |
221 | { | 225 | { |
@@ -231,25 +235,13 @@ __acquires(ehci->lock) | |||
231 | qh_put (qh); | 235 | qh_put (qh); |
232 | } | 236 | } |
233 | 237 | ||
234 | spin_lock (&urb->lock); | 238 | if (unlikely(urb->unlinked)) { |
235 | urb->hcpriv = NULL; | 239 | COUNT(ehci->stats.unlink); |
236 | switch (urb->status) { | 240 | } else { |
237 | case -EINPROGRESS: /* success */ | 241 | if (likely(status == -EINPROGRESS)) |
238 | urb->status = 0; | 242 | status = 0; |
239 | default: /* fault */ | 243 | COUNT(ehci->stats.complete); |
240 | COUNT (ehci->stats.complete); | ||
241 | break; | ||
242 | case -EREMOTEIO: /* fault or normal */ | ||
243 | if (!(urb->transfer_flags & URB_SHORT_NOT_OK)) | ||
244 | urb->status = 0; | ||
245 | COUNT (ehci->stats.complete); | ||
246 | break; | ||
247 | case -ECONNRESET: /* canceled */ | ||
248 | case -ENOENT: | ||
249 | COUNT (ehci->stats.unlink); | ||
250 | break; | ||
251 | } | 244 | } |
252 | spin_unlock (&urb->lock); | ||
253 | 245 | ||
254 | #ifdef EHCI_URB_TRACE | 246 | #ifdef EHCI_URB_TRACE |
255 | ehci_dbg (ehci, | 247 | ehci_dbg (ehci, |
@@ -257,13 +249,14 @@ __acquires(ehci->lock) | |||
257 | __FUNCTION__, urb->dev->devpath, urb, | 249 | __FUNCTION__, urb->dev->devpath, urb, |
258 | usb_pipeendpoint (urb->pipe), | 250 | usb_pipeendpoint (urb->pipe), |
259 | usb_pipein (urb->pipe) ? "in" : "out", | 251 | usb_pipein (urb->pipe) ? "in" : "out", |
260 | urb->status, | 252 | status, |
261 | urb->actual_length, urb->transfer_buffer_length); | 253 | urb->actual_length, urb->transfer_buffer_length); |
262 | #endif | 254 | #endif |
263 | 255 | ||
264 | /* complete() can reenter this HCD */ | 256 | /* complete() can reenter this HCD */ |
257 | usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); | ||
265 | spin_unlock (&ehci->lock); | 258 | spin_unlock (&ehci->lock); |
266 | usb_hcd_giveback_urb (ehci_to_hcd(ehci), urb); | 259 | usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); |
267 | spin_lock (&ehci->lock); | 260 | spin_lock (&ehci->lock); |
268 | } | 261 | } |
269 | 262 | ||
@@ -283,6 +276,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
283 | { | 276 | { |
284 | struct ehci_qtd *last = NULL, *end = qh->dummy; | 277 | struct ehci_qtd *last = NULL, *end = qh->dummy; |
285 | struct list_head *entry, *tmp; | 278 | struct list_head *entry, *tmp; |
279 | int last_status = -EINPROGRESS; | ||
286 | int stopped; | 280 | int stopped; |
287 | unsigned count = 0; | 281 | unsigned count = 0; |
288 | int do_status = 0; | 282 | int do_status = 0; |
@@ -311,10 +305,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
311 | struct ehci_qtd *qtd; | 305 | struct ehci_qtd *qtd; |
312 | struct urb *urb; | 306 | struct urb *urb; |
313 | u32 token = 0; | 307 | u32 token = 0; |
314 | 308 | int qtd_status; | |
315 | /* ignore QHs that are currently inactive */ | ||
316 | if (qh->hw_info1 & __constant_cpu_to_le32(QH_INACTIVATE)) | ||
317 | break; | ||
318 | 309 | ||
319 | qtd = list_entry (entry, struct ehci_qtd, qtd_list); | 310 | qtd = list_entry (entry, struct ehci_qtd, qtd_list); |
320 | urb = qtd->urb; | 311 | urb = qtd->urb; |
@@ -322,11 +313,12 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
322 | /* clean up any state from previous QTD ...*/ | 313 | /* clean up any state from previous QTD ...*/ |
323 | if (last) { | 314 | if (last) { |
324 | if (likely (last->urb != urb)) { | 315 | if (likely (last->urb != urb)) { |
325 | ehci_urb_done (ehci, last->urb); | 316 | ehci_urb_done(ehci, last->urb, last_status); |
326 | count++; | 317 | count++; |
327 | } | 318 | } |
328 | ehci_qtd_free (ehci, last); | 319 | ehci_qtd_free (ehci, last); |
329 | last = NULL; | 320 | last = NULL; |
321 | last_status = -EINPROGRESS; | ||
330 | } | 322 | } |
331 | 323 | ||
332 | /* ignore urbs submitted during completions we reported */ | 324 | /* ignore urbs submitted during completions we reported */ |
@@ -362,13 +354,14 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
362 | stopped = 1; | 354 | stopped = 1; |
363 | 355 | ||
364 | if (unlikely (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) | 356 | if (unlikely (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) |
365 | urb->status = -ESHUTDOWN; | 357 | last_status = -ESHUTDOWN; |
366 | 358 | ||
367 | /* ignore active urbs unless some previous qtd | 359 | /* ignore active urbs unless some previous qtd |
368 | * for the urb faulted (including short read) or | 360 | * for the urb faulted (including short read) or |
369 | * its urb was canceled. we may patch qh or qtds. | 361 | * its urb was canceled. we may patch qh or qtds. |
370 | */ | 362 | */ |
371 | if (likely (urb->status == -EINPROGRESS)) | 363 | if (likely(last_status == -EINPROGRESS && |
364 | !urb->unlinked)) | ||
372 | continue; | 365 | continue; |
373 | 366 | ||
374 | /* issue status after short control reads */ | 367 | /* issue status after short control reads */ |
@@ -396,11 +389,14 @@ halt: | |||
396 | } | 389 | } |
397 | 390 | ||
398 | /* remove it from the queue */ | 391 | /* remove it from the queue */ |
399 | spin_lock (&urb->lock); | 392 | qtd_status = qtd_copy_status(ehci, urb, qtd->length, token); |
400 | qtd_copy_status (ehci, urb, qtd->length, token); | 393 | if (unlikely(qtd_status == -EREMOTEIO)) { |
401 | do_status = (urb->status == -EREMOTEIO) | 394 | do_status = (!urb->unlinked && |
402 | && usb_pipecontrol (urb->pipe); | 395 | usb_pipecontrol(urb->pipe)); |
403 | spin_unlock (&urb->lock); | 396 | qtd_status = 0; |
397 | } | ||
398 | if (likely(last_status == -EINPROGRESS)) | ||
399 | last_status = qtd_status; | ||
404 | 400 | ||
405 | if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { | 401 | if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { |
406 | last = list_entry (qtd->qtd_list.prev, | 402 | last = list_entry (qtd->qtd_list.prev, |
@@ -413,7 +409,7 @@ halt: | |||
413 | 409 | ||
414 | /* last urb's completion might still need calling */ | 410 | /* last urb's completion might still need calling */ |
415 | if (likely (last != NULL)) { | 411 | if (likely (last != NULL)) { |
416 | ehci_urb_done (ehci, last->urb); | 412 | ehci_urb_done(ehci, last->urb, last_status); |
417 | count++; | 413 | count++; |
418 | ehci_qtd_free (ehci, last); | 414 | ehci_qtd_free (ehci, last); |
419 | } | 415 | } |
@@ -917,7 +913,6 @@ static struct ehci_qh *qh_append_tds ( | |||
917 | static int | 913 | static int |
918 | submit_async ( | 914 | submit_async ( |
919 | struct ehci_hcd *ehci, | 915 | struct ehci_hcd *ehci, |
920 | struct usb_host_endpoint *ep, | ||
921 | struct urb *urb, | 916 | struct urb *urb, |
922 | struct list_head *qtd_list, | 917 | struct list_head *qtd_list, |
923 | gfp_t mem_flags | 918 | gfp_t mem_flags |
@@ -926,10 +921,10 @@ submit_async ( | |||
926 | int epnum; | 921 | int epnum; |
927 | unsigned long flags; | 922 | unsigned long flags; |
928 | struct ehci_qh *qh = NULL; | 923 | struct ehci_qh *qh = NULL; |
929 | int rc = 0; | 924 | int rc; |
930 | 925 | ||
931 | qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); | 926 | qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); |
932 | epnum = ep->desc.bEndpointAddress; | 927 | epnum = urb->ep->desc.bEndpointAddress; |
933 | 928 | ||
934 | #ifdef EHCI_URB_TRACE | 929 | #ifdef EHCI_URB_TRACE |
935 | ehci_dbg (ehci, | 930 | ehci_dbg (ehci, |
@@ -937,7 +932,7 @@ submit_async ( | |||
937 | __FUNCTION__, urb->dev->devpath, urb, | 932 | __FUNCTION__, urb->dev->devpath, urb, |
938 | epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", | 933 | epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", |
939 | urb->transfer_buffer_length, | 934 | urb->transfer_buffer_length, |
940 | qtd, ep->hcpriv); | 935 | qtd, urb->ep->hcpriv); |
941 | #endif | 936 | #endif |
942 | 937 | ||
943 | spin_lock_irqsave (&ehci->lock, flags); | 938 | spin_lock_irqsave (&ehci->lock, flags); |
@@ -946,9 +941,13 @@ submit_async ( | |||
946 | rc = -ESHUTDOWN; | 941 | rc = -ESHUTDOWN; |
947 | goto done; | 942 | goto done; |
948 | } | 943 | } |
944 | rc = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); | ||
945 | if (unlikely(rc)) | ||
946 | goto done; | ||
949 | 947 | ||
950 | qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv); | 948 | qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); |
951 | if (unlikely(qh == NULL)) { | 949 | if (unlikely(qh == NULL)) { |
950 | usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); | ||
952 | rc = -ENOMEM; | 951 | rc = -ENOMEM; |
953 | goto done; | 952 | goto done; |
954 | } | 953 | } |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index d4a8ace4967..80d99bce2b3 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -479,109 +479,6 @@ static int disable_periodic (struct ehci_hcd *ehci) | |||
479 | } | 479 | } |
480 | 480 | ||
481 | /*-------------------------------------------------------------------------*/ | 481 | /*-------------------------------------------------------------------------*/ |
482 | #ifdef CONFIG_CPU_FREQ | ||
483 | |||
484 | static int safe_to_modify_i (struct ehci_hcd *ehci, struct ehci_qh *qh) | ||
485 | { | ||
486 | int now; /* current (frame * 8) + uframe */ | ||
487 | int prev_start, next_start; /* uframes from/to split start */ | ||
488 | int start_uframe = ffs(le32_to_cpup (&qh->hw_info2) & QH_SMASK); | ||
489 | int end_uframe = fls((le32_to_cpup (&qh->hw_info2) & QH_CMASK) >> 8); | ||
490 | int split_duration = end_uframe - start_uframe; | ||
491 | |||
492 | now = readl(&ehci->regs->frame_index) % (ehci->periodic_size << 3); | ||
493 | |||
494 | next_start = ((1024 << 3) + (qh->start << 3) + start_uframe - now) | ||
495 | % (qh->period << 3); | ||
496 | prev_start = (qh->period << 3) - next_start; | ||
497 | |||
498 | /* | ||
499 | * Make sure there will be at least one uframe when qh is safe. | ||
500 | */ | ||
501 | if ((qh->period << 3) <= (ehci->i_thresh + 2 + split_duration)) | ||
502 | /* never safe */ | ||
503 | return -EINVAL; | ||
504 | |||
505 | /* | ||
506 | * Wait 1 uframe after transaction should have started, to make | ||
507 | * sure controller has time to write back overlay, so we can | ||
508 | * check QTD_STS_STS to see if transaction is in progress. | ||
509 | */ | ||
510 | if ((next_start > ehci->i_thresh) && (prev_start > 1)) | ||
511 | /* safe to set "i" bit if split isn't in progress */ | ||
512 | return (qh->hw_token & STATUS_BIT(ehci)) ? 0 : 1; | ||
513 | else | ||
514 | return 0; | ||
515 | } | ||
516 | |||
517 | /* Set inactivate bit for all the split interrupt QHs. */ | ||
518 | static void qh_inactivate_split_intr_qhs (struct ehci_hcd *ehci) | ||
519 | { | ||
520 | struct ehci_qh *qh; | ||
521 | int not_done, safe; | ||
522 | u32 inactivate = INACTIVATE_BIT(ehci); | ||
523 | u32 active = ACTIVE_BIT(ehci); | ||
524 | |||
525 | do { | ||
526 | not_done = 0; | ||
527 | list_for_each_entry(qh, &ehci->split_intr_qhs, | ||
528 | split_intr_qhs) { | ||
529 | if (qh->hw_info1 & inactivate) | ||
530 | /* already off */ | ||
531 | continue; | ||
532 | /* | ||
533 | * To avoid setting "I" after the start split happens, | ||
534 | * don't set it if the QH might be cached in the | ||
535 | * controller. Some HCs (Broadcom/ServerWorks HT1000) | ||
536 | * will stop in the middle of a split transaction when | ||
537 | * the "I" bit is set. | ||
538 | */ | ||
539 | safe = safe_to_modify_i(ehci, qh); | ||
540 | if (safe == 0) { | ||
541 | not_done = 1; | ||
542 | } else if (safe > 0) { | ||
543 | qh->was_active = qh->hw_token & active; | ||
544 | qh->hw_info1 |= inactivate; | ||
545 | } | ||
546 | } | ||
547 | } while (not_done); | ||
548 | wmb(); | ||
549 | } | ||
550 | |||
551 | static void qh_reactivate_split_intr_qhs (struct ehci_hcd *ehci) | ||
552 | { | ||
553 | struct ehci_qh *qh; | ||
554 | u32 token; | ||
555 | int not_done, safe; | ||
556 | u32 inactivate = INACTIVATE_BIT(ehci); | ||
557 | u32 active = ACTIVE_BIT(ehci); | ||
558 | u32 halt = HALT_BIT(ehci); | ||
559 | |||
560 | do { | ||
561 | not_done = 0; | ||
562 | list_for_each_entry(qh, &ehci->split_intr_qhs, split_intr_qhs) { | ||
563 | if (!(qh->hw_info1 & inactivate)) /* already on */ | ||
564 | continue; | ||
565 | /* | ||
566 | * Don't reactivate if cached, or controller might | ||
567 | * overwrite overlay after we modify it! | ||
568 | */ | ||
569 | safe = safe_to_modify_i(ehci, qh); | ||
570 | if (safe == 0) { | ||
571 | not_done = 1; | ||
572 | } else if (safe > 0) { | ||
573 | /* See EHCI 1.0 section 4.15.2.4. */ | ||
574 | token = qh->hw_token; | ||
575 | qh->hw_token = (token | halt) & ~active; | ||
576 | wmb(); | ||
577 | qh->hw_info1 &= ~inactivate; | ||
578 | wmb(); | ||
579 | qh->hw_token = (token & ~halt) | qh->was_active; | ||
580 | } | ||
581 | } | ||
582 | } while (not_done); | ||
583 | } | ||
584 | #endif | ||
585 | 482 | ||
586 | /* periodic schedule slots have iso tds (normal or split) first, then a | 483 | /* periodic schedule slots have iso tds (normal or split) first, then a |
587 | * sparse tree for active interrupt transfers. | 484 | * sparse tree for active interrupt transfers. |
@@ -599,17 +496,6 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
599 | period, hc32_to_cpup(ehci, &qh->hw_info2) & (QH_CMASK | QH_SMASK), | 496 | period, hc32_to_cpup(ehci, &qh->hw_info2) & (QH_CMASK | QH_SMASK), |
600 | qh, qh->start, qh->usecs, qh->c_usecs); | 497 | qh, qh->start, qh->usecs, qh->c_usecs); |
601 | 498 | ||
602 | #ifdef CONFIG_CPU_FREQ | ||
603 | /* | ||
604 | * If low/full speed interrupt QHs are inactive (because of | ||
605 | * cpufreq changing processor speeds), start QH with I flag set-- | ||
606 | * it will automatically be cleared when cpufreq is done. | ||
607 | */ | ||
608 | if (ehci->cpufreq_changing) | ||
609 | if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) | ||
610 | qh->hw_info1 |= INACTIVATE_BIT(ehci); | ||
611 | #endif | ||
612 | |||
613 | /* high bandwidth, or otherwise every microframe */ | 499 | /* high bandwidth, or otherwise every microframe */ |
614 | if (period == 0) | 500 | if (period == 0) |
615 | period = 1; | 501 | period = 1; |
@@ -658,12 +544,6 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
658 | ? ((qh->usecs + qh->c_usecs) / qh->period) | 544 | ? ((qh->usecs + qh->c_usecs) / qh->period) |
659 | : (qh->usecs * 8); | 545 | : (qh->usecs * 8); |
660 | 546 | ||
661 | #ifdef CONFIG_CPU_FREQ | ||
662 | /* add qh to list of low/full speed interrupt QHs, if applicable */ | ||
663 | if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) { | ||
664 | list_add(&qh->split_intr_qhs, &ehci->split_intr_qhs); | ||
665 | } | ||
666 | #endif | ||
667 | /* maybe enable periodic schedule processing */ | 547 | /* maybe enable periodic schedule processing */ |
668 | if (!ehci->periodic_sched++) | 548 | if (!ehci->periodic_sched++) |
669 | return enable_periodic (ehci); | 549 | return enable_periodic (ehci); |
@@ -683,13 +563,6 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
683 | // THEN | 563 | // THEN |
684 | // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */); | 564 | // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */); |
685 | 565 | ||
686 | #ifdef CONFIG_CPU_FREQ | ||
687 | /* remove qh from list of low/full speed interrupt QHs */ | ||
688 | if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) { | ||
689 | list_del_init(&qh->split_intr_qhs); | ||
690 | } | ||
691 | #endif | ||
692 | |||
693 | /* high bandwidth, or otherwise part of every microframe */ | 566 | /* high bandwidth, or otherwise part of every microframe */ |
694 | if ((period = qh->period) == 0) | 567 | if ((period = qh->period) == 0) |
695 | period = 1; | 568 | period = 1; |
@@ -924,7 +797,6 @@ done: | |||
924 | 797 | ||
925 | static int intr_submit ( | 798 | static int intr_submit ( |
926 | struct ehci_hcd *ehci, | 799 | struct ehci_hcd *ehci, |
927 | struct usb_host_endpoint *ep, | ||
928 | struct urb *urb, | 800 | struct urb *urb, |
929 | struct list_head *qtd_list, | 801 | struct list_head *qtd_list, |
930 | gfp_t mem_flags | 802 | gfp_t mem_flags |
@@ -932,23 +804,26 @@ static int intr_submit ( | |||
932 | unsigned epnum; | 804 | unsigned epnum; |
933 | unsigned long flags; | 805 | unsigned long flags; |
934 | struct ehci_qh *qh; | 806 | struct ehci_qh *qh; |
935 | int status = 0; | 807 | int status; |
936 | struct list_head empty; | 808 | struct list_head empty; |
937 | 809 | ||
938 | /* get endpoint and transfer/schedule data */ | 810 | /* get endpoint and transfer/schedule data */ |
939 | epnum = ep->desc.bEndpointAddress; | 811 | epnum = urb->ep->desc.bEndpointAddress; |
940 | 812 | ||
941 | spin_lock_irqsave (&ehci->lock, flags); | 813 | spin_lock_irqsave (&ehci->lock, flags); |
942 | 814 | ||
943 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 815 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, |
944 | &ehci_to_hcd(ehci)->flags))) { | 816 | &ehci_to_hcd(ehci)->flags))) { |
945 | status = -ESHUTDOWN; | 817 | status = -ESHUTDOWN; |
946 | goto done; | 818 | goto done_not_linked; |
947 | } | 819 | } |
820 | status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); | ||
821 | if (unlikely(status)) | ||
822 | goto done_not_linked; | ||
948 | 823 | ||
949 | /* get qh and force any scheduling errors */ | 824 | /* get qh and force any scheduling errors */ |
950 | INIT_LIST_HEAD (&empty); | 825 | INIT_LIST_HEAD (&empty); |
951 | qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv); | 826 | qh = qh_append_tds(ehci, urb, &empty, epnum, &urb->ep->hcpriv); |
952 | if (qh == NULL) { | 827 | if (qh == NULL) { |
953 | status = -ENOMEM; | 828 | status = -ENOMEM; |
954 | goto done; | 829 | goto done; |
@@ -959,13 +834,16 @@ static int intr_submit ( | |||
959 | } | 834 | } |
960 | 835 | ||
961 | /* then queue the urb's tds to the qh */ | 836 | /* then queue the urb's tds to the qh */ |
962 | qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv); | 837 | qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); |
963 | BUG_ON (qh == NULL); | 838 | BUG_ON (qh == NULL); |
964 | 839 | ||
965 | /* ... update usbfs periodic stats */ | 840 | /* ... update usbfs periodic stats */ |
966 | ehci_to_hcd(ehci)->self.bandwidth_int_reqs++; | 841 | ehci_to_hcd(ehci)->self.bandwidth_int_reqs++; |
967 | 842 | ||
968 | done: | 843 | done: |
844 | if (unlikely(status)) | ||
845 | usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); | ||
846 | done_not_linked: | ||
969 | spin_unlock_irqrestore (&ehci->lock, flags); | 847 | spin_unlock_irqrestore (&ehci->lock, flags); |
970 | if (status) | 848 | if (status) |
971 | qtd_list_free (ehci, urb, qtd_list); | 849 | qtd_list_free (ehci, urb, qtd_list); |
@@ -1749,7 +1627,7 @@ itd_complete ( | |||
1749 | 1627 | ||
1750 | /* give urb back to the driver ... can be out-of-order */ | 1628 | /* give urb back to the driver ... can be out-of-order */ |
1751 | dev = urb->dev; | 1629 | dev = urb->dev; |
1752 | ehci_urb_done (ehci, urb); | 1630 | ehci_urb_done(ehci, urb, 0); |
1753 | urb = NULL; | 1631 | urb = NULL; |
1754 | 1632 | ||
1755 | /* defer stopping schedule; completion can submit */ | 1633 | /* defer stopping schedule; completion can submit */ |
@@ -1813,12 +1691,19 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
1813 | /* schedule ... need to lock */ | 1691 | /* schedule ... need to lock */ |
1814 | spin_lock_irqsave (&ehci->lock, flags); | 1692 | spin_lock_irqsave (&ehci->lock, flags); |
1815 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1693 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, |
1816 | &ehci_to_hcd(ehci)->flags))) | 1694 | &ehci_to_hcd(ehci)->flags))) { |
1817 | status = -ESHUTDOWN; | 1695 | status = -ESHUTDOWN; |
1818 | else | 1696 | goto done_not_linked; |
1819 | status = iso_stream_schedule (ehci, urb, stream); | 1697 | } |
1698 | status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); | ||
1699 | if (unlikely(status)) | ||
1700 | goto done_not_linked; | ||
1701 | status = iso_stream_schedule(ehci, urb, stream); | ||
1820 | if (likely (status == 0)) | 1702 | if (likely (status == 0)) |
1821 | itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); | 1703 | itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); |
1704 | else | ||
1705 | usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); | ||
1706 | done_not_linked: | ||
1822 | spin_unlock_irqrestore (&ehci->lock, flags); | 1707 | spin_unlock_irqrestore (&ehci->lock, flags); |
1823 | 1708 | ||
1824 | done: | 1709 | done: |
@@ -2115,7 +2000,7 @@ sitd_complete ( | |||
2115 | 2000 | ||
2116 | /* give urb back to the driver */ | 2001 | /* give urb back to the driver */ |
2117 | dev = urb->dev; | 2002 | dev = urb->dev; |
2118 | ehci_urb_done (ehci, urb); | 2003 | ehci_urb_done(ehci, urb, 0); |
2119 | urb = NULL; | 2004 | urb = NULL; |
2120 | 2005 | ||
2121 | /* defer stopping schedule; completion can submit */ | 2006 | /* defer stopping schedule; completion can submit */ |
@@ -2176,12 +2061,19 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
2176 | /* schedule ... need to lock */ | 2061 | /* schedule ... need to lock */ |
2177 | spin_lock_irqsave (&ehci->lock, flags); | 2062 | spin_lock_irqsave (&ehci->lock, flags); |
2178 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 2063 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, |
2179 | &ehci_to_hcd(ehci)->flags))) | 2064 | &ehci_to_hcd(ehci)->flags))) { |
2180 | status = -ESHUTDOWN; | 2065 | status = -ESHUTDOWN; |
2181 | else | 2066 | goto done_not_linked; |
2182 | status = iso_stream_schedule (ehci, urb, stream); | 2067 | } |
2068 | status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); | ||
2069 | if (unlikely(status)) | ||
2070 | goto done_not_linked; | ||
2071 | status = iso_stream_schedule(ehci, urb, stream); | ||
2183 | if (status == 0) | 2072 | if (status == 0) |
2184 | sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); | 2073 | sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); |
2074 | else | ||
2075 | usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); | ||
2076 | done_not_linked: | ||
2185 | spin_unlock_irqrestore (&ehci->lock, flags); | 2077 | spin_unlock_irqrestore (&ehci->lock, flags); |
2186 | 2078 | ||
2187 | done: | 2079 | done: |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 2c68a04230c..951d69fec51 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -71,12 +71,6 @@ struct ehci_hcd { /* one per controller */ | |||
71 | __u32 hcs_params; /* cached register copy */ | 71 | __u32 hcs_params; /* cached register copy */ |
72 | spinlock_t lock; | 72 | spinlock_t lock; |
73 | 73 | ||
74 | #ifdef CONFIG_CPU_FREQ | ||
75 | struct notifier_block cpufreq_transition; | ||
76 | int cpufreq_changing; | ||
77 | struct list_head split_intr_qhs; | ||
78 | #endif | ||
79 | |||
80 | /* async schedule support */ | 74 | /* async schedule support */ |
81 | struct ehci_qh *async; | 75 | struct ehci_qh *async; |
82 | struct ehci_qh *reclaim; | 76 | struct ehci_qh *reclaim; |
@@ -439,10 +433,6 @@ struct ehci_qh { | |||
439 | __hc32 hw_next; /* see EHCI 3.6.1 */ | 433 | __hc32 hw_next; /* see EHCI 3.6.1 */ |
440 | __hc32 hw_info1; /* see EHCI 3.6.2 */ | 434 | __hc32 hw_info1; /* see EHCI 3.6.2 */ |
441 | #define QH_HEAD 0x00008000 | 435 | #define QH_HEAD 0x00008000 |
442 | #define QH_INACTIVATE 0x00000080 | ||
443 | |||
444 | #define INACTIVATE_BIT(ehci) cpu_to_hc32(ehci, QH_INACTIVATE) | ||
445 | |||
446 | __hc32 hw_info2; /* see EHCI 3.6.2 */ | 436 | __hc32 hw_info2; /* see EHCI 3.6.2 */ |
447 | #define QH_SMASK 0x000000ff | 437 | #define QH_SMASK 0x000000ff |
448 | #define QH_CMASK 0x0000ff00 | 438 | #define QH_CMASK 0x0000ff00 |
@@ -492,10 +482,6 @@ struct ehci_qh { | |||
492 | unsigned short start; /* where polling starts */ | 482 | unsigned short start; /* where polling starts */ |
493 | #define NO_FRAME ((unsigned short)~0) /* pick new start */ | 483 | #define NO_FRAME ((unsigned short)~0) /* pick new start */ |
494 | struct usb_device *dev; /* access to TT */ | 484 | struct usb_device *dev; /* access to TT */ |
495 | #ifdef CONFIG_CPU_FREQ | ||
496 | struct list_head split_intr_qhs; /* list of split qhs */ | ||
497 | __le32 was_active; /* active bit before "i" set */ | ||
498 | #endif | ||
499 | } __attribute__ ((aligned (32))); | 485 | } __attribute__ ((aligned (32))); |
500 | 486 | ||
501 | /*-------------------------------------------------------------------------*/ | 487 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 46873f2534b..c27417f5b9d 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -228,7 +228,6 @@ static void preproc_atl_queue(struct isp116x *isp116x) | |||
228 | struct urb, urb_list); | 228 | struct urb, urb_list); |
229 | ptd = &ep->ptd; | 229 | ptd = &ep->ptd; |
230 | len = ep->length; | 230 | len = ep->length; |
231 | spin_lock(&urb->lock); | ||
232 | ep->data = (unsigned char *)urb->transfer_buffer | 231 | ep->data = (unsigned char *)urb->transfer_buffer |
233 | + urb->actual_length; | 232 | + urb->actual_length; |
234 | 233 | ||
@@ -264,7 +263,6 @@ static void preproc_atl_queue(struct isp116x *isp116x) | |||
264 | | PTD_EP(ep->epnum); | 263 | | PTD_EP(ep->epnum); |
265 | ptd->len = PTD_LEN(len) | PTD_DIR(dir); | 264 | ptd->len = PTD_LEN(len) | PTD_DIR(dir); |
266 | ptd->faddr = PTD_FA(usb_pipedevice(urb->pipe)); | 265 | ptd->faddr = PTD_FA(usb_pipedevice(urb->pipe)); |
267 | spin_unlock(&urb->lock); | ||
268 | if (!ep->active) { | 266 | if (!ep->active) { |
269 | ptd->mps |= PTD_LAST_MSK; | 267 | ptd->mps |= PTD_LAST_MSK; |
270 | isp116x->atl_last_dir = dir; | 268 | isp116x->atl_last_dir = dir; |
@@ -275,6 +273,61 @@ static void preproc_atl_queue(struct isp116x *isp116x) | |||
275 | } | 273 | } |
276 | 274 | ||
277 | /* | 275 | /* |
276 | Take done or failed requests out of schedule. Give back | ||
277 | processed urbs. | ||
278 | */ | ||
279 | static void finish_request(struct isp116x *isp116x, struct isp116x_ep *ep, | ||
280 | struct urb *urb, int status) | ||
281 | __releases(isp116x->lock) __acquires(isp116x->lock) | ||
282 | { | ||
283 | unsigned i; | ||
284 | |||
285 | ep->error_count = 0; | ||
286 | |||
287 | if (usb_pipecontrol(urb->pipe)) | ||
288 | ep->nextpid = USB_PID_SETUP; | ||
289 | |||
290 | urb_dbg(urb, "Finish"); | ||
291 | |||
292 | usb_hcd_unlink_urb_from_ep(isp116x_to_hcd(isp116x), urb); | ||
293 | spin_unlock(&isp116x->lock); | ||
294 | usb_hcd_giveback_urb(isp116x_to_hcd(isp116x), urb, status); | ||
295 | spin_lock(&isp116x->lock); | ||
296 | |||
297 | /* take idle endpoints out of the schedule */ | ||
298 | if (!list_empty(&ep->hep->urb_list)) | ||
299 | return; | ||
300 | |||
301 | /* async deschedule */ | ||
302 | if (!list_empty(&ep->schedule)) { | ||
303 | list_del_init(&ep->schedule); | ||
304 | return; | ||
305 | } | ||
306 | |||
307 | /* periodic deschedule */ | ||
308 | DBG("deschedule qh%d/%p branch %d\n", ep->period, ep, ep->branch); | ||
309 | for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) { | ||
310 | struct isp116x_ep *temp; | ||
311 | struct isp116x_ep **prev = &isp116x->periodic[i]; | ||
312 | |||
313 | while (*prev && ((temp = *prev) != ep)) | ||
314 | prev = &temp->next; | ||
315 | if (*prev) | ||
316 | *prev = ep->next; | ||
317 | isp116x->load[i] -= ep->load; | ||
318 | } | ||
319 | ep->branch = PERIODIC_SIZE; | ||
320 | isp116x_to_hcd(isp116x)->self.bandwidth_allocated -= | ||
321 | ep->load / ep->period; | ||
322 | |||
323 | /* switch irq type? */ | ||
324 | if (!--isp116x->periodic_count) { | ||
325 | isp116x->irqenb &= ~HCuPINT_SOF; | ||
326 | isp116x->irqenb |= HCuPINT_ATL; | ||
327 | } | ||
328 | } | ||
329 | |||
330 | /* | ||
278 | Analyze transfer results, handle partial transfers and errors | 331 | Analyze transfer results, handle partial transfers and errors |
279 | */ | 332 | */ |
280 | static void postproc_atl_queue(struct isp116x *isp116x) | 333 | static void postproc_atl_queue(struct isp116x *isp116x) |
@@ -284,6 +337,7 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
284 | struct usb_device *udev; | 337 | struct usb_device *udev; |
285 | struct ptd *ptd; | 338 | struct ptd *ptd; |
286 | int short_not_ok; | 339 | int short_not_ok; |
340 | int status; | ||
287 | u8 cc; | 341 | u8 cc; |
288 | 342 | ||
289 | for (ep = isp116x->atl_active; ep; ep = ep->active) { | 343 | for (ep = isp116x->atl_active; ep; ep = ep->active) { |
@@ -294,7 +348,7 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
294 | ptd = &ep->ptd; | 348 | ptd = &ep->ptd; |
295 | cc = PTD_GET_CC(ptd); | 349 | cc = PTD_GET_CC(ptd); |
296 | short_not_ok = 1; | 350 | short_not_ok = 1; |
297 | spin_lock(&urb->lock); | 351 | status = -EINPROGRESS; |
298 | 352 | ||
299 | /* Data underrun is special. For allowed underrun | 353 | /* Data underrun is special. For allowed underrun |
300 | we clear the error and continue as normal. For | 354 | we clear the error and continue as normal. For |
@@ -302,47 +356,36 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
302 | immediately while for control transfer, | 356 | immediately while for control transfer, |
303 | we do a STATUS stage. */ | 357 | we do a STATUS stage. */ |
304 | if (cc == TD_DATAUNDERRUN) { | 358 | if (cc == TD_DATAUNDERRUN) { |
305 | if (!(urb->transfer_flags & URB_SHORT_NOT_OK)) { | 359 | if (!(urb->transfer_flags & URB_SHORT_NOT_OK) || |
306 | DBG("Allowed data underrun\n"); | 360 | usb_pipecontrol(urb->pipe)) { |
361 | DBG("Allowed or control data underrun\n"); | ||
307 | cc = TD_CC_NOERROR; | 362 | cc = TD_CC_NOERROR; |
308 | short_not_ok = 0; | 363 | short_not_ok = 0; |
309 | } else { | 364 | } else { |
310 | ep->error_count = 1; | 365 | ep->error_count = 1; |
311 | if (usb_pipecontrol(urb->pipe)) | 366 | usb_settoggle(udev, ep->epnum, |
312 | ep->nextpid = USB_PID_ACK; | 367 | ep->nextpid == USB_PID_OUT, |
313 | else | 368 | PTD_GET_TOGGLE(ptd)); |
314 | usb_settoggle(udev, ep->epnum, | ||
315 | ep->nextpid == | ||
316 | USB_PID_OUT, | ||
317 | PTD_GET_TOGGLE(ptd)); | ||
318 | urb->actual_length += PTD_GET_COUNT(ptd); | 369 | urb->actual_length += PTD_GET_COUNT(ptd); |
319 | urb->status = cc_to_error[TD_DATAUNDERRUN]; | 370 | status = cc_to_error[TD_DATAUNDERRUN]; |
320 | spin_unlock(&urb->lock); | 371 | goto done; |
321 | continue; | ||
322 | } | 372 | } |
323 | } | 373 | } |
324 | /* Keep underrun error through the STATUS stage */ | ||
325 | if (urb->status == cc_to_error[TD_DATAUNDERRUN]) | ||
326 | cc = TD_DATAUNDERRUN; | ||
327 | 374 | ||
328 | if (cc != TD_CC_NOERROR && cc != TD_NOTACCESSED | 375 | if (cc != TD_CC_NOERROR && cc != TD_NOTACCESSED |
329 | && (++ep->error_count >= 3 || cc == TD_CC_STALL | 376 | && (++ep->error_count >= 3 || cc == TD_CC_STALL |
330 | || cc == TD_DATAOVERRUN)) { | 377 | || cc == TD_DATAOVERRUN)) { |
331 | if (urb->status == -EINPROGRESS) | 378 | status = cc_to_error[cc]; |
332 | urb->status = cc_to_error[cc]; | ||
333 | if (ep->nextpid == USB_PID_ACK) | 379 | if (ep->nextpid == USB_PID_ACK) |
334 | ep->nextpid = 0; | 380 | ep->nextpid = 0; |
335 | spin_unlock(&urb->lock); | 381 | goto done; |
336 | continue; | ||
337 | } | 382 | } |
338 | /* According to usb spec, zero-length Int transfer signals | 383 | /* According to usb spec, zero-length Int transfer signals |
339 | finishing of the urb. Hey, does this apply only | 384 | finishing of the urb. Hey, does this apply only |
340 | for IN endpoints? */ | 385 | for IN endpoints? */ |
341 | if (usb_pipeint(urb->pipe) && !PTD_GET_LEN(ptd)) { | 386 | if (usb_pipeint(urb->pipe) && !PTD_GET_LEN(ptd)) { |
342 | if (urb->status == -EINPROGRESS) | 387 | status = 0; |
343 | urb->status = 0; | 388 | goto done; |
344 | spin_unlock(&urb->lock); | ||
345 | continue; | ||
346 | } | 389 | } |
347 | 390 | ||
348 | /* Relax after previously failed, but later succeeded | 391 | /* Relax after previously failed, but later succeeded |
@@ -381,8 +424,8 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
381 | /* All data for this URB is transferred, let's finish */ | 424 | /* All data for this URB is transferred, let's finish */ |
382 | if (usb_pipecontrol(urb->pipe)) | 425 | if (usb_pipecontrol(urb->pipe)) |
383 | ep->nextpid = USB_PID_ACK; | 426 | ep->nextpid = USB_PID_ACK; |
384 | else if (urb->status == -EINPROGRESS) | 427 | else |
385 | urb->status = 0; | 428 | status = 0; |
386 | break; | 429 | break; |
387 | case USB_PID_SETUP: | 430 | case USB_PID_SETUP: |
388 | if (PTD_GET_ACTIVE(ptd) | 431 | if (PTD_GET_ACTIVE(ptd) |
@@ -402,69 +445,16 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
402 | if (PTD_GET_ACTIVE(ptd) | 445 | if (PTD_GET_ACTIVE(ptd) |
403 | || (cc != TD_CC_NOERROR && cc < 0x0E)) | 446 | || (cc != TD_CC_NOERROR && cc < 0x0E)) |
404 | break; | 447 | break; |
405 | if (urb->status == -EINPROGRESS) | 448 | status = 0; |
406 | urb->status = 0; | ||
407 | ep->nextpid = 0; | 449 | ep->nextpid = 0; |
408 | break; | 450 | break; |
409 | default: | 451 | default: |
410 | BUG(); | 452 | BUG(); |
411 | } | 453 | } |
412 | spin_unlock(&urb->lock); | ||
413 | } | ||
414 | } | ||
415 | 454 | ||
416 | /* | 455 | done: |
417 | Take done or failed requests out of schedule. Give back | 456 | if (status != -EINPROGRESS || urb->unlinked) |
418 | processed urbs. | 457 | finish_request(isp116x, ep, urb, status); |
419 | */ | ||
420 | static void finish_request(struct isp116x *isp116x, struct isp116x_ep *ep, | ||
421 | struct urb *urb) | ||
422 | __releases(isp116x->lock) __acquires(isp116x->lock) | ||
423 | { | ||
424 | unsigned i; | ||
425 | |||
426 | urb->hcpriv = NULL; | ||
427 | ep->error_count = 0; | ||
428 | |||
429 | if (usb_pipecontrol(urb->pipe)) | ||
430 | ep->nextpid = USB_PID_SETUP; | ||
431 | |||
432 | urb_dbg(urb, "Finish"); | ||
433 | |||
434 | spin_unlock(&isp116x->lock); | ||
435 | usb_hcd_giveback_urb(isp116x_to_hcd(isp116x), urb); | ||
436 | spin_lock(&isp116x->lock); | ||
437 | |||
438 | /* take idle endpoints out of the schedule */ | ||
439 | if (!list_empty(&ep->hep->urb_list)) | ||
440 | return; | ||
441 | |||
442 | /* async deschedule */ | ||
443 | if (!list_empty(&ep->schedule)) { | ||
444 | list_del_init(&ep->schedule); | ||
445 | return; | ||
446 | } | ||
447 | |||
448 | /* periodic deschedule */ | ||
449 | DBG("deschedule qh%d/%p branch %d\n", ep->period, ep, ep->branch); | ||
450 | for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) { | ||
451 | struct isp116x_ep *temp; | ||
452 | struct isp116x_ep **prev = &isp116x->periodic[i]; | ||
453 | |||
454 | while (*prev && ((temp = *prev) != ep)) | ||
455 | prev = &temp->next; | ||
456 | if (*prev) | ||
457 | *prev = ep->next; | ||
458 | isp116x->load[i] -= ep->load; | ||
459 | } | ||
460 | ep->branch = PERIODIC_SIZE; | ||
461 | isp116x_to_hcd(isp116x)->self.bandwidth_allocated -= | ||
462 | ep->load / ep->period; | ||
463 | |||
464 | /* switch irq type? */ | ||
465 | if (!--isp116x->periodic_count) { | ||
466 | isp116x->irqenb &= ~HCuPINT_SOF; | ||
467 | isp116x->irqenb |= HCuPINT_ATL; | ||
468 | } | 458 | } |
469 | } | 459 | } |
470 | 460 | ||
@@ -570,9 +560,6 @@ static void start_atl_transfers(struct isp116x *isp116x) | |||
570 | */ | 560 | */ |
571 | static void finish_atl_transfers(struct isp116x *isp116x) | 561 | static void finish_atl_transfers(struct isp116x *isp116x) |
572 | { | 562 | { |
573 | struct isp116x_ep *ep; | ||
574 | struct urb *urb; | ||
575 | |||
576 | if (!isp116x->atl_active) | 563 | if (!isp116x->atl_active) |
577 | return; | 564 | return; |
578 | /* Fifo not ready? */ | 565 | /* Fifo not ready? */ |
@@ -582,16 +569,6 @@ static void finish_atl_transfers(struct isp116x *isp116x) | |||
582 | atomic_inc(&isp116x->atl_finishing); | 569 | atomic_inc(&isp116x->atl_finishing); |
583 | unpack_fifo(isp116x); | 570 | unpack_fifo(isp116x); |
584 | postproc_atl_queue(isp116x); | 571 | postproc_atl_queue(isp116x); |
585 | for (ep = isp116x->atl_active; ep; ep = ep->active) { | ||
586 | urb = | ||
587 | container_of(ep->hep->urb_list.next, struct urb, urb_list); | ||
588 | /* USB_PID_ACK check here avoids finishing of | ||
589 | control transfers, for which TD_DATAUNDERRUN | ||
590 | occured, while URB_SHORT_NOT_OK was set */ | ||
591 | if (urb && urb->status != -EINPROGRESS | ||
592 | && ep->nextpid != USB_PID_ACK) | ||
593 | finish_request(isp116x, ep, urb); | ||
594 | } | ||
595 | atomic_dec(&isp116x->atl_finishing); | 572 | atomic_dec(&isp116x->atl_finishing); |
596 | } | 573 | } |
597 | 574 | ||
@@ -685,7 +662,7 @@ static int balance(struct isp116x *isp116x, u16 period, u16 load) | |||
685 | /*-----------------------------------------------------------------*/ | 662 | /*-----------------------------------------------------------------*/ |
686 | 663 | ||
687 | static int isp116x_urb_enqueue(struct usb_hcd *hcd, | 664 | static int isp116x_urb_enqueue(struct usb_hcd *hcd, |
688 | struct usb_host_endpoint *hep, struct urb *urb, | 665 | struct urb *urb, |
689 | gfp_t mem_flags) | 666 | gfp_t mem_flags) |
690 | { | 667 | { |
691 | struct isp116x *isp116x = hcd_to_isp116x(hcd); | 668 | struct isp116x *isp116x = hcd_to_isp116x(hcd); |
@@ -694,6 +671,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, | |||
694 | int is_out = !usb_pipein(pipe); | 671 | int is_out = !usb_pipein(pipe); |
695 | int type = usb_pipetype(pipe); | 672 | int type = usb_pipetype(pipe); |
696 | int epnum = usb_pipeendpoint(pipe); | 673 | int epnum = usb_pipeendpoint(pipe); |
674 | struct usb_host_endpoint *hep = urb->ep; | ||
697 | struct isp116x_ep *ep = NULL; | 675 | struct isp116x_ep *ep = NULL; |
698 | unsigned long flags; | 676 | unsigned long flags; |
699 | int i; | 677 | int i; |
@@ -717,7 +695,12 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, | |||
717 | if (!HC_IS_RUNNING(hcd->state)) { | 695 | if (!HC_IS_RUNNING(hcd->state)) { |
718 | kfree(ep); | 696 | kfree(ep); |
719 | ret = -ENODEV; | 697 | ret = -ENODEV; |
720 | goto fail; | 698 | goto fail_not_linked; |
699 | } | ||
700 | ret = usb_hcd_link_urb_to_ep(hcd, urb); | ||
701 | if (ret) { | ||
702 | kfree(ep); | ||
703 | goto fail_not_linked; | ||
721 | } | 704 | } |
722 | 705 | ||
723 | if (hep->hcpriv) | 706 | if (hep->hcpriv) |
@@ -820,19 +803,13 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, | |||
820 | } | 803 | } |
821 | } | 804 | } |
822 | 805 | ||
823 | /* in case of unlink-during-submit */ | ||
824 | spin_lock(&urb->lock); | ||
825 | if (urb->status != -EINPROGRESS) { | ||
826 | spin_unlock(&urb->lock); | ||
827 | finish_request(isp116x, ep, urb); | ||
828 | ret = 0; | ||
829 | goto fail; | ||
830 | } | ||
831 | urb->hcpriv = hep; | 806 | urb->hcpriv = hep; |
832 | spin_unlock(&urb->lock); | ||
833 | start_atl_transfers(isp116x); | 807 | start_atl_transfers(isp116x); |
834 | 808 | ||
835 | fail: | 809 | fail: |
810 | if (ret) | ||
811 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
812 | fail_not_linked: | ||
836 | spin_unlock_irqrestore(&isp116x->lock, flags); | 813 | spin_unlock_irqrestore(&isp116x->lock, flags); |
837 | return ret; | 814 | return ret; |
838 | } | 815 | } |
@@ -840,20 +817,21 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, | |||
840 | /* | 817 | /* |
841 | Dequeue URBs. | 818 | Dequeue URBs. |
842 | */ | 819 | */ |
843 | static int isp116x_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | 820 | static int isp116x_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, |
821 | int status) | ||
844 | { | 822 | { |
845 | struct isp116x *isp116x = hcd_to_isp116x(hcd); | 823 | struct isp116x *isp116x = hcd_to_isp116x(hcd); |
846 | struct usb_host_endpoint *hep; | 824 | struct usb_host_endpoint *hep; |
847 | struct isp116x_ep *ep, *ep_act; | 825 | struct isp116x_ep *ep, *ep_act; |
848 | unsigned long flags; | 826 | unsigned long flags; |
827 | int rc; | ||
849 | 828 | ||
850 | spin_lock_irqsave(&isp116x->lock, flags); | 829 | spin_lock_irqsave(&isp116x->lock, flags); |
830 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); | ||
831 | if (rc) | ||
832 | goto done; | ||
833 | |||
851 | hep = urb->hcpriv; | 834 | hep = urb->hcpriv; |
852 | /* URB already unlinked (or never linked)? */ | ||
853 | if (!hep) { | ||
854 | spin_unlock_irqrestore(&isp116x->lock, flags); | ||
855 | return 0; | ||
856 | } | ||
857 | ep = hep->hcpriv; | 835 | ep = hep->hcpriv; |
858 | WARN_ON(hep != ep->hep); | 836 | WARN_ON(hep != ep->hep); |
859 | 837 | ||
@@ -870,10 +848,10 @@ static int isp116x_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
870 | } | 848 | } |
871 | 849 | ||
872 | if (urb) | 850 | if (urb) |
873 | finish_request(isp116x, ep, urb); | 851 | finish_request(isp116x, ep, urb, status); |
874 | 852 | done: | |
875 | spin_unlock_irqrestore(&isp116x->lock, flags); | 853 | spin_unlock_irqrestore(&isp116x->lock, flags); |
876 | return 0; | 854 | return rc; |
877 | } | 855 | } |
878 | 856 | ||
879 | static void isp116x_endpoint_disable(struct usb_hcd *hcd, | 857 | static void isp116x_endpoint_disable(struct usb_hcd *hcd, |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 6f9e43e9a6c..ebab5ce8f5c 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -24,7 +24,7 @@ | |||
24 | * small: 0) header + data packets 1) just header | 24 | * small: 0) header + data packets 1) just header |
25 | */ | 25 | */ |
26 | static void __maybe_unused | 26 | static void __maybe_unused |
27 | urb_print (struct urb * urb, char * str, int small) | 27 | urb_print(struct urb * urb, char * str, int small, int status) |
28 | { | 28 | { |
29 | unsigned int pipe= urb->pipe; | 29 | unsigned int pipe= urb->pipe; |
30 | 30 | ||
@@ -34,7 +34,7 @@ urb_print (struct urb * urb, char * str, int small) | |||
34 | } | 34 | } |
35 | 35 | ||
36 | #ifndef OHCI_VERBOSE_DEBUG | 36 | #ifndef OHCI_VERBOSE_DEBUG |
37 | if (urb->status != 0) | 37 | if (status != 0) |
38 | #endif | 38 | #endif |
39 | dbg("%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d stat=%d", | 39 | dbg("%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d stat=%d", |
40 | str, | 40 | str, |
@@ -46,7 +46,7 @@ urb_print (struct urb * urb, char * str, int small) | |||
46 | urb->transfer_flags, | 46 | urb->transfer_flags, |
47 | urb->actual_length, | 47 | urb->actual_length, |
48 | urb->transfer_buffer_length, | 48 | urb->transfer_buffer_length, |
49 | urb->status); | 49 | status); |
50 | 50 | ||
51 | #ifdef OHCI_VERBOSE_DEBUG | 51 | #ifdef OHCI_VERBOSE_DEBUG |
52 | if (!small) { | 52 | if (!small) { |
@@ -66,7 +66,7 @@ urb_print (struct urb * urb, char * str, int small) | |||
66 | urb->transfer_buffer_length: urb->actual_length; | 66 | urb->transfer_buffer_length: urb->actual_length; |
67 | for (i = 0; i < 16 && i < len; i++) | 67 | for (i = 0; i < 16 && i < len; i++) |
68 | printk (" %02x", ((__u8 *) urb->transfer_buffer) [i]); | 68 | printk (" %02x", ((__u8 *) urb->transfer_buffer) [i]); |
69 | printk ("%s stat:%d\n", i < len? "...": "", urb->status); | 69 | printk ("%s stat:%d\n", i < len? "...": "", status); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | #endif | 72 | #endif |
@@ -74,7 +74,7 @@ urb_print (struct urb * urb, char * str, int small) | |||
74 | 74 | ||
75 | #define ohci_dbg_sw(ohci, next, size, format, arg...) \ | 75 | #define ohci_dbg_sw(ohci, next, size, format, arg...) \ |
76 | do { \ | 76 | do { \ |
77 | if (next) { \ | 77 | if (next != NULL) { \ |
78 | unsigned s_len; \ | 78 | unsigned s_len; \ |
79 | s_len = scnprintf (*next, *size, format, ## arg ); \ | 79 | s_len = scnprintf (*next, *size, format, ## arg ); \ |
80 | *size -= s_len; *next += s_len; \ | 80 | *size -= s_len; *next += s_len; \ |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 2038125b7f8..240c7f50754 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -81,7 +81,6 @@ static void ohci_dump (struct ohci_hcd *ohci, int verbose); | |||
81 | static int ohci_init (struct ohci_hcd *ohci); | 81 | static int ohci_init (struct ohci_hcd *ohci); |
82 | static void ohci_stop (struct usb_hcd *hcd); | 82 | static void ohci_stop (struct usb_hcd *hcd); |
83 | static int ohci_restart (struct ohci_hcd *ohci); | 83 | static int ohci_restart (struct ohci_hcd *ohci); |
84 | static void ohci_quirk_nec_worker (struct work_struct *work); | ||
85 | 84 | ||
86 | #include "ohci-hub.c" | 85 | #include "ohci-hub.c" |
87 | #include "ohci-dbg.c" | 86 | #include "ohci-dbg.c" |
@@ -118,7 +117,6 @@ MODULE_PARM_DESC (no_handshake, "true (not default) disables BIOS handshake"); | |||
118 | */ | 117 | */ |
119 | static int ohci_urb_enqueue ( | 118 | static int ohci_urb_enqueue ( |
120 | struct usb_hcd *hcd, | 119 | struct usb_hcd *hcd, |
121 | struct usb_host_endpoint *ep, | ||
122 | struct urb *urb, | 120 | struct urb *urb, |
123 | gfp_t mem_flags | 121 | gfp_t mem_flags |
124 | ) { | 122 | ) { |
@@ -131,11 +129,11 @@ static int ohci_urb_enqueue ( | |||
131 | int retval = 0; | 129 | int retval = 0; |
132 | 130 | ||
133 | #ifdef OHCI_VERBOSE_DEBUG | 131 | #ifdef OHCI_VERBOSE_DEBUG |
134 | urb_print (urb, "SUB", usb_pipein (pipe)); | 132 | urb_print(urb, "SUB", usb_pipein(pipe), -EINPROGRESS); |
135 | #endif | 133 | #endif |
136 | 134 | ||
137 | /* every endpoint has a ed, locate and maybe (re)initialize it */ | 135 | /* every endpoint has a ed, locate and maybe (re)initialize it */ |
138 | if (! (ed = ed_get (ohci, ep, urb->dev, pipe, urb->interval))) | 136 | if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval))) |
139 | return -ENOMEM; | 137 | return -ENOMEM; |
140 | 138 | ||
141 | /* for the private part of the URB we need the number of TDs (size) */ | 139 | /* for the private part of the URB we need the number of TDs (size) */ |
@@ -171,11 +169,10 @@ static int ohci_urb_enqueue ( | |||
171 | } | 169 | } |
172 | 170 | ||
173 | /* allocate the private part of the URB */ | 171 | /* allocate the private part of the URB */ |
174 | urb_priv = kmalloc (sizeof (urb_priv_t) + size * sizeof (struct td *), | 172 | urb_priv = kzalloc (sizeof (urb_priv_t) + size * sizeof (struct td *), |
175 | mem_flags); | 173 | mem_flags); |
176 | if (!urb_priv) | 174 | if (!urb_priv) |
177 | return -ENOMEM; | 175 | return -ENOMEM; |
178 | memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (struct td *)); | ||
179 | INIT_LIST_HEAD (&urb_priv->pending); | 176 | INIT_LIST_HEAD (&urb_priv->pending); |
180 | urb_priv->length = size; | 177 | urb_priv->length = size; |
181 | urb_priv->ed = ed; | 178 | urb_priv->ed = ed; |
@@ -201,22 +198,17 @@ static int ohci_urb_enqueue ( | |||
201 | retval = -ENODEV; | 198 | retval = -ENODEV; |
202 | goto fail; | 199 | goto fail; |
203 | } | 200 | } |
204 | 201 | retval = usb_hcd_link_urb_to_ep(hcd, urb); | |
205 | /* in case of unlink-during-submit */ | 202 | if (retval) |
206 | spin_lock (&urb->lock); | ||
207 | if (urb->status != -EINPROGRESS) { | ||
208 | spin_unlock (&urb->lock); | ||
209 | urb->hcpriv = urb_priv; | ||
210 | finish_urb (ohci, urb); | ||
211 | retval = 0; | ||
212 | goto fail; | 203 | goto fail; |
213 | } | ||
214 | 204 | ||
215 | /* schedule the ed if needed */ | 205 | /* schedule the ed if needed */ |
216 | if (ed->state == ED_IDLE) { | 206 | if (ed->state == ED_IDLE) { |
217 | retval = ed_schedule (ohci, ed); | 207 | retval = ed_schedule (ohci, ed); |
218 | if (retval < 0) | 208 | if (retval < 0) { |
219 | goto fail0; | 209 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
210 | goto fail; | ||
211 | } | ||
220 | if (ed->type == PIPE_ISOCHRONOUS) { | 212 | if (ed->type == PIPE_ISOCHRONOUS) { |
221 | u16 frame = ohci_frame_no(ohci); | 213 | u16 frame = ohci_frame_no(ohci); |
222 | 214 | ||
@@ -240,8 +232,6 @@ static int ohci_urb_enqueue ( | |||
240 | urb->hcpriv = urb_priv; | 232 | urb->hcpriv = urb_priv; |
241 | td_submit_urb (ohci, urb); | 233 | td_submit_urb (ohci, urb); |
242 | 234 | ||
243 | fail0: | ||
244 | spin_unlock (&urb->lock); | ||
245 | fail: | 235 | fail: |
246 | if (retval) | 236 | if (retval) |
247 | urb_free_priv (ohci, urb_priv); | 237 | urb_free_priv (ohci, urb_priv); |
@@ -250,22 +240,26 @@ fail: | |||
250 | } | 240 | } |
251 | 241 | ||
252 | /* | 242 | /* |
253 | * decouple the URB from the HC queues (TDs, urb_priv); it's | 243 | * decouple the URB from the HC queues (TDs, urb_priv). |
254 | * already marked using urb->status. reporting is always done | 244 | * reporting is always done |
255 | * asynchronously, and we might be dealing with an urb that's | 245 | * asynchronously, and we might be dealing with an urb that's |
256 | * partially transferred, or an ED with other urbs being unlinked. | 246 | * partially transferred, or an ED with other urbs being unlinked. |
257 | */ | 247 | */ |
258 | static int ohci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) | 248 | static int ohci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
259 | { | 249 | { |
260 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 250 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
261 | unsigned long flags; | 251 | unsigned long flags; |
252 | int rc; | ||
262 | 253 | ||
263 | #ifdef OHCI_VERBOSE_DEBUG | 254 | #ifdef OHCI_VERBOSE_DEBUG |
264 | urb_print (urb, "UNLINK", 1); | 255 | urb_print(urb, "UNLINK", 1, status); |
265 | #endif | 256 | #endif |
266 | 257 | ||
267 | spin_lock_irqsave (&ohci->lock, flags); | 258 | spin_lock_irqsave (&ohci->lock, flags); |
268 | if (HC_IS_RUNNING(hcd->state)) { | 259 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); |
260 | if (rc) { | ||
261 | ; /* Do nothing */ | ||
262 | } else if (HC_IS_RUNNING(hcd->state)) { | ||
269 | urb_priv_t *urb_priv; | 263 | urb_priv_t *urb_priv; |
270 | 264 | ||
271 | /* Unless an IRQ completed the unlink while it was being | 265 | /* Unless an IRQ completed the unlink while it was being |
@@ -283,10 +277,10 @@ static int ohci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) | |||
283 | * any more ... just clean up every urb's memory. | 277 | * any more ... just clean up every urb's memory. |
284 | */ | 278 | */ |
285 | if (urb->hcpriv) | 279 | if (urb->hcpriv) |
286 | finish_urb (ohci, urb); | 280 | finish_urb(ohci, urb, status); |
287 | } | 281 | } |
288 | spin_unlock_irqrestore (&ohci->lock, flags); | 282 | spin_unlock_irqrestore (&ohci->lock, flags); |
289 | return 0; | 283 | return rc; |
290 | } | 284 | } |
291 | 285 | ||
292 | /*-------------------------------------------------------------------------*/ | 286 | /*-------------------------------------------------------------------------*/ |
@@ -315,6 +309,8 @@ rescan: | |||
315 | if (!HC_IS_RUNNING (hcd->state)) { | 309 | if (!HC_IS_RUNNING (hcd->state)) { |
316 | sanitize: | 310 | sanitize: |
317 | ed->state = ED_IDLE; | 311 | ed->state = ED_IDLE; |
312 | if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT) | ||
313 | ohci->eds_scheduled--; | ||
318 | finish_unlinks (ohci, 0); | 314 | finish_unlinks (ohci, 0); |
319 | } | 315 | } |
320 | 316 | ||
@@ -322,7 +318,12 @@ sanitize: | |||
322 | case ED_UNLINK: /* wait for hw to finish? */ | 318 | case ED_UNLINK: /* wait for hw to finish? */ |
323 | /* major IRQ delivery trouble loses INTR_SF too... */ | 319 | /* major IRQ delivery trouble loses INTR_SF too... */ |
324 | if (limit-- == 0) { | 320 | if (limit-- == 0) { |
325 | ohci_warn (ohci, "IRQ INTR_SF lossage\n"); | 321 | ohci_warn(ohci, "ED unlink timeout\n"); |
322 | if (quirk_zfmicro(ohci)) { | ||
323 | ohci_warn(ohci, "Attempting ZF TD recovery\n"); | ||
324 | ohci->ed_to_check = ed; | ||
325 | ohci->zf_delay = 2; | ||
326 | } | ||
326 | goto sanitize; | 327 | goto sanitize; |
327 | } | 328 | } |
328 | spin_unlock_irqrestore (&ohci->lock, flags); | 329 | spin_unlock_irqrestore (&ohci->lock, flags); |
@@ -380,6 +381,93 @@ ohci_shutdown (struct usb_hcd *hcd) | |||
380 | (void) ohci_readl (ohci, &ohci->regs->control); | 381 | (void) ohci_readl (ohci, &ohci->regs->control); |
381 | } | 382 | } |
382 | 383 | ||
384 | static int check_ed(struct ohci_hcd *ohci, struct ed *ed) | ||
385 | { | ||
386 | return (hc32_to_cpu(ohci, ed->hwINFO) & ED_IN) != 0 | ||
387 | && (hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK) | ||
388 | == (hc32_to_cpu(ohci, ed->hwTailP) & TD_MASK) | ||
389 | && !list_empty(&ed->td_list); | ||
390 | } | ||
391 | |||
392 | /* ZF Micro watchdog timer callback. The ZF Micro chipset sometimes completes | ||
393 | * an interrupt TD but neglects to add it to the donelist. On systems with | ||
394 | * this chipset, we need to periodically check the state of the queues to look | ||
395 | * for such "lost" TDs. | ||
396 | */ | ||
397 | static void unlink_watchdog_func(unsigned long _ohci) | ||
398 | { | ||
399 | long flags; | ||
400 | unsigned max; | ||
401 | unsigned seen_count = 0; | ||
402 | unsigned i; | ||
403 | struct ed **seen = NULL; | ||
404 | struct ohci_hcd *ohci = (struct ohci_hcd *) _ohci; | ||
405 | |||
406 | spin_lock_irqsave(&ohci->lock, flags); | ||
407 | max = ohci->eds_scheduled; | ||
408 | if (!max) | ||
409 | goto done; | ||
410 | |||
411 | if (ohci->ed_to_check) | ||
412 | goto out; | ||
413 | |||
414 | seen = kcalloc(max, sizeof *seen, GFP_ATOMIC); | ||
415 | if (!seen) | ||
416 | goto out; | ||
417 | |||
418 | for (i = 0; i < NUM_INTS; i++) { | ||
419 | struct ed *ed = ohci->periodic[i]; | ||
420 | |||
421 | while (ed) { | ||
422 | unsigned temp; | ||
423 | |||
424 | /* scan this branch of the periodic schedule tree */ | ||
425 | for (temp = 0; temp < seen_count; temp++) { | ||
426 | if (seen[temp] == ed) { | ||
427 | /* we've checked it and what's after */ | ||
428 | ed = NULL; | ||
429 | break; | ||
430 | } | ||
431 | } | ||
432 | if (!ed) | ||
433 | break; | ||
434 | seen[seen_count++] = ed; | ||
435 | if (!check_ed(ohci, ed)) { | ||
436 | ed = ed->ed_next; | ||
437 | continue; | ||
438 | } | ||
439 | |||
440 | /* HC's TD list is empty, but HCD sees at least one | ||
441 | * TD that's not been sent through the donelist. | ||
442 | */ | ||
443 | ohci->ed_to_check = ed; | ||
444 | ohci->zf_delay = 2; | ||
445 | |||
446 | /* The HC may wait until the next frame to report the | ||
447 | * TD as done through the donelist and INTR_WDH. (We | ||
448 | * just *assume* it's not a multi-TD interrupt URB; | ||
449 | * those could defer the IRQ more than one frame, using | ||
450 | * DI...) Check again after the next INTR_SF. | ||
451 | */ | ||
452 | ohci_writel(ohci, OHCI_INTR_SF, | ||
453 | &ohci->regs->intrstatus); | ||
454 | ohci_writel(ohci, OHCI_INTR_SF, | ||
455 | &ohci->regs->intrenable); | ||
456 | |||
457 | /* flush those writes */ | ||
458 | (void) ohci_readl(ohci, &ohci->regs->control); | ||
459 | |||
460 | goto out; | ||
461 | } | ||
462 | } | ||
463 | out: | ||
464 | kfree(seen); | ||
465 | if (ohci->eds_scheduled) | ||
466 | mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ)); | ||
467 | done: | ||
468 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
469 | } | ||
470 | |||
383 | /*-------------------------------------------------------------------------* | 471 | /*-------------------------------------------------------------------------* |
384 | * HC functions | 472 | * HC functions |
385 | *-------------------------------------------------------------------------*/ | 473 | *-------------------------------------------------------------------------*/ |
@@ -617,6 +705,15 @@ retry: | |||
617 | mdelay ((temp >> 23) & 0x1fe); | 705 | mdelay ((temp >> 23) & 0x1fe); |
618 | hcd->state = HC_STATE_RUNNING; | 706 | hcd->state = HC_STATE_RUNNING; |
619 | 707 | ||
708 | if (quirk_zfmicro(ohci)) { | ||
709 | /* Create timer to watch for bad queue state on ZF Micro */ | ||
710 | setup_timer(&ohci->unlink_watchdog, unlink_watchdog_func, | ||
711 | (unsigned long) ohci); | ||
712 | |||
713 | ohci->eds_scheduled = 0; | ||
714 | ohci->ed_to_check = NULL; | ||
715 | } | ||
716 | |||
620 | ohci_dump (ohci, 1); | 717 | ohci_dump (ohci, 1); |
621 | 718 | ||
622 | return 0; | 719 | return 0; |
@@ -630,10 +727,11 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
630 | { | 727 | { |
631 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 728 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
632 | struct ohci_regs __iomem *regs = ohci->regs; | 729 | struct ohci_regs __iomem *regs = ohci->regs; |
633 | int ints; | 730 | int ints; |
634 | 731 | ||
635 | /* we can eliminate a (slow) ohci_readl() | 732 | /* we can eliminate a (slow) ohci_readl() |
636 | if _only_ WDH caused this irq */ | 733 | * if _only_ WDH caused this irq |
734 | */ | ||
637 | if ((ohci->hcca->done_head != 0) | 735 | if ((ohci->hcca->done_head != 0) |
638 | && ! (hc32_to_cpup (ohci, &ohci->hcca->done_head) | 736 | && ! (hc32_to_cpup (ohci, &ohci->hcca->done_head) |
639 | & 0x01)) { | 737 | & 0x01)) { |
@@ -652,7 +750,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
652 | 750 | ||
653 | if (ints & OHCI_INTR_UE) { | 751 | if (ints & OHCI_INTR_UE) { |
654 | // e.g. due to PCI Master/Target Abort | 752 | // e.g. due to PCI Master/Target Abort |
655 | if (ohci->flags & OHCI_QUIRK_NEC) { | 753 | if (quirk_nec(ohci)) { |
656 | /* Workaround for a silicon bug in some NEC chips used | 754 | /* Workaround for a silicon bug in some NEC chips used |
657 | * in Apple's PowerBooks. Adapted from Darwin code. | 755 | * in Apple's PowerBooks. Adapted from Darwin code. |
658 | */ | 756 | */ |
@@ -714,6 +812,31 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
714 | ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrenable); | 812 | ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrenable); |
715 | } | 813 | } |
716 | 814 | ||
815 | if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) { | ||
816 | spin_lock(&ohci->lock); | ||
817 | if (ohci->ed_to_check) { | ||
818 | struct ed *ed = ohci->ed_to_check; | ||
819 | |||
820 | if (check_ed(ohci, ed)) { | ||
821 | /* HC thinks the TD list is empty; HCD knows | ||
822 | * at least one TD is outstanding | ||
823 | */ | ||
824 | if (--ohci->zf_delay == 0) { | ||
825 | struct td *td = list_entry( | ||
826 | ed->td_list.next, | ||
827 | struct td, td_list); | ||
828 | ohci_warn(ohci, | ||
829 | "Reclaiming orphan TD %p\n", | ||
830 | td); | ||
831 | takeback_td(ohci, td); | ||
832 | ohci->ed_to_check = NULL; | ||
833 | } | ||
834 | } else | ||
835 | ohci->ed_to_check = NULL; | ||
836 | } | ||
837 | spin_unlock(&ohci->lock); | ||
838 | } | ||
839 | |||
717 | /* could track INTR_SO to reduce available PCI/... bandwidth */ | 840 | /* could track INTR_SO to reduce available PCI/... bandwidth */ |
718 | 841 | ||
719 | /* handle any pending URB/ED unlinks, leaving INTR_SF enabled | 842 | /* handle any pending URB/ED unlinks, leaving INTR_SF enabled |
@@ -722,7 +845,9 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
722 | spin_lock (&ohci->lock); | 845 | spin_lock (&ohci->lock); |
723 | if (ohci->ed_rm_list) | 846 | if (ohci->ed_rm_list) |
724 | finish_unlinks (ohci, ohci_frame_no(ohci)); | 847 | finish_unlinks (ohci, ohci_frame_no(ohci)); |
725 | if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list | 848 | if ((ints & OHCI_INTR_SF) != 0 |
849 | && !ohci->ed_rm_list | ||
850 | && !ohci->ed_to_check | ||
726 | && HC_IS_RUNNING(hcd->state)) | 851 | && HC_IS_RUNNING(hcd->state)) |
727 | ohci_writel (ohci, OHCI_INTR_SF, ®s->intrdisable); | 852 | ohci_writel (ohci, OHCI_INTR_SF, ®s->intrdisable); |
728 | spin_unlock (&ohci->lock); | 853 | spin_unlock (&ohci->lock); |
@@ -752,6 +877,9 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
752 | free_irq(hcd->irq, hcd); | 877 | free_irq(hcd->irq, hcd); |
753 | hcd->irq = -1; | 878 | hcd->irq = -1; |
754 | 879 | ||
880 | if (quirk_zfmicro(ohci)) | ||
881 | del_timer(&ohci->unlink_watchdog); | ||
882 | |||
755 | remove_debug_files (ohci); | 883 | remove_debug_files (ohci); |
756 | ohci_mem_cleanup (ohci); | 884 | ohci_mem_cleanup (ohci); |
757 | if (ohci->hcca) { | 885 | if (ohci->hcca) { |
@@ -799,9 +927,8 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
799 | ed, ed->state); | 927 | ed, ed->state); |
800 | } | 928 | } |
801 | 929 | ||
802 | spin_lock (&urb->lock); | 930 | if (!urb->unlinked) |
803 | urb->status = -ESHUTDOWN; | 931 | urb->unlinked = -ESHUTDOWN; |
804 | spin_unlock (&urb->lock); | ||
805 | } | 932 | } |
806 | finish_unlinks (ohci, 0); | 933 | finish_unlinks (ohci, 0); |
807 | spin_unlock_irq(&ohci->lock); | 934 | spin_unlock_irq(&ohci->lock); |
@@ -829,27 +956,6 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
829 | 956 | ||
830 | /*-------------------------------------------------------------------------*/ | 957 | /*-------------------------------------------------------------------------*/ |
831 | 958 | ||
832 | /* NEC workaround */ | ||
833 | static void ohci_quirk_nec_worker(struct work_struct *work) | ||
834 | { | ||
835 | struct ohci_hcd *ohci = container_of(work, struct ohci_hcd, nec_work); | ||
836 | int status; | ||
837 | |||
838 | status = ohci_init(ohci); | ||
839 | if (status != 0) { | ||
840 | ohci_err(ohci, "Restarting NEC controller failed " | ||
841 | "in ohci_init, %d\n", status); | ||
842 | return; | ||
843 | } | ||
844 | |||
845 | status = ohci_restart(ohci); | ||
846 | if (status != 0) | ||
847 | ohci_err(ohci, "Restarting NEC controller failed " | ||
848 | "in ohci_restart, %d\n", status); | ||
849 | } | ||
850 | |||
851 | /*-------------------------------------------------------------------------*/ | ||
852 | |||
853 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 959 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC |
854 | 960 | ||
855 | MODULE_AUTHOR (DRIVER_AUTHOR); | 961 | MODULE_AUTHOR (DRIVER_AUTHOR); |
@@ -927,11 +1033,17 @@ MODULE_LICENSE ("GPL"); | |||
927 | #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver | 1033 | #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver |
928 | #endif | 1034 | #endif |
929 | 1035 | ||
1036 | #ifdef CONFIG_USB_OHCI_HCD_SSB | ||
1037 | #include "ohci-ssb.c" | ||
1038 | #define SSB_OHCI_DRIVER ssb_ohci_driver | ||
1039 | #endif | ||
1040 | |||
930 | #if !defined(PCI_DRIVER) && \ | 1041 | #if !defined(PCI_DRIVER) && \ |
931 | !defined(PLATFORM_DRIVER) && \ | 1042 | !defined(PLATFORM_DRIVER) && \ |
932 | !defined(OF_PLATFORM_DRIVER) && \ | 1043 | !defined(OF_PLATFORM_DRIVER) && \ |
933 | !defined(SA1111_DRIVER) && \ | 1044 | !defined(SA1111_DRIVER) && \ |
934 | !defined(PS3_SYSTEM_BUS_DRIVER) | 1045 | !defined(PS3_SYSTEM_BUS_DRIVER) && \ |
1046 | !defined(SSB_OHCI_DRIVER) | ||
935 | #error "missing bus glue for ohci-hcd" | 1047 | #error "missing bus glue for ohci-hcd" |
936 | #endif | 1048 | #endif |
937 | 1049 | ||
@@ -976,10 +1088,20 @@ static int __init ohci_hcd_mod_init(void) | |||
976 | goto error_pci; | 1088 | goto error_pci; |
977 | #endif | 1089 | #endif |
978 | 1090 | ||
1091 | #ifdef SSB_OHCI_DRIVER | ||
1092 | retval = ssb_driver_register(&SSB_OHCI_DRIVER); | ||
1093 | if (retval) | ||
1094 | goto error_ssb; | ||
1095 | #endif | ||
1096 | |||
979 | return retval; | 1097 | return retval; |
980 | 1098 | ||
981 | /* Error path */ | 1099 | /* Error path */ |
1100 | #ifdef SSB_OHCI_DRIVER | ||
1101 | error_ssb: | ||
1102 | #endif | ||
982 | #ifdef PCI_DRIVER | 1103 | #ifdef PCI_DRIVER |
1104 | pci_unregister_driver(&PCI_DRIVER); | ||
983 | error_pci: | 1105 | error_pci: |
984 | #endif | 1106 | #endif |
985 | #ifdef SA1111_DRIVER | 1107 | #ifdef SA1111_DRIVER |
@@ -1004,6 +1126,9 @@ module_init(ohci_hcd_mod_init); | |||
1004 | 1126 | ||
1005 | static void __exit ohci_hcd_mod_exit(void) | 1127 | static void __exit ohci_hcd_mod_exit(void) |
1006 | { | 1128 | { |
1129 | #ifdef SSB_OHCI_DRIVER | ||
1130 | ssb_driver_unregister(&SSB_OHCI_DRIVER); | ||
1131 | #endif | ||
1007 | #ifdef PCI_DRIVER | 1132 | #ifdef PCI_DRIVER |
1008 | pci_unregister_driver(&PCI_DRIVER); | 1133 | pci_unregister_driver(&PCI_DRIVER); |
1009 | #endif | 1134 | #endif |
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c index 450c7b460c5..2f20d3dc895 100644 --- a/drivers/usb/host/ohci-mem.c +++ b/drivers/usb/host/ohci-mem.c | |||
@@ -28,7 +28,6 @@ static void ohci_hcd_init (struct ohci_hcd *ohci) | |||
28 | ohci->next_statechange = jiffies; | 28 | ohci->next_statechange = jiffies; |
29 | spin_lock_init (&ohci->lock); | 29 | spin_lock_init (&ohci->lock); |
30 | INIT_LIST_HEAD (&ohci->pending); | 30 | INIT_LIST_HEAD (&ohci->pending); |
31 | INIT_WORK (&ohci->nec_work, ohci_quirk_nec_worker); | ||
32 | } | 31 | } |
33 | 32 | ||
34 | /*-------------------------------------------------------------------------*/ | 33 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index a5e2eb85d07..d0360f65ebd 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -84,7 +84,7 @@ static int ohci_quirk_zfmicro(struct usb_hcd *hcd) | |||
84 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 84 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
85 | 85 | ||
86 | ohci->flags |= OHCI_QUIRK_ZFMICRO; | 86 | ohci->flags |= OHCI_QUIRK_ZFMICRO; |
87 | ohci_dbg (ohci, "enabled Compaq ZFMicro chipset quirk\n"); | 87 | ohci_dbg(ohci, "enabled Compaq ZFMicro chipset quirks\n"); |
88 | 88 | ||
89 | return 0; | 89 | return 0; |
90 | } | 90 | } |
@@ -113,11 +113,31 @@ static int ohci_quirk_toshiba_scc(struct usb_hcd *hcd) | |||
113 | 113 | ||
114 | /* Check for NEC chip and apply quirk for allegedly lost interrupts. | 114 | /* Check for NEC chip and apply quirk for allegedly lost interrupts. |
115 | */ | 115 | */ |
116 | |||
117 | static void ohci_quirk_nec_worker(struct work_struct *work) | ||
118 | { | ||
119 | struct ohci_hcd *ohci = container_of(work, struct ohci_hcd, nec_work); | ||
120 | int status; | ||
121 | |||
122 | status = ohci_init(ohci); | ||
123 | if (status != 0) { | ||
124 | ohci_err(ohci, "Restarting NEC controller failed in %s, %d\n", | ||
125 | "ohci_init", status); | ||
126 | return; | ||
127 | } | ||
128 | |||
129 | status = ohci_restart(ohci); | ||
130 | if (status != 0) | ||
131 | ohci_err(ohci, "Restarting NEC controller failed in %s, %d\n", | ||
132 | "ohci_restart", status); | ||
133 | } | ||
134 | |||
116 | static int ohci_quirk_nec(struct usb_hcd *hcd) | 135 | static int ohci_quirk_nec(struct usb_hcd *hcd) |
117 | { | 136 | { |
118 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 137 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
119 | 138 | ||
120 | ohci->flags |= OHCI_QUIRK_NEC; | 139 | ohci->flags |= OHCI_QUIRK_NEC; |
140 | INIT_WORK(&ohci->nec_work, ohci_quirk_nec_worker); | ||
121 | ohci_dbg (ohci, "enabled NEC chipset lost interrupt quirk\n"); | 141 | ohci_dbg (ohci, "enabled NEC chipset lost interrupt quirk\n"); |
122 | 142 | ||
123 | return 0; | 143 | return 0; |
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index c43b66acd4d..0a742692015 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c | |||
@@ -134,8 +134,11 @@ ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) | |||
134 | } | 134 | } |
135 | 135 | ||
136 | ohci = hcd_to_ohci(hcd); | 136 | ohci = hcd_to_ohci(hcd); |
137 | if (is_bigendian) | 137 | if (is_bigendian) { |
138 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; | 138 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; |
139 | if (of_device_is_compatible(dn, "mpc5200-ohci")) | ||
140 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | ||
141 | } | ||
139 | 142 | ||
140 | ohci_hcd_init(ohci); | 143 | ohci_hcd_init(ohci); |
141 | 144 | ||
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 1a2e1777ca6..f95be1896b0 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
@@ -73,6 +73,11 @@ static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver, | |||
73 | 73 | ||
74 | ohci = hcd_to_ohci(hcd); | 74 | ohci = hcd_to_ohci(hcd); |
75 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; | 75 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; |
76 | |||
77 | #ifdef CONFIG_PPC_MPC52xx | ||
78 | /* MPC52xx doesn't need frame_no shift */ | ||
79 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | ||
80 | #endif | ||
76 | ohci_hcd_init(ohci); | 81 | ohci_hcd_init(ohci); |
77 | 82 | ||
78 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); | 83 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); |
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 830a3fe8615..51817322232 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c | |||
@@ -36,29 +36,15 @@ static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv) | |||
36 | * PRECONDITION: ohci lock held, irqs blocked. | 36 | * PRECONDITION: ohci lock held, irqs blocked. |
37 | */ | 37 | */ |
38 | static void | 38 | static void |
39 | finish_urb (struct ohci_hcd *ohci, struct urb *urb) | 39 | finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status) |
40 | __releases(ohci->lock) | 40 | __releases(ohci->lock) |
41 | __acquires(ohci->lock) | 41 | __acquires(ohci->lock) |
42 | { | 42 | { |
43 | // ASSERT (urb->hcpriv != 0); | 43 | // ASSERT (urb->hcpriv != 0); |
44 | 44 | ||
45 | urb_free_priv (ohci, urb->hcpriv); | 45 | urb_free_priv (ohci, urb->hcpriv); |
46 | urb->hcpriv = NULL; | 46 | if (likely(status == -EINPROGRESS)) |
47 | 47 | status = 0; | |
48 | spin_lock (&urb->lock); | ||
49 | if (likely (urb->status == -EINPROGRESS)) | ||
50 | urb->status = 0; | ||
51 | /* report short control reads right even though the data TD always | ||
52 | * has TD_R set. (much simpler, but creates the 1-td limit.) | ||
53 | */ | ||
54 | if (unlikely (urb->transfer_flags & URB_SHORT_NOT_OK) | ||
55 | && unlikely (usb_pipecontrol (urb->pipe)) | ||
56 | && urb->actual_length < urb->transfer_buffer_length | ||
57 | && usb_pipein (urb->pipe) | ||
58 | && urb->status == 0) { | ||
59 | urb->status = -EREMOTEIO; | ||
60 | } | ||
61 | spin_unlock (&urb->lock); | ||
62 | 48 | ||
63 | switch (usb_pipetype (urb->pipe)) { | 49 | switch (usb_pipetype (urb->pipe)) { |
64 | case PIPE_ISOCHRONOUS: | 50 | case PIPE_ISOCHRONOUS: |
@@ -70,12 +56,13 @@ __acquires(ohci->lock) | |||
70 | } | 56 | } |
71 | 57 | ||
72 | #ifdef OHCI_VERBOSE_DEBUG | 58 | #ifdef OHCI_VERBOSE_DEBUG |
73 | urb_print (urb, "RET", usb_pipeout (urb->pipe)); | 59 | urb_print(urb, "RET", usb_pipeout (urb->pipe), status); |
74 | #endif | 60 | #endif |
75 | 61 | ||
76 | /* urb->complete() can reenter this HCD */ | 62 | /* urb->complete() can reenter this HCD */ |
63 | usb_hcd_unlink_urb_from_ep(ohci_to_hcd(ohci), urb); | ||
77 | spin_unlock (&ohci->lock); | 64 | spin_unlock (&ohci->lock); |
78 | usb_hcd_giveback_urb (ohci_to_hcd(ohci), urb); | 65 | usb_hcd_giveback_urb(ohci_to_hcd(ohci), urb, status); |
79 | spin_lock (&ohci->lock); | 66 | spin_lock (&ohci->lock); |
80 | 67 | ||
81 | /* stop periodic dma if it's not needed */ | 68 | /* stop periodic dma if it's not needed */ |
@@ -179,6 +166,10 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed) | |||
179 | ed->ed_prev = NULL; | 166 | ed->ed_prev = NULL; |
180 | ed->ed_next = NULL; | 167 | ed->ed_next = NULL; |
181 | ed->hwNextED = 0; | 168 | ed->hwNextED = 0; |
169 | if (quirk_zfmicro(ohci) | ||
170 | && (ed->type == PIPE_INTERRUPT) | ||
171 | && !(ohci->eds_scheduled++)) | ||
172 | mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ)); | ||
182 | wmb (); | 173 | wmb (); |
183 | 174 | ||
184 | /* we care about rm_list when setting CLE/BLE in case the HC was at | 175 | /* we care about rm_list when setting CLE/BLE in case the HC was at |
@@ -708,19 +699,18 @@ static void td_submit_urb ( | |||
708 | * Done List handling functions | 699 | * Done List handling functions |
709 | *-------------------------------------------------------------------------*/ | 700 | *-------------------------------------------------------------------------*/ |
710 | 701 | ||
711 | /* calculate transfer length/status and update the urb | 702 | /* calculate transfer length/status and update the urb */ |
712 | * PRECONDITION: irqsafe (only for urb->status locking) | 703 | static int td_done(struct ohci_hcd *ohci, struct urb *urb, struct td *td) |
713 | */ | ||
714 | static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td) | ||
715 | { | 704 | { |
716 | u32 tdINFO = hc32_to_cpup (ohci, &td->hwINFO); | 705 | u32 tdINFO = hc32_to_cpup (ohci, &td->hwINFO); |
717 | int cc = 0; | 706 | int cc = 0; |
707 | int status = -EINPROGRESS; | ||
718 | 708 | ||
719 | list_del (&td->td_list); | 709 | list_del (&td->td_list); |
720 | 710 | ||
721 | /* ISO ... drivers see per-TD length/status */ | 711 | /* ISO ... drivers see per-TD length/status */ |
722 | if (tdINFO & TD_ISO) { | 712 | if (tdINFO & TD_ISO) { |
723 | u16 tdPSW = ohci_hwPSW (ohci, td, 0); | 713 | u16 tdPSW = ohci_hwPSW(ohci, td, 0); |
724 | int dlen = 0; | 714 | int dlen = 0; |
725 | 715 | ||
726 | /* NOTE: assumes FC in tdINFO == 0, and that | 716 | /* NOTE: assumes FC in tdINFO == 0, and that |
@@ -729,7 +719,7 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td) | |||
729 | 719 | ||
730 | cc = (tdPSW >> 12) & 0xF; | 720 | cc = (tdPSW >> 12) & 0xF; |
731 | if (tdINFO & TD_CC) /* hc didn't touch? */ | 721 | if (tdINFO & TD_CC) /* hc didn't touch? */ |
732 | return; | 722 | return status; |
733 | 723 | ||
734 | if (usb_pipeout (urb->pipe)) | 724 | if (usb_pipeout (urb->pipe)) |
735 | dlen = urb->iso_frame_desc [td->index].length; | 725 | dlen = urb->iso_frame_desc [td->index].length; |
@@ -762,12 +752,8 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td) | |||
762 | if (cc == TD_DATAUNDERRUN | 752 | if (cc == TD_DATAUNDERRUN |
763 | && !(urb->transfer_flags & URB_SHORT_NOT_OK)) | 753 | && !(urb->transfer_flags & URB_SHORT_NOT_OK)) |
764 | cc = TD_CC_NOERROR; | 754 | cc = TD_CC_NOERROR; |
765 | if (cc != TD_CC_NOERROR && cc < 0x0E) { | 755 | if (cc != TD_CC_NOERROR && cc < 0x0E) |
766 | spin_lock (&urb->lock); | 756 | status = cc_to_error[cc]; |
767 | if (urb->status == -EINPROGRESS) | ||
768 | urb->status = cc_to_error [cc]; | ||
769 | spin_unlock (&urb->lock); | ||
770 | } | ||
771 | 757 | ||
772 | /* count all non-empty packets except control SETUP packet */ | 758 | /* count all non-empty packets except control SETUP packet */ |
773 | if ((type != PIPE_CONTROL || td->index != 0) && tdBE != 0) { | 759 | if ((type != PIPE_CONTROL || td->index != 0) && tdBE != 0) { |
@@ -786,14 +772,15 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td) | |||
786 | urb->actual_length, | 772 | urb->actual_length, |
787 | urb->transfer_buffer_length); | 773 | urb->transfer_buffer_length); |
788 | } | 774 | } |
775 | return status; | ||
789 | } | 776 | } |
790 | 777 | ||
791 | /*-------------------------------------------------------------------------*/ | 778 | /*-------------------------------------------------------------------------*/ |
792 | 779 | ||
793 | static inline struct td * | 780 | static void ed_halted(struct ohci_hcd *ohci, struct td *td, int cc) |
794 | ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev) | ||
795 | { | 781 | { |
796 | struct urb *urb = td->urb; | 782 | struct urb *urb = td->urb; |
783 | urb_priv_t *urb_priv = urb->hcpriv; | ||
797 | struct ed *ed = td->ed; | 784 | struct ed *ed = td->ed; |
798 | struct list_head *tmp = td->td_list.next; | 785 | struct list_head *tmp = td->td_list.next; |
799 | __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C); | 786 | __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C); |
@@ -805,13 +792,12 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev) | |||
805 | wmb (); | 792 | wmb (); |
806 | ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); | 793 | ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); |
807 | 794 | ||
808 | /* put any later tds from this urb onto the donelist, after 'td', | 795 | /* Get rid of all later tds from this urb. We don't have |
809 | * order won't matter here: no errors, and nothing was transferred. | 796 | * to be careful: no errors and nothing was transferred. |
810 | * also patch the ed so it looks as if those tds completed normally. | 797 | * Also patch the ed so it looks as if those tds completed normally. |
811 | */ | 798 | */ |
812 | while (tmp != &ed->td_list) { | 799 | while (tmp != &ed->td_list) { |
813 | struct td *next; | 800 | struct td *next; |
814 | __hc32 info; | ||
815 | 801 | ||
816 | next = list_entry (tmp, struct td, td_list); | 802 | next = list_entry (tmp, struct td, td_list); |
817 | tmp = next->td_list.next; | 803 | tmp = next->td_list.next; |
@@ -826,14 +812,9 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev) | |||
826 | * then we need to leave the control STATUS packet queued | 812 | * then we need to leave the control STATUS packet queued |
827 | * and clear ED_SKIP. | 813 | * and clear ED_SKIP. |
828 | */ | 814 | */ |
829 | info = next->hwINFO; | ||
830 | info |= cpu_to_hc32 (ohci, TD_DONE); | ||
831 | info &= ~cpu_to_hc32 (ohci, TD_CC); | ||
832 | next->hwINFO = info; | ||
833 | |||
834 | next->next_dl_td = rev; | ||
835 | rev = next; | ||
836 | 815 | ||
816 | list_del(&next->td_list); | ||
817 | urb_priv->td_cnt++; | ||
837 | ed->hwHeadP = next->hwNextTD | toggle; | 818 | ed->hwHeadP = next->hwNextTD | toggle; |
838 | } | 819 | } |
839 | 820 | ||
@@ -859,8 +840,6 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev) | |||
859 | hc32_to_cpu (ohci, td->hwINFO), | 840 | hc32_to_cpu (ohci, td->hwINFO), |
860 | cc, cc_to_error [cc]); | 841 | cc, cc_to_error [cc]); |
861 | } | 842 | } |
862 | |||
863 | return rev; | ||
864 | } | 843 | } |
865 | 844 | ||
866 | /* replies to the request have to be on a FIFO basis so | 845 | /* replies to the request have to be on a FIFO basis so |
@@ -897,7 +876,7 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci) | |||
897 | */ | 876 | */ |
898 | if (cc != TD_CC_NOERROR | 877 | if (cc != TD_CC_NOERROR |
899 | && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H))) | 878 | && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H))) |
900 | td_rev = ed_halted (ohci, td, cc, td_rev); | 879 | ed_halted(ohci, td, cc); |
901 | 880 | ||
902 | td->next_dl_td = td_rev; | 881 | td->next_dl_td = td_rev; |
903 | td_rev = td; | 882 | td_rev = td; |
@@ -940,8 +919,12 @@ skip_ed: | |||
940 | TD_MASK; | 919 | TD_MASK; |
941 | 920 | ||
942 | /* INTR_WDH may need to clean up first */ | 921 | /* INTR_WDH may need to clean up first */ |
943 | if (td->td_dma != head) | 922 | if (td->td_dma != head) { |
944 | goto skip_ed; | 923 | if (ed == ohci->ed_to_check) |
924 | ohci->ed_to_check = NULL; | ||
925 | else | ||
926 | goto skip_ed; | ||
927 | } | ||
945 | } | 928 | } |
946 | } | 929 | } |
947 | 930 | ||
@@ -974,7 +957,7 @@ rescan_this: | |||
974 | urb = td->urb; | 957 | urb = td->urb; |
975 | urb_priv = td->urb->hcpriv; | 958 | urb_priv = td->urb->hcpriv; |
976 | 959 | ||
977 | if (urb->status == -EINPROGRESS) { | 960 | if (!urb->unlinked) { |
978 | prev = &td->hwNextTD; | 961 | prev = &td->hwNextTD; |
979 | continue; | 962 | continue; |
980 | } | 963 | } |
@@ -990,7 +973,7 @@ rescan_this: | |||
990 | /* if URB is done, clean up */ | 973 | /* if URB is done, clean up */ |
991 | if (urb_priv->td_cnt == urb_priv->length) { | 974 | if (urb_priv->td_cnt == urb_priv->length) { |
992 | modified = completed = 1; | 975 | modified = completed = 1; |
993 | finish_urb (ohci, urb); | 976 | finish_urb(ohci, urb, 0); |
994 | } | 977 | } |
995 | } | 978 | } |
996 | if (completed && !list_empty (&ed->td_list)) | 979 | if (completed && !list_empty (&ed->td_list)) |
@@ -998,6 +981,8 @@ rescan_this: | |||
998 | 981 | ||
999 | /* ED's now officially unlinked, hc doesn't see */ | 982 | /* ED's now officially unlinked, hc doesn't see */ |
1000 | ed->state = ED_IDLE; | 983 | ed->state = ED_IDLE; |
984 | if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT) | ||
985 | ohci->eds_scheduled--; | ||
1001 | ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H); | 986 | ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H); |
1002 | ed->hwNextED = 0; | 987 | ed->hwNextED = 0; |
1003 | wmb (); | 988 | wmb (); |
@@ -1021,7 +1006,7 @@ rescan_this: | |||
1021 | 1006 | ||
1022 | if (ohci->ed_controltail) { | 1007 | if (ohci->ed_controltail) { |
1023 | command |= OHCI_CLF; | 1008 | command |= OHCI_CLF; |
1024 | if (ohci->flags & OHCI_QUIRK_ZFMICRO) | 1009 | if (quirk_zfmicro(ohci)) |
1025 | mdelay(1); | 1010 | mdelay(1); |
1026 | if (!(ohci->hc_control & OHCI_CTRL_CLE)) { | 1011 | if (!(ohci->hc_control & OHCI_CTRL_CLE)) { |
1027 | control |= OHCI_CTRL_CLE; | 1012 | control |= OHCI_CTRL_CLE; |
@@ -1031,7 +1016,7 @@ rescan_this: | |||
1031 | } | 1016 | } |
1032 | if (ohci->ed_bulktail) { | 1017 | if (ohci->ed_bulktail) { |
1033 | command |= OHCI_BLF; | 1018 | command |= OHCI_BLF; |
1034 | if (ohci->flags & OHCI_QUIRK_ZFMICRO) | 1019 | if (quirk_zfmicro(ohci)) |
1035 | mdelay(1); | 1020 | mdelay(1); |
1036 | if (!(ohci->hc_control & OHCI_CTRL_BLE)) { | 1021 | if (!(ohci->hc_control & OHCI_CTRL_BLE)) { |
1037 | control |= OHCI_CTRL_BLE; | 1022 | control |= OHCI_CTRL_BLE; |
@@ -1043,13 +1028,13 @@ rescan_this: | |||
1043 | /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */ | 1028 | /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */ |
1044 | if (control) { | 1029 | if (control) { |
1045 | ohci->hc_control |= control; | 1030 | ohci->hc_control |= control; |
1046 | if (ohci->flags & OHCI_QUIRK_ZFMICRO) | 1031 | if (quirk_zfmicro(ohci)) |
1047 | mdelay(1); | 1032 | mdelay(1); |
1048 | ohci_writel (ohci, ohci->hc_control, | 1033 | ohci_writel (ohci, ohci->hc_control, |
1049 | &ohci->regs->control); | 1034 | &ohci->regs->control); |
1050 | } | 1035 | } |
1051 | if (command) { | 1036 | if (command) { |
1052 | if (ohci->flags & OHCI_QUIRK_ZFMICRO) | 1037 | if (quirk_zfmicro(ohci)) |
1053 | mdelay(1); | 1038 | mdelay(1); |
1054 | ohci_writel (ohci, command, &ohci->regs->cmdstatus); | 1039 | ohci_writel (ohci, command, &ohci->regs->cmdstatus); |
1055 | } | 1040 | } |
@@ -1061,11 +1046,60 @@ rescan_this: | |||
1061 | /*-------------------------------------------------------------------------*/ | 1046 | /*-------------------------------------------------------------------------*/ |
1062 | 1047 | ||
1063 | /* | 1048 | /* |
1049 | * Used to take back a TD from the host controller. This would normally be | ||
1050 | * called from within dl_done_list, however it may be called directly if the | ||
1051 | * HC no longer sees the TD and it has not appeared on the donelist (after | ||
1052 | * two frames). This bug has been observed on ZF Micro systems. | ||
1053 | */ | ||
1054 | static void takeback_td(struct ohci_hcd *ohci, struct td *td) | ||
1055 | { | ||
1056 | struct urb *urb = td->urb; | ||
1057 | urb_priv_t *urb_priv = urb->hcpriv; | ||
1058 | struct ed *ed = td->ed; | ||
1059 | int status; | ||
1060 | |||
1061 | /* update URB's length and status from TD */ | ||
1062 | status = td_done(ohci, urb, td); | ||
1063 | urb_priv->td_cnt++; | ||
1064 | |||
1065 | /* If all this urb's TDs are done, call complete() */ | ||
1066 | if (urb_priv->td_cnt == urb_priv->length) | ||
1067 | finish_urb(ohci, urb, status); | ||
1068 | |||
1069 | /* clean schedule: unlink EDs that are no longer busy */ | ||
1070 | if (list_empty(&ed->td_list)) { | ||
1071 | if (ed->state == ED_OPER) | ||
1072 | start_ed_unlink(ohci, ed); | ||
1073 | |||
1074 | /* ... reenabling halted EDs only after fault cleanup */ | ||
1075 | } else if ((ed->hwINFO & cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE)) | ||
1076 | == cpu_to_hc32(ohci, ED_SKIP)) { | ||
1077 | td = list_entry(ed->td_list.next, struct td, td_list); | ||
1078 | if (!(td->hwINFO & cpu_to_hc32(ohci, TD_DONE))) { | ||
1079 | ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP); | ||
1080 | /* ... hc may need waking-up */ | ||
1081 | switch (ed->type) { | ||
1082 | case PIPE_CONTROL: | ||
1083 | ohci_writel(ohci, OHCI_CLF, | ||
1084 | &ohci->regs->cmdstatus); | ||
1085 | break; | ||
1086 | case PIPE_BULK: | ||
1087 | ohci_writel(ohci, OHCI_BLF, | ||
1088 | &ohci->regs->cmdstatus); | ||
1089 | break; | ||
1090 | } | ||
1091 | } | ||
1092 | } | ||
1093 | } | ||
1094 | |||
1095 | /* | ||
1064 | * Process normal completions (error or success) and clean the schedules. | 1096 | * Process normal completions (error or success) and clean the schedules. |
1065 | * | 1097 | * |
1066 | * This is the main path for handing urbs back to drivers. The only other | 1098 | * This is the main path for handing urbs back to drivers. The only other |
1067 | * path is finish_unlinks(), which unlinks URBs using ed_rm_list, instead of | 1099 | * normal path is finish_unlinks(), which unlinks URBs using ed_rm_list, |
1068 | * scanning the (re-reversed) donelist as this does. | 1100 | * instead of scanning the (re-reversed) donelist as this does. There's |
1101 | * an abnormal path too, handling a quirk in some Compaq silicon: URBs | ||
1102 | * with TDs that appear to be orphaned are directly reclaimed. | ||
1069 | */ | 1103 | */ |
1070 | static void | 1104 | static void |
1071 | dl_done_list (struct ohci_hcd *ohci) | 1105 | dl_done_list (struct ohci_hcd *ohci) |
@@ -1074,44 +1108,7 @@ dl_done_list (struct ohci_hcd *ohci) | |||
1074 | 1108 | ||
1075 | while (td) { | 1109 | while (td) { |
1076 | struct td *td_next = td->next_dl_td; | 1110 | struct td *td_next = td->next_dl_td; |
1077 | struct urb *urb = td->urb; | 1111 | takeback_td(ohci, td); |
1078 | urb_priv_t *urb_priv = urb->hcpriv; | ||
1079 | struct ed *ed = td->ed; | ||
1080 | |||
1081 | /* update URB's length and status from TD */ | ||
1082 | td_done (ohci, urb, td); | ||
1083 | urb_priv->td_cnt++; | ||
1084 | |||
1085 | /* If all this urb's TDs are done, call complete() */ | ||
1086 | if (urb_priv->td_cnt == urb_priv->length) | ||
1087 | finish_urb (ohci, urb); | ||
1088 | |||
1089 | /* clean schedule: unlink EDs that are no longer busy */ | ||
1090 | if (list_empty (&ed->td_list)) { | ||
1091 | if (ed->state == ED_OPER) | ||
1092 | start_ed_unlink (ohci, ed); | ||
1093 | |||
1094 | /* ... reenabling halted EDs only after fault cleanup */ | ||
1095 | } else if ((ed->hwINFO & cpu_to_hc32 (ohci, | ||
1096 | ED_SKIP | ED_DEQUEUE)) | ||
1097 | == cpu_to_hc32 (ohci, ED_SKIP)) { | ||
1098 | td = list_entry (ed->td_list.next, struct td, td_list); | ||
1099 | if (!(td->hwINFO & cpu_to_hc32 (ohci, TD_DONE))) { | ||
1100 | ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP); | ||
1101 | /* ... hc may need waking-up */ | ||
1102 | switch (ed->type) { | ||
1103 | case PIPE_CONTROL: | ||
1104 | ohci_writel (ohci, OHCI_CLF, | ||
1105 | &ohci->regs->cmdstatus); | ||
1106 | break; | ||
1107 | case PIPE_BULK: | ||
1108 | ohci_writel (ohci, OHCI_BLF, | ||
1109 | &ohci->regs->cmdstatus); | ||
1110 | break; | ||
1111 | } | ||
1112 | } | ||
1113 | } | ||
1114 | |||
1115 | td = td_next; | 1112 | td = td_next; |
1116 | } | 1113 | } |
1117 | } | 1114 | } |
diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c new file mode 100644 index 00000000000..bc3e785d8c0 --- /dev/null +++ b/drivers/usb/host/ohci-ssb.c | |||
@@ -0,0 +1,247 @@ | |||
1 | /* | ||
2 | * Sonics Silicon Backplane | ||
3 | * Broadcom USB-core OHCI driver | ||
4 | * | ||
5 | * Copyright 2007 Michael Buesch <mb@bu3sch.de> | ||
6 | * | ||
7 | * Derived from the OHCI-PCI driver | ||
8 | * Copyright 1999 Roman Weissgaerber | ||
9 | * Copyright 2000-2002 David Brownell | ||
10 | * Copyright 1999 Linus Torvalds | ||
11 | * Copyright 1999 Gregory P. Smith | ||
12 | * | ||
13 | * Derived from the USBcore related parts of Broadcom-SB | ||
14 | * Copyright 2005 Broadcom Corporation | ||
15 | * | ||
16 | * Licensed under the GNU/GPL. See COPYING for details. | ||
17 | */ | ||
18 | #include <linux/ssb/ssb.h> | ||
19 | |||
20 | |||
21 | #define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29) | ||
22 | |||
23 | struct ssb_ohci_device { | ||
24 | struct ohci_hcd ohci; /* _must_ be at the beginning. */ | ||
25 | |||
26 | u32 enable_flags; | ||
27 | }; | ||
28 | |||
29 | static inline | ||
30 | struct ssb_ohci_device *hcd_to_ssb_ohci(struct usb_hcd *hcd) | ||
31 | { | ||
32 | return (struct ssb_ohci_device *)(hcd->hcd_priv); | ||
33 | } | ||
34 | |||
35 | |||
36 | static int ssb_ohci_reset(struct usb_hcd *hcd) | ||
37 | { | ||
38 | struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); | ||
39 | struct ohci_hcd *ohci = &ohcidev->ohci; | ||
40 | int err; | ||
41 | |||
42 | ohci_hcd_init(ohci); | ||
43 | err = ohci_init(ohci); | ||
44 | |||
45 | return err; | ||
46 | } | ||
47 | |||
48 | static int ssb_ohci_start(struct usb_hcd *hcd) | ||
49 | { | ||
50 | struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); | ||
51 | struct ohci_hcd *ohci = &ohcidev->ohci; | ||
52 | int err; | ||
53 | |||
54 | err = ohci_run(ohci); | ||
55 | if (err < 0) { | ||
56 | ohci_err(ohci, "can't start\n"); | ||
57 | ohci_stop(hcd); | ||
58 | } | ||
59 | |||
60 | return err; | ||
61 | } | ||
62 | |||
63 | #ifdef CONFIG_PM | ||
64 | static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) | ||
65 | { | ||
66 | struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); | ||
67 | struct ohci_hcd *ohci = &ohcidev->ohci; | ||
68 | unsigned long flags; | ||
69 | |||
70 | spin_lock_irqsave(&ohci->lock, flags); | ||
71 | |||
72 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | ||
73 | ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */ | ||
74 | |||
75 | /* make sure snapshot being resumed re-enumerates everything */ | ||
76 | if (message.event == PM_EVENT_PRETHAW) | ||
77 | ohci_usb_reset(ohci); | ||
78 | |||
79 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
80 | |||
81 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int ssb_ohci_hcd_resume(struct usb_hcd *hcd) | ||
86 | { | ||
87 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
88 | usb_hcd_resume_root_hub(hcd); | ||
89 | return 0; | ||
90 | } | ||
91 | #endif /* CONFIG_PM */ | ||
92 | |||
93 | static const struct hc_driver ssb_ohci_hc_driver = { | ||
94 | .description = "ssb-usb-ohci", | ||
95 | .product_desc = "SSB OHCI Controller", | ||
96 | .hcd_priv_size = sizeof(struct ssb_ohci_device), | ||
97 | |||
98 | .irq = ohci_irq, | ||
99 | .flags = HCD_MEMORY | HCD_USB11, | ||
100 | |||
101 | .reset = ssb_ohci_reset, | ||
102 | .start = ssb_ohci_start, | ||
103 | .stop = ohci_stop, | ||
104 | .shutdown = ohci_shutdown, | ||
105 | |||
106 | #ifdef CONFIG_PM | ||
107 | .suspend = ssb_ohci_hcd_suspend, | ||
108 | .resume = ssb_ohci_hcd_resume, | ||
109 | #endif | ||
110 | |||
111 | .urb_enqueue = ohci_urb_enqueue, | ||
112 | .urb_dequeue = ohci_urb_dequeue, | ||
113 | .endpoint_disable = ohci_endpoint_disable, | ||
114 | |||
115 | .get_frame_number = ohci_get_frame, | ||
116 | |||
117 | .hub_status_data = ohci_hub_status_data, | ||
118 | .hub_control = ohci_hub_control, | ||
119 | .hub_irq_enable = ohci_rhsc_enable, | ||
120 | .bus_suspend = ohci_bus_suspend, | ||
121 | .bus_resume = ohci_bus_resume, | ||
122 | |||
123 | .start_port_reset = ohci_start_port_reset, | ||
124 | }; | ||
125 | |||
126 | static void ssb_ohci_detach(struct ssb_device *dev) | ||
127 | { | ||
128 | struct usb_hcd *hcd = ssb_get_drvdata(dev); | ||
129 | |||
130 | usb_remove_hcd(hcd); | ||
131 | iounmap(hcd->regs); | ||
132 | usb_put_hcd(hcd); | ||
133 | ssb_device_disable(dev, 0); | ||
134 | } | ||
135 | |||
136 | static int ssb_ohci_attach(struct ssb_device *dev) | ||
137 | { | ||
138 | struct ssb_ohci_device *ohcidev; | ||
139 | struct usb_hcd *hcd; | ||
140 | int err = -ENOMEM; | ||
141 | u32 tmp, flags = 0; | ||
142 | |||
143 | if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) | ||
144 | flags |= SSB_OHCI_TMSLOW_HOSTMODE; | ||
145 | |||
146 | ssb_device_enable(dev, flags); | ||
147 | |||
148 | hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev, | ||
149 | dev->dev->bus_id); | ||
150 | if (!hcd) | ||
151 | goto err_dev_disable; | ||
152 | ohcidev = hcd_to_ssb_ohci(hcd); | ||
153 | ohcidev->enable_flags = flags; | ||
154 | |||
155 | tmp = ssb_read32(dev, SSB_ADMATCH0); | ||
156 | hcd->rsrc_start = ssb_admatch_base(tmp); | ||
157 | hcd->rsrc_len = ssb_admatch_size(tmp); | ||
158 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
159 | if (!hcd->regs) | ||
160 | goto err_put_hcd; | ||
161 | err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED); | ||
162 | if (err) | ||
163 | goto err_iounmap; | ||
164 | |||
165 | ssb_set_drvdata(dev, hcd); | ||
166 | |||
167 | return err; | ||
168 | |||
169 | err_iounmap: | ||
170 | iounmap(hcd->regs); | ||
171 | err_put_hcd: | ||
172 | usb_put_hcd(hcd); | ||
173 | err_dev_disable: | ||
174 | ssb_device_disable(dev, flags); | ||
175 | return err; | ||
176 | } | ||
177 | |||
178 | static int ssb_ohci_probe(struct ssb_device *dev, | ||
179 | const struct ssb_device_id *id) | ||
180 | { | ||
181 | int err; | ||
182 | u16 chipid_top; | ||
183 | |||
184 | /* USBcores are only connected on embedded devices. */ | ||
185 | chipid_top = (dev->bus->chip_id & 0xFF00); | ||
186 | if (chipid_top != 0x4700 && chipid_top != 0x5300) | ||
187 | return -ENODEV; | ||
188 | |||
189 | /* TODO: Probably need checks here; is the core connected? */ | ||
190 | |||
191 | if (usb_disabled()) | ||
192 | return -ENODEV; | ||
193 | |||
194 | /* We currently always attach SSB_DEV_USB11_HOSTDEV | ||
195 | * as HOST OHCI. If we want to attach it as Client device, | ||
196 | * we must branch here and call into the (yet to | ||
197 | * be written) Client mode driver. Same for remove(). */ | ||
198 | |||
199 | err = ssb_ohci_attach(dev); | ||
200 | |||
201 | return err; | ||
202 | } | ||
203 | |||
204 | static void ssb_ohci_remove(struct ssb_device *dev) | ||
205 | { | ||
206 | ssb_ohci_detach(dev); | ||
207 | } | ||
208 | |||
209 | #ifdef CONFIG_PM | ||
210 | |||
211 | static int ssb_ohci_suspend(struct ssb_device *dev, pm_message_t state) | ||
212 | { | ||
213 | ssb_device_disable(dev, 0); | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | static int ssb_ohci_resume(struct ssb_device *dev) | ||
219 | { | ||
220 | struct usb_hcd *hcd = ssb_get_drvdata(dev); | ||
221 | struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); | ||
222 | |||
223 | ssb_device_enable(dev, ohcidev->enable_flags); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | #else /* !CONFIG_PM */ | ||
229 | #define ssb_ohci_suspend NULL | ||
230 | #define ssb_ohci_resume NULL | ||
231 | #endif /* CONFIG_PM */ | ||
232 | |||
233 | static const struct ssb_device_id ssb_ohci_table[] = { | ||
234 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), | ||
235 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), | ||
236 | SSB_DEVTABLE_END | ||
237 | }; | ||
238 | MODULE_DEVICE_TABLE(ssb, ssb_ohci_table); | ||
239 | |||
240 | static struct ssb_driver ssb_ohci_driver = { | ||
241 | .name = KBUILD_MODNAME, | ||
242 | .id_table = ssb_ohci_table, | ||
243 | .probe = ssb_ohci_probe, | ||
244 | .remove = ssb_ohci_remove, | ||
245 | .suspend = ssb_ohci_suspend, | ||
246 | .resume = ssb_ohci_resume, | ||
247 | }; | ||
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 4ada43cf138..47c5c66a282 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -398,11 +398,38 @@ struct ohci_hcd { | |||
398 | #define OHCI_QUIRK_BE_MMIO 0x10 /* BE registers */ | 398 | #define OHCI_QUIRK_BE_MMIO 0x10 /* BE registers */ |
399 | #define OHCI_QUIRK_ZFMICRO 0x20 /* Compaq ZFMicro chipset*/ | 399 | #define OHCI_QUIRK_ZFMICRO 0x20 /* Compaq ZFMicro chipset*/ |
400 | #define OHCI_QUIRK_NEC 0x40 /* lost interrupts */ | 400 | #define OHCI_QUIRK_NEC 0x40 /* lost interrupts */ |
401 | #define OHCI_QUIRK_FRAME_NO 0x80 /* no big endian frame_no shift */ | ||
401 | // there are also chip quirks/bugs in init logic | 402 | // there are also chip quirks/bugs in init logic |
402 | 403 | ||
403 | struct work_struct nec_work; /* Worker for NEC quirk */ | 404 | struct work_struct nec_work; /* Worker for NEC quirk */ |
405 | |||
406 | /* Needed for ZF Micro quirk */ | ||
407 | struct timer_list unlink_watchdog; | ||
408 | unsigned eds_scheduled; | ||
409 | struct ed *ed_to_check; | ||
410 | unsigned zf_delay; | ||
404 | }; | 411 | }; |
405 | 412 | ||
413 | #ifdef CONFIG_PCI | ||
414 | static inline int quirk_nec(struct ohci_hcd *ohci) | ||
415 | { | ||
416 | return ohci->flags & OHCI_QUIRK_NEC; | ||
417 | } | ||
418 | static inline int quirk_zfmicro(struct ohci_hcd *ohci) | ||
419 | { | ||
420 | return ohci->flags & OHCI_QUIRK_ZFMICRO; | ||
421 | } | ||
422 | #else | ||
423 | static inline int quirk_nec(struct ohci_hcd *ohci) | ||
424 | { | ||
425 | return 0; | ||
426 | } | ||
427 | static inline int quirk_zfmicro(struct ohci_hcd *ohci) | ||
428 | { | ||
429 | return 0; | ||
430 | } | ||
431 | #endif | ||
432 | |||
406 | /* convert between an hcd pointer and the corresponding ohci_hcd */ | 433 | /* convert between an hcd pointer and the corresponding ohci_hcd */ |
407 | static inline struct ohci_hcd *hcd_to_ohci (struct usb_hcd *hcd) | 434 | static inline struct ohci_hcd *hcd_to_ohci (struct usb_hcd *hcd) |
408 | { | 435 | { |
@@ -607,15 +634,12 @@ static inline u32 hc32_to_cpup (const struct ohci_hcd *ohci, const __hc32 *x) | |||
607 | /* HCCA frame number is 16 bits, but is accessed as 32 bits since not all | 634 | /* HCCA frame number is 16 bits, but is accessed as 32 bits since not all |
608 | * hardware handles 16 bit reads. That creates a different confusion on | 635 | * hardware handles 16 bit reads. That creates a different confusion on |
609 | * some big-endian SOC implementations. Same thing happens with PSW access. | 636 | * some big-endian SOC implementations. Same thing happens with PSW access. |
610 | * | ||
611 | * FIXME: Deal with that as a runtime quirk when STB03xxx is ported over | ||
612 | * to arch/powerpc | ||
613 | */ | 637 | */ |
614 | 638 | ||
615 | #ifdef CONFIG_STB03xxx | 639 | #ifdef CONFIG_PPC_MPC52xx |
616 | #define OHCI_BE_FRAME_NO_SHIFT 16 | 640 | #define big_endian_frame_no_quirk(ohci) (ohci->flags & OHCI_QUIRK_FRAME_NO) |
617 | #else | 641 | #else |
618 | #define OHCI_BE_FRAME_NO_SHIFT 0 | 642 | #define big_endian_frame_no_quirk(ohci) 0 |
619 | #endif | 643 | #endif |
620 | 644 | ||
621 | static inline u16 ohci_frame_no(const struct ohci_hcd *ohci) | 645 | static inline u16 ohci_frame_no(const struct ohci_hcd *ohci) |
@@ -623,7 +647,8 @@ static inline u16 ohci_frame_no(const struct ohci_hcd *ohci) | |||
623 | u32 tmp; | 647 | u32 tmp; |
624 | if (big_endian_desc(ohci)) { | 648 | if (big_endian_desc(ohci)) { |
625 | tmp = be32_to_cpup((__force __be32 *)&ohci->hcca->frame_no); | 649 | tmp = be32_to_cpup((__force __be32 *)&ohci->hcca->frame_no); |
626 | tmp >>= OHCI_BE_FRAME_NO_SHIFT; | 650 | if (!big_endian_frame_no_quirk(ohci)) |
651 | tmp >>= 16; | ||
627 | } else | 652 | } else |
628 | tmp = le32_to_cpup((__force __le32 *)&ohci->hcca->frame_no); | 653 | tmp = le32_to_cpup((__force __le32 *)&ohci->hcca->frame_no); |
629 | 654 | ||
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index a7a7070c6e2..ae8ec4474eb 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -35,10 +35,8 @@ | |||
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/usb.h> | 36 | #include <linux/usb.h> |
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | 38 | #include <linux/io.h> | |
39 | #include <asm/io.h> | 39 | #include <linux/irq.h> |
40 | #include <asm/irq.h> | ||
41 | #include <asm/system.h> | ||
42 | 40 | ||
43 | #include "../core/hcd.h" | 41 | #include "../core/hcd.h" |
44 | #include "r8a66597.h" | 42 | #include "r8a66597.h" |
@@ -54,16 +52,21 @@ static const char hcd_name[] = "r8a66597_hcd"; | |||
54 | /* module parameters */ | 52 | /* module parameters */ |
55 | static unsigned short clock = XTAL12; | 53 | static unsigned short clock = XTAL12; |
56 | module_param(clock, ushort, 0644); | 54 | module_param(clock, ushort, 0644); |
57 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0(default=0)"); | 55 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " |
56 | "(default=0)"); | ||
57 | |||
58 | static unsigned short vif = LDRV; | 58 | static unsigned short vif = LDRV; |
59 | module_param(vif, ushort, 0644); | 59 | module_param(vif, ushort, 0644); |
60 | MODULE_PARM_DESC(vif, "input VIF: 3.3V=32768, 1.5V=0(default=32768)"); | 60 | MODULE_PARM_DESC(vif, "input VIF: 3.3V=32768, 1.5V=0(default=32768)"); |
61 | static unsigned short endian = 0; | 61 | |
62 | static unsigned short endian; | ||
62 | module_param(endian, ushort, 0644); | 63 | module_param(endian, ushort, 0644); |
63 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0(default=0)"); | 64 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); |
65 | |||
64 | static unsigned short irq_sense = INTL; | 66 | static unsigned short irq_sense = INTL; |
65 | module_param(irq_sense, ushort, 0644); | 67 | module_param(irq_sense, ushort, 0644); |
66 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0(default=32)"); | 68 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " |
69 | "(default=32)"); | ||
67 | 70 | ||
68 | static void packet_write(struct r8a66597 *r8a66597, u16 pipenum); | 71 | static void packet_write(struct r8a66597 *r8a66597, u16 pipenum); |
69 | static int r8a66597_get_frame(struct usb_hcd *hcd); | 72 | static int r8a66597_get_frame(struct usb_hcd *hcd); |
@@ -308,7 +311,7 @@ static int make_r8a66597_device(struct r8a66597 *r8a66597, | |||
308 | struct r8a66597_device *dev; | 311 | struct r8a66597_device *dev; |
309 | int usb_address = urb->setup_packet[2]; /* urb->pipe is address 0 */ | 312 | int usb_address = urb->setup_packet[2]; /* urb->pipe is address 0 */ |
310 | 313 | ||
311 | dev = kzalloc(sizeof(struct r8a66597_device), GFP_KERNEL); | 314 | dev = kzalloc(sizeof(struct r8a66597_device), GFP_ATOMIC); |
312 | if (dev == NULL) | 315 | if (dev == NULL) |
313 | return -ENOMEM; | 316 | return -ENOMEM; |
314 | 317 | ||
@@ -611,33 +614,33 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597, | |||
611 | u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min; | 614 | u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min; |
612 | 615 | ||
613 | memset(array, 0, sizeof(array)); | 616 | memset(array, 0, sizeof(array)); |
614 | switch(ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { | 617 | switch (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { |
615 | case USB_ENDPOINT_XFER_BULK: | 618 | case USB_ENDPOINT_XFER_BULK: |
616 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) | 619 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) |
617 | array[i++] = 4; | 620 | array[i++] = 4; |
618 | else { | 621 | else { |
619 | array[i++] = 3; | 622 | array[i++] = 3; |
620 | array[i++] = 5; | 623 | array[i++] = 5; |
621 | } | 624 | } |
622 | break; | 625 | break; |
623 | case USB_ENDPOINT_XFER_INT: | 626 | case USB_ENDPOINT_XFER_INT: |
624 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { | 627 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { |
625 | array[i++] = 6; | 628 | array[i++] = 6; |
626 | array[i++] = 7; | 629 | array[i++] = 7; |
627 | array[i++] = 8; | 630 | array[i++] = 8; |
628 | } else | 631 | } else |
629 | array[i++] = 9; | 632 | array[i++] = 9; |
630 | break; | 633 | break; |
631 | case USB_ENDPOINT_XFER_ISOC: | 634 | case USB_ENDPOINT_XFER_ISOC: |
632 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) | 635 | if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) |
633 | array[i++] = 2; | 636 | array[i++] = 2; |
634 | else | 637 | else |
635 | array[i++] = 1; | 638 | array[i++] = 1; |
636 | break; | 639 | break; |
637 | default: | 640 | default: |
638 | err("Illegal type"); | 641 | err("Illegal type"); |
639 | return 0; | 642 | return 0; |
640 | } | 643 | } |
641 | 644 | ||
642 | i = 1; | 645 | i = 1; |
643 | min = array[0]; | 646 | min = array[0]; |
@@ -654,7 +657,7 @@ static u16 get_r8a66597_type(__u8 type) | |||
654 | { | 657 | { |
655 | u16 r8a66597_type; | 658 | u16 r8a66597_type; |
656 | 659 | ||
657 | switch(type) { | 660 | switch (type) { |
658 | case USB_ENDPOINT_XFER_BULK: | 661 | case USB_ENDPOINT_XFER_BULK: |
659 | r8a66597_type = R8A66597_BULK; | 662 | r8a66597_type = R8A66597_BULK; |
660 | break; | 663 | break; |
@@ -779,10 +782,12 @@ static void force_dequeue(struct r8a66597 *r8a66597, u16 pipenum, u16 address) | |||
779 | kfree(td); | 782 | kfree(td); |
780 | 783 | ||
781 | if (urb) { | 784 | if (urb) { |
782 | urb->status = -ENODEV; | 785 | usb_hcd_unlink_urb_from_ep(r8a66597_to_hcd(r8a66597), |
783 | urb->hcpriv = NULL; | 786 | urb); |
787 | |||
784 | spin_unlock(&r8a66597->lock); | 788 | spin_unlock(&r8a66597->lock); |
785 | usb_hcd_giveback_urb(r8a66597_to_hcd(r8a66597), urb); | 789 | usb_hcd_giveback_urb(r8a66597_to_hcd(r8a66597), urb, |
790 | -ENODEV); | ||
786 | spin_lock(&r8a66597->lock); | 791 | spin_lock(&r8a66597->lock); |
787 | } | 792 | } |
788 | break; | 793 | break; |
@@ -829,7 +834,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb, | |||
829 | info.pipenum = get_empty_pipenum(r8a66597, ep); | 834 | info.pipenum = get_empty_pipenum(r8a66597, ep); |
830 | info.address = get_urb_to_r8a66597_addr(r8a66597, urb); | 835 | info.address = get_urb_to_r8a66597_addr(r8a66597, urb); |
831 | info.epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | 836 | info.epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; |
832 | info.maxpacket = ep->wMaxPacketSize; | 837 | info.maxpacket = le16_to_cpu(ep->wMaxPacketSize); |
833 | info.type = get_r8a66597_type(ep->bmAttributes | 838 | info.type = get_r8a66597_type(ep->bmAttributes |
834 | & USB_ENDPOINT_XFERTYPE_MASK); | 839 | & USB_ENDPOINT_XFERTYPE_MASK); |
835 | info.bufnum = get_bufnum(info.pipenum); | 840 | info.bufnum = get_bufnum(info.pipenum); |
@@ -874,7 +879,7 @@ static void r8a66597_usb_preconnect(struct r8a66597 *r8a66597, int port) | |||
874 | { | 879 | { |
875 | r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) | 880 | r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) |
876 | | (1 << USB_PORT_FEAT_C_CONNECTION); | 881 | | (1 << USB_PORT_FEAT_C_CONNECTION); |
877 | r8a66597_write(r8a66597, (u16)~DTCH, get_intsts_reg(port)); | 882 | r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); |
878 | r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); | 883 | r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); |
879 | } | 884 | } |
880 | 885 | ||
@@ -917,10 +922,10 @@ static void prepare_setup_packet(struct r8a66597 *r8a66597, | |||
917 | 922 | ||
918 | r8a66597_write(r8a66597, make_devsel(td->address) | td->maxpacket, | 923 | r8a66597_write(r8a66597, make_devsel(td->address) | td->maxpacket, |
919 | DCPMAXP); | 924 | DCPMAXP); |
920 | r8a66597_write(r8a66597, (u16)~(SIGN | SACK), INTSTS1); | 925 | r8a66597_write(r8a66597, ~(SIGN | SACK), INTSTS1); |
921 | 926 | ||
922 | for (i = 0; i < 4; i++) { | 927 | for (i = 0; i < 4; i++) { |
923 | r8a66597_write(r8a66597, p[i], setup_addr); | 928 | r8a66597_write(r8a66597, cpu_to_le16(p[i]), setup_addr); |
924 | setup_addr += 2; | 929 | setup_addr += 2; |
925 | } | 930 | } |
926 | r8a66597_write(r8a66597, SUREQ, DCPCTR); | 931 | r8a66597_write(r8a66597, SUREQ, DCPCTR); |
@@ -948,19 +953,18 @@ static void prepare_packet_read(struct r8a66597 *r8a66597, | |||
948 | pipe_irq_disable(r8a66597, td->pipenum); | 953 | pipe_irq_disable(r8a66597, td->pipenum); |
949 | pipe_setting(r8a66597, td); | 954 | pipe_setting(r8a66597, td); |
950 | pipe_stop(r8a66597, td->pipe); | 955 | pipe_stop(r8a66597, td->pipe); |
951 | r8a66597_write(r8a66597, (u16)~(1 << td->pipenum), | 956 | r8a66597_write(r8a66597, ~(1 << td->pipenum), BRDYSTS); |
952 | BRDYSTS); | ||
953 | 957 | ||
954 | if (td->pipe->pipetre) { | 958 | if (td->pipe->pipetre) { |
955 | r8a66597_write(r8a66597, TRCLR, | 959 | r8a66597_write(r8a66597, TRCLR, |
956 | td->pipe->pipetre); | 960 | td->pipe->pipetre); |
957 | r8a66597_write(r8a66597, | 961 | r8a66597_write(r8a66597, |
958 | (urb->transfer_buffer_length | 962 | (urb->transfer_buffer_length |
959 | + td->maxpacket - 1) | 963 | + td->maxpacket - 1) |
960 | / td->maxpacket, | 964 | / td->maxpacket, |
961 | td->pipe->pipetrn); | 965 | td->pipe->pipetrn); |
962 | r8a66597_bset(r8a66597, TRENB, | 966 | r8a66597_bset(r8a66597, TRENB, |
963 | td->pipe->pipetre); | 967 | td->pipe->pipetre); |
964 | } | 968 | } |
965 | 969 | ||
966 | pipe_start(r8a66597, td->pipe); | 970 | pipe_start(r8a66597, td->pipe); |
@@ -991,7 +995,7 @@ static void prepare_packet_write(struct r8a66597 *r8a66597, | |||
991 | if (td->pipe->pipetre) | 995 | if (td->pipe->pipetre) |
992 | r8a66597_bclr(r8a66597, TRENB, td->pipe->pipetre); | 996 | r8a66597_bclr(r8a66597, TRENB, td->pipe->pipetre); |
993 | } | 997 | } |
994 | r8a66597_write(r8a66597, (u16)~(1 << td->pipenum), BRDYSTS); | 998 | r8a66597_write(r8a66597, ~(1 << td->pipenum), BRDYSTS); |
995 | 999 | ||
996 | fifo_change_from_pipe(r8a66597, td->pipe); | 1000 | fifo_change_from_pipe(r8a66597, td->pipe); |
997 | tmp = r8a66597_read(r8a66597, td->pipe->fifoctr); | 1001 | tmp = r8a66597_read(r8a66597, td->pipe->fifoctr); |
@@ -1009,27 +1013,36 @@ static void prepare_status_packet(struct r8a66597 *r8a66597, | |||
1009 | struct urb *urb = td->urb; | 1013 | struct urb *urb = td->urb; |
1010 | 1014 | ||
1011 | r8a66597_pipe_toggle(r8a66597, td->pipe, 1); | 1015 | r8a66597_pipe_toggle(r8a66597, td->pipe, 1); |
1016 | pipe_stop(r8a66597, td->pipe); | ||
1012 | 1017 | ||
1013 | if (urb->setup_packet[0] & USB_ENDPOINT_DIR_MASK) { | 1018 | if (urb->setup_packet[0] & USB_ENDPOINT_DIR_MASK) { |
1014 | r8a66597_bset(r8a66597, R8A66597_DIR, DCPCFG); | 1019 | r8a66597_bset(r8a66597, R8A66597_DIR, DCPCFG); |
1015 | r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); | 1020 | r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); |
1016 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); | 1021 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); |
1017 | r8a66597_write(r8a66597, BVAL | BCLR, CFIFOCTR); | 1022 | r8a66597_write(r8a66597, ~BEMP0, BEMPSTS); |
1018 | r8a66597_write(r8a66597, (u16)~BEMP0, BEMPSTS); | 1023 | r8a66597_write(r8a66597, BCLR, CFIFOCTR); |
1024 | r8a66597_write(r8a66597, BVAL, CFIFOCTR); | ||
1019 | enable_irq_empty(r8a66597, 0); | 1025 | enable_irq_empty(r8a66597, 0); |
1020 | } else { | 1026 | } else { |
1021 | r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); | 1027 | r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); |
1022 | r8a66597_mdfy(r8a66597, 0, ISEL | CURPIPE, CFIFOSEL); | 1028 | r8a66597_mdfy(r8a66597, 0, ISEL | CURPIPE, CFIFOSEL); |
1023 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); | 1029 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); |
1024 | r8a66597_write(r8a66597, BCLR, CFIFOCTR); | 1030 | r8a66597_write(r8a66597, BCLR, CFIFOCTR); |
1025 | r8a66597_write(r8a66597, (u16)~BRDY0, BRDYSTS); | ||
1026 | r8a66597_write(r8a66597, (u16)~BEMP0, BEMPSTS); | ||
1027 | enable_irq_ready(r8a66597, 0); | 1031 | enable_irq_ready(r8a66597, 0); |
1028 | } | 1032 | } |
1029 | enable_irq_nrdy(r8a66597, 0); | 1033 | enable_irq_nrdy(r8a66597, 0); |
1030 | pipe_start(r8a66597, td->pipe); | 1034 | pipe_start(r8a66597, td->pipe); |
1031 | } | 1035 | } |
1032 | 1036 | ||
1037 | static int is_set_address(unsigned char *setup_packet) | ||
1038 | { | ||
1039 | if (((setup_packet[0] & USB_TYPE_MASK) == USB_TYPE_STANDARD) && | ||
1040 | setup_packet[1] == USB_REQ_SET_ADDRESS) | ||
1041 | return 1; | ||
1042 | else | ||
1043 | return 0; | ||
1044 | } | ||
1045 | |||
1033 | /* this function must be called with interrupt disabled */ | 1046 | /* this function must be called with interrupt disabled */ |
1034 | static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td) | 1047 | static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td) |
1035 | { | 1048 | { |
@@ -1037,7 +1050,7 @@ static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td) | |||
1037 | 1050 | ||
1038 | switch (td->type) { | 1051 | switch (td->type) { |
1039 | case USB_PID_SETUP: | 1052 | case USB_PID_SETUP: |
1040 | if (td->urb->setup_packet[1] == USB_REQ_SET_ADDRESS) { | 1053 | if (is_set_address(td->urb->setup_packet)) { |
1041 | td->set_address = 1; | 1054 | td->set_address = 1; |
1042 | td->urb->setup_packet[2] = alloc_usb_address(r8a66597, | 1055 | td->urb->setup_packet[2] = alloc_usb_address(r8a66597, |
1043 | td->urb); | 1056 | td->urb); |
@@ -1104,8 +1117,9 @@ static void set_td_timer(struct r8a66597 *r8a66597, struct r8a66597_td *td) | |||
1104 | } | 1117 | } |
1105 | 1118 | ||
1106 | /* this function must be called with interrupt disabled */ | 1119 | /* this function must be called with interrupt disabled */ |
1107 | static void done(struct r8a66597 *r8a66597, struct r8a66597_td *td, | 1120 | static void finish_request(struct r8a66597 *r8a66597, struct r8a66597_td *td, |
1108 | u16 pipenum, struct urb *urb) | 1121 | u16 pipenum, struct urb *urb, int status) |
1122 | __releases(r8a66597->lock) __acquires(r8a66597->lock) | ||
1109 | { | 1123 | { |
1110 | int restart = 0; | 1124 | int restart = 0; |
1111 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); | 1125 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); |
@@ -1113,7 +1127,7 @@ static void done(struct r8a66597 *r8a66597, struct r8a66597_td *td, | |||
1113 | r8a66597->timeout_map &= ~(1 << pipenum); | 1127 | r8a66597->timeout_map &= ~(1 << pipenum); |
1114 | 1128 | ||
1115 | if (likely(td)) { | 1129 | if (likely(td)) { |
1116 | if (td->set_address && urb->status != 0) | 1130 | if (td->set_address && (status != 0 || urb->unlinked)) |
1117 | r8a66597->address_map &= ~(1 << urb->setup_packet[2]); | 1131 | r8a66597->address_map &= ~(1 << urb->setup_packet[2]); |
1118 | 1132 | ||
1119 | pipe_toggle_save(r8a66597, td->pipe, urb); | 1133 | pipe_toggle_save(r8a66597, td->pipe, urb); |
@@ -1128,9 +1142,9 @@ static void done(struct r8a66597 *r8a66597, struct r8a66597_td *td, | |||
1128 | if (usb_pipeisoc(urb->pipe)) | 1142 | if (usb_pipeisoc(urb->pipe)) |
1129 | urb->start_frame = r8a66597_get_frame(hcd); | 1143 | urb->start_frame = r8a66597_get_frame(hcd); |
1130 | 1144 | ||
1131 | urb->hcpriv = NULL; | 1145 | usb_hcd_unlink_urb_from_ep(r8a66597_to_hcd(r8a66597), urb); |
1132 | spin_unlock(&r8a66597->lock); | 1146 | spin_unlock(&r8a66597->lock); |
1133 | usb_hcd_giveback_urb(hcd, urb); | 1147 | usb_hcd_giveback_urb(hcd, urb, status); |
1134 | spin_lock(&r8a66597->lock); | 1148 | spin_lock(&r8a66597->lock); |
1135 | } | 1149 | } |
1136 | 1150 | ||
@@ -1144,14 +1158,6 @@ static void done(struct r8a66597 *r8a66597, struct r8a66597_td *td, | |||
1144 | } | 1158 | } |
1145 | } | 1159 | } |
1146 | 1160 | ||
1147 | /* this function must be called with interrupt disabled */ | ||
1148 | static void finish_request(struct r8a66597 *r8a66597, struct r8a66597_td *td, | ||
1149 | u16 pipenum, struct urb *urb) | ||
1150 | __releases(r8a66597->lock) __acquires(r8a66597->lock) | ||
1151 | { | ||
1152 | done(r8a66597, td, pipenum, urb); | ||
1153 | } | ||
1154 | |||
1155 | static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | 1161 | static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) |
1156 | { | 1162 | { |
1157 | u16 tmp; | 1163 | u16 tmp; |
@@ -1160,6 +1166,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1160 | struct r8a66597_td *td = r8a66597_get_td(r8a66597, pipenum); | 1166 | struct r8a66597_td *td = r8a66597_get_td(r8a66597, pipenum); |
1161 | struct urb *urb; | 1167 | struct urb *urb; |
1162 | int finish = 0; | 1168 | int finish = 0; |
1169 | int status = 0; | ||
1163 | 1170 | ||
1164 | if (unlikely(!td)) | 1171 | if (unlikely(!td)) |
1165 | return; | 1172 | return; |
@@ -1168,17 +1175,15 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1168 | fifo_change_from_pipe(r8a66597, td->pipe); | 1175 | fifo_change_from_pipe(r8a66597, td->pipe); |
1169 | tmp = r8a66597_read(r8a66597, td->pipe->fifoctr); | 1176 | tmp = r8a66597_read(r8a66597, td->pipe->fifoctr); |
1170 | if (unlikely((tmp & FRDY) == 0)) { | 1177 | if (unlikely((tmp & FRDY) == 0)) { |
1171 | urb->status = -EPIPE; | ||
1172 | pipe_stop(r8a66597, td->pipe); | 1178 | pipe_stop(r8a66597, td->pipe); |
1173 | pipe_irq_disable(r8a66597, pipenum); | 1179 | pipe_irq_disable(r8a66597, pipenum); |
1174 | err("in fifo not ready (%d)", pipenum); | 1180 | err("in fifo not ready (%d)", pipenum); |
1175 | finish_request(r8a66597, td, pipenum, td->urb); | 1181 | finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); |
1176 | return; | 1182 | return; |
1177 | } | 1183 | } |
1178 | 1184 | ||
1179 | /* prepare parameters */ | 1185 | /* prepare parameters */ |
1180 | rcv_len = tmp & DTLN; | 1186 | rcv_len = tmp & DTLN; |
1181 | bufsize = td->maxpacket; | ||
1182 | if (usb_pipeisoc(urb->pipe)) { | 1187 | if (usb_pipeisoc(urb->pipe)) { |
1183 | buf = (u16 *)(urb->transfer_buffer + | 1188 | buf = (u16 *)(urb->transfer_buffer + |
1184 | urb->iso_frame_desc[td->iso_cnt].offset); | 1189 | urb->iso_frame_desc[td->iso_cnt].offset); |
@@ -1187,29 +1192,31 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1187 | buf = (void *)urb->transfer_buffer + urb->actual_length; | 1192 | buf = (void *)urb->transfer_buffer + urb->actual_length; |
1188 | urb_len = urb->transfer_buffer_length - urb->actual_length; | 1193 | urb_len = urb->transfer_buffer_length - urb->actual_length; |
1189 | } | 1194 | } |
1190 | if (rcv_len < bufsize) | 1195 | bufsize = min(urb_len, (int) td->maxpacket); |
1191 | size = min(rcv_len, urb_len); | 1196 | if (rcv_len <= bufsize) { |
1192 | else | 1197 | size = rcv_len; |
1193 | size = min(bufsize, urb_len); | 1198 | } else { |
1199 | size = bufsize; | ||
1200 | status = -EOVERFLOW; | ||
1201 | finish = 1; | ||
1202 | } | ||
1194 | 1203 | ||
1195 | /* update parameters */ | 1204 | /* update parameters */ |
1196 | urb->actual_length += size; | 1205 | urb->actual_length += size; |
1197 | if (rcv_len == 0) | 1206 | if (rcv_len == 0) |
1198 | td->zero_packet = 1; | 1207 | td->zero_packet = 1; |
1199 | if ((size % td->maxpacket) > 0) { | 1208 | if (rcv_len < bufsize) { |
1200 | td->short_packet = 1; | 1209 | td->short_packet = 1; |
1201 | if (urb->transfer_buffer_length != urb->actual_length && | ||
1202 | urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1203 | td->urb->status = -EREMOTEIO; | ||
1204 | } | 1210 | } |
1205 | if (usb_pipeisoc(urb->pipe)) { | 1211 | if (usb_pipeisoc(urb->pipe)) { |
1206 | urb->iso_frame_desc[td->iso_cnt].actual_length = size; | 1212 | urb->iso_frame_desc[td->iso_cnt].actual_length = size; |
1207 | urb->iso_frame_desc[td->iso_cnt].status = 0; | 1213 | urb->iso_frame_desc[td->iso_cnt].status = status; |
1208 | td->iso_cnt++; | 1214 | td->iso_cnt++; |
1215 | finish = 0; | ||
1209 | } | 1216 | } |
1210 | 1217 | ||
1211 | /* check transfer finish */ | 1218 | /* check transfer finish */ |
1212 | if (check_transfer_finish(td, urb)) { | 1219 | if (finish || check_transfer_finish(td, urb)) { |
1213 | pipe_stop(r8a66597, td->pipe); | 1220 | pipe_stop(r8a66597, td->pipe); |
1214 | pipe_irq_disable(r8a66597, pipenum); | 1221 | pipe_irq_disable(r8a66597, pipenum); |
1215 | finish = 1; | 1222 | finish = 1; |
@@ -1224,11 +1231,8 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum) | |||
1224 | buf, size); | 1231 | buf, size); |
1225 | } | 1232 | } |
1226 | 1233 | ||
1227 | if (finish && pipenum != 0) { | 1234 | if (finish && pipenum != 0) |
1228 | if (td->urb->status == -EINPROGRESS) | 1235 | finish_request(r8a66597, td, pipenum, urb, status); |
1229 | td->urb->status = 0; | ||
1230 | finish_request(r8a66597, td, pipenum, urb); | ||
1231 | } | ||
1232 | } | 1236 | } |
1233 | 1237 | ||
1234 | static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | 1238 | static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) |
@@ -1246,11 +1250,10 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | |||
1246 | fifo_change_from_pipe(r8a66597, td->pipe); | 1250 | fifo_change_from_pipe(r8a66597, td->pipe); |
1247 | tmp = r8a66597_read(r8a66597, td->pipe->fifoctr); | 1251 | tmp = r8a66597_read(r8a66597, td->pipe->fifoctr); |
1248 | if (unlikely((tmp & FRDY) == 0)) { | 1252 | if (unlikely((tmp & FRDY) == 0)) { |
1249 | urb->status = -EPIPE; | ||
1250 | pipe_stop(r8a66597, td->pipe); | 1253 | pipe_stop(r8a66597, td->pipe); |
1251 | pipe_irq_disable(r8a66597, pipenum); | 1254 | pipe_irq_disable(r8a66597, pipenum); |
1252 | err("out write fifo not ready. (%d)", pipenum); | 1255 | err("out write fifo not ready. (%d)", pipenum); |
1253 | finish_request(r8a66597, td, pipenum, td->urb); | 1256 | finish_request(r8a66597, td, pipenum, urb, -EPIPE); |
1254 | return; | 1257 | return; |
1255 | } | 1258 | } |
1256 | 1259 | ||
@@ -1269,7 +1272,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | |||
1269 | 1272 | ||
1270 | /* write fifo */ | 1273 | /* write fifo */ |
1271 | if (pipenum > 0) | 1274 | if (pipenum > 0) |
1272 | r8a66597_write(r8a66597, (u16)~(1 << pipenum), BEMPSTS); | 1275 | r8a66597_write(r8a66597, ~(1 << pipenum), BEMPSTS); |
1273 | if (urb->transfer_buffer) { | 1276 | if (urb->transfer_buffer) { |
1274 | r8a66597_write_fifo(r8a66597, td->pipe->fifoaddr, buf, size); | 1277 | r8a66597_write_fifo(r8a66597, td->pipe->fifoaddr, buf, size); |
1275 | if (!usb_pipebulk(urb->pipe) || td->maxpacket != size) | 1278 | if (!usb_pipebulk(urb->pipe) || td->maxpacket != size) |
@@ -1295,7 +1298,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | |||
1295 | } | 1298 | } |
1296 | 1299 | ||
1297 | 1300 | ||
1298 | static void check_next_phase(struct r8a66597 *r8a66597) | 1301 | static void check_next_phase(struct r8a66597 *r8a66597, int status) |
1299 | { | 1302 | { |
1300 | struct r8a66597_td *td = r8a66597_get_td(r8a66597, 0); | 1303 | struct r8a66597_td *td = r8a66597_get_td(r8a66597, 0); |
1301 | struct urb *urb; | 1304 | struct urb *urb; |
@@ -1308,49 +1311,41 @@ static void check_next_phase(struct r8a66597 *r8a66597) | |||
1308 | switch (td->type) { | 1311 | switch (td->type) { |
1309 | case USB_PID_IN: | 1312 | case USB_PID_IN: |
1310 | case USB_PID_OUT: | 1313 | case USB_PID_OUT: |
1311 | if (urb->status != -EINPROGRESS) { | ||
1312 | finish = 1; | ||
1313 | break; | ||
1314 | } | ||
1315 | if (check_transfer_finish(td, urb)) | 1314 | if (check_transfer_finish(td, urb)) |
1316 | td->type = USB_PID_ACK; | 1315 | td->type = USB_PID_ACK; |
1317 | break; | 1316 | break; |
1318 | case USB_PID_SETUP: | 1317 | case USB_PID_SETUP: |
1319 | if (urb->status != -EINPROGRESS) | 1318 | if (urb->transfer_buffer_length == urb->actual_length) |
1320 | finish = 1; | ||
1321 | else if (urb->transfer_buffer_length == urb->actual_length) { | ||
1322 | td->type = USB_PID_ACK; | 1319 | td->type = USB_PID_ACK; |
1323 | urb->status = 0; | 1320 | else if (usb_pipeout(urb->pipe)) |
1324 | } else if (usb_pipeout(urb->pipe)) | ||
1325 | td->type = USB_PID_OUT; | 1321 | td->type = USB_PID_OUT; |
1326 | else | 1322 | else |
1327 | td->type = USB_PID_IN; | 1323 | td->type = USB_PID_IN; |
1328 | break; | 1324 | break; |
1329 | case USB_PID_ACK: | 1325 | case USB_PID_ACK: |
1330 | finish = 1; | 1326 | finish = 1; |
1331 | if (urb->status == -EINPROGRESS) | ||
1332 | urb->status = 0; | ||
1333 | break; | 1327 | break; |
1334 | } | 1328 | } |
1335 | 1329 | ||
1336 | if (finish) | 1330 | if (finish || status != 0 || urb->unlinked) |
1337 | finish_request(r8a66597, td, 0, urb); | 1331 | finish_request(r8a66597, td, 0, urb, status); |
1338 | else | 1332 | else |
1339 | start_transfer(r8a66597, td); | 1333 | start_transfer(r8a66597, td); |
1340 | } | 1334 | } |
1341 | 1335 | ||
1342 | static void set_urb_error(struct r8a66597 *r8a66597, u16 pipenum) | 1336 | static int get_urb_error(struct r8a66597 *r8a66597, u16 pipenum) |
1343 | { | 1337 | { |
1344 | struct r8a66597_td *td = r8a66597_get_td(r8a66597, pipenum); | 1338 | struct r8a66597_td *td = r8a66597_get_td(r8a66597, pipenum); |
1345 | 1339 | ||
1346 | if (td && td->urb) { | 1340 | if (td) { |
1347 | u16 pid = r8a66597_read(r8a66597, td->pipe->pipectr) & PID; | 1341 | u16 pid = r8a66597_read(r8a66597, td->pipe->pipectr) & PID; |
1348 | 1342 | ||
1349 | if (pid == PID_NAK) | 1343 | if (pid == PID_NAK) |
1350 | td->urb->status = -ECONNRESET; | 1344 | return -ECONNRESET; |
1351 | else | 1345 | else |
1352 | td->urb->status = -EPIPE; | 1346 | return -EPIPE; |
1353 | } | 1347 | } |
1348 | return 0; | ||
1354 | } | 1349 | } |
1355 | 1350 | ||
1356 | static void irq_pipe_ready(struct r8a66597 *r8a66597) | 1351 | static void irq_pipe_ready(struct r8a66597 *r8a66597) |
@@ -1362,14 +1357,14 @@ static void irq_pipe_ready(struct r8a66597 *r8a66597) | |||
1362 | 1357 | ||
1363 | mask = r8a66597_read(r8a66597, BRDYSTS) | 1358 | mask = r8a66597_read(r8a66597, BRDYSTS) |
1364 | & r8a66597_read(r8a66597, BRDYENB); | 1359 | & r8a66597_read(r8a66597, BRDYENB); |
1365 | r8a66597_write(r8a66597, (u16)~mask, BRDYSTS); | 1360 | r8a66597_write(r8a66597, ~mask, BRDYSTS); |
1366 | if (mask & BRDY0) { | 1361 | if (mask & BRDY0) { |
1367 | td = r8a66597_get_td(r8a66597, 0); | 1362 | td = r8a66597_get_td(r8a66597, 0); |
1368 | if (td && td->type == USB_PID_IN) | 1363 | if (td && td->type == USB_PID_IN) |
1369 | packet_read(r8a66597, 0); | 1364 | packet_read(r8a66597, 0); |
1370 | else | 1365 | else |
1371 | pipe_irq_disable(r8a66597, 0); | 1366 | pipe_irq_disable(r8a66597, 0); |
1372 | check_next_phase(r8a66597); | 1367 | check_next_phase(r8a66597, 0); |
1373 | } | 1368 | } |
1374 | 1369 | ||
1375 | for (pipenum = 1; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { | 1370 | for (pipenum = 1; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { |
@@ -1397,13 +1392,13 @@ static void irq_pipe_empty(struct r8a66597 *r8a66597) | |||
1397 | 1392 | ||
1398 | mask = r8a66597_read(r8a66597, BEMPSTS) | 1393 | mask = r8a66597_read(r8a66597, BEMPSTS) |
1399 | & r8a66597_read(r8a66597, BEMPENB); | 1394 | & r8a66597_read(r8a66597, BEMPENB); |
1400 | r8a66597_write(r8a66597, (u16)~mask, BEMPSTS); | 1395 | r8a66597_write(r8a66597, ~mask, BEMPSTS); |
1401 | if (mask & BEMP0) { | 1396 | if (mask & BEMP0) { |
1402 | cfifo_change(r8a66597, 0); | 1397 | cfifo_change(r8a66597, 0); |
1403 | td = r8a66597_get_td(r8a66597, 0); | 1398 | td = r8a66597_get_td(r8a66597, 0); |
1404 | if (td && td->type != USB_PID_OUT) | 1399 | if (td && td->type != USB_PID_OUT) |
1405 | disable_irq_empty(r8a66597, 0); | 1400 | disable_irq_empty(r8a66597, 0); |
1406 | check_next_phase(r8a66597); | 1401 | check_next_phase(r8a66597, 0); |
1407 | } | 1402 | } |
1408 | 1403 | ||
1409 | for (pipenum = 1; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { | 1404 | for (pipenum = 1; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { |
@@ -1418,9 +1413,8 @@ static void irq_pipe_empty(struct r8a66597 *r8a66597) | |||
1418 | if ((tmp & INBUFM) == 0) { | 1413 | if ((tmp & INBUFM) == 0) { |
1419 | disable_irq_empty(r8a66597, pipenum); | 1414 | disable_irq_empty(r8a66597, pipenum); |
1420 | pipe_irq_disable(r8a66597, pipenum); | 1415 | pipe_irq_disable(r8a66597, pipenum); |
1421 | if (td->urb->status == -EINPROGRESS) | 1416 | finish_request(r8a66597, td, pipenum, td->urb, |
1422 | td->urb->status = 0; | 1417 | 0); |
1423 | finish_request(r8a66597, td, pipenum, td->urb); | ||
1424 | } | 1418 | } |
1425 | } | 1419 | } |
1426 | } | 1420 | } |
@@ -1431,15 +1425,16 @@ static void irq_pipe_nrdy(struct r8a66597 *r8a66597) | |||
1431 | u16 check; | 1425 | u16 check; |
1432 | u16 pipenum; | 1426 | u16 pipenum; |
1433 | u16 mask; | 1427 | u16 mask; |
1428 | int status; | ||
1434 | 1429 | ||
1435 | mask = r8a66597_read(r8a66597, NRDYSTS) | 1430 | mask = r8a66597_read(r8a66597, NRDYSTS) |
1436 | & r8a66597_read(r8a66597, NRDYENB); | 1431 | & r8a66597_read(r8a66597, NRDYENB); |
1437 | r8a66597_write(r8a66597, (u16)~mask, NRDYSTS); | 1432 | r8a66597_write(r8a66597, ~mask, NRDYSTS); |
1438 | if (mask & NRDY0) { | 1433 | if (mask & NRDY0) { |
1439 | cfifo_change(r8a66597, 0); | 1434 | cfifo_change(r8a66597, 0); |
1440 | set_urb_error(r8a66597, 0); | 1435 | status = get_urb_error(r8a66597, 0); |
1441 | pipe_irq_disable(r8a66597, 0); | 1436 | pipe_irq_disable(r8a66597, 0); |
1442 | check_next_phase(r8a66597); | 1437 | check_next_phase(r8a66597, status); |
1443 | } | 1438 | } |
1444 | 1439 | ||
1445 | for (pipenum = 1; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { | 1440 | for (pipenum = 1; pipenum < R8A66597_MAX_NUM_PIPE; pipenum++) { |
@@ -1450,10 +1445,10 @@ static void irq_pipe_nrdy(struct r8a66597 *r8a66597) | |||
1450 | if (unlikely(!td)) | 1445 | if (unlikely(!td)) |
1451 | continue; | 1446 | continue; |
1452 | 1447 | ||
1453 | set_urb_error(r8a66597, pipenum); | 1448 | status = get_urb_error(r8a66597, pipenum); |
1454 | pipe_irq_disable(r8a66597, pipenum); | 1449 | pipe_irq_disable(r8a66597, pipenum); |
1455 | pipe_stop(r8a66597, td->pipe); | 1450 | pipe_stop(r8a66597, td->pipe); |
1456 | finish_request(r8a66597, td, pipenum, td->urb); | 1451 | finish_request(r8a66597, td, pipenum, td->urb, status); |
1457 | } | 1452 | } |
1458 | } | 1453 | } |
1459 | } | 1454 | } |
@@ -1473,6 +1468,7 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) | |||
1473 | u16 intsts0, intsts1, intsts2; | 1468 | u16 intsts0, intsts1, intsts2; |
1474 | u16 intenb0, intenb1, intenb2; | 1469 | u16 intenb0, intenb1, intenb2; |
1475 | u16 mask0, mask1, mask2; | 1470 | u16 mask0, mask1, mask2; |
1471 | int status; | ||
1476 | 1472 | ||
1477 | spin_lock(&r8a66597->lock); | 1473 | spin_lock(&r8a66597->lock); |
1478 | 1474 | ||
@@ -1488,14 +1484,14 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) | |||
1488 | mask0 = intsts0 & intenb0 & (BEMP | NRDY | BRDY); | 1484 | mask0 = intsts0 & intenb0 & (BEMP | NRDY | BRDY); |
1489 | if (mask2) { | 1485 | if (mask2) { |
1490 | if (mask2 & ATTCH) { | 1486 | if (mask2 & ATTCH) { |
1491 | r8a66597_write(r8a66597, (u16)~ATTCH, INTSTS2); | 1487 | r8a66597_write(r8a66597, ~ATTCH, INTSTS2); |
1492 | r8a66597_bclr(r8a66597, ATTCHE, INTENB2); | 1488 | r8a66597_bclr(r8a66597, ATTCHE, INTENB2); |
1493 | 1489 | ||
1494 | /* start usb bus sampling */ | 1490 | /* start usb bus sampling */ |
1495 | start_root_hub_sampling(r8a66597, 1); | 1491 | start_root_hub_sampling(r8a66597, 1); |
1496 | } | 1492 | } |
1497 | if (mask2 & DTCH) { | 1493 | if (mask2 & DTCH) { |
1498 | r8a66597_write(r8a66597, (u16)~DTCH, INTSTS2); | 1494 | r8a66597_write(r8a66597, ~DTCH, INTSTS2); |
1499 | r8a66597_bclr(r8a66597, DTCHE, INTENB2); | 1495 | r8a66597_bclr(r8a66597, DTCHE, INTENB2); |
1500 | r8a66597_usb_disconnect(r8a66597, 1); | 1496 | r8a66597_usb_disconnect(r8a66597, 1); |
1501 | } | 1497 | } |
@@ -1503,25 +1499,25 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) | |||
1503 | 1499 | ||
1504 | if (mask1) { | 1500 | if (mask1) { |
1505 | if (mask1 & ATTCH) { | 1501 | if (mask1 & ATTCH) { |
1506 | r8a66597_write(r8a66597, (u16)~ATTCH, INTSTS1); | 1502 | r8a66597_write(r8a66597, ~ATTCH, INTSTS1); |
1507 | r8a66597_bclr(r8a66597, ATTCHE, INTENB1); | 1503 | r8a66597_bclr(r8a66597, ATTCHE, INTENB1); |
1508 | 1504 | ||
1509 | /* start usb bus sampling */ | 1505 | /* start usb bus sampling */ |
1510 | start_root_hub_sampling(r8a66597, 0); | 1506 | start_root_hub_sampling(r8a66597, 0); |
1511 | } | 1507 | } |
1512 | if (mask1 & DTCH) { | 1508 | if (mask1 & DTCH) { |
1513 | r8a66597_write(r8a66597, (u16)~DTCH, INTSTS1); | 1509 | r8a66597_write(r8a66597, ~DTCH, INTSTS1); |
1514 | r8a66597_bclr(r8a66597, DTCHE, INTENB1); | 1510 | r8a66597_bclr(r8a66597, DTCHE, INTENB1); |
1515 | r8a66597_usb_disconnect(r8a66597, 0); | 1511 | r8a66597_usb_disconnect(r8a66597, 0); |
1516 | } | 1512 | } |
1517 | if (mask1 & SIGN) { | 1513 | if (mask1 & SIGN) { |
1518 | r8a66597_write(r8a66597, (u16)~SIGN, INTSTS1); | 1514 | r8a66597_write(r8a66597, ~SIGN, INTSTS1); |
1519 | set_urb_error(r8a66597, 0); | 1515 | status = get_urb_error(r8a66597, 0); |
1520 | check_next_phase(r8a66597); | 1516 | check_next_phase(r8a66597, status); |
1521 | } | 1517 | } |
1522 | if (mask1 & SACK) { | 1518 | if (mask1 & SACK) { |
1523 | r8a66597_write(r8a66597, (u16)~SACK, INTSTS1); | 1519 | r8a66597_write(r8a66597, ~SACK, INTSTS1); |
1524 | check_next_phase(r8a66597); | 1520 | check_next_phase(r8a66597, 0); |
1525 | } | 1521 | } |
1526 | } | 1522 | } |
1527 | if (mask0) { | 1523 | if (mask0) { |
@@ -1663,13 +1659,9 @@ static int check_pipe_config(struct r8a66597 *r8a66597, struct urb *urb) | |||
1663 | static int r8a66597_start(struct usb_hcd *hcd) | 1659 | static int r8a66597_start(struct usb_hcd *hcd) |
1664 | { | 1660 | { |
1665 | struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); | 1661 | struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); |
1666 | int ret; | ||
1667 | 1662 | ||
1668 | hcd->state = HC_STATE_RUNNING; | 1663 | hcd->state = HC_STATE_RUNNING; |
1669 | if ((ret = enable_controller(r8a66597)) < 0) | 1664 | return enable_controller(r8a66597); |
1670 | return ret; | ||
1671 | |||
1672 | return 0; | ||
1673 | } | 1665 | } |
1674 | 1666 | ||
1675 | static void r8a66597_stop(struct usb_hcd *hcd) | 1667 | static void r8a66597_stop(struct usb_hcd *hcd) |
@@ -1696,13 +1688,12 @@ static void set_address_zero(struct r8a66597 *r8a66597, struct urb *urb) | |||
1696 | 1688 | ||
1697 | static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, | 1689 | static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, |
1698 | struct urb *urb, | 1690 | struct urb *urb, |
1699 | struct usb_host_endpoint *hep, | 1691 | struct usb_host_endpoint *hep) |
1700 | gfp_t mem_flags) | ||
1701 | { | 1692 | { |
1702 | struct r8a66597_td *td; | 1693 | struct r8a66597_td *td; |
1703 | u16 pipenum; | 1694 | u16 pipenum; |
1704 | 1695 | ||
1705 | td = kzalloc(sizeof(struct r8a66597_td), mem_flags); | 1696 | td = kzalloc(sizeof(struct r8a66597_td), GFP_ATOMIC); |
1706 | if (td == NULL) | 1697 | if (td == NULL) |
1707 | return NULL; | 1698 | return NULL; |
1708 | 1699 | ||
@@ -1725,23 +1716,28 @@ static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, | |||
1725 | } | 1716 | } |
1726 | 1717 | ||
1727 | static int r8a66597_urb_enqueue(struct usb_hcd *hcd, | 1718 | static int r8a66597_urb_enqueue(struct usb_hcd *hcd, |
1728 | struct usb_host_endpoint *hep, | ||
1729 | struct urb *urb, | 1719 | struct urb *urb, |
1730 | gfp_t mem_flags) | 1720 | gfp_t mem_flags) |
1731 | { | 1721 | { |
1722 | struct usb_host_endpoint *hep = urb->ep; | ||
1732 | struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); | 1723 | struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); |
1733 | struct r8a66597_td *td = NULL; | 1724 | struct r8a66597_td *td = NULL; |
1734 | int ret = 0, request = 0; | 1725 | int ret, request = 0; |
1735 | unsigned long flags; | 1726 | unsigned long flags; |
1736 | 1727 | ||
1737 | spin_lock_irqsave(&r8a66597->lock, flags); | 1728 | spin_lock_irqsave(&r8a66597->lock, flags); |
1738 | if (!get_urb_to_r8a66597_dev(r8a66597, urb)) { | 1729 | if (!get_urb_to_r8a66597_dev(r8a66597, urb)) { |
1739 | ret = -ENODEV; | 1730 | ret = -ENODEV; |
1740 | goto error; | 1731 | goto error_not_linked; |
1741 | } | 1732 | } |
1742 | 1733 | ||
1734 | ret = usb_hcd_link_urb_to_ep(hcd, urb); | ||
1735 | if (ret) | ||
1736 | goto error_not_linked; | ||
1737 | |||
1743 | if (!hep->hcpriv) { | 1738 | if (!hep->hcpriv) { |
1744 | hep->hcpriv = kzalloc(sizeof(struct r8a66597_pipe), mem_flags); | 1739 | hep->hcpriv = kzalloc(sizeof(struct r8a66597_pipe), |
1740 | GFP_ATOMIC); | ||
1745 | if (!hep->hcpriv) { | 1741 | if (!hep->hcpriv) { |
1746 | ret = -ENOMEM; | 1742 | ret = -ENOMEM; |
1747 | goto error; | 1743 | goto error; |
@@ -1755,7 +1751,7 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd, | |||
1755 | init_pipe_config(r8a66597, urb); | 1751 | init_pipe_config(r8a66597, urb); |
1756 | 1752 | ||
1757 | set_address_zero(r8a66597, urb); | 1753 | set_address_zero(r8a66597, urb); |
1758 | td = r8a66597_make_td(r8a66597, urb, hep, mem_flags); | 1754 | td = r8a66597_make_td(r8a66597, urb, hep); |
1759 | if (td == NULL) { | 1755 | if (td == NULL) { |
1760 | ret = -ENOMEM; | 1756 | ret = -ENOMEM; |
1761 | goto error; | 1757 | goto error; |
@@ -1763,15 +1759,7 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd, | |||
1763 | if (list_empty(&r8a66597->pipe_queue[td->pipenum])) | 1759 | if (list_empty(&r8a66597->pipe_queue[td->pipenum])) |
1764 | request = 1; | 1760 | request = 1; |
1765 | list_add_tail(&td->queue, &r8a66597->pipe_queue[td->pipenum]); | 1761 | list_add_tail(&td->queue, &r8a66597->pipe_queue[td->pipenum]); |
1766 | |||
1767 | spin_lock(&urb->lock); | ||
1768 | if (urb->status != -EINPROGRESS) { | ||
1769 | spin_unlock(&urb->lock); | ||
1770 | ret = -EPIPE; | ||
1771 | goto error; | ||
1772 | } | ||
1773 | urb->hcpriv = td; | 1762 | urb->hcpriv = td; |
1774 | spin_unlock(&urb->lock); | ||
1775 | 1763 | ||
1776 | if (request) { | 1764 | if (request) { |
1777 | ret = start_transfer(r8a66597, td); | 1765 | ret = start_transfer(r8a66597, td); |
@@ -1783,26 +1771,36 @@ static int r8a66597_urb_enqueue(struct usb_hcd *hcd, | |||
1783 | set_td_timer(r8a66597, td); | 1771 | set_td_timer(r8a66597, td); |
1784 | 1772 | ||
1785 | error: | 1773 | error: |
1774 | if (ret) | ||
1775 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
1776 | error_not_linked: | ||
1786 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1777 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
1787 | return ret; | 1778 | return ret; |
1788 | } | 1779 | } |
1789 | 1780 | ||
1790 | static int r8a66597_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | 1781 | static int r8a66597_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, |
1782 | int status) | ||
1791 | { | 1783 | { |
1792 | struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); | 1784 | struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd); |
1793 | struct r8a66597_td *td; | 1785 | struct r8a66597_td *td; |
1794 | unsigned long flags; | 1786 | unsigned long flags; |
1787 | int rc; | ||
1795 | 1788 | ||
1796 | spin_lock_irqsave(&r8a66597->lock, flags); | 1789 | spin_lock_irqsave(&r8a66597->lock, flags); |
1790 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); | ||
1791 | if (rc) | ||
1792 | goto done; | ||
1793 | |||
1797 | if (urb->hcpriv) { | 1794 | if (urb->hcpriv) { |
1798 | td = urb->hcpriv; | 1795 | td = urb->hcpriv; |
1799 | pipe_stop(r8a66597, td->pipe); | 1796 | pipe_stop(r8a66597, td->pipe); |
1800 | pipe_irq_disable(r8a66597, td->pipenum); | 1797 | pipe_irq_disable(r8a66597, td->pipenum); |
1801 | disable_irq_empty(r8a66597, td->pipenum); | 1798 | disable_irq_empty(r8a66597, td->pipenum); |
1802 | done(r8a66597, td, td->pipenum, urb); | 1799 | finish_request(r8a66597, td, td->pipenum, urb, status); |
1803 | } | 1800 | } |
1801 | done: | ||
1804 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1802 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
1805 | return 0; | 1803 | return rc; |
1806 | } | 1804 | } |
1807 | 1805 | ||
1808 | static void r8a66597_endpoint_disable(struct usb_hcd *hcd, | 1806 | static void r8a66597_endpoint_disable(struct usb_hcd *hcd, |
@@ -1832,7 +1830,7 @@ static void r8a66597_endpoint_disable(struct usb_hcd *hcd, | |||
1832 | td = r8a66597_get_td(r8a66597, pipenum); | 1830 | td = r8a66597_get_td(r8a66597, pipenum); |
1833 | if (td) | 1831 | if (td) |
1834 | urb = td->urb; | 1832 | urb = td->urb; |
1835 | done(r8a66597, td, pipenum, urb); | 1833 | finish_request(r8a66597, td, pipenum, urb, -ESHUTDOWN); |
1836 | kfree(hep->hcpriv); | 1834 | kfree(hep->hcpriv); |
1837 | hep->hcpriv = NULL; | 1835 | hep->hcpriv = NULL; |
1838 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1836 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
@@ -2029,7 +2027,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2029 | case GetPortStatus: | 2027 | case GetPortStatus: |
2030 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2028 | if (wIndex > R8A66597_MAX_ROOT_HUB) |
2031 | goto error; | 2029 | goto error; |
2032 | *(u32 *)buf = rh->port; | 2030 | *(u32 *)buf = cpu_to_le32(rh->port); |
2033 | break; | 2031 | break; |
2034 | case SetPortFeature: | 2032 | case SetPortFeature: |
2035 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2033 | if (wIndex > R8A66597_MAX_ROOT_HUB) |
@@ -2128,8 +2126,8 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2128 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); | 2126 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); |
2129 | 2127 | ||
2130 | del_timer_sync(&r8a66597->rh_timer); | 2128 | del_timer_sync(&r8a66597->rh_timer); |
2131 | iounmap((void *)r8a66597->reg); | ||
2132 | usb_remove_hcd(hcd); | 2129 | usb_remove_hcd(hcd); |
2130 | iounmap((void *)r8a66597->reg); | ||
2133 | usb_put_hcd(hcd); | 2131 | usb_put_hcd(hcd); |
2134 | return 0; | 2132 | return 0; |
2135 | } | 2133 | } |
@@ -2210,8 +2208,6 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2210 | clean_up: | 2208 | clean_up: |
2211 | if (reg) | 2209 | if (reg) |
2212 | iounmap(reg); | 2210 | iounmap(reg); |
2213 | if (res) | ||
2214 | release_mem_region(res->start, 1); | ||
2215 | 2211 | ||
2216 | return ret; | 2212 | return ret; |
2217 | } | 2213 | } |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index 97c2a71ac7a..fe9ceb077d9 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -203,14 +203,14 @@ | |||
203 | #define DTLN 0x0FFF /* b11-0: FIFO received data length */ | 203 | #define DTLN 0x0FFF /* b11-0: FIFO received data length */ |
204 | 204 | ||
205 | /* Interrupt Enable Register 0 */ | 205 | /* Interrupt Enable Register 0 */ |
206 | #define VBSE 0x8000 /* b15: VBUS interrupt */ | 206 | #define VBSE 0x8000 /* b15: VBUS interrupt */ |
207 | #define RSME 0x4000 /* b14: Resume interrupt */ | 207 | #define RSME 0x4000 /* b14: Resume interrupt */ |
208 | #define SOFE 0x2000 /* b13: Frame update interrupt */ | 208 | #define SOFE 0x2000 /* b13: Frame update interrupt */ |
209 | #define DVSE 0x1000 /* b12: Device state transition interrupt */ | 209 | #define DVSE 0x1000 /* b12: Device state transition interrupt */ |
210 | #define CTRE 0x0800 /* b11: Control transfer stage transition interrupt */ | 210 | #define CTRE 0x0800 /* b11: Control transfer stage transition interrupt */ |
211 | #define BEMPE 0x0400 /* b10: Buffer empty interrupt */ | 211 | #define BEMPE 0x0400 /* b10: Buffer empty interrupt */ |
212 | #define NRDYE 0x0200 /* b9: Buffer not ready interrupt */ | 212 | #define NRDYE 0x0200 /* b9: Buffer not ready interrupt */ |
213 | #define BRDYE 0x0100 /* b8: Buffer ready interrupt */ | 213 | #define BRDYE 0x0100 /* b8: Buffer ready interrupt */ |
214 | 214 | ||
215 | /* Interrupt Enable Register 1 */ | 215 | /* Interrupt Enable Register 1 */ |
216 | #define OVRCRE 0x8000 /* b15: Over-current interrupt */ | 216 | #define OVRCRE 0x8000 /* b15: Over-current interrupt */ |
@@ -268,16 +268,16 @@ | |||
268 | #define SOF_DISABLE 0x0000 /* SOF OUT Disable */ | 268 | #define SOF_DISABLE 0x0000 /* SOF OUT Disable */ |
269 | 269 | ||
270 | /* Interrupt Status Register 0 */ | 270 | /* Interrupt Status Register 0 */ |
271 | #define VBINT 0x8000 /* b15: VBUS interrupt */ | 271 | #define VBINT 0x8000 /* b15: VBUS interrupt */ |
272 | #define RESM 0x4000 /* b14: Resume interrupt */ | 272 | #define RESM 0x4000 /* b14: Resume interrupt */ |
273 | #define SOFR 0x2000 /* b13: SOF frame update interrupt */ | 273 | #define SOFR 0x2000 /* b13: SOF frame update interrupt */ |
274 | #define DVST 0x1000 /* b12: Device state transition interrupt */ | 274 | #define DVST 0x1000 /* b12: Device state transition interrupt */ |
275 | #define CTRT 0x0800 /* b11: Control transfer stage transition interrupt */ | 275 | #define CTRT 0x0800 /* b11: Control transfer stage transition interrupt */ |
276 | #define BEMP 0x0400 /* b10: Buffer empty interrupt */ | 276 | #define BEMP 0x0400 /* b10: Buffer empty interrupt */ |
277 | #define NRDY 0x0200 /* b9: Buffer not ready interrupt */ | 277 | #define NRDY 0x0200 /* b9: Buffer not ready interrupt */ |
278 | #define BRDY 0x0100 /* b8: Buffer ready interrupt */ | 278 | #define BRDY 0x0100 /* b8: Buffer ready interrupt */ |
279 | #define VBSTS 0x0080 /* b7: VBUS input port */ | 279 | #define VBSTS 0x0080 /* b7: VBUS input port */ |
280 | #define DVSQ 0x0070 /* b6-4: Device state */ | 280 | #define DVSQ 0x0070 /* b6-4: Device state */ |
281 | #define DS_SPD_CNFG 0x0070 /* Suspend Configured */ | 281 | #define DS_SPD_CNFG 0x0070 /* Suspend Configured */ |
282 | #define DS_SPD_ADDR 0x0060 /* Suspend Address */ | 282 | #define DS_SPD_ADDR 0x0060 /* Suspend Address */ |
283 | #define DS_SPD_DFLT 0x0050 /* Suspend Default */ | 283 | #define DS_SPD_DFLT 0x0050 /* Suspend Default */ |
@@ -315,13 +315,10 @@ | |||
315 | /* Micro Frame Number Register */ | 315 | /* Micro Frame Number Register */ |
316 | #define UFRNM 0x0007 /* b2-0: Micro frame number */ | 316 | #define UFRNM 0x0007 /* b2-0: Micro frame number */ |
317 | 317 | ||
318 | /* USB Address / Low Power Status Recovery Register */ | ||
319 | //#define USBADDR 0x007F /* b6-0: USB address */ | ||
320 | |||
321 | /* Default Control Pipe Maxpacket Size Register */ | 318 | /* Default Control Pipe Maxpacket Size Register */ |
322 | /* Pipe Maxpacket Size Register */ | 319 | /* Pipe Maxpacket Size Register */ |
323 | #define DEVSEL 0xF000 /* b15-14: Device address select */ | 320 | #define DEVSEL 0xF000 /* b15-14: Device address select */ |
324 | #define MAXP 0x007F /* b6-0: Maxpacket size of default control pipe */ | 321 | #define MAXP 0x007F /* b6-0: Maxpacket size of default control pipe */ |
325 | 322 | ||
326 | /* Default Control Pipe Control Register */ | 323 | /* Default Control Pipe Control Register */ |
327 | #define BSTS 0x8000 /* b15: Buffer status */ | 324 | #define BSTS 0x8000 /* b15: Buffer status */ |
@@ -366,21 +363,21 @@ | |||
366 | #define MXPS 0x07FF /* b10-0: Maxpacket size */ | 363 | #define MXPS 0x07FF /* b10-0: Maxpacket size */ |
367 | 364 | ||
368 | /* Pipe Cycle Configuration Register */ | 365 | /* Pipe Cycle Configuration Register */ |
369 | #define IFIS 0x1000 /* b12: Isochronous in-buffer flush mode select */ | 366 | #define IFIS 0x1000 /* b12: Isochronous in-buffer flush mode select */ |
370 | #define IITV 0x0007 /* b2-0: Isochronous interval */ | 367 | #define IITV 0x0007 /* b2-0: Isochronous interval */ |
371 | 368 | ||
372 | /* Pipex Control Register */ | 369 | /* Pipex Control Register */ |
373 | #define BSTS 0x8000 /* b15: Buffer status */ | 370 | #define BSTS 0x8000 /* b15: Buffer status */ |
374 | #define INBUFM 0x4000 /* b14: IN buffer monitor (Only for PIPE1 to 5) */ | 371 | #define INBUFM 0x4000 /* b14: IN buffer monitor (Only for PIPE1 to 5) */ |
375 | #define CSCLR 0x2000 /* b13: complete-split status clear */ | 372 | #define CSCLR 0x2000 /* b13: complete-split status clear */ |
376 | #define CSSTS 0x1000 /* b12: complete-split status */ | 373 | #define CSSTS 0x1000 /* b12: complete-split status */ |
377 | #define ATREPM 0x0400 /* b10: Auto repeat mode */ | 374 | #define ATREPM 0x0400 /* b10: Auto repeat mode */ |
378 | #define ACLRM 0x0200 /* b9: Out buffer auto clear mode */ | 375 | #define ACLRM 0x0200 /* b9: Out buffer auto clear mode */ |
379 | #define SQCLR 0x0100 /* b8: Sequence toggle bit clear */ | 376 | #define SQCLR 0x0100 /* b8: Sequence toggle bit clear */ |
380 | #define SQSET 0x0080 /* b7: Sequence toggle bit set */ | 377 | #define SQSET 0x0080 /* b7: Sequence toggle bit set */ |
381 | #define SQMON 0x0040 /* b6: Sequence toggle bit monitor */ | 378 | #define SQMON 0x0040 /* b6: Sequence toggle bit monitor */ |
382 | #define PBUSY 0x0020 /* b5: pipe busy */ | 379 | #define PBUSY 0x0020 /* b5: pipe busy */ |
383 | #define PID 0x0003 /* b1-0: Response PID */ | 380 | #define PID 0x0003 /* b1-0: Response PID */ |
384 | 381 | ||
385 | /* PIPExTRE */ | 382 | /* PIPExTRE */ |
386 | #define TRENB 0x0200 /* b9: Transaction counter enable */ | 383 | #define TRENB 0x0200 /* b9: Transaction counter enable */ |
@@ -407,15 +404,15 @@ | |||
407 | #define make_devsel(addr) (addr << 12) | 404 | #define make_devsel(addr) (addr << 12) |
408 | 405 | ||
409 | struct r8a66597_pipe_info { | 406 | struct r8a66597_pipe_info { |
410 | u16 pipenum; | 407 | u16 pipenum; |
411 | u16 address; /* R8A66597 HCD usb addres */ | 408 | u16 address; /* R8A66597 HCD usb addres */ |
412 | u16 epnum; | 409 | u16 epnum; |
413 | u16 maxpacket; | 410 | u16 maxpacket; |
414 | u16 type; | 411 | u16 type; |
415 | u16 bufnum; | 412 | u16 bufnum; |
416 | u16 buf_bsize; | 413 | u16 buf_bsize; |
417 | u16 interval; | 414 | u16 interval; |
418 | u16 dir_in; | 415 | u16 dir_in; |
419 | }; | 416 | }; |
420 | 417 | ||
421 | struct r8a66597_pipe { | 418 | struct r8a66597_pipe { |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 4cfa3ff2c99..94d859aa73f 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -435,14 +435,9 @@ static void finish_request( | |||
435 | if (usb_pipecontrol(urb->pipe)) | 435 | if (usb_pipecontrol(urb->pipe)) |
436 | ep->nextpid = USB_PID_SETUP; | 436 | ep->nextpid = USB_PID_SETUP; |
437 | 437 | ||
438 | spin_lock(&urb->lock); | 438 | usb_hcd_unlink_urb_from_ep(sl811_to_hcd(sl811), urb); |
439 | if (urb->status == -EINPROGRESS) | ||
440 | urb->status = status; | ||
441 | urb->hcpriv = NULL; | ||
442 | spin_unlock(&urb->lock); | ||
443 | |||
444 | spin_unlock(&sl811->lock); | 439 | spin_unlock(&sl811->lock); |
445 | usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb); | 440 | usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb, status); |
446 | spin_lock(&sl811->lock); | 441 | spin_lock(&sl811->lock); |
447 | 442 | ||
448 | /* leave active endpoints in the schedule */ | 443 | /* leave active endpoints in the schedule */ |
@@ -538,35 +533,21 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank) | |||
538 | bank + SL11H_XFERCNTREG); | 533 | bank + SL11H_XFERCNTREG); |
539 | if (len > ep->length) { | 534 | if (len > ep->length) { |
540 | len = ep->length; | 535 | len = ep->length; |
541 | urb->status = -EOVERFLOW; | 536 | urbstat = -EOVERFLOW; |
542 | } | 537 | } |
543 | urb->actual_length += len; | 538 | urb->actual_length += len; |
544 | sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0), | 539 | sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0), |
545 | buf, len); | 540 | buf, len); |
546 | usb_dotoggle(udev, ep->epnum, 0); | 541 | usb_dotoggle(udev, ep->epnum, 0); |
547 | if (urb->actual_length == urb->transfer_buffer_length) | 542 | if (urbstat == -EINPROGRESS && |
548 | urbstat = 0; | 543 | (len < ep->maxpacket || |
549 | else if (len < ep->maxpacket) { | 544 | urb->actual_length == |
550 | if (urb->transfer_flags & URB_SHORT_NOT_OK) | 545 | urb->transfer_buffer_length)) { |
551 | urbstat = -EREMOTEIO; | 546 | if (usb_pipecontrol(urb->pipe)) |
547 | ep->nextpid = USB_PID_ACK; | ||
552 | else | 548 | else |
553 | urbstat = 0; | 549 | urbstat = 0; |
554 | } | 550 | } |
555 | if (usb_pipecontrol(urb->pipe) | ||
556 | && (urbstat == -EREMOTEIO | ||
557 | || urbstat == 0)) { | ||
558 | |||
559 | /* NOTE if the status stage STALLs (why?), | ||
560 | * this reports the wrong urb status. | ||
561 | */ | ||
562 | spin_lock(&urb->lock); | ||
563 | if (urb->status == -EINPROGRESS) | ||
564 | urb->status = urbstat; | ||
565 | spin_unlock(&urb->lock); | ||
566 | |||
567 | urb = NULL; | ||
568 | ep->nextpid = USB_PID_ACK; | ||
569 | } | ||
570 | break; | 551 | break; |
571 | case USB_PID_SETUP: | 552 | case USB_PID_SETUP: |
572 | // PACKET("...ACK/setup_%02x qh%p\n", bank, ep); | 553 | // PACKET("...ACK/setup_%02x qh%p\n", bank, ep); |
@@ -605,7 +586,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank) | |||
605 | bank, status, ep, urbstat); | 586 | bank, status, ep, urbstat); |
606 | } | 587 | } |
607 | 588 | ||
608 | if (urb && (urbstat != -EINPROGRESS || urb->status != -EINPROGRESS)) | 589 | if (urbstat != -EINPROGRESS || urb->unlinked) |
609 | finish_request(sl811, ep, urb, urbstat); | 590 | finish_request(sl811, ep, urb, urbstat); |
610 | } | 591 | } |
611 | 592 | ||
@@ -807,7 +788,6 @@ static int balance(struct sl811 *sl811, u16 period, u16 load) | |||
807 | 788 | ||
808 | static int sl811h_urb_enqueue( | 789 | static int sl811h_urb_enqueue( |
809 | struct usb_hcd *hcd, | 790 | struct usb_hcd *hcd, |
810 | struct usb_host_endpoint *hep, | ||
811 | struct urb *urb, | 791 | struct urb *urb, |
812 | gfp_t mem_flags | 792 | gfp_t mem_flags |
813 | ) { | 793 | ) { |
@@ -820,7 +800,8 @@ static int sl811h_urb_enqueue( | |||
820 | struct sl811h_ep *ep = NULL; | 800 | struct sl811h_ep *ep = NULL; |
821 | unsigned long flags; | 801 | unsigned long flags; |
822 | int i; | 802 | int i; |
823 | int retval = 0; | 803 | int retval; |
804 | struct usb_host_endpoint *hep = urb->ep; | ||
824 | 805 | ||
825 | #ifdef DISABLE_ISO | 806 | #ifdef DISABLE_ISO |
826 | if (type == PIPE_ISOCHRONOUS) | 807 | if (type == PIPE_ISOCHRONOUS) |
@@ -838,7 +819,12 @@ static int sl811h_urb_enqueue( | |||
838 | || !HC_IS_RUNNING(hcd->state)) { | 819 | || !HC_IS_RUNNING(hcd->state)) { |
839 | retval = -ENODEV; | 820 | retval = -ENODEV; |
840 | kfree(ep); | 821 | kfree(ep); |
841 | goto fail; | 822 | goto fail_not_linked; |
823 | } | ||
824 | retval = usb_hcd_link_urb_to_ep(hcd, urb); | ||
825 | if (retval) { | ||
826 | kfree(ep); | ||
827 | goto fail_not_linked; | ||
842 | } | 828 | } |
843 | 829 | ||
844 | if (hep->hcpriv) { | 830 | if (hep->hcpriv) { |
@@ -951,37 +937,31 @@ static int sl811h_urb_enqueue( | |||
951 | sofirq_on(sl811); | 937 | sofirq_on(sl811); |
952 | } | 938 | } |
953 | 939 | ||
954 | /* in case of unlink-during-submit */ | ||
955 | spin_lock(&urb->lock); | ||
956 | if (urb->status != -EINPROGRESS) { | ||
957 | spin_unlock(&urb->lock); | ||
958 | finish_request(sl811, ep, urb, 0); | ||
959 | retval = 0; | ||
960 | goto fail; | ||
961 | } | ||
962 | urb->hcpriv = hep; | 940 | urb->hcpriv = hep; |
963 | spin_unlock(&urb->lock); | ||
964 | |||
965 | start_transfer(sl811); | 941 | start_transfer(sl811); |
966 | sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable); | 942 | sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable); |
967 | fail: | 943 | fail: |
944 | if (retval) | ||
945 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
946 | fail_not_linked: | ||
968 | spin_unlock_irqrestore(&sl811->lock, flags); | 947 | spin_unlock_irqrestore(&sl811->lock, flags); |
969 | return retval; | 948 | return retval; |
970 | } | 949 | } |
971 | 950 | ||
972 | static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | 951 | static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
973 | { | 952 | { |
974 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 953 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
975 | struct usb_host_endpoint *hep; | 954 | struct usb_host_endpoint *hep; |
976 | unsigned long flags; | 955 | unsigned long flags; |
977 | struct sl811h_ep *ep; | 956 | struct sl811h_ep *ep; |
978 | int retval = 0; | 957 | int retval; |
979 | 958 | ||
980 | spin_lock_irqsave(&sl811->lock, flags); | 959 | spin_lock_irqsave(&sl811->lock, flags); |
981 | hep = urb->hcpriv; | 960 | retval = usb_hcd_check_unlink_urb(hcd, urb, status); |
982 | if (!hep) | 961 | if (retval) |
983 | goto fail; | 962 | goto fail; |
984 | 963 | ||
964 | hep = urb->hcpriv; | ||
985 | ep = hep->hcpriv; | 965 | ep = hep->hcpriv; |
986 | if (ep) { | 966 | if (ep) { |
987 | /* finish right away if this urb can't be active ... | 967 | /* finish right away if this urb can't be active ... |
@@ -1029,8 +1009,8 @@ static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
1029 | VDBG("dequeue, urb %p active %s; wait4irq\n", urb, | 1009 | VDBG("dequeue, urb %p active %s; wait4irq\n", urb, |
1030 | (sl811->active_a == ep) ? "A" : "B"); | 1010 | (sl811->active_a == ep) ? "A" : "B"); |
1031 | } else | 1011 | } else |
1032 | fail: | ||
1033 | retval = -EINVAL; | 1012 | retval = -EINVAL; |
1013 | fail: | ||
1034 | spin_unlock_irqrestore(&sl811->lock, flags); | 1014 | spin_unlock_irqrestore(&sl811->lock, flags); |
1035 | return retval; | 1015 | return retval; |
1036 | } | 1016 | } |
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 2d0e73b2009..5da63f53500 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -278,10 +278,9 @@ static int sl811_cs_probe(struct pcmcia_device *link) | |||
278 | { | 278 | { |
279 | local_info_t *local; | 279 | local_info_t *local; |
280 | 280 | ||
281 | local = kmalloc(sizeof(local_info_t), GFP_KERNEL); | 281 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); |
282 | if (!local) | 282 | if (!local) |
283 | return -ENOMEM; | 283 | return -ENOMEM; |
284 | memset(local, 0, sizeof(local_info_t)); | ||
285 | local->p_dev = link; | 284 | local->p_dev = link; |
286 | link->priv = local; | 285 | link->priv = local; |
287 | 286 | ||
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index e98df2ee990..ac283b09a63 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #include <linux/usb.h> | 51 | #include <linux/usb.h> |
52 | #include <linux/workqueue.h> | 52 | #include <linux/workqueue.h> |
53 | #include <linux/platform_device.h> | 53 | #include <linux/platform_device.h> |
54 | #include <linux/pci_ids.h> | 54 | #include <linux/mutex.h> |
55 | #include <asm/io.h> | 55 | #include <asm/io.h> |
56 | #include <asm/irq.h> | 56 | #include <asm/irq.h> |
57 | #include <asm/system.h> | 57 | #include <asm/system.h> |
@@ -83,7 +83,7 @@ static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); | |||
83 | * u132_module_lock exists to protect access to global variables | 83 | * u132_module_lock exists to protect access to global variables |
84 | * | 84 | * |
85 | */ | 85 | */ |
86 | static struct semaphore u132_module_lock; | 86 | static struct mutex u132_module_lock; |
87 | static int u132_exiting = 0; | 87 | static int u132_exiting = 0; |
88 | static int u132_instances = 0; | 88 | static int u132_instances = 0; |
89 | static struct list_head u132_static_list; | 89 | static struct list_head u132_static_list; |
@@ -183,7 +183,7 @@ struct u132_ring { | |||
183 | struct u132 { | 183 | struct u132 { |
184 | struct kref kref; | 184 | struct kref kref; |
185 | struct list_head u132_list; | 185 | struct list_head u132_list; |
186 | struct semaphore sw_lock; | 186 | struct mutex sw_lock; |
187 | struct semaphore scheduler_lock; | 187 | struct semaphore scheduler_lock; |
188 | struct u132_platform_data *board; | 188 | struct u132_platform_data *board; |
189 | struct platform_device *platform_dev; | 189 | struct platform_device *platform_dev; |
@@ -258,10 +258,10 @@ static void u132_hcd_delete(struct kref *kref) | |||
258 | struct platform_device *pdev = u132->platform_dev; | 258 | struct platform_device *pdev = u132->platform_dev; |
259 | struct usb_hcd *hcd = u132_to_hcd(u132); | 259 | struct usb_hcd *hcd = u132_to_hcd(u132); |
260 | u132->going += 1; | 260 | u132->going += 1; |
261 | down(&u132_module_lock); | 261 | mutex_lock(&u132_module_lock); |
262 | list_del_init(&u132->u132_list); | 262 | list_del_init(&u132->u132_list); |
263 | u132_instances -= 1; | 263 | u132_instances -= 1; |
264 | up(&u132_module_lock); | 264 | mutex_unlock(&u132_module_lock); |
265 | dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" | 265 | dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" |
266 | "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); | 266 | "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); |
267 | usb_put_hcd(hcd); | 267 | usb_put_hcd(hcd); |
@@ -492,20 +492,20 @@ static void u132_hcd_monitor_work(struct work_struct *work) | |||
492 | return; | 492 | return; |
493 | } else { | 493 | } else { |
494 | int retval; | 494 | int retval; |
495 | down(&u132->sw_lock); | 495 | mutex_lock(&u132->sw_lock); |
496 | retval = read_roothub_info(u132); | 496 | retval = read_roothub_info(u132); |
497 | if (retval) { | 497 | if (retval) { |
498 | struct usb_hcd *hcd = u132_to_hcd(u132); | 498 | struct usb_hcd *hcd = u132_to_hcd(u132); |
499 | u132_disable(u132); | 499 | u132_disable(u132); |
500 | u132->going = 1; | 500 | u132->going = 1; |
501 | up(&u132->sw_lock); | 501 | mutex_unlock(&u132->sw_lock); |
502 | usb_hc_died(hcd); | 502 | usb_hc_died(hcd); |
503 | ftdi_elan_gone_away(u132->platform_dev); | 503 | ftdi_elan_gone_away(u132->platform_dev); |
504 | u132_monitor_put_kref(u132); | 504 | u132_monitor_put_kref(u132); |
505 | return; | 505 | return; |
506 | } else { | 506 | } else { |
507 | u132_monitor_requeue_work(u132, 500); | 507 | u132_monitor_requeue_work(u132, 500); |
508 | up(&u132->sw_lock); | 508 | mutex_unlock(&u132->sw_lock); |
509 | return; | 509 | return; |
510 | } | 510 | } |
511 | } | 511 | } |
@@ -518,9 +518,8 @@ static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, | |||
518 | unsigned long irqs; | 518 | unsigned long irqs; |
519 | struct usb_hcd *hcd = u132_to_hcd(u132); | 519 | struct usb_hcd *hcd = u132_to_hcd(u132); |
520 | urb->error_count = 0; | 520 | urb->error_count = 0; |
521 | urb->status = status; | ||
522 | urb->hcpriv = NULL; | ||
523 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 521 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
522 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
524 | endp->queue_next += 1; | 523 | endp->queue_next += 1; |
525 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { | 524 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { |
526 | endp->active = 0; | 525 | endp->active = 0; |
@@ -542,7 +541,7 @@ static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, | |||
542 | u132_ring_queue_work(u132, ring, 0); | 541 | u132_ring_queue_work(u132, ring, 0); |
543 | up(&u132->scheduler_lock); | 542 | up(&u132->scheduler_lock); |
544 | u132_endp_put_kref(u132, endp); | 543 | u132_endp_put_kref(u132, endp); |
545 | usb_hcd_giveback_urb(hcd, urb); | 544 | usb_hcd_giveback_urb(hcd, urb, status); |
546 | return; | 545 | return; |
547 | } | 546 | } |
548 | 547 | ||
@@ -558,9 +557,8 @@ static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, | |||
558 | unsigned long irqs; | 557 | unsigned long irqs; |
559 | struct usb_hcd *hcd = u132_to_hcd(u132); | 558 | struct usb_hcd *hcd = u132_to_hcd(u132); |
560 | urb->error_count = 0; | 559 | urb->error_count = 0; |
561 | urb->status = status; | ||
562 | urb->hcpriv = NULL; | ||
563 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 560 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
561 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
564 | endp->queue_next += 1; | 562 | endp->queue_next += 1; |
565 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { | 563 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { |
566 | endp->active = 0; | 564 | endp->active = 0; |
@@ -575,7 +573,7 @@ static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, | |||
575 | endp->active = 0; | 573 | endp->active = 0; |
576 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 574 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
577 | kfree(urbq); | 575 | kfree(urbq); |
578 | } usb_hcd_giveback_urb(hcd, urb); | 576 | } usb_hcd_giveback_urb(hcd, urb, status); |
579 | return; | 577 | return; |
580 | } | 578 | } |
581 | 579 | ||
@@ -645,12 +643,12 @@ static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, | |||
645 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 643 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
646 | return; | 644 | return; |
647 | } else if (u132->going > 0) { | 645 | } else if (u132->going > 0) { |
648 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 646 | dev_err(&u132->platform_dev->dev, "device is being removed " |
649 | "%p status=%d\n", urb, urb->status); | 647 | "urb=%p\n", urb); |
650 | up(&u132->scheduler_lock); | 648 | up(&u132->scheduler_lock); |
651 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 649 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
652 | return; | 650 | return; |
653 | } else if (urb->status == -EINPROGRESS) { | 651 | } else if (!urb->unlinked) { |
654 | struct u132_ring *ring = endp->ring; | 652 | struct u132_ring *ring = endp->ring; |
655 | u8 *u = urb->transfer_buffer + urb->actual_length; | 653 | u8 *u = urb->transfer_buffer + urb->actual_length; |
656 | u8 *b = buf; | 654 | u8 *b = buf; |
@@ -716,10 +714,10 @@ static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, | |||
716 | return; | 714 | return; |
717 | } | 715 | } |
718 | } else { | 716 | } else { |
719 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 717 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
720 | "s=%d\n", urb, urb->status); | 718 | "unlinked=%d\n", urb, urb->unlinked); |
721 | up(&u132->scheduler_lock); | 719 | up(&u132->scheduler_lock); |
722 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 720 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
723 | return; | 721 | return; |
724 | } | 722 | } |
725 | } | 723 | } |
@@ -744,12 +742,12 @@ static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, | |||
744 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 742 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
745 | return; | 743 | return; |
746 | } else if (u132->going > 0) { | 744 | } else if (u132->going > 0) { |
747 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 745 | dev_err(&u132->platform_dev->dev, "device is being removed " |
748 | "%p status=%d\n", urb, urb->status); | 746 | "urb=%p\n", urb); |
749 | up(&u132->scheduler_lock); | 747 | up(&u132->scheduler_lock); |
750 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 748 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
751 | return; | 749 | return; |
752 | } else if (urb->status == -EINPROGRESS) { | 750 | } else if (!urb->unlinked) { |
753 | struct u132_ring *ring = endp->ring; | 751 | struct u132_ring *ring = endp->ring; |
754 | urb->actual_length += len; | 752 | urb->actual_length += len; |
755 | endp->toggle_bits = toggle_bits; | 753 | endp->toggle_bits = toggle_bits; |
@@ -768,10 +766,10 @@ static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, | |||
768 | return; | 766 | return; |
769 | } | 767 | } |
770 | } else { | 768 | } else { |
771 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 769 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
772 | "s=%d\n", urb, urb->status); | 770 | "unlinked=%d\n", urb, urb->unlinked); |
773 | up(&u132->scheduler_lock); | 771 | up(&u132->scheduler_lock); |
774 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 772 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
775 | return; | 773 | return; |
776 | } | 774 | } |
777 | } | 775 | } |
@@ -797,12 +795,12 @@ static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, | |||
797 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 795 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
798 | return; | 796 | return; |
799 | } else if (u132->going > 0) { | 797 | } else if (u132->going > 0) { |
800 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 798 | dev_err(&u132->platform_dev->dev, "device is being removed " |
801 | "%p status=%d\n", urb, urb->status); | 799 | "urb=%p\n", urb); |
802 | up(&u132->scheduler_lock); | 800 | up(&u132->scheduler_lock); |
803 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 801 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
804 | return; | 802 | return; |
805 | } else if (urb->status == -EINPROGRESS) { | 803 | } else if (!urb->unlinked) { |
806 | struct u132_ring *ring = endp->ring; | 804 | struct u132_ring *ring = endp->ring; |
807 | u8 *u = urb->transfer_buffer + urb->actual_length; | 805 | u8 *u = urb->transfer_buffer + urb->actual_length; |
808 | u8 *b = buf; | 806 | u8 *b = buf; |
@@ -871,10 +869,10 @@ static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, | |||
871 | return; | 869 | return; |
872 | } | 870 | } |
873 | } else { | 871 | } else { |
874 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 872 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
875 | "s=%d\n", urb, urb->status); | 873 | "unlinked=%d\n", urb, urb->unlinked); |
876 | up(&u132->scheduler_lock); | 874 | up(&u132->scheduler_lock); |
877 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 875 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
878 | return; | 876 | return; |
879 | } | 877 | } |
880 | } | 878 | } |
@@ -898,20 +896,20 @@ static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, | |||
898 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 896 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
899 | return; | 897 | return; |
900 | } else if (u132->going > 0) { | 898 | } else if (u132->going > 0) { |
901 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 899 | dev_err(&u132->platform_dev->dev, "device is being removed " |
902 | "%p status=%d\n", urb, urb->status); | 900 | "urb=%p\n", urb); |
903 | up(&u132->scheduler_lock); | 901 | up(&u132->scheduler_lock); |
904 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 902 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
905 | return; | 903 | return; |
906 | } else if (urb->status == -EINPROGRESS) { | 904 | } else if (!urb->unlinked) { |
907 | up(&u132->scheduler_lock); | 905 | up(&u132->scheduler_lock); |
908 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 906 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
909 | return; | 907 | return; |
910 | } else { | 908 | } else { |
911 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 909 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
912 | "s=%d\n", urb, urb->status); | 910 | "unlinked=%d\n", urb, urb->unlinked); |
913 | up(&u132->scheduler_lock); | 911 | up(&u132->scheduler_lock); |
914 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 912 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
915 | return; | 913 | return; |
916 | } | 914 | } |
917 | } | 915 | } |
@@ -936,12 +934,12 @@ static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, | |||
936 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 934 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
937 | return; | 935 | return; |
938 | } else if (u132->going > 0) { | 936 | } else if (u132->going > 0) { |
939 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 937 | dev_err(&u132->platform_dev->dev, "device is being removed " |
940 | "%p status=%d\n", urb, urb->status); | 938 | "urb=%p\n", urb); |
941 | up(&u132->scheduler_lock); | 939 | up(&u132->scheduler_lock); |
942 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 940 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
943 | return; | 941 | return; |
944 | } else if (urb->status == -EINPROGRESS) { | 942 | } else if (!urb->unlinked) { |
945 | struct u132_ring *ring = endp->ring; | 943 | struct u132_ring *ring = endp->ring; |
946 | u8 *u = urb->transfer_buffer; | 944 | u8 *u = urb->transfer_buffer; |
947 | u8 *b = buf; | 945 | u8 *b = buf; |
@@ -980,10 +978,10 @@ static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, | |||
980 | return; | 978 | return; |
981 | } | 979 | } |
982 | } else { | 980 | } else { |
983 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 981 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
984 | "s=%d\n", urb, urb->status); | 982 | "unlinked=%d\n", urb, urb->unlinked); |
985 | up(&u132->scheduler_lock); | 983 | up(&u132->scheduler_lock); |
986 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 984 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
987 | return; | 985 | return; |
988 | } | 986 | } |
989 | } | 987 | } |
@@ -1007,20 +1005,20 @@ static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, | |||
1007 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1005 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1008 | return; | 1006 | return; |
1009 | } else if (u132->going > 0) { | 1007 | } else if (u132->going > 0) { |
1010 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1008 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1011 | "%p status=%d\n", urb, urb->status); | 1009 | "urb=%p\n", urb); |
1012 | up(&u132->scheduler_lock); | 1010 | up(&u132->scheduler_lock); |
1013 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1011 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1014 | return; | 1012 | return; |
1015 | } else if (urb->status == -EINPROGRESS) { | 1013 | } else if (!urb->unlinked) { |
1016 | up(&u132->scheduler_lock); | 1014 | up(&u132->scheduler_lock); |
1017 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1015 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1018 | return; | 1016 | return; |
1019 | } else { | 1017 | } else { |
1020 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1018 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1021 | "s=%d\n", urb, urb->status); | 1019 | "unlinked=%d\n", urb, urb->unlinked); |
1022 | up(&u132->scheduler_lock); | 1020 | up(&u132->scheduler_lock); |
1023 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1021 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1024 | return; | 1022 | return; |
1025 | } | 1023 | } |
1026 | } | 1024 | } |
@@ -1045,12 +1043,12 @@ static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, | |||
1045 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1043 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1046 | return; | 1044 | return; |
1047 | } else if (u132->going > 0) { | 1045 | } else if (u132->going > 0) { |
1048 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1046 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1049 | "%p status=%d\n", urb, urb->status); | 1047 | "urb=%p\n", urb); |
1050 | up(&u132->scheduler_lock); | 1048 | up(&u132->scheduler_lock); |
1051 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1049 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1052 | return; | 1050 | return; |
1053 | } else if (urb->status == -EINPROGRESS) { | 1051 | } else if (!urb->unlinked) { |
1054 | if (usb_pipein(urb->pipe)) { | 1052 | if (usb_pipein(urb->pipe)) { |
1055 | int retval; | 1053 | int retval; |
1056 | struct u132_ring *ring = endp->ring; | 1054 | struct u132_ring *ring = endp->ring; |
@@ -1077,10 +1075,10 @@ static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, | |||
1077 | return; | 1075 | return; |
1078 | } | 1076 | } |
1079 | } else { | 1077 | } else { |
1080 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1078 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1081 | "s=%d\n", urb, urb->status); | 1079 | "unlinked=%d\n", urb, urb->unlinked); |
1082 | up(&u132->scheduler_lock); | 1080 | up(&u132->scheduler_lock); |
1083 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1081 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1084 | return; | 1082 | return; |
1085 | } | 1083 | } |
1086 | } | 1084 | } |
@@ -1106,22 +1104,22 @@ static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, | |||
1106 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1104 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1107 | return; | 1105 | return; |
1108 | } else if (u132->going > 0) { | 1106 | } else if (u132->going > 0) { |
1109 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1107 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1110 | "%p status=%d\n", urb, urb->status); | 1108 | "urb=%p\n", urb); |
1111 | up(&u132->scheduler_lock); | 1109 | up(&u132->scheduler_lock); |
1112 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1110 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1113 | return; | 1111 | return; |
1114 | } else if (urb->status == -EINPROGRESS) { | 1112 | } else if (!urb->unlinked) { |
1115 | u132->addr[0].address = 0; | 1113 | u132->addr[0].address = 0; |
1116 | endp->usb_addr = udev->usb_addr; | 1114 | endp->usb_addr = udev->usb_addr; |
1117 | up(&u132->scheduler_lock); | 1115 | up(&u132->scheduler_lock); |
1118 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1116 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1119 | return; | 1117 | return; |
1120 | } else { | 1118 | } else { |
1121 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1119 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1122 | "s=%d\n", urb, urb->status); | 1120 | "unlinked=%d\n", urb, urb->unlinked); |
1123 | up(&u132->scheduler_lock); | 1121 | up(&u132->scheduler_lock); |
1124 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1122 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1125 | return; | 1123 | return; |
1126 | } | 1124 | } |
1127 | } | 1125 | } |
@@ -1145,12 +1143,12 @@ static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, | |||
1145 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1143 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1146 | return; | 1144 | return; |
1147 | } else if (u132->going > 0) { | 1145 | } else if (u132->going > 0) { |
1148 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1146 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1149 | "%p status=%d\n", urb, urb->status); | 1147 | "urb=%p\n", urb); |
1150 | up(&u132->scheduler_lock); | 1148 | up(&u132->scheduler_lock); |
1151 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1149 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1152 | return; | 1150 | return; |
1153 | } else if (urb->status == -EINPROGRESS) { | 1151 | } else if (!urb->unlinked) { |
1154 | int retval; | 1152 | int retval; |
1155 | struct u132_ring *ring = endp->ring; | 1153 | struct u132_ring *ring = endp->ring; |
1156 | up(&u132->scheduler_lock); | 1154 | up(&u132->scheduler_lock); |
@@ -1162,10 +1160,10 @@ static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, | |||
1162 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1160 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1163 | return; | 1161 | return; |
1164 | } else { | 1162 | } else { |
1165 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1163 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1166 | "s=%d\n", urb, urb->status); | 1164 | "unlinked=%d\n", urb, urb->unlinked); |
1167 | up(&u132->scheduler_lock); | 1165 | up(&u132->scheduler_lock); |
1168 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1166 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1169 | return; | 1167 | return; |
1170 | } | 1168 | } |
1171 | } | 1169 | } |
@@ -1189,20 +1187,20 @@ static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, | |||
1189 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1187 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1190 | return; | 1188 | return; |
1191 | } else if (u132->going > 0) { | 1189 | } else if (u132->going > 0) { |
1192 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1190 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1193 | "%p status=%d\n", urb, urb->status); | 1191 | "urb=%p\n", urb); |
1194 | up(&u132->scheduler_lock); | 1192 | up(&u132->scheduler_lock); |
1195 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1193 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1196 | return; | 1194 | return; |
1197 | } else if (urb->status == -EINPROGRESS) { | 1195 | } else if (!urb->unlinked) { |
1198 | up(&u132->scheduler_lock); | 1196 | up(&u132->scheduler_lock); |
1199 | u132_hcd_giveback_urb(u132, endp, urb, 0); | 1197 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1200 | return; | 1198 | return; |
1201 | } else { | 1199 | } else { |
1202 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1200 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1203 | "s=%d\n", urb, urb->status); | 1201 | "unlinked=%d\n", urb, urb->unlinked); |
1204 | up(&u132->scheduler_lock); | 1202 | up(&u132->scheduler_lock); |
1205 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1203 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1206 | return; | 1204 | return; |
1207 | } | 1205 | } |
1208 | } | 1206 | } |
@@ -1227,12 +1225,12 @@ static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, | |||
1227 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1225 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1228 | return; | 1226 | return; |
1229 | } else if (u132->going > 0) { | 1227 | } else if (u132->going > 0) { |
1230 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1228 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1231 | "%p status=%d\n", urb, urb->status); | 1229 | "urb=%p\n", urb); |
1232 | up(&u132->scheduler_lock); | 1230 | up(&u132->scheduler_lock); |
1233 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1231 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1234 | return; | 1232 | return; |
1235 | } else if (urb->status == -EINPROGRESS) { | 1233 | } else if (!urb->unlinked) { |
1236 | int retval; | 1234 | int retval; |
1237 | struct u132_ring *ring = endp->ring; | 1235 | struct u132_ring *ring = endp->ring; |
1238 | u8 *u = urb->transfer_buffer; | 1236 | u8 *u = urb->transfer_buffer; |
@@ -1251,10 +1249,10 @@ static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, | |||
1251 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1249 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1252 | return; | 1250 | return; |
1253 | } else { | 1251 | } else { |
1254 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1252 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1255 | "s=%d\n", urb, urb->status); | 1253 | "unlinked=%d\n", urb, urb->unlinked); |
1256 | up(&u132->scheduler_lock); | 1254 | up(&u132->scheduler_lock); |
1257 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1255 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1258 | return; | 1256 | return; |
1259 | } | 1257 | } |
1260 | } | 1258 | } |
@@ -1279,12 +1277,12 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, | |||
1279 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | 1277 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); |
1280 | return; | 1278 | return; |
1281 | } else if (u132->going > 0) { | 1279 | } else if (u132->going > 0) { |
1282 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 1280 | dev_err(&u132->platform_dev->dev, "device is being removed " |
1283 | "%p status=%d\n", urb, urb->status); | 1281 | "urb=%p\n", urb); |
1284 | up(&u132->scheduler_lock); | 1282 | up(&u132->scheduler_lock); |
1285 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | 1283 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); |
1286 | return; | 1284 | return; |
1287 | } else if (urb->status == -EINPROGRESS) { | 1285 | } else if (!urb->unlinked) { |
1288 | int retval; | 1286 | int retval; |
1289 | struct u132_ring *ring = endp->ring; | 1287 | struct u132_ring *ring = endp->ring; |
1290 | up(&u132->scheduler_lock); | 1288 | up(&u132->scheduler_lock); |
@@ -1296,10 +1294,10 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, | |||
1296 | u132_hcd_giveback_urb(u132, endp, urb, retval); | 1294 | u132_hcd_giveback_urb(u132, endp, urb, retval); |
1297 | return; | 1295 | return; |
1298 | } else { | 1296 | } else { |
1299 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | 1297 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " |
1300 | "s=%d\n", urb, urb->status); | 1298 | "unlinked=%d\n", urb, urb->unlinked); |
1301 | up(&u132->scheduler_lock); | 1299 | up(&u132->scheduler_lock); |
1302 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | 1300 | u132_hcd_giveback_urb(u132, endp, urb, 0); |
1303 | return; | 1301 | return; |
1304 | } | 1302 | } |
1305 | } | 1303 | } |
@@ -1519,12 +1517,15 @@ static void u132_hcd_endp_work_scheduler(struct work_struct *work) | |||
1519 | } | 1517 | } |
1520 | } | 1518 | } |
1521 | } | 1519 | } |
1520 | #ifdef CONFIG_PM | ||
1522 | 1521 | ||
1523 | static void port_power(struct u132 *u132, int pn, int is_on) | 1522 | static void port_power(struct u132 *u132, int pn, int is_on) |
1524 | { | 1523 | { |
1525 | u132->port[pn].power = is_on; | 1524 | u132->port[pn].power = is_on; |
1526 | } | 1525 | } |
1527 | 1526 | ||
1527 | #endif | ||
1528 | |||
1528 | static void u132_power(struct u132 *u132, int is_on) | 1529 | static void u132_power(struct u132 *u132, int is_on) |
1529 | { | 1530 | { |
1530 | struct usb_hcd *hcd = u132_to_hcd(u132) | 1531 | struct usb_hcd *hcd = u132_to_hcd(u132) |
@@ -1801,10 +1802,10 @@ static void u132_hcd_stop(struct usb_hcd *hcd) | |||
1801 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" | 1802 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" |
1802 | "ed\n", hcd); | 1803 | "ed\n", hcd); |
1803 | } else { | 1804 | } else { |
1804 | down(&u132->sw_lock); | 1805 | mutex_lock(&u132->sw_lock); |
1805 | msleep(100); | 1806 | msleep(100); |
1806 | u132_power(u132, 0); | 1807 | u132_power(u132, 0); |
1807 | up(&u132->sw_lock); | 1808 | mutex_unlock(&u132->sw_lock); |
1808 | } | 1809 | } |
1809 | } | 1810 | } |
1810 | 1811 | ||
@@ -1826,7 +1827,7 @@ static int u132_hcd_start(struct usb_hcd *hcd) | |||
1826 | (pdev->dev.platform_data))->vendor; | 1827 | (pdev->dev.platform_data))->vendor; |
1827 | u16 device = ((struct u132_platform_data *) | 1828 | u16 device = ((struct u132_platform_data *) |
1828 | (pdev->dev.platform_data))->device; | 1829 | (pdev->dev.platform_data))->device; |
1829 | down(&u132->sw_lock); | 1830 | mutex_lock(&u132->sw_lock); |
1830 | msleep(10); | 1831 | msleep(10); |
1831 | if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { | 1832 | if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { |
1832 | u132->flags = OHCI_QUIRK_AMD756; | 1833 | u132->flags = OHCI_QUIRK_AMD756; |
@@ -1841,7 +1842,7 @@ static int u132_hcd_start(struct usb_hcd *hcd) | |||
1841 | u132->going = 1; | 1842 | u132->going = 1; |
1842 | } | 1843 | } |
1843 | msleep(100); | 1844 | msleep(100); |
1844 | up(&u132->sw_lock); | 1845 | mutex_unlock(&u132->sw_lock); |
1845 | return retval; | 1846 | return retval; |
1846 | } else { | 1847 | } else { |
1847 | dev_err(&u132->platform_dev->dev, "platform_device missing\n"); | 1848 | dev_err(&u132->platform_dev->dev, "platform_device missing\n"); |
@@ -1861,32 +1862,44 @@ static int u132_hcd_reset(struct usb_hcd *hcd) | |||
1861 | return -ESHUTDOWN; | 1862 | return -ESHUTDOWN; |
1862 | } else { | 1863 | } else { |
1863 | int retval; | 1864 | int retval; |
1864 | down(&u132->sw_lock); | 1865 | mutex_lock(&u132->sw_lock); |
1865 | retval = u132_init(u132); | 1866 | retval = u132_init(u132); |
1866 | if (retval) { | 1867 | if (retval) { |
1867 | u132_disable(u132); | 1868 | u132_disable(u132); |
1868 | u132->going = 1; | 1869 | u132->going = 1; |
1869 | } | 1870 | } |
1870 | up(&u132->sw_lock); | 1871 | mutex_unlock(&u132->sw_lock); |
1871 | return retval; | 1872 | return retval; |
1872 | } | 1873 | } |
1873 | } | 1874 | } |
1874 | 1875 | ||
1875 | static int create_endpoint_and_queue_int(struct u132 *u132, | 1876 | static int create_endpoint_and_queue_int(struct u132 *u132, |
1876 | struct u132_udev *udev, struct usb_host_endpoint *hep, struct urb *urb, | 1877 | struct u132_udev *udev, struct urb *urb, |
1877 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, | 1878 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, |
1878 | gfp_t mem_flags) | 1879 | gfp_t mem_flags) |
1879 | { | 1880 | { |
1880 | struct u132_ring *ring; | 1881 | struct u132_ring *ring; |
1881 | unsigned long irqs; | 1882 | unsigned long irqs; |
1882 | u8 endp_number = ++u132->num_endpoints; | 1883 | int rc; |
1883 | struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] = | 1884 | u8 endp_number; |
1884 | kmalloc(sizeof(struct u132_endp), mem_flags); | 1885 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); |
1886 | |||
1885 | if (!endp) { | 1887 | if (!endp) { |
1886 | return -ENOMEM; | 1888 | return -ENOMEM; |
1887 | } | 1889 | } |
1890 | |||
1891 | spin_lock_init(&endp->queue_lock.slock); | ||
1892 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
1893 | rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); | ||
1894 | if (rc) { | ||
1895 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
1896 | kfree(endp); | ||
1897 | return rc; | ||
1898 | } | ||
1899 | |||
1900 | endp_number = ++u132->num_endpoints; | ||
1901 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; | ||
1888 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); | 1902 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); |
1889 | spin_lock_init(&endp->queue_lock.slock); | ||
1890 | INIT_LIST_HEAD(&endp->urb_more); | 1903 | INIT_LIST_HEAD(&endp->urb_more); |
1891 | ring = endp->ring = &u132->ring[0]; | 1904 | ring = endp->ring = &u132->ring[0]; |
1892 | if (ring->curr_endp) { | 1905 | if (ring->curr_endp) { |
@@ -1902,7 +1915,7 @@ static int create_endpoint_and_queue_int(struct u132 *u132, | |||
1902 | endp->delayed = 0; | 1915 | endp->delayed = 0; |
1903 | endp->endp_number = endp_number; | 1916 | endp->endp_number = endp_number; |
1904 | endp->u132 = u132; | 1917 | endp->u132 = u132; |
1905 | endp->hep = hep; | 1918 | endp->hep = urb->ep; |
1906 | endp->pipetype = usb_pipetype(urb->pipe); | 1919 | endp->pipetype = usb_pipetype(urb->pipe); |
1907 | u132_endp_init_kref(u132, endp); | 1920 | u132_endp_init_kref(u132, endp); |
1908 | if (usb_pipein(urb->pipe)) { | 1921 | if (usb_pipein(urb->pipe)) { |
@@ -1921,7 +1934,6 @@ static int create_endpoint_and_queue_int(struct u132 *u132, | |||
1921 | u132_udev_get_kref(u132, udev); | 1934 | u132_udev_get_kref(u132, udev); |
1922 | } | 1935 | } |
1923 | urb->hcpriv = u132; | 1936 | urb->hcpriv = u132; |
1924 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
1925 | endp->delayed = 1; | 1937 | endp->delayed = 1; |
1926 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); | 1938 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); |
1927 | endp->udev_number = address; | 1939 | endp->udev_number = address; |
@@ -1936,8 +1948,8 @@ static int create_endpoint_and_queue_int(struct u132 *u132, | |||
1936 | return 0; | 1948 | return 0; |
1937 | } | 1949 | } |
1938 | 1950 | ||
1939 | static int queue_int_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | 1951 | static int queue_int_on_old_endpoint(struct u132 *u132, |
1940 | struct usb_host_endpoint *hep, struct urb *urb, | 1952 | struct u132_udev *udev, struct urb *urb, |
1941 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | 1953 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, |
1942 | u8 usb_endp, u8 address) | 1954 | u8 usb_endp, u8 address) |
1943 | { | 1955 | { |
@@ -1961,21 +1973,33 @@ static int queue_int_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | |||
1961 | } | 1973 | } |
1962 | 1974 | ||
1963 | static int create_endpoint_and_queue_bulk(struct u132 *u132, | 1975 | static int create_endpoint_and_queue_bulk(struct u132 *u132, |
1964 | struct u132_udev *udev, struct usb_host_endpoint *hep, struct urb *urb, | 1976 | struct u132_udev *udev, struct urb *urb, |
1965 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, | 1977 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, |
1966 | gfp_t mem_flags) | 1978 | gfp_t mem_flags) |
1967 | { | 1979 | { |
1968 | int ring_number; | 1980 | int ring_number; |
1969 | struct u132_ring *ring; | 1981 | struct u132_ring *ring; |
1970 | unsigned long irqs; | 1982 | unsigned long irqs; |
1971 | u8 endp_number = ++u132->num_endpoints; | 1983 | int rc; |
1972 | struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] = | 1984 | u8 endp_number; |
1973 | kmalloc(sizeof(struct u132_endp), mem_flags); | 1985 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); |
1986 | |||
1974 | if (!endp) { | 1987 | if (!endp) { |
1975 | return -ENOMEM; | 1988 | return -ENOMEM; |
1976 | } | 1989 | } |
1990 | |||
1991 | spin_lock_init(&endp->queue_lock.slock); | ||
1992 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
1993 | rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); | ||
1994 | if (rc) { | ||
1995 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
1996 | kfree(endp); | ||
1997 | return rc; | ||
1998 | } | ||
1999 | |||
2000 | endp_number = ++u132->num_endpoints; | ||
2001 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; | ||
1977 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); | 2002 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); |
1978 | spin_lock_init(&endp->queue_lock.slock); | ||
1979 | INIT_LIST_HEAD(&endp->urb_more); | 2003 | INIT_LIST_HEAD(&endp->urb_more); |
1980 | endp->dequeueing = 0; | 2004 | endp->dequeueing = 0; |
1981 | endp->edset_flush = 0; | 2005 | endp->edset_flush = 0; |
@@ -1983,7 +2007,7 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132, | |||
1983 | endp->delayed = 0; | 2007 | endp->delayed = 0; |
1984 | endp->endp_number = endp_number; | 2008 | endp->endp_number = endp_number; |
1985 | endp->u132 = u132; | 2009 | endp->u132 = u132; |
1986 | endp->hep = hep; | 2010 | endp->hep = urb->ep; |
1987 | endp->pipetype = usb_pipetype(urb->pipe); | 2011 | endp->pipetype = usb_pipetype(urb->pipe); |
1988 | u132_endp_init_kref(u132, endp); | 2012 | u132_endp_init_kref(u132, endp); |
1989 | if (usb_pipein(urb->pipe)) { | 2013 | if (usb_pipein(urb->pipe)) { |
@@ -2012,7 +2036,6 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132, | |||
2012 | } | 2036 | } |
2013 | ring->length += 1; | 2037 | ring->length += 1; |
2014 | urb->hcpriv = u132; | 2038 | urb->hcpriv = u132; |
2015 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
2016 | endp->udev_number = address; | 2039 | endp->udev_number = address; |
2017 | endp->usb_addr = usb_addr; | 2040 | endp->usb_addr = usb_addr; |
2018 | endp->usb_endp = usb_endp; | 2041 | endp->usb_endp = usb_endp; |
@@ -2026,7 +2049,7 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132, | |||
2026 | } | 2049 | } |
2027 | 2050 | ||
2028 | static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | 2051 | static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, |
2029 | struct usb_host_endpoint *hep, struct urb *urb, | 2052 | struct urb *urb, |
2030 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | 2053 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, |
2031 | u8 usb_endp, u8 address) | 2054 | u8 usb_endp, u8 address) |
2032 | { | 2055 | { |
@@ -2048,19 +2071,32 @@ static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | |||
2048 | } | 2071 | } |
2049 | 2072 | ||
2050 | static int create_endpoint_and_queue_control(struct u132 *u132, | 2073 | static int create_endpoint_and_queue_control(struct u132 *u132, |
2051 | struct usb_host_endpoint *hep, struct urb *urb, | 2074 | struct urb *urb, |
2052 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, | 2075 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, |
2053 | gfp_t mem_flags) | 2076 | gfp_t mem_flags) |
2054 | { | 2077 | { |
2055 | struct u132_ring *ring; | 2078 | struct u132_ring *ring; |
2056 | u8 endp_number = ++u132->num_endpoints; | 2079 | unsigned long irqs; |
2057 | struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] = | 2080 | int rc; |
2058 | kmalloc(sizeof(struct u132_endp), mem_flags); | 2081 | u8 endp_number; |
2082 | struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); | ||
2083 | |||
2059 | if (!endp) { | 2084 | if (!endp) { |
2060 | return -ENOMEM; | 2085 | return -ENOMEM; |
2061 | } | 2086 | } |
2087 | |||
2088 | spin_lock_init(&endp->queue_lock.slock); | ||
2089 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
2090 | rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); | ||
2091 | if (rc) { | ||
2092 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
2093 | kfree(endp); | ||
2094 | return rc; | ||
2095 | } | ||
2096 | |||
2097 | endp_number = ++u132->num_endpoints; | ||
2098 | urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; | ||
2062 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); | 2099 | INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); |
2063 | spin_lock_init(&endp->queue_lock.slock); | ||
2064 | INIT_LIST_HEAD(&endp->urb_more); | 2100 | INIT_LIST_HEAD(&endp->urb_more); |
2065 | ring = endp->ring = &u132->ring[0]; | 2101 | ring = endp->ring = &u132->ring[0]; |
2066 | if (ring->curr_endp) { | 2102 | if (ring->curr_endp) { |
@@ -2076,11 +2112,10 @@ static int create_endpoint_and_queue_control(struct u132 *u132, | |||
2076 | endp->delayed = 0; | 2112 | endp->delayed = 0; |
2077 | endp->endp_number = endp_number; | 2113 | endp->endp_number = endp_number; |
2078 | endp->u132 = u132; | 2114 | endp->u132 = u132; |
2079 | endp->hep = hep; | 2115 | endp->hep = urb->ep; |
2080 | u132_endp_init_kref(u132, endp); | 2116 | u132_endp_init_kref(u132, endp); |
2081 | u132_endp_get_kref(u132, endp); | 2117 | u132_endp_get_kref(u132, endp); |
2082 | if (usb_addr == 0) { | 2118 | if (usb_addr == 0) { |
2083 | unsigned long irqs; | ||
2084 | u8 address = u132->addr[usb_addr].address; | 2119 | u8 address = u132->addr[usb_addr].address; |
2085 | struct u132_udev *udev = &u132->udev[address]; | 2120 | struct u132_udev *udev = &u132->udev[address]; |
2086 | endp->udev_number = address; | 2121 | endp->udev_number = address; |
@@ -2094,7 +2129,6 @@ static int create_endpoint_and_queue_control(struct u132 *u132, | |||
2094 | udev->endp_number_in[usb_endp] = endp_number; | 2129 | udev->endp_number_in[usb_endp] = endp_number; |
2095 | udev->endp_number_out[usb_endp] = endp_number; | 2130 | udev->endp_number_out[usb_endp] = endp_number; |
2096 | urb->hcpriv = u132; | 2131 | urb->hcpriv = u132; |
2097 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
2098 | endp->queue_size = 1; | 2132 | endp->queue_size = 1; |
2099 | endp->queue_last = 0; | 2133 | endp->queue_last = 0; |
2100 | endp->queue_next = 0; | 2134 | endp->queue_next = 0; |
@@ -2103,7 +2137,6 @@ static int create_endpoint_and_queue_control(struct u132 *u132, | |||
2103 | u132_endp_queue_work(u132, endp, 0); | 2137 | u132_endp_queue_work(u132, endp, 0); |
2104 | return 0; | 2138 | return 0; |
2105 | } else { /*(usb_addr > 0) */ | 2139 | } else { /*(usb_addr > 0) */ |
2106 | unsigned long irqs; | ||
2107 | u8 address = u132->addr[usb_addr].address; | 2140 | u8 address = u132->addr[usb_addr].address; |
2108 | struct u132_udev *udev = &u132->udev[address]; | 2141 | struct u132_udev *udev = &u132->udev[address]; |
2109 | endp->udev_number = address; | 2142 | endp->udev_number = address; |
@@ -2117,7 +2150,6 @@ static int create_endpoint_and_queue_control(struct u132 *u132, | |||
2117 | udev->endp_number_in[usb_endp] = endp_number; | 2150 | udev->endp_number_in[usb_endp] = endp_number; |
2118 | udev->endp_number_out[usb_endp] = endp_number; | 2151 | udev->endp_number_out[usb_endp] = endp_number; |
2119 | urb->hcpriv = u132; | 2152 | urb->hcpriv = u132; |
2120 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
2121 | endp->queue_size = 1; | 2153 | endp->queue_size = 1; |
2122 | endp->queue_last = 0; | 2154 | endp->queue_last = 0; |
2123 | endp->queue_next = 0; | 2155 | endp->queue_next = 0; |
@@ -2129,7 +2161,7 @@ static int create_endpoint_and_queue_control(struct u132 *u132, | |||
2129 | } | 2161 | } |
2130 | 2162 | ||
2131 | static int queue_control_on_old_endpoint(struct u132 *u132, | 2163 | static int queue_control_on_old_endpoint(struct u132 *u132, |
2132 | struct usb_host_endpoint *hep, struct urb *urb, | 2164 | struct urb *urb, |
2133 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | 2165 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, |
2134 | u8 usb_endp) | 2166 | u8 usb_endp) |
2135 | { | 2167 | { |
@@ -2229,8 +2261,8 @@ static int queue_control_on_old_endpoint(struct u132 *u132, | |||
2229 | } | 2261 | } |
2230 | } | 2262 | } |
2231 | 2263 | ||
2232 | static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | 2264 | static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, |
2233 | struct urb *urb, gfp_t mem_flags) | 2265 | gfp_t mem_flags) |
2234 | { | 2266 | { |
2235 | struct u132 *u132 = hcd_to_u132(hcd); | 2267 | struct u132 *u132 = hcd_to_u132(hcd); |
2236 | if (irqs_disabled()) { | 2268 | if (irqs_disabled()) { |
@@ -2245,8 +2277,8 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2245 | , u132->going); | 2277 | , u132->going); |
2246 | return -ENODEV; | 2278 | return -ENODEV; |
2247 | } else if (u132->going > 0) { | 2279 | } else if (u132->going > 0) { |
2248 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | 2280 | dev_err(&u132->platform_dev->dev, "device is being removed " |
2249 | "%p status=%d\n", urb, urb->status); | 2281 | "urb=%p\n", urb); |
2250 | return -ESHUTDOWN; | 2282 | return -ESHUTDOWN; |
2251 | } else { | 2283 | } else { |
2252 | u8 usb_addr = usb_pipedevice(urb->pipe); | 2284 | u8 usb_addr = usb_pipedevice(urb->pipe); |
@@ -2255,16 +2287,24 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2255 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { | 2287 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { |
2256 | u8 address = u132->addr[usb_addr].address; | 2288 | u8 address = u132->addr[usb_addr].address; |
2257 | struct u132_udev *udev = &u132->udev[address]; | 2289 | struct u132_udev *udev = &u132->udev[address]; |
2258 | struct u132_endp *endp = hep->hcpriv; | 2290 | struct u132_endp *endp = urb->ep->hcpriv; |
2259 | urb->actual_length = 0; | 2291 | urb->actual_length = 0; |
2260 | if (endp) { | 2292 | if (endp) { |
2261 | unsigned long irqs; | 2293 | unsigned long irqs; |
2262 | int retval; | 2294 | int retval; |
2263 | spin_lock_irqsave(&endp->queue_lock.slock, | 2295 | spin_lock_irqsave(&endp->queue_lock.slock, |
2264 | irqs); | 2296 | irqs); |
2265 | retval = queue_int_on_old_endpoint(u132, udev, | 2297 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2266 | hep, urb, usb_dev, endp, usb_addr, | 2298 | if (retval == 0) { |
2267 | usb_endp, address); | 2299 | retval = queue_int_on_old_endpoint( |
2300 | u132, udev, urb, | ||
2301 | usb_dev, endp, | ||
2302 | usb_addr, usb_endp, | ||
2303 | address); | ||
2304 | if (retval) | ||
2305 | usb_hcd_unlink_urb_from_ep( | ||
2306 | hcd, urb); | ||
2307 | } | ||
2268 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2308 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2269 | irqs); | 2309 | irqs); |
2270 | if (retval) { | 2310 | if (retval) { |
@@ -2279,8 +2319,8 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2279 | return -EINVAL; | 2319 | return -EINVAL; |
2280 | } else { /*(endp == NULL) */ | 2320 | } else { /*(endp == NULL) */ |
2281 | return create_endpoint_and_queue_int(u132, udev, | 2321 | return create_endpoint_and_queue_int(u132, udev, |
2282 | hep, urb, usb_dev, usb_addr, usb_endp, | 2322 | urb, usb_dev, usb_addr, |
2283 | address, mem_flags); | 2323 | usb_endp, address, mem_flags); |
2284 | } | 2324 | } |
2285 | } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { | 2325 | } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { |
2286 | dev_err(&u132->platform_dev->dev, "the hardware does no" | 2326 | dev_err(&u132->platform_dev->dev, "the hardware does no" |
@@ -2289,16 +2329,24 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2289 | } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { | 2329 | } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { |
2290 | u8 address = u132->addr[usb_addr].address; | 2330 | u8 address = u132->addr[usb_addr].address; |
2291 | struct u132_udev *udev = &u132->udev[address]; | 2331 | struct u132_udev *udev = &u132->udev[address]; |
2292 | struct u132_endp *endp = hep->hcpriv; | 2332 | struct u132_endp *endp = urb->ep->hcpriv; |
2293 | urb->actual_length = 0; | 2333 | urb->actual_length = 0; |
2294 | if (endp) { | 2334 | if (endp) { |
2295 | unsigned long irqs; | 2335 | unsigned long irqs; |
2296 | int retval; | 2336 | int retval; |
2297 | spin_lock_irqsave(&endp->queue_lock.slock, | 2337 | spin_lock_irqsave(&endp->queue_lock.slock, |
2298 | irqs); | 2338 | irqs); |
2299 | retval = queue_bulk_on_old_endpoint(u132, udev, | 2339 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2300 | hep, urb, usb_dev, endp, usb_addr, | 2340 | if (retval == 0) { |
2301 | usb_endp, address); | 2341 | retval = queue_bulk_on_old_endpoint( |
2342 | u132, udev, urb, | ||
2343 | usb_dev, endp, | ||
2344 | usb_addr, usb_endp, | ||
2345 | address); | ||
2346 | if (retval) | ||
2347 | usb_hcd_unlink_urb_from_ep( | ||
2348 | hcd, urb); | ||
2349 | } | ||
2302 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2350 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2303 | irqs); | 2351 | irqs); |
2304 | if (retval) { | 2352 | if (retval) { |
@@ -2311,10 +2359,10 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2311 | return -EINVAL; | 2359 | return -EINVAL; |
2312 | } else | 2360 | } else |
2313 | return create_endpoint_and_queue_bulk(u132, | 2361 | return create_endpoint_and_queue_bulk(u132, |
2314 | udev, hep, urb, usb_dev, usb_addr, | 2362 | udev, urb, usb_dev, usb_addr, |
2315 | usb_endp, address, mem_flags); | 2363 | usb_endp, address, mem_flags); |
2316 | } else { | 2364 | } else { |
2317 | struct u132_endp *endp = hep->hcpriv; | 2365 | struct u132_endp *endp = urb->ep->hcpriv; |
2318 | u16 urb_size = 8; | 2366 | u16 urb_size = 8; |
2319 | u8 *b = urb->setup_packet; | 2367 | u8 *b = urb->setup_packet; |
2320 | int i = 0; | 2368 | int i = 0; |
@@ -2337,9 +2385,16 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2337 | int retval; | 2385 | int retval; |
2338 | spin_lock_irqsave(&endp->queue_lock.slock, | 2386 | spin_lock_irqsave(&endp->queue_lock.slock, |
2339 | irqs); | 2387 | irqs); |
2340 | retval = queue_control_on_old_endpoint(u132, | 2388 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2341 | hep, urb, usb_dev, endp, usb_addr, | 2389 | if (retval == 0) { |
2342 | usb_endp); | 2390 | retval = queue_control_on_old_endpoint( |
2391 | u132, urb, usb_dev, | ||
2392 | endp, usb_addr, | ||
2393 | usb_endp); | ||
2394 | if (retval) | ||
2395 | usb_hcd_unlink_urb_from_ep( | ||
2396 | hcd, urb); | ||
2397 | } | ||
2343 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2398 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
2344 | irqs); | 2399 | irqs); |
2345 | if (retval) { | 2400 | if (retval) { |
@@ -2352,7 +2407,7 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | |||
2352 | return -EINVAL; | 2407 | return -EINVAL; |
2353 | } else | 2408 | } else |
2354 | return create_endpoint_and_queue_control(u132, | 2409 | return create_endpoint_and_queue_control(u132, |
2355 | hep, urb, usb_dev, usb_addr, usb_endp, | 2410 | urb, usb_dev, usb_addr, usb_endp, |
2356 | mem_flags); | 2411 | mem_flags); |
2357 | } | 2412 | } |
2358 | } | 2413 | } |
@@ -2371,8 +2426,7 @@ static int dequeue_from_overflow_chain(struct u132 *u132, | |||
2371 | list_del(scan); | 2426 | list_del(scan); |
2372 | endp->queue_size -= 1; | 2427 | endp->queue_size -= 1; |
2373 | urb->error_count = 0; | 2428 | urb->error_count = 0; |
2374 | urb->hcpriv = NULL; | 2429 | usb_hcd_giveback_urb(hcd, urb, 0); |
2375 | usb_hcd_giveback_urb(hcd, urb); | ||
2376 | return 0; | 2430 | return 0; |
2377 | } else | 2431 | } else |
2378 | continue; | 2432 | continue; |
@@ -2387,10 +2441,17 @@ static int dequeue_from_overflow_chain(struct u132 *u132, | |||
2387 | } | 2441 | } |
2388 | 2442 | ||
2389 | static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | 2443 | static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, |
2390 | struct urb *urb) | 2444 | struct urb *urb, int status) |
2391 | { | 2445 | { |
2392 | unsigned long irqs; | 2446 | unsigned long irqs; |
2447 | int rc; | ||
2448 | |||
2393 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | 2449 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); |
2450 | rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); | ||
2451 | if (rc) { | ||
2452 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
2453 | return rc; | ||
2454 | } | ||
2394 | if (endp->queue_size == 0) { | 2455 | if (endp->queue_size == 0) { |
2395 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" | 2456 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" |
2396 | "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, | 2457 | "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, |
@@ -2406,11 +2467,10 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2406 | endp->edset_flush = 1; | 2467 | endp->edset_flush = 1; |
2407 | u132_endp_queue_work(u132, endp, 0); | 2468 | u132_endp_queue_work(u132, endp, 0); |
2408 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2469 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2409 | urb->hcpriv = NULL; | ||
2410 | return 0; | 2470 | return 0; |
2411 | } else { | 2471 | } else { |
2412 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2472 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2413 | u132_hcd_abandon_urb(u132, endp, urb, urb->status); | 2473 | u132_hcd_abandon_urb(u132, endp, urb, status); |
2414 | return 0; | 2474 | return 0; |
2415 | } | 2475 | } |
2416 | } else { | 2476 | } else { |
@@ -2435,6 +2495,8 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2435 | } | 2495 | } |
2436 | if (urb_slot) { | 2496 | if (urb_slot) { |
2437 | struct usb_hcd *hcd = u132_to_hcd(u132); | 2497 | struct usb_hcd *hcd = u132_to_hcd(u132); |
2498 | |||
2499 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
2438 | endp->queue_size -= 1; | 2500 | endp->queue_size -= 1; |
2439 | if (list_empty(&endp->urb_more)) { | 2501 | if (list_empty(&endp->urb_more)) { |
2440 | spin_unlock_irqrestore(&endp->queue_lock.slock, | 2502 | spin_unlock_irqrestore(&endp->queue_lock.slock, |
@@ -2449,8 +2511,7 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2449 | irqs); | 2511 | irqs); |
2450 | kfree(urbq); | 2512 | kfree(urbq); |
2451 | } urb->error_count = 0; | 2513 | } urb->error_count = 0; |
2452 | urb->hcpriv = NULL; | 2514 | usb_hcd_giveback_urb(hcd, urb, status); |
2453 | usb_hcd_giveback_urb(hcd, urb); | ||
2454 | return 0; | 2515 | return 0; |
2455 | } else if (list_empty(&endp->urb_more)) { | 2516 | } else if (list_empty(&endp->urb_more)) { |
2456 | dev_err(&u132->platform_dev->dev, "urb=%p not found in " | 2517 | dev_err(&u132->platform_dev->dev, "urb=%p not found in " |
@@ -2464,7 +2525,10 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2464 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2525 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2465 | return -EINVAL; | 2526 | return -EINVAL; |
2466 | } else { | 2527 | } else { |
2467 | int retval = dequeue_from_overflow_chain(u132, endp, | 2528 | int retval; |
2529 | |||
2530 | usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); | ||
2531 | retval = dequeue_from_overflow_chain(u132, endp, | ||
2468 | urb); | 2532 | urb); |
2469 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | 2533 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); |
2470 | return retval; | 2534 | return retval; |
@@ -2472,7 +2536,7 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | |||
2472 | } | 2536 | } |
2473 | } | 2537 | } |
2474 | 2538 | ||
2475 | static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | 2539 | static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
2476 | { | 2540 | { |
2477 | struct u132 *u132 = hcd_to_u132(hcd); | 2541 | struct u132 *u132 = hcd_to_u132(hcd); |
2478 | if (u132->going > 2) { | 2542 | if (u132->going > 2) { |
@@ -2487,11 +2551,11 @@ static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
2487 | if (usb_pipein(urb->pipe)) { | 2551 | if (usb_pipein(urb->pipe)) { |
2488 | u8 endp_number = udev->endp_number_in[usb_endp]; | 2552 | u8 endp_number = udev->endp_number_in[usb_endp]; |
2489 | struct u132_endp *endp = u132->endp[endp_number - 1]; | 2553 | struct u132_endp *endp = u132->endp[endp_number - 1]; |
2490 | return u132_endp_urb_dequeue(u132, endp, urb); | 2554 | return u132_endp_urb_dequeue(u132, endp, urb, status); |
2491 | } else { | 2555 | } else { |
2492 | u8 endp_number = udev->endp_number_out[usb_endp]; | 2556 | u8 endp_number = udev->endp_number_out[usb_endp]; |
2493 | struct u132_endp *endp = u132->endp[endp_number - 1]; | 2557 | struct u132_endp *endp = u132->endp[endp_number - 1]; |
2494 | return u132_endp_urb_dequeue(u132, endp, urb); | 2558 | return u132_endp_urb_dequeue(u132, endp, urb, status); |
2495 | } | 2559 | } |
2496 | } | 2560 | } |
2497 | } | 2561 | } |
@@ -2801,7 +2865,7 @@ static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2801 | return -ESHUTDOWN; | 2865 | return -ESHUTDOWN; |
2802 | } else { | 2866 | } else { |
2803 | int retval = 0; | 2867 | int retval = 0; |
2804 | down(&u132->sw_lock); | 2868 | mutex_lock(&u132->sw_lock); |
2805 | switch (typeReq) { | 2869 | switch (typeReq) { |
2806 | case ClearHubFeature: | 2870 | case ClearHubFeature: |
2807 | switch (wValue) { | 2871 | switch (wValue) { |
@@ -2864,7 +2928,7 @@ static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2864 | stall:retval = -EPIPE; | 2928 | stall:retval = -EPIPE; |
2865 | break; | 2929 | break; |
2866 | } | 2930 | } |
2867 | up(&u132->sw_lock); | 2931 | mutex_unlock(&u132->sw_lock); |
2868 | return retval; | 2932 | return retval; |
2869 | } | 2933 | } |
2870 | } | 2934 | } |
@@ -3000,7 +3064,7 @@ static int __devexit u132_remove(struct platform_device *pdev) | |||
3000 | dev_err(&u132->platform_dev->dev, "removing device u132" | 3064 | dev_err(&u132->platform_dev->dev, "removing device u132" |
3001 | ".%d\n", u132->sequence_num); | 3065 | ".%d\n", u132->sequence_num); |
3002 | msleep(100); | 3066 | msleep(100); |
3003 | down(&u132->sw_lock); | 3067 | mutex_lock(&u132->sw_lock); |
3004 | u132_monitor_cancel_work(u132); | 3068 | u132_monitor_cancel_work(u132); |
3005 | while (rings-- > 0) { | 3069 | while (rings-- > 0) { |
3006 | struct u132_ring *ring = &u132->ring[rings]; | 3070 | struct u132_ring *ring = &u132->ring[rings]; |
@@ -3013,7 +3077,7 @@ static int __devexit u132_remove(struct platform_device *pdev) | |||
3013 | u132->going += 1; | 3077 | u132->going += 1; |
3014 | printk(KERN_INFO "removing device u132.%d\n", | 3078 | printk(KERN_INFO "removing device u132.%d\n", |
3015 | u132->sequence_num); | 3079 | u132->sequence_num); |
3016 | up(&u132->sw_lock); | 3080 | mutex_unlock(&u132->sw_lock); |
3017 | usb_remove_hcd(hcd); | 3081 | usb_remove_hcd(hcd); |
3018 | u132_u132_put_kref(u132); | 3082 | u132_u132_put_kref(u132); |
3019 | return 0; | 3083 | return 0; |
@@ -3033,7 +3097,7 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev) | |||
3033 | u132->platform_dev = pdev; | 3097 | u132->platform_dev = pdev; |
3034 | u132->power = 0; | 3098 | u132->power = 0; |
3035 | u132->reset = 0; | 3099 | u132->reset = 0; |
3036 | init_MUTEX(&u132->sw_lock); | 3100 | mutex_init(&u132->sw_lock); |
3037 | init_MUTEX(&u132->scheduler_lock); | 3101 | init_MUTEX(&u132->scheduler_lock); |
3038 | while (rings-- > 0) { | 3102 | while (rings-- > 0) { |
3039 | struct u132_ring *ring = &u132->ring[rings]; | 3103 | struct u132_ring *ring = &u132->ring[rings]; |
@@ -3043,7 +3107,7 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev) | |||
3043 | ring->curr_endp = NULL; | 3107 | ring->curr_endp = NULL; |
3044 | INIT_DELAYED_WORK(&ring->scheduler, | 3108 | INIT_DELAYED_WORK(&ring->scheduler, |
3045 | u132_hcd_ring_work_scheduler); | 3109 | u132_hcd_ring_work_scheduler); |
3046 | } down(&u132->sw_lock); | 3110 | } mutex_lock(&u132->sw_lock); |
3047 | INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); | 3111 | INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); |
3048 | while (ports-- > 0) { | 3112 | while (ports-- > 0) { |
3049 | struct u132_port *port = &u132->port[ports]; | 3113 | struct u132_port *port = &u132->port[ports]; |
@@ -3073,7 +3137,7 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev) | |||
3073 | while (endps-- > 0) { | 3137 | while (endps-- > 0) { |
3074 | u132->endp[endps] = NULL; | 3138 | u132->endp[endps] = NULL; |
3075 | } | 3139 | } |
3076 | up(&u132->sw_lock); | 3140 | mutex_unlock(&u132->sw_lock); |
3077 | return; | 3141 | return; |
3078 | } | 3142 | } |
3079 | 3143 | ||
@@ -3111,10 +3175,10 @@ static int __devinit u132_probe(struct platform_device *pdev) | |||
3111 | int retval = 0; | 3175 | int retval = 0; |
3112 | struct u132 *u132 = hcd_to_u132(hcd); | 3176 | struct u132 *u132 = hcd_to_u132(hcd); |
3113 | hcd->rsrc_start = 0; | 3177 | hcd->rsrc_start = 0; |
3114 | down(&u132_module_lock); | 3178 | mutex_lock(&u132_module_lock); |
3115 | list_add_tail(&u132->u132_list, &u132_static_list); | 3179 | list_add_tail(&u132->u132_list, &u132_static_list); |
3116 | u132->sequence_num = ++u132_instances; | 3180 | u132->sequence_num = ++u132_instances; |
3117 | up(&u132_module_lock); | 3181 | mutex_unlock(&u132_module_lock); |
3118 | u132_u132_init_kref(u132); | 3182 | u132_u132_init_kref(u132); |
3119 | u132_initialise(u132, pdev); | 3183 | u132_initialise(u132, pdev); |
3120 | hcd->product_desc = "ELAN U132 Host Controller"; | 3184 | hcd->product_desc = "ELAN U132 Host Controller"; |
@@ -3216,7 +3280,7 @@ static int __init u132_hcd_init(void) | |||
3216 | INIT_LIST_HEAD(&u132_static_list); | 3280 | INIT_LIST_HEAD(&u132_static_list); |
3217 | u132_instances = 0; | 3281 | u132_instances = 0; |
3218 | u132_exiting = 0; | 3282 | u132_exiting = 0; |
3219 | init_MUTEX(&u132_module_lock); | 3283 | mutex_init(&u132_module_lock); |
3220 | if (usb_disabled()) | 3284 | if (usb_disabled()) |
3221 | return -ENODEV; | 3285 | return -ENODEV; |
3222 | printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, | 3286 | printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, |
@@ -3232,9 +3296,9 @@ static void __exit u132_hcd_exit(void) | |||
3232 | { | 3296 | { |
3233 | struct u132 *u132; | 3297 | struct u132 *u132; |
3234 | struct u132 *temp; | 3298 | struct u132 *temp; |
3235 | down(&u132_module_lock); | 3299 | mutex_lock(&u132_module_lock); |
3236 | u132_exiting += 1; | 3300 | u132_exiting += 1; |
3237 | up(&u132_module_lock); | 3301 | mutex_unlock(&u132_module_lock); |
3238 | list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { | 3302 | list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { |
3239 | platform_device_unregister(u132->platform_dev); | 3303 | platform_device_unregister(u132->platform_dev); |
3240 | } platform_driver_unregister(&u132_platform_driver); | 3304 | } platform_driver_unregister(&u132_platform_driver); |
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index 1497371583b..20cc58b9780 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c | |||
@@ -120,8 +120,8 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space) | |||
120 | out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : "")); | 120 | out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : "")); |
121 | out += sprintf(out, " Actlen=%d", urbp->urb->actual_length); | 121 | out += sprintf(out, " Actlen=%d", urbp->urb->actual_length); |
122 | 122 | ||
123 | if (urbp->urb->status != -EINPROGRESS) | 123 | if (urbp->urb->unlinked) |
124 | out += sprintf(out, " Status=%d", urbp->urb->status); | 124 | out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked); |
125 | out += sprintf(out, "\n"); | 125 | out += sprintf(out, "\n"); |
126 | 126 | ||
127 | i = nactive = ninactive = 0; | 127 | i = nactive = ninactive = 0; |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 76c555a67da..4db17f75f4f 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -237,7 +237,7 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci) | |||
237 | static int remote_wakeup_is_broken(struct uhci_hcd *uhci) | 237 | static int remote_wakeup_is_broken(struct uhci_hcd *uhci) |
238 | { | 238 | { |
239 | int port; | 239 | int port; |
240 | char *sys_info; | 240 | const char *sys_info; |
241 | static char bad_Asus_board[] = "A7V8X"; | 241 | static char bad_Asus_board[] = "A7V8X"; |
242 | 242 | ||
243 | /* One of Asus's motherboards has a bug which causes it to | 243 | /* One of Asus's motherboards has a bug which causes it to |
@@ -933,7 +933,7 @@ static int __init uhci_hcd_init(void) | |||
933 | } | 933 | } |
934 | 934 | ||
935 | uhci_up_cachep = kmem_cache_create("uhci_urb_priv", | 935 | uhci_up_cachep = kmem_cache_create("uhci_urb_priv", |
936 | sizeof(struct urb_priv), 0, 0, NULL, NULL); | 936 | sizeof(struct urb_priv), 0, 0, NULL); |
937 | if (!uhci_up_cachep) | 937 | if (!uhci_up_cachep) |
938 | goto up_failed; | 938 | goto up_failed; |
939 | 939 | ||
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h index 1b3d23406ac..340d6ed3e6e 100644 --- a/drivers/usb/host/uhci-hcd.h +++ b/drivers/usb/host/uhci-hcd.h | |||
@@ -146,7 +146,6 @@ struct uhci_qh { | |||
146 | short phase; /* Between 0 and period-1 */ | 146 | short phase; /* Between 0 and period-1 */ |
147 | short load; /* Periodic time requirement, in us */ | 147 | short load; /* Periodic time requirement, in us */ |
148 | unsigned int iso_frame; /* Frame # for iso_packet_desc */ | 148 | unsigned int iso_frame; /* Frame # for iso_packet_desc */ |
149 | int iso_status; /* Status for Isochronous URBs */ | ||
150 | 149 | ||
151 | int state; /* QH_STATE_xxx; see above */ | 150 | int state; /* QH_STATE_xxx; see above */ |
152 | int type; /* Queue type (control, bulk, etc) */ | 151 | int type; /* Queue type (control, bulk, etc) */ |
@@ -457,21 +456,6 @@ struct urb_priv { | |||
457 | }; | 456 | }; |
458 | 457 | ||
459 | 458 | ||
460 | /* | ||
461 | * Locking in uhci.c | ||
462 | * | ||
463 | * Almost everything relating to the hardware schedule and processing | ||
464 | * of URBs is protected by uhci->lock. urb->status is protected by | ||
465 | * urb->lock; that's the one exception. | ||
466 | * | ||
467 | * To prevent deadlocks, never lock uhci->lock while holding urb->lock. | ||
468 | * The safe order of locking is: | ||
469 | * | ||
470 | * #1 uhci->lock | ||
471 | * #2 urb->lock | ||
472 | */ | ||
473 | |||
474 | |||
475 | /* Some special IDs */ | 459 | /* Some special IDs */ |
476 | 460 | ||
477 | #define PCI_VENDOR_ID_GENESYS 0x17a0 | 461 | #define PCI_VENDOR_ID_GENESYS 0x17a0 |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index 4aed305982e..e5d60d5b105 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -757,7 +757,6 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci, | |||
757 | uhci_free_td(uhci, td); | 757 | uhci_free_td(uhci, td); |
758 | } | 758 | } |
759 | 759 | ||
760 | urbp->urb->hcpriv = NULL; | ||
761 | kmem_cache_free(uhci_up_cachep, urbp); | 760 | kmem_cache_free(uhci_up_cachep, urbp); |
762 | } | 761 | } |
763 | 762 | ||
@@ -827,8 +826,10 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, | |||
827 | * If direction is "send", change the packet ID from SETUP (0x2D) | 826 | * If direction is "send", change the packet ID from SETUP (0x2D) |
828 | * to OUT (0xE1). Else change it from SETUP to IN (0x69) and | 827 | * to OUT (0xE1). Else change it from SETUP to IN (0x69) and |
829 | * set Short Packet Detect (SPD) for all data packets. | 828 | * set Short Packet Detect (SPD) for all data packets. |
829 | * | ||
830 | * 0-length transfers always get treated as "send". | ||
830 | */ | 831 | */ |
831 | if (usb_pipeout(urb->pipe)) | 832 | if (usb_pipeout(urb->pipe) || len == 0) |
832 | destination ^= (USB_PID_SETUP ^ USB_PID_OUT); | 833 | destination ^= (USB_PID_SETUP ^ USB_PID_OUT); |
833 | else { | 834 | else { |
834 | destination ^= (USB_PID_SETUP ^ USB_PID_IN); | 835 | destination ^= (USB_PID_SETUP ^ USB_PID_IN); |
@@ -839,7 +840,12 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, | |||
839 | * Build the DATA TDs | 840 | * Build the DATA TDs |
840 | */ | 841 | */ |
841 | while (len > 0) { | 842 | while (len > 0) { |
842 | int pktsze = min(len, maxsze); | 843 | int pktsze = maxsze; |
844 | |||
845 | if (len <= pktsze) { /* The last data packet */ | ||
846 | pktsze = len; | ||
847 | status &= ~TD_CTRL_SPD; | ||
848 | } | ||
843 | 849 | ||
844 | td = uhci_alloc_td(uhci); | 850 | td = uhci_alloc_td(uhci); |
845 | if (!td) | 851 | if (!td) |
@@ -866,20 +872,10 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, | |||
866 | goto nomem; | 872 | goto nomem; |
867 | *plink = LINK_TO_TD(td); | 873 | *plink = LINK_TO_TD(td); |
868 | 874 | ||
869 | /* | 875 | /* Change direction for the status transaction */ |
870 | * It's IN if the pipe is an output pipe or we're not expecting | 876 | destination ^= (USB_PID_IN ^ USB_PID_OUT); |
871 | * data back. | ||
872 | */ | ||
873 | destination &= ~TD_TOKEN_PID_MASK; | ||
874 | if (usb_pipeout(urb->pipe) || !urb->transfer_buffer_length) | ||
875 | destination |= USB_PID_IN; | ||
876 | else | ||
877 | destination |= USB_PID_OUT; | ||
878 | |||
879 | destination |= TD_TOKEN_TOGGLE; /* End in Data1 */ | 877 | destination |= TD_TOKEN_TOGGLE; /* End in Data1 */ |
880 | 878 | ||
881 | status &= ~TD_CTRL_SPD; | ||
882 | |||
883 | uhci_add_td_to_urbp(td, urbp); | 879 | uhci_add_td_to_urbp(td, urbp); |
884 | uhci_fill_td(td, status | TD_CTRL_IOC, | 880 | uhci_fill_td(td, status | TD_CTRL_IOC, |
885 | destination | uhci_explen(0), 0); | 881 | destination | uhci_explen(0), 0); |
@@ -1185,10 +1181,18 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb) | |||
1185 | } | 1181 | } |
1186 | } | 1182 | } |
1187 | 1183 | ||
1184 | /* Did we receive a short packet? */ | ||
1188 | } else if (len < uhci_expected_length(td_token(td))) { | 1185 | } else if (len < uhci_expected_length(td_token(td))) { |
1189 | 1186 | ||
1190 | /* We received a short packet */ | 1187 | /* For control transfers, go to the status TD if |
1191 | if (urb->transfer_flags & URB_SHORT_NOT_OK) | 1188 | * this isn't already the last data TD */ |
1189 | if (qh->type == USB_ENDPOINT_XFER_CONTROL) { | ||
1190 | if (td->list.next != urbp->td_list.prev) | ||
1191 | ret = 1; | ||
1192 | } | ||
1193 | |||
1194 | /* For bulk and interrupt, this may be an error */ | ||
1195 | else if (urb->transfer_flags & URB_SHORT_NOT_OK) | ||
1192 | ret = -EREMOTEIO; | 1196 | ret = -EREMOTEIO; |
1193 | 1197 | ||
1194 | /* Fixup needed only if this isn't the URB's last TD */ | 1198 | /* Fixup needed only if this isn't the URB's last TD */ |
@@ -1208,10 +1212,6 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb) | |||
1208 | 1212 | ||
1209 | err: | 1213 | err: |
1210 | if (ret < 0) { | 1214 | if (ret < 0) { |
1211 | /* In case a control transfer gets an error | ||
1212 | * during the setup stage */ | ||
1213 | urb->actual_length = max(urb->actual_length, 0); | ||
1214 | |||
1215 | /* Note that the queue has stopped and save | 1215 | /* Note that the queue has stopped and save |
1216 | * the next toggle value */ | 1216 | * the next toggle value */ |
1217 | qh->element = UHCI_PTR_TERM; | 1217 | qh->element = UHCI_PTR_TERM; |
@@ -1323,7 +1323,6 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1323 | if (list_empty(&qh->queue)) { | 1323 | if (list_empty(&qh->queue)) { |
1324 | qh->iso_packet_desc = &urb->iso_frame_desc[0]; | 1324 | qh->iso_packet_desc = &urb->iso_frame_desc[0]; |
1325 | qh->iso_frame = urb->start_frame; | 1325 | qh->iso_frame = urb->start_frame; |
1326 | qh->iso_status = 0; | ||
1327 | } | 1326 | } |
1328 | 1327 | ||
1329 | qh->skel = SKEL_ISO; | 1328 | qh->skel = SKEL_ISO; |
@@ -1360,22 +1359,18 @@ static int uhci_result_isochronous(struct uhci_hcd *uhci, struct urb *urb) | |||
1360 | qh->iso_packet_desc->actual_length = actlength; | 1359 | qh->iso_packet_desc->actual_length = actlength; |
1361 | qh->iso_packet_desc->status = status; | 1360 | qh->iso_packet_desc->status = status; |
1362 | } | 1361 | } |
1363 | 1362 | if (status) | |
1364 | if (status) { | ||
1365 | urb->error_count++; | 1363 | urb->error_count++; |
1366 | qh->iso_status = status; | ||
1367 | } | ||
1368 | 1364 | ||
1369 | uhci_remove_td_from_urbp(td); | 1365 | uhci_remove_td_from_urbp(td); |
1370 | uhci_free_td(uhci, td); | 1366 | uhci_free_td(uhci, td); |
1371 | qh->iso_frame += qh->period; | 1367 | qh->iso_frame += qh->period; |
1372 | ++qh->iso_packet_desc; | 1368 | ++qh->iso_packet_desc; |
1373 | } | 1369 | } |
1374 | return qh->iso_status; | 1370 | return 0; |
1375 | } | 1371 | } |
1376 | 1372 | ||
1377 | static int uhci_urb_enqueue(struct usb_hcd *hcd, | 1373 | static int uhci_urb_enqueue(struct usb_hcd *hcd, |
1378 | struct usb_host_endpoint *hep, | ||
1379 | struct urb *urb, gfp_t mem_flags) | 1374 | struct urb *urb, gfp_t mem_flags) |
1380 | { | 1375 | { |
1381 | int ret; | 1376 | int ret; |
@@ -1386,19 +1381,19 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd, | |||
1386 | 1381 | ||
1387 | spin_lock_irqsave(&uhci->lock, flags); | 1382 | spin_lock_irqsave(&uhci->lock, flags); |
1388 | 1383 | ||
1389 | ret = urb->status; | 1384 | ret = usb_hcd_link_urb_to_ep(hcd, urb); |
1390 | if (ret != -EINPROGRESS) /* URB already unlinked! */ | 1385 | if (ret) |
1391 | goto done; | 1386 | goto done_not_linked; |
1392 | 1387 | ||
1393 | ret = -ENOMEM; | 1388 | ret = -ENOMEM; |
1394 | urbp = uhci_alloc_urb_priv(uhci, urb); | 1389 | urbp = uhci_alloc_urb_priv(uhci, urb); |
1395 | if (!urbp) | 1390 | if (!urbp) |
1396 | goto done; | 1391 | goto done; |
1397 | 1392 | ||
1398 | if (hep->hcpriv) | 1393 | if (urb->ep->hcpriv) |
1399 | qh = (struct uhci_qh *) hep->hcpriv; | 1394 | qh = urb->ep->hcpriv; |
1400 | else { | 1395 | else { |
1401 | qh = uhci_alloc_qh(uhci, urb->dev, hep); | 1396 | qh = uhci_alloc_qh(uhci, urb->dev, urb->ep); |
1402 | if (!qh) | 1397 | if (!qh) |
1403 | goto err_no_qh; | 1398 | goto err_no_qh; |
1404 | } | 1399 | } |
@@ -1439,27 +1434,29 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd, | |||
1439 | err_submit_failed: | 1434 | err_submit_failed: |
1440 | if (qh->state == QH_STATE_IDLE) | 1435 | if (qh->state == QH_STATE_IDLE) |
1441 | uhci_make_qh_idle(uhci, qh); /* Reclaim unused QH */ | 1436 | uhci_make_qh_idle(uhci, qh); /* Reclaim unused QH */ |
1442 | |||
1443 | err_no_qh: | 1437 | err_no_qh: |
1444 | uhci_free_urb_priv(uhci, urbp); | 1438 | uhci_free_urb_priv(uhci, urbp); |
1445 | |||
1446 | done: | 1439 | done: |
1440 | if (ret) | ||
1441 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
1442 | done_not_linked: | ||
1447 | spin_unlock_irqrestore(&uhci->lock, flags); | 1443 | spin_unlock_irqrestore(&uhci->lock, flags); |
1448 | return ret; | 1444 | return ret; |
1449 | } | 1445 | } |
1450 | 1446 | ||
1451 | static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | 1447 | static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) |
1452 | { | 1448 | { |
1453 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 1449 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
1454 | unsigned long flags; | 1450 | unsigned long flags; |
1455 | struct urb_priv *urbp; | ||
1456 | struct uhci_qh *qh; | 1451 | struct uhci_qh *qh; |
1452 | int rc; | ||
1457 | 1453 | ||
1458 | spin_lock_irqsave(&uhci->lock, flags); | 1454 | spin_lock_irqsave(&uhci->lock, flags); |
1459 | urbp = urb->hcpriv; | 1455 | rc = usb_hcd_check_unlink_urb(hcd, urb, status); |
1460 | if (!urbp) /* URB was never linked! */ | 1456 | if (rc) |
1461 | goto done; | 1457 | goto done; |
1462 | qh = urbp->qh; | 1458 | |
1459 | qh = ((struct urb_priv *) urb->hcpriv)->qh; | ||
1463 | 1460 | ||
1464 | /* Remove Isochronous TDs from the frame list ASAP */ | 1461 | /* Remove Isochronous TDs from the frame list ASAP */ |
1465 | if (qh->type == USB_ENDPOINT_XFER_ISOC) { | 1462 | if (qh->type == USB_ENDPOINT_XFER_ISOC) { |
@@ -1476,22 +1473,31 @@ static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
1476 | 1473 | ||
1477 | done: | 1474 | done: |
1478 | spin_unlock_irqrestore(&uhci->lock, flags); | 1475 | spin_unlock_irqrestore(&uhci->lock, flags); |
1479 | return 0; | 1476 | return rc; |
1480 | } | 1477 | } |
1481 | 1478 | ||
1482 | /* | 1479 | /* |
1483 | * Finish unlinking an URB and give it back | 1480 | * Finish unlinking an URB and give it back |
1484 | */ | 1481 | */ |
1485 | static void uhci_giveback_urb(struct uhci_hcd *uhci, struct uhci_qh *qh, | 1482 | static void uhci_giveback_urb(struct uhci_hcd *uhci, struct uhci_qh *qh, |
1486 | struct urb *urb) | 1483 | struct urb *urb, int status) |
1487 | __releases(uhci->lock) | 1484 | __releases(uhci->lock) |
1488 | __acquires(uhci->lock) | 1485 | __acquires(uhci->lock) |
1489 | { | 1486 | { |
1490 | struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; | 1487 | struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; |
1491 | 1488 | ||
1489 | if (qh->type == USB_ENDPOINT_XFER_CONTROL) { | ||
1490 | |||
1491 | /* urb->actual_length < 0 means the setup transaction didn't | ||
1492 | * complete successfully. Either it failed or the URB was | ||
1493 | * unlinked first. Regardless, don't confuse people with a | ||
1494 | * negative length. */ | ||
1495 | urb->actual_length = max(urb->actual_length, 0); | ||
1496 | } | ||
1497 | |||
1492 | /* When giving back the first URB in an Isochronous queue, | 1498 | /* When giving back the first URB in an Isochronous queue, |
1493 | * reinitialize the QH's iso-related members for the next URB. */ | 1499 | * reinitialize the QH's iso-related members for the next URB. */ |
1494 | if (qh->type == USB_ENDPOINT_XFER_ISOC && | 1500 | else if (qh->type == USB_ENDPOINT_XFER_ISOC && |
1495 | urbp->node.prev == &qh->queue && | 1501 | urbp->node.prev == &qh->queue && |
1496 | urbp->node.next != &qh->queue) { | 1502 | urbp->node.next != &qh->queue) { |
1497 | struct urb *nurb = list_entry(urbp->node.next, | 1503 | struct urb *nurb = list_entry(urbp->node.next, |
@@ -1499,7 +1505,6 @@ __acquires(uhci->lock) | |||
1499 | 1505 | ||
1500 | qh->iso_packet_desc = &nurb->iso_frame_desc[0]; | 1506 | qh->iso_packet_desc = &nurb->iso_frame_desc[0]; |
1501 | qh->iso_frame = nurb->start_frame; | 1507 | qh->iso_frame = nurb->start_frame; |
1502 | qh->iso_status = 0; | ||
1503 | } | 1508 | } |
1504 | 1509 | ||
1505 | /* Take the URB off the QH's queue. If the queue is now empty, | 1510 | /* Take the URB off the QH's queue. If the queue is now empty, |
@@ -1512,9 +1517,10 @@ __acquires(uhci->lock) | |||
1512 | } | 1517 | } |
1513 | 1518 | ||
1514 | uhci_free_urb_priv(uhci, urbp); | 1519 | uhci_free_urb_priv(uhci, urbp); |
1520 | usb_hcd_unlink_urb_from_ep(uhci_to_hcd(uhci), urb); | ||
1515 | 1521 | ||
1516 | spin_unlock(&uhci->lock); | 1522 | spin_unlock(&uhci->lock); |
1517 | usb_hcd_giveback_urb(uhci_to_hcd(uhci), urb); | 1523 | usb_hcd_giveback_urb(uhci_to_hcd(uhci), urb, status); |
1518 | spin_lock(&uhci->lock); | 1524 | spin_lock(&uhci->lock); |
1519 | 1525 | ||
1520 | /* If the queue is now empty, we can unlink the QH and give up its | 1526 | /* If the queue is now empty, we can unlink the QH and give up its |
@@ -1550,24 +1556,17 @@ static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
1550 | if (status == -EINPROGRESS) | 1556 | if (status == -EINPROGRESS) |
1551 | break; | 1557 | break; |
1552 | 1558 | ||
1553 | spin_lock(&urb->lock); | ||
1554 | if (urb->status == -EINPROGRESS) /* Not dequeued */ | ||
1555 | urb->status = status; | ||
1556 | else | ||
1557 | status = ECONNRESET; /* Not -ECONNRESET */ | ||
1558 | spin_unlock(&urb->lock); | ||
1559 | |||
1560 | /* Dequeued but completed URBs can't be given back unless | 1559 | /* Dequeued but completed URBs can't be given back unless |
1561 | * the QH is stopped or has finished unlinking. */ | 1560 | * the QH is stopped or has finished unlinking. */ |
1562 | if (status == ECONNRESET) { | 1561 | if (urb->unlinked) { |
1563 | if (QH_FINISHED_UNLINKING(qh)) | 1562 | if (QH_FINISHED_UNLINKING(qh)) |
1564 | qh->is_stopped = 1; | 1563 | qh->is_stopped = 1; |
1565 | else if (!qh->is_stopped) | 1564 | else if (!qh->is_stopped) |
1566 | return; | 1565 | return; |
1567 | } | 1566 | } |
1568 | 1567 | ||
1569 | uhci_giveback_urb(uhci, qh, urb); | 1568 | uhci_giveback_urb(uhci, qh, urb, status); |
1570 | if (status < 0 && qh->type != USB_ENDPOINT_XFER_ISOC) | 1569 | if (status < 0) |
1571 | break; | 1570 | break; |
1572 | } | 1571 | } |
1573 | 1572 | ||
@@ -1582,7 +1581,7 @@ static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) | |||
1582 | restart: | 1581 | restart: |
1583 | list_for_each_entry(urbp, &qh->queue, node) { | 1582 | list_for_each_entry(urbp, &qh->queue, node) { |
1584 | urb = urbp->urb; | 1583 | urb = urbp->urb; |
1585 | if (urb->status != -EINPROGRESS) { | 1584 | if (urb->unlinked) { |
1586 | 1585 | ||
1587 | /* Fix up the TD links and save the toggles for | 1586 | /* Fix up the TD links and save the toggles for |
1588 | * non-Isochronous queues. For Isochronous queues, | 1587 | * non-Isochronous queues. For Isochronous queues, |
@@ -1591,7 +1590,7 @@ restart: | |||
1591 | qh->is_stopped = 0; | 1590 | qh->is_stopped = 0; |
1592 | return; | 1591 | return; |
1593 | } | 1592 | } |
1594 | uhci_giveback_urb(uhci, qh, urb); | 1593 | uhci_giveback_urb(uhci, qh, urb, 0); |
1595 | goto restart; | 1594 | goto restart; |
1596 | } | 1595 | } |
1597 | } | 1596 | } |