[PATCH] imx8: Correct the SCU API return value check

From: Peng Fan peng.fan@nxp.com
The SCU API alrdeay has been converted to return Linux error code, using SCU error code is not correct here, although SC_ERR_NONE is value as 0.
Signed-off-by: Peng Fan peng.fan@nxp.com --- arch/arm/mach-imx/imx8/ahab.c | 8 ++++---- arch/arm/mach-imx/imx8/cpu.c | 34 +++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-imx/imx8/ahab.c b/arch/arm/mach-imx/imx8/ahab.c index ed44df394b1..324e010bb2c 100644 --- a/arch/arm/mach-imx/imx8/ahab.c +++ b/arch/arm/mach-imx/imx8/ahab.c @@ -345,9 +345,9 @@ int ahab_close(void) u16 lc;
err = sc_seco_chip_info(-1, &lc, NULL, NULL, NULL); - if (err != SC_ERR_NONE) { + if (err) { printf("Error in get lifecycle\n"); - return -EIO; + return err; }
if (lc != 0x20) { @@ -357,9 +357,9 @@ int ahab_close(void) }
err = sc_seco_forward_lifecycle(-1, 16); - if (err != SC_ERR_NONE) { + if (err) { printf("Error in forward lifecycle to OEM closed\n"); - return -EIO; + return err; }
return 0; diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 834aca82bcf..317db31eeda 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -48,7 +48,7 @@ static char *get_reset_cause(void) { sc_pm_reset_reason_t reason;
- if (sc_pm_reset_reason(-1, &reason) != SC_ERR_NONE) + if (sc_pm_reset_reason(-1, &reason)) return "Unknown reset";
switch (reason) { @@ -160,6 +160,7 @@ int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data) sc_faddr_t tcml_addr; u32 tcml_size = SZ_128K; ulong addr; + int ret;
switch (core_id) { case 0: @@ -187,10 +188,12 @@ int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data)
printf("Power on M4 and MU\n");
- if (sc_pm_set_resource_power_mode(-1, core_rsrc, SC_PM_PW_MODE_ON) != SC_ERR_NONE) - return -EIO; + ret = sc_pm_set_resource_power_mode(-1, core_rsrc, SC_PM_PW_MODE_ON); + if (ret) + return ret;
- if (sc_pm_set_resource_power_mode(-1, mu_rsrc, SC_PM_PW_MODE_ON) != SC_ERR_NONE) + ret = sc_pm_set_resource_power_mode(-1, mu_rsrc, SC_PM_PW_MODE_ON); + if (ret) return -EIO;
printf("Copy M4 image from 0x%lx to TCML 0x%lx\n", addr, (ulong)tcml_addr); @@ -199,7 +202,8 @@ int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data) memcpy((void *)tcml_addr, (void *)addr, tcml_size);
printf("Start M4 %u\n", core_id); - if (sc_pm_cpu_start(-1, core_rsrc, true, tcml_addr) != SC_ERR_NONE) + ret = sc_pm_cpu_start(-1, core_rsrc, true, tcml_addr); + if (ret) return -EIO;
printf("bootaux complete\n"); @@ -242,20 +246,23 @@ int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data)
printf("Power on aux core %d\n", core_id);
- if (sc_pm_set_resource_power_mode(-1, core_rsrc, SC_PM_PW_MODE_ON) != SC_ERR_NONE) - return -EIO; + ret = sc_pm_set_resource_power_mode(-1, core_rsrc, SC_PM_PW_MODE_ON); + if (ret) + return ret;
if (mu_rsrc != SC_R_NONE) { - if (sc_pm_set_resource_power_mode(-1, mu_rsrc, SC_PM_PW_MODE_ON) != SC_ERR_NONE) + ret = sc_pm_set_resource_power_mode(-1, mu_rsrc, SC_PM_PW_MODE_ON); + if (ret) return -EIO; }
if (core_id == 1) { struct power_domain pd;
- if (sc_pm_clock_enable(-1, core_rsrc, SC_PM_CLK_PER, true, false) != SC_ERR_NONE) { + ret = sc_pm_clock_enable(-1, core_rsrc, SC_PM_CLK_PER, true, false) + if (ret) { printf("Error enable clock\n"); - return -EIO; + return ret; }
if (!imx8_power_domain_lookup_name("audio_sai0", &pd)) { @@ -286,8 +293,9 @@ int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data)
printf("Start %s\n", core_id == 0 ? "M4" : "HIFI");
- if (sc_pm_cpu_start(-1, core_rsrc, true, aux_core_ram) != SC_ERR_NONE) - return -EIO; + ret = sc_pm_cpu_start(-1, core_rsrc, true, aux_core_ram); + if (ret) + return ret;
printf("bootaux complete\n"); return 0; @@ -313,7 +321,7 @@ int arch_auxiliary_core_check_up(u32 core_id) return 0; }
- if (sc_pm_get_resource_power_mode(-1, core_rsrc, &power_mode) != SC_ERR_NONE) + if (sc_pm_get_resource_power_mode(-1, core_rsrc, &power_mode)) return 0;
if (power_mode != SC_PM_PW_MODE_OFF)

On Sat, Oct 5, 2024 at 9:01 PM Peng Fan (OSS) peng.fan@oss.nxp.com wrote:
From: Peng Fan peng.fan@nxp.com
The SCU API alrdeay has been converted to return Linux error code, using SCU error code is not correct here, although SC_ERR_NONE is value as 0.
Signed-off-by: Peng Fan peng.fan@nxp.com
This causes the following build failure:
aarch64: + colibri-imx8x 304+WARNING 'mx8qx-ahab-container.img' not found, resulting binary is not-functional 305+arch/arm/mach-imx/imx8/cpu.c: In function 'arch_auxiliary_core_up': 306+arch/arm/mach-imx/imx8/cpu.c:249:9: error: 'ret' undeclared (first use in this function) 307+ 249 | ret = sc_pm_set_resource_power_mode(-1, core_rsrc, SC_PM_PW_MODE_ON); 308+ | ^~~ 309+arch/arm/mach-imx/imx8/cpu.c:249:9: note: each undeclared identifier is reported only once for each function it appears in 310+arch/arm/mach-imx/imx8/cpu.c:262:84: error: expected ';' before 'if' 311+ 262 | ret = sc_pm_clock_enable(-1, core_rsrc, SC_PM_CLK_PER, true, false) 312+ | ^ 313+ | ; 314+ 263 | if (ret) { 315+ | ~~ 316+arch/arm/mach-imx/imx8/cpu.c:260:37: error: unused variable 'pd' [-Werror=unused-variable] 317+ 260 | struct power_domain pd; 318+ | ^~ 319+cc1: all warnings being treated as errors 320+make[3]: *** [scripts/Makefile.build:257: arch/arm/mach-imx/imx8/cpu.o] Error 1 321+make[2]: *** [scripts/Makefile.build:398: arch/arm/mach-imx/imx8] Error 2 322+make[1]: *** [Makefile:1907: arch/arm/mach-imx] Error 2 323+make: *** [Makefile:177: sub-make] Error 2
Please make sure to run the patches through CI.

Subject: Re: [PATCH] imx8: Correct the SCU API return value check
On Sat, Oct 5, 2024 at 9:01 PM Peng Fan (OSS) peng.fan@oss.nxp.com wrote:
From: Peng Fan peng.fan@nxp.com
The SCU API alrdeay has been converted to return Linux error code, using SCU error code is not correct here, although SC_ERR_NONE is value as 0.
Signed-off-by: Peng Fan peng.fan@nxp.com
This causes the following build failure:
aarch64: + colibri-imx8x 304+WARNING 'mx8qx-ahab-container.img' not found, resulting binary is not-functional 305+arch/arm/mach-imx/imx8/cpu.c: In function 'arch_auxiliary_core_up': 306+arch/arm/mach-imx/imx8/cpu.c:249:9: error: 'ret' undeclared (first use in this function) 307+ 249 | ret = sc_pm_set_resource_power_mode(-1, core_rsrc, 307+ SC_PM_PW_MODE_ON); 308+ | ^~~ 309+arch/arm/mach-imx/imx8/cpu.c:249:9: note: each undeclared identifier is reported only once for each function it appears in 310+arch/arm/mach-imx/imx8/cpu.c:262:84: error: expected ';' before 'if' 311+ 262 | ret = sc_pm_clock_enable(-1, core_rsrc, SC_PM_CLK_PER, true, 311+ false) 312+ | ^ 313+ | ; 314+ 263 | if (ret) { 315+ | ~~ 316+arch/arm/mach-imx/imx8/cpu.c:260:37: error: unused variable 'pd' [-Werror=unused-variable] 317+ 260 | struct power_domain pd; 318+ | ^~ 319+cc1: all warnings being treated as errors 320+make[3]: *** [scripts/Makefile.build:257: arch/arm/mach-imx/imx8/cpu.o] Error 1 321+make[2]: *** [scripts/Makefile.build:398: arch/arm/mach- imx/imx8] 321+Error 2 322+make[1]: *** [Makefile:1907: arch/arm/mach-imx] Error 2 323+make: *** [Makefile:177: sub-make] Error 2
Please make sure to run the patches through CI.
Ah. I built imx8qm_mek, no issue, but seems indeed issue for 8qxp. I will do more test.
Thanks, Peng.

On Tue, Oct 08, 2024 at 03:01:54PM +0000, Peng Fan wrote:
Subject: Re: [PATCH] imx8: Correct the SCU API return value check
On Sat, Oct 5, 2024 at 9:01 PM Peng Fan (OSS) peng.fan@oss.nxp.com wrote:
From: Peng Fan peng.fan@nxp.com
The SCU API alrdeay has been converted to return Linux error code, using SCU error code is not correct here, although SC_ERR_NONE is value as 0.
Signed-off-by: Peng Fan peng.fan@nxp.com
This causes the following build failure:
aarch64: + colibri-imx8x 304+WARNING 'mx8qx-ahab-container.img' not found, resulting binary is not-functional 305+arch/arm/mach-imx/imx8/cpu.c: In function 'arch_auxiliary_core_up': 306+arch/arm/mach-imx/imx8/cpu.c:249:9: error: 'ret' undeclared (first use in this function) 307+ 249 | ret = sc_pm_set_resource_power_mode(-1, core_rsrc, 307+ SC_PM_PW_MODE_ON); 308+ | ^~~ 309+arch/arm/mach-imx/imx8/cpu.c:249:9: note: each undeclared identifier is reported only once for each function it appears in 310+arch/arm/mach-imx/imx8/cpu.c:262:84: error: expected ';' before 'if' 311+ 262 | ret = sc_pm_clock_enable(-1, core_rsrc, SC_PM_CLK_PER, true, 311+ false) 312+ | ^ 313+ | ; 314+ 263 | if (ret) { 315+ | ~~ 316+arch/arm/mach-imx/imx8/cpu.c:260:37: error: unused variable 'pd' [-Werror=unused-variable] 317+ 260 | struct power_domain pd; 318+ | ^~ 319+cc1: all warnings being treated as errors 320+make[3]: *** [scripts/Makefile.build:257: arch/arm/mach-imx/imx8/cpu.o] Error 1 321+make[2]: *** [scripts/Makefile.build:398: arch/arm/mach- imx/imx8] 321+Error 2 322+make[1]: *** [Makefile:1907: arch/arm/mach-imx] Error 2 323+make: *** [Makefile:177: sub-make] Error 2
Please make sure to run the patches through CI.
Ah. I built imx8qm_mek, no issue, but seems indeed issue for 8qxp. I will do more test.
Before reposting all of the i.MX95 related code please at least locally build all of the imx families, and pushing a branch through Azure CI would be better still, thanks.

-----Original Message----- From: Tom Rini trini@konsulko.com Sent: Tuesday, October 8, 2024 11:09 PM To: Peng Fan peng.fan@nxp.com Cc: Fabio Estevam festevam@gmail.com; Peng Fan (OSS) peng.fan@oss.nxp.com; sbabic@denx.de; u-boot@lists.denx.de; dl- uboot-imx uboot-imx@nxp.com Subject: Re: [PATCH] imx8: Correct the SCU API return value check
On Tue, Oct 08, 2024 at 03:01:54PM +0000, Peng Fan wrote:
Subject: Re: [PATCH] imx8: Correct the SCU API return value check
On Sat, Oct 5, 2024 at 9:01 PM Peng Fan (OSS)
wrote:
From: Peng Fan peng.fan@nxp.com
The SCU API alrdeay has been converted to return Linux error
code,
using SCU error code is not correct here, although SC_ERR_NONE
is
value as 0.
Signed-off-by: Peng Fan peng.fan@nxp.com
This causes the following build failure:
aarch64: + colibri-imx8x 304+WARNING 'mx8qx-ahab-container.img' not found, resulting
binary
is not-functional 305+arch/arm/mach-imx/imx8/cpu.c: In function 'arch_auxiliary_core_up': 306+arch/arm/mach-imx/imx8/cpu.c:249:9: error: 'ret' undeclared (first use in this function) 307+ 249 | ret = sc_pm_set_resource_power_mode(-1, core_rsrc, 307+ SC_PM_PW_MODE_ON); 308+ | ^~~ 309+arch/arm/mach-imx/imx8/cpu.c:249:9: note: each undeclared identifier is reported only once for each function it appears in 310+arch/arm/mach-imx/imx8/cpu.c:262:84: error: expected ';'
before
'if' 311+ 262 | ret = sc_pm_clock_enable(-1, core_rsrc,
SC_PM_CLK_PER,
true, 311+ false) 312+ | ^ 313+ | ; 314+ 263 | if (ret) { 315+ | ~~ 316+arch/arm/mach-imx/imx8/cpu.c:260:37: error: unused
variable
'pd' [-Werror=unused-variable] 317+ 260 | struct power_domain pd; 318+ | ^~ 319+cc1: all warnings being treated as errors 320+make[3]: *** [scripts/Makefile.build:257: arch/arm/mach-imx/imx8/cpu.o] Error 1 321+make[2]: *** [scripts/Makefile.build:398: arch/arm/mach- imx/imx8] 321+Error 2 322+make[1]: *** [Makefile:1907: arch/arm/mach-imx] Error 2 323+make: *** [Makefile:177: sub-make] Error 2
Please make sure to run the patches through CI.
Ah. I built imx8qm_mek, no issue, but seems indeed issue for 8qxp. I will do more test.
Before reposting all of the i.MX95 related code please at least locally build all of the imx families, and pushing a branch through Azure CI would be better still, thanks.
This patch is not for i.MX95, but sure we will do more CI in future patches.
Thanks, Peng.
-- Tom
participants (4)
-
Fabio Estevam
-
Peng Fan
-
Peng Fan (OSS)
-
Tom Rini