Re: [PATCH printk v5 1/1] printk: extend console_lock for per-console locking

From: John Ogness
Date: Wed Jun 22 2022 - 18:37:27 EST


On 2022-06-22, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> I have bisected another intriguing issue to this commit: on SiPEED
> MAiX BiT (Canaan K210 riscv), it no longer prints the line detecting
> ttySIF0, i.e. the console output changes like:
>
> spi-nor spi1.0: gd25lq128d (16384 Kbytes)
> i2c_dev: i2c /dev entries driver
> k210-fpioa 502b0000.pinmux: K210 FPIOA pin controller
> -38000000.serial: ttySIF0 at MMIO 0x38000000 (irq = 1, base_baud =
> 115200) is a SiFive UART v0
> printk: console [ttySIF0] enabled
> printk: bootconsole [sifive0] disabled
> printk: console [ttySIF0] printing thread started
>
> As this patch does not make any changes to drivers/tty/, and ttySIF0
> does work (it's the console), I looked in /proc/kmsg, and bingo,
> the missing line is there, so it is generated, but never printed.

What is sifive0? Are you using the earlycon driver to create an early
boot console? Can I see your boot args?

There is a known issue the that earlycon does not synchronize with
normal consoles. A patch was recently posted [0] on LKML.

> I tried taking the port spinlock in sifive_serial_startup(), as
> suggested for the meson driver, but that doesn't make a difference.

It may not have made a difference for you, but it should be there.
sifive_serial_startup() is writing to SIFIVE_SERIAL_IE_OFFS without
taking port->lock. sifive_serial_console_write() also writes to this
register (under port->lock). This could lead to RX watermark interrupts
being disabled for some time. The problem is not as bad as it was with
the meson driver because __ssp_enable_rxwm() is updating the shadow
copy. But still, it is a bug. And anyway we shouldn't have 2 CPUs
writing to a register simultaneously.

John Ogness

[0] https://lore.kernel.org/lkml/20220621090900.GB7891@xxxxxxxxxxxxxxx