For s32g platform, it uses linflexuart driver for console, but if in preempt-rt mode, there will be following calltrace when debug configs enabled:
BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:969 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1, name: swapper/0 Preemption disabled at: [<ffffffc0100a4c84>] __prb_trylock.constprop.0+0x24/0x144 CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.10.63-rt47-yocto-preempt-rt #1 Hardware name: Freescale S32G274 (DT) Call trace: dump_backtrace+0x0/0x1a0 show_stack+0x24/0x30 dump_stack+0xcc/0x108 ___might_sleep+0x144/0x180 rt_spin_lock+0x34/0x9c linflex_console_write+0x60/0x130 print_sync+0x114/0x16c print_sync_until+0x88/0x130 vprintk_store+0x434/0x59c vprintk_emit+0x4c/0xa0 printk+0x8c/0xb0 register_console+0x1fc/0x330 uart_add_one_port+0x4ec/0x514 linflex_probe+0x1d8/0x370 platform_drv_probe+0x60/0xb4 really_probe+0xf0/0x4a0 driver_probe_device+0x64/0xcc device_driver_attach+0xcc/0xd4 __driver_attach+0x90/0x13c bus_for_each_dev+0x7c/0xd0 driver_attach+0x30/0x40 bus_add_driver+0x114/0x210 driver_register+0x84/0x140 __platform_driver_register+0x54/0x60 linflex_serial_init+0x54/0x7c do_one_initcall+0x6c/0x300 kernel_init_freeable+0x238/0x2a4 kernel_init+0x20/0x120 ret_from_fork+0x10/0x38 This is due to the driver implements the write_atomic() callback, that is indeed the function linflex_console_write(), which will call spin_lock(). As the write_atomic() callback will be called in print_sync() in atomic context, then the calltrace shows. Further more, the write_atomic() callback is optional, so delete it in linflexuart driver to fix the above issue. Signed-off-by: Zhantao Tang <[email protected]> --- drivers/tty/serial/fsl_linflexuart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c index d742320d781c..9ad8270316ed 100644 --- a/drivers/tty/serial/fsl_linflexuart.c +++ b/drivers/tty/serial/fsl_linflexuart.c @@ -1423,7 +1423,6 @@ static struct uart_driver linflex_reg; static struct console linflex_console = { .name = DEV_NAME, .write = linflex_console_write, - .write_atomic = linflex_console_write, .device = uart_console_device, .setup = linflex_console_setup, .flags = CON_PRINTBUFFER, -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#12323): https://lists.yoctoproject.org/g/linux-yocto/message/12323 Mute This Topic: https://lists.yoctoproject.org/mt/97898136/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
