Skip to contentSkip to conversation

mach-k3: j722s: unlock mmr after spl_early_init

PATCH In review Udit Kumar 4 participants 5 messages Feb 23 – Feb 27

Subsystems (2)
lore
Share & tools
lore

Udit Kumar

author
#0 lore raw

PATCH 1/1 mach-k3: j722s: unlock mmr after spl_early_init

unlocking control mmr before spl_early_init leads to unpredicable behaviour.
So unlock it after spl_early_init.

Fixes 5e291ee34fd4 ("arch: mach-k3: Introduce basic files to support J722S SoC family")

---
On HS-SE of J722S in particular, enable_mcu_esm_reset function is not able to reset bit-17 of ctrl mmr CTRLMMR_MCU_RST_CTRL. Which leads to wdt is not functional. With this change
bit-17 was getting reset properly on HS-SE and HS-FS devices.

HS-FS
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-fs

HS-SE
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-se

 arch/arm/mach-k3/j722s/j722s_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-k3/j722s/j722s_init.c +2 -2
index 1180c75f551..a0dab5d7032 100644
@@ -84,13 +84,13 @@ 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);
 
+	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.34.1
#1 lore raw
Quoted 1 line · Udit Kumar

unlocking control mmr before spl_early_init leads to

Nit: capitalize the first letter

Quoted 1 line

unpredicable behaviour.

and run through codespell.

Commit msg is vague. What unpredictable behavior? How do we know moving the ctrl_mmr_unlock() to after spl_early_init() really resolves this unpredictable behavior?

Quoted 2 lines

So unlock it after spl_early_init.

Wrap commit msg at 80 char uniformly please.

Quoted 9 lines
Fixes 5e291ee34fd4 ("arch: mach-k3: Introduce basic files to support J722S SoC family")

---

On HS-SE of J722S in particular, enable_mcu_esm_reset function is not able to reset bit-17 of ctrl mmr CTRLMMR_MCU_RST_CTRL. Which leads to wdt is not functional. With this change
bit-17 was getting reset properly on HS-SE and HS-FS devices.

This too needs to go into commit msg if not in $subject as this is what user actually sees as the issue.

Quoted 29 lines

HS-FS
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-fs

HS-SE
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-se

 arch/arm/mach-k3/j722s/j722s_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-k3/j722s/j722s_init.c +2 -2
index 1180c75f551..a0dab5d7032 100644
@@ -84,13 +84,13 @@ 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);
 
+	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
Regards
Vignesh
https://ti.com/opensource
#2 lore raw

On February 24, 2026 thus sayeth Vignesh Raghavendra:

Quoted 7 lines · Udit Kumar
Quoted 1 line

unlocking control mmr before spl_early_init leads to

Nit: capitalize the first letter

Quoted 7 lines
Quoted 1 line

unpredicable behaviour.

and run through codespell.

Commit msg is vague. What unpredictable behavior? How do we know moving the ctrl_mmr_unlock() to after spl_early_init() really resolves this unpredictable behavior?

This is an issue has been reported by many people using any of our SE configured reference SoCs which we haven't been able to give an answer for.[0]

The current theory is the CTRL_MMR ranges are firewalled by ROM and TIFS is unlocking them for us. If that's true then we need to move this until after the version message is returned to guarantee the range is unlocked by the time we get to this point.

Moving it to after the spl_early_init() adds more time but isn't guaranteed with many boots.

[0] https://lore.kernel.org/u-boot/[email protected]/

~Bryan

Quoted 54 lines
Quoted 3 lines

So unlock it after spl_early_init.

Wrap commit msg at 80 char uniformly please.

Quoted 9 lines
Fixes 5e291ee34fd4 ("arch: mach-k3: Introduce basic files to support J722S SoC family")

---

On HS-SE of J722S in particular, enable_mcu_esm_reset function is not able to reset bit-17 of ctrl mmr CTRLMMR_MCU_RST_CTRL. Which leads to wdt is not functional. With this change
bit-17 was getting reset properly on HS-SE and HS-FS devices.

This too needs to go into commit msg if not in $subject as this is what user actually sees as the issue.

Quoted 29 lines

HS-FS
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-fs

HS-SE
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-se

 arch/arm/mach-k3/j722s/j722s_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-k3/j722s/j722s_init.c +2 -2
index 1180c75f551..a0dab5d7032 100644
@@ -84,13 +84,13 @@ 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);
 
+	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
Regards
Vignesh
https://ti.com/opensource
#3 lore raw
Quoted 25 lines · Bryan Brattlof

On February 24, 2026 thus sayeth Vignesh Raghavendra:

Quoted 7 lines · Udit Kumar
Quoted 1 line

unlocking control mmr before spl_early_init leads to

Nit: capitalize the first letter

Quoted 7 lines
Quoted 1 line

unpredicable behaviour.

and run through codespell.

Commit msg is vague. What unpredictable behavior? How do we know moving the ctrl_mmr_unlock() to after spl_early_init() really resolves this unpredictable behavior?

This is an issue has been reported by many people using any of our SE configured reference SoCs which we haven't been able to give an answer for.[0]

The current theory is the CTRL_MMR ranges are firewalled by ROM and TIFS is unlocking them for us. If that's true then we need to move this until after the version message is returned to guarantee the range is unlocked by the time we get to this point.

Quoted 4 lines

Moving it to after the spl_early_init() adds more time but isn't guaranteed with many boots.

[0] https://lore.kernel.org/u-boot/[email protected]/

Thanks Bryan,
Make sense to move unlock of mmr after fw versions are printed. So that we are sure tifs and boot-rom are finishing with firewalling.

FYI, i just did one experiment, put random delay before calls to ctrl_mmr_unlock() and wdt seems to be working ok.

Another option I see, let original code be as is, and add support similar to above patch for wdt.

Quoted 57 lines

~Bryan

Quoted 54 lines
Quoted 3 lines

So unlock it after spl_early_init.

Wrap commit msg at 80 char uniformly please.

Quoted 9 lines
Fixes 5e291ee34fd4 ("arch: mach-k3: Introduce basic files to support J722S SoC family")

---

On HS-SE of J722S in particular, enable_mcu_esm_reset function is not able to reset bit-17 of ctrl mmr CTRLMMR_MCU_RST_CTRL. Which leads to wdt is not functional. With this change
bit-17 was getting reset properly on HS-SE and HS-FS devices.

This too needs to go into commit msg if not in $subject as this is what user actually sees as the issue.

Quoted 29 lines

HS-FS
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-fs

HS-SE
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-se

 arch/arm/mach-k3/j722s/j722s_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-k3/j722s/j722s_init.c +2 -2
index 1180c75f551..a0dab5d7032 100644
@@ -84,13 +84,13 @@ 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);
 
+	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
Regards
Vignesh
https://ti.com/opensource
#4 lore raw

Hi Udit

Quoted 38 lines · Udit
Quoted 25 lines · Bryan Brattlof

On February 24, 2026 thus sayeth Vignesh Raghavendra:

Quoted 7 lines · Udit Kumar
Quoted 1 line

unlocking control mmr before spl_early_init leads to

Nit: capitalize the first letter

Quoted 7 lines
Quoted 1 line

unpredicable behaviour.

and run through codespell.

Commit msg is vague. What unpredictable behavior? How do we know moving the ctrl_mmr_unlock() to after spl_early_init() really resolves this unpredictable behavior?

This is an issue has been reported by many people using any of our SE configured reference SoCs which we haven't been able to give an answer for.[0]

The current theory is the CTRL_MMR ranges are firewalled by ROM and TIFS is unlocking them for us. If that's true then we need to move this until after the version message is returned to guarantee the range is unlocked by the time we get to this point.

Quoted 4 lines

Moving it to after the spl_early_init() adds more time but isn't guaranteed with many boots.

[0] https://lore.kernel.org/u-boot/[email protected]/

Thanks Bryan,
Make sense to move unlock of mmr after fw versions are printed. So that we are sure tifs and boot-rom are finishing with firewalling.

Quoted 5 lines

FYI, i just did one experiment, put random delay before calls to ctrl_mmr_unlock() and wdt seems to be working ok.

Another option I see, let original code be as is, and add support similar to above patch for wdt.

Unless we somehow know when TIFS is done with unlocking (is the version print suggested by Bryan a solid yes it's done? if so that's the right solution) I think unlocking the MCU_ESM for WDT is a better fix. Else we're randomly trying to estimate when unlocking is over, perhaps there are further CTRL_MMRs in queue to be unlocked at that point and we'd be doing this again (although this is unlikely since spl_early_init probably takes a good amount of time)

Quoted 59 lines
Quoted 58 lines

~Bryan

Quoted 54 lines
Quoted 3 lines

So unlock it after spl_early_init.

Wrap commit msg at 80 char uniformly please.

Quoted 9 lines
Fixes 5e291ee34fd4 ("arch: mach-k3: Introduce basic files to support J722S SoC family")

---

On HS-SE of J722S in particular, enable_mcu_esm_reset function is not able to reset bit-17 of ctrl mmr CTRLMMR_MCU_RST_CTRL. Which leads to wdt is not functional. With this change
bit-17 was getting reset properly on HS-SE and HS-FS devices.

This too needs to go into commit msg if not in $subject as this is what user actually sees as the issue.

Quoted 29 lines

HS-FS
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-fs

HS-SE
https://gist.github.com/uditkumarti/4ba05c9335212630ce9240ac67e11c2d#file-hs-se

 arch/arm/mach-k3/j722s/j722s_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-k3/j722s/j722s_init.c +2 -2
index 1180c75f551..a0dab5d7032 100644
@@ -84,13 +84,13 @@ 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);
 
+	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
Regards
Vignesh
https://ti.com/opensource
Signature · 2 lines
Thanking You
Neha Malcom Francis