From patchwork Tue Apr 28 16:22:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 185813 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp5995767ilf; Tue, 28 Apr 2020 09:22:45 -0700 (PDT) X-Received: by 2002:a5d:420d:: with SMTP id n13mr37146267wrq.204.1588090965626; Tue, 28 Apr 2020 09:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588090965; cv=none; d=google.com; s=arc-20160816; b=0FGhyX7N3uDUsGI+s0YXMqCwd4kI9PFWXya5F4WIJePQ5NQxyYXW1JYFKmD4Ep/ZD0 ju4qqG1aQzHejHj76jLYCMgl4vHsckMHS6iL1JB4u3uyU5bufoBYjf+mJyzO0r4sg9ml E7Dp2TEGFAUyP5tEBKe0KxeSRYksAArNzNJPkZl2V1YTNm/a87lPpkAg98kLaKvqhCma hUga1N77EFr9RLqHFIR8D4A0IsftCv+AE88HkxYfEidwhGCsOMe66LfNcXlr/Ucb9BdL kMpu9XUo+M+WBMI7nLZWg6ounVIVYLR+Bd1x6kZAuOlcShhOCcYR4cvVndl/iAHcc03e QynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=QZ3V+kSzSOvh3yPLaUGq339r3FXngS2JfBwbre6zrhE=; b=g30qXFL0rrcAFYDvp46reZCj60PmwfPssczoV7Zt2M5tF8eAaqJk5yalXBVo8A6n9g r5QU6j/VC42JfSz6+YBcdIkuA+D4cv2mTvfD2dcdKLrRk+wvaCu664tBWtmXlfsK3u5J QB0PXeb0GC7pXq8nPI/MVj8uqHZQAYTCXkbbvleEh/8bdIuw3iZWblxFyDDFa1rsEV0p CNAZsCRCxjorUm7gPZ6owyq4i2e4rd+Mv1rlXJTqYgiWH2VwAwYKesOPP7QCq/T8Ywgj McjcLYxIfQWM2m1K6g1n5iFgTclHKBiiS1K+EYguTba7zuX0V9veJNC76pJgKydPvU9o 2/Ww== 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 daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s19sor2150234wmj.1.2020.04.28.09.22.45 for (Google Transport Security); Tue, 28 Apr 2020 09:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXhWPL5O; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=OJdho1UNwYUZuLlFog5XUkmdlFBRDKP0T1aWB/V6ZL/MEb3B4DCvzAvTgCpP5YJRCi WbeNiCcv0vUjEADjloSRw7vAeS1K7MSmbkiuzndJrfLjoblWBSiaBidqwAtP+2WRnwPt wiJxVzUzxWNCn+agXqDMwv22yTMA/b0CYbI9QHf7XE/Jhuks1mXy39hU3YQ9q4yzarOC aTrJpPziuS7AzEP0yEEOrSP21QGtq0ksvQBV1cC4SFOthchEYGZRveMsjBXf5TJRJ5fz zZ3n7RHOIIN0WtCFLKMSpejnk5Cs9i09l83qhO/eqMx4BmgaAlHvvA0+SeIARNfZXSGN LlZw== X-Gm-Message-State: AGi0PubQeLHi/CRA6ZE8lWR/feKESC4dmEq4D0yC/nmlOMiUarYKa++N hNRMzyLlVb+k8VjChSI5dxILiVX4 X-Google-Smtp-Source: APiQypL+DZ5U8Se/92OpfKlWfoY0M5q66E1XNeANbqXCYI9gMYeEmYEHp30ZLcpfBz/YNt7hw8TgYA== X-Received: by 2002:a1c:9a81:: with SMTP id c123mr5124445wme.115.1588090965173; Tue, 28 Apr 2020 09:22:45 -0700 (PDT) Return-Path: 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 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(-) -- 2.25.1 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) {