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

[PATCH] USB: ohci-hcd, more portable diagnostics

This is the rest of the work to make the driver not care which
version of the OS it's using, so the difference between the 2.5
and 2.5 versions can just be a small patch with stuff that has
a real need to be different.
parent d3d118a8
......@@ -72,9 +72,9 @@ urb_print (struct urb * urb, char * str, int small)
#endif
}
static void ohci_dump_intr_mask (struct device *dev, char *label, __u32 mask)
static void ohci_dump_intr_mask (struct ohci_hcd *ohci, char *label, __u32 mask)
{
dev_dbg (dev, "%s: 0x%08x%s%s%s%s%s%s%s%s%s\n",
ohci_dbg (ohci, "%s: 0x%08x%s%s%s%s%s%s%s%s%s\n",
label,
mask,
(mask & OHCI_INTR_MIE) ? " MIE" : "",
......@@ -89,10 +89,10 @@ static void ohci_dump_intr_mask (struct device *dev, char *label, __u32 mask)
);
}
static void maybe_print_eds (struct device *dev, char *label, __u32 value)
static void maybe_print_eds (struct ohci_hcd *ohci, char *label, __u32 value)
{
if (value)
dev_dbg (dev, "%s %08x\n", label, value);
ohci_dbg (ohci, "%s %08x\n", label, value);
}
static char *hcfs2string (int state)
......@@ -110,16 +110,16 @@ static char *hcfs2string (int state)
static void ohci_dump_status (struct ohci_hcd *controller)
{
struct ohci_regs *regs = controller->regs;
struct device *dev = controller->hcd.controller;
__u32 temp;
temp = readl (&regs->revision) & 0xff;
dev_dbg (dev, "OHCI %d.%d, %s legacy support registers\n",
ohci_dbg (controller, "OHCI %d.%d, %s legacy support registers\n",
0x03 & (temp >> 4), (temp & 0x0f),
(temp & 0x10) ? "with" : "NO");
temp = readl (&regs->control);
dev_dbg (dev, "control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n", temp,
ohci_dbg (controller,
"control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n", temp,
(temp & OHCI_CTRL_RWE) ? " RWE" : "",
(temp & OHCI_CTRL_RWC) ? " RWC" : "",
(temp & OHCI_CTRL_IR) ? " IR" : "",
......@@ -132,7 +132,7 @@ static void ohci_dump_status (struct ohci_hcd *controller)
);
temp = readl (&regs->cmdstatus);
dev_dbg (dev, "cmdstatus: 0x%08x SOC=%d%s%s%s%s\n", temp,
ohci_dbg (controller, "cmdstatus: 0x%08x SOC=%d%s%s%s%s\n", temp,
(temp & OHCI_SOC) >> 16,
(temp & OHCI_OCR) ? " OCR" : "",
(temp & OHCI_BLF) ? " BLF" : "",
......@@ -140,20 +140,19 @@ static void ohci_dump_status (struct ohci_hcd *controller)
(temp & OHCI_HCR) ? " HCR" : ""
);
ohci_dump_intr_mask (dev, "intrstatus", readl (&regs->intrstatus));
ohci_dump_intr_mask (dev, "intrenable", readl (&regs->intrenable));
ohci_dump_intr_mask (controller, "intrstatus", readl (&regs->intrstatus));
ohci_dump_intr_mask (controller, "intrenable", readl (&regs->intrenable));
// intrdisable always same as intrenable
// ohci_dump_intr_mask (dev, "intrdisable", readl (&regs->intrdisable));
maybe_print_eds (dev, "ed_periodcurrent", readl (&regs->ed_periodcurrent));
maybe_print_eds (controller, "ed_periodcurrent", readl (&regs->ed_periodcurrent));
maybe_print_eds (dev, "ed_controlhead", readl (&regs->ed_controlhead));
maybe_print_eds (dev, "ed_controlcurrent", readl (&regs->ed_controlcurrent));
maybe_print_eds (controller, "ed_controlhead", readl (&regs->ed_controlhead));
maybe_print_eds (controller, "ed_controlcurrent", readl (&regs->ed_controlcurrent));
maybe_print_eds (dev, "ed_bulkhead", readl (&regs->ed_bulkhead));
maybe_print_eds (dev, "ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
maybe_print_eds (controller, "ed_bulkhead", readl (&regs->ed_bulkhead));
maybe_print_eds (controller, "ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
maybe_print_eds (dev, "donehead", readl (&regs->donehead));
maybe_print_eds (controller, "donehead", readl (&regs->donehead));
}
static void ohci_dump_roothub (struct ohci_hcd *controller, int verbose)
......@@ -166,7 +165,7 @@ static void ohci_dump_roothub (struct ohci_hcd *controller, int verbose)
ndp = (temp & RH_A_NDP);
if (verbose) {
dev_dbg (controller->hcd.controller,
ohci_dbg (controller,
"roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d\n", temp,
((temp & RH_A_POTPGT) >> 24) & 0xff,
(temp & RH_A_NOCP) ? " NOCP" : "",
......@@ -177,14 +176,14 @@ static void ohci_dump_roothub (struct ohci_hcd *controller, int verbose)
ndp
);
temp = roothub_b (controller);
dev_dbg (controller->hcd.controller,
ohci_dbg (controller,
"roothub.b: %08x PPCM=%04x DR=%04x\n",
temp,
(temp & RH_B_PPCM) >> 16,
(temp & RH_B_DR)
);
temp = roothub_status (controller);
dev_dbg (controller->hcd.controller,
ohci_dbg (controller,
"roothub.status: %08x%s%s%s%s%s%s\n",
temp,
(temp & RH_HS_CRWE) ? " CRWE" : "",
......@@ -204,13 +203,12 @@ static void ohci_dump_roothub (struct ohci_hcd *controller, int verbose)
static void ohci_dump (struct ohci_hcd *controller, int verbose)
{
dev_dbg (controller->hcd.controller,
"OHCI controller state\n");
ohci_dbg (controller, "OHCI controller state\n");
// dumps some of the state we know about
ohci_dump_status (controller);
if (controller->hcca)
dev_dbg (controller->hcd.controller,
ohci_dbg (controller,
"hcca frame #%04x\n", controller->hcca->frame_no);
ohci_dump_roothub (controller, 1);
}
......@@ -218,11 +216,11 @@ static void ohci_dump (struct ohci_hcd *controller, int verbose)
static const char data0 [] = "DATA0";
static const char data1 [] = "DATA1";
static void ohci_dump_td (char *label, struct td *td)
static void ohci_dump_td (struct ohci_hcd *ohci, char *label, struct td *td)
{
u32 tmp = le32_to_cpup (&td->hwINFO);
dbg ("%s td %p%s; urb %p index %d; hw next td %08x",
ohci_dbg (ohci, "%s td %p%s; urb %p index %d; hw next td %08x",
label, td,
(tmp & TD_DONE) ? " (DONE)" : "",
td->urb, td->index,
......@@ -243,28 +241,28 @@ static void ohci_dump_td (char *label, struct td *td)
case TD_DP_OUT: pid = "OUT"; break;
default: pid = "(bad pid)"; break;
}
dbg (" info %08x CC=%x %s DI=%d %s %s", tmp,
ohci_dbg (ohci, " info %08x CC=%x %s DI=%d %s %s", tmp,
TD_CC_GET(tmp), /* EC, */ toggle,
(tmp & TD_DI) >> 21, pid,
(tmp & TD_R) ? "R" : "");
cbp = le32_to_cpup (&td->hwCBP);
be = le32_to_cpup (&td->hwBE);
dbg (" cbp %08x be %08x (len %d)", cbp, be,
ohci_dbg (ohci, " cbp %08x be %08x (len %d)", cbp, be,
cbp ? (be + 1 - cbp) : 0);
} else {
unsigned i;
dbg (" info %08x CC=%x FC=%d DI=%d SF=%04x", tmp,
ohci_dbg (ohci, " info %08x CC=%x FC=%d DI=%d SF=%04x", tmp,
TD_CC_GET(tmp),
(tmp >> 24) & 0x07,
(tmp & TD_DI) >> 21,
tmp & 0x0000ffff);
dbg (" bp0 %08x be %08x",
ohci_dbg (ohci, " bp0 %08x be %08x",
le32_to_cpup (&td->hwCBP) & ~0x0fff,
le32_to_cpup (&td->hwBE));
for (i = 0; i < MAXPSW; i++) {
u16 psw = le16_to_cpup (&td->hwPSW [i]);
int cc = (psw >> 12) & 0x0f;
dbg (" psw [%d] = %2x, CC=%x %s=%d", i,
ohci_dbg (ohci, " psw [%d] = %2x, CC=%x %s=%d", i,
psw, cc,
(cc >= 0x0e) ? "OFFSET" : "SIZE",
psw & 0x0fff);
......@@ -279,8 +277,9 @@ ohci_dump_ed (struct ohci_hcd *ohci, char *label, struct ed *ed, int verbose)
u32 tmp = ed->hwINFO;
char *type = "";
dbg ("%s: %s, ed %p state 0x%x type %s; next ed %08x",
ohci->hcd.self.bus_name, label,
ohci_dbg (ohci,
"%s, ed %p state 0x%x type %s; next ed %08x\n",
label,
ed, ed->state, edstring (ed->type),
le32_to_cpup (&ed->hwNextED));
switch (tmp & (ED_IN|ED_OUT)) {
......@@ -288,7 +287,8 @@ ohci_dump_ed (struct ohci_hcd *ohci, char *label, struct ed *ed, int verbose)
case ED_IN: type = "-IN"; break;
/* else from TDs ... control */
}
dbg (" info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d", le32_to_cpu (tmp),
ohci_dbg (ohci,
" info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d", le32_to_cpu (tmp),
0x03ff & (le32_to_cpu (tmp) >> 16),
(tmp & ED_DEQUEUE) ? " DQ" : "",
(tmp & ED_ISO) ? " ISO" : "",
......@@ -297,7 +297,8 @@ ohci_dump_ed (struct ohci_hcd *ohci, char *label, struct ed *ed, int verbose)
0x000f & (le32_to_cpu (tmp) >> 7),
type,
0x007f & le32_to_cpu (tmp));
dbg (" tds: head %08x %s%s tail %08x%s",
ohci_dbg (ohci,
" tds: head %08x %s%s tail %08x%s",
tmp = le32_to_cpup (&ed->hwHeadP),
(ed->hwHeadP & ED_C) ? data1 : data0,
(ed->hwHeadP & ED_H) ? " HALT" : "",
......@@ -312,7 +313,7 @@ ohci_dump_ed (struct ohci_hcd *ohci, char *label, struct ed *ed, int verbose)
list_for_each (tmp, &ed->td_list) {
struct td *td;
td = list_entry (tmp, struct td, td_list);
ohci_dump_td (" ->", td);
ohci_dump_td (ohci, " ->", td);
}
}
}
......
......@@ -334,9 +334,11 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
td_free (ohci, ed->dummy);
break;
default:
err ("%s-%s ed %p (#%d) not unlinked; disconnect() bug? %d",
ohci->hcd.self.bus_name, udev->devpath, ed,
i, ed->state);
ohci_err (ohci,
"dev %s ep%d-%s linked; disconnect() bug?\n",
udev->devpath,
(i >> 1) & 0x0f, (i & 1) ? "out" : "in");
/* ED_OPER: some driver disconnect() is broken,
* it didn't even start its unlinks much less wait
* for their completions.
......@@ -356,8 +358,10 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
#ifdef DEBUG
/* a driver->disconnect() returned before its unlinks completed? */
if (in_interrupt ()) {
warn ("disconnect() bug for dev usb-%s-%s ep 0x%x",
ohci->hcd.self.bus_name, udev->devpath, i);
ohci_warn (ohci,
"driver disconnect() bug %s ep%d-%s\n",
udev->devpath,
(i >> 1) & 0x0f, (i & 1) ? "out" : "in");
}
#endif
......@@ -428,7 +432,7 @@ static int hc_reset (struct ohci_hcd *ohci)
temp = 30; /* ... allow extra time */
while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
if (--temp == 0) {
dev_err (ohci->hcd.controller, "USB HC reset timed out!");
ohci_err (ohci, "USB HC reset timed out!\n");
return -1;
}
udelay (1);
......@@ -485,7 +489,7 @@ static int hc_start (struct ohci_hcd *ohci)
*/
if ((readl (&ohci->regs->fminterval) & 0x3fff0000) == 0
|| !readl (&ohci->regs->periodicstart)) {
err ("%s init err", ohci->hcd.self.bus_name);
ohci_err (ohci, "init err\n");
return -EOVERFLOW;
}
......@@ -564,7 +568,7 @@ static void ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
/* cardbus/... hardware gone before remove() */
} else if ((ints = readl (&regs->intrstatus)) == ~(u32)0) {
disable (ohci);
dbg ("%s device removed!", hcd->self.bus_name);
ohci_dbg (ohci, "device removed!\n");
return;
/* interrupt for some other device? */
......@@ -572,13 +576,9 @@ static void ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
return;
}
// dbg ("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no));
if (ints & OHCI_INTR_UE) {
disable (ohci);
err ("OHCI Unrecoverable Error, %s disabled",
hcd->self.bus_name);
ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
// e.g. due to PCI Master/Target Abort
ohci_dump (ohci, 1);
......@@ -613,7 +613,7 @@ static void ohci_stop (struct usb_hcd *hcd)
{
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
dev_dbg (hcd->controller, "stop %s controller%s\n",
ohci_dbg (ohci, "stop %s controller%s\n",
hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS),
ohci->disabled ? " (disabled)" : ""
);
......
......@@ -40,7 +40,7 @@ static u32 roothub_portstatus (struct ohci_hcd *hc, int i)
/*-------------------------------------------------------------------------*/
#define dbg_port(hc,label,num,value) \
dev_dbg (hc->hcd.controller, \
ohci_dbg (hc, \
"%s roothub.portstatus [%d] " \
"= 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
label, num, temp, \
......@@ -75,9 +75,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
if (ports > MAX_ROOT_PORTS) {
if (ohci->disabled)
return -ESHUTDOWN;
err ("%s bogus NDP=%d, rereads as NDP=%d",
hcd->self.bus_name, ports,
readl (&ohci->regs->roothub.a) & RH_A_NDP);
ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n",
ports, readl (&ohci->regs->roothub.a) & RH_A_NDP);
/* retry later; "should not happen" */
return 0;
}
......
......@@ -116,7 +116,7 @@ td_free (struct ohci_hcd *hc, struct td *td)
if (*prev)
*prev = td->td_hash;
else
dev_dbg (hc->hcd.controller, "bad hash for td %p\n", td);
ohci_dbg (hc, "bad hash for td %p\n", td);
pci_pool_free (hc->td_cache, td, td->td_dma);
}
......
......@@ -96,7 +96,7 @@ ohci_pci_start (struct usb_hcd *hcd)
}
if (hc_start (ohci) < 0) {
err ("can't start %s", ohci->hcd.self.bus_name);
ohci_err (ohci, "can't start\n");
ohci_stop (hcd);
return -EBUSY;
}
......@@ -116,13 +116,13 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state)
u16 cmd;
if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER) {
dbg ("can't suspend %s (state is %s)", hcd->self.bus_name,
ohci_dbg (ohci, "can't suspend (state is %s)\n",
hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS));
return -EIO;
}
/* act as if usb suspend can always be used */
dbg ("%s: suspend to %d", hcd->self.bus_name, state);
ohci_dbg (ohci, "suspend to %d\n", state);
ohci->sleeping = 1;
/* First stop processing */
......@@ -157,16 +157,16 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state)
switch (readl (&ohci->regs->control) & OHCI_CTRL_HCFS) {
case OHCI_USB_RESET:
dbg ("%s suspend->reset ?", hcd->self.bus_name);
ohci_dbg (ohci, "suspend->reset ?\n");
break;
case OHCI_USB_RESUME:
dbg ("%s suspend->resume ?", hcd->self.bus_name);
ohci_dbg (ohci, "suspend->resume ?\n");
break;
case OHCI_USB_OPER:
dbg ("%s suspend->operational ?", hcd->self.bus_name);
ohci_dbg (ohci, "suspend->operational ?\n");
break;
case OHCI_USB_SUSPEND:
dbg ("%s suspended", hcd->self.bus_name);
ohci_dbg (ohci, "suspended\n");
break;
}
......@@ -223,13 +223,13 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
switch (temp) {
case OHCI_USB_RESET: // lost power
info ("USB restart: %s", hcd->self.bus_name);
ohci_info (ohci, "USB restart\n");
retval = hc_restart (ohci);
break;
case OHCI_USB_SUSPEND: // host wakeup
case OHCI_USB_RESUME: // remote wakeup
info ("USB continue: %s from %s wakeup", hcd->self.bus_name,
ohci_info (ohci, "USB continue from %s wakeup\n",
(temp == OHCI_USB_SUSPEND)
? "host" : "remote");
ohci->hc_control = OHCI_USB_RESUME;
......@@ -242,7 +242,7 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
temp = readl (&ohci->regs->control);
temp = ohci->hc_control & OHCI_CTRL_HCFS;
if (temp != OHCI_USB_RESUME) {
err ("controller %s won't resume", hcd->self.bus_name);
ohci_err (ohci, "controller won't resume\n");
ohci->disabled = 1;
retval = -EIO;
break;
......@@ -288,11 +288,12 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
writel (OHCI_BLF | OHCI_CLF, &ohci->regs->cmdstatus);
// ohci_dump_status (ohci);
dbg ("sleeping = %d, disabled = %d", ohci->sleeping, ohci->disabled);
ohci_dbg (ohci, "sleeping = %d, disabled = %d\n",
ohci->sleeping, ohci->disabled);
break;
default:
warn ("odd PCI resume for %s", hcd->self.bus_name);
ohci_warn (ohci, "odd PCI resume\n");
}
return retval;
}
......@@ -383,11 +384,11 @@ static struct pci_driver ohci_pci_driver = {
static int __init ohci_hcd_pci_init (void)
{
dbg (DRIVER_INFO " (PCI)");
printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
if (usb_disabled())
return -ENODEV;
dbg ("block sizes: ed %d td %d",
printk (KERN_DEBUG "%s: block sizes: ed %d td %d\n", hcd_name,
sizeof (struct ed), sizeof (struct td));
return pci_module_init (&ohci_pci_driver);
}
......
......@@ -110,12 +110,9 @@ static void periodic_link (struct ohci_hcd *ohci, struct ed *ed)
{
unsigned i;
#ifdef OHCI_VERBOSE_DEBUG
dbg ("%s: link %sed %p branch %d [%dus.], interval %d",
ohci->hcd.self.bus_name,
ohci_vdbg (ohci, "link %sed %p branch %d [%dus.], interval %d\n",
(ed->hwINFO & ED_ISO) ? "iso " : "",
ed, ed->branch, ed->load, ed->interval);
#endif
for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
struct ed **prev = &ohci->periodic [i];
......@@ -206,7 +203,7 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
default:
branch = balance (ohci, ed->interval, ed->load);
if (branch < 0) {
dev_dbg (ohci->hcd.controller,
ohci_dbg (ohci,
"ERR %d, interval %d msecs, load %d\n",
branch, ed->interval, ed->load);
// FIXME if there are TDs queued, fail them!
......@@ -787,7 +784,7 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
}
/* help for troubleshooting: */
dev_dbg (&urb->dev->dev,
ohci_dbg (ohci,
"urb %p usb-%s-%s ep-%d-%s cc %d --> status %d\n",
urb,
urb->dev->bus->bus_name, urb->dev->devpath,
......@@ -821,8 +818,7 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
td = dma_to_td (ohci, td_dma);
if (!td) {
err ("%s bad entry %8x",
ohci->hcd.self.bus_name, td_dma);
ohci_err (ohci, "bad entry %8x\n", td_dma);
break;
}
......
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