[RFC 3/3] ohci: rewrite ohci_dump() for dynamic debug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Oliver Neukum <oneukum@xxxxxxx>

As this function is called from interrupt care must
be taken that as little as possible overhead is used
if dynamic debbuging is not enabled.

Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
---
 drivers/usb/host/ohci-dbg.c | 91 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 90 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 5592c2b..2a67971 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -38,6 +38,8 @@
 		*size -= s_len; *next += s_len; \
 	} while (0);
 
+static void ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size);
+
 static void ohci_dump_intr_mask (
 	struct ohci_hcd *ohci,
 	char *label,
@@ -60,6 +62,25 @@ static void ohci_dump_intr_mask (
 		);
 }
 
+static void ohci_print_intr_mask(struct ohci_hcd *ohci,
+				 char *label,
+				 u32 mask)
+{
+	ohci_dbg(ohci, "%s 0x%08x%s%s%s%s%s%s%s%s%s\n",
+		label,
+		mask,
+		(mask & OHCI_INTR_MIE) ? " MIE" : "",
+		(mask & OHCI_INTR_OC) ? " OC" : "",
+		(mask & OHCI_INTR_RHSC) ? " RHSC" : "",
+		(mask & OHCI_INTR_FNO) ? " FNO" : "",
+		(mask & OHCI_INTR_UE) ? " UE" : "",
+		(mask & OHCI_INTR_RD) ? " RD" : "",
+		(mask & OHCI_INTR_SF) ? " SF" : "",
+		(mask & OHCI_INTR_WDH) ? " WDH" : "",
+		(mask & OHCI_INTR_SO) ? " SO" : ""
+		);
+}
+
 static void maybe_print_eds (
 	struct ohci_hcd *ohci,
 	char *label,
@@ -71,6 +92,15 @@ static void maybe_print_eds (
 		ohci_dbg_sw (ohci, next, size, "%s %08x\n", label, value);
 }
 
+static inline void dbg_eds(
+	struct ohci_hcd *ohci,
+	char *label,
+	u32 value)
+{
+	if (value)
+		ohci_dbg(ohci, "%s %08x\n", label, value);
+}
+
 static char *hcfs2string (int state)
 {
 	switch (state) {
@@ -97,6 +127,65 @@ static const char *rh_state_string(struct ohci_hcd *ohci)
 
 // dump control and status registers
 static void
+ohci_print_status(struct ohci_hcd *controller)
+{
+	struct ohci_regs __iomem *regs = controller->regs;
+	struct device *ddev = ohci_to_hcd(controller)->self.controller;
+	u32 temp = 0xffffffff;
+
+	dev_dbg(ddev, "OHCI %d.", 0x03 & ((temp = ohci_readl(controller, &regs->revision) & 0xff)>> 4));
+	dev_dbg(ddev, "%d, %s legacy support registers, rh state %s\n",
+		(temp & 0x0f),
+		(temp & 0x0100) ? "with" : "NO",
+		rh_state_string(controller));
+
+	dev_dbg(ddev, "control 0x%03x", temp = ohci_readl(controller, &regs->control));
+	dev_dbg(ddev, "%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
+		(temp & OHCI_CTRL_RWE) ? " RWE" : "",
+		(temp & OHCI_CTRL_RWC) ? " RWC" : "",
+		(temp & OHCI_CTRL_IR) ? " IR" : "",
+		hcfs2string (temp & OHCI_CTRL_HCFS),
+		(temp & OHCI_CTRL_BLE) ? " BLE" : "",
+		(temp & OHCI_CTRL_CLE) ? " CLE" : "",
+		(temp & OHCI_CTRL_IE) ? " IE" : "",
+		(temp & OHCI_CTRL_PLE) ? " PLE" : "",
+		temp & OHCI_CTRL_CBSR
+		);
+
+	dev_dbg(ddev, "cmdstatus 0x%05x ", temp = ohci_readl(controller, &regs->cmdstatus));
+	dev_dbg(ddev, "SOC=%d%s%s%s%s\n",
+		(temp & OHCI_SOC) >> 16,
+		(temp & OHCI_OCR) ? " OCR" : "",
+		(temp & OHCI_BLF) ? " BLF" : "",
+		(temp & OHCI_CLF) ? " CLF" : "",
+		(temp & OHCI_HCR) ? " HCR" : ""
+		);
+
+	ohci_print_intr_mask(controller, "intrstatus",
+			ohci_readl(controller, &regs->intrstatus));
+	ohci_print_intr_mask(controller, "intrenable",
+			ohci_readl(controller, &regs->intrenable));
+	// intrdisable always same as intrenable
+
+	dbg_eds(controller, "ed_periodcurrent",
+			ohci_readl(controller, &regs->ed_periodcurrent));
+
+	dbg_eds(controller, "ed_controlhead",
+			ohci_readl(controller, &regs->ed_controlhead));
+	dbg_eds(controller, "ed_controlcurrent",
+			ohci_readl(controller, &regs->ed_controlcurrent));
+
+	dbg_eds(controller, "ed_bulkhead",
+			ohci_readl(controller, &regs->ed_bulkhead));
+	dbg_eds(controller, "ed_bulkcurrent",
+			ohci_readl(controller, &regs->ed_bulkcurrent));
+
+	dbg_eds(controller, "donehead",
+			ohci_readl(controller, &regs->donehead));
+}
+
+// dump control and status registers
+static void
 ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size)
 {
 	struct ohci_regs __iomem *regs = controller->regs;
@@ -241,7 +330,7 @@ static void ohci_dump (struct ohci_hcd *controller, int verbose)
 	ohci_dbg (controller, "OHCI controller state\n");
 
 	// dumps some of the state we know about
-	ohci_dump_status (controller, NULL, NULL);
+	ohci_print_status(controller);
 	if (controller->hcca)
 		ohci_dbg (controller,
 			"hcca frame #%04x\n", ohci_frame_no(controller));
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux