* [PATCH v4 1/3] of: export of_stdout symbol
2026-07-22 8:25 [PATCH v4 0/3] pmdomain: imx: build the SCU power domain driver as a module Zhipeng.wang_1
@ 2026-07-22 8:25 ` Zhipeng.wang_1
2026-07-22 8:25 ` [PATCH v4 2/3] pmdomain: imx: scu-pd: allow building as a module Zhipeng.wang_1
2026-07-22 8:25 ` [PATCH v4 3/3] clk: imx: imx8qxp: add soft dependency on SCU power domain driver Zhipeng.wang_1
2 siblings, 0 replies; 6+ messages in thread
From: Zhipeng.wang_1 @ 2026-07-22 8:25 UTC (permalink / raw)
To: robh, saravanak, ulfh, Frank.Li, s.hauer
Cc: kernel, festevam, peng.fan, aisheng.dong, jindong.yue,
xuegang.liu, devicetree, linux-pm, imx, linux-arm-kernel,
linux-kernel, linux-clk
From: Zhipeng Wang <zhipeng.wang_1@nxp.com>
of_stdout is declared extern in include/linux/of.h alongside of_root
and of_chosen, but unlike those two it is not exported, preventing
modules from referencing it.
Export it with EXPORT_SYMBOL_GPL() so drivers that need the stdout
device node can be built as modules.
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
drivers/of/base.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 6e7a42dedad3..a25c95800719 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -39,6 +39,7 @@ struct device_node *of_chosen;
EXPORT_SYMBOL(of_chosen);
struct device_node *of_aliases;
struct device_node *of_stdout;
+EXPORT_SYMBOL_GPL(of_stdout);
static const char *of_stdout_options;
struct kset *of_kset;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] pmdomain: imx: scu-pd: allow building as a module
2026-07-22 8:25 [PATCH v4 0/3] pmdomain: imx: build the SCU power domain driver as a module Zhipeng.wang_1
2026-07-22 8:25 ` [PATCH v4 1/3] of: export of_stdout symbol Zhipeng.wang_1
@ 2026-07-22 8:25 ` Zhipeng.wang_1
2026-07-22 8:38 ` sashiko-bot
2026-07-22 8:25 ` [PATCH v4 3/3] clk: imx: imx8qxp: add soft dependency on SCU power domain driver Zhipeng.wang_1
2 siblings, 1 reply; 6+ messages in thread
From: Zhipeng.wang_1 @ 2026-07-22 8:25 UTC (permalink / raw)
To: robh, saravanak, ulfh, Frank.Li, s.hauer
Cc: kernel, festevam, peng.fan, aisheng.dong, jindong.yue,
xuegang.liu, devicetree, linux-pm, imx, linux-arm-kernel,
linux-kernel, linux-clk
From: Zhipeng Wang <zhipeng.wang_1@nxp.com>
Convert CONFIG_IMX_SCU_PD from bool to tristate to allow building as a
loadable module. This is needed on Android devices using the Generic
Kernel Image (GKI), where SoC-specific drivers must be built as modules
rather than built into the core kernel image.
For i.MX8Q devices running Android with a GKI kernel, the SCU power
domain driver must be loadable. Without tristate support, power domains
cannot be properly initialized, preventing these systems from
functioning under GKI.
Use subsys_initcall() so that when built-in the power domain provider
probes before its consumers (e.g. the SCU clock driver at
device_initcall level), fixing "failed to attached the power domain"
warnings at boot. When built as a module, subsys_initcall() is
equivalent to module_init(). No module_exit() is provided because the
SCU power domain provider is a system-level resource that cannot be
safely removed at runtime.
Add MODULE_DEVICE_TABLE() for OF-based module autoloading.
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
drivers/pmdomain/imx/Kconfig | 2 +-
drivers/pmdomain/imx/scu-pd.c | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/pmdomain/imx/Kconfig b/drivers/pmdomain/imx/Kconfig
index 00203615c65e..472e9dec6bd4 100644
--- a/drivers/pmdomain/imx/Kconfig
+++ b/drivers/pmdomain/imx/Kconfig
@@ -21,7 +21,7 @@ config IMX9_BLK_CTRL
depends on PM_GENERIC_DOMAINS
config IMX_SCU_PD
- bool "IMX SCU Power Domain driver"
+ tristate "IMX SCU Power Domain driver"
depends on IMX_SCU
help
The System Controller Firmware (SCFW) based power domain driver.
diff --git a/drivers/pmdomain/imx/scu-pd.c b/drivers/pmdomain/imx/scu-pd.c
index 3ec33667a308..e3f9e741daf7 100644
--- a/drivers/pmdomain/imx/scu-pd.c
+++ b/drivers/pmdomain/imx/scu-pd.c
@@ -531,6 +531,7 @@ static const struct of_device_id imx_sc_pd_match[] = {
{ .compatible = "fsl,scu-pd", &imx8qxp_scu_pd},
{ /* sentinel */ }
};
+MODULE_DEVICE_TABLE(of, imx_sc_pd_match);
static struct platform_driver imx_sc_pd_driver = {
.driver = {
@@ -540,7 +541,12 @@ static struct platform_driver imx_sc_pd_driver = {
},
.probe = imx_sc_pd_probe,
};
-builtin_platform_driver(imx_sc_pd_driver);
+
+static int __init imx_sc_pd_driver_init(void)
+{
+ return platform_driver_register(&imx_sc_pd_driver);
+}
+subsys_initcall(imx_sc_pd_driver_init);
MODULE_AUTHOR("Dong Aisheng <aisheng.dong@nxp.com>");
MODULE_DESCRIPTION("IMX SCU Power Domain driver");
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v4 2/3] pmdomain: imx: scu-pd: allow building as a module
2026-07-22 8:25 ` [PATCH v4 2/3] pmdomain: imx: scu-pd: allow building as a module Zhipeng.wang_1
@ 2026-07-22 8:38 ` sashiko-bot
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-07-22 8:38 UTC (permalink / raw)
To: Zhipeng.wang_1; +Cc: robh, conor+dt, Frank.Li, devicetree, imx
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Converting the IMX_SCU_PD driver to a loadable module introduces a critical probe ordering race condition that permanently breaks SCU clock initialization.
--
--- Patch [2]: [PATCH v4 2/3] pmdomain: imx: scu-pd: allow building as a module ---
commit 628d94a1fc8f8e8847b2257f097c88ea5e22ffe7
Author: Zhipeng Wang <zhipeng.wang_1@nxp.com>
pmdomain: imx: scu-pd: allow building as a module
This commit converts the IMX SCU power domain driver to a tristate to
support Android GKI loadable modules. It relies on subsys_initcall() to
preserve probe ordering when built-in.
> diff --git a/drivers/pmdomain/imx/scu-pd.c b/drivers/pmdomain/imx/scu-pd.c
> index 3ec33667a308c..e3f9e741daf76 100644
> --- a/drivers/pmdomain/imx/scu-pd.c
> +++ b/drivers/pmdomain/imx/scu-pd.c
[ ... ]
> @@ -540,7 +541,12 @@ static struct platform_driver imx_sc_pd_driver = {
> },
> .probe = imx_sc_pd_probe,
> };
> -builtin_platform_driver(imx_sc_pd_driver);
> +
> +static int __init imx_sc_pd_driver_init(void)
> +{
> + return platform_driver_register(&imx_sc_pd_driver);
> +}
> +subsys_initcall(imx_sc_pd_driver_init);
[Severity: High]
Does converting this driver to a loadable module break the probe ordering
with the SCU clock driver?
Because subsys_initcall() behaves like module_init() when built as a module,
the power domain and clock modules will be loaded asynchronously by udev.
If the clock provider probes before the power domain module is loaded,
it fails to attach the power domain but proceeds to register the clocks
anyway:
drivers/clk/imx/clk-scu.c:imx_clk_scu_alloc_dev() {
...
ret = imx_clk_scu_attach_pd(&pdev->dev, rsrc_id);
if (ret)
pr_warn("%s: failed to attached the power domain %d\n",
name, ret);
ret = platform_device_add(pdev);
...
}
Since there is no fw_devlink dependency (the clock controller DT node
lacks a power-domains property) and no symbol dependency, the clock
driver will not defer its probe. This leaves the SCU clocks without
their required power domains, which causes hardware faults when the
clocks are later enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722082522.3747962-1-Zhipeng.wang_1@oss.nxp.com?part=2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] clk: imx: imx8qxp: add soft dependency on SCU power domain driver
2026-07-22 8:25 [PATCH v4 0/3] pmdomain: imx: build the SCU power domain driver as a module Zhipeng.wang_1
2026-07-22 8:25 ` [PATCH v4 1/3] of: export of_stdout symbol Zhipeng.wang_1
2026-07-22 8:25 ` [PATCH v4 2/3] pmdomain: imx: scu-pd: allow building as a module Zhipeng.wang_1
@ 2026-07-22 8:25 ` Zhipeng.wang_1
2026-07-22 8:35 ` sashiko-bot
2 siblings, 1 reply; 6+ messages in thread
From: Zhipeng.wang_1 @ 2026-07-22 8:25 UTC (permalink / raw)
To: robh, saravanak, ulfh, Frank.Li, s.hauer
Cc: kernel, festevam, peng.fan, aisheng.dong, jindong.yue,
xuegang.liu, devicetree, linux-pm, imx, linux-arm-kernel,
linux-kernel, linux-clk
From: Zhipeng Wang <zhipeng.wang_1@nxp.com>
The i.MX8QXP SCU clock driver manually attaches power domains to each
clock device via of_genpd_add_device() in imx_clk_scu_attach_pd().
If the SCU power domain provider has not probed yet, the attachment
fails silently with a pr_warn() and the clock device is registered
without a power domain.
When both drivers are built as modules, there is no implicit
dependency to guarantee load order. Add MODULE_SOFTDEP("pre:
imx_scu_pd") so that modprobe loads the SCU power domain module
before the clock module.
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
drivers/clk/imx/clk-imx8qxp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clk/imx/clk-imx8qxp.c b/drivers/clk/imx/clk-imx8qxp.c
index c781425a005e..23ef6b959dee 100644
--- a/drivers/clk/imx/clk-imx8qxp.c
+++ b/drivers/clk/imx/clk-imx8qxp.c
@@ -373,3 +373,4 @@ module_exit(imx8qxp_clk_exit);
MODULE_AUTHOR("Aisheng Dong <aisheng.dong@nxp.com>");
MODULE_DESCRIPTION("NXP i.MX8QXP clock driver");
MODULE_LICENSE("GPL v2");
+MODULE_SOFTDEP("pre: imx_scu_pd");
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v4 3/3] clk: imx: imx8qxp: add soft dependency on SCU power domain driver
2026-07-22 8:25 ` [PATCH v4 3/3] clk: imx: imx8qxp: add soft dependency on SCU power domain driver Zhipeng.wang_1
@ 2026-07-22 8:35 ` sashiko-bot
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-07-22 8:35 UTC (permalink / raw)
To: Zhipeng.wang_1; +Cc: robh, Frank.Li, conor+dt, imx, devicetree
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The `MODULE_SOFTDEP` declaration specifies an incorrect module name, rendering the fix completely ineffective.
Pre-existing issues:
- [High] Ignoring -EPROBE_DEFER causes silent device registration without power domains, leading to hardware exceptions.
--
--- Patch [3]: [PATCH v4 3/3] clk: imx: imx8qxp: add soft dependency on SCU power domain driver ---
commit f47fec3b0de49112a338b6cde236c5713303a35f
Author: Zhipeng Wang <zhipeng.wang_1@nxp.com>
clk: imx: imx8qxp: add soft dependency on SCU power domain driver
This commit adds a soft dependency on the SCU power domain module to ensure
it is loaded before the i.MX8QXP clock driver. This attempts to work around
silent failures when attaching power domains during device initialization.
> diff --git a/drivers/clk/imx/clk-imx8qxp.c b/drivers/clk/imx/clk-imx8qxp.c
> index c781425a005ef..23ef6b959dee8 100644
> --- a/drivers/clk/imx/clk-imx8qxp.c
> +++ b/drivers/clk/imx/clk-imx8qxp.c
> @@ -373,3 +373,4 @@ module_exit(imx8qxp_clk_exit);
> MODULE_AUTHOR("Aisheng Dong <aisheng.dong@nxp.com>");
> MODULE_DESCRIPTION("NXP i.MX8QXP clock driver");
> MODULE_LICENSE("GPL v2");
> +MODULE_SOFTDEP("pre: imx_scu_pd");
[Severity: High]
Does this soft dependency specify the correct module name?
The Makefile entry obj-$(CONFIG_IMX_SCU_PD) += scu-pd.o typically results
in a module named scu-pd (or scu_pd). When modprobe parses imx_scu_pd,
it won't find the module, ignoring the dependency and rendering the
workaround ineffective.
[Severity: High]
This isn't a bug introduced by this patch, but the patch relies on a module
load workaround rather than fixing the root cause of the probe order issue.
In drivers/clk/imx/clk-scu.c, imx_clk_scu_alloc_dev() silently ignores
errors from imx_clk_scu_attach_pd():
ret = imx_clk_scu_attach_pd(&pdev->dev, rsrc_id);
if (ret)
pr_warn("%s: failed to attached the power domain %d\n",
name, ret);
If the power domain provider probes after the clock provider or defers its
probe, of_genpd_add_device() returns -EPROBE_DEFER. Because this error
is ignored, clocks are registered without power domains attached, leading to
hardware exceptions or power leaks when those clocks are accessed.
Should the -EPROBE_DEFER error be propagated up the call stack instead?
This would allow the standard kernel deferral mechanism to reliably enforce
the initialization ordering, handling manual module loads and provider probe
deferrals gracefully without relying on MODULE_SOFTDEP.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722082522.3747962-1-Zhipeng.wang_1@oss.nxp.com?part=3
^ permalink raw reply [flat|nested] 6+ messages in thread