U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: mediatek: fix reprobe regression
@ 2026-08-13 13:10 David Lechner
  2026-08-13 13:15 ` David Lechner
  2026-08-14  3:35 ` sam.shih
  0 siblings, 2 replies; 3+ messages in thread
From: David Lechner @ 2026-08-13 13:10 UTC (permalink / raw)
  To: Lukasz Majewski, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
	Julien Stephan, GSS_MTK_Uboot_upstream, Tom Rini
  Cc: u-boot, Sam Shih, David Lechner

Clear the MediaTek clock provider registry after relocation. This is
necessary for a couple of reasons. If any clock probed before the
relocation, the registry will contain a pointer to pre-relocation
memory. Also, all drivers reprobe after relocation, so even if we
had a valid pointer, it would be to a clock provider that had not been
reprobed yet. Clearing the registry ensures that all clock providers
are re-registered when they are reprobed after relocation.

Reported-by: Sam Shih <Sam.Shih@mediatek.com>
Fixes: 8ef0ad4c7a6d ("clk: mediatek: use registered provider for parent lookup")
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/clk/mediatek/clk-mtk.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 13c248c93a6..849e8a196e5 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -1130,3 +1130,21 @@ int mtk_clk_probe(struct udevice *dev)
 
 	return mtk_clk_tree_register_provider(dev, tree);
 }
+
+static int mtk_clock_reset_registry(void)
+{
+	/*
+	 * When U-Boot is relocated, the static clock provider registry is no
+	 * longer valid since it contains pointers to the old U-Boot memory.
+	 * Furthermore, all devices are re-probed after relocation. Therefore,
+	 * we need to reset the registry before any devices can probe after
+	 * relocation.
+	 */
+
+	for (int i = 0; i < ARRAY_SIZE(mtk_clk_providers); i++)
+		mtk_clk_providers[i] = NULL;
+
+	return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_R, mtk_clock_reset_registry);

---
base-commit: 0b581a9612e46310ee52bf8359165950d38b2a2b
change-id: 20260813-mtk-clk-fix-reprobe-regression-6ac0c072600b

Best regards,
--  
David Lechner <dlechner@baylibre.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: mediatek: fix reprobe regression
  2026-08-13 13:10 [PATCH] clk: mediatek: fix reprobe regression David Lechner
@ 2026-08-13 13:15 ` David Lechner
  2026-08-14  3:35 ` sam.shih
  1 sibling, 0 replies; 3+ messages in thread
From: David Lechner @ 2026-08-13 13:15 UTC (permalink / raw)
  To: Lukasz Majewski, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon,
	Julien Stephan, GSS_MTK_Uboot_upstream, Tom Rini
  Cc: u-boot, Sam Shih

On 8/13/26 8:10 AM, David Lechner wrote:
> Clear the MediaTek clock provider registry after relocation. This is
> necessary for a couple of reasons. If any clock probed before the
> relocation, the registry will contain a pointer to pre-relocation
> memory. Also, all drivers reprobe after relocation, so even if we
> had a valid pointer, it would be to a clock provider that had not been
> reprobed yet. Clearing the registry ensures that all clock providers
> are re-registered when they are reprobed after relocation.
> 
Disregard. I forgot an important detail and will send v2 shortly.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: mediatek: fix reprobe regression
  2026-08-13 13:10 [PATCH] clk: mediatek: fix reprobe regression David Lechner
  2026-08-13 13:15 ` David Lechner
@ 2026-08-14  3:35 ` sam.shih
  1 sibling, 0 replies; 3+ messages in thread
From: sam.shih @ 2026-08-14  3:35 UTC (permalink / raw)
  To: David Lechner, Lukasz Majewski, Ryder Lee, Weijie Gao,
	Chunfeng Yun, Igor Belwon, Julien Stephan, GSS_MTK_Uboot_upstream,
	Tom Rini
  Cc: u-boot

Hi David,

Thank you for the patch.

I have tested this v2 patch on Filogic SoCs (MT7987/MT7988), and I can 
confirm that the issue regarding the clock usage before relocation 
(e.g., UART early console) is now fixed. The system boots up and works 
properly without the previous regression.

Please feel free to add my Tested-by tag:

Tested-by: Sam Shih <Sam.Shih@mediatek.com>

Best regards,
Sam

On Thu, 2026-08-13 at 08:10 -0500, David Lechner wrote:
> Clear the MediaTek clock provider registry after relocation. This is
> necessary for a couple of reasons. If any clock probed before the
> relocation, the registry will contain a pointer to pre-relocation
> memory. Also, all drivers reprobe after relocation, so even if we
> had a valid pointer, it would be to a clock provider that had not
> been
> reprobed yet. Clearing the registry ensures that all clock providers
> are re-registered when they are reprobed after relocation.
> 
> Reported-by: Sam Shih <Sam.Shih@mediatek.com>
> Fixes: 8ef0ad4c7a6d ("clk: mediatek: use registered provider for
> parent lookup")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
>  drivers/clk/mediatek/clk-mtk.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/clk/mediatek/clk-mtk.c
> b/drivers/clk/mediatek/clk-mtk.c
> index 13c248c93a6..849e8a196e5 100644
> --- a/drivers/clk/mediatek/clk-mtk.c
> +++ b/drivers/clk/mediatek/clk-mtk.c
> @@ -1130,3 +1130,21 @@ int mtk_clk_probe(struct udevice *dev)
>  
>  	return mtk_clk_tree_register_provider(dev, tree);
>  }
> +
> +static int mtk_clock_reset_registry(void)
> +{
> +	/*
> +	 * When U-Boot is relocated, the static clock provider
> registry is no
> +	 * longer valid since it contains pointers to the old U-Boot
> memory.
> +	 * Furthermore, all devices are re-probed after relocation.
> Therefore,
> +	 * we need to reset the registry before any devices can
> probe after
> +	 * relocation.
> +	 */
> +
> +	for (int i = 0; i < ARRAY_SIZE(mtk_clk_providers); i++)
> +		mtk_clk_providers[i] = NULL;
> +
> +	return 0;
> +}
> +
> +EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_R, mtk_clock_reset_registry);
> 
> ---
> base-commit: 0b581a9612e46310ee52bf8359165950d38b2a2b
> change-id: 20260813-mtk-clk-fix-reprobe-regression-6ac0c072600b
> 
> Best regards,
> --  
> David Lechner <dlechner@baylibre.com>
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-14  3:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 13:10 [PATCH] clk: mediatek: fix reprobe regression David Lechner
2026-08-13 13:15 ` David Lechner
2026-08-14  3:35 ` sam.shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox