imx: mach: imx8: fdt: fix industrial GPU frequencies
Subsystems (3)
cover imx: mach: imx8: fdt: fix industrial GPU frequencies
On the industrial i.MX 8 variant, U-Boot limits the GPU clocks to 625 MHz by patching the device tree of the kernel. This series fixes two issues with that code.
The first patch makes the helpers return the libfdt error codes, so missing nodes are ignored again and real errors are printed with a meaningful message. Before, booting a device tree without the GPU1 nodes printed a misleading error:
Failed to set assigned-clock-rates for GPU1: FDT_ERR_BADPHANDLE
The second patch adds support for the GPU0 bus node name used by mainline Linux and NXP downstream kernels starting with 6.18 (bus@53000000 instead of bus@53100000). Without it, GPU0 runs at the default 700/850 MHz instead of the 625 MHz limit of the industrial SoC.
Stefan Eichenberger (2):
imx: mach: imx8: fdt: return libfdt errors from helpers
imx: mach: imx8: fdt: support newer GPU0 bus node name
arch/arm/mach-imx/imx8/fdt.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
Signature · 1 line
2.56.0
PATCH 1/2 imx: mach: imx8: fdt: return libfdt errors from helpers
From: Stefan Eichenberger <[email protected]>
delete_node() and change_property() replaced the libfdt error codes with -ENXIO and -EINVAL, but the callers pass the result to fdt_strerror(), which expects a libfdt error code. In addition, update_fdt_gpu_industrial_frequencies() compared the result against the positive ENXIO, so a missing node was reported as an error instead of being ignored.
On an industrial i.MX 8 booted with a device tree that lacks the GPU1 nodes (e.g. mainline Linux), a misleading error is printed on every boot because -ENXIO is interpreted by fdt_strerror() as a libfdt error code, e.g.:
Failed to set assigned-clock-rates for GPU1: FDT_ERR_BADPHANDLE
Return the libfdt error codes unchanged and ignore -FDT_ERR_NOTFOUND, which fdt_path_offset() returns if the node does not exist.
--- arch/arm/mach-imx/imx8/fdt.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
arch/arm/mach-imx/imx8/fdt.c +9 -19
@@ -281,34 +281,24 @@ static int ft_add_optee_node(void *fdt, struct bd_info *bd)static int delete_node (void *blob,const char *node) {int nodeoffset; -int err; nodeoffset =fdt_path_offset (blob, node);if (nodeoffset <0 ) -return -ENXIO ; - - err =fdt_del_node (blob, nodeoffset); -if (err) -return -EINVAL ; +return nodeoffset; -return 0 ; +return fdt_del_node (blob, nodeoffset); }static int change_property (void *blob,const char *node,const char *property,const void *value,int len) {int nodeoffset; -int err; nodeoffset =fdt_path_offset (blob, node);if (nodeoffset <0 ) -return -ENXIO ; - - err =fdt_setprop (blob, nodeoffset, property, value, len); -if (err) -return -EINVAL ; +return nodeoffset; -return 0 ; +return fdt_setprop (blob, nodeoffset, property, value, len); }static void update_fdt_gpu_industrial_frequencies (void *blob)
@@ -330,21 +320,21 @@ static void update_fdt_gpu_industrial_frequencies(void *blob) err =change_property (blob,"/bus@53100000/gpu@53100000" ,"assigned-clock-rates" , gpu_assigned_clocks,sizeof (gpu_assigned_clocks)); -if (err && err !=ENXIO ) +if (err && err != -FDT_ERR_NOTFOUND )printf ("Failed to set assigned-clock-rates for GPU0: %s\n" ,fdt_strerror (err)); err =change_property (blob,"/bus@54100000/gpu@54100000" ,"assigned-clock-rates" , gpu_assigned_clocks,sizeof (gpu_assigned_clocks)); -if (err && err !=ENXIO ) +if (err && err != -FDT_ERR_NOTFOUND )printf ("Failed to set assigned-clock-rates for GPU1: %s\n" ,fdt_strerror (err)); err =change_property (blob,"/bus@54100000/imx8_gpu1_ss@80000000" ,"operating-points" , &gpu_opp_table,sizeof (gpu_opp_table)); -if (err && err !=ENXIO ) +if (err && err != -FDT_ERR_NOTFOUND )printf ("Failed to set operating-points for GPU: %s\n" ,fdt_strerror (err)); }
@@ -354,12 +344,12 @@ static void update_fdt_cpu_industrial_frequencies(void *blob)int err; err =delete_node (blob,"/opp-table-0/opp-1200000000" ); -if (err && err != -ENXIO ) +if (err && err != -FDT_ERR_NOTFOUND )printf ("Failed to delete 1.2 GHz node on A53: %s\n" ,fdt_strerror (err)); err =delete_node (blob,"/opp-table-1/opp-1596000000" ); -if (err && err != -ENXIO ) +if (err && err != -FDT_ERR_NOTFOUND )printf ("Failed to delete 1.596 GHz node on A72: %s\n" ,fdt_strerror (err)); }
Signature · 1 line
2.56.0
Re: [PATCH v1 1/2] imx: mach: imx8: fdt: return libfdt errors from helpers
Quoted 14 lines · Stefan Eichenberger
From: Stefan Eichenberger <[email protected]>
delete_node()andchange_property()replaced the libfdt error codes with-ENXIOand-EINVAL, but the callers pass the result tofdt_strerror(), which expects a libfdt error code. In addition,update_fdt_gpu_industrial_frequencies()compared the result against the positive ENXIO, so a missing node was reported as an error instead of being ignored.On an industrial i.MX 8 booted with a device tree that lacks the GPU1 nodes (e.g. mainline Linux), a misleading error is printed on every boot because
-ENXIOis interpreted byfdt_strerror()as a libfdt error code, e.g.:
Quoted 7 lines
Failed to set assigned-clock-rates for GPU1:
FDT_ERR_BADPHANDLEReturn the libfdt error codes unchanged and ignore -FDT_ERR_NOTFOUND, which
fdt_path_offset()returns if the node does not exist.Fixes e9cf7f515a19 ("imx: mach: imx8: fdt: set correct frequencies for the industrial SoC")Signed-off-by Stefan Eichenberger <[email protected]>
PATCH 2/2 imx: mach: imx8: fdt: support newer GPU0 bus node name
In reply to Stefan EichenbergerFrom: Stefan Eichenberger <[email protected]>
Mainline Linux and NXP downstream kernels starting with 6.18 name the GPU0 subsystem bus@53000000, while older downstream kernels used bus@53100000. Because of that, the industrial GPU clock rates were not applied and GPU0 kept running at the default 700/850 MHz instead of the 625 MHz limit of the industrial SoC.
Use /bus@53000000/gpu@53100000 and, if it does not exist, fall back to the legacy /bus@53100000/gpu@53100000.
--- arch/arm/mach-imx/imx8/fdt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/mach-imx/imx8/fdt.c +6 -1
@@ -317,9 +317,14 @@ static void update_fdt_gpu_industrial_frequencies(void *blob) gpu_assigned_clocks[0 ] =cpu_to_fdt32 (625000000 );/* Core Clock */ gpu_assigned_clocks[1 ] =cpu_to_fdt32 (625000000 );/* Shader Clock */ - err =change_property (blob,"/bus@53100000/gpu@53100000" , + err =change_property (blob,"/bus@53000000/gpu@53100000" ,"assigned-clock-rates" , gpu_assigned_clocks,sizeof (gpu_assigned_clocks)); +/* NXP kernels before 6.18 use bus@53100000 */ +if (err == -FDT_ERR_NOTFOUND ) + err =change_property (blob,"/bus@53100000/gpu@53100000" , +"assigned-clock-rates" , gpu_assigned_clocks, +sizeof (gpu_assigned_clocks));if (err && err != -FDT_ERR_NOTFOUND )printf ("Failed to set assigned-clock-rates for GPU0: %s\n" ,fdt_strerror (err));
Signature · 1 line
2.56.0
Re: [PATCH v1 2/2] imx: mach: imx8: fdt: support newer GPU0 bus node name
Quoted 8 lines · Stefan Eichenberger
From: Stefan Eichenberger <[email protected]>
Mainline Linux and NXP downstream kernels starting with 6.18 name the GPU0 subsystem bus@53000000, while older downstream kernels used bus@53100000. Because of that, the industrial GPU clock rates were not applied and GPU0 kept running at the default 700/850 MHz instead of the 625 MHz limit of the industrial SoC.
Quoted 4 lines
Use /bus@53000000/gpu@53100000 and, if it does not exist, fall back to the legacy /bus@53100000/gpu@53100000.
Signed-off-by Stefan Eichenberger <[email protected]>