Skip to contentSkip to conversation

imx: power-domain: Fix crash due to uninitialized 'id' field

PATCH Applied Frieder Schrempf 3 participants 3 messages Jul 22, 2025 – Jul 24, 2025 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 imx: power-domain: Fix crash due to uninitialized 'id' field

From: Frieder Schrempf <[email protected]>

In case of the i.MX8M power-domains (i.MX8MQ, MM, MN) there is only one power-domain for each device. Therefore the 'id' field in struct power_domain should always be zero.

Currently if a power-domain is accessed after the initial bind, the 'id' field is left uninitialized. This didn't cause any problems until the following commits were introduced:

9086b64ca071 ("power-domain: Add support for refcounting (again)") a785ef24487b ("imx: power-domain: Enable refcounting on imx8mp")

Now the 'id' field gets accessed in the power_domain_off() sequence and the invalid value causes "Synchronous Abort" failures.

This was observed on a i.MX8MM board when running "usb start" and then "usb stop".

Fix this issue by setting power_domain->id to '0' in imx8m_power_domain_of_xlate().

Fixes d08a194871fd ("imx: add support for i.MX8MQ power domain controller")
Fixes 9086b64ca071 ("power-domain: Add support for refcounting (again)")
---
 drivers/power/domain/imx8m-power-domain.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/domain/imx8m-power-domain.c +2 -0
index b44aae78e6d..a7e64971a2a 100644
@@ -468,6 +468,8 @@ out_clk_disable:
 static int imx8m_power_domain_of_xlate(struct power_domain *power_domain,
 				      struct ofnode_phandle_args *args)
 {
+	power_domain->id = 0;
+
 	return 0;
 }
 
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Frieder,

Quoted 34 lines · Frieder Schrempf

From: Frieder Schrempf <[email protected]>

In case of the i.MX8M power-domains (i.MX8MQ, MM, MN) there is only one power-domain for each device. Therefore the 'id' field in struct power_domain should always be zero.

Currently if a power-domain is accessed after the initial bind, the 'id' field is left uninitialized. This didn't cause any problems until the following commits were introduced:

9086b64ca071 ("power-domain: Add support for refcounting (again)") a785ef24487b ("imx: power-domain: Enable refcounting on imx8mp")

Now the 'id' field gets accessed in the power_domain_off() sequence and the invalid value causes "Synchronous Abort" failures.

This was observed on a i.MX8MM board when running "usb start" and then "usb stop".

Fix this issue by setting power_domain->id to '0' in imx8m_power_domain_of_xlate().

Fixes d08a194871fd ("imx: add support for i.MX8MQ power domain controller")
Fixes 9086b64ca071 ("power-domain: Add support for refcounting (again)")
---
 drivers/power/domain/imx8m-power-domain.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/domain/imx8m-power-domain.c +0 -0
index b44aae78e6d..a7e64971a2a 100644

drivers/power/domain/imx8m-power-domain.c out_clk_disable: · line 474

Quoted 7 lines
drivers/power/domain/imx8m-power-domain.c +2 -0
@@ -468,6 +468,8 @@ out_clk_disable:
 static int imx8m_power_domain_of_xlate(struct power_domain *power_domain,
 				      struct ofnode_phandle_args *args)
 {
+	power_domain->id = 0;
+
 	return 0;
 }

Looks like a correct fix. I wonder how many drivers do not properly set an id though. Thanks a lot!

Thanks,
Miquèl

reviewer Applied
#2 lore raw
In reply to Frieder Schrempf
Quoted 20 lines · Frieder Schrempf

From: Frieder Schrempf <[email protected]>

In case of the i.MX8M power-domains (i.MX8MQ, MM, MN) there is only one power-domain for each device. Therefore the 'id' field in struct power_domain should always be zero.

Currently if a power-domain is accessed after the initial bind, the 'id' field is left uninitialized. This didn't cause any problems until the following commits were introduced:

9086b64ca071 ("power-domain: Add support for refcounting (again)") a785ef24487b ("imx: power-domain: Enable refcounting on imx8mp")

Now the 'id' field gets accessed in the power_domain_off() sequence and the invalid value causes "Synchronous Abort" failures.

This was observed on a i.MX8MM board when running "usb start" and then "usb stop".

Quoted 6 lines

Fix this issue by setting power_domain->id to '0' in imx8m_power_domain_of_xlate().

Fixes d08a194871fd ("imx: add support for i.MX8MQ power domain controller")
Fixes 9086b64ca071 ("power-domain: Add support for refcounting (again)")

Applied, thanks.