Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1230720ybz; Wed, 29 Apr 2020 17:42:14 -0700 (PDT) X-Google-Smtp-Source: APiQypLfsLX/N8AO5w/AQQEA6uRvW/VC4t4/W9FrGpbw0WrkrBlSjNxOragWAA/AK2Gf/14mTIYx X-Received: by 2002:a50:d6d0:: with SMTP id l16mr522514edj.317.1588207334214; Wed, 29 Apr 2020 17:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588207334; cv=none; d=google.com; s=arc-20160816; b=mQEs1AbkvjVlYisdbaaBi26HYtVV0EL3MGOyoiCGbJL/+p9+EdmXaBiztz5WoWgRrG T8d1VvkmFkG1WrFkvWLjhJ1z7yLyTkVFnhiHAweDZyJ7h47BwquAgZ1VeSM+px1x88MK n58tI4Zvqh24NU7qQg+h07CiVpVQzxx76iVsutkA47WsCh1vJzGmAJRjH1gDG5Uv/0hF zR2SdqFp6Q0JEoxeu52eHGSVySEuycYLgume5zIUQhB0Ko5N1p8+DoU19g2KQNrkvVE/ shNwHj3c2GC2FupYikmEEJBVH8DOFic0fewggr0p5a6h1qhjWX5wv1Jm5j/ALQXh5Vzd av1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=49/GUq/fltLJWqVhbL7UqtJO8rowbFsOO5SNzjwHTOY=; b=WMP9Y+f0At/omLDdwShhL40F/R7BLpzwU+TjzHWA31ml9Pk6eu8uGwafvaVfSNPZ99 arcHFqiZpHanQbOLiYQ8pxw0Wp0L7Ry+xbvOSEuZUk0bJarBD5BIEtZ6o7rhz0Kret8L nwJmIzeNC31M1bTOWApfXY44Wq3he2cPJqVkcHoOhgaqh1nO3MAUSPygEXtMu5qBRg8C xY220+v0cANyiQjQsewW8UvDxUSHwm614xw/t3TxdqBxENXEYC1XkoxefYiXd0U1asWp g/Te/1hledB4mWqfyMSDjvvisFCNMci/Z6bvkACaPS2/6luInRSkdUC6OAHriZZv9X5Q 7hfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=i2TyRdk3; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si4949966edx.530.2020.04.29.17.41.50; Wed, 29 Apr 2020 17:42:14 -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=@chromium.org header.s=google header.b=i2TyRdk3; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbgD3AkZ (ORCPT + 99 others); Wed, 29 Apr 2020 20:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726329AbgD3AkZ (ORCPT ); Wed, 29 Apr 2020 20:40:25 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA787C035495 for ; Wed, 29 Apr 2020 17:40:24 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id g35so1723481uad.0 for ; Wed, 29 Apr 2020 17:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=49/GUq/fltLJWqVhbL7UqtJO8rowbFsOO5SNzjwHTOY=; b=i2TyRdk3Tqw4h5DLb1A3tKoVpg6kPPWMN84oMR/sl9QzBxxG57S94enQkwZ8kWGyDV tzwy8lrWGZ5glKqDug98HzSRlI/YWxPBTgkGtapyACJT9Q7CD0mJ1M+mRSABCl9EdY8i qce3QsW8VvVCYeQp7Cbb/dZQ7uMdN1f7TZLaE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=49/GUq/fltLJWqVhbL7UqtJO8rowbFsOO5SNzjwHTOY=; b=Kr46GsOTXIFp8xQrlInEeiZXSEZ1Y6CVTsLo8m2cn4jtPhRykKggKVaR7HvyKZzbT4 X+otK9JeGQbz6qhaurViPa0SBMKOsgqr6C9VeU7StuPz9xoEXSJBOO++tgLVKwwM+b7y tSIREzY8UREkaepJlInp3V0e5MoKtrc1YH5iAr2xFO5Zg3n315LnvZuL2jm5/wz7e7Z6 pdL4p+JEAntkTawrZONYk8M8XKaBRo22OvWj3ujhomhARIwqBPfwqSXJS4iSAdX7w6BS a2AJFO8ZxQvmPaaAcCapfem7JixRRDufFMG5it2FQp6sTIFxa/IS/Uf47A3XKQ60AFbW pE8Q== X-Gm-Message-State: AGi0PubIvGnu30uETdDwYeS+bzRlAA7/jliT1eIN0ysXJqvYEAMbjwwt 9V6nD+0SXrQ0uQYSfes/WVLIhmtJvKE= X-Received: by 2002:ab0:328:: with SMTP id 37mr496236uat.112.1588207223762; Wed, 29 Apr 2020 17:40:23 -0700 (PDT) Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com. [209.85.221.169]) by smtp.gmail.com with ESMTPSA id x23sm399067uan.15.2020.04.29.17.40.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 17:40:22 -0700 (PDT) Received: by mail-vk1-f169.google.com with SMTP id u203so1239221vkb.11 for ; Wed, 29 Apr 2020 17:40:22 -0700 (PDT) X-Received: by 2002:a1f:9645:: with SMTP id y66mr643020vkd.40.1588207222154; Wed, 29 Apr 2020 17:40:22 -0700 (PDT) MIME-Version: 1.0 References: <20200428162227.687978-1-daniel.thompson@linaro.org> In-Reply-To: <20200428162227.687978-1-daniel.thompson@linaro.org> From: Doug Anderson Date: Wed, 29 Apr 2020 17:40:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] serial: earlycon: Allow earlier DT scan is acpi=off To: Daniel Thompson Cc: Greg Kroah-Hartman , Jiri Slaby , Sumit Garg , linux-serial@vger.kernel.org, LKML , Patch Tracking Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Apr 28, 2020 at 9:22 AM Daniel Thompson wrote: > > 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(-) I wonder if a cleaner option is to just add a special "earlycon" value like "earlycon=not_acpi". This wouldn't require any special peeking and would just be a sentinel that just says "you should autodetect the earlycon, but don't worry about waiting for ACPI". ...that in itself is a bit of a hack, but at least it's more self contained in the earlycon driver and maybe more discoverable when someone is figuring out how to setup earlycon? -Doug > > 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 >