Re: [PATCH 1/2] printk: Track command line console positions to fix console order

From: Petr Mladek
Date: Wed Jun 12 2024 - 10:49:16 EST


On Tue 2024-06-11 12:56:54, Tony Lindgren wrote:
> On Tue, Jun 11, 2024 at 10:17:11AM +0200, Petr Mladek wrote:
> > On Thu 2024-06-06 14:41:46, Tony Lindgren wrote:
> > > Recent changes to allow using DEVNAME:0.0 style console names caused a
> > > regression to the kernel command line handling for the console options.
> >
> > Sigh, I have missed that it has already ended in the mainline via
> > the tty tree :-/
> >
> > Honestly, I would prefer to revert it and implement it a clean way.
> > I see a lot of existing and possible problems:
>
> Naturally no objection from me for reverting if there are issues that are
> unfixable from the printk point of view. I'll update the fix along the
> lines you're suggesting below though, let's see if that's enough for the
> -rc cycle.

OK, let's see how the updated fix looks like.

> > 1. Where and how is DEVNAME:0.0 defined?
> >
> > The only documentation seems to be in
> > Documentation/admin-guide/kernel-parameters.txt for the console=
> > parameter:
> >
> > <paste>
> > <DEVNAME>:<n>.<n>[,options]
> > Use the specified serial port on the serial core bus.
> > The addressing uses DEVNAME of the physical serial port
> > device, followed by the serial core controller instance,
> > and the serial port instance. The options are the same
> > as documented for the ttyS addressing above.
> >
> > The mapping of the serial ports to the tty instances
> > can be viewed with:
> >
> > $ ls -d /sys/bus/serial-base/devices/*:*.*/tty/*
> > /sys/bus/serial-base/devices/00:04:0.0/tty/ttyS0
> >
> > In the above example, the console can be addressed with
> > console=00:04:0.0. Note that a console addressed this
> > way will only get added when the related device driver
> > is ready. The use of an earlycon parameter in addition to
> > the console may be desired for console output early on.
> > </paste>
> >
> > This seems to be a brand new bus.
> >
> > Is it stable?
> > Is it documented in Documentation/ABI/stable/?
>
> I think the DEVNAME originates from udev to be used for various rules. Yes
> it should be documented somewhere though. I'd say it's stable as it's been
> in use for years :)
>
> > It seems that the feature will cover "only" serial consoles.
> > But DEVNAME is a generic name. It might make more sense to
> > call it "SERIAL_BASE_DEVNAME" or "SERIAL_DEVNAME" or "SBASE_DEVNAME" or so.
> >
> > Anyway, console= is an interface with the user space. We will need to
> > maintain the backward compatibility "forever".
> >
> > => we should think twice about the interface !!!
>
> I think we want to keep it generic with DEVNAME, I don't see why we'd want
> make it serial console specific, at least in the code. For the documentation,
> I think the kernel parameters example is clear on the serial port usage?

OK, let's keep the DEVNAME in both the code and documentation,

> > 3. The delimiter between "DEVNAME" and X.Y numbers is ":".
> > But ":" is also part of the sample DEVNAME "00:00"
> >
> > Is it a good idea?
> >
> > Is the current naming scheme a well known historic one
> > or something invented for the new bus?
>
> PCI and USB use a ":" already for the device naming. Also a "-" can be used
> by the device names, many platform devices do that. I don't think we can
> pick any better limiter here, at least out of the ":", "-" and "." options.

OK, it seems that ':' is the best choice.

And thanks for explaining the other details. Everything makes more sense now.

Best Regards,
Petr