From: Tony Lindgren <tony.lindgren@linux.intel.com>
To: Petr Mladek <pmladek@suse.com>
Cc: "Tony Lindgren" <tony@atomide.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Steven Rostedt" <rostedt@goodmis.org>,
"John Ogness" <john.ogness@linutronix.de>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
"David S . Miller" <davem@davemloft.net>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Dhruva Gole" <d-gole@ti.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Johan Hovold" <johan@kernel.org>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
"Sebastian Reichel" <sre@kernel.org>,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v7 1/7] printk: Save console options for add_preferred_console_match()
Date: Mon, 27 May 2024 14:13:19 +0300 [thread overview]
Message-ID: <ZlRqz2b0ZrtkxScL@tlindgre-MOBL1> (raw)
In-Reply-To: <ZlC6_Um4P4b-_WQE@pathway.suse.cz>
Hi,
On Fri, May 24, 2024 at 06:06:21PM +0200, Petr Mladek wrote:
> I have finally found time to looks at this again.
Great good to hear.
> First, about breaking the preferred console:
>
> The patchset still causes the regression with /dev/console association
> as already reported for v3, see
> https://lore.kernel.org/r/ZWnvc6-LnXdjOQLY@alley
Thanks and sorry for missing this issue. I thought I had this issue
already handled, but looking at what I tested with earlier, looks like
I had the console options the wrong way around.
> I used the following kernel command line:
>
> earlycon=uart8250,io,0x3f8,115200 console=ttyS0,115200 console=tty0 ignore_loglevel log_buf_len=1M
>
> The patchset caused that /dev/console became associated with
> ttyS0 instead of tty0, see the "C" flag:
>
> original # cat /proc/consoles
> tty0 -WU (EC ) 4:1
> ttyS0 -W- (E p a) 4:64
>
> vs.
>
> patched # cat /proc/consoles
> ttyS0 -W- (EC p a) 4:64
> tty0 -WU (E ) 4:1
OK
> I have added some debugging messages which nicely show the reason.
> In the original code, __add_preferred_console() is called twice
> when processing the command line:
>
> [ 0.099312] __add_preferred_console[0]: ttyS, 0 (preferrred_console == 0)
> [ 0.099982] __add_preferred_console[1]: tty, 0 (preferrred_console == 1)
OK thanks for tracking down where things go wrong.
> The code thinks that "ttyS0" has been mentioned on the command line
> once again. And preferred_console is _wrongly_ set back to '0'.
>
> My view:
>
> The delayed __add_preferred_console() is a way to hell.
>
> The preferences are defined by the ordering on the command line.
> All entries have to be added when the command line options are
> being proceed to keep the order.
To me it seems we can fix this by keeping track of the console position
in the kernel command line. I'll send a fix for this to discuss.
> A solution might be to store "devname" separately in
> struct console_cmdline and allow empty "name". We could
> implement then a function similar to
> add_preferred_console_match() which would try to match
> "devname" and set/update "name", "index" value when matched.
>
> Note that we might also need to add some synchronization
> if it might be possible to modify struct console_cmdline
> in parallel.
OK certainly no objection from me if we can make this happen without
making things more complex :)
> Second, about the possible duplication:
>
> I might get it wrong. IMHO, in principle, this patchset tries
> to achieve similar thing as the "match()" callback, see
> the commit c7cef0a84912cab3c9 ("console: Add extensible
> console matching").
>
> The .match() callback in struct console is to match, for example,
> console=uart8250,io,0x3f8,115200 when the uart8250 driver
> calls register_console() when it is being properly initialized
> as "ttyS".
>
> BTW: The .match() needs saved options because it internally calls
> .setup() callback. IMHO, this is a very ugly detail
> which complicates design of the register_console() code.
>
>
> Both approaches try to match a "driver/device-specific name" with
> the generic "ttySX".
>
> console=uart8250,io,0x3f8,115200 => ttyS0
> vs.
> console=00:00:0.0,115200 => ttyS0
>
>
> Where console=uart8250,io,0x3f8,115200 is handled by:
>
> - "uart" is added to console_cmdline[]
> - matched directly via newcon->match() callback
>
> vs. console=00:00:0.0,115200
>
> - 00:00:0.0 is added to conopt[]
> - "ttyS0" added to console_cmdline[] when "00:00:0.0" initialized
> - "ttyS0" is then matched directly
>
>
> Question: Would it it be able to use the existing .match() callback
> also to match the DEVNAME?
>
> Or somehow reuse the approach?
Thanks, I'll take a look if .match(), or some parts related to it, can
be used.
> Could register_console() know how to generate possible
> DEVNAME for the given struct console?
I don't think we can make much assumptions about the devices early on,
and we also have the console index -1 issue.
Regards,
Tony
next prev parent reply other threads:[~2024-05-27 11:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 10:59 [PATCH v7 0/7] Add support for DEVNAME:0.0 style hardware based addressing Tony Lindgren
2024-03-27 10:59 ` [PATCH v7 1/7] printk: Save console options for add_preferred_console_match() Tony Lindgren
2024-03-27 13:36 ` Andy Shevchenko
2024-05-24 16:06 ` Petr Mladek
2024-05-27 11:13 ` Tony Lindgren [this message]
2024-05-27 13:45 ` Petr Mladek
2024-05-28 5:05 ` Tony Lindgren
2024-05-31 6:54 ` Tony Lindgren
2024-06-04 13:17 ` Tony Lindgren
2024-03-27 10:59 ` [PATCH v7 2/7] printk: Don't try to parse DEVNAME:0.0 console options Tony Lindgren
2024-03-27 10:59 ` [PATCH v7 3/7] printk: Flag register_console() if console is set on command line Tony Lindgren
2024-03-27 10:59 ` [PATCH v7 4/7] serial: core: Add support for DEVNAME:0.0 style naming for kernel console Tony Lindgren
2024-03-28 6:31 ` Dhruva Gole
2024-03-28 7:22 ` Greg Kroah-Hartman
2024-03-28 10:33 ` Dhruva Gole
2024-03-27 10:59 ` [PATCH v7 5/7] serial: core: Handle serial console options Tony Lindgren
2024-03-27 10:59 ` [PATCH v7 6/7] serial: 8250: Add preferred console in serial8250_isa_init_ports() Tony Lindgren
2024-03-27 10:59 ` [PATCH v7 7/7] Documentation: kernel-parameters: Add DEVNAME:0.0 format for serial ports Tony Lindgren
2024-03-28 6:05 ` Dhruva Gole
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=ZlRqz2b0ZrtkxScL@tlindgre-MOBL1 \
--to=tony.lindgren@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=corbet@lwn.net \
--cc=d-gole@ti.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
--cc=vigneshr@ti.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