cancel
Showing results for 
Search instead for 
Did you mean: 

Linux RT patch on STM32MP157F

axel101
Associate III

Hi, Community

I'm building linux based firmware on STM32MP157F ad I need to apply linux RT patches.

I'm using STM32MP157F-EV1 for testing

As linuxkernel I'm using ST linux v5.10-stm32mp-r2, of STMicroelectronics linux repo. This tag is v5.10.61 kernel version, so I took patch-5.10.59-rt52.patch.gz, since it is nearest kernel version.

The patch was applied without errors, but at startup there is a following exception in pinctrl-stm32 driver:

[    2.905809] ------------[ cut here ]------------
[    2.905823] WARNING: CPU: 0 PID: 1 at kernel/locking/rtmutex.c:2040 __rt_mutex_trylock+0x110/0x114
[    2.905860] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W         5.10.61-rt52agvl-stm32mp157f-ev1 #2
[    2.905873] Hardware name: STM32 (Device Tree Support)
[    2.905890] [<c010f7c8>] (unwind_backtrace) from [<c010c3c0>] (show_stack+0x10/0x14)
[    2.905919] [<c010c3c0>] (show_stack) from [<c0db0a58>] (dump_stack+0xb4/0xc8)
[    2.905940] [<c0db0a58>] (dump_stack) from [<c012f8f8>] (__warn+0xe8/0x100)
[    2.905962] [<c012f8f8>] (__warn) from [<c0d98d2c>] (warn_slowpath_fmt+0x7c/0xa8)
[    2.905985] [<c0d98d2c>] (warn_slowpath_fmt) from [<c0db53a4>](__rt_mutex_trylock+0x110/0x114)
[    2.906008] [<c0db53a4>] (__rt_mutex_trylock) from [<c0db7070>] (rt_spin_trylock+0x8/0x28)
[    2.906032] [<c0db7070>] (rt_spin_trylock) from [<c05e7404>] (clk_enable_lock+0x10/0x108)
[    2.906060] [<c05e7404>] (clk_enable_lock) from [<c05ecd7c>] (clk_enable+0x18/0x30)
[    2.906083] [<c05ecd7c>] (clk_enable) from [<c05c4958>] (stm32_gpio_irq_trigger+0x28/0x78)
[    2.906107] [<c05c4958>] (stm32_gpio_irq_trigger) from [<c01958b8>] (handle_fasteoi_irq+0x160/0x25c)
[    2.906134] [<c01958b8>] (handle_fasteoi_irq) from [<c018fdd8>] (__handle_domain_irq+0xa0/0x10c)
[    2.906156] [<c018fdd8>] (__handle_domain_irq) from [<c05b1930>] (gic_handle_irq+0x80/0x94)
[    2.906182] [<c05b1930>] (gic_handle_irq) from [<c0100b0c>] (__irq_svc+0x6c/0xbc)
[    2.906203] Exception stack(0xc18b7cd8 to 0xc18b7d20)
[    2.906214] 7cc0:                                                       c2821680 a0000013
[    2.906227] 7ce0: c18c0000 00000001 c146b714 c18c0510 c18b7d48 c18c0000 c18b6000 c2821681
[    2.906239] 7d00: c18b7d48 c30195f4 c2821681 c18b7d28 c0db4d58 c0db4d90 20000013 ffffffff                                                                                  
[    2.906248] [<c0100b0c>] (__irq_svc) from [<c0db4d90>] (rt_spin_lock_slowlock_locked+0x1c0/0x2f8)
[    2.906271] [<c0db4d90>] (rt_spin_lock_slowlock_locked) from [<c0db4f1c>] (rt_spin_lock_slowlock+0x54/0x84)
[    2.906294] [<c0db4f1c>] (rt_spin_lock_slowlock) from [<c0db700c>] (rt_spin_lock+0x50/0x5c)
[    2.906317] [<c0db700c>] (rt_spin_lock) from [<c0653298>] (uart_change_speed+0x38/0xdc)
[    2.906341] [<c0653298>] (uart_change_speed) from [<c0654bf4>] (uart_port_startup+0x19c/0x234)
[    2.906362] [<c0654bf4>] (uart_port_startup) from [<c0655250>] (uart_port_activate+0x58/0x90)
[    2.906383] [<c0655250>] (uart_port_activate) from [<c063f680>] (tty_port_open+0x7c/0xbc)
[    2.906407] [<c063f680>] (tty_port_open) from [<c0652b84>] (uart_open+0x14/0x1c)
[    2.906428] [<c0652b84>] (uart_open) from [<c0637a7c>] (tty_open+0x120/0x2f0)
[    2.906448] [<c0637a7c>] (tty_open) from [<c030e138>] (chrdev_open+0x80/0x190)
[    2.906472] [<c030e138>] (chrdev_open) from [<c03047d8>] (do_dentry_open+0xe4/0x3b8)
[    2.906497] [<c03047d8>] (do_dentry_open) from [<c0318b2c>] (do_open+0x1c4/0x294)
[    2.906520] [<c0318b2c>] (do_open) from [<c0319e4c>] (path_openat+0x10c/0x1c4)
[    2.906540] [<c0319e4c>] (path_openat) from [<c0319f78>] (do_filp_open+0x74/0x120)
[    2.906561] [<c0319f78>] (do_filp_open) from [<c03065b8>] (filp_open+0x12c/0x1c4)
[    2.906584] [<c03065b8>] (filp_open) from [<c1201400>] (console_on_rootfs+0x18/0x54)
[    2.906607] [<c1201400>] (console_on_rootfs) from [<c12015ac>] (kernel_init_freeable+0x170/0x194)
[    2.906626] [<c12015ac>] (kernel_init_freeable) from [<c0db159c>] (kernel_init+0x8/0x118)
[    2.906646] [<c0db159c>] (kernel_init) from [<c0100150>] (ret_from_fork+0x14/0x24)
[    2.906664] Exception stack(0xc18b7fb0 to 0xc18b7ff8)
[    2.906675] 7fa0:                                     00000000 00000000 00000000 00000000
[    2.906687] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.906697] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    2.906704] ---[ end trace 0000000000000003 ]---

I found look similar issue, and there all spin_lock/spin_unlock were replaced with raw_spin_lock/raw_spin_unlock since in RT kernel spinlock/spin_unlock may sleep. But this is not my case (I tried to replace all spin_lock/pin_unlock with raw_* and it's doesn't help) because exception is generated in clk_enable function, which uses spin_lock inside. How should I rework stm32 pinctrl driver?

1 ACCEPTED SOLUTION

Accepted Solutions
axel101
Associate III

I solved this issue by implementing raw_* variant of clk_enable and lk_disable which are using raw spinlocks. Also I reworked i2c-stm32f7.c file and use my raw_clk_enable and raw_clk_disable functions

View solution in original post

1 REPLY 1
axel101
Associate III

I solved this issue by implementing raw_* variant of clk_enable and lk_disable which are using raw spinlocks. Also I reworked i2c-stm32f7.c file and use my raw_clk_enable and raw_clk_disable functions