diff mbox series

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

Message ID 823ad3165bbcfa61561ff4aac17f41d08e1e91f8.1670724490.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State New, archived
Headers show
Series Try to fix XHCI console on AMD systems (help needed) | expand

Commit Message

Marek Marczykowski-Górecki Dec. 11, 2022, 2:10 a.m. UTC
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@invisiblethingslab.com>
---
 xen/drivers/char/xhci-dbc.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
diff mbox series

Patch

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)