usb: early: add support for early printk through USB3 debug port
Subsystems (4)
v8 cover usb: early: add support for early printk through USB3 debug port
xHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. With DbC hardware initialized, the system will present a debug device through the USB3 debug port (normally the first USB3 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. The DbC functionality is independent of xHCI host.
This patch set adds support for early printk functionality through a USB3 debug port by 1) initializing and enabling the DbC hardware during early boot; 2) registering a boot console to the system so that early printk messages can go through the USB3 debug port. It also includes some lines of changes in usb_debug driver so that it can be bound when a USB3 debug device is enumerated.
---
Change log:
v7->v8:
- refine the Kconfig help text.
- cleanup the unnecessary USB_EARLY_PRINTK bool.
- refine comments and trace messages in the driver.
- update usb3-debug-port.rst after internal reivew.
v6->v7:
- add a new patch "[PATCH 1/5] x86: add simple udelay calibration" to make udelay() work for early drivers.
- [PATCH 2/5] usb: dbc: early driver for xhci debug capability
- add a kernel thread to handle error cases, such as cable unplugging.
- Fixed several code styles pointed out by Ingo.
v5->v6:
- rebase the patches on top of the latest 4.10-rc4
- run successfully in a 32-bit kernel
- [PATCH 1/4]
- remove ugly linebreaks to make code more readable
- rename config names to make them consistency
- move sleep-able ioremap() out of the lock area
- rename reserved fields of register structures
- make the vertical tabulation of struct fields consistent
- [PATCH 2/4]
- remove "#ifdef" in the generic code by creating proper wrappers in header file
- [PATCH 3/4]
- refine the title and commit message
- [PATCH 4/4]
- fix several typos and grammar errors in the document
v4->v5:
- add raw_spin_lock to make xdbc_bulk_write() reentrant.
v3->v4:
- Rename the document with .dst suffix.
- Add the list of hardware that has been succesfuly tested on in the document.
v2->v3:
- Removed spinlock usage.
- Removed work queue usage.
- Refined the user guide document.
v1->v2:
- Refactor the duplicate code in xdbc_early_start() and xdbc_handle_external_reset().
- Free resources when hardware not used any more.
- Refine the user guide document.
Lu Baolu (5):
x86: add simple udelay calibration
usb: early: add driver for xhci debug capability
x86: add support for earlyprintk via USB3 debug port
usb: serial: add dbc debug device support to usb_debug
usb: doc: add document for USB3 debug port usage
Documentation/admin-guide/kernel-parameters.txt | 1 + Documentation/usb/usb3-debug-port.rst | 100 +++ arch/x86/Kconfig.debug | 23 + arch/x86/kernel/early_printk.c | 5 + arch/x86/kernel/setup.c | 26 + drivers/usb/Makefile | 2 +- drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 1014 +++++++++++++++++++++++ drivers/usb/early/xhci-dbc.h | 211 +++++ drivers/usb/serial/usb_debug.c | 28 +- include/linux/usb/xhci-dbgp.h | 29 + 11 files changed, 1436 insertions(+), 4 deletions(-) create mode 100644 Documentation/usb/usb3-debug-port.rst create mode 100644 drivers/usb/early/xhci-dbc.c create mode 100644 drivers/usb/early/xhci-dbc.h create mode 100644 include/linux/usb/xhci-dbgp.h
Signature · 1 line
2.1.4
PATCH v8 1/5 x86: add simple udelay calibration
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for loops_per_jiffy. Hence, udelay() could be used after this initialization.
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/x86/kernel/setup.c +22 -0
@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures
@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Signature · 1 line
2.1.4
tip-bot for Lu Baolu
merge bot[tip:x86/debug] x86/timers: Add simple udelay calibration
x86/timers: Add simple udelay calibration
Commit-ID: dd759d93f4dd4fd2f345a78ad1223bb3edf3ee7b Gitweb: http://git.kernel.org/tip/dd759d93f4dd4fd2f345a78ad1223bb3edf3ee7b Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:29 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:28:45 +0100
x86/timers: Add simple udelay calibration
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for loops_per_jiffy. Hence, udelay() could be used after this initialization.
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/x86/kernel/setup.c +22 -0
@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures
@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Re: [tip:x86/debug] x86/timers: Add simple udelay calibration
Quoted 66 lines · tip-bot for Lu Baolu
Commit-ID: dd759d93f4dd4fd2f345a78ad1223bb3edf3ee7b Gitweb: http://git.kernel.org/tip/dd759d93f4dd4fd2f345a78ad1223bb3edf3ee7b Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:29 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:28:45 +0100x86/timers: Add simple udelay calibration
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.Signed-off-by Lu Baolu <[email protected]>Acked-by Thomas Gleixner <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Borislav Petkov <[email protected]>Cc Brian Gerst <[email protected]>Cc Denys Vlasenko <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Josh Poimboeuf <[email protected]>Cc Linus Torvalds <[email protected]>Cc Mathias Nyman <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Ingo Molnar <[email protected]>--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +20
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 8 lines
arch/x86/kernel/setup.c +2
-0@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Can we move this past init_hypervisor_platform()? Otherwise, the x86_platform hooks aren't fully initialized yet, and we may use the wrong functions.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux
Re: [tip:x86/debug] x86/timers: Add simple udelay calibration
Hi,
Quoted 69 lines · Jan Kiszka
Quoted 68 lines · tip-bot for Lu Baolu
Commit-ID: dd759d93f4dd4fd2f345a78ad1223bb3edf3ee7b Gitweb: http://git.kernel.org/tip/dd759d93f4dd4fd2f345a78ad1223bb3edf3ee7b Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:29 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:28:45 +0100x86/timers: Add simple udelay calibration
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.Signed-off-by Lu Baolu <[email protected]>Acked-by Thomas Gleixner <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Borislav Petkov <[email protected]>Cc Brian Gerst <[email protected]>Cc Denys Vlasenko <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Josh Poimboeuf <[email protected]>Cc Linus Torvalds <[email protected]>Cc Mathias Nyman <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Ingo Molnar <[email protected]>--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +20
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx ();
Quoted 7 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 6 lines
arch/x86/kernel/setup.c +2
-0+simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG Can we move this past
init_hypervisor_platform()?
Yes, we can as far as I can see.
Best regards,
Lu Baolu
Quoted 6 lines
Otherwise, the
x86_platformhooks aren't fully initialized yet, and we may use the wrong functions.Jan
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Lu BaoluQuoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.
This breaks Xen PV guests since at this point, and until x86_init.paging.pagetable_init() which is when pvclock_vcpu_time_info is mapped, they cannot access pvclock.
Is it reasonable to do this before tsc_init() is called? (The failure has nothing to do with tsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to move simple_udelay_calibration() after x86_init.paging.pagetable_init()?
-boris
Quoted 40 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +20
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 8 lines
arch/x86/kernel/setup.c +2
-0@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Lu BaoluQuoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.
This breaks Xen PV guests since at this point, and until x86_init.paging.pagetable_init() which is when pvclock_vcpu_time_info is mapped, they cannot access pvclock.
Is it reasonable to do this before tsc_init() is called? (The failure has nothing to do with tsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to move simple_udelay_calibration() after x86_init.paging.pagetable_init()?
-boris
Quoted 48 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +22
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?
This is currently only used for bare metal. How about by-pass it for Xen PV guests?
Best regards,
Lu Baolu
Quoted 46 lines
-boris
Quoted 42 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +20
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx ();
Quoted 6 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 5 lines
arch/x86/kernel/setup.c +2
-0+simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Boris OstrovskyHi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?
This is currently only used for bare metal. How about by-pass it for Xen PV guests?
Best regards,
Lu Baolu
Quoted 52 lines
-boris
Quoted 47 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +22
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.
Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides tsc_init() (which might not be important here), at the time when simple_udelay_calibration() is invoked we haven't yet called:
* kvmclock_init(), which sets calibration routines for KVM
* init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
* x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
-boris
Quoted 49 lines
Best regards,
Lu BaoluQuoted 45 lines
-boris
Quoted 42 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +20
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx ();
Quoted 5 lines
Quoted 5 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 5 lines
arch/x86/kernel/setup.c +2
-0+simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Lu BaoluQuoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.
Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides tsc_init() (which might not be important here), at the time when simple_udelay_calibration() is invoked we haven't yet called:
* kvmclock_init(), which sets calibration routines for KVM
* init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
* x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
-boris
Quoted 54 lines
Best regards,
Lu BaoluQuoted 50 lines
-boris
Quoted 47 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +22
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; } +static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ; + + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Hi, Lu
Quoted 21 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
Quoted 10 lines
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
I guess these may have been missed.
Do you have any comments about these?
Quoted 25 lines
-boris
Quoted 22 lines
Best regards,
Lu BaoluQuoted 18 lines
-boris
Quoted 15 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +0
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; }
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/x86/kernel/setup.c dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) · line 846
Quoted 7 lines
arch/x86/kernel/setup.c +7
-0+static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ;
if it returns here, can we use udelay() correctly like before?
Thanks,
dou.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
arch/x86/kernel/setup.c +13
-0+ + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx ();
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 5 lines
arch/x86/kernel/setup.c +2
-0+simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Boris OstrovskyHi, Lu
Quoted 21 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
Quoted 10 lines
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
I guess these may have been missed.
Do you have any comments about these?
Quoted 25 lines
-boris
Quoted 22 lines
Best regards,
Lu BaoluQuoted 18 lines
-boris
Quoted 15 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +0
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; }
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/x86/kernel/setup.c dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) · line 846
Quoted 7 lines
arch/x86/kernel/setup.c +7
-0+static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ;
if it returns here, can we use udelay() correctly like before?
Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
arch/x86/kernel/setup.c +15
-0+ + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 21 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
Quoted 10 lines
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Best regards,
Lu Baolu
Quoted 64 lines
Quoted 25 lines
-boris
Quoted 22 lines
Best regards,
Lu BaoluQuoted 18 lines
-boris
Quoted 15 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +0
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; }Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/x86/kernel/setup.c dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) · line 846
Quoted 7 lines
arch/x86/kernel/setup.c +7
-0+static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ;if it returns here, can we use
udelay()correctly like before?Thanks,
dou.
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
arch/x86/kernel/setup.c +15
-0+ + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();
Quoted 12 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/x86/kernel/setup.c +0
-0#ifdef CONFIG_MEMORY_HOTPLUG Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Dou LiyangHi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 21 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
Quoted 10 lines
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Best regards,
Lu Baolu
Quoted 76 lines
Quoted 25 lines
-boris
Quoted 22 lines
Best regards,
Lu BaoluQuoted 18 lines
-boris
Quoted 15 lines
--- arch/x86/kernel/setup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)arch/x86/kernel/setup.c +0
-0@@ -837,6 +837,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)return 0 ; }Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/x86/kernel/setup.c dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) · line 846
Quoted 7 lines
arch/x86/kernel/setup.c +7
-0+static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ;if it returns here, can we use
udelay()correctly like before?Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
arch/x86/kernel/setup.c +15
-0+ + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Hi, Lu
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 31 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
Quoted 6 lines
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Yes, I have seen it in the upstream.
Firstly, I also met this problem want to call udelay() earlier than *loops_per_jiffy* setup like you[1]. So I am very interesting in this patch. ;)
I am also confused about the questions which Boris asked:
whether do the CPU and TSC calibration too early just for using udelay()?
this design broke our interface of x86_paltform.calibrate_cpu/tsc.
And I also have a question below.
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/x86/kernel/setup.c dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) · line 846
Quoted 8 lines
arch/x86/kernel/setup.c +7
-0+static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ;
if we don't have the TSC feature in booting CPU and it returns here, can we use udelay() correctly like before?
[1] https://lkml.org/lkml/2017/7/3/276
Thanks,
dou.
Quoted 35 lines
Quoted 35 lines
Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
arch/x86/kernel/setup.c +15
-0+ + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx (); +simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG
Quoted 9 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Lu BaoluHi, Lu
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 31 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PV
Quoted 6 lines
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Yes, I have seen it in the upstream.
Firstly, I also met this problem want to call udelay() earlier than *loops_per_jiffy* setup like you[1]. So I am very interesting in this patch. ;)
I am also confused about the questions which Boris asked:
whether do the CPU and TSC calibration too early just for using udelay()?
this design broke our interface of x86_paltform.calibrate_cpu/tsc.
And I also have a question below.
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/x86/kernel/setup.c dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) · line 846
Quoted 8 lines
arch/x86/kernel/setup.c +7
-0+static void __init simple_udelay_calibration (void ) +{ +unsigned int tsc_khz, cpu_khz; +unsigned long lpj; + +if (!boot_cpu_has (X86_FEATURE_TSC )) +return ;
if we don't have the TSC feature in booting CPU and it returns here, can we use udelay() correctly like before?
[1] https://lkml.org/lkml/2017/7/3/276
Thanks,
dou.
Quoted 44 lines
Quoted 40 lines
Thanks,
dou.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
arch/x86/kernel/setup.c +13
-0+ + cpu_khz = x86_platform.calibrate_cpu (); + tsc_khz = x86_platform.calibrate_tsc (); + + tsc_khz = tsc_khz ? : cpu_khz; +if (!tsc_khz) +return ; + + lpj = tsc_khz *1000 ; +do_div (lpj,HZ ); + loops_per_jiffy = lpj; +} +/* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p)*/ x86_configure_nx ();Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1012
Quoted 5 lines
arch/x86/kernel/setup.c +2
-0+simple_udelay_calibration (); +parse_early_param ();#ifdef CONFIG_MEMORY_HOTPLUG --
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Hi,
Quoted 66 lines · Dou Liyang
Hi, Lu
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 31 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PVQuoted 6 lines
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Yes, I have seen it in the upstream.
Firstly, I also met this problem want to call
udelay()earlier than *loops_per_jiffy* setup like you[1]. So I am very interesting in this patch. ;)I am also confused about the questions which Boris asked:
whether do the CPU and TSC calibration too early just for using
udelay()?this design broke our interface of x86_paltform.calibrate_cpu/tsc.
And I also have a question below.
[...]
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+static void __init simple_udelay_calibration(void) +{ + unsigned int tsc_khz, cpu_khz; + unsigned long lpj; + + if (!boot_cpu_has(X86_FEATURE_TSC)) + return;if we don't have the TSC feature in booting CPU and it returns here, can we use
udelay()correctly like before?
If we have TSC feature, we calculate a preciser loops_per_jiffy here. Otherwise, we just keep it as before. This function doesn't broke the use of udelay().
Best regards,
Lu Baolu
Quoted 42 lines
[1] https://lkml.org/lkml/2017/7/3/276
Thanks,
dou.
Quoted 35 lines
Quoted 35 lines
Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
(quoted diff) +15
-0+ + cpu_khz = x86_platform.calibrate_cpu(); + tsc_khz = x86_platform.calibrate_tsc(); + + tsc_khz = tsc_khz ? : cpu_khz; + if (!tsc_khz) + return; + + lpj = tsc_khz * 1000; + do_div(lpj, HZ); + loops_per_jiffy = lpj; +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p) */ x86_configure_nx(); + simple_udelay_calibration(); + parse_early_param(); #ifdef CONFIG_MEMORY_HOTPLUG
Quoted 16 lines
Quoted 9 lines
Quoted 5 lines
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Dou LiyangHi,
Quoted 66 lines · Dou Liyang
Hi, Lu
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 31 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PVQuoted 6 lines
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Yes, I have seen it in the upstream.
Firstly, I also met this problem want to call
udelay()earlier than *loops_per_jiffy* setup like you[1]. So I am very interesting in this patch. ;)I am also confused about the questions which Boris asked:
whether do the CPU and TSC calibration too early just for using
udelay()?this design broke our interface of x86_paltform.calibrate_cpu/tsc.
And I also have a question below.
[...]
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+static void __init simple_udelay_calibration(void) +{ + unsigned int tsc_khz, cpu_khz; + unsigned long lpj; + + if (!boot_cpu_has(X86_FEATURE_TSC)) + return;if we don't have the TSC feature in booting CPU and it returns here, can we use
udelay()correctly like before?
If we have TSC feature, we calculate a preciser loops_per_jiffy here. Otherwise, we just keep it as before. This function doesn't broke the use of udelay().
Best regards,
Lu Baolu
Quoted 58 lines
[1] https://lkml.org/lkml/2017/7/3/276
Thanks,
dou.
Quoted 44 lines
Quoted 40 lines
Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
(quoted diff) +15
-0+ + cpu_khz = x86_platform.calibrate_cpu(); + tsc_khz = x86_platform.calibrate_tsc(); + + tsc_khz = tsc_khz ? : cpu_khz; + if (!tsc_khz) + return; + + lpj = tsc_khz * 1000; + do_div(lpj, HZ); + loops_per_jiffy = lpj; +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p) */ x86_configure_nx(); + simple_udelay_calibration(); + parse_early_param(); #ifdef CONFIG_MEMORY_HOTPLUGSignature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 1/5] x86: add simple udelay calibration
Hi, Lu
Quoted 81 lines · Lu Baolu
Hi,
Quoted 66 lines · Dou Liyang
Hi, Lu
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 31 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PVQuoted 6 lines
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Yes, I have seen it in the upstream.
Firstly, I also met this problem want to call
udelay()earlier than *loops_per_jiffy* setup like you[1]. So I am very interesting in this patch. ;)I am also confused about the questions which Boris asked:
whether do the CPU and TSC calibration too early just for using
udelay()?this design broke our interface of x86_paltform.calibrate_cpu/tsc.
And I also have a question below.
[...]
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+static void __init simple_udelay_calibration(void) +{ + unsigned int tsc_khz, cpu_khz; + unsigned long lpj; + + if (!boot_cpu_has(X86_FEATURE_TSC)) + return;if we don't have the TSC feature in booting CPU and it returns here, can we use
udelay()correctly like before?
Quoted 3 lines
If we have TSC feature, we calculate a preciser
loops_per_jiffyhere. Otherwise, we just keep it as before. This function doesn't broke the use ofudelay().
Oh, I see.
In XDbC (XHCI debug capability), we just want the udelay() work more precisely in the TSC supported system.
It is different with my problem I missed.
Thanks for your kind explanation. :)
Thanks,
dou
Quoted 66 lines
Best regards,
Lu BaoluQuoted 58 lines
[1] https://lkml.org/lkml/2017/7/3/276
Thanks,
dou.
Quoted 35 lines
Quoted 35 lines
Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
(quoted diff) +15
-0+ + cpu_khz = x86_platform.calibrate_cpu(); + tsc_khz = x86_platform.calibrate_tsc(); + + tsc_khz = tsc_khz ? : cpu_khz; + if (!tsc_khz) + return; + + lpj = tsc_khz * 1000; + do_div(lpj, HZ); + loops_per_jiffy = lpj; +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p) */ x86_configure_nx(); + simple_udelay_calibration(); + parse_early_param(); #ifdef CONFIG_MEMORY_HOTPLUGQuoted 9 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v8 1/5] x86: add simple udelay calibration
In reply to Lu BaoluHi, Lu
Quoted 81 lines · Lu Baolu
Hi,
Quoted 66 lines · Dou Liyang
Hi, Lu
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Dou Liyang
Hi, Lu
Quoted 31 lines · Boris Ostrovsky
Quoted 12 lines · Lu Baolu
Hi,
Quoted 9 lines · Boris Ostrovsky
Quoted 4 lines · Lu Baolu
Add a simple udelay calibration in x86 architecture-specific boot-time initializations. This will get a workable estimate for
loops_per_jiffy. Hence,udelay()could be used after this initialization.This breaks Xen PV guests since at this point, and until
x86_init.paging.pagetable_init()which is whenpvclock_vcpu_time_infois mapped, they cannot access pvclock.Quoted 7 lines
Quoted 5 lines
Is it reasonable to do this before
tsc_init()is called? (The failure has nothing to do withtsc_init(), really --- it's just that it is called late enough that Xen PV guests get properly initialized.) If it is, would it be possible to movesimple_udelay_calibration()afterx86_init.paging.pagetable_init()?This is currently only used for bare metal. How about by-pass it for Xen PV guests?
It is fixed this for Xen PV guests now (in the sense that we don't crash anymore) but my question is still whether this is not too early. Besides
tsc_init()(which might not be important here), at the time whensimple_udelay_calibration()is invoked we haven't yet called:
*kvmclock_init(), which sets calibration routines for KVM
*init_hypervisor_platform(), which sets calibration routines for vmware and Xen HVM
*x86_init.paging.pagetable_init(), which sets calibration routines for Xen PVQuoted 6 lines
Quoted 4 lines
I guess these may have been missed.
Do you have any comments about these?
The patch will be available in 4.13-rc1.
Yes, I have seen it in the upstream.
Firstly, I also met this problem want to call
udelay()earlier than *loops_per_jiffy* setup like you[1]. So I am very interesting in this patch. ;)I am also confused about the questions which Boris asked:
whether do the CPU and TSC calibration too early just for using
udelay()?this design broke our interface of x86_paltform.calibrate_cpu/tsc.
And I also have a question below.
[...]
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+static void __init simple_udelay_calibration(void) +{ + unsigned int tsc_khz, cpu_khz; + unsigned long lpj; + + if (!boot_cpu_has(X86_FEATURE_TSC)) + return;if we don't have the TSC feature in booting CPU and it returns here, can we use
udelay()correctly like before?
Quoted 3 lines
If we have TSC feature, we calculate a preciser
loops_per_jiffyhere. Otherwise, we just keep it as before. This function doesn't broke the use ofudelay().
Oh, I see.
In XDbC (XHCI debug capability), we just want the udelay() work more precisely in the TSC supported system.
It is different with my problem I missed.
Thanks for your kind explanation. :)
Thanks,
dou
Quoted 66 lines
Best regards,
Lu BaoluQuoted 58 lines
[1] https://lkml.org/lkml/2017/7/3/276
Thanks,
dou.
Quoted 35 lines
Quoted 35 lines
Thanks,
dou.
Quoted 29 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
(quoted diff) +15
-0+ + cpu_khz = x86_platform.calibrate_cpu(); + tsc_khz = x86_platform.calibrate_tsc(); + + tsc_khz = tsc_khz ? : cpu_khz; + if (!tsc_khz) + return; + + lpj = tsc_khz * 1000; + do_div(lpj, HZ); + loops_per_jiffy = lpj; +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures@@ -985,6 +1005,8 @@ void __init setup_arch(char **cmdline_p) */ x86_configure_nx(); + simple_udelay_calibration(); + parse_early_param(); #ifdef CONFIG_MEMORY_HOTPLUGQuoted 9 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v8 2/5 usb: early: add driver for xhci debug capability
In reply to Lu BaoluXHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. Software learns this capability by walking through the extended capability list of the host. XHCI specification describes DbC in the section 7.6.
This patch introduces the code to probe and initialize the debug capability hardware during early boot. With hardware initialized, the debug target (system on which this code is running) will present a debug device through the debug port (normally the first USB3 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. The DbC functionality is independent of the xHCI host. There isn't any precondition from the xHCI host side for the DbC to work.
One use for this feature is kernel debugging, for example when your machine crashes very early before the regular console code is initialized. Other uses include simpler, lockless logging instead of a full-blown printk console driver and klogd.
--- arch/x86/Kconfig.debug | 23 + drivers/usb/Makefile | 2 +- drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 1014 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/early/xhci-dbc.h | 211 +++++++++ include/linux/usb/xhci-dbgp.h | 29 ++ 6 files changed, 1279 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/early/xhci-dbc.c create mode 100644 drivers/usb/early/xhci-dbc.h create mode 100644 include/linux/usb/xhci-dbgp.h
arch/x86/Kconfig.debug +23 -0
@@ -5,6 +5,9 @@ config TRACE_IRQFLAGS_SUPPORT source "lib/Kconfig.debug" +config EARLY_PRINTK_USB + bool + config X86_VERBOSE_BOOTUP bool "Enable verbose x86 bootup info messages" default y
@@ -29,6 +32,7 @@ config EARLY_PRINTK config EARLY_PRINTK_DBGP bool "Early printk via EHCI debug port" depends on EARLY_PRINTK && PCI + select EARLY_PRINTK_USB ---help--- Write kernel log output directly into the EHCI debug port.
@@ -48,6 +52,25 @@ 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_USB_XDBC + bool "Early printk via the xHCI debug port" + depends on EARLY_PRINTK && PCI + select EARLY_PRINTK_USB + ---help--- + Write kernel log output directly into the xHCI debug port. + + One use for this feature is kernel debugging, for example when your + machine crashes very early before the regular console code is + initialized. Other uses include simpler, lockless logging instead of + a full-blown printk console driver + klogd. + + For normal production environments this is normally not recommended, + because it doesn't feed events into klogd/syslogd and doesn't try to + print anything on the screen. + + You should normally N here, unless you want to debug early crashes or + need a very simple printk logging facility. + config X86_PTDUMP_CORE def_bool n
drivers/usb/Makefile +1 -1
@@ -49,7 +49,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/ obj-$(CONFIG_USB_SERIAL) += serial/ obj-$(CONFIG_USB) += misc/ -obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ +obj-$(CONFIG_EARLY_PRINTK_USB) += early/ obj-$(CONFIG_USB_ATM) += atm/ obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
drivers/usb/early/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o +obj-$(CONFIG_EARLY_PRINTK_USB_XDBC) += xhci-dbc.o
drivers/usb/early/xhci-dbc.c new file +1014 -0
1,014 lines not on this page · raw message
drivers/usb/early/xhci-dbc.h new file +211 -0
211 lines not on this page · raw message
include/linux/usb/xhci-dbgp.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Standalone xHCI debug capability driver +* +* Copyright (C) 2016 Intel Corporation +* +* Author: Lu Baolu <[email protected]> +* +* 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_DBGP_H +#define __LINUX_XHCI_DBGP_H + +#ifdef CONFIG_EARLY_PRINTK_USB_XDBC +int __init early_xdbc_parse_parameter (char *s); +int __init early_xdbc_setup_hardware (void ); +void __init early_xdbc_register_console (void ); +#else +static inline int __init early_xdbc_setup_hardware (void ) +{ +return -ENODEV ; +} +static inline void __init early_xdbc_register_console (void ) +{ +} +#endif /* CONFIG_EARLY_PRINTK_USB_XDBC */ +#endif /* __LINUX_XHCI_DBGP_H */
Signature · 1 line
2.1.4
tip-bot for Lu Baolu
merge bot[tip:x86/debug] usb/early: Add driver for xhci debug capability
usb/early: Add driver for xhci debug capability
Commit-ID: aeb9dd1de98c1a5f2007ea5d2a154c1244caf8a0 Gitweb: http://git.kernel.org/tip/aeb9dd1de98c1a5f2007ea5d2a154c1244caf8a0 Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:30 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:30:05 +0100
usb/early: Add driver for xhci debug capability
XHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. Software learns this capability by walking through the extended capability list of the host. XHCI specification describes DbC in section 7.6.
This patch introduces the code to probe and initialize the debug capability hardware during early boot. With hardware initialized, the debug target (system on which this code is running) will present a debug device through the debug port (normally the first USB3 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. The DbC functionality is independent of the xHCI host. There isn't any precondition from the xHCI host side for the DbC to work.
One use for this feature is kernel debugging, for example when your machine crashes very early before the regular console code is initialized. Other uses include simpler, lockless logging instead of a full-blown printk console driver and klogd.
--- arch/x86/Kconfig.debug | 27 +- drivers/usb/Makefile | 2 +- drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 1014 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/early/xhci-dbc.h | 211 +++++++++ include/linux/usb/xhci-dbgp.h | 29 ++ 6 files changed, 1281 insertions(+), 3 deletions(-)
arch/x86/Kconfig.debug +25 -2
@@ -5,6 +5,9 @@ config TRACE_IRQFLAGS_SUPPORT source "lib/Kconfig.debug" +config EARLY_PRINTK_USB + bool + config X86_VERBOSE_BOOTUP bool "Enable verbose x86 bootup info messages" default y
@@ -23,19 +26,20 @@ config EARLY_PRINTK 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, + with klogd/syslogd or the X server. You should normally say N here, unless you want to debug such a crash. config EARLY_PRINTK_DBGP bool "Early printk via EHCI debug port" depends on EARLY_PRINTK && PCI + select EARLY_PRINTK_USB ---help--- Write kernel log output directly into the EHCI 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, + with klogd/syslogd or the X server. You should normally say N here, unless you want to debug such a crash. You need usb debug device. config EARLY_PRINTK_EFI
@@ -48,6 +52,25 @@ 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_USB_XDBC + bool "Early printk via the xHCI debug port" + depends on EARLY_PRINTK && PCI + select EARLY_PRINTK_USB + ---help--- + Write kernel log output directly into the xHCI debug port. + + One use for this feature is kernel debugging, for example when your + machine crashes very early before the regular console code is + initialized. Other uses include simpler, lockless logging instead of + a full-blown printk console driver + klogd. + + For normal production environments this is normally not recommended, + because it doesn't feed events into klogd/syslogd and doesn't try to + print anything on the screen. + + You should normally say N here, unless you want to debug early + crashes or need a very simple printk logging facility. + config X86_PTDUMP_CORE def_bool n
drivers/usb/Makefile +1 -1
@@ -49,7 +49,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/ obj-$(CONFIG_USB_SERIAL) += serial/ obj-$(CONFIG_USB) += misc/ -obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ +obj-$(CONFIG_EARLY_PRINTK_USB) += early/ obj-$(CONFIG_USB_ATM) += atm/ obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
drivers/usb/early/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o +obj-$(CONFIG_EARLY_PRINTK_USB_XDBC) += xhci-dbc.o
drivers/usb/early/xhci-dbc.c new file +1014 -0
1,014 lines not on this page · raw message
drivers/usb/early/xhci-dbc.h new file +211 -0
211 lines not on this page · raw message
include/linux/usb/xhci-dbgp.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Standalone xHCI debug capability driver +* +* Copyright (C) 2016 Intel Corporation +* +* Author: Lu Baolu <[email protected]> +* +* 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_DBGP_H +#define __LINUX_XHCI_DBGP_H + +#ifdef CONFIG_EARLY_PRINTK_USB_XDBC +int __init early_xdbc_parse_parameter (char *s); +int __init early_xdbc_setup_hardware (void ); +void __init early_xdbc_register_console (void ); +#else +static inline int __init early_xdbc_setup_hardware (void ) +{ +return -ENODEV ; +} +static inline void __init early_xdbc_register_console (void ) +{ +} +#endif /* CONFIG_EARLY_PRINTK_USB_XDBC */ +#endif /* __LINUX_XHCI_DBGP_H */
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
In reply to Lu BaoluQuoted 26 lines · Lu Baolu
XHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. Software learns this capability by walking through the extended capability list of the host. XHCI specification describes DbC in the section 7.6.
This patch introduces the code to probe and initialize the debug capability hardware during early boot. With hardware initialized, the debug target (system on which this code is running) will present a debug device through the debug port (normally the first USB3 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. The DbC functionality is independent of the xHCI host. There isn't any precondition from the xHCI host side for the DbC to work.
One use for this feature is kernel debugging, for example when your machine crashes very early before the regular console code is initialized. Other uses include simpler, lockless logging instead of a full-blown printk console driver and klogd.
Cc Ingo Molnar <[email protected]>Cc Mathias Nyman <[email protected]>Signed-off-by Lu Baolu <[email protected]>
...
drivers/usb/early/xhci-dbc.c line 37
Quoted 4 lines
drivers/usb/early/xhci-dbc.c new file +4
-0+ +#define XDBC_TRACE +#ifdef XDBC_TRACE +#define xdbc_trace trace_printk
Did you forget to remove the #define XDBC_TRACE?
Enabling this driver brings the "trace_printk() being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.
Thanks,
Vlastimil
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Hi,
Quoted 35 lines · Vlastimil Babka
Quoted 26 lines · Lu Baolu
XHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. Software learns this capability by walking through the extended capability list of the host. XHCI specification describes DbC in the section 7.6.
This patch introduces the code to probe and initialize the debug capability hardware during early boot. With hardware initialized, the debug target (system on which this code is running) will present a debug device through the debug port (normally the first USB3 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. The DbC functionality is independent of the xHCI host. There isn't any precondition from the xHCI host side for the DbC to work.
One use for this feature is kernel debugging, for example when your machine crashes very early before the regular console code is initialized. Other uses include simpler, lockless logging instead of a full-blown printk console driver and klogd.
Cc Ingo Molnar <[email protected]>Cc Mathias Nyman <[email protected]>Signed-off-by Lu Baolu <[email protected]>...
drivers/usb/early/xhci-dbc.c line 37
Quoted 4 lines
drivers/usb/early/xhci-dbc.c new file +4
-0+ +#define XDBC_TRACE +#ifdef XDBC_TRACE +#define xdbc_trace trace_printkDid you forget to remove the #define
XDBC_TRACE?
Quoted 3 lines
Enabling this driver brings the "
trace_printk()being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.
This feature is only for a DEBUG kernel, should not be enabled for any production kernel. This was the reason I enabled trace_printk() by default.
Best regards,
Lu Baolu
Quoted 3 lines
Thanks,
Vlastimil
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Quoted 6 lines · On Wed, 31 May 2017 11:27:19 +0800 Lu Baolu <[email protected]> wrote:
Quoted 6 lines
drivers/usb/early/xhci-dbc.c line 37
Quoted 4 lines
drivers/usb/early/xhci-dbc.c new file +4
-0+ +#define XDBC_TRACE +#ifdef XDBC_TRACE +#define xdbc_trace trace_printkDid you forget to remove the #define
XDBC_TRACE?
Quoted 7 lines
Quoted 3 lines
Enabling this driver brings the "
trace_printk()being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.This feature is only for a DEBUG kernel, should not be enabled for any production kernel. This was the reason I enabled
trace_printk()by default.
Yes, it is perfectly fine to use trace_printk() for debug only configs. But if if you have it there and it is helpful to debug something that happens in a production system, you may want to look into creating a real tracepoint for the locations.
-- Steve
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Hi,
Quoted 13 lines · Steven Rostedt
Quoted 9 lines · On Wed, 31 May 2017 11:27:19 +0800 Lu Baolu <[email protected]> wrote:
Quoted 9 lines
drivers/usb/early/xhci-dbc.c line 37
Quoted 4 lines
drivers/usb/early/xhci-dbc.c new file +4
-0+ +#define XDBC_TRACE +#ifdef XDBC_TRACE +#define xdbc_trace trace_printkDid you forget to remove the #define
XDBC_TRACE?Enabling this driver brings the "
trace_printk()being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.
Quoted 7 lines
Quoted 3 lines
This feature is only for a DEBUG kernel, should not be enabled for any production kernel. This was the reason I enabled
trace_printk()by default.Yes, it is perfectly fine to use
trace_printk()for debug only configs. But if if you have it there and it is helpful to debug something that happens in a production system, you may want to look into creating a real tracepoint for the locations.
Yes. Good suggestion. I will try this.
Thank you!
Best regards,
Lu Baolu
Quoted 7 lines
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
In reply to Lu BaoluQuoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Vlastimil Babka
Quoted 26 lines · Lu Baolu
XHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. Software learns this capability by walking through the extended capability list of the host. XHCI specification describes DbC in the section 7.6.
This patch introduces the code to probe and initialize the debug capability hardware during early boot. With hardware initialized, the debug target (system on which this code is running) will present a debug device through the debug port (normally the first USB3 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. The DbC functionality is independent of the xHCI host. There isn't any precondition from the xHCI host side for the DbC to work.
One use for this feature is kernel debugging, for example when your machine crashes very early before the regular console code is initialized. Other uses include simpler, lockless logging instead of a full-blown printk console driver and klogd.
Cc Ingo Molnar <[email protected]>Cc Mathias Nyman <[email protected]>Signed-off-by Lu Baolu <[email protected]>...
drivers/usb/early/xhci-dbc.c line 37
Quoted 4 lines
drivers/usb/early/xhci-dbc.c new file +4
-0+ +#define XDBC_TRACE +#ifdef XDBC_TRACE +#define xdbc_trace trace_printkDid you forget to remove the #define
XDBC_TRACE?
Quoted 7 lines
Quoted 3 lines
Enabling this driver brings the "
trace_printk()being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.This feature is only for a DEBUG kernel, should not be enabled for any production kernel. This was the reason I enabled
trace_printk()by default.
Hmm, but it seems we generally enable all these early printk features/drivers in our distro kernels. They are not active without a early_printk=X bootparam anyway, right? It's much more convenient to e.g. just tell customer to change a param when debugging something than to install a debug kernel. So I wouldn't agree that only a DEBUG kernel should have this compiled in.
Thanks,
Vlastimil
Quoted 7 lines
Best regards,
Lu BaoluQuoted 3 lines
Thanks,
Vlastimil
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Hi,
Quoted 45 lines · Vlastimil Babka
Quoted 38 lines · Lu Baolu
Hi,
Quoted 35 lines · Vlastimil Babka
Quoted 26 lines · Lu Baolu
XHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. Software learns this capability by walking through the extended capability list of the host. XHCI specification describes DbC in the section 7.6.
This patch introduces the code to probe and initialize the debug capability hardware during early boot. With hardware initialized, the debug target (system on which this code is running) will present a debug device through the debug port (normally the first USB3 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. The DbC functionality is independent of the xHCI host. There isn't any precondition from the xHCI host side for the DbC to work.
One use for this feature is kernel debugging, for example when your machine crashes very early before the regular console code is initialized. Other uses include simpler, lockless logging instead of a full-blown printk console driver and klogd.
Cc Ingo Molnar <[email protected]>Cc Mathias Nyman <[email protected]>Signed-off-by Lu Baolu <[email protected]>...
drivers/usb/early/xhci-dbc.c line 37
Quoted 4 lines
drivers/usb/early/xhci-dbc.c new file +4
-0+ +#define XDBC_TRACE +#ifdef XDBC_TRACE +#define xdbc_trace trace_printkDid you forget to remove the #define
XDBC_TRACE?Quoted 6 lines
Quoted 3 lines
Enabling this driver brings the "
trace_printk()being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.This feature is only for a DEBUG kernel, should not be enabled for any production kernel. This was the reason I enabled
trace_printk()by default.
Quoted 6 lines
Hmm, but it seems we generally enable all these early printk features/drivers in our distro kernels. They are not active without a early_printk=X bootparam anyway, right? It's much more convenient to e.g. just tell customer to change a param when debugging something than to install a debug kernel. So I wouldn't agree that only a DEBUG kernel should have this compiled in.
Okay, I will try to find a fix.
Best regards,
Lu Baolu
Quoted 15 lines
Thanks,
VlastimilQuoted 6 lines
Best regards,
Lu BaoluQuoted 3 lines
Thanks,
Vlastimil--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Quoted 16 lines · Lu Baolu
Hi,
Quoted 13 lines · Vlastimil Babka
Quoted 12 lines · Lu Baolu
Hi,
Quoted 6 lines · Vlastimil Babka
On 03/21/2017 09:01 AM, Lu Baolu wrote:
Did you forget to remove the #defineXDBC_TRACE?Enabling this driver brings the "
trace_printk()being used. Allocating extra memory. This means that this is a DEBUG kernel and it is unsafe for production use." message in 4.12-rcX dmesg.This feature is only for a DEBUG kernel, should not be enabled for any production kernel. This was the reason I enabled
trace_printk()by default.
Quoted 8 lines
Quoted 6 lines
Hmm, but it seems we generally enable all these early printk features/drivers in our distro kernels. They are not active without a early_printk=X bootparam anyway, right? It's much more convenient to e.g. just tell customer to change a param when debugging something than to install a debug kernel. So I wouldn't agree that only a DEBUG kernel should have this compiled in.
Okay, I will try to find a fix.
Thanks. I didn't make it clear that the trace_printk() warning is there even if the code using it doesn't actually execute (i.e. I didn't specify any early_printk bootparam). There are some roastedy tricks to detect the potential users, so that the buffers can be allocated in advance to allow the first trace_printk() from any context, I guess.
I'm not sure if there's a way to change it so that your driver reports the trace_printk usage only in response to the bootparam (which could also be a safe point to allocate ftrace buffers?).
Vlastimil
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Quoted 9 lines · Vlastimil Babka
Thanks. I didn't make it clear that the
trace_printk()warning is there even if the code using it doesn't actually execute (i.e. I didn't specify anyearly_printkbootparam). There are some roastedy tricks to detect the potential users, so that the buffers can be allocated in advance to allow the firsttrace_printk()from any context, I guess.I'm not sure if there's a way to change it so that your driver reports the
trace_printkusage only in response to the bootparam (which could also be a safe point to allocate ftrace buffers?).
No, nor do we want to. There should not be a single caller to trace_printk() in normal kernels.
Re: [PATCH v8 2/5] usb: early: add driver for xhci debug capability
Quoted 8 lines · On Thu, 1 Jun 2017 14:25:51 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 7 lines · Vlastimil Babka
Thanks. I didn't make it clear that the
trace_printk()warning is there even if the code using it doesn't actually execute (i.e. I didn't specify anyearly_printkbootparam). There are some roastedy tricks to detect the potential users, so that the buffers can be allocated in advance to allow the firsttrace_printk()from any context, I guess.
Quoted 6 lines
Quoted 3 lines
I'm not sure if there's a way to change it so that your driver reports the
trace_printkusage only in response to the bootparam (which could also be a safe point to allocate ftrace buffers?).No, nor do we want to. There should not be a single caller to
trace_printk()in normal kernels.
Correct. If you find a trace_printk() that would be useful in a production environment, then make it a tracepoint.
That's why I have that nasty banner, to make sure trace_printk()s are not the "quick way" to add tracepoint hacks.
-- Steve
PATCH v8 3/5 x86: add support for earlyprintk via USB3 debug port
In reply to Lu BaoluAdd support for earlyprintk by writing debug messages to the USB3 debug port. Users can use this type of early printk by specifying the kernel parameter of "earlyprintk=xdbc". This gives users a chance of providing debugging output.
The hardware for USB3 debug port requires DMA memory blocks. This requires to delay setting up debugging hardware and registering boot console until the memblocks are filled.
--- Documentation/admin-guide/kernel-parameters.txt | 1 + arch/x86/kernel/early_printk.c | 5 +++++ arch/x86/kernel/setup.c | 4 ++++ 3 files changed, 10 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +1 -0
@@ -989,6 +989,7 @@ 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
arch/x86/kernel/early_printk.c +5 -0
@@ -17,6 +17,7 @@#include <asm/intel-mid.h> #include <asm/pgtable.h> #include <linux/usb/ehci_def.h> +#include <linux/usb/xhci-dbgp.h> #include <linux/efi.h> #include <asm/efi.h> #include <asm/pci_x86.h>
@@ -381,6 +382,10 @@ static int __init setup_early_printk(char *buf)if (!strncmp (buf,"efi" ,3 ))early_console_register (&early_efi_console, keep);#endif +#ifdef CONFIG_EARLY_PRINTK_USB_XDBC +if (!strncmp (buf,"xdbc" ,4 )) +early_xdbc_parse_parameter (buf +4 ); +#endif buf++; }
arch/x86/kernel/setup.c +4 -0
@@ -70,6 +70,7 @@#include <linux/tboot.h> #include <linux/jiffies.h> +#include <linux/usb/xhci-dbgp.h> #include <video/edid.h> #include <asm/mtrr.h>
@@ -1144,6 +1145,9 @@ void __init setup_arch(char **cmdline_p)memblock_set_current_limit (ISA_END_ADDRESS );memblock_x86_fill (); +if (!early_xdbc_setup_hardware ()) +early_xdbc_register_console (); +reserve_bios_regions ();if (efi_enabled (EFI_MEMMAP )) {
Signature · 1 line
2.1.4
tip-bot for Lu Baolu
merge bot[tip:x86/debug] x86/earlyprintk: Add support for earlyprintk via USB3 debug port
x86/earlyprintk: Add support for earlyprintk via USB3 debug port
Commit-ID: 1b5aeebf3a92273b4d85aeff37a16037bc3c3abf Gitweb: http://git.kernel.org/tip/1b5aeebf3a92273b4d85aeff37a16037bc3c3abf Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:31 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:30:16 +0100
x86/earlyprintk: Add support for earlyprintk via USB3 debug port
Add support for earlyprintk by writing debug messages to the USB3 debug port. Users can use this type of early printk by specifying the kernel parameter of "earlyprintk=xdbc". This gives users a chance of providing debugging output.
The hardware for USB3 debug port requires DMA memory blocks. This requires to delay setting up debugging hardware and registering boot console until the memblocks are filled.
--- Documentation/admin-guide/kernel-parameters.txt | 1 + arch/x86/kernel/early_printk.c | 5 +++++ arch/x86/kernel/setup.c | 4 ++++ 3 files changed, 10 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +1 -0
@@ -989,6 +989,7 @@ 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
arch/x86/kernel/early_printk.c +5 -0
@@ -17,6 +17,7 @@#include <asm/intel-mid.h> #include <asm/pgtable.h> #include <linux/usb/ehci_def.h> +#include <linux/usb/xhci-dbgp.h> #include <linux/efi.h> #include <asm/efi.h> #include <asm/pci_x86.h>
@@ -381,6 +382,10 @@ static int __init setup_early_printk(char *buf)if (!strncmp (buf,"efi" ,3 ))early_console_register (&early_efi_console, keep);#endif +#ifdef CONFIG_EARLY_PRINTK_USB_XDBC +if (!strncmp (buf,"xdbc" ,4 )) +early_xdbc_parse_parameter (buf +4 ); +#endif buf++; }
arch/x86/kernel/setup.c +4 -0
@@ -70,6 +70,7 @@#include <linux/tboot.h> #include <linux/jiffies.h> +#include <linux/usb/xhci-dbgp.h> #include <video/edid.h> #include <asm/mtrr.h>
@@ -1144,6 +1145,9 @@ void __init setup_arch(char **cmdline_p)memblock_set_current_limit (ISA_END_ADDRESS );memblock_x86_fill (); +if (!early_xdbc_setup_hardware ()) +early_xdbc_register_console (); +reserve_bios_regions ();if (efi_enabled (EFI_MEMMAP )) {
PATCH v8 4/5 usb: serial: add dbc debug device support to usb_debug
In reply to Lu BaoluThis patch adds dbc debug device support to the usb_debug driver.
--- drivers/usb/serial/usb_debug.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/usb/serial/usb_debug.c +25 -3
@@ -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" );
Signature · 1 line
2.1.4
tip-bot for Lu Baolu
merge bot[tip:x86/debug] usb/serial: Add DBC debug device support to usb_debug
usb/serial: Add DBC debug device support to usb_debug
Commit-ID: 57fb47279a04cd53641dc5ae55a6d47e4f32a2fd Gitweb: http://git.kernel.org/tip/57fb47279a04cd53641dc5ae55a6d47e4f32a2fd Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:32 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:30:17 +0100
usb/serial: Add DBC debug device support to usb_debug
This patch adds DBC debug device support to the usb_debug driver.
--- drivers/usb/serial/usb_debug.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/usb/serial/usb_debug.c +25 -3
@@ -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" );
PATCH v8 5/5 usb: doc: add document for USB3 debug port usage
In reply to Lu BaoluAdd Documentation/usb/usb3-debug-port.rst. This document includes the guide for using USB3 debug port.
--- Documentation/usb/usb3-debug-port.rst | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Documentation/usb/usb3-debug-port.rst
Documentation/usb/usb3-debug-port.rst new file +100 -0
@@ -0,0 +1,100 @@ +=============== +USB3 debug port +=============== + +:Author: Lu Baolu <[email protected]> +:Date: March 2017 + +GENERAL +======= + +This is a HOWTO for using the USB3 debug port on x86 systems. + +Before using any kernel debugging functionality based on USB3 +debug port, you need to:: + + 1) check whether any USB3 debug port is available in + your system; + 2) check which port is used for debugging purposes; + 3) have a USB 3.0 super-speed A-to-A debugging cable. + +INTRODUCTION +============ + +The xHCI debug capability (DbC) is an optional but standalone +functionality provided by the xHCI host controller. The xHCI +specification describes DbC in the section 7.6. + +When DbC is initialized and enabled, it will present a debug +device through the debug port (normally the first USB3 +super-speed port). The debug device is fully compliant with +the USB framework and provides the equivalent of a very high +performance full-duplex serial link between the debug target +(the system under debugging) and a debug host. + +EARLY PRINTK +============ + +DbC has been designed to log early printk messages. One use for +this feature is kernel debugging. For example, when your machine +crashes very early before the regular console code is initialized. +Other uses include simpler, lockless logging instead of a full- +blown printk console driver and klogd. + +On the debug target system, you need to customize a debugging +kernel with CONFIG_EARLY_PRINTK_USB_XDBC enabled. And, add below +kernel boot parameter:: + + "earlyprintk=xdbc" + +If there are multiple xHCI controllers in your system, you can +append a host contoller index to this kernel parameter. This +index starts from 0. + +Current design doesn't support DbC runtime suspend/resume. As +the result, you'd better disable runtime power management for +USB subsystem by adding below kernel boot parameter:: + + "usbcore.autosuspend=-1" + +Before starting the debug target, you should connect the debug +port to a USB port (root port or port of any 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 the debug target, DbC will be detected and +initialized. After initialization, the debug host should be able +to enumerate the debug device in debug target. The debug host +will then bind the debug device with the usb_debug driver module +and create the /dev/ttyUSB device. + +If the debug device enumeration goes smoothly, you should be able +to see below kernel messages on the debug host:: + + # tail -f /var/log/kern.log + [ 1815.983374] usb 4-3: new SuperSpeed USB device number 4 using xhci_hcd + [ 1815.999595] usb 4-3: LPM exit latency is zeroed, disabling LPM. + [ 1815.999899] usb 4-3: New USB device found, idVendor=1d6b, idProduct=0004 + [ 1815.999902] usb 4-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 + [ 1815.999903] usb 4-3: Product: Remote GDB + [ 1815.999904] usb 4-3: Manufacturer: Linux + [ 1815.999905] usb 4-3: SerialNumber: 0001 + [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc converter detected + [ 1816.000360] usb 4-3: xhci_dbc converter now attached to ttyUSB0 + +You can use any communication program, for example minicom, to +read and view the messages. Below simple bash scripts can help +you to check the sanity of the setup. + +.. code-block:: sh + + ===== start of bash scripts ============= + #!/bin/bash + + while true ; do + while [ ! -d /sys/class/tty/ttyUSB0 ] ; do + : + done + cat /dev/ttyUSB0 + done + ===== end of bash scripts ===============
Signature · 1 line
2.1.4
tip-bot for Lu Baolu
merge bot[tip:x86/debug] usb/doc: Add document for USB3 debug port usage
usb/doc: Add document for USB3 debug port usage
Commit-ID: 1b326277798aa820c1043617786609b9bb4bee78 Gitweb: http://git.kernel.org/tip/1b326277798aa820c1043617786609b9bb4bee78 Author: Lu Baolu <[email protected]> AuthorDate: Tue, 21 Mar 2017 16:01:33 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 21 Mar 2017 12:30:17 +0100
usb/doc: Add document for USB3 debug port usage
Add Documentation/usb/usb3-debug-port.rst. This document includes the guide for using USB3 debug port.
--- Documentation/usb/usb3-debug-port.rst | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+)
Documentation/usb/usb3-debug-port.rst new file +100 -0
@@ -0,0 +1,100 @@ +=============== +USB3 debug port +=============== + +:Author: Lu Baolu <[email protected]> +:Date: March 2017 + +GENERAL +======= + +This is a HOWTO for using the USB3 debug port on x86 systems. + +Before using any kernel debugging functionality based on USB3 +debug port, you need to:: + + 1) check whether any USB3 debug port is available in + your system; + 2) check which port is used for debugging purposes; + 3) have a USB 3.0 super-speed A-to-A debugging cable. + +INTRODUCTION +============ + +The xHCI debug capability (DbC) is an optional but standalone +functionality provided by the xHCI host controller. The xHCI +specification describes DbC in the section 7.6. + +When DbC is initialized and enabled, it will present a debug +device through the debug port (normally the first USB3 +super-speed port). The debug device is fully compliant with +the USB framework and provides the equivalent of a very high +performance full-duplex serial link between the debug target +(the system under debugging) and a debug host. + +EARLY PRINTK +============ + +DbC has been designed to log early printk messages. One use for +this feature is kernel debugging. For example, when your machine +crashes very early before the regular console code is initialized. +Other uses include simpler, lockless logging instead of a full- +blown printk console driver and klogd. + +On the debug target system, you need to customize a debugging +kernel with CONFIG_EARLY_PRINTK_USB_XDBC enabled. And, add below +kernel boot parameter:: + + "earlyprintk=xdbc" + +If there are multiple xHCI controllers in your system, you can +append a host contoller index to this kernel parameter. This +index starts from 0. + +Current design doesn't support DbC runtime suspend/resume. As +the result, you'd better disable runtime power management for +USB subsystem by adding below kernel boot parameter:: + + "usbcore.autosuspend=-1" + +Before starting the debug target, you should connect the debug +port to a USB port (root port or port of any 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 the debug target, DbC will be detected and +initialized. After initialization, the debug host should be able +to enumerate the debug device in debug target. The debug host +will then bind the debug device with the usb_debug driver module +and create the /dev/ttyUSB device. + +If the debug device enumeration goes smoothly, you should be able +to see below kernel messages on the debug host:: + + # tail -f /var/log/kern.log + [ 1815.983374] usb 4-3: new SuperSpeed USB device number 4 using xhci_hcd + [ 1815.999595] usb 4-3: LPM exit latency is zeroed, disabling LPM. + [ 1815.999899] usb 4-3: New USB device found, idVendor=1d6b, idProduct=0004 + [ 1815.999902] usb 4-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 + [ 1815.999903] usb 4-3: Product: Remote GDB + [ 1815.999904] usb 4-3: Manufacturer: Linux + [ 1815.999905] usb 4-3: SerialNumber: 0001 + [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc converter detected + [ 1816.000360] usb 4-3: xhci_dbc converter now attached to ttyUSB0 + +You can use any communication program, for example minicom, to +read and view the messages. Below simple bash scripts can help +you to check the sanity of the setup. + +.. code-block:: sh + + ===== start of bash scripts ============= + #!/bin/bash + + while true ; do + while [ ! -d /sys/class/tty/ttyUSB0 ] ; do + : + done + cat /dev/ttyUSB0 + done + ===== end of bash scripts ===============
Quoted 17 lines · Lu Baolu
xHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. With DbC hardware initialized, the system will present a debug device through the USB3 debug port (normally the first USB3 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. The DbC functionality is independent of xHCI host.
This patch set adds support for early printk functionality through a USB3 debug port by 1) initializing and enabling the DbC hardware during early boot; 2) registering a boot console to the system so that early printk messages can go through the USB3 debug port. It also includes some lines of changes in
usb_debugdriver so that it can be bound when a USB3 debug device is enumerated.
[...]
Quoted 8 lines
Lu Baolu (5):
x86: add simple udelay calibration
usb: early: add driver for xhci debug capability
x86: add support for earlyprintk via USB3 debug port
usb: serial: add dbc debug device support tousb_debug
usb: doc: add document for USB3 debug port usage
Quoted 16 lines
Documentation/admin-guide/kernel-parameters.txt | 1 + Documentation/usb/usb3-debug-port.rst | 100 +++ arch/x86/Kconfig.debug | 23 + arch/x86/kernel/early_printk.c | 5 + arch/x86/kernel/setup.c | 26 + drivers/usb/Makefile | 2 +- drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 1014 +++++++++++++++++++++++ drivers/usb/early/xhci-dbc.h | 211 +++++ drivers/usb/serial/usb_debug.c | 28 +- include/linux/usb/xhci-dbgp.h | 29 + 11 files changed, 1436 insertions(+), 4 deletions(-) create mode 100644 Documentation/usb/usb3-debug-port.rst create mode 100644 drivers/usb/early/xhci-dbc.c create mode 100644 drivers/usb/early/xhci-dbc.h create mode 100644 include/linux/usb/xhci-dbgp.h
Ok, this has now become a high quality series with picture-perfect patches AFAICS.
Thomas also gave his Acked-by to all the patches.
I've applied them locally to -tip (it appears the USB maintainers are still fine with this being carried in tip:x86/debug for a v4.12 merge, right?), and will push them out and will propagate them to linux-next as well if they pass testing.
Thanks for the great work!
Ingo
Greg Kroah-Hartman
maintainerQuoted 46 lines · Ingo Molnar
Quoted 17 lines · Lu Baolu
xHCI debug capability (DbC) is an optional but standalone functionality provided by an xHCI host controller. With DbC hardware initialized, the system will present a debug device through the USB3 debug port (normally the first USB3 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. The DbC functionality is independent of xHCI host.
This patch set adds support for early printk functionality through a USB3 debug port by 1) initializing and enabling the DbC hardware during early boot; 2) registering a boot console to the system so that early printk messages can go through the USB3 debug port. It also includes some lines of changes in
usb_debugdriver so that it can be bound when a USB3 debug device is enumerated.[...]
Quoted 8 lines
Lu Baolu (5):
x86: add simple udelay calibration
usb: early: add driver for xhci debug capability
x86: add support for earlyprintk via USB3 debug port
usb: serial: add dbc debug device support tousb_debug
usb: doc: add document for USB3 debug port usageQuoted 16 lines
Documentation/admin-guide/kernel-parameters.txt | 1 + Documentation/usb/usb3-debug-port.rst | 100 +++ arch/x86/Kconfig.debug | 23 + arch/x86/kernel/early_printk.c | 5 + arch/x86/kernel/setup.c | 26 + drivers/usb/Makefile | 2 +- drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 1014 +++++++++++++++++++++++ drivers/usb/early/xhci-dbc.h | 211 +++++ drivers/usb/serial/usb_debug.c | 28 +- include/linux/usb/xhci-dbgp.h | 29 + 11 files changed, 1436 insertions(+), 4 deletions(-) create mode 100644 Documentation/usb/usb3-debug-port.rst create mode 100644 drivers/usb/early/xhci-dbc.c create mode 100644 drivers/usb/early/xhci-dbc.h create mode 100644 include/linux/usb/xhci-dbgp.h
Quoted 7 lines
Ok, this has now become a high quality series with picture-perfect patches AFAICS.
Thomas also gave his Acked-by to all the patches.
I've applied them locally to -tip (it appears the USB maintainers are still fine with this being carried in tip:x86/debug for a v4.12 merge, right?), and will push them out and will propagate them to linux-next as well if they pass testing.
Yes, no objection from me.
thanks,
greg k-h
Quoted 6 lines · Greg Kroah-Hartman
Quoted 4 lines
I've applied them locally to -tip (it appears the USB maintainers are still fine with this being carried in tip:x86/debug for a v4.12 merge, right?), and will push them out and will propagate them to linux-next as well if they pass testing.
Yes, no objection from me.
Cool, thanks!
Ingo
Hi,
Quoted 25 lines · Ingo Molnar
Quoted 23 lines
Lu Baolu (5):
Quoted 22 lines
x86: add simple udelay calibration
usb: early: add driver for xhci debug capability
x86: add support for earlyprintk via USB3 debug port
usb: serial: add dbc debug device support tousb_debug
usb: doc: add document for USB3 debug port usageDocumentation/admin-guide/kernel-parameters.txt | 1 + Documentation/usb/usb3-debug-port.rst | 100 +++ arch/x86/Kconfig.debug | 23 + arch/x86/kernel/early_printk.c | 5 + arch/x86/kernel/setup.c | 26 + drivers/usb/Makefile | 2 +- drivers/usb/early/Makefile | 1 + drivers/usb/early/xhci-dbc.c | 1014 +++++++++++++++++++++++ drivers/usb/early/xhci-dbc.h | 211 +++++ drivers/usb/serial/usb_debug.c | 28 +- include/linux/usb/xhci-dbgp.h | 29 + 11 files changed, 1436 insertions(+), 4 deletions(-) create mode 100644 Documentation/usb/usb3-debug-port.rst create mode 100644 drivers/usb/early/xhci-dbc.c create mode 100644 drivers/usb/early/xhci-dbc.h create mode 100644 include/linux/usb/xhci-dbgp.hOk, this has now become a high quality series with picture-perfect patches AFAICS.
Quoted 7 lines
Thomas also gave his Acked-by to all the patches.
I've applied them locally to -tip (it appears the USB maintainers are still fine with this being carried in tip:x86/debug for a v4.12 merge, right?), and will push them out and will propagate them to linux-next as well if they pass testing.
Thanks for the great work!
Thank you!
Best regards,
Lu Baolu