Re: [PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
On Tue, Jan 26, 2016 at 06:27:47PM +0800, Lu Baolu wrote: > > > On 01/26/2016 03:36 PM, Greg Kroah-Hartman wrote: > > On Tue, Jan 26, 2016 at 12:14:16PM +0800, Lu Baolu wrote: > >> 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 > >> --- > >> MAINTAINERS | 7 + > >> arch/x86/Kconfig.debug | 12 + > >> drivers/usb/early/Makefile | 1 + > > Why did you make a whole new subdirectory, just for your one driver? > > Please don't do that, just put it in the host controller directory where > > it belongs... > > I am sorry, but driver/usb/early is an existing subdirectory. You are correct, sorry about that, my fault. greg k-h
Re: [PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
On Tue, Jan 26, 2016 at 06:27:47PM +0800, Lu Baolu wrote: > > > On 01/26/2016 03:36 PM, Greg Kroah-Hartman wrote: > > On Tue, Jan 26, 2016 at 12:14:16PM +0800, Lu Baolu wrote: > >> 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> >> --- > >> MAINTAINERS | 7 + > >> arch/x86/Kconfig.debug | 12 + > >> drivers/usb/early/Makefile | 1 + > > Why did you make a whole new subdirectory, just for your one driver? > > Please don't do that, just put it in the host controller directory where > > it belongs... > > I am sorry, but driver/usb/early is an existing subdirectory. You are correct, sorry about that, my fault. greg k-h
Re: [PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
On 01/26/2016 03:36 PM, Greg Kroah-Hartman wrote: > On Tue, Jan 26, 2016 at 12:14:16PM +0800, Lu Baolu wrote: >> 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 >> --- >> MAINTAINERS | 7 + >> arch/x86/Kconfig.debug | 12 + >> drivers/usb/early/Makefile | 1 + > Why did you make a whole new subdirectory, just for your one driver? > Please don't do that, just put it in the host controller directory where > it belongs... I am sorry, but driver/usb/early is an existing subdirectory. $ ls drivers/usb/early/ ehci-dbgp.c Makefile If I understand it correctly, the "early" subdirectory is used to keep drivers which should be loaded during early boot stage. We already have code for EHCI debug port there with the filename ehci-dbgp.c. It is used to aid the developer to get kernel messages during early boot through EHCI debug port. What I have done is to implement the same thing with xHCI debug port. It's not part of xHCI host controller driver and it is executed even before xHCI driver is loaded. Thanks, Baolu > >
Re: [PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
On 01/26/2016 03:36 PM, Greg Kroah-Hartman wrote: > On Tue, Jan 26, 2016 at 12:14:16PM +0800, Lu Baolu wrote: >> 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>> --- >> MAINTAINERS | 7 + >> arch/x86/Kconfig.debug | 12 + >> drivers/usb/early/Makefile | 1 + > Why did you make a whole new subdirectory, just for your one driver? > Please don't do that, just put it in the host controller directory where > it belongs... I am sorry, but driver/usb/early is an existing subdirectory. $ ls drivers/usb/early/ ehci-dbgp.c Makefile If I understand it correctly, the "early" subdirectory is used to keep drivers which should be loaded during early boot stage. We already have code for EHCI debug port there with the filename ehci-dbgp.c. It is used to aid the developer to get kernel messages during early boot through EHCI debug port. What I have done is to implement the same thing with xHCI debug port. It's not part of xHCI host controller driver and it is executed even before xHCI driver is loaded. Thanks, Baolu > >
Re: [PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
On Tue, Jan 26, 2016 at 12:14:16PM +0800, Lu Baolu wrote: > 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 > --- > MAINTAINERS | 7 + > arch/x86/Kconfig.debug | 12 + > drivers/usb/early/Makefile | 1 + Why did you make a whole new subdirectory, just for your one driver? Please don't do that, just put it in the host controller directory where it belongs...
[PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
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 --- MAINTAINERS | 7 + arch/x86/Kconfig.debug | 12 + drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 774 +++ include/linux/usb/xhci-dbc.h | 187 +++ 5 files changed, 981 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 30aca4a..e6d7076 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11505,6 +11505,13 @@ S: Supported F: drivers/usb/host/xhci* F: drivers/usb/host/pci-quirks* +USB XHCI DEBUG PORT +M: Lu Baolu +L: linux-...@vger.kernel.org +S: Supported +F: drivers/usb/early/xhci-dbc.c +F: include/linux/usb/xhci-dbc.h + USB ZD1201 DRIVER L: linux-wirel...@vger.kernel.org W: http://linux-lc100020.sourceforge.net diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 9b18ed9..ba60cb1 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug @@ -48,6 +48,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_CORE def_bool n 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 000..254a0a8 --- /dev/null +++ b/drivers/usb/early/xhci-dbc.c @@ -0,0 +1,774 @@ +/** + * xhci-dbc.c - xHCI debug capability driver + * + * Copyright (C) 2015 Intel Corporation + * + * Author: Lu Baolu + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../host/xhci.h" + +#defineXDBC_PROTOCOL 1 /* GNU Remote Debug Command Set */ +#defineXDBC_VENDOR_ID 0x1d6b /* Linux Foundation 0x1d6b */ +#defineXDBC_PRODUCT_ID 0x0004 /* __le16 idProduct; device 0004 */ +#defineXDBC_DEVICE_REV 0x0010 /* 0.10 */ + +static struct xdbc_state xdbc_stat; +static struct xdbc_state *xdbcp = _stat; + +#ifdef DBC_DEBUG +/* place holder */ +#definexdbc_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(>xdbc_reg->capability)); + xdbc_trace(" Door bell: %08x\n", + readl(>xdbc_reg->doorbell)); + xdbc_trace(" Event Ring Segment Table Size: %08x\n", + readl(>xdbc_reg->ersts)); + xdbc_trace(" Event Ring Segment Table Base Address: %16llx\n", + xdbc_read64(>xdbc_reg->erstba)); + xdbc_trace(" Event Ring Dequeue Pointer: %16llx\n", + xdbc_read64(>xdbc_reg->erdp)); + xdbc_trace(" Port status and control: %08x\n", + readl(>xdbc_reg->portsc)); + xdbc_trace(" Debug Capability Context Pointer: %16llx\n", + xdbc_read64(>xdbc_reg->dccp)); + xdbc_trace(" Device Descriptor Info Register 1: %08x\n", +
[PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
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--- MAINTAINERS | 7 + arch/x86/Kconfig.debug | 12 + drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 774 +++ include/linux/usb/xhci-dbc.h | 187 +++ 5 files changed, 981 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 30aca4a..e6d7076 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11505,6 +11505,13 @@ S: Supported F: drivers/usb/host/xhci* F: drivers/usb/host/pci-quirks* +USB XHCI DEBUG PORT +M: Lu Baolu +L: linux-...@vger.kernel.org +S: Supported +F: drivers/usb/early/xhci-dbc.c +F: include/linux/usb/xhci-dbc.h + USB ZD1201 DRIVER L: linux-wirel...@vger.kernel.org W: http://linux-lc100020.sourceforge.net diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 9b18ed9..ba60cb1 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug @@ -48,6 +48,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_CORE def_bool n 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 000..254a0a8 --- /dev/null +++ b/drivers/usb/early/xhci-dbc.c @@ -0,0 +1,774 @@ +/** + * xhci-dbc.c - xHCI debug capability driver + * + * Copyright (C) 2015 Intel Corporation + * + * Author: Lu Baolu + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../host/xhci.h" + +#defineXDBC_PROTOCOL 1 /* GNU Remote Debug Command Set */ +#defineXDBC_VENDOR_ID 0x1d6b /* Linux Foundation 0x1d6b */ +#defineXDBC_PRODUCT_ID 0x0004 /* __le16 idProduct; device 0004 */ +#defineXDBC_DEVICE_REV 0x0010 /* 0.10 */ + +static struct xdbc_state xdbc_stat; +static struct xdbc_state *xdbcp = _stat; + +#ifdef DBC_DEBUG +/* place holder */ +#definexdbc_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(>xdbc_reg->capability)); + xdbc_trace(" Door bell: %08x\n", + readl(>xdbc_reg->doorbell)); + xdbc_trace(" Event Ring Segment Table Size: %08x\n", + readl(>xdbc_reg->ersts)); + xdbc_trace(" Event Ring Segment Table Base Address: %16llx\n", + xdbc_read64(>xdbc_reg->erstba)); + xdbc_trace(" Event Ring Dequeue Pointer: %16llx\n", + xdbc_read64(>xdbc_reg->erdp)); + xdbc_trace(" Port status and control: %08x\n", + readl(>xdbc_reg->portsc)); + xdbc_trace(" Debug Capability Context Pointer: %16llx\n", + xdbc_read64(>xdbc_reg->dccp)); + xdbc_trace("
Re: [PATCH v6 03/12] usb: dbc: probe and setup xhci debug capability
On Tue, Jan 26, 2016 at 12:14:16PM +0800, Lu Baolu wrote: > 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> --- > MAINTAINERS | 7 + > arch/x86/Kconfig.debug | 12 + > drivers/usb/early/Makefile | 1 + Why did you make a whole new subdirectory, just for your one driver? Please don't do that, just put it in the host controller directory where it belongs...