public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Raul Rangel <rrangel@chromium.org>
Cc: Randy Dunlap <rdunlap@infradead.org>,
	Mario Limonciello <mario.limonciello@amd.com>,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kramasub@chromium.org, Alexander Potapenko <glider@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	Li Zhe <lizhe.67@bytedance.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Zhou jie <zhoujie@nfschina.com>
Subject: Re: [PATCH] init: Don't proxy console= to earlycon
Date: Thu, 22 Aug 2024 10:15:05 +0200	[thread overview]
Message-ID: <ZsbziXXdPwLrJR_t@pathway.suse.cz> (raw)
In-Reply-To: <CAHQZ30BwXeZNS1BZCQa5Nyb6S7akXvAqnhXR8w2Cj6LnMG6kGg@mail.gmail.com>

On Wed 2024-08-21 09:30:17, Raul Rangel wrote:
> On Wed, Aug 21, 2024 at 8:38 AM Petr Mladek <pmladek@suse.com> wrote:
> >
> > On Thu 2024-08-08 11:30:53, Raul Rangel wrote:
> > > On Fri, Jul 28, 2023 at 11:57 AM Raul Rangel <rrangel@chromium.org> wrote:
> > > > > Your patch is good then. Well, would you mind to add a comment into
> > > > > the code and make the commit message more clear even for dummies like
> > > > > me?
> > > > >
> > > > > Something like the patch below. It would be better to split it into
> > > > > two:
> > > > >
> > > > >    + 1st shuffling the check and adding the first part of the comment
> > > > >    + 2nd fixing the case with empty console= options.
> > > > >
> > > > > I could prepare the patchset. I would keep your SOB for the 2nd patch
> > > > > if you agreed.
> > > >
> > > > Yes, feel free. Thanks!
> > > >
> > >
> > > Hey Petr,
> > > I was just following up on this. Were you going to prepare the two patches?
> >
> > I have been quite overloaded last two years. It would help me a lot if
> > you could prepare the two patches and send them for review.
> >
> > Thanks for re-opening this. It has already fallen through cracks on my
> > side /o\.
> >
> > Best Regards,
> > Petr
> 
> No worries, we were just going through our tech debt backlog and this
> patch came up.
> 
> Thinking about this a little bit more, I'm wondering if we can clean
> up the hack. Would something like the following patch work? My thought
> is we declare an early handler for `console=`, so we can handle the
> `console=uartXXXX` case, and leave the non-early handler in place to
> handle the `console=ttyXX` cases.

I am not completely sure but I guess that it should work.

> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index a5f380584cdae7..7a48fe6fc0dffc 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -241,6 +241,21 @@ static int __init param_setup_earlycon(char *buf)
>  }
>  early_param("earlycon", param_setup_earlycon);
> 
> +static int __init param_setup_earlycon_console_alias(char *buf)
> +{
> +       /* We only want to handle `console=XXXX` in this handler. We leave
> +          `console` and `console=` to be handled later by the non-early printk
> +          handler.
> +       */

I would prefer to be more clear about why we do not want to handle
this case here. Something like:

<proposal>
	/* `console` and `console=` are used to disable console	completely. */
</proposal>

> +       if (!buf || !buf[0]) {
> +               return 0;
> +       }
> +
> +       /* `console=uartXXXX` is actually an alias for `earlycon=uartXXXX`. */
> +       /* `console=uartXXXX` is actually an alias for `earlycon=uartXXXX`. */
> +       return param_setup_earlycon(buf);
> +}
> +early_param("console=", param_setup_earlycon_console_alias);

I am not sure if '=' can be part of the param. All other early_param()
definitions are without '='. Also it seems that next_arg() in lib/cmdline.c
replaces '=' with '\0'.


> +
>  #ifdef CONFIG_OF_EARLY_FLATTREE
> 
>  int __init of_setup_earlycon(const struct earlycon_id *match,
> diff --git a/init/main.c b/init/main.c
> index 8e1f6127e172c3..b6f0cb424176da 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -740,9 +740,7 @@ static int __init do_early_param(char *param, char *val,
>         const struct obs_kernel_param *p;
> 
>         for (p = __setup_start; p < __setup_end; p++) {
> -               if ((p->early && parameq(param, p->str)) ||
> -                   (strcmp(param, "console") == 0 &&
> -                    strcmp(p->str, "earlycon") == 0 && val && val[0])) {
> +               if ((p->early && parameq(param, p->str))) {
>                         if (p->setup_func(val) != 0)
>                                 pr_warn("Malformed early option '%s'\n", param);
>                 }

I really like this change if it works ;-)

Best Regards,
Petr

      reply	other threads:[~2024-08-22  8:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-08  1:17 [PATCH] init: Don't proxy console= to earlycon Raul E Rangel
2023-07-09  0:48 ` Andrew Morton
2023-07-11 18:15   ` Raul Rangel
2023-07-09 23:46 ` Randy Dunlap
2023-07-10  1:15   ` Mario Limonciello
2023-07-10  2:43     ` Randy Dunlap
2023-07-10 15:30       ` Raul Rangel
2023-07-10 15:41         ` Randy Dunlap
2023-07-14 16:38         ` Petr Mladek
2023-07-14 17:21           ` Raul Rangel
2023-07-14 17:24             ` Raul Rangel
2023-07-14 18:35             ` Petr Mladek
2023-07-14 21:42               ` Raul Rangel
2023-07-18  9:50                 ` Petr Mladek
2023-07-28 17:57                   ` Raul Rangel
2024-08-08 17:30                     ` Raul Rangel
2024-08-21 14:38                       ` Petr Mladek
2024-08-21 15:30                         ` Raul Rangel
2024-08-22  8:15                           ` Petr Mladek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZsbziXXdPwLrJR_t@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=Jason@zx2c4.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kramasub@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhe.67@bytedance.com \
    --cc=mario.limonciello@amd.com \
    --cc=mark.rutland@arm.com \
    --cc=rdunlap@infradead.org \
    --cc=rrangel@chromium.org \
    --cc=will@kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=zhoujie@nfschina.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox