K3: wait for TIFS init before CTRL_MMR unlock
Subsystems (2)
v2 cover K3: wait for TIFS init before CTRL_MMR unlock
Hi,
this series uses a TIFS barrier before doing the ctrl_mmr_unlock(). This specific implementation works for the platforms where TIFS is already running at this point. Note that other K3 platforms may have the same problem, but for these this implementation is not straight forward.
This series is only tested on am625 HS-SE. I don't have any other HS-SE boards.
Best,
Markus
---
Changes in v2:
- Create a common helper k3_sysfw_wait_ready() to make the purpose of
the get_ti_sci_handle() clear.
- Extend the series to the other SoCs with the same boot process: am62a7,
am62p5 and j722s.
- Link to v1: https://patch.msgid.link/20260923-v2026-10-next-topic-am62-hs-se-fix-unlock-race-v1-1-300ddb9f5be8@baylibre.com
---
Markus Schneider-Pargmann (5):
arm: mach-k3: common: add helper to wait for TIFS initialization
arm: mach-k3: am625: Wait for TIFS initialization
arm: mach-k3: am62a7: Wait for TIFS initialization
arm: mach-k3: am62p5: Wait for TIFS initialization
arm: mach-k3: j722s: Wait for TIFS initialization
arch/arm/mach-k3/am62ax/am62a7_init.c | 5 +++-- arch/arm/mach-k3/am62px/am62p5_init.c | 5 +++-- arch/arm/mach-k3/am62x/am625_init.c | 5 +++-- arch/arm/mach-k3/common.c | 10 ++++++++++ arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/j722s/j722s_init.c | 5 +++-- 6 files changed, 23 insertions(+), 8 deletions(-)
---
base-commit: 75df64103873fac09642860cedadaffb8cf6b2c7
change-id: 20260923-v2026-10-next-topic-am62-hs-se-fix-unlock-race-15fda445257e
Best regards,
Signature · 1 line
Markus Schneider-Pargmann <[email protected]>
PATCH v2 1/5 arm: mach-k3: common: add helper to wait for TIFS initialization
Add a helper to wait for TIFS initialization to be finished. Effectively this is just a call to get_ti_sci_handle() but I think a separate function makes the purpose of this call better visible.
get_ti_sci_handle() internally leads to fetching the TIFS version with a message and response. TIFS only responds once initialization finished. If a response is not received get_ti_sci_handle() returns after a timeout.
--- arch/arm/mach-k3/common.c | 10 ++++++++++ arch/arm/mach-k3/common.h | 1 + 2 files changed, 11 insertions(+)
arch/arm/mach-k3/common.c +10 -0
@@ -54,6 +54,16 @@ struct ti_sci_handle *get_ti_sci_handle(void)return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw (dev); } +void k3_sysfw_wait_ready (void ) +{ +/* +* Wait for TIFS initialization to finish. This helper is used to make +* sure TIFS removed the firewall before U-Boot tries to unlock CTRL_MMR +* registers and continues the boot. +*/ +get_ti_sci_handle (); +} +void k3_sysfw_print_ver (void ) {struct ti_sci_handle *ti_sci =get_ti_sci_handle ();
arch/arm/mach-k3/common.h +1 -0
@@ -38,6 +38,7 @@ void disable_linefill_optimization(void);int remove_fwl_region (struct fwl_data *fwl);void remove_fwl_configs (struct fwl_data *fwl_data,size_t fwl_data_size);int load_firmware (char *name_fw,char *name_loadaddr,u32 *loadaddr); +void k3_sysfw_wait_ready (void );void k3_sysfw_print_ver (void );void k3_dm_print_ver (void );void spl_enable_cache (void );
Signature · 1 line
2.55.0
Re: [PATCH v2 1/5] arm: mach-k3: common: add helper to wait for TIFS initialization
Quoted 20 lines · Markus Schneider-Pargmann
Add a helper to wait for TIFS initialization to be finished. Effectively this is just a call to
get_ti_sci_handle()but I think a separate function makes the purpose of this call better visible.
get_ti_sci_handle()internally leads to fetching the TIFS version with a message and response. TIFS only responds once initialization finished. If a response is not receivedget_ti_sci_handle()returns after a timeout.Signed-off-by Markus Schneider-Pargmann <[email protected]>--- arch/arm/mach-k3/common.c | 10 ++++++++++ arch/arm/mach-k3/common.h | 1 + 2 files changed, 11 insertions(+)arch/arm/mach-k3/common.c +0
-0
arch/arm/mach-k3/common.c struct ti_sci_handle *get_ti_sci_handle(void) · line 57
Quoted 4 lines
arch/arm/mach-k3/common.c +1
-0@@ -54,6 +54,16 @@ struct ti_sci_handle *get_ti_sci_handle(void)return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw (dev); } +void k3_sysfw_wait_ready (void )
Please put some warning on use of this function. On few SOCs like J721E, u-boot loads the TIFS firmware. In such case, no point of calling this function.
With added comments, please use
Quoted 25 lines
arch/arm/mach-k3/common.c +9
-0+{ +/* +* Wait for TIFS initialization to finish. This helper is used to make +* sure TIFS removed the firewall before U-Boot tries to unlock CTRL_MMR +* registers and continues the boot. +*/ +get_ti_sci_handle (); +} +void k3_sysfw_print_ver (void ) {struct ti_sci_handle *ti_sci =get_ti_sci_handle ();arch/arm/mach-k3/common.h +1
-0@@ -38,6 +38,7 @@ void disable_linefill_optimization(void);int remove_fwl_region (struct fwl_data *fwl);void remove_fwl_configs (struct fwl_data *fwl_data,size_t fwl_data_size);int load_firmware (char *name_fw,char *name_loadaddr,u32 *loadaddr); +void k3_sysfw_wait_ready (void );void k3_sysfw_print_ver (void );void k3_dm_print_ver (void );void spl_enable_cache (void );
PATCH v2 2/5 arm: mach-k3: am625: Wait for TIFS initialization
In reply to Markus Schneider-PargmannOn HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot ctrl_mmr_unlock() can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.
Wait for TIFS to be initialized using k3_sysfw_wait_ready() before doing ctrl_mmr_unlock(). Note that spl_early_init() needs to be done first to setup DM.
--- arch/arm/mach-k3/am62x/am625_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-k3/am62x/am625_init.c +3 -2
@@ -158,11 +158,12 @@ void board_init_f(ulong dummy)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); -/* Init DM early */ spl_early_init (); +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); +/* * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and * MAIN_UART1 modules and continue regardless of the result of pinctrl.
Signature · 1 line
2.55.0
PATCH v2 3/5 arm: mach-k3: am62a7: Wait for TIFS initialization
In reply to Markus Schneider-PargmannOn HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot ctrl_mmr_unlock() can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.
Wait for TIFS to be initialized using k3_sysfw_wait_ready() before doing ctrl_mmr_unlock(). Note that spl_early_init() needs to be done first to setup DM.
--- arch/arm/mach-k3/am62ax/am62a7_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-k3/am62ax/am62a7_init.c +3 -2
@@ -134,11 +134,12 @@ void board_init_f(ulong dummy)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); -/* Init DM early */ spl_early_init (); +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); +/* * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and * MAIN_UART1 modules and continue regardless of the result of pinctrl.
Signature · 1 line
2.55.0
PATCH v2 4/5 arm: mach-k3: am62p5: Wait for TIFS initialization
In reply to Markus Schneider-PargmannOn HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot ctrl_mmr_unlock() can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.
Wait for TIFS to be initialized using k3_sysfw_wait_ready() before doing ctrl_mmr_unlock(). Note that spl_early_init() needs to be done first to setup DM.
--- arch/arm/mach-k3/am62px/am62p5_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-k3/am62px/am62p5_init.c +3 -2
@@ -116,13 +116,14 @@ void board_init_f(ulong dummy)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); -/* Init DM early */ ret =spl_early_init ();if (ret)panic ("spl_early_init() failed: %d\n" , ret); +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); +/* * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and * MAIN_UART1 modules and continue regardless of the result of pinctrl.
Signature · 1 line
2.55.0
PATCH v2 5/5 arm: mach-k3: j722s: Wait for TIFS initialization
In reply to Markus Schneider-PargmannOn HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot ctrl_mmr_unlock() can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.
Wait for TIFS to be initialized using k3_sysfw_wait_ready() before doing ctrl_mmr_unlock(). Note that spl_early_init() needs to be done first to setup DM.
--- arch/arm/mach-k3/j722s/j722s_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-k3/j722s/j722s_init.c +3 -2
@@ -84,13 +84,14 @@ static void k3_spl_init(void)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); -/* Init DM early */ ret =spl_early_init ();if (ret)panic ("spl_early_init() failed: %d\n" , ret); +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); +/* * Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue * regardless of the result of pinctrl. Do this without probing the
Signature · 1 line
2.55.0
Re: [PATCH v2 5/5] arm: mach-k3: j722s: Wait for TIFS initialization
Quoted 7 lines · Markus Schneider-Pargmann
On HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot
ctrl_mmr_unlock()can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.
Quoted 8 lines
Wait for TIFS to be initialized using
k3_sysfw_wait_ready()before doingctrl_mmr_unlock(). Note thatspl_early_init()needs to be done first to setup DM.Signed-off-by Markus Schneider-Pargmann <[email protected]>---
I have tested on J722S hs-fs and hs-se devices, Post this patch wdt reset got functional on hs-se device.
So for this patch
Quoted 25 lines
arch/arm/mach-k3/j722s/j722s_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/arm/mach-k3/j722s/j722s_init.c +3
-2@@ -84,13 +84,14 @@ static void k3_spl_init(void)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); -/* Init DM early */ ret =spl_early_init ();if (ret)panic ("spl_early_init() failed: %d\n" , ret); +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); +/* * Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue * regardless of the result of pinctrl. Do this without probing the
Re: [PATCH v2 5/5] arm: mach-k3: j722s: Wait for TIFS initialization
Le 17/10/2026 à 04:40, Kumar, Udit a écrit :
Quoted 19 lines · Markus Schneider-Pargmann
Quoted 7 lines
On HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot
ctrl_mmr_unlock()can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.Quoted 8 lines
Wait for TIFS to be initialized using
k3_sysfw_wait_ready()before doingctrl_mmr_unlock(). Note thatspl_early_init()needs to be done first to setup DM.Signed-off-by Markus Schneider-Pargmann <[email protected]>---
Quoted 7 lines
I have tested on J722S hs-fs and hs-se devices, Post this patch wdt reset got functional on hs-se device.
So for this patch
Tested-by Udit Kumar <[email protected]>
I tested it on my LPM series with j722s HS-FS, and I still need a ctrl_mmr_unlock() before spl_early_init() and also another after k3_sysfw_print_ver() otherwise querying pmic fails.
Regards,
Richard
Quoted 26 lines
Quoted 25 lines
arch/arm/mach-k3/j722s/j722s_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/arm/mach-k3/j722s/j722s_init.c +3
-2@@ -84,13 +84,14 @@ static void k3_spl_init(void)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); -/* Init DM early */ ret =spl_early_init ();if (ret)panic ("spl_early_init() failed: %d\n" , ret); +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); +/* * Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue * regardless of the result of pinctrl. Do this without probing the
Signature · 3 lines
Richard Genoud, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v2 5/5] arm: mach-k3: j722s: Wait for TIFS initialization
Quoted 25 lines · Richard GENOUD
Le 17/10/2026 à 04:40, Kumar, Udit a écrit :
Quoted 24 lines · Markus Schneider-Pargmann
Quoted 11 lines
On HS-SE platforms TIFS takes longer to initialize. TIFS only removes the firewall on the registers at the end of initialization. On HS-SE the U-Boot
ctrl_mmr_unlock()can happen before TIFS removed the firewall leading to a race condition. This leads to a broken watchdog since the signal configuration doesn't succeed because the write doesn't take effect.Wait for TIFS to be initialized using
k3_sysfw_wait_ready()before doingctrl_mmr_unlock(). Note thatspl_early_init()needs to be done first to setup DM.Quoted 6 lines
Signed-off-by Markus Schneider-Pargmann <[email protected]>---
I have tested on J722S hs-fs and hs-se devices, Post this patch wdt reset got functional on hs-se device.
Quoted 8 lines
Quoted 4 lines
So for this patch
Tested-by Udit Kumar <[email protected]>I tested it on my LPM series with j722s HS-FS, and I still need a
ctrl_mmr_unlock()beforespl_early_init()and also another afterk3_sysfw_print_ver()otherwise querying pmic fails.
Thanks Richard for testing LPM flow.
I realized now, you need PMIC which is probed in spl_early_init(), so MMR has to be unlocked before this call.
However below patch fixes wdt flow in HS_SE devices.
Quoted 32 lines
Regards,
RichardQuoted 27 lines
Quoted 26 lines
arch/arm/mach-k3/j722s/j722s_init.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)arch/arm/mach-k3/ renamed from arch/arm/mach-k3/j722s/j722s_init.c +0
-0
j722s/j722s_init.c
index1180c75f551d..c15b3b2682d9100644arch/arm/mach-k3/j722s/j722s_init.c +2
-1@@ -84,13 +84,14 @@ static void k3_spl_init(void)*/ store_boot_info_from_rom(); - ctrl_mmr_unlock(); - /* Init DM early */ ret = spl_early_init(); if (ret) panic("spl_early_init() failed: %d\n", ret); + k3_sysfw_wait_ready(); + ctrl_mmr_unlock(); + /** Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue
* regardless of the result of pinctrl. Do this without probing the
PATCH 1/3 arm: mach-k3: common: add helper to wait for TIFS initialization
Add a helper to wait for TIFS initialization to be finished. Effectively this is just a call to get_ti_sci_handle() but I think a separate function makes the purpose of this call better visible.
get_ti_sci_handle() internally leads to fetching the TIFS version with a message and response. TIFS only responds once initialization finished. If a response is not received get_ti_sci_handle() returns after a timeout.
--- arch/arm/mach-k3/common.c | 10 ++++++++++ arch/arm/mach-k3/common.h | 1 + 2 files changed, 11 insertions(+)
arch/arm/mach-k3/common.c +10 -0
@@ -54,6 +54,16 @@ struct ti_sci_handle *get_ti_sci_handle(void)return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw (dev); } +void k3_sysfw_wait_ready (void ) +{ +/* +* Wait for TIFS initialization to finish. This helper is used to make +* sure TIFS removed the firewall before U-Boot tries to unlock CTRL_MMR +* registers and continues the boot. +*/ +get_ti_sci_handle (); +} +void k3_sysfw_print_ver (void ) {struct ti_sci_handle *ti_sci =get_ti_sci_handle ();
arch/arm/mach-k3/common.h +1 -0
@@ -38,6 +38,7 @@ void disable_linefill_optimization(void);int remove_fwl_region (struct fwl_data *fwl);void remove_fwl_configs (struct fwl_data *fwl_data,size_t fwl_data_size);int load_firmware (char *name_fw,char *name_loadaddr,u32 *loadaddr); +void k3_sysfw_wait_ready (void );void k3_sysfw_print_ver (void );void k3_dm_print_ver (void );void spl_enable_cache (void );
Signature · 1 line
2.56.0
PATCH 2/3 dm: core: Add SPL_DM_EVENT
Add an option to allow DM_EVENT in SPL.
--- drivers/core/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/core/Kconfig +10 -0
@@ -117,6 +117,16 @@ config DM_EVENT register a 'spy' function that is called when the event occurs. Such subsystems must select this option. +config SPL_DM_EVENT + bool + depends on SPL_DM + select SPL_EVENT + help + This enables support for generating events related to driver model + operations in SPL, such as probing or removing a device. Subsystems + can register a 'spy' function that is called when the event occurs. + Such subsystems must select this option. + config SPL_DM_DEVICE_REMOVE bool "Support device removal in SPL" depends on SPL_DM
Signature · 1 line
2.56.0
Re: [PATCH 2/3] dm: core: Add SPL_DM_EVENT
Hi Markus,
Quoted 3 lines · Markus Schneider-Pargmann
dm: core: Add
SPL_DM_EVENTAdd an option to allow
DM_EVENTin SPL.
Please can you give the reason here: K3 needs to run code from EVT_DM_POST_INIT_F in SPL, before anything is probed. It would also be worth noting that this makes device_notify() send probe/remove events for every device in SPL, not just the post-init event.
drivers/core/Kconfig config DM_EVENT · line 120
Quoted 6 lines
drivers/core/Kconfig +4
-0@@ -117,6 +117,16 @@ config DM_EVENT +config SPL_DM_EVENT + bool + depends on SPL_DM + select SPL_EVENT
SPL_EVENT is inside the 'if EVENT' block in common/Kconfig, so a board selecting SPL_DM_EVENT without EVENT gets an unmet-dependency warning and SPL_EVENT is forced on anyway. This is fine for j722s, which already enables EVENT, but please can you add 'depends on SPL_DM && EVENT' so it works for other boards too?
Regards,
Simon
PATCH 3/3 WIP: arm: mach-k3: j722s: Wait for TIFS initialization
In reply to Markus Schneider-Pargmann--- arch/arm/mach-k3/Kconfig | 1 + arch/arm/mach-k3/j722s/j722s_init.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
arch/arm/mach-k3/Kconfig +1 -0
@@ -30,6 +30,7 @@ config SOC_K3_J721S2 config SOC_K3_J722S bool "TI's K3 based J722S SoC Family Support" + select SPL_DM_EVENT if SPL config SOC_K3_J784S4 bool "TI's K3 based J784S4 SoC Family Support"
arch/arm/mach-k3/j722s/j722s_init.c +17 -3
@@ -11,6 +11,7 @@#include <dm.h> #include <dm/uclass-internal.h> #include <dm/pinctrl.h> +#include <event.h> #include "../sysfw-loader.h" #include "../common.h"
@@ -70,6 +71,18 @@ static void ctrl_mmr_unlock(void)mmr_unlock (PADCFG_MMR1_BASE ,1 ); } +/* +* Called by spl_early_init() before anything is probed. +*/ +static int k3_spl_dm_post_init_f (void ) +{ +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); + +return 0 ; +} +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , k3_spl_dm_post_init_f); +static void k3_spl_init (void ) {struct udevice *dev;
@@ -84,9 +97,10 @@ static void k3_spl_init(void)*/ store_boot_info_from_rom (); -ctrl_mmr_unlock (); - -/* Init DM early */ +/* +* Init DM early. Note that this calls k3_spl_dm_post_init_f before +* probing to do ctrl_mmr_unlock. +*/ ret =spl_early_init ();if (ret)panic ("spl_early_init() failed: %d\n" , ret);
Signature · 1 line
2.56.0
Re: [PATCH 3/3] WIP: arm: mach-k3: j722s: Wait for TIFS initialization
Hi,
On Thu Oct 22, 2026 at 12:15 PM CEST, Markus Schneider-Pargmann wrote:
...
arch/arm/mach-k3/j722s/j722s_init.c static void ctrl_mmr_unlock(void) · line 84
Quoted 11 lines
arch/arm/mach-k3/j722s/j722s_init.c +11
-0+/* +* Called by spl_early_init() before anything is probed. +*/ +static int k3_spl_dm_post_init_f (void ) +{ +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); + +return 0 ; +} +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , k3_spl_dm_post_init_f);
I am wondering if this would work for your situation where the PMIC is probed immediately?
Best
Markus
Re: [PATCH 3/3] WIP: arm: mach-k3: j722s: Wait for TIFS initialization
Hi Markus,
Le 22/10/2026 à 12:18, Markus Schneider-Pargmann a écrit :
Quoted 4 lines
Hi,
On Thu Oct 22, 2026 at 12:15 PM CEST, Markus Schneider-Pargmann wrote:
...
Quoted 14 lines
arch/arm/mach-k3/j722s/j722s_init.c static void ctrl_mmr_unlock(void) · line 84
Quoted 11 lines
arch/arm/mach-k3/j722s/j722s_init.c +11
-0+/* +* Called by spl_early_init() before anything is probed. +*/ +static int k3_spl_dm_post_init_f (void ) +{ +k3_sysfw_wait_ready (); +ctrl_mmr_unlock (); + +return 0 ; +} +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , k3_spl_dm_post_init_f);I am wondering if this would work for your situation where the PMIC is probed immediately?
I've just tried those patches, and indeed, it works for j722s HS-FS.
I have to drop the ctrl_mmr_unlock() that was done after k3_sysfw_print_ver(); in my series, and everything is working nicely. That's great!
Quoted 3 lines
Best
Markus
Regards,
Richars