* [PATCH 0/3] x86: Make XDBC work
@ 2022-03-04 15:19 Peter Zijlstra
2022-03-04 15:19 ` [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay() Peter Zijlstra
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Peter Zijlstra @ 2022-03-04 15:19 UTC (permalink / raw)
To: x86, mathias.nyman, gregkh; +Cc: linux-kernel, peterz, rdunlap, linux-usb
Hi!
These are the patches I needed to make XDBC go on my tigerlake NUC.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay()
2022-03-04 15:19 [PATCH 0/3] x86: Make XDBC work Peter Zijlstra
@ 2022-03-04 15:19 ` Peter Zijlstra
2022-03-04 15:19 ` [PATCH 2/3] usb: early: xhci-dbc: Remove duplicate keep parsing Peter Zijlstra
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2022-03-04 15:19 UTC (permalink / raw)
To: x86, mathias.nyman, gregkh; +Cc: linux-kernel, peterz, rdunlap, linux-usb
Currently loops_per_jiffy is set in tsc_early_init(), but then don't
switch to delay_tsc, with the result that delay_loop is used with
loops_per_jiffy set for delay_tsc.
Then in (late) tsc_init() lpj_fine is set (which is mostly unused) and
after which use_tsc_delay() is finally called.
Move both loops_per_jiffy and use_tsc_delay() into
tsc_enable_sched_clock() which is called the moment tsc_khz is
determined, be it early or late. Keeping the lot consistent.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/kernel/tsc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1487,6 +1487,9 @@ static unsigned long __init get_loops_pe
static void __init tsc_enable_sched_clock(void)
{
+ loops_per_jiffy = get_loops_per_jiffy();
+ use_tsc_delay();
+
/* Sanitize TSC ADJUST before cyc2ns gets initialized */
tsc_store_and_check_tsc_adjust(true);
cyc2ns_init_boot_cpu();
@@ -1502,8 +1505,6 @@ void __init tsc_early_init(void)
return;
if (!determine_cpu_tsc_frequencies(true))
return;
- loops_per_jiffy = get_loops_per_jiffy();
-
tsc_enable_sched_clock();
}
@@ -1537,7 +1538,6 @@ void __init tsc_init(void)
enable_sched_clock_irqtime();
lpj_fine = get_loops_per_jiffy();
- use_tsc_delay();
check_system_tsc_reliable();
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] usb: early: xhci-dbc: Remove duplicate keep parsing
2022-03-04 15:19 [PATCH 0/3] x86: Make XDBC work Peter Zijlstra
2022-03-04 15:19 ` [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay() Peter Zijlstra
@ 2022-03-04 15:19 ` Peter Zijlstra
2022-03-04 15:19 ` [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing Peter Zijlstra
2022-04-20 3:14 ` [PATCH 0/3] x86: Make XDBC work Randy Dunlap
3 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2022-03-04 15:19 UTC (permalink / raw)
To: x86, mathias.nyman, gregkh; +Cc: linux-kernel, peterz, rdunlap, linux-usb
The generic earlyprintk= parsing already parses the optional ",keep",
no need to duplicate that in the xdbc driver.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/kernel/early_printk.c | 2 +-
drivers/usb/early/xhci-dbc.c | 5 ++---
include/linux/usb/xhci-dbgp.h | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -387,7 +387,7 @@ static int __init setup_early_printk(cha
#endif
#ifdef CONFIG_EARLY_PRINTK_USB_XDBC
if (!strncmp(buf, "xdbc", 4))
- early_xdbc_parse_parameter(buf + 4);
+ early_xdbc_parse_parameter(buf + 4, keep);
#endif
buf++;
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -599,7 +599,7 @@ static int __init xdbc_early_setup(void)
return 0;
}
-int __init early_xdbc_parse_parameter(char *s)
+int __init early_xdbc_parse_parameter(char *s, int keep_early)
{
unsigned long dbgp_num = 0;
u32 bus, dev, func, offset;
@@ -608,8 +608,7 @@ int __init early_xdbc_parse_parameter(ch
if (!early_pci_allowed())
return -EPERM;
- if (strstr(s, "keep"))
- early_console_keep = true;
+ early_console_keep = keep_early;
if (xdbc.xdbc_reg)
return 0;
--- a/include/linux/usb/xhci-dbgp.h
+++ b/include/linux/usb/xhci-dbgp.h
@@ -15,7 +15,7 @@
#define __LINUX_XHCI_DBGP_H
#ifdef CONFIG_EARLY_PRINTK_USB_XDBC
-int __init early_xdbc_parse_parameter(char *s);
+int __init early_xdbc_parse_parameter(char *s, int keep_early);
int __init early_xdbc_setup_hardware(void);
void __init early_xdbc_register_console(void);
#else
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing
2022-03-04 15:19 [PATCH 0/3] x86: Make XDBC work Peter Zijlstra
2022-03-04 15:19 ` [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay() Peter Zijlstra
2022-03-04 15:19 ` [PATCH 2/3] usb: early: xhci-dbc: Remove duplicate keep parsing Peter Zijlstra
@ 2022-03-04 15:19 ` Peter Zijlstra
2022-03-08 10:01 ` Mathias Nyman
2022-04-20 3:14 ` [PATCH 0/3] x86: Make XDBC work Randy Dunlap
3 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2022-03-04 15:19 UTC (permalink / raw)
To: x86, mathias.nyman, gregkh; +Cc: linux-kernel, peterz, rdunlap, linux-usb
kstrtoul() assumes the string contains the number only and is \0
terminated, this is not the case, as such things like:
earlyprintk=xdbc1,keep
go completely sideways. Use simple_strtoul() instead.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
drivers/usb/early/xhci-dbc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -603,6 +603,7 @@ int __init early_xdbc_parse_parameter(ch
{
unsigned long dbgp_num = 0;
u32 bus, dev, func, offset;
+ char *e;
int ret;
if (!early_pci_allowed())
@@ -613,8 +614,11 @@ int __init early_xdbc_parse_parameter(ch
if (xdbc.xdbc_reg)
return 0;
- if (*s && kstrtoul(s, 0, &dbgp_num))
- dbgp_num = 0;
+ if (*s) {
+ dbgp_num = simple_strtoul(s, &e, 10);
+ if (s == e)
+ dbgp_num = 0;
+ }
pr_notice("dbgp_num: %lu\n", dbgp_num);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing
2022-03-04 15:19 ` [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing Peter Zijlstra
@ 2022-03-08 10:01 ` Mathias Nyman
0 siblings, 0 replies; 6+ messages in thread
From: Mathias Nyman @ 2022-03-08 10:01 UTC (permalink / raw)
To: Peter Zijlstra, x86, gregkh; +Cc: linux-kernel, rdunlap, linux-usb
On 4.3.2022 17.19, Peter Zijlstra wrote:
> kstrtoul() assumes the string contains the number only and is \0
> terminated, this is not the case, as such things like:
>
> earlyprintk=xdbc1,keep
>
> go completely sideways. Use simple_strtoul() instead.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> drivers/usb/early/xhci-dbc.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> --- a/drivers/usb/early/xhci-dbc.c
> +++ b/drivers/usb/early/xhci-dbc.c
> @@ -603,6 +603,7 @@ int __init early_xdbc_parse_parameter(ch
> {
> unsigned long dbgp_num = 0;
> u32 bus, dev, func, offset;
> + char *e;
> int ret;
>
> if (!early_pci_allowed())
> @@ -613,8 +614,11 @@ int __init early_xdbc_parse_parameter(ch
> if (xdbc.xdbc_reg)
> return 0;
>
> - if (*s && kstrtoul(s, 0, &dbgp_num))
> - dbgp_num = 0;
> + if (*s) {
Do you think we need a code comment here stating something like
"use deprecated simple_strtoul() as kstrtoul can't handle characters after the number"
> + dbgp_num = simple_strtoul(s, &e, 10);
> + if (s == e)
> + dbgp_num = 0;
> + }
>
If not then PATCH 2/3 and 3/3 looks good to me
I don't know much about PATCH 1/3, the tsc change, but it didn't cause any issues for me either.
Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Thanks
-Mathias
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] x86: Make XDBC work
2022-03-04 15:19 [PATCH 0/3] x86: Make XDBC work Peter Zijlstra
` (2 preceding siblings ...)
2022-03-04 15:19 ` [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing Peter Zijlstra
@ 2022-04-20 3:14 ` Randy Dunlap
3 siblings, 0 replies; 6+ messages in thread
From: Randy Dunlap @ 2022-04-20 3:14 UTC (permalink / raw)
To: Peter Zijlstra, x86, mathias.nyman, gregkh; +Cc: linux-kernel, linux-usb
Hi Peter,
On 3/4/22 07:19, Peter Zijlstra wrote:
> Hi!
>
> These are the patches I needed to make XDBC go on my tigerlake NUC.
>
I finally tested these patches (in mainline).
It's working well for me. Thanks.
--
~Randy
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-20 3:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04 15:19 [PATCH 0/3] x86: Make XDBC work Peter Zijlstra
2022-03-04 15:19 ` [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay() Peter Zijlstra
2022-03-04 15:19 ` [PATCH 2/3] usb: early: xhci-dbc: Remove duplicate keep parsing Peter Zijlstra
2022-03-04 15:19 ` [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing Peter Zijlstra
2022-03-08 10:01 ` Mathias Nyman
2022-04-20 3:14 ` [PATCH 0/3] x86: Make XDBC work Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).