From patchwork Fri Mar 4 15:19:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 12769331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59345C433EF for ; Fri, 4 Mar 2022 15:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240251AbiCDPXW (ORCPT ); Fri, 4 Mar 2022 10:23:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240225AbiCDPXR (ORCPT ); Fri, 4 Mar 2022 10:23:17 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FADB113A; Fri, 4 Mar 2022 07:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=i3uMN0XPCwzCCdJutSxOT0wu27OyMGNYJIeJECgEmYE=; b=aYtGzYmw8n0hqlGzMB/GVKRc1k 0EUx7uJQPV8vHY0UYk/h/Dl3Dg+B1v2+sZ/pD2d9O5516+8E88oq/iLMFb+HA7CRpXaUouUq0vHzr lCXCMP+xWspJSRaqVgpXv/YURR0YI998jQ+0JI6PyuyGv9QwRX1TTUuxvPE9P8Dj3M9Lr7ZVTxZ76 Ei0UbSwKFAg27eutVG9tJQzaC5sGBTsSPk69dV9hLRs2CwpC1VIumN1B6XvOD0wWnd5REvwq+xLIa +SJATIAiRyN0v43H2L4gnpulrBoV8x3E8vmSYVFeEqAB53tCVu1kCEeP7Eq/T/jrM5Uw3AFs51g04 hMCL9xcw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ9l4-00FEIm-Sp; Fri, 04 Mar 2022 15:22:19 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 819D530041D; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 6B7102012A030; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Message-ID: <20220304152135.914397165@infradead.org> User-Agent: quilt/0.66 Date: Fri, 04 Mar 2022 16:19:54 +0100 From: Peter Zijlstra To: x86@kernel.org, mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, rdunlap@infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay() References: <20220304151953.830111479@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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) --- 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(); From patchwork Fri Mar 4 15:19:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 12769328 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03FE7C433F5 for ; Fri, 4 Mar 2022 15:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240232AbiCDPXT (ORCPT ); Fri, 4 Mar 2022 10:23:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240223AbiCDPXR (ORCPT ); Fri, 4 Mar 2022 10:23:17 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C33DF10A6; Fri, 4 Mar 2022 07:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=h4FCNEPQwTG4sN1msaWa8+oYY6eRjb1lItZHTcbmJsA=; b=HvjqSCmDT7NxHR1WfgWeLckGZK s73J8y0wubGQnoJWwN6ER55IZfO7cqLKAftOn3ALwvg0oIGaOryZQG26pNdtpwyZx4VY8FMmY3vW5 KPXPlgxRNhb/qmKCryj91ARhfy5LOz5I0HUv+WDfUh6860r5CcxNCiHYR+qGrJxgkzNPaZB0Xw0Gi sKyMVMfxowaDNGZQVRCKeflnSpNeQeJCfyo0icU5nCDBh0pIH9ZusbfP/0qqPXOp+zenbIShSiVW3 LcxFzOpce8iFuWXXHVrWhadr0XOzFhZR1xTsIRw9AH/76SaaKxGVVXojt4JxrATBJ0exwvfc6Cp+7 YmJL5LUQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ9l4-00FEIl-SV; Fri, 04 Mar 2022 15:22:18 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 86444300454; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 6E1D72C546F73; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Message-ID: <20220304152135.975568860@infradead.org> User-Agent: quilt/0.66 Date: Fri, 04 Mar 2022 16:19:55 +0100 From: Peter Zijlstra To: x86@kernel.org, mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, rdunlap@infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 2/3] usb: early: xhci-dbc: Remove duplicate keep parsing References: <20220304151953.830111479@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The generic earlyprintk= parsing already parses the optional ",keep", no need to duplicate that in the xdbc driver. Signed-off-by: Peter Zijlstra (Intel) --- 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 From patchwork Fri Mar 4 15:19:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 12769330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A4A3C433F5 for ; Fri, 4 Mar 2022 15:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240245AbiCDPXU (ORCPT ); Fri, 4 Mar 2022 10:23:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240222AbiCDPXR (ORCPT ); Fri, 4 Mar 2022 10:23:17 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07DDD3880; Fri, 4 Mar 2022 07:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=QIlhvxTHHS/nanVwwxtHal6Wu98/SCmslE6BWXHduno=; b=X6qLG+ac8+En9eKNFpe+lA8tfA tgakWYuk8MeZZ7sI7+z0NuZXZ2XrIQu+i4DdINWK9aD+TIDms/Dg59lB2yGMx8GtCx3ug/okC3Ghf VFr9vCOdMpVwcyE3LExAIPfk8E8FwW5wncTwJx9Blm25+Qd/mEuTa0/11QDR3r8pBIK+kQwPD7TGS ZnS6KGd15FNfofasKdHqPsDl8ePIlPqC9QFxYj+MSWFv1mzlVmNTbd+F0sjJ4BUC7zq/8y8BV7RMY Ln74b7DK8Lpad8CIxczhTNSx5xCCOVGR3TFcQHg+Dfkbhs0G/Sr4fq8ebkFjxah2XV9yFKQtRmWMk UxFbVk9w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ9l3-00Cjnd-UU; Fri, 04 Mar 2022 15:22:18 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 88433300472; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7111E2C546F85; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Message-ID: <20220304152136.035911620@infradead.org> User-Agent: quilt/0.66 Date: Fri, 04 Mar 2022 16:19:56 +0100 From: Peter Zijlstra To: x86@kernel.org, mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, rdunlap@infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing References: <20220304151953.830111479@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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) Acked-by: Mathias Nyman --- 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);