Skip to contentSkip to conversation

clk: imx5: Check the IIM clock before reading the i.MX53 revision

PATCH In review Jiawen Liu 3 participants 3 messages Nov 29 – Nov 30

Subsystems (3)
lore
Share & tools
lore

Jiawen Liu

author
#0 lore raw

PATCH 1/1 clk: imx5: Check the IIM clock before reading the i.MX53 revision

During i.MX53 device-tree boot, mx53_clocks_init() reads the silicon revision from the IIM after calling clk_prepare_enable(). The IIM gate registration can return an error pointer that clk_prepare() dereferences. If a valid clock fails to prepare or enable, the callback still reads the IIM without acquiring its clock and then attempts an unmatched disable and unprepare.

Use the existing registration diagnostic and skip the revision read when the IIM gate failed to register. Log prepare or enable failures, and read the revision and release the clock only after a successful acquisition. Continue USB and UART clock setup in all cases.

Verified the control flow by source
inspection, cross-built clk-imx5.o with ARM imx_v6_v7_defconfig, and ran git diff --check and checkpatch. No runtime or hardware reproduction was performed.

Fixes b8d4176fa59e ("ARM i.MX5: implement clocks using common clock framework")
---
 drivers/clk/imx/clk-imx5.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/clk/imx/clk-imx5.c +12 -3
index 9c5f489b3975d..d3fc9fcd8ec2f 100644
@@ -472,7 +472,9 @@ static void __init mx53_clocks_init(struct device_node *np)
 {
 	void __iomem *ccm_base;
 	void __iomem *pll_base;
+	struct clk *iim_clk;
 	unsigned long r;
+	int ret;
 
 	pll_base = ioremap(MX53_DPLL1_BASE, SZ_16K);
 	WARN_ON(!pll_base);
@@ -602,9 +604,16 @@ static void __init mx53_clocks_init(struct device_node *np)
 	/* make sure step clock is running from 24MHz */
 	clk_set_parent(clk[IMX5_CLK_STEP_SEL], clk[IMX5_CLK_LP_APM]);
 
-	clk_prepare_enable(clk[IMX5_CLK_IIM_GATE]);
-	imx_print_silicon_rev("i.MX53", mx53_revision());
-	clk_disable_unprepare(clk[IMX5_CLK_IIM_GATE]);
+	iim_clk = clk[IMX5_CLK_IIM_GATE];
+	if (!IS_ERR(iim_clk)) {
+		ret = clk_prepare_enable(iim_clk);
+		if (ret) {
+			pr_err("i.MX53: failed to enable IIM clock: %d\n", ret);
+		} else {
+			imx_print_silicon_rev("i.MX53", mx53_revision());
+			clk_disable_unprepare(iim_clk);
+		}
+	}
 
 	r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000);
 	clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 17 lines · Jiawen Liu

During i.MX53 device-tree boot, mx53_clocks_init() reads the silicon revision from the IIM after calling clk_prepare_enable(). The IIM gate registration can return an error pointer that clk_prepare() dereferences. If a valid clock fails to prepare or enable, the callback still reads the IIM without acquiring its clock and then attempts an unmatched disable and unprepare.

Use the existing registration diagnostic and skip the revision read when the IIM gate failed to register. Log prepare or enable failures, and read the revision and release the clock only after a successful acquisition. Continue USB and UART clock setup in all cases.

Verified the control flow by source
inspection, cross-built clk-imx5.o with ARM imx_v6_v7_defconfig, and ran git diff --check and checkpatch. No runtime or hardware reproduction was performed.

Quoted 6 lines
Fixes b8d4176fa59e ("ARM i.MX5: implement clocks using common clock framework")
---
 drivers/clk/imx/clk-imx5.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

You sent multiple independent patches, to multiple independent subsystems. The amount of these patches clearly suggest this was AI generated and most likely not tested.

More importantly, you sent all this work without properly organizing relevant patches into patchsets. This makes reviewing difficult and might cause multiple reviewers to address the same issue. Replying to the entire set is impossible and requires handling each patch independently, instead of applying or discarding the set. Maintainers also won't see the bigger picture of your work. Quite worrying.

Please read kernel documentation BEFORE posting more work. It will explain you how to identify subsystems, how to organize your work per subsystem (so a patchset grouping multiple patches with a short cover letter), how to document the issue discovery method and what was or was not tested.

Best regards,
Krzysztof

Reviewed-by Peng Fan on v1 1/1
#2 lore raw
In reply to Jiawen Liu
Quoted 45 lines · On Sun, 29 Nov 2026 19:25:33 +0000 Jiawen Liu <[email protected]> wrote:

During i.MX53 device-tree boot, mx53_clocks_init() reads the silicon revision from the IIM after calling clk_prepare_enable(). The IIM gate registration can return an error pointer that clk_prepare() dereferences. If a valid clock fails to prepare or enable, the callback still reads the IIM without acquiring its clock and then attempts an unmatched disable and unprepare.

Use the existing registration diagnostic and skip the revision read when the IIM gate failed to register. Log prepare or enable failures, and read the revision and release the clock only after a successful acquisition. Continue USB and UART clock setup in all cases.

Verified the control flow by source
inspection, cross-built clk-imx5.o with ARM imx_v6_v7_defconfig, and ran git diff --check and checkpatch. No runtime or hardware reproduction was performed.

Fixes b8d4176fa59e ("ARM i.MX5: implement clocks using common clock framework")
---
 drivers/clk/imx/clk-imx5.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/clk/imx/clk-imx5.c +3 -3
index 9c5f489b3975d..d3fc9fcd8ec2f 100644
@@ -472,7 +472,9 @@ static void __init mx53_clocks_init(struct device_node *np)
 {
 	void __iomem *ccm_base;
 	void __iomem *pll_base;
+	struct clk *iim_clk;
 	unsigned long r;
+	int ret;
 
 	pll_base = ioremap(MX53_DPLL1_BASE, SZ_16K);
 	WARN_ON(!pll_base);
@@ -602,9 +604,16 @@ static void __init mx53_clocks_init(struct device_node *np)
 	/* make sure step clock is running from 24MHz */
 	clk_set_parent(clk[IMX5_CLK_STEP_SEL], clk[IMX5_CLK_LP_APM]);
 
-	clk_prepare_enable(clk[IMX5_CLK_IIM_GATE]);
-	imx_print_silicon_rev("i.MX53", mx53_revision());
-	clk_disable_unprepare(clk[IMX5_CLK_IIM_GATE]);
+	iim_clk = clk[IMX5_CLK_IIM_GATE];

drivers/clk/imx/clk-imx5.c static void __init mx53_clocks_init(struct device_node *np) · line 617

Quoted 10 lines
drivers/clk/imx/clk-imx5.c +9 -0
+	if (!IS_ERR(iim_clk)) {
+		ret = clk_prepare_enable(iim_clk);
+		if (ret) {
+			pr_err("i.MX53: failed to enable IIM clock: %d\n", ret);
+		} else {
+			imx_print_silicon_rev("i.MX53", mx53_revision());
+			clk_disable_unprepare(iim_clk);
+		}
+	}