2022-06-03 15:47:52

by Paul Menzel

[permalink] [raw]
Subject: Non-working serial console

Dear Linux folks,


Since a while I noticed, output to the serial console with
`console=ttyS0,115200n8` does not work with the attached configuration
`defconfig-non-working-serial.txt` created by `make savedefconfig`.
Only, when with `earlyprintk=ttyS0,115200,keep` the serial console
starts working. I am able to reproduce it in QEMU. It’s reproducible
with Linus’ latest master branch.

$ git log --oneline --no-decorate -1
8ab2afa23bd19 Merge tag 'for-5.19/fbdev-1' of
git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
$ qemu-system-x86_64 --version
QEMU emulator version 5.1.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
$ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append
"console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses

With `earlyprintk=` it works:

$ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append
"earlyprintk=serial console=ttyS0,115200n8" -serial
file:/dev/shm/kernel.txt -curses

Strangely, I found a different configuration, where it works, but I
didn’t see what configuration option makes the difference.

Can you reproduce the problem with `defconfig-no-working-serial.txt`?


Kind regards,

Paul


Attachments:
defconfig-working-serial.txt (19.38 kB)
defconfig-non-working-serial.txt (25.59 kB)
Download all attachments

2022-06-03 16:56:16

by Paul Menzel

[permalink] [raw]
Subject: Re: Non-working serial console

Dear Linux folks,


Am 02.06.22 um 18:50 schrieb Paul Menzel:

> Since a while I noticed, output to the serial console with
> `console=ttyS0,115200n8` does not work with the attached configuration
> `defconfig-non-working-serial.txt` created by `make savedefconfig`.
> Only, when with `earlyprintk=ttyS0,115200,keep` the serial console
> starts working. I am able to reproduce it in QEMU. It’s reproducible
> with Linus’ latest master branch.
>
>     $ git log --oneline --no-decorate -1
>     8ab2afa23bd19 Merge tag 'for-5.19/fbdev-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
>     $ qemu-system-x86_64 --version
>     QEMU emulator version 5.1.0
>     Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
>     $ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses
>
> With `earlyprintk=` it works:
>
>     $ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "earlyprintk=serial console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses
>
> Strangely, I found a different configuration, where it works, but I
> didn’t see what configuration option makes the difference.
>
> Can you reproduce the problem with `defconfig-no-working-serial.txt`?

It turns out, the non-working configuration build the serial 8250 driver
as a module (`CONFIG_SERIAL_8250=m`) instead of building it into the
Linux kernel. Building it into the Linux kernel and using
`CONFIG_SERIAL_8250_CONSOLE=y` fixes my issue.

```
$ diff -u .config.old .config
--- .config.old 2022-05-31 18:40:31.329017225 +0200
+++ .config 2022-06-02 22:53:06.317175267 +0200
@@ -1814,6 +1814,7 @@

CONFIG_UEFI_CPER=y
CONFIG_UEFI_CPER_X86=y
+CONFIG_EFI_EARLYCON=y
CONFIG_EFI_CUSTOM_SSDT_OVERLAYS=y
# CONFIG_EFI_DISABLE_RUNTIME is not set
# CONFIG_EFI_COCO_SECRET is not set
@@ -2554,11 +2555,13 @@
#
# Serial drivers
#
-CONFIG_SERIAL_8250=m
+CONFIG_SERIAL_EARLYCON=y
+CONFIG_SERIAL_8250=y
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
CONFIG_SERIAL_8250_PNP=y
# CONFIG_SERIAL_8250_16550A_VARIANTS is not set
# CONFIG_SERIAL_8250_FINTEK is not set
+CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_8250_DMA=y
# CONFIG_SERIAL_8250_PCI is not set
CONFIG_SERIAL_8250_NR_UARTS=32
@@ -2575,7 +2578,8 @@
#
# CONFIG_SERIAL_KGDB_NMI is not set
# CONFIG_SERIAL_UARTLITE is not set
-CONFIG_SERIAL_CORE=m
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_CONSOLE_POLL=y
# CONFIG_SERIAL_JSM is not set
# CONFIG_SERIAL_LANTIQ is not set
@@ -2590,7 +2594,7 @@
# CONFIG_SERIAL_SPRD is not set
# end of Serial drivers

-CONFIG_SERIAL_MCTRL_GPIO=m
+CONFIG_SERIAL_MCTRL_GPIO=y
# CONFIG_SERIAL_NONSTANDARD is not set
# CONFIG_N_GSM is not set
# CONFIG_NOZOMI is not set
```

The question is, if `earlyprintk=ttyS0,115200(,keep)` worked before with
`CONFIG_SERIAL_8250=m`, why the driver is needed, and `console=ttyS0,…`
cannot fall back to the earlyprintk driver.


Kind regards,

Paul

2022-06-06 03:44:28

by Paul Menzel

[permalink] [raw]
Subject: Re: Non-working serial console

Dear Greg,


Am 04.06.22 um 11:04 schrieb Greg KH:
> On Thu, Jun 02, 2022 at 11:09:15PM +0200, Paul Menzel wrote:

>> Am 02.06.22 um 18:50 schrieb Paul Menzel:
>>
>>> Since a while I noticed, output to the serial console with
>>> `console=ttyS0,115200n8` does not work with the attached configuration
>>> `defconfig-non-working-serial.txt` created by `make savedefconfig`.
>>> Only, when with `earlyprintk=ttyS0,115200,keep` the serial console
>>> starts working. I am able to reproduce it in QEMU. It’s reproducible
>>> with Linus’ latest master branch.
>>>
>>>     $ git log --oneline --no-decorate -1
>>>     8ab2afa23bd19 Merge tag 'for-5.19/fbdev-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
>>>     $ qemu-system-x86_64 --version
>>>     QEMU emulator version 5.1.0
>>>     Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
>>>     $ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses
>>>
>>> With `earlyprintk=` it works:
>>>
>>>     $ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "earlyprintk=serial console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses
>>>
>>> Strangely, I found a different configuration, where it works, but I
>>> didn’t see what configuration option makes the difference.
>>>
>>> Can you reproduce the problem with `defconfig-no-working-serial.txt`?
>>
>> It turns out, the non-working configuration build the serial 8250 driver as
>> a module (`CONFIG_SERIAL_8250=m`) instead of building it into the Linux
>> kernel. Building it into the Linux kernel and using
>> `CONFIG_SERIAL_8250_CONSOLE=y` fixes my issue.
>
> That makes sense, you need the console to be able to properly send data
> out to it :)

Indeed.

I am still confused, that `earlyprintk=ttyS0,115200,keep` works though
despite `CONFIG_SERIAL_8250=m`. Doesn’t that mean, that Linux
nevertheless contains some code to initialize the serial console, and
send data to it?

> Was this a Kconfig change somewhere recently that we messed up the
> defaults for? Any chance you can use 'git bisect' to track down the
> offending change?

No, I guess I made the change several months back to make the Linux
kernel image smaller to decrease the boot time. (I have to do
measurements again.)


Kind regards,

Paul

2022-06-06 05:56:09

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: Non-working serial console

On Thu, Jun 02, 2022 at 11:09:15PM +0200, Paul Menzel wrote:
> Dear Linux folks,
>
>
> Am 02.06.22 um 18:50 schrieb Paul Menzel:
>
> > Since a while I noticed, output to the serial console with
> > `console=ttyS0,115200n8` does not work with the attached configuration
> > `defconfig-non-working-serial.txt` created by `make savedefconfig`.
> > Only, when with `earlyprintk=ttyS0,115200,keep` the serial console
> > starts working. I am able to reproduce it in QEMU. It’s reproducible
> > with Linus’ latest master branch.
> >
> >     $ git log --oneline --no-decorate -1
> >     8ab2afa23bd19 Merge tag 'for-5.19/fbdev-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
> >     $ qemu-system-x86_64 --version
> >     QEMU emulator version 5.1.0
> >     Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
> >     $ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses
> >
> > With `earlyprintk=` it works:
> >
> >     $ qemu-system-x86_64 -kernel arch/x86/boot/bzImage -append "earlyprintk=serial console=ttyS0,115200n8" -serial file:/dev/shm/kernel.txt -curses
> >
> > Strangely, I found a different configuration, where it works, but I
> > didn’t see what configuration option makes the difference.
> >
> > Can you reproduce the problem with `defconfig-no-working-serial.txt`?
>
> It turns out, the non-working configuration build the serial 8250 driver as
> a module (`CONFIG_SERIAL_8250=m`) instead of building it into the Linux
> kernel. Building it into the Linux kernel and using
> `CONFIG_SERIAL_8250_CONSOLE=y` fixes my issue.

That makes sense, you need the console to be able to properly send data
out to it :)

Was this a Kconfig change somewhere recently that we messed up the
defaults for? Any chance you can use 'git bisect' to track down the
offending change?

thanks,

greg k-h

2022-06-06 14:44:55

by Andy Shevchenko

[permalink] [raw]
Subject: Re: Non-working serial console

On Mon, Jun 6, 2022 at 5:44 AM Paul Menzel <[email protected]> wrote:
> Am 04.06.22 um 11:04 schrieb Greg KH:

...

> I am still confused, that `earlyprintk=ttyS0,115200,keep` works though
> despite `CONFIG_SERIAL_8250=m`. Doesn’t that mean, that Linux
> nevertheless contains some code to initialize the serial console, and
> send data to it?

If you keep x86 in mind, then yes, three different console code
handling (decompressing stage, boot stage, driver stage) + earlyprintk
(on top of the same code for decompressing / booting stages) +
earlycon (this is actually a driver:ish stage).

--
With Best Regards,
Andy Shevchenko