Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4326389ybz; Tue, 28 Apr 2020 09:24:38 -0700 (PDT) X-Google-Smtp-Source: APiQypI/aCqW47MoRjE2vAhDulFBOb9AWUNviVX3474xtMpXYryo3KaYmm30xiRv8DPcii/77nzf X-Received: by 2002:a17:906:48c:: with SMTP id f12mr26176092eja.93.1588091078321; Tue, 28 Apr 2020 09:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588091078; cv=none; d=google.com; s=arc-20160816; b=PnZS5yVAf5Ktli5BpN0tT6gDc845FnxD2AUiuaAbERfTyeMmF/xXghaO9PXc4OFoBl d8nYx7MI18ufNL/DdXg9tUy2jLUKA27Zacfiv9UaFzFx3LAlr52ofcqGhzYU4C6iPyxl 8qHIYT3ZWcsUIEqWvQHbDabkzQfZl4OOL7qvXxTfdT0kpxD3pfUeXRt3mWX5im7zgWKl EQLoZzRkfWj8mAwVMw5c6L70GK25eX9pL8EPnih0LCybAHfIbeCaw+GlYcagUMMJV25e f/jhGjYjrRA1PCxSqbR9liVZw/8VKKsSXZGjAdW0OPAMpd6GJaCVGa6JA47lIQnY7cRE txtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QZ3V+kSzSOvh3yPLaUGq339r3FXngS2JfBwbre6zrhE=; b=PEVa4w6fXoEDlPHFLTwfQVvDYfYWmWDBmuuIOCNU9Z5YjKZSFYrU/liLjX9qf/BuLT wAKp2/G8tHvwj6Ku8njZSmKfc2SyQqwPBdcZfDNXUud7U4lmyT9A5Up87zthcweYCO1e +bfbX2Amuku1P6K9iWNicFt8PkdwmY9yePWsqo8UwCRly3BdZ5XcCqdEr1M8BP4a74Yl ItKeibYqd75xve1MRruLSilI8JWVJ6xY7QrOEKXEjuakrAgEv7cg5zxfs027nlT5EOys L3uwHPcaFQRiOJFnydVsf+qnLBymqRhwy7TTiSVahKyKgkuYg/K5QamUVMCL2ls27qJQ HgOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXhWPL5O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si2032727edv.44.2020.04.28.09.24.12; Tue, 28 Apr 2020 09:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXhWPL5O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728269AbgD1QWr (ORCPT + 99 others); Tue, 28 Apr 2020 12:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728035AbgD1QWr (ORCPT ); Tue, 28 Apr 2020 12:22:47 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 842FAC03C1AC for ; Tue, 28 Apr 2020 09:22:46 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id r26so3586437wmh.0 for ; Tue, 28 Apr 2020 09:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QZ3V+kSzSOvh3yPLaUGq339r3FXngS2JfBwbre6zrhE=; b=qXhWPL5O7QAlv2qAlEN7m7ou3SRfXay58XLzapUHPOrqFq57kRVrnAzyNaGqh0bdcT uiUDpYM+PCcW+uNeiiV1PYYfD2ZfHjhEvIQhhoqqiJ0KeDHG3kZUjXl4MfKlTjAfVuIe dkwhWQN/n2d7ZCrIC44jjhiVvc0O9z8yYk4Mspwztl1qzB4z2nK6zbYiijDhavRbx0ku ah3ajFogcn4fC/aTM48Eiq4MLrUhzDADKX33b7Wj5M3a8WtYnbT8a/KxUGc0+mTstRoa C1JbOFU2h0y1kg1tUKWJGCUF9Z1uYkdiDOykvYngQnHUHQjXICAXSV6IuWKcL7nvMnMv eySw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QZ3V+kSzSOvh3yPLaUGq339r3FXngS2JfBwbre6zrhE=; b=tFupC10sHSiNp8FTSuQGh5gtNKeRoLOGE9r43p2tCEG2HrsRG0+2owoMFZ0bku54xs LQjynRoNuLIWoSDgqSosZAxWeDXnPjC+eOZttJCYWCaGX9TGuEwnE2MYML0DvNa6LCSD Nl1n1oxiTOWDbWYgxkT8OF8imfU94vHT/MB7sxlWHKEw2HjmOiB4aOcE5SPodBTyr50U HcHKwAxVihjTHdP4Jm0fm26Ck5VJZLETs4HjJGbUzmE4ZKsyqMVg7TIfvrXuo243pxUc /bbP2Rv+XMNcB/qLbBGVjSTCQ0TLm05lA1rM9U/nv0zapAMYRlCYorhbaKThOrvPUfFD uj1w== X-Gm-Message-State: AGi0PuZzdSa+fjg0b2vP3ycVI3LuayJVfRnjbjTQ4UJvBFKlnxDrlOFV CdtFHs+ZQKB/zs910s4S3WTm0w== X-Received: by 2002:a1c:9a81:: with SMTP id c123mr5124445wme.115.1588090965173; Tue, 28 Apr 2020 09:22:45 -0700 (PDT) Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id o6sm17736097wrw.63.2020.04.28.09.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 09:22:44 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman Cc: Daniel Thompson , Jiri Slaby , Douglas Anderson , Sumit Garg , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH] serial: earlycon: Allow earlier DT scan is acpi=off Date: Tue, 28 Apr 2020 17:22:27 +0100 Message-Id: <20200428162227.687978-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently if the kernel has support for ACPI SPCR parsing then earlycon without arguments is processed later than the full earlycon=... alternative. If ACPI has been explicitly disabled on the kernel command line then there is not need to defer since the ACPI code (both x86 and arm64) will never actually run. Or, put another way it allows lazy people to throw "acpi=off earlycon" onto the command line of a DT systems and be confident the console will start as early as possible without them having to lookup the driver and address needed for a specific platform. Signed-off-by: Daniel Thompson --- drivers/tty/serial/earlycon.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index 2ae9190b64bb..ebb648aacb47 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -215,6 +215,31 @@ int __init setup_earlycon(char *buf) */ bool earlycon_acpi_spcr_enable __initdata; +/* + * This takes a sneaky peek at other boot arguments (which may not have + * been parsed at this point in the boot) to check whether ACPI has + * been explicitly disabled. If it is explicitly disabled then there is + * no reason to defer initialization of the early console. + */ +static bool earlycon_check_for_acpi_off(void) +{ + static const char token[] = "acpi=off"; + const char *arg; + char before, after; + + arg = strstr(boot_command_line, token); + while (arg) { + before = arg == boot_command_line ? ' ' : arg[-1]; + after = arg[sizeof(token)-1]; + if (isspace(before) && (isspace(after) || after == '\0')) + return true; + + arg = strstr(arg+1, token); + } + + return false; +} + /* early_param wrapper for setup_earlycon() */ static int __init param_setup_earlycon(char *buf) { @@ -222,7 +247,8 @@ static int __init param_setup_earlycon(char *buf) /* Just 'earlycon' is a valid param for devicetree and ACPI SPCR. */ if (!buf || !buf[0]) { - if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) { + if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE) && + !earlycon_check_for_acpi_off()) { earlycon_acpi_spcr_enable = true; return 0; } else if (!buf) { -- 2.25.1