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

[RFC PATCH 3/3] DEBUG: dump xhci state on connection timeout



Debug patch that shows xhci state after some arbitrary (and not very
smart) timeout.

DO NOT MERGE.
The timeout doesn't actually prevent registering the console.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
---
 xen/drivers/char/xhci-dbc.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index 62b0ce88b6bf..cb209332a4be 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -33,7 +33,7 @@
 #include <asm/system.h>
 
 /* uncomment to have dbc_uart_dump() debug function */
-/* #define DBC_DEBUG 1 */
+#define DBC_DEBUG 1
 
 #define DBC_POLL_INTERVAL 100 /* us */
 
@@ -264,6 +264,10 @@ struct dbc {
     uint16_t pci_cr;
 };
 
+#ifdef DBC_DEBUG
+static void dbc_uart_dump(void);
+#endif
+
 static void *dbc_sys_map_xhc(uint64_t phys, size_t size)
 {
     size_t i;
@@ -900,13 +904,23 @@ static void dbc_reset_debug_port(struct dbc *dbc)
 static void dbc_enable_dbc(struct dbc *dbc)
 {
     struct dbc_reg *reg = dbc->dbc_reg;
+    unsigned long timeout = 10000000;
 
     wmb();
     writel(readl(&reg->ctrl) | (1U << DBC_CTRL_DCE), &reg->ctrl);
     wmb();
 
     while ( (readl(&reg->ctrl) & (1U << DBC_CTRL_DCE)) == 0 )
+    {
         cpu_relax();
+        if (!--timeout)
+            break;
+    }
+    if (!timeout)
+    {
+        dbc_error("timeout 1\n");
+        dbc_uart_dump();
+    }
 
     /* reset ports on initial open, to force re-enumerating by the host */
     if ( !dbc->open )
@@ -916,8 +930,18 @@ static void dbc_enable_dbc(struct dbc *dbc)
     writel(readl(&reg->portsc) | (1U << DBC_PSC_PED), &reg->portsc);
     wmb();
 
+    timeout = 1000000;
     while ( (readl(&reg->ctrl) & (1U << DBC_CTRL_DCR)) == 0 )
+    {
         cpu_relax();
+        if (!--timeout)
+            break;
+    }
+    if (!timeout)
+    {
+        dbc_error("timeout 2\n");
+        dbc_uart_dump();
+    }
 }
 
 static void dbc_disable_dbc(struct dbc *dbc)
-- 
git-series 0.9.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.