RE: [PATCH] printk: nbcon: check uart port is nbcon or not in nbcon_release

From: John Ogness
Date: Wed Jan 17 2024 - 05:06:10 EST


On 2024-01-17, "Chang, Junxiao" <junxiao.chang@xxxxxxxxx> wrote:
> There are several serial ports in one Intel ADL hardware, they are
> enumerated as ttyS0, ttyS1, ttyS4, and so on. Multiple console options
> might be appended to kernel command line. For example,
> "console=ttyS0,115200n8 console=ttyS4,115200n8
> console=ttyS5,115200n8".
>
> In this case, several uarts "cons" pointers are same.

Typically a UART driver will register the console structure in the
driver's initcall(), which is only called once per driver. This is why
it is usually not possible to have multiple UART consoles.

If a driver _does_ allow registering consoles for multiple devices, then
it must allocate separate console structs for each registration.

Note that register_console() will generate a warning and abort if a
driver attempts to register the same console struct twice:

WARN(con == newcon, "console '%s%d' already registered\n",
con->name, con->index)

So I ask again. Please explain how this is possible.

John