remoteproc: imx_rproc: allow attaching to running core kicked by the bootloader
Subsystems (2)
v3 cover remoteproc: imx_rproc: allow attaching to running core kicked by the bootloader
From: Hiago De Franco <[email protected]>
For the i.MX8X and i.MX8 family SoCs, currently when the remotecore is started by the bootloader and the M core and A core are in the same partition, the driver is not capable to detect the remote core and report the correct state of it.
This series of patches implement an API call to the SCU which will return the power mode of a given resource (M core in this case) and if it is already powered on, the driver will attach to it. This SCU API is being added to the new file drivers/firmware/imx/power.c, where all PM related APIs should go.
Finally, the imx_rproc_clk_enable() function was also changed to make it return before dev_clk_get() is called, as it currently generates an SCU fault reset if the remote core is already running and the kernel tries to enable the clock again. These changes are a follow up from a v1 sent to imx_rproc [1] and from a reported regression [2].
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/20250404141713.ac2ntcsjsf7epdfa@hiago-nb/
v3:
- New file introduced, drivers/firmware/imx/power.c, to handle the PM (Power Management) API functions, as suggested in v2.
- First patch, "firmware: imx: move get power mode function from scu-pd.c to misc.c" was dropped to make the reviewing process easier and in favor of firmware/imx/power.c file. Moving the power mode function from scu-pd.c as proposed will be sent later in a different future patch, as suggested.
v2:
- https://lore.kernel.org/lkml/[email protected]/
v1:
- https://lore.kernel.org/lkml/[email protected]/
Hiago De Franco (3):
firmware: imx: introduce imx_sc_pm_get_resource_power_mode()
remoteproc: imx_rproc: skip clock enable when M-core is managed by the
SCU
remoteproc: imx_rproc: add power mode check for remote core attachment
drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/power.c | 52 +++++++++++++++++++++++++++++ drivers/remoteproc/imx_rproc.c | 17 ++++++++-- include/linux/firmware/imx/svc/pm.h | 9 +++++ 4 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 drivers/firmware/imx/power.c
Signature · 1 line
2.39.5
PATCH v3 1/3 firmware: imx: introduce imx_sc_pm_get_resource_power_mode()
From: Hiago De Franco <[email protected]>
This SCU API returns the power mode of a given resource.
As example, remoteproc/imx_rproc.c can now use this function to check the power mode of the remote core to properly set "attached" or "offline" modes.
Since there is no proper firmware/imx file to place this function, also introduce firmware/imx/power.c file to keep all the PM functions inside.
---
v3: New patch.
--- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/power.c | 52 +++++++++++++++++++++++++++++ include/linux/firmware/imx/svc/pm.h | 9 +++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/imx/power.c
drivers/firmware/imx/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o -obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o power.o obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o
drivers/firmware/imx/power.c new file +52 -0
52 lines not on this page · raw message
include/linux/firmware/imx/svc/pm.h +9 -0
@@ -82,4 +82,13 @@ enum imx_sc_pm_func {#define IMX_SC_PM_PARENT_PLL2 3/* Parent in PLL2 or PLL0/4 */ #define IMX_SC_PM_PARENT_BYPS 4/* Parent is a bypass clock. */ +#if IS_ENABLED (CONFIG_IMX_SCU ) +int imx_sc_pm_get_resource_power_mode (struct imx_sc_ipc *ipc,u32 resource); +#else +static inline int imx_sc_pm_get_resource_power_mode (struct imx_sc_ipc *ipc, +u32 resource) +{ +return -EOPNOTSUPP ; +} +#endif #endif /* _SC_PM_API_H */
Signature · 1 line
2.39.5
PATCH v3 2/3 remoteproc: imx_rproc: skip clock enable when M-core is managed by the SCU
In reply to Hiago De FrancoFrom: Hiago De Franco <[email protected]>
For the i.MX8X and i.MX8 family SoCs, when the M-core is powered up by the bootloader, M-core and Linux are in same SCFW (System Controller Firmware) partition, so linux has permission to control M-core.
But when M-core is started, the SCFW will automatically enable the clock and configure the rate, and any users that want to enable the clock will get error 'LOCKED' from SCFW. So current imx_rproc.c probe function fails because clk_prepare_enable also fails. With that, the M-core power domain is powered off when it is still running, causing a SCU (System Controller Unit) fault reset, and the system restarts.
To address the issue, ignore handling the clk for i.MX8X and i.MX8 M-core, because SCFW will automatically enable and configure the clock.
---
v3: Unchanged.
v2: Commit description updated, as suggested. Fixed Peng Fan email.
v1: https://lore.kernel.org/lkml/[email protected]/
--- drivers/remoteproc/imx_rproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +2 -2
@@ -1029,8 +1029,8 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv)struct device *dev = priv->dev;int ret; -/* Remote core is not under control of Linux */ -if (dcfg->method ==IMX_RPROC_NONE ) +/* Remote core is not under control of Linux or it is managed by SCU API */ +if (dcfg->method ==IMX_RPROC_NONE || dcfg->method ==IMX_RPROC_SCU_API )return 0 ; priv->clk =devm_clk_get (dev,NULL );
Signature · 1 line
2.39.5
PATCH v3 3/3 remoteproc: imx_rproc: add power mode check for remote core attachment
In reply to Hiago De FrancoFrom: Hiago De Franco <[email protected]>
When the remote core is started before Linux boots (e.g., by the bootloader), the driver currently is not able to attach because it only checks for cores running in different partitions. If the core was kicked by the bootloader, it is in the same partition as Linux and it is already up and running.
This adds power mode verification through the SCU interface, enabling the driver to detect when the remote core is already running and properly attach to it.
---
v3: Unchanged.
v2: Dropped unecessary include. Removed the imx_rproc_is_on function, as suggested.
v1: https://lore.kernel.org/lkml/[email protected]/
--- drivers/remoteproc/imx_rproc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/remoteproc/imx_rproc.c +13 -0
@@ -949,6 +949,19 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)if (of_property_read_u32 (dev->of_node,"fsl,entry-address" , &priv->entry))return -EINVAL ; +/* +* If remote core is already running (e.g. kicked by +* the bootloader), attach to it. +*/ + ret =imx_sc_pm_get_resource_power_mode (priv->ipc_handle, + priv->rsrc_id); +if (ret <0 ) +dev_err (dev,"failed to get power resource %d mode, ret %d\n" , + priv->rsrc_id, ret); + +if (ret ==IMX_SC_PM_PW_MODE_ON ) + priv->rproc->state =RPROC_DETACHED ; +return imx_rproc_attach_pd (priv); }
Signature · 1 line
2.39.5
Quoted 1 line · Hiago De Franco
From: Hiago De Franco <[email protected]>
Let's wait for V2 discussion a bit, then I will give a look if we reach an agreement on using firmware power API here.
Thanks,
Peng