Commit ea2b2c10 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB: OHCI cleanups

This splits out a few obvious fixes, to help shrink a PM patch:

  - when the HC is quiescing, don't schedule any more EDs
    or re-activate any after unlink completion.

  - when the HC is suspended, don't access registers through
    sysfs either.

  - simplify locking and call for donelist processing
parent 2a339670
...@@ -617,7 +617,17 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -617,7 +617,17 @@ show_registers (struct class_device *class_dev, char *buf)
/* dump driver info, then registers in spec order */ /* dump driver info, then registers in spec order */
ohci_dbg_sw (ohci, &next, &size, ohci_dbg_sw (ohci, &next, &size,
"%s version " DRIVER_VERSION "\n", hcd_name); "bus %s, device %s\n"
"%s version " DRIVER_VERSION "\n",
hcd->self.controller->bus->name,
hcd->self.controller->bus_id,
hcd_name);
if (bus->controller->power.power_state) {
size -= scnprintf (next, size,
"SUSPENDED (no register access)\n");
goto done;
}
ohci_dump_status(ohci, &next, &size); ohci_dump_status(ohci, &next, &size);
...@@ -657,8 +667,8 @@ show_registers (struct class_device *class_dev, char *buf) ...@@ -657,8 +667,8 @@ show_registers (struct class_device *class_dev, char *buf)
/* roothub */ /* roothub */
ohci_dump_roothub (ohci, 1, &next, &size); ohci_dump_roothub (ohci, 1, &next, &size);
done:
spin_unlock_irqrestore (&ohci->lock, flags); spin_unlock_irqrestore (&ohci->lock, flags);
return PAGE_SIZE - size; return PAGE_SIZE - size;
} }
static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
......
...@@ -611,11 +611,13 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs) ...@@ -611,11 +611,13 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
ohci_dump (ohci, 1); ohci_dump (ohci, 1);
hc_reset (ohci); hc_reset (ohci);
} }
if (ints & OHCI_INTR_WDH) { if (ints & OHCI_INTR_WDH) {
if (HCD_IS_RUNNING(hcd->state)) if (HCD_IS_RUNNING(hcd->state))
writel (OHCI_INTR_WDH, &regs->intrdisable); writel (OHCI_INTR_WDH, &regs->intrdisable);
dl_done_list (ohci, dl_reverse_done_list (ohci), ptregs); spin_lock (&ohci->lock);
dl_done_list (ohci, ptregs);
spin_unlock (&ohci->lock);
if (HCD_IS_RUNNING(hcd->state)) if (HCD_IS_RUNNING(hcd->state))
writel (OHCI_INTR_WDH, &regs->intrenable); writel (OHCI_INTR_WDH, &regs->intrenable);
} }
......
...@@ -281,6 +281,11 @@ static int ohci_pci_resume (struct usb_hcd *hcd) ...@@ -281,6 +281,11 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
writel (OHCI_INTR_WDH, &ohci->regs->intrdisable); writel (OHCI_INTR_WDH, &ohci->regs->intrdisable);
(void) readl (&ohci->regs->intrdisable); (void) readl (&ohci->regs->intrdisable);
/* Check for a pending done list */
if (ohci->hcca->done_head)
dl_done_list (ohci, NULL);
spin_unlock_irq (&ohci->lock); spin_unlock_irq (&ohci->lock);
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
...@@ -288,9 +293,6 @@ static int ohci_pci_resume (struct usb_hcd *hcd) ...@@ -288,9 +293,6 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
enable_irq (to_pci_dev(hcd->self.controller)->irq); enable_irq (to_pci_dev(hcd->self.controller)->irq);
#endif #endif
/* Check for a pending done list */
if (ohci->hcca->done_head)
dl_done_list (ohci, dl_reverse_done_list (ohci), NULL);
writel (OHCI_INTR_WDH, &ohci->regs->intrenable); writel (OHCI_INTR_WDH, &ohci->regs->intrenable);
/* assume there are TDs on the bulk and control lists */ /* assume there are TDs on the bulk and control lists */
......
...@@ -170,6 +170,9 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed) ...@@ -170,6 +170,9 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
{ {
int branch; int branch;
if (ohci->hcd.state == USB_STATE_QUIESCING)
return -EAGAIN;
ed->state = ED_OPER; ed->state = ED_OPER;
ed->ed_prev = 0; ed->ed_prev = 0;
ed->ed_next = 0; ed->ed_next = 0;
...@@ -867,9 +870,6 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci) ...@@ -867,9 +870,6 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
u32 td_dma; u32 td_dma;
struct td *td_rev = NULL; struct td *td_rev = NULL;
struct td *td = NULL; struct td *td = NULL;
unsigned long flags;
spin_lock_irqsave (&ohci->lock, flags);
td_dma = le32_to_cpup (&ohci->hcca->done_head); td_dma = le32_to_cpup (&ohci->hcca->done_head);
ohci->hcca->done_head = 0; ohci->hcca->done_head = 0;
...@@ -901,7 +901,6 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci) ...@@ -901,7 +901,6 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
td_rev = td; td_rev = td;
td_dma = le32_to_cpup (&td->hwNextTD); td_dma = le32_to_cpup (&td->hwNextTD);
} }
spin_unlock_irqrestore (&ohci->lock, flags);
return td_rev; return td_rev;
} }
...@@ -1015,7 +1014,9 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs) ...@@ -1015,7 +1014,9 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs)
} }
/* maybe reenable control and bulk lists */ /* maybe reenable control and bulk lists */
if (HCD_IS_RUNNING(ohci->hcd.state) && !ohci->ed_rm_list) { if (HCD_IS_RUNNING(ohci->hcd.state)
&& ohci->hcd.state != USB_STATE_QUIESCING
&& !ohci->ed_rm_list) {
u32 command = 0, control = 0; u32 command = 0, control = 0;
if (ohci->ed_controltail) { if (ohci->ed_controltail) {
...@@ -1055,11 +1056,10 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs) ...@@ -1055,11 +1056,10 @@ finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs)
* scanning the (re-reversed) donelist as this does. * scanning the (re-reversed) donelist as this does.
*/ */
static void static void
dl_done_list (struct ohci_hcd *ohci, struct td *td, struct pt_regs *regs) dl_done_list (struct ohci_hcd *ohci, struct pt_regs *regs)
{ {
unsigned long flags; struct td *td = dl_reverse_done_list (ohci);
spin_lock_irqsave (&ohci->lock, flags);
while (td) { while (td) {
struct td *td_next = td->next_dl_td; struct td *td_next = td->next_dl_td;
struct urb *urb = td->urb; struct urb *urb = td->urb;
...@@ -1100,5 +1100,4 @@ dl_done_list (struct ohci_hcd *ohci, struct td *td, struct pt_regs *regs) ...@@ -1100,5 +1100,4 @@ dl_done_list (struct ohci_hcd *ohci, struct td *td, struct pt_regs *regs)
td = td_next; td = td_next;
} }
spin_unlock_irqrestore (&ohci->lock, flags);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment