Re: [PATCH next v1 1/2] serial: 8250: Switch to nbcon console

From: John Ogness
Date: Thu Sep 05 2024 - 15:23:20 EST


On 2024-09-05, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> On Thu, Sep 05, 2024 at 03:53:18PM +0206, John Ogness wrote:
>> Implement the necessary callbacks to switch the 8250 console driver
>> to perform as an nbcon console.
>>
>> Add implementations for the nbcon console callbacks (write_atomic,
>> write_thread, device_lock, device_unlock) and add CON_NBCON to the
>> initial flags.
>>
>> The legacy code is kept in order to easily switch back to legacy mode
>> by defining USE_SERIAL_8250_LEGACY_CONSOLE.
>
> ...
>
>> static struct console univ8250_console = {
>> .name = "ttyS",
>> +#ifdef USE_SERIAL_8250_LEGACY_CONSOLE
>
> Can it be done at run-time (theoretically or even practically)?
> (Note that we have already knob to disable / enable consoles.)

We don't want to maintain the legacy variant and really people should
not be using it either. NBCON is the way forward for all console
drivers.

I will just remove it for v2. If someone wants to use the old code, they
will need to revert the patch.


>> + if (nbcon_exit_unsafe(wctxt)) {
>> + int len = READ_ONCE(wctxt->len);
>
>> + int i;
>
> unsigned ?

ACK.

>> + /* Atomic console not supported for rs485 mode. */
>
> RS485

ACK.

> Feels like parts (1) and (2) duplicates existing pieces of code. May it be
> refactored to minimize the duplication?

When I remove the unused legacy code, the duplication
disappears. write_thread() and write_atomic() have very little in
common.

John Ogness