All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
@ 2015-11-09  7:38 Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI " Lu Baolu
                   ` (12 more replies)
  0 siblings, 13 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

This patch series adds support for early printk through USB3 debug port.
USB3 debug port is described in xHCI specification as an optional extended
capability.

The first patch adds a file in sysfs, through which users can check
whether the debug capability is supported by a specific host controller,
and the hardware state.

Patch 2 to 10 add the driver for xHCI debug capability. It interfaces with
the register set and provides the required ops (read/write/control) to upper
layers. Early printk is one consumer of these ops. The hooks for early printk
are introduced in patch 9. This design is similar to what we have done in
drivers/usb/early/ehci-dbgp.c.

Patch 11 is a minor change to usb_debug module. This change is required to
bind usb_debug with the USB3 debug device.

Patch 12 is the design document and user guide.

Change log:
v1->v2:
(1) Patch 1 re-implemented. "debugfs" has been replaced with sysfs.
    The scope reduced from all extended capabilities to debug port
    specific.
(2) Patch 11 changed. Removed unnecessary .bulk_out_size setting.

v2->v3:
(1) Patch 11 got acked by Johan Hovold.

Lu Baolu (12):
  usb: xhci: add sysfs file for xHCI debug port
  x86: fixmap: add permanent fixmap for xhci debug port
  usb: xhci: dbc: probe and setup xhci debug capability
  usb: xhci: dbc: add support for Intel xHCI dbc quirk
  usb: xhci: dbc: add debug buffer
  usb: xhci: dbc: add bulk out and bulk in interfaces
  usb: xhci: dbc: handle dbc-configured exit
  usb: xhci: dbc: handle endpoint stall
  x86: early_printk: add USB3 debug port earlyprintk support
  usb: xhci: dbc: add handshake between debug target and host
  usb: serial: usb_debug: add support for dbc debug device
  usb: doc: add document for xHCI DbC driver

 .../ABI/testing/sysfs-bus-pci-drivers-xhci_hcd     |   23 +
 Documentation/kernel-parameters.txt                |    1 +
 Documentation/usb/xhci-dbc.txt                     |  325 +++++
 MAINTAINERS                                        |    8 +
 arch/x86/Kconfig.debug                             |   12 +
 arch/x86/include/asm/fixmap.h                      |    4 +
 arch/x86/kernel/early_printk.c                     |    5 +
 drivers/usb/early/Makefile                         |    1 +
 drivers/usb/early/xhci-dbc.c                       | 1407 ++++++++++++++++++++
 drivers/usb/host/Makefile                          |    2 +-
 drivers/usb/host/xhci-ext-caps.h                   |   14 +-
 drivers/usb/host/xhci-sysfs.c                      |  100 ++
 drivers/usb/host/xhci.c                            |    4 +
 drivers/usb/host/xhci.h                            |    4 +
 drivers/usb/serial/usb_debug.c                     |   28 +-
 include/linux/usb/xhci-dbc.h                       |  224 ++++
 16 files changed, 2157 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
 create mode 100644 Documentation/usb/xhci-dbc.txt
 create mode 100644 drivers/usb/early/xhci-dbc.c
 create mode 100644 drivers/usb/host/xhci-sysfs.c
 create mode 100644 include/linux/usb/xhci-dbc.h

-- 
2.1.4


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI debug port
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-10  9:36   ` Dave Young
  2015-11-09  7:38 ` [PATCH v3 02/12] x86: fixmap: add permanent fixmap for xhci " Lu Baolu
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

This patch adds a sysfs file for users to check 1) whether the debug
capability is implemented by hardware; 2) if supported, which state
does it stay at.

With a host that supports debug port, a file named "debug_port_state"
will be created under the device sysfs directory. Reading this file
will show users the state (disabled, enabled or configured) of the
debug port.

With a host that does NOT support debug port, "debug_port_state" file
won't be created.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 .../ABI/testing/sysfs-bus-pci-drivers-xhci_hcd     |  23 +++++
 drivers/usb/host/Makefile                          |   2 +-
 drivers/usb/host/xhci-ext-caps.h                   |  14 ++-
 drivers/usb/host/xhci-sysfs.c                      | 100 +++++++++++++++++++++
 drivers/usb/host/xhci.c                            |   4 +
 drivers/usb/host/xhci.h                            |   4 +
 6 files changed, 145 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
 create mode 100644 drivers/usb/host/xhci-sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
new file mode 100644
index 0000000..dd3e722
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
@@ -0,0 +1,23 @@
+What:		/sys/bus/pci/drivers/xhci_hcd/.../debug_port_state
+Date:		November 2015
+KernelVersion:	4.3.0
+Contact:	Lu Baolu <baolu.lu@linux.intel.com>
+Description:
+		This file is designed for users to check the state of a
+		USB3 debug port. On a machine which supports USB3 debug
+		port, this file will be created. Reading this file will
+		show the state (disabled, enabled or configured) of the
+		debug port. On a machine that doesn't support USB3 debug
+		port, this file doesn't exist.
+
+		The state of a debug port could be:
+		1) disabled: The debug port is not enabled and the root
+			port has been switched to xHCI host as a normal
+			root port.
+		2) enabled: The debug port is enabled. The debug port
+			has been assigned to debug capability. The debug
+			capability is able to handle the control requests
+			defined in USB3 spec.
+		3) configured: The debug port has been enumerated by the
+			debug host as a debug device. The debug port is
+			in use now.
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e7558ab..810c304 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -12,7 +12,7 @@ fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o
 
 xhci-hcd-y := xhci.o xhci-mem.o
 xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
-xhci-hcd-y += xhci-trace.o
+xhci-hcd-y += xhci-trace.o xhci-sysfs.o
 
 xhci-plat-hcd-y := xhci-plat.o
 ifneq ($(CONFIG_USB_XHCI_MVEBU), )
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index 9fe3225..12c87e5 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -49,8 +49,15 @@
 #define XHCI_EXT_CAPS_PM	3
 #define XHCI_EXT_CAPS_VIRT	4
 #define XHCI_EXT_CAPS_ROUTE	5
-/* IDs 6-9 reserved */
+#define XHCI_EXT_CAPS_LOCALMEM	6
+/* IDs 7-9 reserved */
 #define XHCI_EXT_CAPS_DEBUG	10
+/* IDs 192-255 vendor specific */
+#define XHCI_EXT_CAPS_VEN_START	192
+#define XHCI_EXT_CAPS_VEN_END	255
+#define XHCI_EXT_CAPS_VENDOR(p)	(((p) >= XHCI_EXT_CAPS_VEN_START) && \
+				((p) <= XHCI_EXT_CAPS_VEN_END))
+#define XHCI_EXT_MAX_CAPID	XHCI_EXT_CAPS_VEN_END
 /* USB Legacy Support Capability - section 7.1.1 */
 #define XHCI_HC_BIOS_OWNED	(1 << 16)
 #define XHCI_HC_OS_OWNED	(1 << 24)
@@ -73,6 +80,11 @@
 #define XHCI_HLC               (1 << 19)
 #define XHCI_BLC               (1 << 20)
 
+/* Debug capability - section 7.6.8 */
+#define XHCI_DBC_DCCTRL		0x20
+#define XHCI_DBC_DCCTRL_DCR	(1 << 0)
+#define	XHCI_DBC_DCCTRL_DCE	(1 << 31)
+
 /* command register values to disable interrupts and halt the HC */
 /* start/stop HC execution - do not write unless HC is halted*/
 #define XHCI_CMD_RUN		(1 << 0)
diff --git a/drivers/usb/host/xhci-sysfs.c b/drivers/usb/host/xhci-sysfs.c
new file mode 100644
index 0000000..0192ac4
--- /dev/null
+++ b/drivers/usb/host/xhci-sysfs.c
@@ -0,0 +1,100 @@
+/*
+ * sysfs interface for xHCI host controller driver
+ *
+ * Copyright (C) 2015 Intel Corp.
+ *
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+
+#include "xhci.h"
+
+/*
+ * Return the register offset of a extended capability specified
+ * by @cap_id. Return 0 if @cap_id capability is not supported or
+ * in error cases.
+ */
+static int get_extended_capability_offset(struct xhci_hcd *xhci,
+					int cap_id)
+{
+	u32		cap_reg;
+	unsigned long	flags;
+	int		offset;
+	void __iomem	*base = (void __iomem *) xhci->cap_regs;
+	struct usb_hcd	*hcd = xhci_to_hcd(xhci);
+	int		time_to_leave = XHCI_EXT_MAX_CAPID;
+
+	spin_lock_irqsave(&xhci->lock, flags);
+
+	offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET);
+	if (!HCD_HW_ACCESSIBLE(hcd) || !offset) {
+		spin_unlock_irqrestore(&xhci->lock, flags);
+		return 0;
+	}
+
+	while (time_to_leave--) {
+		cap_reg = readl(base + offset);
+
+		if (XHCI_EXT_CAPS_ID(cap_reg) == cap_id)
+			break;
+
+		offset = xhci_find_next_cap_offset(base, offset);
+		if (!offset)
+			break;
+	}
+
+	spin_unlock_irqrestore(&xhci->lock, flags);
+
+	return offset;
+}
+
+static ssize_t debug_port_state_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int		count = 0, offset;
+	char		*state;
+	void __iomem	*dbc_base;
+	u32		dcctrl_reg;
+	struct xhci_hcd	*xhci = hcd_to_xhci(dev_get_drvdata(dev));
+
+	offset = get_extended_capability_offset(xhci, XHCI_EXT_CAPS_DEBUG);
+	if (!offset)
+		return 0;
+
+	dbc_base = (void __iomem *) xhci->cap_regs + offset;
+	dcctrl_reg = readl(dbc_base + XHCI_DBC_DCCTRL);
+
+	if (!(dcctrl_reg & XHCI_DBC_DCCTRL_DCE))
+		state = "disabled";
+	else if (dcctrl_reg & XHCI_DBC_DCCTRL_DCR)
+		state = "configured";
+	else
+		state = "enabled";
+
+	count = scnprintf(buf, PAGE_SIZE, "%s\n", state);
+
+	return count;
+}
+static DEVICE_ATTR_RO(debug_port_state);
+
+int xhci_sysfs_create_files(struct xhci_hcd *xhci)
+{
+	struct device *dev = xhci_to_hcd(xhci)->self.controller;
+
+	if (get_extended_capability_offset(xhci, XHCI_EXT_CAPS_DEBUG))
+		return device_create_file(dev, &dev_attr_debug_port_state);
+
+	return 0;
+}
+
+void xhci_sysfs_remove_files(struct xhci_hcd *xhci)
+{
+	struct device *dev = xhci_to_hcd(xhci)->self.controller;
+
+	if (get_extended_capability_offset(xhci, XHCI_EXT_CAPS_DEBUG))
+		device_remove_file(dev, &dev_attr_debug_port_state);
+}
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6e7dc6f..583b59f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -651,6 +651,9 @@ int xhci_run(struct usb_hcd *hcd)
 	}
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Finished xhci_run for USB2 roothub");
+
+	xhci_sysfs_create_files(xhci);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(xhci_run);
@@ -684,6 +687,7 @@ void xhci_stop(struct usb_hcd *hcd)
 	xhci_reset(xhci);
 	spin_unlock_irq(&xhci->lock);
 
+	xhci_sysfs_remove_files(xhci);
 	xhci_cleanup_msix(xhci);
 
 	/* Deleting Compliance Mode Recovery Timer */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index be9048e..6bd2e6a 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1950,4 +1950,8 @@ struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_container_
 struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx);
 struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index);
 
+/* xHCI sysfs interfaces */
+int xhci_sysfs_create_files(struct xhci_hcd *xhci);
+void xhci_sysfs_remove_files(struct xhci_hcd *xhci);
+
 #endif /* __LINUX_XHCI_HCD_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 02/12] x86: fixmap: add permanent fixmap for xhci debug port
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI " Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 03/12] usb: xhci: dbc: probe and setup xhci debug capability Lu Baolu
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

xHCI compatible USB3 host controller may provide debug capability
which enables low-level system debug over USB. In order to probing
this debug capability, Linux kernel needs to map and access the
mmio of the host controller during early boot.

This patch adds permenent fixmap pages in fixed_addresses table for
xHCI mmio access.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 arch/x86/include/asm/fixmap.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index f80d700..fbf452f 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -82,6 +82,10 @@ enum fixed_addresses {
 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
 	FIX_OHCI1394_BASE,
 #endif
+#ifdef CONFIG_EARLY_PRINTK_XDBC
+	FIX_XDBC_BASE,
+	FIX_XDBC_END = FIX_XDBC_BASE + 15,
+#endif
 #ifdef CONFIG_X86_LOCAL_APIC
 	FIX_APIC_BASE,	/* local (CPU) APIC) -- required for SMP or not */
 #endif
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 03/12] usb: xhci: dbc: probe and setup xhci debug capability
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI " Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 02/12] x86: fixmap: add permanent fixmap for xhci " Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 04/12] usb: xhci: dbc: add support for Intel xHCI dbc quirk Lu Baolu
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

xHCI debug capability (DbC) is an optional functionality provided
by an xHCI host controller. Software learns this capability by
walking through the extended capability list in mmio of the host.

This patch introduces the code to probe and initialize the debug
capability hardware during early boot. With hardware initialization
done, the debug target (system under debug which has DbC enabled)
will present a debug device through the debug port. The debug device
is fully compliant with the USB framework and provides the equivalent
of a very high performance (USB3) full-duplex serial link between the
debug host and target.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 MAINTAINERS                  |   7 +
 arch/x86/Kconfig.debug       |  12 +
 drivers/usb/early/Makefile   |   1 +
 drivers/usb/early/xhci-dbc.c | 787 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/xhci-dbc.h | 187 ++++++++++
 5 files changed, 994 insertions(+)
 create mode 100644 drivers/usb/early/xhci-dbc.c
 create mode 100644 include/linux/usb/xhci-dbc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 0425167..585a369 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11040,6 +11040,13 @@ S:	Supported
 F:	drivers/usb/host/xhci*
 F:	drivers/usb/host/pci-quirks*
 
+USB XHCI DEBUG PORT
+M:	Lu Baolu <baolu.lu@linux.intel.com>
+L:	linux-usb@vger.kernel.org
+S:	Supported
+F:	drivers/usb/early/xhci-dbc.c
+F:	include/linux/usb/xhci-dbc.h
+
 USB ZD1201 DRIVER
 L:	linux-wireless@vger.kernel.org
 W:	http://linux-lc100020.sourceforge.net
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index d8c0d32..8d95abd 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -65,6 +65,18 @@ config EARLY_PRINTK_EFI
 	  This is useful for kernel debugging when your machine crashes very
 	  early before the console code is initialized.
 
+config EARLY_PRINTK_XDBC
+	bool "Early printk via xHCI debug port"
+	depends on EARLY_PRINTK && PCI
+	---help---
+	  Write kernel log output directly into the xHCI debug port.
+
+	  This is useful for kernel debugging when your machine crashes very
+	  early before the console code is initialized. For normal operation
+	  it is not recommended because it looks ugly and doesn't cooperate
+	  with klogd/syslogd or the X server. You should normally N here,
+	  unless you want to debug such a crash.
+
 config X86_PTDUMP
 	bool "Export kernel pagetable layout to userspace via debugfs"
 	depends on DEBUG_KERNEL
diff --git a/drivers/usb/early/Makefile b/drivers/usb/early/Makefile
index 24bbe51..2db5906 100644
--- a/drivers/usb/early/Makefile
+++ b/drivers/usb/early/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o
+obj-$(CONFIG_EARLY_PRINTK_XDBC) += xhci-dbc.o
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
new file mode 100644
index 0000000..22a1de9
--- /dev/null
+++ b/drivers/usb/early/xhci-dbc.c
@@ -0,0 +1,787 @@
+/**
+ * xhci-dbc.c - xHCI debug capability driver
+ *
+ * Copyright (C) 2015 Intel Corporation
+ *
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ * Some code shared with EHCI debug port and xHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/pci_regs.h>
+#include <linux/pci_ids.h>
+#include <linux/bootmem.h>
+#include <linux/io.h>
+#include <asm/pci-direct.h>
+#include <asm/fixmap.h>
+#include <linux/bcd.h>
+#include <linux/export.h>
+#include <linux/version.h>
+#include <linux/usb/xhci-dbc.h>
+
+#include "../host/xhci.h"
+
+#define	XDBC_PROTOCOL		1	/* GNU Remote Debug Command Set */
+#define	XDBC_VENDOR_ID		0x1d6b	/* Linux Foundation 0x1d6b */
+#define	XDBC_PRODUCT_ID		0x0004	/* __le16 idProduct; device 0004 */
+#define	XDBC_DEVICE_REV		0x0010	/* 0.10 */
+
+static struct xdbc_state xdbc_stat;
+static struct xdbc_state *xdbcp = &xdbc_stat;
+
+#ifdef DBC_DEBUG
+/* place holder */
+#define	xdbc_trace	printk
+static void xdbc_dbg_dump_regs(char *str)
+{
+	if (!xdbcp->xdbc_reg) {
+		xdbc_trace("register not mapped\n");
+		return;
+	}
+
+	xdbc_trace("XDBC registers: %s\n", str);
+	xdbc_trace("  Capability: %08x\n",
+			readl(&xdbcp->xdbc_reg->capability));
+	xdbc_trace("  Door bell: %08x\n",
+			readl(&xdbcp->xdbc_reg->doorbell));
+	xdbc_trace("  Event Ring Segment Table Size: %08x\n",
+			readl(&xdbcp->xdbc_reg->ersts));
+	xdbc_trace("  Event Ring Segment Table Base Address: %16llx\n",
+			xdbc_read64(&xdbcp->xdbc_reg->erstba));
+	xdbc_trace("  Event Ring Dequeue Pointer: %16llx\n",
+			xdbc_read64(&xdbcp->xdbc_reg->erdp));
+	xdbc_trace("  Port status and control: %08x\n",
+			readl(&xdbcp->xdbc_reg->portsc));
+	xdbc_trace("  Debug Capability Context Pointer: %16llx\n",
+			xdbc_read64(&xdbcp->xdbc_reg->dccp));
+	xdbc_trace("  Device Descriptor Info Register 1: %08x\n",
+			readl(&xdbcp->xdbc_reg->devinfo1));
+	xdbc_trace("  Device Descriptor Info Register 2: %08x\n",
+			readl(&xdbcp->xdbc_reg->devinfo2));
+}
+
+static void xdbc_dbg_dump_info_context(char *str)
+{
+	int i;
+	u64 addr;
+	u32 *field;
+
+	if (!xdbcp->dbcc_base)
+		return;
+
+	xdbc_trace("%s:\n", str);
+
+	field = (u32 *)xdbcp->dbcc_base;
+	addr = xdbcp->dbcc_dma;
+	for (i = 0; i < XDBC_INFO_CONTEXT_SIZE;) {
+		xdbc_trace("@%016llx %08x %08x %08x %08x\n",
+			addr,
+			le32_to_cpu(field[i]),
+			le32_to_cpu(field[i + 1]),
+			le32_to_cpu(field[i + 2]),
+			le32_to_cpu(field[i + 3]));
+		addr += 16;
+		i += 4;
+	}
+}
+
+static void xdbc_dbg_dump_erst(char *str)
+{
+	int i;
+	u64 addr = xdbcp->erst_dma;
+	struct xdbc_erst_entry *entry;
+
+	if (!xdbcp->erst_base)
+		return;
+
+	xdbc_trace("%s\n", str);
+
+	for (i = 0; i < xdbcp->erst_size / sizeof(*entry); i++) {
+		entry = (struct xdbc_erst_entry *)xdbcp->erst_base + i;
+		xdbc_trace("@%016llx %08x %08x %08x %08x\n",
+			addr,
+			lower_32_bits(le64_to_cpu(entry->seg_addr)),
+			upper_32_bits(le64_to_cpu(entry->seg_addr)),
+			le32_to_cpu(entry->seg_size),
+			le32_to_cpu(entry->rsvd));
+		addr += sizeof(*entry);
+	}
+}
+
+static void xdbc_dbg_dump_segment(struct xdbc_segment *seg, char *str)
+{
+	int i;
+	u64 addr = seg->dma;
+	struct xdbc_trb *trb;
+
+	if (!seg->trbs)
+		return;
+
+	xdbc_trace("%s\n", str);
+
+	for (i = 0; i < XDBC_TRBS_PER_SEGMENT; i++) {
+		trb = &seg->trbs[i];
+		xdbc_trace("@%016llx %08x %08x %08x %08x\n", addr,
+			le32_to_cpu(trb->field[0]),
+			le32_to_cpu(trb->field[1]),
+			le32_to_cpu(trb->field[2]),
+			le32_to_cpu(trb->field[3]));
+		addr += sizeof(*trb);
+	}
+}
+
+static void xdbc_dbg_dump_string(char *str)
+{
+	u32 *string = (u32 *)xdbcp->string_base;
+	int i, max;
+
+	max = xdbcp->string_size / sizeof(u32);
+
+	xdbc_trace("%s\n", str);
+
+	for (i = 0; i < max; i += 4) {
+		xdbc_trace("@%016llx %08x %08x %08x %08x\n",
+			xdbcp->string_dma + i * 16,
+			le32_to_cpu(string[0]),
+			le32_to_cpu(string[1]),
+			le32_to_cpu(string[2]),
+			le32_to_cpu(string[3]));
+		string += 4;
+	}
+}
+
+static void xdbc_dbg_dump_data(char *str)
+{
+	xdbc_trace("XDBC data structure: %s\n", str);
+	xdbc_dbg_dump_erst("ERST:");
+	xdbc_dbg_dump_segment(&xdbcp->evt_seg, "Event Ring Segment:");
+	xdbc_dbg_dump_segment(&xdbcp->out_seg, "TXout Ring Segment:");
+	xdbc_dbg_dump_segment(&xdbcp->in_seg, "TXin Ring Segment:");
+	xdbc_dbg_dump_info_context("DBCC:");
+	xdbc_dbg_dump_string("String Descriptor:");
+}
+
+#else
+static inline void xdbc_trace(const char *fmt, ...) { }
+static inline void xdbc_dbg_dump_regs(char *str) { }
+static inline void xdbc_dbg_dump_data(char *str) { }
+#endif	/* DBC_DEBUG */
+
+/*
+ * FIXME: kernel provided delay interfaces, like usleep, isn't ready yet
+ *        at the time DbC gets initialized. Below implementation is only
+ *        for x86 platform. Need to reconsider this when porting it onto
+ *        other architectures.
+ */
+static inline void xdbc_udelay(int us)
+{
+	while (us-- > 0)
+		outb(0x1, 0x80);
+}
+
+static void __iomem *xdbc_map_pci_mmio(u32 bus,
+		u32 dev, u32 func, u8 bar, size_t *length)
+{
+	u32 val, sz;
+	u64 val64, sz64, mask64;
+	u8 byte;
+	unsigned long idx, max_idx;
+	void __iomem *base;
+
+	val = read_pci_config(bus, dev, func, bar);
+	write_pci_config(bus, dev, func, bar, ~0);
+	sz = read_pci_config(bus, dev, func, bar);
+	write_pci_config(bus, dev, func, bar, val);
+	if (val == 0xffffffff || sz == 0xffffffff) {
+		xdbc_trace("invalid mmio bar\n");
+		return NULL;
+	}
+
+	val64 = val & PCI_BASE_ADDRESS_MEM_MASK;
+	sz64 = sz & PCI_BASE_ADDRESS_MEM_MASK;
+	mask64 = (u32)PCI_BASE_ADDRESS_MEM_MASK;
+
+	if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
+			PCI_BASE_ADDRESS_MEM_TYPE_64) {
+		val = read_pci_config(bus, dev, func, bar + 4);
+		write_pci_config(bus, dev, func, bar + 4, ~0);
+		sz = read_pci_config(bus, dev, func, bar + 4);
+		write_pci_config(bus, dev, func, bar + 4, val);
+
+		val64 |= ((u64)val << 32);
+		sz64 |= ((u64)sz << 32);
+		mask64 |= ((u64)~0 << 32);
+	}
+
+	sz64 &= mask64;
+
+	if (sizeof(dma_addr_t) < 8 || !sz64) {
+		xdbc_trace("can't handle 64bit BAR\n");
+		return NULL;
+	}
+
+	sz64 = 1ULL << __ffs64(sz64);
+
+	if (sz64 > (FIX_XDBC_END - FIX_XDBC_BASE + 1) * PAGE_SIZE) {
+		xdbc_trace("mmio size beyond 64k not supported\n");
+		return NULL;
+	}
+
+	xdbc_trace("bar: base 0x%llx size 0x%llx offset %03x\n",
+			val64, sz64, bar);
+
+	/* check if the mem space is enabled */
+	byte = read_pci_config_byte(bus, dev, func, PCI_COMMAND);
+	if (!(byte & PCI_COMMAND_MEMORY)) {
+		byte  |= PCI_COMMAND_MEMORY;
+		write_pci_config_byte(bus, dev, func, PCI_COMMAND, byte);
+		xdbc_trace("mmio for xhci enabled\n");
+	}
+
+	/* 64k mmio will be fix-mapped */
+	max_idx = FIX_XDBC_END - FIX_XDBC_BASE;
+	for (idx = 0; idx <= max_idx; idx++)
+		set_fixmap_nocache(FIX_XDBC_BASE + idx,
+			(val64 & PAGE_MASK) + (max_idx - idx) * PAGE_SIZE);
+	base = (void __iomem *)__fix_to_virt(FIX_XDBC_END);
+	base += val64 & ~PAGE_MASK;
+
+	/* save in the state block */
+	xdbcp->bus = bus;
+	xdbcp->dev = dev;
+	xdbcp->func = func;
+	xdbcp->bar = bar;
+	xdbcp->xhci_base = base;
+	xdbcp->xhci_length = sz64;
+
+	if (length)
+		*length = sz64;
+
+	return base;
+}
+
+/*
+ * FIXME: The bootmem allocator isn't ready at the time when DbC gets
+ *        initialized. Below implementation reserves DMA memory blocks
+ *        in the kernel static data segment.
+ */
+static void *xdbc_get_page(dma_addr_t *dma_addr,
+		enum xdbc_page_type type)
+{
+	void *virt;
+	static char event_page[PAGE_SIZE] __aligned(PAGE_SIZE);
+	static char in_ring_page[PAGE_SIZE] __aligned(PAGE_SIZE);
+	static char out_ring_page[PAGE_SIZE] __aligned(PAGE_SIZE);
+	static char table_page[PAGE_SIZE] __aligned(PAGE_SIZE);
+
+	switch (type) {
+	case XDBC_PAGE_EVENT:
+		virt = (void *)event_page;
+		break;
+	case XDBC_PAGE_TXIN:
+		virt = (void *)in_ring_page;
+		break;
+	case XDBC_PAGE_TXOUT:
+		virt = (void *)out_ring_page;
+		break;
+	case XDBC_PAGE_TABLE:
+		virt = (void *)table_page;
+		break;
+	default:
+		return NULL;
+	}
+
+	memset(virt, 0, PAGE_SIZE);
+
+	if (dma_addr)
+		*dma_addr = (dma_addr_t)__pa(virt);
+
+	return virt;
+}
+
+typedef void (*xdbc_walk_excap_cb)(int cap_offset, void *data);
+
+/*
+ * xdbc_walk_excap:
+ *
+ * xHCI extended capability list walker.
+ *
+ * @bus - xHC PCI bus#
+ * @dev - xHC PCI dev#
+ * @func - xHC PCI function#
+ * @cap - capability ID
+ * @oneshot - return immediately once hit match
+ * @cb - call back
+ * @data - callback private data
+ *
+ * Return the last cap offset, otherwize 0.
+ */
+static u32 xdbc_walk_excap(u32 bus, u32 dev, u32 func, int cap,
+		bool oneshot, xdbc_walk_excap_cb cb, void *data)
+{
+	void __iomem *base;
+	int ext_cap_offset, retval = 0;
+	size_t len = 0;
+	u32 val;
+
+	if (xdbcp->xhci_base && xdbcp->xhci_length) {
+		if (xdbcp->bus != bus ||
+				xdbcp->dev != dev ||
+				xdbcp->func != func) {
+			xdbc_trace("only one DbC can be used\n");
+			return 0;
+		}
+
+		len = xdbcp->xhci_length;
+		base = xdbcp->xhci_base;
+	} else {
+		base = xdbc_map_pci_mmio(bus, dev, func,
+				PCI_BASE_ADDRESS_0, &len);
+		if (base == NULL)
+			return 0;
+	}
+
+	ext_cap_offset = xhci_find_next_cap_offset(base,
+			XHCI_HCC_PARAMS_OFFSET);
+	do {
+		if ((ext_cap_offset + sizeof(val)) >= len) {
+			xdbc_trace("malformed extended capability list\n");
+			break;
+		}
+
+		if (!ext_cap_offset)
+			break;
+
+		val = readl(base + ext_cap_offset);
+		if (XHCI_EXT_CAPS_ID(val) == cap) {
+			retval = ext_cap_offset;
+			if (cb)
+				cb(ext_cap_offset, data);
+			if (oneshot)
+				break;
+		}
+		ext_cap_offset = xhci_find_next_cap_offset(base,
+				ext_cap_offset);
+	} while (1);
+
+	return retval;
+}
+
+static u32 __init xdbc_find_dbgp(int xdbc_num,
+		u32 *rbus, u32 *rdev, u32 *rfunc)
+{
+	u32 bus, dev, func, class;
+	unsigned cap;
+
+	for (bus = 0; bus < XDBC_PCI_MAX_BUSES; bus++) {
+		for (dev = 0; dev < XDBC_PCI_MAX_DEVICES; dev++) {
+			for (func = 0; func < XDBC_PCI_MAX_FUNCTION; func++) {
+				class = read_pci_config(bus, dev, func,
+						PCI_CLASS_REVISION);
+				if ((class >> 8) != PCI_CLASS_SERIAL_USB_XHCI)
+					continue;
+
+				if (xdbc_num-- != 0)
+					continue;
+
+				cap = xdbc_walk_excap(bus, dev, func,
+						XHCI_EXT_CAPS_DEBUG,
+						true, NULL, NULL);
+				*rbus = bus;
+				*rdev = dev;
+				*rfunc = func;
+				return cap;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static int handshake(void __iomem *ptr, u32 mask, u32 done,
+		int wait_usec, int delay_usec)
+{
+	u32	result;
+
+	do {
+		result = readl(ptr);
+		result &= mask;
+		if (result == done)
+			return 0;
+		xdbc_udelay(delay_usec);
+		wait_usec -= delay_usec;
+	} while (wait_usec > 0);
+
+	return -ETIMEDOUT;
+}
+
+static void __init xdbc_bios_handoff(void)
+{
+	int ext_cap_offset;
+	int timeout;
+	u32 val;
+
+	ext_cap_offset = xdbc_walk_excap(xdbcp->bus,
+					xdbcp->dev,
+					xdbcp->func,
+					XHCI_EXT_CAPS_LEGACY,
+					true, NULL, NULL);
+	val = readl(xdbcp->xhci_base + ext_cap_offset);
+
+	/* If the BIOS owns the HC, signal that the OS wants it, and wait */
+	if (val & XHCI_HC_BIOS_OWNED) {
+		writel(val | XHCI_HC_OS_OWNED,
+				xdbcp->xhci_base + ext_cap_offset);
+		timeout = handshake(xdbcp->xhci_base + ext_cap_offset,
+				XHCI_HC_BIOS_OWNED, 0, 5000, 10);
+
+		/* Assume a buggy BIOS and take HC ownership anyway */
+		if (timeout) {
+			xdbc_trace("xHCI BIOS handoff failed (BIOS bug ?)\n");
+			writel(val & ~XHCI_HC_BIOS_OWNED,
+					xdbcp->xhci_base + ext_cap_offset);
+		}
+	}
+
+	/* Disable any BIOS SMIs and clear all SMI events*/
+	val = readl(xdbcp->xhci_base + ext_cap_offset +
+			XHCI_LEGACY_CONTROL_OFFSET);
+	val &= XHCI_LEGACY_DISABLE_SMI;
+	val |= XHCI_LEGACY_SMI_EVENTS;
+	writel(val, xdbcp->xhci_base + ext_cap_offset +
+			XHCI_LEGACY_CONTROL_OFFSET);
+}
+
+/*
+ * xdbc_alloc_ring: allocate physical memory for a ring
+ */
+static int xdbc_alloc_ring(struct xdbc_segment *seg,
+		struct xdbc_ring *ring,
+		enum xdbc_page_type type)
+{
+	struct xdbc_trb *link_trb;
+
+	seg->trbs = xdbc_get_page(&seg->dma, type);
+	if (!seg->trbs)
+		return -ENOMEM;
+
+	ring->segment = seg;
+	ring->enqueue = seg->trbs;
+	ring->dequeue = seg->trbs;
+	ring->cycle_state = 1;
+
+	if (type == XDBC_PAGE_TXIN || type == XDBC_PAGE_TXOUT) {
+		link_trb = &seg->trbs[XDBC_TRBS_PER_SEGMENT - 1];
+		link_trb->field[0] = cpu_to_le32(lower_32_bits(seg->dma));
+		link_trb->field[1] = cpu_to_le32(upper_32_bits(seg->dma));
+		link_trb->field[3] = cpu_to_le32(TRB_TYPE(TRB_LINK)) |
+				cpu_to_le32(LINK_TOGGLE);
+	}
+
+	return 0;
+}
+
+static inline void xdbc_put_utf16(u16 *s, const char *c, size_t size)
+{
+	int i;
+
+	for (i = 0; i < size; i++)
+		s[i] = cpu_to_le16(c[i]);
+}
+
+static int xdbc_mem_init(void)
+{
+	struct xdbc_erst_entry *entry;
+	struct xdbc_strings *strings;
+	struct xdbc_context *context;
+	struct xdbc_ep_context *ep_in, *ep_out;
+	struct usb_string_descriptor *s_desc;
+	unsigned int max_burst;
+	u32 string_length;
+	int ret, index = 0;
+	u32 dev_info;
+
+	/* allocate table page */
+	xdbcp->table_base = xdbc_get_page(&xdbcp->table_dma,
+			XDBC_PAGE_TABLE);
+	if (!xdbcp->table_base) {
+		xdbc_trace("falied to alloc table page\n");
+		return -ENOMEM;
+	}
+
+	/* allocate and initialize event ring */
+	ret = xdbc_alloc_ring(&xdbcp->evt_seg, &xdbcp->evt_ring,
+			XDBC_PAGE_EVENT);
+	if (ret < 0) {
+		xdbc_trace("failed to alloc event ring\n");
+		return ret;
+	}
+
+	/* allocate event ring segment table */
+	xdbcp->erst_size = 16;
+	xdbcp->erst_base = xdbcp->table_base +
+			index * XDBC_TABLE_ENTRY_SIZE;
+	xdbcp->erst_dma = xdbcp->table_dma +
+			index * XDBC_TABLE_ENTRY_SIZE;
+	index += XDBC_ERST_ENTRY_NUM;
+
+	/* Initialize Event Ring Segment Table */
+	entry = (struct xdbc_erst_entry *)xdbcp->erst_base;
+	entry->seg_addr = cpu_to_le64(xdbcp->evt_seg.dma);
+	entry->seg_size = cpu_to_le32(XDBC_TRBS_PER_SEGMENT);
+	entry->rsvd = 0;
+
+	/* Initialize ERST registers */
+	writel(1, &xdbcp->xdbc_reg->ersts);
+	xdbc_write64(xdbcp->erst_dma, &xdbcp->xdbc_reg->erstba);
+	xdbc_write64(xdbcp->evt_seg.dma, &xdbcp->xdbc_reg->erdp);
+
+	/* debug capability contexts */
+	BUILD_BUG_ON(sizeof(struct xdbc_info_context) != 64);
+	BUILD_BUG_ON(sizeof(struct xdbc_ep_context) != 64);
+	BUILD_BUG_ON(sizeof(struct xdbc_context) != 64 * 3);
+
+	xdbcp->dbcc_size = 64 * 3;
+	xdbcp->dbcc_base = xdbcp->table_base +
+			index * XDBC_TABLE_ENTRY_SIZE;
+	xdbcp->dbcc_dma = xdbcp->table_dma +
+			index * XDBC_TABLE_ENTRY_SIZE;
+	index += XDBC_DBCC_ENTRY_NUM;
+
+	/* IN/OUT endpoint transfer ring */
+	ret = xdbc_alloc_ring(&xdbcp->in_seg, &xdbcp->in_ring,
+			XDBC_PAGE_TXIN);
+	if (ret < 0) {
+		xdbc_trace("failed to alloc IN transfer ring\n");
+		return ret;
+	}
+
+	ret = xdbc_alloc_ring(&xdbcp->out_seg, &xdbcp->out_ring,
+			XDBC_PAGE_TXOUT);
+	if (ret < 0) {
+		xdbc_trace("failed to alloc OUT transfer ring\n");
+		return ret;
+	}
+
+	/* strings */
+	xdbcp->string_size = sizeof(struct xdbc_strings);
+	xdbcp->string_base = xdbcp->table_base +
+			index * XDBC_TABLE_ENTRY_SIZE;
+	xdbcp->string_dma = xdbcp->table_dma +
+			index * XDBC_TABLE_ENTRY_SIZE;
+	index += XDBC_STRING_ENTRY_NUM;
+
+	strings = (struct xdbc_strings *)xdbcp->string_base;
+
+	/* serial string */
+	s_desc = (struct usb_string_descriptor *)strings->serial;
+	s_desc->bLength = (strlen(XDBC_STRING_SERIAL) + 1) * 2;
+	s_desc->bDescriptorType = USB_DT_STRING;
+	xdbc_put_utf16(s_desc->wData, XDBC_STRING_SERIAL,
+			strlen(XDBC_STRING_SERIAL));
+
+	string_length = s_desc->bLength;
+	string_length <<= 8;
+
+	/* product string */
+	s_desc = (struct usb_string_descriptor *)strings->product;
+	s_desc->bLength = (strlen(XDBC_STRING_PRODUCT) + 1) * 2;
+	s_desc->bDescriptorType = USB_DT_STRING;
+	xdbc_put_utf16(s_desc->wData, XDBC_STRING_PRODUCT,
+			strlen(XDBC_STRING_PRODUCT));
+
+	string_length += s_desc->bLength;
+	string_length <<= 8;
+
+	/* manufacture string */
+	s_desc = (struct usb_string_descriptor *)strings->manufacture;
+	s_desc->bLength = (strlen(XDBC_STRING_MANUFACTURE) + 1) * 2;
+	s_desc->bDescriptorType = USB_DT_STRING;
+	xdbc_put_utf16(s_desc->wData, XDBC_STRING_MANUFACTURE,
+			strlen(XDBC_STRING_MANUFACTURE));
+
+	string_length += s_desc->bLength;
+	string_length <<= 8;
+
+	/* string 0 */
+	strings->string0[0] = 4;
+	strings->string0[1] = USB_DT_STRING;
+	strings->string0[2] = 0x09;
+	strings->string0[3] = 0x04;
+
+	string_length += 4;
+
+	/* populate the contexts */
+	context = (struct xdbc_context *)xdbcp->dbcc_base;
+	context->info.string0 = cpu_to_le64(xdbcp->string_dma);
+	context->info.manufacture = cpu_to_le64(xdbcp->string_dma +
+			XDBC_MAX_STRING_LENGTH);
+	context->info.product = cpu_to_le64(xdbcp->string_dma +
+			XDBC_MAX_STRING_LENGTH * 2);
+	context->info.serial = cpu_to_le64(xdbcp->string_dma +
+			XDBC_MAX_STRING_LENGTH * 3);
+	context->info.length = cpu_to_le32(string_length);
+
+	max_burst = DEBUG_MAX_BURST(readl(&xdbcp->xdbc_reg->control));
+	ep_out = (struct xdbc_ep_context *)&context->out;
+	ep_out->ep_info1 = 0;
+	ep_out->ep_info2 = cpu_to_le32(EP_TYPE(BULK_OUT_EP) |
+			MAX_PACKET(1024) | MAX_BURST(max_burst));
+	ep_out->deq = cpu_to_le64(xdbcp->out_seg.dma |
+			xdbcp->out_ring.cycle_state);
+
+	ep_in = (struct xdbc_ep_context *)&context->in;
+	ep_in->ep_info1 = 0;
+	ep_in->ep_info2 = cpu_to_le32(EP_TYPE(BULK_OUT_EP) |
+			MAX_PACKET(1024) | MAX_BURST(max_burst));
+	ep_in->deq = cpu_to_le64(xdbcp->in_seg.dma |
+			xdbcp->in_ring.cycle_state);
+
+	/* write DbC context pointer register */
+	xdbc_write64(xdbcp->dbcc_dma, &xdbcp->xdbc_reg->dccp);
+
+	/* device descriptor info registers */
+	dev_info = cpu_to_le32((XDBC_VENDOR_ID << 16) | XDBC_PROTOCOL);
+	writel(dev_info, &xdbcp->xdbc_reg->devinfo1);
+	dev_info = cpu_to_le32((XDBC_DEVICE_REV << 16) | XDBC_PRODUCT_ID);
+	writel(dev_info, &xdbcp->xdbc_reg->devinfo2);
+
+	return 0;
+}
+
+/*
+ * xdbc_start: start DbC
+ *
+ * Set DbC enable bit and wait until DbC run bit being set or timed out.
+ */
+static int xdbc_start(void)
+{
+	u32 ctrl, status;
+
+	ctrl = readl(&xdbcp->xdbc_reg->control);
+	writel(ctrl | CTRL_DCE | CTRL_LSE, &xdbcp->xdbc_reg->control);
+
+	if (handshake(&xdbcp->xdbc_reg->control, CTRL_DCE,
+			CTRL_DCE, 100000, 100) < 0) {
+		xdbc_trace("falied to initialize hardware\n");
+		return -ENODEV;
+	}
+
+	/* wait for port connection */
+	if (handshake(&xdbcp->xdbc_reg->portsc, PORTSC_CCS,
+			PORTSC_CCS, 5000000, 100) < 0) {
+		xdbc_trace("waiting for connection timed out\n");
+		return -ETIMEDOUT;
+	}
+	xdbc_trace("port connection detected\n");
+
+	/* wait for debug device to be configured */
+	if (handshake(&xdbcp->xdbc_reg->control, CTRL_DCR,
+			CTRL_DCR, 5000000, 100) < 0) {
+		xdbc_trace("waiting for device configuration timed out\n");
+		return -ETIMEDOUT;
+	}
+
+	/* port should have a valid port# */
+	status = readl(&xdbcp->xdbc_reg->status);
+	if (!DCST_DPN(status)) {
+		xdbc_trace("invalid root hub port number\n");
+		return -ENODEV;
+	}
+
+	xdbc_trace("root hub port number %d\n", DCST_DPN(status));
+
+	xdbc_trace("DbC is running now, control 0x%08x\n",
+			readl(&xdbcp->xdbc_reg->control));
+
+	return 0;
+}
+
+static int xdbc_setup(void)
+{
+	int ret;
+
+	writel(0, &xdbcp->xdbc_reg->control);
+	if (handshake(&xdbcp->xdbc_reg->control, CTRL_DCE,
+			0, 100000, 100) < 0) {
+		xdbc_trace("falied to initialize hardware\n");
+		return -ETIMEDOUT;
+	}
+
+	/* allocate and initialize all memory data structures */
+	ret = xdbc_mem_init();
+	if (ret < 0) {
+		xdbc_trace("failed to initialize memory\n");
+		return ret;
+	}
+
+	/*
+	 * Memory barrier to ensure hardware sees the bits
+	 * setting above.
+	 */
+	mmiowb();
+
+	/* dump registers and data structures */
+	xdbc_dbg_dump_regs("hardware setup completed");
+	xdbc_dbg_dump_data("hardware setup completed");
+
+	ret = xdbc_start();
+	if (ret < 0) {
+		xdbc_trace("failed to start DbC, cable connected?\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+int __init early_xdbc_init(char *s)
+{
+	u32 bus = 0, dev = 0, func = 0;
+	unsigned long dbgp_num = 0;
+	u32 offset;
+	int ret;
+
+	if (!early_pci_allowed())
+		return -EPERM;
+
+	/* FIXME: early printk "keep" option will be supported later */
+	if (strstr(s, "keep"))
+		return -EPERM;
+
+	if (xdbcp->xdbc_reg)
+		return 0;
+
+	if (*s && kstrtoul(s, 0, &dbgp_num))
+		dbgp_num = 0;
+
+	xdbc_trace("dbgp_num: %lu\n", dbgp_num);
+
+	offset = xdbc_find_dbgp(dbgp_num, &bus, &dev, &func);
+	if (!offset)
+		return -ENODEV;
+
+	xdbc_trace("Found xHCI debug capability on %02x:%02x.%1x\n",
+			bus, dev, func);
+
+	if (!xdbcp->xhci_base)
+		return -EINVAL;
+
+	xdbcp->xdbc_reg = (struct xdbc_regs __iomem *)
+			(xdbcp->xhci_base + offset);
+	xdbc_dbg_dump_regs("debug capability located");
+
+	/* hand over the owner of host from BIOS */
+	xdbc_bios_handoff();
+
+	ret = xdbc_setup();
+	if (ret < 0) {
+		pr_notice("failed to setup xHCI DbC connection\n");
+		xdbcp->xhci_base = NULL;
+		xdbcp->xdbc_reg = NULL;
+		return ret;
+	}
+
+	return 0;
+}
diff --git a/include/linux/usb/xhci-dbc.h b/include/linux/usb/xhci-dbc.h
new file mode 100644
index 0000000..153fb87
--- /dev/null
+++ b/include/linux/usb/xhci-dbc.h
@@ -0,0 +1,187 @@
+/*
+ * xHCI debug capability driver
+ *
+ * Copyright (C) 2015 Intel Corporation
+ *
+ * Author: Lu Baolu <baolu.lu@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_XHCI_DBC_H
+#define __LINUX_XHCI_DBC_H
+
+#include <linux/types.h>
+#include <linux/usb/ch9.h>
+
+/**
+ * struct xdbc_regs - xHCI Debug Capability Register interface.
+ */
+struct xdbc_regs {
+	__le32	capability;
+	__le32	doorbell;
+	__le32	ersts;		/* Event Ring Segment Table Size*/
+	__le32	rvd0;		/* 0c~0f reserved bits */
+	__le64	erstba;		/* Event Ring Segment Table Base Address */
+	__le64	erdp;		/* Event Ring Dequeue Pointer */
+	__le32	control;
+#define	DEBUG_MAX_BURST(p)	(((p) >> 16) & 0xff)
+#define	CTRL_DCR		(1 << 0)	/* DbC Run */
+#define	CTRL_PED		(1 << 1)	/* Port Enable/Disable */
+#define	CTRL_HOT		(1 << 2)	/* Halt Out TR */
+#define	CTRL_HIT		(1 << 3)	/* Halt In TR */
+#define	CTRL_DRC		(1 << 4)	/* DbC run change */
+#define	CTRL_DCE		(1 << 31)	/* DbC enable */
+#define	CTRL_LSE		(1 << 1)
+	__le32	status;
+#define	DCST_DPN(p)		(((p) >> 24) & 0xff)
+	__le32	portsc;		/* Port status and control */
+#define	PORTSC_CCS		(1 << 0)
+#define	PORTSC_CSC		(1 << 17)
+#define	PORTSC_PRC		(1 << 21)
+#define	PORTSC_PLC		(1 << 22)
+#define	PORTSC_CEC		(1 << 23)
+	__le32	rvd1;		/* 2b~28 reserved bits */
+	__le64	dccp;		/* Debug Capability Context Pointer */
+	__le32	devinfo1;	/* Device Descriptor Info Register 1 */
+	__le32	devinfo2;	/* Device Descriptor Info Register 2 */
+};
+
+/*
+ * xHCI Debug Capability data structures
+ */
+struct xdbc_trb {
+	__le32 field[4];
+};
+
+struct xdbc_erst_entry {
+	__le64	seg_addr;
+	__le32	seg_size;
+	__le32	rsvd;
+};
+
+struct xdbc_info_context {
+	__le64	string0;
+	__le64	manufacture;
+	__le64	product;
+	__le64	serial;
+	__le32	length;
+	__le32	rsvdz[7];
+};
+
+struct xdbc_ep_context {
+	__le32	ep_info1;
+	__le32	ep_info2;
+	__le64	deq;
+	__le32	tx_info;
+	__le32	rsvd0[11];
+};
+
+struct xdbc_context {
+	struct xdbc_info_context	info;
+	struct xdbc_ep_context		out;
+	struct xdbc_ep_context		in;
+};
+
+#define	XDBC_INFO_CONTEXT_SIZE		48
+
+#define	XDBC_MAX_STRING_LENGTH		64
+#define	XDBC_STRING_MANUFACTURE		"Linux"
+#define	XDBC_STRING_PRODUCT		"Remote GDB"
+#define	XDBC_STRING_SERIAL		"0001"
+struct xdbc_strings {
+	char	string0[XDBC_MAX_STRING_LENGTH];
+	char	manufacture[XDBC_MAX_STRING_LENGTH];
+	char	product[XDBC_MAX_STRING_LENGTH];
+	char	serial[XDBC_MAX_STRING_LENGTH];
+};
+
+/*
+ * software state structure
+ */
+struct xdbc_segment {
+	struct xdbc_trb		*trbs;
+	dma_addr_t		dma;
+};
+
+#define	XDBC_TRBS_PER_SEGMENT	256
+
+struct xdbc_ring {
+	struct xdbc_segment	*segment;
+	struct xdbc_trb		*enqueue;
+	struct xdbc_trb		*dequeue;
+	u32			cycle_state;
+};
+
+enum xdbc_page_type {
+	XDBC_PAGE_EVENT,
+	XDBC_PAGE_TXIN,
+	XDBC_PAGE_TXOUT,
+	XDBC_PAGE_TABLE,
+};
+
+struct xdbc_state {
+	/* pci device info*/
+	u32		bus;
+	u32		dev;
+	u32		func;
+	u8		bar;
+	void __iomem	*xhci_base;
+	size_t		xhci_length;
+#define	XDBC_PCI_MAX_BUSES		256
+#define	XDBC_PCI_MAX_DEVICES		32
+#define	XDBC_PCI_MAX_FUNCTION		8
+
+	/* DbC register base */
+	struct		xdbc_regs __iomem *xdbc_reg;
+
+	/* DbC table page */
+	dma_addr_t	table_dma;
+	void		*table_base;
+
+#define	XDBC_TABLE_ENTRY_SIZE		64
+#define	XDBC_ERST_ENTRY_NUM		1
+#define	XDBC_DBCC_ENTRY_NUM		3
+#define	XDBC_STRING_ENTRY_NUM		4
+
+	/* event ring segment table */
+	dma_addr_t	erst_dma;
+	size_t		erst_size;
+	void		*erst_base;
+
+	/* event ring segments */
+	struct xdbc_ring	evt_ring;
+	struct xdbc_segment	evt_seg;
+
+	/* debug capability contexts */
+	dma_addr_t	dbcc_dma;
+	size_t		dbcc_size;
+	void		*dbcc_base;
+
+	/* descriptor strings */
+	dma_addr_t	string_dma;
+	size_t		string_size;
+	void		*string_base;
+
+	/* bulk OUT endpoint */
+	struct xdbc_ring	out_ring;
+	struct xdbc_segment	out_seg;
+
+	/* bulk IN endpoint */
+	struct xdbc_ring	in_ring;
+	struct xdbc_segment	in_seg;
+};
+
+#define	XDBC_MAX_PACKET		1024
+
+/* door bell target */
+#define	OUT_EP_DOORBELL		0
+#define	IN_EP_DOORBELL		1
+#define	DOOR_BELL_TARGET(p)	(((p) & 0xff) << 8)
+
+#define	xdbc_read64(regs)	xhci_read_64(NULL, (regs))
+#define	xdbc_write64(val, regs)	xhci_write_64(NULL, (val), (regs))
+
+#endif /* __LINUX_XHCI_DBC_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 04/12] usb: xhci: dbc: add support for Intel xHCI dbc quirk
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (2 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 03/12] usb: xhci: dbc: probe and setup xhci debug capability Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 05/12] usb: xhci: dbc: add debug buffer Lu Baolu
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

On Intel platform, if the debug target is connected with debug
host, enabling DCE bit in command register leads to a hung bus
state. In the hung state, the host system will not see a port
connected status bit set. Hence debug target fails to be probed.

The state could be resolved by performing a port reset to the
debug port from the host xHCI. This patch introduces this work
around.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/early/xhci-dbc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/xhci-dbc.h |  2 ++
 2 files changed, 54 insertions(+)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 22a1de9..6b23f09 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -255,6 +255,8 @@ static void __iomem *xdbc_map_pci_mmio(u32 bus,
 	xdbcp->bar = bar;
 	xdbcp->xhci_base = base;
 	xdbcp->xhci_length = sz64;
+	xdbcp->vendor = read_pci_config_16(bus, dev, func, PCI_VENDOR_ID);
+	xdbcp->device = read_pci_config_16(bus, dev, func, PCI_DEVICE_ID);
 
 	if (length)
 		*length = sz64;
@@ -651,6 +653,52 @@ static int xdbc_mem_init(void)
 	return 0;
 }
 
+static void xdbc_reset_debug_port_callback(int cap_offset, void *data)
+{
+	u8 major;
+	u32 val, port_offset, port_count;
+	u32 cap_length;
+	void __iomem *ops_reg;
+	void __iomem *portsc;
+	int i;
+
+	val = readl(xdbcp->xhci_base + cap_offset);
+	major = (u8) XHCI_EXT_PORT_MAJOR(val);
+
+	/* only reset super-speed port */
+	if (major != 0x3)
+		return;
+
+	val = readl(xdbcp->xhci_base + cap_offset + 8);
+	port_offset = XHCI_EXT_PORT_OFF(val);
+	port_count = XHCI_EXT_PORT_COUNT(val);
+	xdbc_trace("Extcap Port offset %d count %d\n",
+			port_offset, port_count);
+
+	cap_length = readl(xdbcp->xhci_base) & 0xff;
+	ops_reg = xdbcp->xhci_base + cap_length;
+
+	port_offset--;
+	for (i = port_offset; i < (port_offset + port_count); i++) {
+		portsc = ops_reg + 0x400 + i * 0x10;
+		val = readl(portsc);
+		/* reset the port if CCS bit is cleared */
+		if (!(val & 0x1))
+			writel(val | (1 << 4), portsc);
+	}
+}
+
+static void xdbc_reset_debug_port(void)
+{
+	xdbc_walk_excap(xdbcp->bus,
+			xdbcp->dev,
+			xdbcp->func,
+			XHCI_EXT_CAPS_PROTOCOL,
+			false,
+			xdbc_reset_debug_port_callback,
+			NULL);
+}
+
 /*
  * xdbc_start: start DbC
  *
@@ -669,6 +717,10 @@ static int xdbc_start(void)
 		return -ENODEV;
 	}
 
+	/* reset port to avoid bus hang */
+	if (xdbcp->vendor == PCI_VENDOR_ID_INTEL)
+		xdbc_reset_debug_port();
+
 	/* wait for port connection */
 	if (handshake(&xdbcp->xdbc_reg->portsc, PORTSC_CCS,
 			PORTSC_CCS, 5000000, 100) < 0) {
diff --git a/include/linux/usb/xhci-dbc.h b/include/linux/usb/xhci-dbc.h
index 153fb87..fc0ef9a 100644
--- a/include/linux/usb/xhci-dbc.h
+++ b/include/linux/usb/xhci-dbc.h
@@ -128,6 +128,8 @@ struct xdbc_state {
 	u32		dev;
 	u32		func;
 	u8		bar;
+	u16		vendor;
+	u16		device;
 	void __iomem	*xhci_base;
 	size_t		xhci_length;
 #define	XDBC_PCI_MAX_BUSES		256
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 05/12] usb: xhci: dbc: add debug buffer
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (3 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 04/12] usb: xhci: dbc: add support for Intel xHCI dbc quirk Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 06/12] usb: xhci: dbc: add bulk out and bulk in interfaces Lu Baolu
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

"printk" is not suitable for dbc debugging especially when console
is in usage. This patch adds a debug buffer in dbc driver and puts
the debug messages in this local buffer. The debug buffer could be
dumped whenever the console is not in use. This part of code will
not be visible unless DBC_DEBUG is defined.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/early/xhci-dbc.c | 62 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 6b23f09..b36a527 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -32,8 +32,64 @@ static struct xdbc_state xdbc_stat;
 static struct xdbc_state *xdbcp = &xdbc_stat;
 
 #ifdef DBC_DEBUG
-/* place holder */
-#define	xdbc_trace	printk
+#define	XDBC_DEBUG_BUF_SIZE	(PAGE_SIZE * 32)
+#define	MSG_MAX_LINE		128
+static char xdbc_debug_buf[XDBC_DEBUG_BUF_SIZE];
+static void xdbc_trace(const char *fmt, ...)
+{
+	int i, size;
+	va_list args;
+	static int pos;
+	char temp_buf[MSG_MAX_LINE];
+
+	if (pos >= XDBC_DEBUG_BUF_SIZE - 1)
+		return;
+
+	memset(temp_buf, 0, MSG_MAX_LINE);
+	va_start(args, fmt);
+	vsnprintf(temp_buf, MSG_MAX_LINE - 1, fmt, args);
+	va_end(args);
+
+	i = 0;
+	size = strlen(temp_buf);
+	while (i < size) {
+		xdbc_debug_buf[pos] = temp_buf[i];
+		pos++;
+		i++;
+
+		if (pos >= XDBC_DEBUG_BUF_SIZE - 1)
+			break;
+	}
+}
+
+static void xdbc_dump_debug_buffer(void)
+{
+	int index = 0;
+	int count = 0;
+	char dump_buf[MSG_MAX_LINE];
+
+	xdbc_trace("The end of DbC trace buffer\n");
+	pr_notice("DBC debug buffer:\n");
+	memset(dump_buf, 0, MSG_MAX_LINE);
+
+	while (index < XDBC_DEBUG_BUF_SIZE) {
+		if (!xdbc_debug_buf[index])
+			break;
+
+		if (xdbc_debug_buf[index] == '\n' ||
+				count >= MSG_MAX_LINE - 1) {
+			pr_notice("DBC: @%08x %s\n", index, dump_buf);
+			memset(dump_buf, 0, MSG_MAX_LINE);
+			count = 0;
+		} else {
+			dump_buf[count] = xdbc_debug_buf[index];
+			count++;
+		}
+
+		index++;
+	}
+}
+
 static void xdbc_dbg_dump_regs(char *str)
 {
 	if (!xdbcp->xdbc_reg) {
@@ -165,6 +221,7 @@ static void xdbc_dbg_dump_data(char *str)
 
 #else
 static inline void xdbc_trace(const char *fmt, ...) { }
+static inline void xdbc_dump_debug_buffer(void) { }
 static inline void xdbc_dbg_dump_regs(char *str) { }
 static inline void xdbc_dbg_dump_data(char *str) { }
 #endif	/* DBC_DEBUG */
@@ -832,6 +889,7 @@ int __init early_xdbc_init(char *s)
 		pr_notice("failed to setup xHCI DbC connection\n");
 		xdbcp->xhci_base = NULL;
 		xdbcp->xdbc_reg = NULL;
+		xdbc_dump_debug_buffer();
 		return ret;
 	}
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 06/12] usb: xhci: dbc: add bulk out and bulk in interfaces
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (4 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 05/12] usb: xhci: dbc: add debug buffer Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 07/12] usb: xhci: dbc: handle dbc-configured exit Lu Baolu
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

This patch adds interfaces for bulk out and bulk in ops. These
interfaces could be used to implement early printk bootconsole
or hook to various system debuggers.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/early/xhci-dbc.c | 373 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/xhci-dbc.h |  30 ++++
 2 files changed, 403 insertions(+)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index b36a527..f51daa4 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -219,11 +219,21 @@ static void xdbc_dbg_dump_data(char *str)
 	xdbc_dbg_dump_string("String Descriptor:");
 }
 
+static void xdbc_dbg_dump_trb(struct xdbc_trb *trb, char *str)
+{
+	xdbc_trace("DBC trb: %s\n", str);
+	xdbc_trace("@%016llx %08x %08x %08x %08x\n", (u64)__pa(trb),
+				le32_to_cpu(trb->field[0]),
+				le32_to_cpu(trb->field[1]),
+				le32_to_cpu(trb->field[2]),
+				le32_to_cpu(trb->field[3]));
+}
 #else
 static inline void xdbc_trace(const char *fmt, ...) { }
 static inline void xdbc_dump_debug_buffer(void) { }
 static inline void xdbc_dbg_dump_regs(char *str) { }
 static inline void xdbc_dbg_dump_data(char *str) { }
+static inline void xdbc_dbg_dump_trb(struct xdbc_trb *trb, char *str) { }
 #endif	/* DBC_DEBUG */
 
 /*
@@ -334,6 +344,7 @@ static void *xdbc_get_page(dma_addr_t *dma_addr,
 	static char in_ring_page[PAGE_SIZE] __aligned(PAGE_SIZE);
 	static char out_ring_page[PAGE_SIZE] __aligned(PAGE_SIZE);
 	static char table_page[PAGE_SIZE] __aligned(PAGE_SIZE);
+	static char bulk_buf_page[PAGE_SIZE] __aligned(PAGE_SIZE);
 
 	switch (type) {
 	case XDBC_PAGE_EVENT:
@@ -348,6 +359,9 @@ static void *xdbc_get_page(dma_addr_t *dma_addr,
 	case XDBC_PAGE_TABLE:
 		virt = (void *)table_page;
 		break;
+	case XDBC_PAGE_BUFFER:
+		virt = (void *)bulk_buf_page;
+		break;
 	default:
 		return NULL;
 	}
@@ -707,6 +721,12 @@ static int xdbc_mem_init(void)
 	dev_info = cpu_to_le32((XDBC_DEVICE_REV << 16) | XDBC_PRODUCT_ID);
 	writel(dev_info, &xdbcp->xdbc_reg->devinfo2);
 
+	/* get and store the transfer buffer */
+	xdbcp->out_buf = xdbc_get_page(&xdbcp->out_dma,
+			XDBC_PAGE_BUFFER);
+	xdbcp->in_buf = xdbcp->out_buf + XDBC_MAX_PACKET;
+	xdbcp->in_dma = xdbcp->out_dma + XDBC_MAX_PACKET;
+
 	return 0;
 }
 
@@ -802,6 +822,9 @@ static int xdbc_start(void)
 
 	xdbc_trace("root hub port number %d\n", DCST_DPN(status));
 
+	xdbcp->in_ep_state = EP_RUNNING;
+	xdbcp->out_ep_state = EP_RUNNING;
+
 	xdbc_trace("DbC is running now, control 0x%08x\n",
 			readl(&xdbcp->xdbc_reg->control));
 
@@ -895,3 +918,353 @@ int __init early_xdbc_init(char *s)
 
 	return 0;
 }
+
+static void xdbc_queue_trb(struct xdbc_ring *ring,
+		u32 field1, u32 field2, u32 field3, u32 field4)
+{
+	struct xdbc_trb *trb, *link_trb;
+
+	trb = ring->enqueue;
+	trb->field[0] = cpu_to_le32(field1);
+	trb->field[1] = cpu_to_le32(field2);
+	trb->field[2] = cpu_to_le32(field3);
+	trb->field[3] = cpu_to_le32(field4);
+
+	xdbc_dbg_dump_trb(trb, "enqueue trb");
+
+	++(ring->enqueue);
+	if (ring->enqueue >= &ring->segment->trbs[TRBS_PER_SEGMENT - 1]) {
+		link_trb = ring->enqueue;
+		if (ring->cycle_state)
+			link_trb->field[3] |= cpu_to_le32(TRB_CYCLE);
+		else
+			link_trb->field[3] &= cpu_to_le32(~TRB_CYCLE);
+
+		ring->enqueue = ring->segment->trbs;
+		ring->cycle_state ^= 1;
+	}
+}
+
+static void xdbc_ring_doorbell(int target)
+{
+	writel(DOOR_BELL_TARGET(target), &xdbcp->xdbc_reg->doorbell);
+}
+
+static void xdbc_handle_port_status(struct xdbc_trb *evt_trb)
+{
+	u32 port_reg;
+
+	port_reg = readl(&xdbcp->xdbc_reg->portsc);
+
+	if (port_reg & PORTSC_CSC) {
+		xdbc_trace("%s: connect status change event\n", __func__);
+		writel(port_reg | PORTSC_CSC, &xdbcp->xdbc_reg->portsc);
+		port_reg = readl(&xdbcp->xdbc_reg->portsc);
+	}
+
+	if (port_reg & PORTSC_PRC) {
+		xdbc_trace("%s: port reset change event\n", __func__);
+		writel(port_reg | PORTSC_PRC, &xdbcp->xdbc_reg->portsc);
+		port_reg = readl(&xdbcp->xdbc_reg->portsc);
+	}
+
+	if (port_reg & PORTSC_PLC) {
+		xdbc_trace("%s: port link status change event\n", __func__);
+		writel(port_reg | PORTSC_PLC, &xdbcp->xdbc_reg->portsc);
+		port_reg = readl(&xdbcp->xdbc_reg->portsc);
+	}
+
+	if (port_reg & PORTSC_CEC) {
+		xdbc_trace("%s: config error change\n", __func__);
+		writel(port_reg | PORTSC_CEC, &xdbcp->xdbc_reg->portsc);
+		port_reg = readl(&xdbcp->xdbc_reg->portsc);
+	}
+}
+
+static void xdbc_handle_tx_event(struct xdbc_trb *evt_trb)
+{
+	u32 comp_code;
+	u32 tx_dma_high, tx_dma_low;
+	u64 in_dma, out_dma;
+	size_t remain_length;
+	int ep_id;
+
+	tx_dma_low = le32_to_cpu(evt_trb->field[0]);
+	tx_dma_high = le32_to_cpu(evt_trb->field[1]);
+	comp_code = GET_COMP_CODE(le32_to_cpu(evt_trb->field[2]));
+	remain_length = EVENT_TRB_LEN(le32_to_cpu(evt_trb->field[2]));
+	ep_id = TRB_TO_EP_ID(le32_to_cpu(evt_trb->field[3]));
+	in_dma = __pa(xdbcp->in_pending);
+	out_dma = __pa(xdbcp->out_pending);
+
+	/*
+	 * Possible Completion Codes for DbC Transfer Event are Success,
+	 * Stall Error, USB Transaction Error, Babble Detected Error,
+	 * TRB Error, Short Packet, Undefined Error, Event Ring Full Error,
+	 * and Vendor Defined Error. TRB error, undefined error and vendor
+	 * defined error will result in HOT/HIT set and be handled the same
+	 * way as Stall error.
+	 */
+	switch (comp_code) {
+	case COMP_SUCCESS:
+		remain_length = 0;
+	case COMP_SHORT_TX:
+		xdbc_trace("%s: endpoint %d remains %d bytes\n", __func__,
+			ep_id, remain_length);
+		break;
+	case COMP_TRB_ERR:
+	case COMP_BABBLE:
+	case COMP_TX_ERR:
+	case COMP_STALL:
+	default:
+		xdbc_trace("%s: endpoint %d halted\n", __func__, ep_id);
+		if (ep_id == XDBC_EPID_OUT)
+			xdbcp->out_ep_state = EP_HALTED;
+		if (ep_id == XDBC_EPID_IN)
+			xdbcp->in_ep_state = EP_HALTED;
+
+		break;
+	}
+
+	if (lower_32_bits(in_dma) == tx_dma_low &&
+			upper_32_bits(in_dma) == tx_dma_high) {
+		xdbcp->in_complete = comp_code;
+		xdbcp->in_complete_length =
+				(remain_length > xdbcp->in_length) ?
+				0 : xdbcp->in_length - remain_length;
+	}
+
+	if (lower_32_bits(out_dma) == tx_dma_low &&
+			upper_32_bits(out_dma) == tx_dma_high) {
+		xdbcp->out_complete = comp_code;
+		xdbcp->out_complete_length =
+				(remain_length > xdbcp->out_length) ?
+				0 : xdbcp->out_length - remain_length;
+	}
+}
+
+static void xdbc_handle_events(void)
+{
+	struct xdbc_trb *evt_trb;
+	bool update_erdp = false;
+
+	evt_trb = xdbcp->evt_ring.dequeue;
+	while ((le32_to_cpu(evt_trb->field[3]) & TRB_CYCLE) ==
+			xdbcp->evt_ring.cycle_state) {
+		/*
+		 * Memory barrier to ensure software sees the trbs
+		 * enqueued by hardware.
+		 */
+		rmb();
+
+		xdbc_dbg_dump_trb(evt_trb, "event trb");
+
+		/* FIXME: Handle more event types. */
+		switch ((le32_to_cpu(evt_trb->field[3]) & TRB_TYPE_BITMASK)) {
+		case TRB_TYPE(TRB_PORT_STATUS):
+			xdbc_handle_port_status(evt_trb);
+			break;
+		case TRB_TYPE(TRB_TRANSFER):
+			xdbc_handle_tx_event(evt_trb);
+			break;
+		default:
+			break;
+		}
+
+		/* advance to the next trb */
+		++(xdbcp->evt_ring.dequeue);
+		if (xdbcp->evt_ring.dequeue ==
+				&xdbcp->evt_seg.trbs[TRBS_PER_SEGMENT]) {
+			xdbcp->evt_ring.dequeue = xdbcp->evt_seg.trbs;
+			xdbcp->evt_ring.cycle_state ^= 1;
+		}
+
+		evt_trb = xdbcp->evt_ring.dequeue;
+		update_erdp = true;
+	}
+
+	/* update event ring dequeue pointer */
+	if (update_erdp)
+		xdbc_write64(__pa(xdbcp->evt_ring.dequeue),
+				&xdbcp->xdbc_reg->erdp);
+}
+
+/*
+ * Check and dispatch events in event ring. It also checks status
+ * of hardware. This function will be called from multiple threads.
+ * An atomic lock is applied to protect the access of event ring.
+ */
+static int xdbc_check_event(void)
+{
+	/* event ring is under checking by other thread? */
+	if (!test_bit(XDBC_ATOMIC_EVENT, &xdbcp->atomic_flags) &&
+			!test_and_set_bit(XDBC_ATOMIC_EVENT,
+			&xdbcp->atomic_flags))
+		return 0;
+
+	xdbc_handle_events();
+
+	test_and_clear_bit(XDBC_ATOMIC_EVENT, &xdbcp->atomic_flags);
+
+	return 0;
+}
+
+#define	BULK_IN_COMPLETED(p)	((xdbcp->in_pending == (p)) && \
+				 xdbcp->in_complete)
+#define	BULK_OUT_COMPLETED(p)	((xdbcp->out_pending == (p)) && \
+				 xdbcp->out_complete)
+
+/*
+ * Wait for a bulk-in or bulk-out transfer completion or timed out.
+ * Return count of the actually transferred bytes or error.
+ */
+static int xdbc_wait_until_bulk_done(struct xdbc_trb *trb, int loops)
+{
+	int timeout = 0;
+	bool read;
+
+	if (trb != xdbcp->in_pending &&
+			trb != xdbcp->out_pending)
+		return -EINVAL;
+
+	read = (trb == xdbcp->in_pending);
+
+	do {
+		if (xdbc_check_event() < 0)
+			break;
+
+		if (read && BULK_IN_COMPLETED(trb)) {
+			if (xdbcp->in_ep_state == EP_HALTED)
+				return -EAGAIN;
+			else
+				return xdbcp->in_complete_length;
+		}
+
+		if (!read && BULK_OUT_COMPLETED(trb)) {
+			if (xdbcp->out_ep_state == EP_HALTED)
+				return -EAGAIN;
+			else
+				return xdbcp->out_complete_length;
+		}
+
+		xdbc_udelay(10);
+	} while ((timeout++ < loops) || !loops);
+
+	return -EIO;
+}
+
+static int xdbc_bulk_transfer(void *data, int size, int loops, bool read)
+{
+	u64 addr;
+	u32 length, control;
+	struct xdbc_trb *trb;
+	struct xdbc_ring *ring;
+	u32 cycle;
+	int ret;
+
+	if (size > XDBC_MAX_PACKET) {
+		xdbc_trace("%s: bad parameter, size %d", __func__, size);
+		return -EINVAL;
+	}
+
+	ring = (read ? &xdbcp->in_ring : &xdbcp->out_ring);
+	trb = ring->enqueue;
+	cycle = ring->cycle_state;
+
+	length = TRB_LEN(size);
+	control = TRB_TYPE(TRB_NORMAL) | TRB_IOC;
+
+	if (cycle)
+		control &= cpu_to_le32(~TRB_CYCLE);
+	else
+		control |= cpu_to_le32(TRB_CYCLE);
+
+	if (read) {
+		memset(xdbcp->in_buf, 0, XDBC_MAX_PACKET);
+		addr = xdbcp->in_dma;
+
+		xdbcp->in_pending = trb;
+		xdbcp->in_length = size;
+		xdbcp->in_complete = 0;
+		xdbcp->in_complete_length = 0;
+	} else {
+		memcpy(xdbcp->out_buf, data, size);
+		addr = xdbcp->out_dma;
+
+		xdbcp->out_pending = trb;
+		xdbcp->out_length = size;
+		xdbcp->out_complete = 0;
+		xdbcp->out_complete_length = 0;
+	}
+
+	xdbc_queue_trb(ring, lower_32_bits(addr),
+			upper_32_bits(addr),
+			length, control);
+
+	/*
+	 * Memory barrier to ensure hardware sees the trbs
+	 * enqueued above.
+	 */
+	wmb();
+	if (cycle)
+		trb->field[3] |= cpu_to_le32(cycle);
+	else
+		trb->field[3] &= cpu_to_le32(~TRB_CYCLE);
+
+	xdbc_ring_doorbell(read ? IN_EP_DOORBELL : OUT_EP_DOORBELL);
+
+	ret = xdbc_wait_until_bulk_done(trb, loops);
+
+	if (read)
+		xdbcp->in_pending = NULL;
+	else
+		xdbcp->out_pending = NULL;
+
+	if (ret > 0) {
+		if (read)
+			memcpy(data, xdbcp->in_buf, size);
+		else
+			memset(xdbcp->out_buf, 0, XDBC_MAX_PACKET);
+	} else {
+		xdbc_trace("%s: bulk %s transfer results in error %d\n",
+				__func__, read ? "in" : "out", ret);
+	}
+
+	return ret;
+}
+
+int xdbc_bulk_read(void *data, int size, int loops)
+{
+	int ret;
+
+	do {
+		if (!test_bit(XDBC_ATOMIC_BULKIN, &xdbcp->atomic_flags) &&
+				!test_and_set_bit(XDBC_ATOMIC_BULKIN,
+				&xdbcp->atomic_flags))
+			break;
+	} while (1);
+
+	ret = xdbc_bulk_transfer(data, size, loops, true);
+
+	test_and_clear_bit(XDBC_ATOMIC_BULKIN, &xdbcp->atomic_flags);
+
+	return ret;
+}
+
+int xdbc_bulk_write(const char *bytes, int size)
+{
+	int ret;
+
+	do {
+		if (!test_bit(XDBC_ATOMIC_BULKOUT, &xdbcp->atomic_flags) &&
+				!test_and_set_bit(XDBC_ATOMIC_BULKOUT,
+				&xdbcp->atomic_flags))
+			break;
+	} while (1);
+
+	ret = xdbc_bulk_transfer((void *)bytes, size, XDBC_LOOPS, false);
+
+	test_and_clear_bit(XDBC_ATOMIC_BULKOUT, &xdbcp->atomic_flags);
+
+	return ret;
+}
diff --git a/include/linux/usb/xhci-dbc.h b/include/linux/usb/xhci-dbc.h
index fc0ef9a..289ba58 100644
--- a/include/linux/usb/xhci-dbc.h
+++ b/include/linux/usb/xhci-dbc.h
@@ -120,8 +120,17 @@ enum xdbc_page_type {
 	XDBC_PAGE_TXIN,
 	XDBC_PAGE_TXOUT,
 	XDBC_PAGE_TABLE,
+	XDBC_PAGE_BUFFER,
 };
 
+enum xdbc_ep_state {
+	EP_DISABLED,
+	EP_RUNNING,
+	EP_HALTED,
+};
+#define	XDBC_EPID_OUT	2
+#define	XDBC_EPID_IN	1
+
 struct xdbc_state {
 	/* pci device info*/
 	u32		bus;
@@ -170,13 +179,34 @@ struct xdbc_state {
 	/* bulk OUT endpoint */
 	struct xdbc_ring	out_ring;
 	struct xdbc_segment	out_seg;
+	void			*out_buf;
+	dma_addr_t		out_dma;
+	struct xdbc_trb		*out_pending;		/* IN */
+	size_t			out_length;		/* IN */
+	u32			out_complete;		/* OUT */
+	size_t			out_complete_length;	/* OUT */
+	enum xdbc_ep_state	out_ep_state;
 
 	/* bulk IN endpoint */
 	struct xdbc_ring	in_ring;
 	struct xdbc_segment	in_seg;
+	void			*in_buf;
+	dma_addr_t		in_dma;
+	struct xdbc_trb		*in_pending;		/* IN */
+	size_t			in_length;		/* IN */
+	u32			in_complete;		/* OUT */
+	size_t			in_complete_length;	/* OUT */
+	enum xdbc_ep_state	in_ep_state;
+
+	/* atomic flags */
+	unsigned long		atomic_flags;
+#define	XDBC_ATOMIC_BULKOUT	0
+#define	XDBC_ATOMIC_BULKIN	1
+#define	XDBC_ATOMIC_EVENT	2
 };
 
 #define	XDBC_MAX_PACKET		1024
+#define	XDBC_LOOPS		1000
 
 /* door bell target */
 #define	OUT_EP_DOORBELL		0
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 07/12] usb: xhci: dbc: handle dbc-configured exit
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (5 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 06/12] usb: xhci: dbc: add bulk out and bulk in interfaces Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 08/12] usb: xhci: dbc: handle endpoint stall Lu Baolu
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

DbC might exit configured state in some cases (refer to 7.6.4.4 in
xHCI spec 1.1). Software needs detect and clear this situation by
clearing DCCTRL.DCR and wait until the DbC configured before read
or write oprations.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/early/xhci-dbc.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index f51daa4..8a5a51f 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -1153,6 +1153,29 @@ static int xdbc_wait_until_bulk_done(struct xdbc_trb *trb, int loops)
 	return -EIO;
 }
 
+static int xdbc_wait_until_dbc_configured(void)
+{
+	int timeout = 0;
+	u32 reg;
+
+	/* Port exits configured state */
+	reg = readl(&xdbcp->xdbc_reg->control);
+	if (!(reg & CTRL_DRC))
+		return 0;
+
+	/* clear run change bit (RW1C) */
+	writel(reg | CTRL_DRC, &xdbcp->xdbc_reg->control);
+
+	do {
+		if (readl(&xdbcp->xdbc_reg->control) & CTRL_DCR)
+			return 0;
+
+		xdbc_udelay(10);
+	} while (timeout++ < XDBC_LOOPS);
+
+	return -ETIMEDOUT;
+}
+
 static int xdbc_bulk_transfer(void *data, int size, int loops, bool read)
 {
 	u64 addr;
@@ -1167,6 +1190,11 @@ static int xdbc_bulk_transfer(void *data, int size, int loops, bool read)
 		return -EINVAL;
 	}
 
+	if (xdbc_wait_until_dbc_configured()) {
+		xdbc_trace("%s: hardware not ready\n", __func__);
+		return -EPERM;
+	}
+
 	ring = (read ? &xdbcp->in_ring : &xdbcp->out_ring);
 	trb = ring->enqueue;
 	cycle = ring->cycle_state;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 08/12] usb: xhci: dbc: handle endpoint stall
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (6 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 07/12] usb: xhci: dbc: handle dbc-configured exit Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 09/12] x86: early_printk: add USB3 debug port earlyprintk support Lu Baolu
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

In case of endpoint stall, software is able to detect the situation
by reading DCCTRL.HIT or DCCTRL.HOT bits. DbC follows the normal USB
framework to handle endpoint stall. When software detects endpoint
stall situation, it should wait until endpoint is recovered before
read or write oprations.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/early/xhci-dbc.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 8a5a51f..aaf655f 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -1176,6 +1176,37 @@ static int xdbc_wait_until_dbc_configured(void)
 	return -ETIMEDOUT;
 }
 
+static int xdbc_wait_until_epstall_cleared(bool read)
+{
+	int timeout = 0;
+
+	if (read) {
+		do {
+			if (!(readl(&xdbcp->xdbc_reg->control) & CTRL_HIT)) {
+				xdbcp->in_ep_state = EP_RUNNING;
+
+				return 0;
+			}
+
+			xdbcp->in_ep_state = EP_HALTED;
+			xdbc_udelay(10);
+		} while (timeout++ < XDBC_LOOPS);
+	} else {
+		do {
+			if (!(readl(&xdbcp->xdbc_reg->control) & CTRL_HOT)) {
+				xdbcp->out_ep_state = EP_RUNNING;
+
+				return 0;
+			}
+
+			xdbcp->out_ep_state = EP_HALTED;
+			xdbc_udelay(10);
+		} while (timeout++ < XDBC_LOOPS);
+	}
+
+	return -ETIMEDOUT;
+}
+
 static int xdbc_bulk_transfer(void *data, int size, int loops, bool read)
 {
 	u64 addr;
@@ -1195,6 +1226,11 @@ static int xdbc_bulk_transfer(void *data, int size, int loops, bool read)
 		return -EPERM;
 	}
 
+	if (xdbc_wait_until_epstall_cleared(read)) {
+		xdbc_trace("%s: endpoint not ready\n", __func__);
+		return -EPERM;
+	}
+
 	ring = (read ? &xdbcp->in_ring : &xdbcp->out_ring);
 	trb = ring->enqueue;
 	cycle = ring->cycle_state;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 09/12] x86: early_printk: add USB3 debug port earlyprintk support
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (7 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 08/12] usb: xhci: dbc: handle endpoint stall Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 10/12] usb: xhci: dbc: add handshake between debug target and host Lu Baolu
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

Add support for early printk by writing debug messages to the USB3
debug port. Users can use this type of early printk by specifying
kernel parameter of "earlyprintk=xdbc". This gives users a chance
of providing debug output.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 Documentation/kernel-parameters.txt |  1 +
 arch/x86/kernel/early_printk.c      |  5 +++++
 drivers/usb/early/xhci-dbc.c        | 43 +++++++++++++++++++++++++++++++++++++
 include/linux/usb/xhci-dbc.h        |  5 +++++
 4 files changed, 54 insertions(+)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 22a4b68..b65b07f 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1032,6 +1032,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			earlyprintk=ttySn[,baudrate]
 			earlyprintk=dbgp[debugController#]
 			earlyprintk=pciserial,bus:device.function[,baudrate]
+			earlyprintk=xdbc[xhciController#]
 
 			earlyprintk is useful when the kernel crashes before
 			the normal console is initialized. It is not enabled by
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index eec40f5..5341a16 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -17,6 +17,7 @@
 #include <asm/intel-mid.h>
 #include <asm/pgtable.h>
 #include <linux/usb/ehci_def.h>
+#include <linux/usb/xhci-dbc.h>
 #include <linux/efi.h>
 #include <asm/efi.h>
 #include <asm/pci_x86.h>
@@ -373,6 +374,10 @@ static int __init setup_early_printk(char *buf)
 		if (!strncmp(buf, "dbgp", 4) && !early_dbgp_init(buf + 4))
 			early_console_register(&early_dbgp_console, keep);
 #endif
+#ifdef CONFIG_EARLY_PRINTK_XDBC
+		if (!strncmp(buf, "xdbc", 4) && !early_xdbc_init(buf + 4))
+			early_console_register(&early_xdbc_console, keep);
+#endif
 #ifdef CONFIG_HVC_XEN
 		if (!strncmp(buf, "xen", 3))
 			early_console_register(&xenboot_console, keep);
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index aaf655f..68a7139 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -10,6 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/console.h>
 #include <linux/pci_regs.h>
 #include <linux/pci_ids.h>
 #include <linux/bootmem.h>
@@ -1332,3 +1333,45 @@ int xdbc_bulk_write(const char *bytes, int size)
 
 	return ret;
 }
+
+/*
+ * Start a bulk-in or bulk-out transfer, wait until transfer completion
+ * or error. Return the count of actually transferred bytes or error.
+ */
+static void early_xdbc_write(struct console *con, const char *str, u32 n)
+{
+	int chunk, ret;
+	static char buf[XDBC_MAX_PACKET];
+	int use_cr = 0;
+
+	if (!xdbcp->xdbc_reg)
+		return;
+	memset(buf, 0, XDBC_MAX_PACKET);
+	while (n > 0) {
+		for (chunk = 0; chunk < XDBC_MAX_PACKET && n > 0;
+		     str++, chunk++, n--) {
+			if (!use_cr && *str == '\n') {
+				use_cr = 1;
+				buf[chunk] = '\r';
+				str--;
+				n++;
+				continue;
+			}
+			if (use_cr)
+				use_cr = 0;
+			buf[chunk] = *str;
+		}
+		if (chunk > 0) {
+			ret = xdbc_bulk_write(buf, chunk);
+			if (ret < 0)
+				break;
+		}
+	}
+}
+
+struct console early_xdbc_console = {
+	.name =		"earlyxdbc",
+	.write =	early_xdbc_write,
+	.flags =	CON_PRINTBUFFER,
+	.index =	-1,
+};
diff --git a/include/linux/usb/xhci-dbc.h b/include/linux/usb/xhci-dbc.h
index 289ba58..a556eb8 100644
--- a/include/linux/usb/xhci-dbc.h
+++ b/include/linux/usb/xhci-dbc.h
@@ -216,4 +216,9 @@ struct xdbc_state {
 #define	xdbc_read64(regs)	xhci_read_64(NULL, (regs))
 #define	xdbc_write64(val, regs)	xhci_write_64(NULL, (val), (regs))
 
+#ifdef CONFIG_EARLY_PRINTK_XDBC
+extern int early_xdbc_init(char *s);
+extern struct console early_xdbc_console;
+#endif /* CONFIG_EARLY_PRINTK_XDBC */
+
 #endif /* __LINUX_XHCI_DBC_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 10/12] usb: xhci: dbc: add handshake between debug target and host
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (8 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 09/12] x86: early_printk: add USB3 debug port earlyprintk support Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 11/12] usb: serial: usb_debug: add support for dbc debug device Lu Baolu
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

After DbC setup, debug target needs to wait until tty driver and
application (e.g. mincom) on debug taget start.  Otherwise, out
messages might be ignored.

This patch adds a ping/pong mechanism between debug target and
host. Debug target will be waiting there until user presses 'Y'
or 'y' in the tty application.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/early/xhci-dbc.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 68a7139..b75c523 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -32,6 +32,9 @@
 static struct xdbc_state xdbc_stat;
 static struct xdbc_state *xdbcp = &xdbc_stat;
 
+static int early_xdbc_read(struct console *con, char *str, unsigned n);
+static void early_xdbc_write(struct console *con, const char *str, u32 n);
+
 #ifdef DBC_DEBUG
 #define	XDBC_DEBUG_BUF_SIZE	(PAGE_SIZE * 32)
 #define	MSG_MAX_LINE		128
@@ -873,8 +876,12 @@ int __init early_xdbc_init(char *s)
 {
 	u32 bus = 0, dev = 0, func = 0;
 	unsigned long dbgp_num = 0;
+	char *ping = "Press Y to continue...\n";
+	char pong[64];
+	size_t size;
 	u32 offset;
 	int ret;
+	int retry = 20;
 
 	if (!early_pci_allowed())
 		return -EPERM;
@@ -917,6 +924,21 @@ int __init early_xdbc_init(char *s)
 		return ret;
 	}
 
+	while (retry > 0) {
+		early_xdbc_write(NULL, ping, strlen(ping));
+		size = early_xdbc_read(NULL, pong, 64);
+		if (size > 0) {
+			xdbc_trace("%s: pong message: %s\n", __func__, pong);
+			if (pong[0] == 'Y' || pong[0] == 'y')
+				break;
+		} else {
+			xdbc_trace("%s: pong message error %d\n",
+				__func__, size);
+		}
+
+		retry--;
+	}
+
 	return 0;
 }
 
@@ -1338,6 +1360,11 @@ int xdbc_bulk_write(const char *bytes, int size)
  * Start a bulk-in or bulk-out transfer, wait until transfer completion
  * or error. Return the count of actually transferred bytes or error.
  */
+static int early_xdbc_read(struct console *con, char *str, unsigned n)
+{
+	return xdbc_bulk_read(str, n, 0);
+}
+
 static void early_xdbc_write(struct console *con, const char *str, u32 n)
 {
 	int chunk, ret;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 11/12] usb: serial: usb_debug: add support for dbc debug device
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (9 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 10/12] usb: xhci: dbc: add handshake between debug target and host Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-09  7:38 ` [PATCH v3 12/12] usb: doc: add document for xHCI DbC driver Lu Baolu
  2015-11-10  9:39 ` [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Dave Young
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

This patch add dbc debug device support in usb_debug driver.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/usb_debug.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index ca2fa5b..92f7e5c 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -32,7 +32,18 @@ static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE(0x0525, 0x127a) },
 	{ },
 };
-MODULE_DEVICE_TABLE(usb, id_table);
+
+static const struct usb_device_id dbc_id_table[] = {
+	{ USB_DEVICE(0x1d6b, 0x0004) },
+	{ },
+};
+
+static const struct usb_device_id id_table_combined[] = {
+	{ USB_DEVICE(0x0525, 0x127a) },
+	{ USB_DEVICE(0x1d6b, 0x0004) },
+	{ },
+};
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 /* This HW really does not support a serial break, so one will be
  * emulated when ever the break state is set to true.
@@ -71,9 +82,20 @@ static struct usb_serial_driver debug_device = {
 	.process_read_urb =	usb_debug_process_read_urb,
 };
 
+static struct usb_serial_driver dbc_device = {
+	.driver = {
+		.owner =	THIS_MODULE,
+		.name =		"xhci_dbc",
+	},
+	.id_table =		dbc_id_table,
+	.num_ports =		1,
+	.break_ctl =		usb_debug_break_ctl,
+	.process_read_urb =	usb_debug_process_read_urb,
+};
+
 static struct usb_serial_driver * const serial_drivers[] = {
-	&debug_device, NULL
+	&debug_device, &dbc_device, NULL
 };
 
-module_usb_serial_driver(serial_drivers, id_table);
+module_usb_serial_driver(serial_drivers, id_table_combined);
 MODULE_LICENSE("GPL");
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 12/12] usb: doc: add document for xHCI DbC driver
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (10 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 11/12] usb: serial: usb_debug: add support for dbc debug device Lu Baolu
@ 2015-11-09  7:38 ` Lu Baolu
  2015-11-10  9:39 ` [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Dave Young
  12 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-09  7:38 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Alan Stern
  Cc: linux-usb, x86, linux-kernel, Lu Baolu

Add Documentation/usb/xhci-dbc.txt. This document includes
development status and user guide for USB3 debug port.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 Documentation/usb/xhci-dbc.txt | 325 +++++++++++++++++++++++++++++++++++++++++
 MAINTAINERS                    |   1 +
 drivers/usb/early/xhci-dbc.c   |   3 +
 3 files changed, 329 insertions(+)
 create mode 100644 Documentation/usb/xhci-dbc.txt

diff --git a/Documentation/usb/xhci-dbc.txt b/Documentation/usb/xhci-dbc.txt
new file mode 100644
index 0000000..441b40c
--- /dev/null
+++ b/Documentation/usb/xhci-dbc.txt
@@ -0,0 +1,325 @@
+                    xHCI debug capability driver
+
+                 Lu Baolu <baolu.lu@linux.intel.com>
+
+                    Last-updated: September 2015
+
+
+	Contents:
+	---------
+	* What is xHCI DbC?
+	* Debug topologies
+	* Debug stacks
+	* Port Multiplexing
+	* Hardware initialization
+	* External reset
+	* Port reset
+	* Interrupt/DMA/Memory during early boot
+	* Endpoint STALL
+	* Debug device information
+	* How to use DbC early printk?
+	* Limitations
+
+	What is xHCI DbC?
+	-----------------
+
+The xHCI Debugging Capability defined in section 7.6 of xHCI spec 1.1
+provides an optional functionality that enables low-level system debug
+over USB. It provides a means of connecting two systems where one system
+is a Debug Host and the other a Debug Target (System Under Test). The
+Debug Capability provides an interface that is completely independent
+of the xHCI interface. A Debug Target enumerates as a USB debug device
+to the Debug Host, allowing a Debug Host to access a Debug Target through
+the standard USB software stack.
+
+	Debug topologies
+	----------------
+
+Multiple Debug Targets may be attached to a single Debug Host. Debug
+Targets may be connected to any downstream facing port below a Debug
+Host (i.e. anywhere in the fabric, root port or external hub puts).
+A Debug Target may only connect to a Debug Host through a Root Hub port
+of the target. That means connection of a Debug Target to a Debug Host
+through the ports of an external hub is not supported.
+
+Below is a typical connection between Debug Host and Debug target. Two
+Debug targets are connected to a single Debug host.
+
+
+         ________________                ________________
+        |   Debug Host   |              |  Debug Target  |
+        |________________|              |________________|
+        |xHC without DbC |              |  xHC with DbC  |
+        |or DbC disabled |              |     enabled    |
+        |________________|              |________________|
+            |P1|  |p2|                      |P1|  |p2|
+            |__|  |__|                      |__|  |__|
+              |    |                         |
+              |    |_________________________|
+              |_
+                |
+         _______|________                ________________
+        |       HUB      |              |  Debug Target  |
+        |________________|              |________________|
+        | Superspeed hub |              |  xHC with DbC  |
+        |                |              |     enabled    |
+        |________________|              |________________|
+            |P1|  |p2|                      |P1|  |p2|
+            |__|  |__|                      |__|  |__|
+                   |                         |
+                   |_________________________|
+
+	Debug stacks
+	------------
+
+Below is a software stack diagram of both Debug Host and Debug Target.
+
+         ________________                ________________
+        |   Debug Host   |              |  Debug Target  |
+        |________________|              |________________|
+        |   debug App    |              |                |
+        |                |              | system debug   |
+        |   usb_debug    |              |     hooks      |
+        |                |              |                |
+        |    usbcore     |              |                |
+        |                |              |debug capability|
+        |    xhci_hcd    |              |     driver     |
+        |________________|              |________________|
+        |xHC without DbC |              |  xHC with DbC  |
+        |or DbC disabled |              |     enabled    |
+        |________________|              |________________|
+            |P1|  |p2|                      |P1|  |p2|
+            |__|  |__|                      |__|  |__|
+                   |                         |
+                   |_________________________|
+
+
+	Port Multiplexing
+	-----------------
+
+A debug port is always multiplexed with the first xHCI root hub port.
+Whenever debug capability is supported and enabled, and the first root
+hub port is detected to be connected to a downstream super-speed port
+of a Debug Host, the root hub port is assigned to the debug capability
+and operating in an upstream facing mode. Otherwise, all root hub ports
+act as normal downstream facing ports. When the root port is assigned
+to debug capability, it appears through the xHCI as a fully functional
+root hub port that never sees a device attach.
+
+	Hardware initialization
+	-----------------------
+
+xHCI debug capability is initialized during early boot. "early_param"
+micro provides one option. It also provides a global function so that
+early code can call it to initialize the hardware.
+
+int __init early_xdbc_init(char *s)
+
+early_param("string", early_xdbc_init)
+
+Keep in mind that things such as interrupt, system memory, DMA memory,
+PCI configure space access, etc., are all different from a normal device
+driver.
+
+Software probes the debug capability and all its memory and register
+interfaces by walking through the xHCI extended capability List. Debug
+capability is implemented with the capability ID of 10.
+
+After a xHCI debug capability interface was detected, software could
+initialize the hardware so that debug host can enumerate it as a debug
+device. The USB debug device provided by xHC debug capacity experiences
+three modes: disabled mode, enumeration mode and run mode. In each mode,
+software and xHC itself should complete required steps to move it to the
+next mode. Below diagram describes the evolution of each mode.
+
+      __________             ___________             ___________
+     |          |           |           |           |           |
+     |          |           |           |           |           |
+     | Disabled | DbC enable|Enumeration| DbC run   |    Run    |
+     |   mode   |---------->|    mode   |---------->|    mode   |
+     |          |flag 0 to 1|           |flag 0 to 1|           |
+     |          |           |           |           |           |
+     |          |           |           |           |           |
+     |__________|           |___________|           |___________|
+
+To change DbC mode from disabled to enumeration, software should
+1) allocate and initialize all DbC memory data structures. All data
+structures required by a DbC are defined in 7.6 of the spec 1.1;
+2) initialize the registers. All registers required to be initialized
+in disabled mode are defined in 7.6.4.1 of the spec 1.1. With data
+structure and registers initialized, software can Set the debug
+capability enable (DCE) bit to 1 in the Debug Capability Control
+Register (DCCTRL) and DbC enters enumeration mode as soon as this
+bit is set.
+
+DbC hardware is responsible to change DbC mode from enumerate to run.
+As soon as DbC enters enumeration mode, DbC appears as a normal USB
+device which can be enumerated by debug host. Hence, DbC hardware
+should support a default control endpoint, which responds to standard
+USB requests, e.g. SET_ADDRESS, GET_DESCRIPTOR, GET_CONFIGURATION, etc.
+
+After DbC has been configure by debug host, it enters run mode, it's
+the working mode.
+
+	External reset
+	--------------
+
+External reset means DbC reset caused by something outside of DbC hardware
+and software. The external reset sources depends on the DbC System Bus
+Reset(SBR) bit in status register.
+
+If SBR reads 1, the reset source includes,
+
+1) Assertion of chip hardware reset;
+2) System bus reset (e.g. the assertion of PCI RST#);
+3) Transition from the PCI PM D3hot to D0.
+
+If SBR reads 0, the reset source includes,
+
+1) Assertion of chip hardware reset;
+2) Assertion of host controller reset;
+3) Light host controller Reset.
+
+Resetting the DbC shall clear Debug Capability Enable(DCE) bit to 0.
+Software can determing the reset event during runtime by checking the
+DCE bit. The debug device enters disabled mode after reset. DbC driver
+needs to follow above steps to re-initialize the hardware and bring
+the debug device to run state.
+
+	Port reset
+	----------
+
+Debug port resets itself when it detects reset signal from the debug
+host. Software can determine the port reset event by reading the DbC
+port control and staus registers.
+
+The debug device enters enumeration state as soon as the reset signal
+completes. DbC driver should follow above steps to bring the debug
+device into running mode.
+
+	Interrupt/DMA/Memory during early boot
+	--------------------------------------
+
+The driver code needs to take special care during early boot, especially
+when it comes to memory allocation, interrupt, DMA, device MMIO and PCI
+configuration space. This section defines the interfaces used in DbC driver
+for the prior aspects.
+
+All events generated by DbC are put in the event ring, software will
+periodically poll the Event Ring Not Empty bit in the Debug Capability
+Status Register (DCST) to check pending events. To do this, DbC driver
+should 1)poll the event ring after a transfer trb queued and wait until
+transfer completes, or 2) start a thread to do the periodically poll.
+
+A segment of fixed virtual address is reserved for MMIO access purpose.
+Debug capability driver will map the MMIO physical address (exposed in
+PCI BAR) with this fixed virtual address segment.
+
+Debug Capability needs contiguous memory for DMA purpose. The driver
+reserves DMA memory by stating arrays of PAGE_SIZE and ask the compiler
+to align the arrays to PAGE_SIZE.
+
+Base on the following reasons, the driver uses an outb to port 0x80 as
+an I/O delay: timer subsystem might not be ready yet when DbC starts
+to initialize; DbC driver is independent of OS as possible as it can.
+
+	Endpoint STALL
+	--------------
+
+Endpoint STALL happens when data buffer error, parameter Error,
+TRB error, vendor defined error, or undefined error is detected.
+A transfer event will be generated to notify software.
+
+To clear the STALL situation, debug host will send a ClearFeature
+(ENDPOINT_HALT) request. DbC will clear the halt transfer ring
+flag, clear any internal endpoint state, and move the TR dequeue
+pointer to the next TRB in transfer ring.
+
+DbC does not support Soft Retry. Driver must check and determine
+whether to retry the failed transfer.
+
+	Debug device information
+	------------------------
+
+When debug target boots with xHCI debug capability enabled, it appears
+to debug host as a debug device. The debug device is built using one
+interface which declares two bulk endpoints: an IN and an OUT.
+
+class code:	0xdc (diagnostic device, assigned by USB-IF)
+subclass code:	0x02 (debug device, assigned by USB-IF)
+Manufacturer:	"Linux"
+Product:	"Remote GDB"
+Serial:		"0001"
+
+The USB device ID:
+idVendor:	0x1d6b (Linux Foundation)
+idProduct:	0x0004
+
+	How to use DbC early printk?
+	----------------------------
+
+Before using any kernel functionalities based on DbC, users need to check
+whether debug port is supported by the xHCI host in the system.
+
+On a machine which supports USB3 debug port, a file named "debug_port_state"
+will be created under /sys/bus/pci/drivers/xhci_hcd/<pci_bus_name>/. Reading
+this file will show the state (disabled, enabled or configured) of the debug
+port. On a machine that doesn't support USB3 debug port, this file doesn't
+exist.
+
+On debug target system, user needs to enable the following kernel
+config option:
+
+    CONFIG_PCI
+    CONFIG_EARLY_PRINTK
+    CONFIG_EARLY_PRINTK_XDBC
+
+Users also need to add below kernel parameter:
+
+    "earlyprintk=xdbc"
+
+If there are multiple xHCI controllers in the system, user can append
+a host contoller index to this kernel parameter. The index is started
+from 0.
+
+On debug host side, user needs to make sure usb_debug module is included.
+
+On some platforms, such as Intel, you need to disable auto-pm of usb
+subsystem on debug host when you are debugging with DbC.
+
+#echo on | tee /sys/bus/usb/devices/*/power/control
+
+Before starting the debug target, user needs to connect the debug port
+on debug target with a root port or port of external hub on the debug
+host. The cable used to connect these two ports should be a USB 3.0
+super-speed A-to-A debugging cable.
+
+During early boot of debug target, DbC hardware gets initialized. Debug
+host should be able to enuerate debug target as a debug device. Debug
+host will bind the debug device with usb_debug driver module and create
+a tty file for serial communication application.
+
+After tty file being created, user needs to open serial communication
+application, such as minicom. After configuring minicom to open the
+tty file created above, user should be able to see below welcome message
+in minicom:
+
+Press Y to continue...
+
+After 'Y' key is pressed, debug target will go ahead with booting and
+all early printk messages should be routed to the minicom on debug
+host.
+
+	Limitations
+	-----------
+
+Early printk through DbC has been verified to work with Intel Sunrise Point
+chip with below known issues:
+
+1. DbC debug device doesn't support suspend/resume. Users need to disable
+auto-pm of the host controller on debug host.
+
+2. Early prink "keep" option doesn't support by current phase.
+
+3. After several restarts of debug target, debug host might fail to read
+the device descriptor of debug device. Users need to restart the debug host.
diff --git a/MAINTAINERS b/MAINTAINERS
index 585a369..eb48df1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11046,6 +11046,7 @@ L:	linux-usb@vger.kernel.org
 S:	Supported
 F:	drivers/usb/early/xhci-dbc.c
 F:	include/linux/usb/xhci-dbc.h
+F:	Documentation/usb/xhci-dbc.txt
 
 USB ZD1201 DRIVER
 L:	linux-wireless@vger.kernel.org
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index b75c523..676fb41 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -6,6 +6,9 @@
  * Author: Lu Baolu <baolu.lu@linux.intel.com>
  * Some code shared with EHCI debug port and xHCI driver.
  *
+ * Please read Documentation/usb/xhci-dbc.txt before you start to develop
+ * or use code in this file.
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI debug port
  2015-11-09  7:38 ` [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI " Lu Baolu
@ 2015-11-10  9:36   ` Dave Young
  2015-11-11  2:03     ` Lu, Baolu
  0 siblings, 1 reply; 25+ messages in thread
From: Dave Young @ 2015-11-10  9:36 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel

[snip]

> diff --git a/drivers/usb/host/xhci-sysfs.c b/drivers/usb/host/xhci-sysfs.c
> new file mode 100644
> index 0000000..0192ac4
> --- /dev/null
> +++ b/drivers/usb/host/xhci-sysfs.c
> @@ -0,0 +1,100 @@
> +/*
> + * sysfs interface for xHCI host controller driver
> + *
> + * Copyright (C) 2015 Intel Corp.
> + *
> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#include <linux/kernel.h>
> +
> +#include "xhci.h"
> +
> +/*
> + * Return the register offset of a extended capability specified
> + * by @cap_id. Return 0 if @cap_id capability is not supported or
> + * in error cases.
> + */
> +static int get_extended_capability_offset(struct xhci_hcd *xhci,
> +					int cap_id)
> +{
> +	u32		cap_reg;
> +	unsigned long	flags;
> +	int		offset;
> +	void __iomem	*base = (void __iomem *) xhci->cap_regs;
> +	struct usb_hcd	*hcd = xhci_to_hcd(xhci);
> +	int		time_to_leave = XHCI_EXT_MAX_CAPID;
> +
> +	spin_lock_irqsave(&xhci->lock, flags);
> +
> +	offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET);
> +	if (!HCD_HW_ACCESSIBLE(hcd) || !offset) {
> +		spin_unlock_irqrestore(&xhci->lock, flags);
> +		return 0;
> +	}
> +
> +	while (time_to_leave--) {
> +		cap_reg = readl(base + offset);
> +
> +		if (XHCI_EXT_CAPS_ID(cap_reg) == cap_id)
> +			break;
> +
> +		offset = xhci_find_next_cap_offset(base, offset);
> +		if (!offset)
> +			break;
> +	}
> +
> +	spin_unlock_irqrestore(&xhci->lock, flags);

I'm not sure spin_lock is good and necessary here, also seems there's already
a function to find the cap offset:
xhci_find_ext_cap_by_id() in xhci-ext-caps.h

> +
> +	return offset;
> +}
> +

Thanks
Dave

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
                   ` (11 preceding siblings ...)
  2015-11-09  7:38 ` [PATCH v3 12/12] usb: doc: add document for xHCI DbC driver Lu Baolu
@ 2015-11-10  9:39 ` Dave Young
  2015-11-11  1:32   ` Lu, Baolu
  12 siblings, 1 reply; 25+ messages in thread
From: Dave Young @ 2015-11-10  9:39 UTC (permalink / raw)
  To: Lu Baolu
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel

Hi,

On 11/09/15 at 03:38pm, Lu Baolu wrote:
> This patch series adds support for early printk through USB3 debug port.
> USB3 debug port is described in xHCI specification as an optional extended
> capability.
> 

I did a test with your previous patchset with the manually wired cable.
debug host detected the remote device, but later the devie automaticlly
disconnected and earlyprintk hangs.

I have not got more time, will try your new patchset when I have time.

Thanks
Dave

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-10  9:39 ` [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Dave Young
@ 2015-11-11  1:32   ` Lu, Baolu
  2015-11-11  2:25     ` Dave Young
  0 siblings, 1 reply; 25+ messages in thread
From: Lu, Baolu @ 2015-11-11  1:32 UTC (permalink / raw)
  To: Dave Young
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel



On 11/10/2015 05:39 PM, Dave Young wrote:
> Hi,
>
> On 11/09/15 at 03:38pm, Lu Baolu wrote:
>> This patch series adds support for early printk through USB3 debug port.
>> USB3 debug port is described in xHCI specification as an optional extended
>> capability.
>>
> I did a test with your previous patchset with the manually wired cable.
> debug host detected the remote device, but later the devie automaticlly
> disconnected and earlyprintk hangs.

Hi Dave,

What I have done is:

(1) Build a new kernel for debug target with this patch series applied.
(2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
      "keep" option for early printk doesn't support yet. (That's my next
      target.)

(3) Boot the debug host, and disable USB runtime suspend:

# echo on > /sys/bus/pci/devices/<xhci_pci_bus_name>/power/control
# echo on | tee /sys/bus/usb/devices/*/power/control

(4) Boot the debug target. Check the dmesg message on debug host.

# tail -f /var/log/kern.log

Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed 
USB device number 4 using xhci_hcd
Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit 
latency is zeroed, disabling LPM.
Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device 
found, idVendor=1d6b, idProduct=0004
Nov 12 01:27:50 allen-ult kernel: [ 1815.999902] usb 4-3: New USB device 
strings: Mfr=1, Product=2, SerialNumber=3
Nov 12 01:27:50 allen-ult kernel: [ 1815.999903] usb 4-3: Product: 
Remote GDB
Nov 12 01:27:50 allen-ult kernel: [ 1815.999904] usb 4-3: Manufacturer: 
Linux
Nov 12 01:27:50 allen-ult kernel: [ 1815.999905] usb 4-3: SerialNumber: 0001
Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: 
xhci_dbc converter detected
Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc 
converter now attached to ttyUSB0

(5) Host has completed enumeration of debug device. Start "minicom" on 
debug host.


Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Jan  1 2014, 17:13:19.
Port /dev/ttyUSB0, 01:28:02

Press CTRL-A Z for help on special keys

Press Y to continue...

(6) You should be able to see "Press Y to continue..." (if not, try 
pressing Enter key)
Press Y key, debug target should go ahead with boot and early boot 
messages should show in mincom.

Press Y to continue...
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 
4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) 5
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+ 
root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
[    0.000000] KERNEL supported cpus:

[...skipped...]

[    0.000000]  Offload RCU callbacks from CPUs: 0-7.
[    0.000000] Console: colour dummy device 80x25
[    0.000000] console [tty0] enabled
[    0.000000] bootconsole [earlyxdbc0] disabled


So "the devie automaticlly disconnected and earlyprintk hangs" happens 
in which step?

Thanks,
Baolu

>
> I have not got more time, will try your new patchset when I have time.
>
> Thanks
> Dave
>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI debug port
  2015-11-10  9:36   ` Dave Young
@ 2015-11-11  2:03     ` Lu, Baolu
  0 siblings, 0 replies; 25+ messages in thread
From: Lu, Baolu @ 2015-11-11  2:03 UTC (permalink / raw)
  To: Dave Young
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel



On 11/10/2015 05:36 PM, Dave Young wrote:
> [snip]
>
>> diff --git a/drivers/usb/host/xhci-sysfs.c b/drivers/usb/host/xhci-sysfs.c
>> new file mode 100644
>> index 0000000..0192ac4
>> --- /dev/null
>> +++ b/drivers/usb/host/xhci-sysfs.c
>> @@ -0,0 +1,100 @@
>> +/*
>> + * sysfs interface for xHCI host controller driver
>> + *
>> + * Copyright (C) 2015 Intel Corp.
>> + *
>> + * Author: Lu Baolu <baolu.lu@linux.intel.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +#include <linux/kernel.h>
>> +
>> +#include "xhci.h"
>> +
>> +/*
>> + * Return the register offset of a extended capability specified
>> + * by @cap_id. Return 0 if @cap_id capability is not supported or
>> + * in error cases.
>> + */
>> +static int get_extended_capability_offset(struct xhci_hcd *xhci,
>> +					int cap_id)
>> +{
>> +	u32		cap_reg;
>> +	unsigned long	flags;
>> +	int		offset;
>> +	void __iomem	*base = (void __iomem *) xhci->cap_regs;
>> +	struct usb_hcd	*hcd = xhci_to_hcd(xhci);
>> +	int		time_to_leave = XHCI_EXT_MAX_CAPID;
>> +
>> +	spin_lock_irqsave(&xhci->lock, flags);
>> +
>> +	offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET);
>> +	if (!HCD_HW_ACCESSIBLE(hcd) || !offset) {
>> +		spin_unlock_irqrestore(&xhci->lock, flags);
>> +		return 0;
>> +	}
>> +
>> +	while (time_to_leave--) {
>> +		cap_reg = readl(base + offset);
>> +
>> +		if (XHCI_EXT_CAPS_ID(cap_reg) == cap_id)
>> +			break;
>> +
>> +		offset = xhci_find_next_cap_offset(base, offset);
>> +		if (!offset)
>> +			break;
>> +	}
>> +
>> +	spin_unlock_irqrestore(&xhci->lock, flags);
> I'm not sure spin_lock is good and necessary here, also seems there's already

The lock is unnecessary here. I will remove it.

> a function to find the cap offset:
> xhci_find_ext_cap_by_id() in xhci-ext-caps.h

Yes, I will refactor the code.

Thanks,
Baolu
>
>> +
>> +	return offset;
>> +}
>> +
> Thanks
> Dave
>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-11  1:32   ` Lu, Baolu
@ 2015-11-11  2:25     ` Dave Young
  2015-11-11  2:42       ` Lu, Baolu
                         ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Dave Young @ 2015-11-11  2:25 UTC (permalink / raw)
  To: Lu, Baolu
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel

Hi,

On 11/11/15 at 09:32am, Lu, Baolu wrote:
> 
> 
> On 11/10/2015 05:39 PM, Dave Young wrote:
> >Hi,
> >
> >On 11/09/15 at 03:38pm, Lu Baolu wrote:
> >>This patch series adds support for early printk through USB3 debug port.
> >>USB3 debug port is described in xHCI specification as an optional extended
> >>capability.
> >>
> >I did a test with your previous patchset with the manually wired cable.
> >debug host detected the remote device, but later the devie automaticlly
> >disconnected and earlyprintk hangs.
> 
> Hi Dave,
> 
> What I have done is:

Retested it, seems it is not stable. I got a sucessful boot with earlyprintk
But only once and there was no "Press Y to continue", I just blindly pressed Y.

The other tests failed.

Since it is not convinience to test, do you have way to enable the dbc
after kernel boot? like echo 1 to a sysfs file to enable it.
> 
> (1) Build a new kernel for debug target with this patch series applied.
> (2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
>      "keep" option for early printk doesn't support yet. (That's my next
>      target.)
> 
> (3) Boot the debug host, and disable USB runtime suspend:
> 
> # echo on > /sys/bus/pci/devices/<xhci_pci_bus_name>/power/control
> # echo on | tee /sys/bus/usb/devices/*/power/control
> 
> (4) Boot the debug target. Check the dmesg message on debug host.
> 
> # tail -f /var/log/kern.log
> 
> Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed USB
> device number 4 using xhci_hcd
> Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit latency
> is zeroed, disabling LPM.
> Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device
> found, idVendor=1d6b, idProduct=0004
> Nov 12 01:27:50 allen-ult kernel: [ 1815.999902] usb 4-3: New USB device
> strings: Mfr=1, Product=2, SerialNumber=3
> Nov 12 01:27:50 allen-ult kernel: [ 1815.999903] usb 4-3: Product: Remote
> GDB
> Nov 12 01:27:50 allen-ult kernel: [ 1815.999904] usb 4-3: Manufacturer:
> Linux
> Nov 12 01:27:50 allen-ult kernel: [ 1815.999905] usb 4-3: SerialNumber: 0001
> Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc
> converter detected
> Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc converter
> now attached to ttyUSB0
> 
> (5) Host has completed enumeration of debug device. Start "minicom" on debug
> host.
> 

Most times I have no chance to run minicom before the usb disconnection here.

> 
> Welcome to minicom 2.7
> 
> OPTIONS: I18n
> Compiled on Jan  1 2014, 17:13:19.
> Port /dev/ttyUSB0, 01:28:02
> 
> Press CTRL-A Z for help on special keys
> 
> Press Y to continue...
> 
> (6) You should be able to see "Press Y to continue..." (if not, try pressing
> Enter key)
> Press Y key, debug target should go ahead with boot and early boot messages
> should show in mincom.
> 
> Press Y to continue...
> [    0.000000] Initializing cgroup subsys cpuset
> [    0.000000] Initializing cgroup subsys cpu
> [    0.000000] Initializing cgroup subsys cpuacct
> [    0.000000] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 4.8.4
> (Ubuntu 4.8.4-2ubuntu1~14.04) 5
> [    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+
> root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
> [    0.000000] KERNEL supported cpus:
> 
> [...skipped...]
> 
> [    0.000000]  Offload RCU callbacks from CPUs: 0-7.
> [    0.000000] Console: colour dummy device 80x25
> [    0.000000] console [tty0] enabled
> [    0.000000] bootconsole [earlyxdbc0] disabled
> 
> 
> So "the devie automaticlly disconnected and earlyprintk hangs" happens in
> which step?
> 

Here is some log on host side.

[ 1568.052135] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
[ 1568.063416] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1568.063750] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1568.063751] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1568.063752] usb 2-2: Product: Remote GDB
[ 1568.063753] usb 2-2: Manufacturer: Linux
[ 1568.063754] usb 2-2: SerialNumber: 0001
[ 1568.065580] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1568.066309] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1580.464706] usb 2-2: USB disconnect, device number 5
[ 1580.464996] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1580.465062] usb_debug 2-2:1.0: device disconnected
[ 1580.670743] usb 2-2: new SuperSpeed USB device number 6 using xhci_hcd
[ 1580.682068] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1580.682667] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1580.682672] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1580.682675] usb 2-2: Product: Remote GDB
[ 1580.682678] usb 2-2: Manufacturer: Linux
[ 1580.682681] usb 2-2: SerialNumber: 0001
[ 1580.685190] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1580.687106] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1586.751477] usb 2-2: USB disconnect, device number 6
[ 1586.754248] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1586.754287] usb_debug 2-2:1.0: device disconnected
[ 1586.960399] usb 2-2: new SuperSpeed USB device number 7 using xhci_hcd
[ 1586.971562] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1586.971916] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1586.971918] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1586.971919] usb 2-2: Product: Remote GDB
[ 1586.971921] usb 2-2: Manufacturer: Linux
[ 1586.971922] usb 2-2: SerialNumber: 0001
[ 1586.973140] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1586.973939] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1616.615418] usb 2-2: USB disconnect, device number 7
[ 1616.617865] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1616.617918] usb_debug 2-2:1.0: device disconnected
[ 1616.823351] usb 2-2: new SuperSpeed USB device number 8 using xhci_hcd
[ 1616.834520] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1616.834856] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1616.834858] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1616.834859] usb 2-2: Product: Remote GDB
[ 1616.834860] usb 2-2: Manufacturer: Linux
[ 1616.834860] usb 2-2: SerialNumber: 0001
[ 1616.836715] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1616.837327] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1622.719311] usb 2-2: USB disconnect, device number 8
[ 1622.721962] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1622.721995] usb_debug 2-2:1.0: device disconnected
[ 1622.928226] usb 2-2: new SuperSpeed USB device number 9 using xhci_hcd
[ 1622.939383] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1622.939714] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1622.939715] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1622.939716] usb 2-2: Product: Remote GDB
[ 1622.939717] usb 2-2: Manufacturer: Linux
[ 1622.939718] usb 2-2: SerialNumber: 0001
[ 1622.941593] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1622.942187] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1631.312112] usb 2-2: USB disconnect, device number 9
[ 1631.315427] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1631.315465] usb_debug 2-2:1.0: device disconnected
[ 1631.521007] usb 2-2: new SuperSpeed USB device number 10 using xhci_hcd
[ 1631.532212] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1631.532544] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1631.532545] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1631.532546] usb 2-2: Product: Remote GDB
[ 1631.532547] usb 2-2: Manufacturer: Linux
[ 1631.532548] usb 2-2: SerialNumber: 0001
[ 1631.534413] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1631.535117] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1633.252488] usb 2-2: USB disconnect, device number 10
[ 1633.255279] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1633.255314] usb_debug 2-2:1.0: device disconnected
[ 1633.461411] usb 2-2: new SuperSpeed USB device number 11 using xhci_hcd
[ 1633.472598] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1633.472932] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1633.472933] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1633.472934] usb 2-2: Product: Remote GDB
[ 1633.472935] usb 2-2: Manufacturer: Linux
[ 1633.472936] usb 2-2: SerialNumber: 0001
[ 1633.473987] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1633.474624] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1633.900927] usb 2-2: USB disconnect, device number 11
[ 1633.901176] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
[ 1633.901226] usb_debug 2-2:1.0: device disconnected
[ 1634.106831] usb 2-2: new SuperSpeed USB device number 12 using xhci_hcd
[ 1634.117987] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1634.118328] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1634.118329] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1634.118330] usb 2-2: Product: Remote GDB
[ 1634.118331] usb 2-2: Manufacturer: Linux
[ 1634.118332] usb 2-2: SerialNumber: 0001
[ 1634.120194] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1634.120949] usb 2-2: xhci_dbc converter now attached to ttyUSB0

Thanks
Dave

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-11  2:25     ` Dave Young
@ 2015-11-11  2:42       ` Lu, Baolu
  2015-11-11  5:57       ` Lu, Baolu
  2015-11-12  2:45       ` Lu, Baolu
  2 siblings, 0 replies; 25+ messages in thread
From: Lu, Baolu @ 2015-11-11  2:42 UTC (permalink / raw)
  To: Dave Young
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel



On 11/11/2015 10:25 AM, Dave Young wrote:
> Hi,
>
> On 11/11/15 at 09:32am, Lu, Baolu wrote:
>>
>> On 11/10/2015 05:39 PM, Dave Young wrote:
>>> Hi,
>>>
>>> On 11/09/15 at 03:38pm, Lu Baolu wrote:
>>>> This patch series adds support for early printk through USB3 debug port.
>>>> USB3 debug port is described in xHCI specification as an optional extended
>>>> capability.
>>>>
>>> I did a test with your previous patchset with the manually wired cable.
>>> debug host detected the remote device, but later the devie automaticlly
>>> disconnected and earlyprintk hangs.
>> Hi Dave,
>>
>> What I have done is:
> Retested it, seems it is not stable. I got a sucessful boot with earlyprintk
> But only once and there was no "Press Y to continue", I just blindly pressed Y.
>
> The other tests failed.

Problem seems to exist at the place where host and target sync with
each other.

>
> Since it is not convinience to test, do you have way to enable the dbc
> after kernel boot? like echo 1 to a sysfs file to enable it.

This is the first phase of code. I could do this in the next phase.
The problems exist in the interferer between DbC and the host
controller. They share the same power well so host reset, or
suspend/resume will cause DbC not work.

>> (1) Build a new kernel for debug target with this patch series applied.
>> (2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
>>       "keep" option for early printk doesn't support yet. (That's my next
>>       target.)
>>
>> (3) Boot the debug host, and disable USB runtime suspend:
>>
>> # echo on > /sys/bus/pci/devices/<xhci_pci_bus_name>/power/control
>> # echo on | tee /sys/bus/usb/devices/*/power/control
>>
>> (4) Boot the debug target. Check the dmesg message on debug host.
>>
>> # tail -f /var/log/kern.log
>>
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed USB
>> device number 4 using xhci_hcd
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit latency
>> is zeroed, disabling LPM.
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device
>> found, idVendor=1d6b, idProduct=0004
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999902] usb 4-3: New USB device
>> strings: Mfr=1, Product=2, SerialNumber=3
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999903] usb 4-3: Product: Remote
>> GDB
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999904] usb 4-3: Manufacturer:
>> Linux
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999905] usb 4-3: SerialNumber: 0001
>> Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc
>> converter detected
>> Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc converter
>> now attached to ttyUSB0
>>
>> (5) Host has completed enumeration of debug device. Start "minicom" on debug
>> host.
>>
> Most times I have no chance to run minicom before the usb disconnection here.

I will send you a new version for test later. By the way, which hardware
are you using for test?

>
>> Welcome to minicom 2.7
>>
>> OPTIONS: I18n
>> Compiled on Jan  1 2014, 17:13:19.
>> Port /dev/ttyUSB0, 01:28:02
>>
>> Press CTRL-A Z for help on special keys
>>
>> Press Y to continue...
>>
>> (6) You should be able to see "Press Y to continue..." (if not, try pressing
>> Enter key)
>> Press Y key, debug target should go ahead with boot and early boot messages
>> should show in mincom.
>>
>> Press Y to continue...
>> [    0.000000] Initializing cgroup subsys cpuset
>> [    0.000000] Initializing cgroup subsys cpu
>> [    0.000000] Initializing cgroup subsys cpuacct
>> [    0.000000] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 4.8.4
>> (Ubuntu 4.8.4-2ubuntu1~14.04) 5
>> [    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+
>> root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
>> [    0.000000] KERNEL supported cpus:
>>
>> [...skipped...]
>>
>> [    0.000000]  Offload RCU callbacks from CPUs: 0-7.
>> [    0.000000] Console: colour dummy device 80x25
>> [    0.000000] console [tty0] enabled
>> [    0.000000] bootconsole [earlyxdbc0] disabled
>>
>>
>> So "the devie automaticlly disconnected and earlyprintk hangs" happens in
>> which step?
>>
> Here is some log on host side.
>
> [ 1568.052135] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
> [ 1568.063416] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1568.063750] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1568.063751] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1568.063752] usb 2-2: Product: Remote GDB
> [ 1568.063753] usb 2-2: Manufacturer: Linux
> [ 1568.063754] usb 2-2: SerialNumber: 0001
> [ 1568.065580] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1568.066309] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1580.464706] usb 2-2: USB disconnect, device number 5
> [ 1580.464996] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1580.465062] usb_debug 2-2:1.0: device disconnected
> [ 1580.670743] usb 2-2: new SuperSpeed USB device number 6 using xhci_hcd
> [ 1580.682068] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1580.682667] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1580.682672] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1580.682675] usb 2-2: Product: Remote GDB
> [ 1580.682678] usb 2-2: Manufacturer: Linux
> [ 1580.682681] usb 2-2: SerialNumber: 0001
> [ 1580.685190] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1580.687106] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1586.751477] usb 2-2: USB disconnect, device number 6
> [ 1586.754248] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1586.754287] usb_debug 2-2:1.0: device disconnected
> [ 1586.960399] usb 2-2: new SuperSpeed USB device number 7 using xhci_hcd
> [ 1586.971562] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1586.971916] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1586.971918] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1586.971919] usb 2-2: Product: Remote GDB
> [ 1586.971921] usb 2-2: Manufacturer: Linux
> [ 1586.971922] usb 2-2: SerialNumber: 0001
> [ 1586.973140] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1586.973939] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1616.615418] usb 2-2: USB disconnect, device number 7
> [ 1616.617865] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1616.617918] usb_debug 2-2:1.0: device disconnected
> [ 1616.823351] usb 2-2: new SuperSpeed USB device number 8 using xhci_hcd
> [ 1616.834520] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1616.834856] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1616.834858] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1616.834859] usb 2-2: Product: Remote GDB
> [ 1616.834860] usb 2-2: Manufacturer: Linux
> [ 1616.834860] usb 2-2: SerialNumber: 0001
> [ 1616.836715] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1616.837327] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1622.719311] usb 2-2: USB disconnect, device number 8
> [ 1622.721962] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1622.721995] usb_debug 2-2:1.0: device disconnected
> [ 1622.928226] usb 2-2: new SuperSpeed USB device number 9 using xhci_hcd
> [ 1622.939383] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1622.939714] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1622.939715] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1622.939716] usb 2-2: Product: Remote GDB
> [ 1622.939717] usb 2-2: Manufacturer: Linux
> [ 1622.939718] usb 2-2: SerialNumber: 0001
> [ 1622.941593] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1622.942187] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1631.312112] usb 2-2: USB disconnect, device number 9
> [ 1631.315427] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1631.315465] usb_debug 2-2:1.0: device disconnected
> [ 1631.521007] usb 2-2: new SuperSpeed USB device number 10 using xhci_hcd
> [ 1631.532212] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1631.532544] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1631.532545] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1631.532546] usb 2-2: Product: Remote GDB
> [ 1631.532547] usb 2-2: Manufacturer: Linux
> [ 1631.532548] usb 2-2: SerialNumber: 0001
> [ 1631.534413] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1631.535117] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1633.252488] usb 2-2: USB disconnect, device number 10
> [ 1633.255279] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1633.255314] usb_debug 2-2:1.0: device disconnected
> [ 1633.461411] usb 2-2: new SuperSpeed USB device number 11 using xhci_hcd
> [ 1633.472598] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1633.472932] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1633.472933] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1633.472934] usb 2-2: Product: Remote GDB
> [ 1633.472935] usb 2-2: Manufacturer: Linux
> [ 1633.472936] usb 2-2: SerialNumber: 0001
> [ 1633.473987] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1633.474624] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1633.900927] usb 2-2: USB disconnect, device number 11
> [ 1633.901176] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1633.901226] usb_debug 2-2:1.0: device disconnected
> [ 1634.106831] usb 2-2: new SuperSpeed USB device number 12 using xhci_hcd
> [ 1634.117987] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1634.118328] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1634.118329] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1634.118330] usb 2-2: Product: Remote GDB
> [ 1634.118331] usb 2-2: Manufacturer: Linux
> [ 1634.118332] usb 2-2: SerialNumber: 0001
> [ 1634.120194] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1634.120949] usb 2-2: xhci_dbc converter now attached to ttyUSB0
>
> Thanks
> Dave

Thanks,
Baolu



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-11  2:25     ` Dave Young
  2015-11-11  2:42       ` Lu, Baolu
@ 2015-11-11  5:57       ` Lu, Baolu
  2015-11-12  2:45       ` Lu, Baolu
  2 siblings, 0 replies; 25+ messages in thread
From: Lu, Baolu @ 2015-11-11  5:57 UTC (permalink / raw)
  To: Dave Young
  Cc: Mathias Nyman, Greg Kroah-Hartman, Alan Stern, linux-usb, x86,
	linux-kernel



On 11/11/2015 10:25 AM, Dave Young wrote:
> [ 1616.823351] usb 2-2: new SuperSpeed USB device number 8 using xhci_hcd
> [ 1616.834520] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1616.834856] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1616.834858] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1616.834859] usb 2-2: Product: Remote GDB
> [ 1616.834860] usb 2-2: Manufacturer: Linux
> [ 1616.834860] usb 2-2: SerialNumber: 0001
> [ 1616.836715] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1616.837327] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1622.719311] usb 2-2: USB disconnect, device number 8
  Hi Dave,

I revisited the kernel log. It seems the debug host enumerated
the debug target successfully. Can you please check the
minicom configuration?

The configure on my debug host looks like below.

Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Jan  1 2014, 17:13:19.
Port /dev/ttyUSB0, 01:28:02

Rate: 115200

Please make sure you have disabled runtime power management
for USB devices and host controller in debug host. And sometimes,
reboot the debug host helps when enumeration fails.

Thanks,
Baolu

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-11  2:25     ` Dave Young
  2015-11-11  2:42       ` Lu, Baolu
  2015-11-11  5:57       ` Lu, Baolu
@ 2015-11-12  2:45       ` Lu, Baolu
  2015-11-12  6:01         ` Dave Young
  2 siblings, 1 reply; 25+ messages in thread
From: Lu, Baolu @ 2015-11-12  2:45 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-usb, linux-kernel

Hi Dave,

Which device are you testing with? This implementation was developed
and tested on Intel Skylake devices.

It doesn't surprise me if it doesn't work with other silicons. But it do
remind me to create a verified-list and put those known-to-work devices
in it.

Thanks,
Baolu

On 11/11/2015 10:25 AM, Dave Young wrote:
> Hi,
>
> On 11/11/15 at 09:32am, Lu, Baolu wrote:
>>
>> On 11/10/2015 05:39 PM, Dave Young wrote:
>>> Hi,
>>>
>>> On 11/09/15 at 03:38pm, Lu Baolu wrote:
>>>> This patch series adds support for early printk through USB3 debug port.
>>>> USB3 debug port is described in xHCI specification as an optional extended
>>>> capability.
>>>>
>>> I did a test with your previous patchset with the manually wired cable.
>>> debug host detected the remote device, but later the devie automaticlly
>>> disconnected and earlyprintk hangs.
>> Hi Dave,
>>
>> What I have done is:
> Retested it, seems it is not stable. I got a sucessful boot with earlyprintk
> But only once and there was no "Press Y to continue", I just blindly pressed Y.
>
> The other tests failed.
>
> Since it is not convinience to test, do you have way to enable the dbc
> after kernel boot? like echo 1 to a sysfs file to enable it.
>> (1) Build a new kernel for debug target with this patch series applied.
>> (2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
>>       "keep" option for early printk doesn't support yet. (That's my next
>>       target.)
>>
>> (3) Boot the debug host, and disable USB runtime suspend:
>>
>> # echo on > /sys/bus/pci/devices/<xhci_pci_bus_name>/power/control
>> # echo on | tee /sys/bus/usb/devices/*/power/control
>>
>> (4) Boot the debug target. Check the dmesg message on debug host.
>>
>> # tail -f /var/log/kern.log
>>
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed USB
>> device number 4 using xhci_hcd
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit latency
>> is zeroed, disabling LPM.
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device
>> found, idVendor=1d6b, idProduct=0004
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999902] usb 4-3: New USB device
>> strings: Mfr=1, Product=2, SerialNumber=3
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999903] usb 4-3: Product: Remote
>> GDB
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999904] usb 4-3: Manufacturer:
>> Linux
>> Nov 12 01:27:50 allen-ult kernel: [ 1815.999905] usb 4-3: SerialNumber: 0001
>> Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc
>> converter detected
>> Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc converter
>> now attached to ttyUSB0
>>
>> (5) Host has completed enumeration of debug device. Start "minicom" on debug
>> host.
>>
> Most times I have no chance to run minicom before the usb disconnection here.
>
>> Welcome to minicom 2.7
>>
>> OPTIONS: I18n
>> Compiled on Jan  1 2014, 17:13:19.
>> Port /dev/ttyUSB0, 01:28:02
>>
>> Press CTRL-A Z for help on special keys
>>
>> Press Y to continue...
>>
>> (6) You should be able to see "Press Y to continue..." (if not, try pressing
>> Enter key)
>> Press Y key, debug target should go ahead with boot and early boot messages
>> should show in mincom.
>>
>> Press Y to continue...
>> [    0.000000] Initializing cgroup subsys cpuset
>> [    0.000000] Initializing cgroup subsys cpu
>> [    0.000000] Initializing cgroup subsys cpuacct
>> [    0.000000] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 4.8.4
>> (Ubuntu 4.8.4-2ubuntu1~14.04) 5
>> [    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+
>> root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
>> [    0.000000] KERNEL supported cpus:
>>
>> [...skipped...]
>>
>> [    0.000000]  Offload RCU callbacks from CPUs: 0-7.
>> [    0.000000] Console: colour dummy device 80x25
>> [    0.000000] console [tty0] enabled
>> [    0.000000] bootconsole [earlyxdbc0] disabled
>>
>>
>> So "the devie automaticlly disconnected and earlyprintk hangs" happens in
>> which step?
>>
> Here is some log on host side.
>
> [ 1568.052135] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
> [ 1568.063416] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1568.063750] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1568.063751] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1568.063752] usb 2-2: Product: Remote GDB
> [ 1568.063753] usb 2-2: Manufacturer: Linux
> [ 1568.063754] usb 2-2: SerialNumber: 0001
> [ 1568.065580] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1568.066309] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1580.464706] usb 2-2: USB disconnect, device number 5
> [ 1580.464996] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1580.465062] usb_debug 2-2:1.0: device disconnected
> [ 1580.670743] usb 2-2: new SuperSpeed USB device number 6 using xhci_hcd
> [ 1580.682068] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1580.682667] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1580.682672] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1580.682675] usb 2-2: Product: Remote GDB
> [ 1580.682678] usb 2-2: Manufacturer: Linux
> [ 1580.682681] usb 2-2: SerialNumber: 0001
> [ 1580.685190] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1580.687106] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1586.751477] usb 2-2: USB disconnect, device number 6
> [ 1586.754248] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1586.754287] usb_debug 2-2:1.0: device disconnected
> [ 1586.960399] usb 2-2: new SuperSpeed USB device number 7 using xhci_hcd
> [ 1586.971562] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1586.971916] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1586.971918] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1586.971919] usb 2-2: Product: Remote GDB
> [ 1586.971921] usb 2-2: Manufacturer: Linux
> [ 1586.971922] usb 2-2: SerialNumber: 0001
> [ 1586.973140] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1586.973939] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1616.615418] usb 2-2: USB disconnect, device number 7
> [ 1616.617865] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1616.617918] usb_debug 2-2:1.0: device disconnected
> [ 1616.823351] usb 2-2: new SuperSpeed USB device number 8 using xhci_hcd
> [ 1616.834520] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1616.834856] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1616.834858] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1616.834859] usb 2-2: Product: Remote GDB
> [ 1616.834860] usb 2-2: Manufacturer: Linux
> [ 1616.834860] usb 2-2: SerialNumber: 0001
> [ 1616.836715] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1616.837327] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1622.719311] usb 2-2: USB disconnect, device number 8
> [ 1622.721962] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1622.721995] usb_debug 2-2:1.0: device disconnected
> [ 1622.928226] usb 2-2: new SuperSpeed USB device number 9 using xhci_hcd
> [ 1622.939383] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1622.939714] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1622.939715] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1622.939716] usb 2-2: Product: Remote GDB
> [ 1622.939717] usb 2-2: Manufacturer: Linux
> [ 1622.939718] usb 2-2: SerialNumber: 0001
> [ 1622.941593] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1622.942187] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1631.312112] usb 2-2: USB disconnect, device number 9
> [ 1631.315427] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1631.315465] usb_debug 2-2:1.0: device disconnected
> [ 1631.521007] usb 2-2: new SuperSpeed USB device number 10 using xhci_hcd
> [ 1631.532212] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1631.532544] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1631.532545] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1631.532546] usb 2-2: Product: Remote GDB
> [ 1631.532547] usb 2-2: Manufacturer: Linux
> [ 1631.532548] usb 2-2: SerialNumber: 0001
> [ 1631.534413] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1631.535117] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1633.252488] usb 2-2: USB disconnect, device number 10
> [ 1633.255279] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1633.255314] usb_debug 2-2:1.0: device disconnected
> [ 1633.461411] usb 2-2: new SuperSpeed USB device number 11 using xhci_hcd
> [ 1633.472598] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1633.472932] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1633.472933] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1633.472934] usb 2-2: Product: Remote GDB
> [ 1633.472935] usb 2-2: Manufacturer: Linux
> [ 1633.472936] usb 2-2: SerialNumber: 0001
> [ 1633.473987] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1633.474624] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> [ 1633.900927] usb 2-2: USB disconnect, device number 11
> [ 1633.901176] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> [ 1633.901226] usb_debug 2-2:1.0: device disconnected
> [ 1634.106831] usb 2-2: new SuperSpeed USB device number 12 using xhci_hcd
> [ 1634.117987] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> [ 1634.118328] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> [ 1634.118329] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> [ 1634.118330] usb 2-2: Product: Remote GDB
> [ 1634.118331] usb 2-2: Manufacturer: Linux
> [ 1634.118332] usb 2-2: SerialNumber: 0001
> [ 1634.120194] usb_debug 2-2:1.0: xhci_dbc converter detected
> [ 1634.120949] usb 2-2: xhci_dbc converter now attached to ttyUSB0
>
> Thanks
> Dave
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-12  2:45       ` Lu, Baolu
@ 2015-11-12  6:01         ` Dave Young
  2015-11-13  2:04           ` Lu, Baolu
  0 siblings, 1 reply; 25+ messages in thread
From: Dave Young @ 2015-11-12  6:01 UTC (permalink / raw)
  To: Lu, Baolu; +Cc: linux-usb, linux-kernel

Hi, Baolu

On 11/12/15 at 10:45am, Lu, Baolu wrote:
> Hi Dave,
> 
> Which device are you testing with? This implementation was developed
> and tested on Intel Skylake devices.
> 
> It doesn't surprise me if it doesn't work with other silicons. But it do
> remind me to create a verified-list and put those known-to-work devices
> in it.
> 

I have not got time to do more test. What infomation do you want? 
lsusb -v?


> Thanks,
> Baolu
> 
> On 11/11/2015 10:25 AM, Dave Young wrote:
> >Hi,
> >
> >On 11/11/15 at 09:32am, Lu, Baolu wrote:
> >>
> >>On 11/10/2015 05:39 PM, Dave Young wrote:
> >>>Hi,
> >>>
> >>>On 11/09/15 at 03:38pm, Lu Baolu wrote:
> >>>>This patch series adds support for early printk through USB3 debug port.
> >>>>USB3 debug port is described in xHCI specification as an optional extended
> >>>>capability.
> >>>>
> >>>I did a test with your previous patchset with the manually wired cable.
> >>>debug host detected the remote device, but later the devie automaticlly
> >>>disconnected and earlyprintk hangs.
> >>Hi Dave,
> >>
> >>What I have done is:
> >Retested it, seems it is not stable. I got a sucessful boot with earlyprintk
> >But only once and there was no "Press Y to continue", I just blindly pressed Y.
> >
> >The other tests failed.
> >
> >Since it is not convinience to test, do you have way to enable the dbc
> >after kernel boot? like echo 1 to a sysfs file to enable it.
> >>(1) Build a new kernel for debug target with this patch series applied.
> >>(2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
> >>      "keep" option for early printk doesn't support yet. (That's my next
> >>      target.)
> >>
> >>(3) Boot the debug host, and disable USB runtime suspend:
> >>
> >># echo on > /sys/bus/pci/devices/<xhci_pci_bus_name>/power/control
> >># echo on | tee /sys/bus/usb/devices/*/power/control
> >>
> >>(4) Boot the debug target. Check the dmesg message on debug host.
> >>
> >># tail -f /var/log/kern.log
> >>
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed USB
> >>device number 4 using xhci_hcd
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit latency
> >>is zeroed, disabling LPM.
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device
> >>found, idVendor=1d6b, idProduct=0004
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999902] usb 4-3: New USB device
> >>strings: Mfr=1, Product=2, SerialNumber=3
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999903] usb 4-3: Product: Remote
> >>GDB
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999904] usb 4-3: Manufacturer:
> >>Linux
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999905] usb 4-3: SerialNumber: 0001
> >>Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc
> >>converter detected
> >>Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc converter
> >>now attached to ttyUSB0
> >>
> >>(5) Host has completed enumeration of debug device. Start "minicom" on debug
> >>host.
> >>
> >Most times I have no chance to run minicom before the usb disconnection here.
> >
> >>Welcome to minicom 2.7
> >>
> >>OPTIONS: I18n
> >>Compiled on Jan  1 2014, 17:13:19.
> >>Port /dev/ttyUSB0, 01:28:02
> >>
> >>Press CTRL-A Z for help on special keys
> >>
> >>Press Y to continue...
> >>
> >>(6) You should be able to see "Press Y to continue..." (if not, try pressing
> >>Enter key)
> >>Press Y key, debug target should go ahead with boot and early boot messages
> >>should show in mincom.
> >>
> >>Press Y to continue...
> >>[    0.000000] Initializing cgroup subsys cpuset
> >>[    0.000000] Initializing cgroup subsys cpu
> >>[    0.000000] Initializing cgroup subsys cpuacct
> >>[    0.000000] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 4.8.4
> >>(Ubuntu 4.8.4-2ubuntu1~14.04) 5
> >>[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+
> >>root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
> >>[    0.000000] KERNEL supported cpus:
> >>
> >>[...skipped...]
> >>
> >>[    0.000000]  Offload RCU callbacks from CPUs: 0-7.
> >>[    0.000000] Console: colour dummy device 80x25
> >>[    0.000000] console [tty0] enabled
> >>[    0.000000] bootconsole [earlyxdbc0] disabled
> >>
> >>
> >>So "the devie automaticlly disconnected and earlyprintk hangs" happens in
> >>which step?
> >>
> >Here is some log on host side.
> >
> >[ 1568.052135] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
> >[ 1568.063416] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1568.063750] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1568.063751] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1568.063752] usb 2-2: Product: Remote GDB
> >[ 1568.063753] usb 2-2: Manufacturer: Linux
> >[ 1568.063754] usb 2-2: SerialNumber: 0001
> >[ 1568.065580] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1568.066309] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1580.464706] usb 2-2: USB disconnect, device number 5
> >[ 1580.464996] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1580.465062] usb_debug 2-2:1.0: device disconnected
> >[ 1580.670743] usb 2-2: new SuperSpeed USB device number 6 using xhci_hcd
> >[ 1580.682068] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1580.682667] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1580.682672] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1580.682675] usb 2-2: Product: Remote GDB
> >[ 1580.682678] usb 2-2: Manufacturer: Linux
> >[ 1580.682681] usb 2-2: SerialNumber: 0001
> >[ 1580.685190] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1580.687106] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1586.751477] usb 2-2: USB disconnect, device number 6
> >[ 1586.754248] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1586.754287] usb_debug 2-2:1.0: device disconnected
> >[ 1586.960399] usb 2-2: new SuperSpeed USB device number 7 using xhci_hcd
> >[ 1586.971562] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1586.971916] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1586.971918] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1586.971919] usb 2-2: Product: Remote GDB
> >[ 1586.971921] usb 2-2: Manufacturer: Linux
> >[ 1586.971922] usb 2-2: SerialNumber: 0001
> >[ 1586.973140] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1586.973939] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1616.615418] usb 2-2: USB disconnect, device number 7
> >[ 1616.617865] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1616.617918] usb_debug 2-2:1.0: device disconnected
> >[ 1616.823351] usb 2-2: new SuperSpeed USB device number 8 using xhci_hcd
> >[ 1616.834520] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1616.834856] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1616.834858] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1616.834859] usb 2-2: Product: Remote GDB
> >[ 1616.834860] usb 2-2: Manufacturer: Linux
> >[ 1616.834860] usb 2-2: SerialNumber: 0001
> >[ 1616.836715] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1616.837327] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1622.719311] usb 2-2: USB disconnect, device number 8
> >[ 1622.721962] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1622.721995] usb_debug 2-2:1.0: device disconnected
> >[ 1622.928226] usb 2-2: new SuperSpeed USB device number 9 using xhci_hcd
> >[ 1622.939383] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1622.939714] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1622.939715] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1622.939716] usb 2-2: Product: Remote GDB
> >[ 1622.939717] usb 2-2: Manufacturer: Linux
> >[ 1622.939718] usb 2-2: SerialNumber: 0001
> >[ 1622.941593] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1622.942187] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1631.312112] usb 2-2: USB disconnect, device number 9
> >[ 1631.315427] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1631.315465] usb_debug 2-2:1.0: device disconnected
> >[ 1631.521007] usb 2-2: new SuperSpeed USB device number 10 using xhci_hcd
> >[ 1631.532212] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1631.532544] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1631.532545] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1631.532546] usb 2-2: Product: Remote GDB
> >[ 1631.532547] usb 2-2: Manufacturer: Linux
> >[ 1631.532548] usb 2-2: SerialNumber: 0001
> >[ 1631.534413] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1631.535117] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1633.252488] usb 2-2: USB disconnect, device number 10
> >[ 1633.255279] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1633.255314] usb_debug 2-2:1.0: device disconnected
> >[ 1633.461411] usb 2-2: new SuperSpeed USB device number 11 using xhci_hcd
> >[ 1633.472598] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1633.472932] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1633.472933] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1633.472934] usb 2-2: Product: Remote GDB
> >[ 1633.472935] usb 2-2: Manufacturer: Linux
> >[ 1633.472936] usb 2-2: SerialNumber: 0001
> >[ 1633.473987] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1633.474624] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1633.900927] usb 2-2: USB disconnect, device number 11
> >[ 1633.901176] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from ttyUSB0
> >[ 1633.901226] usb_debug 2-2:1.0: device disconnected
> >[ 1634.106831] usb 2-2: new SuperSpeed USB device number 12 using xhci_hcd
> >[ 1634.117987] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1634.118328] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1634.118329] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> >[ 1634.118330] usb 2-2: Product: Remote GDB
> >[ 1634.118331] usb 2-2: Manufacturer: Linux
> >[ 1634.118332] usb 2-2: SerialNumber: 0001
> >[ 1634.120194] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1634.120949] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >
> >Thanks
> >Dave
> >--
> >To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> >the body of a message to majordomo@vger.kernel.org
> >More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-12  6:01         ` Dave Young
@ 2015-11-13  2:04           ` Lu, Baolu
  2015-11-13  2:26             ` Dave Young
  0 siblings, 1 reply; 25+ messages in thread
From: Lu, Baolu @ 2015-11-13  2:04 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-usb, linux-kernel

Hi Dave,

On 11/12/2015 02:01 PM, Dave Young wrote:
> Hi, Baolu
>
> On 11/12/15 at 10:45am, Lu, Baolu wrote:
>> >Hi Dave,
>> >
>> >Which device are you testing with? This implementation was developed
>> >and tested on Intel Skylake devices.
>> >
>> >It doesn't surprise me if it doesn't work with other silicons. But it do
>> >remind me to create a verified-list and put those known-to-work devices
>> >in it.
>> >
> I have not got time to do more test. What infomation do you want?
> lsusb -v?

lspci -v

Thanks,
-Baolu

>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-13  2:04           ` Lu, Baolu
@ 2015-11-13  2:26             ` Dave Young
  2015-11-13  6:23               ` Lu Baolu
  0 siblings, 1 reply; 25+ messages in thread
From: Dave Young @ 2015-11-13  2:26 UTC (permalink / raw)
  To: Lu, Baolu; +Cc: linux-usb, linux-kernel

On 11/13/15 at 10:04am, Lu, Baolu wrote:
> Hi Dave,
> 
> On 11/12/2015 02:01 PM, Dave Young wrote:
> >Hi, Baolu
> >
> >On 11/12/15 at 10:45am, Lu, Baolu wrote:
> >>>Hi Dave,
> >>>
> >>>Which device are you testing with? This implementation was developed
> >>>and tested on Intel Skylake devices.
> >>>
> >>>It doesn't surprise me if it doesn't work with other silicons. But it do
> >>>remind me to create a verified-list and put those known-to-work devices
> >>>in it.
> >>>
> >I have not got time to do more test. What infomation do you want?
> >lsusb -v?
> 
> lspci -v
> 

Here is the controller information:

Host side:

00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05) (prog-if 30 [XHCI])
	Subsystem: Hewlett-Packard Company Device 1905
	Flags: bus master, medium devsel, latency 0, IRQ 27
	Memory at ef120000 (64-bit, non-prefetchable) [size=64K]
	Capabilities: <access denied>
	Kernel driver in use: xhci_hcd

Target side:

00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04) (prog-if 30 [XHCI])
	Subsystem: Lenovo Device 220c
	Flags: bus master, medium devsel, latency 0, IRQ 41
	Memory at f0620000 (64-bit, non-prefetchable) [size=64K]
	Capabilities: <access denied>
	Kernel driver in use: xhci_hcd

Thanks
Dave

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port
  2015-11-13  2:26             ` Dave Young
@ 2015-11-13  6:23               ` Lu Baolu
  0 siblings, 0 replies; 25+ messages in thread
From: Lu Baolu @ 2015-11-13  6:23 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-usb, linux-kernel



On 11/13/2015 10:26 AM, Dave Young wrote:
> On 11/13/15 at 10:04am, Lu, Baolu wrote:
>> Hi Dave,
>>
>> On 11/12/2015 02:01 PM, Dave Young wrote:
>>> Hi, Baolu
>>>
>>> On 11/12/15 at 10:45am, Lu, Baolu wrote:
>>>>> Hi Dave,
>>>>>
>>>>> Which device are you testing with? This implementation was developed
>>>>> and tested on Intel Skylake devices.
>>>>>
>>>>> It doesn't surprise me if it doesn't work with other silicons. But it do
>>>>> remind me to create a verified-list and put those known-to-work devices
>>>>> in it.
>>>>>
>>> I have not got time to do more test. What infomation do you want?
>>> lsusb -v?
>> lspci -v
>>
> Here is the controller information:
>
> Host side:
>
> 00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05) (prog-if 30 [XHCI])
> 	Subsystem: Hewlett-Packard Company Device 1905
> 	Flags: bus master, medium devsel, latency 0, IRQ 27
> 	Memory at ef120000 (64-bit, non-prefetchable) [size=64K]
> 	Capabilities: <access denied>
> 	Kernel driver in use: xhci_hcd
>
> Target side:
>
> 00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04) (prog-if 30 [XHCI])
> 	Subsystem: Lenovo Device 220c
> 	Flags: bus master, medium devsel, latency 0, IRQ 41
> 	Memory at f0620000 (64-bit, non-prefetchable) [size=64K]
> 	Capabilities: <access denied>
> 	Kernel driver in use: xhci_hcd

Okay, thank you.

Thanks,
-Baolu

> Thanks
> Dave
>


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-11-13  6:23 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
2015-11-09  7:38 ` [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI " Lu Baolu
2015-11-10  9:36   ` Dave Young
2015-11-11  2:03     ` Lu, Baolu
2015-11-09  7:38 ` [PATCH v3 02/12] x86: fixmap: add permanent fixmap for xhci " Lu Baolu
2015-11-09  7:38 ` [PATCH v3 03/12] usb: xhci: dbc: probe and setup xhci debug capability Lu Baolu
2015-11-09  7:38 ` [PATCH v3 04/12] usb: xhci: dbc: add support for Intel xHCI dbc quirk Lu Baolu
2015-11-09  7:38 ` [PATCH v3 05/12] usb: xhci: dbc: add debug buffer Lu Baolu
2015-11-09  7:38 ` [PATCH v3 06/12] usb: xhci: dbc: add bulk out and bulk in interfaces Lu Baolu
2015-11-09  7:38 ` [PATCH v3 07/12] usb: xhci: dbc: handle dbc-configured exit Lu Baolu
2015-11-09  7:38 ` [PATCH v3 08/12] usb: xhci: dbc: handle endpoint stall Lu Baolu
2015-11-09  7:38 ` [PATCH v3 09/12] x86: early_printk: add USB3 debug port earlyprintk support Lu Baolu
2015-11-09  7:38 ` [PATCH v3 10/12] usb: xhci: dbc: add handshake between debug target and host Lu Baolu
2015-11-09  7:38 ` [PATCH v3 11/12] usb: serial: usb_debug: add support for dbc debug device Lu Baolu
2015-11-09  7:38 ` [PATCH v3 12/12] usb: doc: add document for xHCI DbC driver Lu Baolu
2015-11-10  9:39 ` [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Dave Young
2015-11-11  1:32   ` Lu, Baolu
2015-11-11  2:25     ` Dave Young
2015-11-11  2:42       ` Lu, Baolu
2015-11-11  5:57       ` Lu, Baolu
2015-11-12  2:45       ` Lu, Baolu
2015-11-12  6:01         ` Dave Young
2015-11-13  2:04           ` Lu, Baolu
2015-11-13  2:26             ` Dave Young
2015-11-13  6:23               ` Lu Baolu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.