Skip to contentSkip to conversation

ARM: imx: imx8m: Adjust thermal trip points for Industrial parts

PATCH In review Adam Ford 4 participants 14 messages May 7, 2022 – May 25, 2022

Subsystems (3)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH v2 1/1 ARM: imx: imx8m: Adjust thermal trip points for Industrial parts

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts. This should apply to 8MQ, 8MM, 8MN, and 8MP.

---
V2: Switch the check from looking for industrial or checkoing for
anything but commerical. This expands the trip point updates other grades as well.

arch/arm/mach-imx/imx8m/soc.c +20 -1
index 8e23e6da32..7175295c3c 100644
@@ -30,6 +30,7 @@
 #include <fsl_wdog.h>
 #include <imx_sip.h>
 #include <linux/bitops.h>
+#include <imx_thermal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1207,10 +1208,10 @@ static int cleanup_nodes_for_efi(void *blob)
 
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+	__maybe_unused int nodeoff;
 #ifdef CONFIG_IMX8MQ
 	int i = 0;
 	int rc;
-	int nodeoff;
 
 	if (get_boot_device() == USB_BOOT) {
 		disable_dcss_nodes(blob);
@@ -1346,6 +1347,24 @@ usb_modify_speed:
 		disable_cpu_nodes(blob, 2);
 #endif
 
+#if defined(CONFIG_IMX_TMU)
+	int minc, maxc, prop;
+
+	nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+
+	/* Only update non-Commerical grade parts */
+	if (get_cpu_temp_grade(&minc, &maxc) != TEMP_COMMERCIAL) {
+		fdt_for_each_subnode(prop, blob, nodeoff) {
+			const char *type = fdt_getprop(blob, prop, "type", NULL);
+
+			if (type && (!strcmp("critical", type)))
+				fdt_setprop_u32(blob, prop, "temperature", maxc * 1000);
+			else if (type && (!strcmp("passive", type)))
+				fdt_setprop_u32(blob, prop, "temperature", (maxc - 10) * 1000);
+		}
+	}
+#endif
+
 	cleanup_nodes_for_efi(blob);
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts. This should apply to 8MQ, 8MM, 8MN, and 8MP.

---
V2: Switch the check from looking for industrial or checkoing for
anything but commerical. This expands the trip point updates other grades as well.

Are the industrial and automotive trip points identical ?

author
#2 lore raw
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts. This should apply to 8MQ, 8MM, 8MN, and 8MP.

Quoted 8 lines
Quoted 6 lines

---
V2: Switch the check from looking for industrial or checkoing for
anything but commerical. This expands the trip point updates other grades as well.

Are the industrial and automotive trip points identical ?

I do not know nor do I have any to test, but Francisco asked for the change. I would expect the corresponding values would be fetched with get_cpu_temp_grade()

I will be on holiday in Italy for the next two weeks, so if there are changes needed, I can address them when I get back.

adam

#3 lore raw
Quoted 14 lines · Adam Ford
Quoted 13 lines · Marek Vasut
Quoted 10 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts. This should apply to 8MQ, 8MM, 8MN, and 8MP.

---
V2: Switch the check from looking for industrial or checkoing for
anything but commerical. This expands the trip point updates other grades as well.

Quoted 5 lines
Quoted 1 line

Are the industrial and automotive trip points identical ?

I do not know nor do I have any to test, but Francisco asked for the change. I would expect the corresponding values would be fetched with get_cpu_temp_grade()

Ah, I see. But then I have to wonder, why are we updating only non-commercial trip points ? Why not update them always ?

#4 lore raw
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Adam Ford
Quoted 13 lines · Marek Vasut
Quoted 10 lines · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal trip points for industrial rated parts. This should apply to 8MQ, 8MM, 8MN, and 8MP.

---
V2: Switch the check from looking for industrial or checkoing for
anything but commerical. This expands the trip point updates other grades as well.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Are the industrial and automotive trip points identical ?

I do not know nor do I have any to test, but Francisco asked for the change. I would expect the corresponding values would be fetched with get_cpu_temp_grade()

Ah, I see. But then I have to wonder, why are we updating only non-commercial trip points ? Why not update them always ?

I didn't think through it enough, I agree on updating the trip points always.

Francesco

#5 lore raw
In reply to Adam Ford

Hi Adam and all,

Thanks for your work. I was about to send a similar patch by myself, but I came up with slightly different code. I'm sending my version for downstream version of NXP (should apply with minor conflicts to upstream) at the end of this mail. Plus some code review.

Quoted 1 line · Adam Ford

If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal

Should be not only for cpu-thermal. See below.

Quoted 3 lines

V2: Switch the check from looking for industrial or checkoing for
anything but commerical. This expands the trip point updates other grades as well.

Typos: checkoing, commerical.

Quoted 1 line

+#include <imx_thermal.h>

Not needed if you drop temp grade check. See below.

Quoted 1 line

+#if defined(CONFIG_IMX_TMU)

I believe this is needed only if you do the temperature reading. get_cpu_temp_grade() does not require this. Please remove.

Review

Quoted 1 line
(quoted diff) +1 -0
+	nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");

This is enough for all variants except 8MP, which has 2 temperature sensors: cpu-thermal and soc-thermal. Both needs to be updated with equal trips.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	/* Only update non-Commerical grade parts */
+	if (get_cpu_temp_grade(&minc, &maxc) != TEMP_COMMERCIAL) {

As others said, I would remove this check, as I don't see any issues if code would set trips for a commercial grade as well. This implies removing the include I mentioned above.

My version which I was going to sent (after rebasing) is below. Feel free to modify/rework/adjust your patch with or without parts from my code.

Quoted 3 lines
Quoted 1 line

Are the industrial and automotive trip points identical ?

I do not know nor do I have any to test...

After you're done with the new patchset I can test it for you. I have access to commercial and industrial variants.

Best regards,
Andrejs Cainikovs

---

arch/arm/mach-imx/imx8m/soc.c +0 -0

index e93ecd28467ccc33ab35f0073840963eb3a01800..d4438b78887b91c600aaf22db47ef8985462ccd8 100644

--- a/arch/arm/mach-imx/imx8m/soc.c

+++ b/arch/arm/mach-imx/imx8m/soc.c

@@ -1001,8 +1001,52 @@ static int disable_cpu_nodes(void *blob, u32 disabled_cores)

return 0;

}

+int fixup_thermal_trips(void *blob, const char *name)

+{

+ int minc, maxc;

+ int node, trip;

+ const char *type;

+ int temp, ret;

+

+ node = fdt_path_offset(blob, "/thermal-zones");

+ if (node < 0)

+ return node;

+

+ node = fdt_subnode_offset(blob, node, name);

+ if (node < 0)

+ return node;

+

+ node = fdt_subnode_offset(blob, node, "trips");

+ if (node < 0)

+ return node;

+

+ get_cpu_temp_grade(&minc, &maxc);

+

+ fdt_for_each_subnode(trip, blob, node) {

+ type = fdt_getprop(blob, trip, "type", NULL);

+

+ temp = 0;

+ if (!strcmp(type, "critical")) {

+ temp = 1000 * maxc;

+ } else if (!strcmp(type, "passive")) {

+ temp = 1000 * (maxc - 10);

+ }

+ if (temp) {

+ ret = fdt_setprop_u32(blob, trip, "temperature", temp);

+ if (ret) {

+ printf("Could not update thermal trip\n");

+ return ret;

+ }

+ }

+ }

+

+ return 0;

+}

+

int ft_system_setup(void *blob, bd_t *bd)

{

+ int ret;

+

#ifdef CONFIG_IMX8MQ

int i = 0;

int rc;

@@ -1128,6 +1172,16 @@ usb_modify_speed:

disable_cpu_nodes(blob, 2);

#endif

+ ret = fixup_thermal_trips(blob, "cpu-thermal");

+#ifdef CONFIG_IMX8MP

+ if (!ret)

+ ret = fixup_thermal_trips(blob, "soc-thermal");

+#endif

+ if (ret) {

+ printf("Failed to update thermal trip\n");

+ return ret;

+ }

+

return ft_add_optee_node(blob, bd);

}

#endif

#6 lore raw

Hi Adam,

Below is the final vesion of my patch after internal review.

Best regards,
Andrejs Cainikovs.

#7 lore raw

PATCH 1/1 imx8m: fixup thermal trips

In reply to Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal grade.

---
 arch/arm/mach-imx/imx8m/soc.c | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +50 -0
index e93ecd2846..b451ece91f 100644
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob, u32 disabled_cores)
 	return 0;
 }
 
+int fixup_thermal_trips(void *blob, const char *name)
+{
+	int minc, maxc;
+	int node, trip;
+
+	node = fdt_path_offset(blob, "/thermal-zones");
+	if (node < 0)
+		return node;
+
+	node = fdt_subnode_offset(blob, node, name);
+	if (node < 0)
+		return node;
+
+	node = fdt_subnode_offset(blob, node, "trips");
+	if (node < 0)
+		return node;
+
+	get_cpu_temp_grade(&minc, &maxc);
+
+	fdt_for_each_subnode(trip, blob, node) {
+		const char *type;
+		int temp, ret;
+
+		type = fdt_getprop(blob, trip, "type", NULL);
+		if (!type)
+			continue;
+
+		temp = 0;
+		if (!strcmp(type, "critical")) {
+			temp = 1000 * maxc;
+		} else if (!strcmp(type, "passive")) {
+			temp = 1000 * (maxc - 10);
+		}
+		if (temp) {
+			ret = fdt_setprop_u32(blob, trip, "temperature", temp);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
 int ft_system_setup(void *blob, bd_t *bd)
 {
 #ifdef CONFIG_IMX8MQ
@@ -1128,6 +1171,13 @@ usb_modify_speed:
 		disable_cpu_nodes(blob, 2);
 #endif
 
+	if (fixup_thermal_trips(blob, "cpu-thermal"))
+		printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+	if (fixup_thermal_trips(blob, "soc-thermal"))
+		printf("Failed to update soc-thermal trip(s)");
+#endif
+
 	return ft_add_optee_node(blob, bd);
 }
 #endif
Signature · 1 line
2.34.1
author
#8 lore raw

Re: [PATCH] imx8m: fixup thermal trips

Quoted 14 lines · Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal grade.

---
 arch/arm/mach-imx/imx8m/soc.c | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +0 -0
index e93ecd2846..b451ece91f 100644

arch/arm/mach-imx/imx8m/soc.c static int disable_cpu_nodes(void *blob, u32 disabled_cores) · line 1004

Quoted 4 lines
arch/arm/mach-imx/imx8m/soc.c +1 -0
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob, u32 disabled_cores)
        return 0;
 }
 
+int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

Quoted 62 lines
arch/arm/mach-imx/imx8m/soc.c +49 -1
+{
+       int minc, maxc;
+       int node, trip;
+
+       node = fdt_path_offset(blob, "/thermal-zones");
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, name);
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, "trips");
+       if (node < 0)
+               return node;
+
+       get_cpu_temp_grade(&minc, &maxc);
+
+       fdt_for_each_subnode(trip, blob, node) {
+               const char *type;
+               int temp, ret;
+
+               type = fdt_getprop(blob, trip, "type", NULL);
+               if (!type)
+                       continue;
+
+               temp = 0;
+               if (!strcmp(type, "critical")) {
+                       temp = 1000 * maxc;
+               } else if (!strcmp(type, "passive")) {
+                       temp = 1000 * (maxc - 10);
+               }
+               if (temp) {
+                       ret = fdt_setprop_u32(blob, trip, "temperature", temp);
+                       if (ret)
+                               return ret;
+               }
+       }
+
+       return 0;
+}
+
 int ft_system_setup(void *blob, bd_t *bd)
 {
 #ifdef CONFIG_IMX8MQ
@@ -1128,6 +1171,13 @@ usb_modify_speed:
                disable_cpu_nodes(blob, 2);
 #endif
 
+       if (fixup_thermal_trips(blob, "cpu-thermal"))
+               printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+       if (fixup_thermal_trips(blob, "soc-thermal"))
+               printf("Failed to update soc-thermal trip(s)");
+#endif
+
        return ft_add_optee_node(blob, bd);
 }
 #endif
--

2.34.1

#9 lore raw

Re: [PATCH] imx8m: fixup thermal trips

Hi Adam,

Quoted 22 lines · Adam Ford
Quoted 20 lines · Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal grade.

---
 arch/arm/mach-imx/imx8m/soc.c | 50
+++++++++++++++++++++++++++++++++++

 1 file changed, 50 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0 -0

imx/imx8m/soc.c
index e93ecd2846..b451ece91f 100644

arch/arm/mach-imx/imx8m/soc.c +0 -0
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob, u32
 disabled_cores)
         return 0;
  }
 
Quoted 3 lines

arch/arm/mach-imx/imx8m/soc.c static int disable_cpu_nodes(void *blob, u32 disabled_cores) · line 1004

Quoted 1 line
arch/arm/mach-imx/imx8m/soc.c +1 -0
+int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

No, this function should be static indeed.

Quoted 65 lines
Quoted 64 lines
arch/arm/mach-imx/imx8m/soc.c +42 -0
+{
+       int minc, maxc;
+       int node, trip;
+
+       node = fdt_path_offset(blob, "/thermal-zones");
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, name);
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, "trips");
+       if (node < 0)
+               return node;
+
+       get_cpu_temp_grade(&minc, &maxc);
+
+       fdt_for_each_subnode(trip, blob, node) {
+               const char *type;
+               int temp, ret;
+
+               type = fdt_getprop(blob, trip, "type", NULL);
+               if (!type)
+                       continue;
+
+               temp = 0;
+               if (!strcmp(type, "critical")) {
+                       temp = 1000 * maxc;
+               } else if (!strcmp(type, "passive")) {
+                       temp = 1000 * (maxc - 10);
+               }
+               if (temp) {
+                       ret = fdt_setprop_u32(blob, trip,
 "temperature", temp);
+                       if (ret)
+                               return ret;
+               }
+       }
+
+       return 0;
+}
+
  int ft_system_setup(void *blob, bd_t *bd)

 {
 #ifdef CONFIG_IMX8MQ

arch/arm/mach-imx/imx8m/soc.c +7 -1
@@ -1128,6 +1171,13 @@ usb_modify_speed:
                 disable_cpu_nodes(blob, 2);
  #endif
 
+       if (fixup_thermal_trips(blob, "cpu-thermal"))
+               printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+       if (fixup_thermal_trips(blob, "soc-thermal"))
+               printf("Failed to update soc-thermal trip(s)");
+#endif
+
         return ft_add_optee_node(blob, bd);
  }
  #endif
--

2.34.1

author Tested-by
#10 lore raw

Re: [PATCH] imx8m: fixup thermal trips

Quoted 26 lines · Andrejs Cainikovs

Hi Adam,

Quoted 22 lines · Adam Ford
Quoted 20 lines · Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal grade.

---
 arch/arm/mach-imx/imx8m/soc.c | 50
+++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0 -0

imx/imx8m/soc.c
index e93ecd2846..b451ece91f 100644

arch/arm/mach-imx/imx8m/soc.c +0 -0
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob, u32
 disabled_cores)
        return 0;
 }
 
Quoted 5 lines
Quoted 3 lines

arch/arm/mach-imx/imx8m/soc.c static int disable_cpu_nodes(void *blob, u32 disabled_cores) · line 1004

Quoted 1 line
arch/arm/mach-imx/imx8m/soc.c +1 -0
+int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

No, this function should be static indeed.

With that change:

Quoted 67 lines
Quoted 66 lines
Quoted 65 lines
arch/arm/mach-imx/imx8m/soc.c +42 -0
+{
+       int minc, maxc;
+       int node, trip;
+
+       node = fdt_path_offset(blob, "/thermal-zones");
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, name);
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, "trips");
+       if (node < 0)
+               return node;
+
+       get_cpu_temp_grade(&minc, &maxc);
+
+       fdt_for_each_subnode(trip, blob, node) {
+               const char *type;
+               int temp, ret;
+
+               type = fdt_getprop(blob, trip, "type", NULL);
+               if (!type)
+                       continue;
+
+               temp = 0;
+               if (!strcmp(type, "critical")) {
+                       temp = 1000 * maxc;
+               } else if (!strcmp(type, "passive")) {
+                       temp = 1000 * (maxc - 10);
+               }
+               if (temp) {
+                       ret = fdt_setprop_u32(blob, trip,
 "temperature", temp);
+                       if (ret)
+                               return ret;
+               }
+       }
+
+       return 0;
+}
+
 int ft_system_setup(void *blob, bd_t *bd)

{
#ifdef CONFIG_IMX8MQ

arch/arm/mach-imx/imx8m/soc.c +7 -1
@@ -1128,6 +1171,13 @@ usb_modify_speed:
                disable_cpu_nodes(blob, 2);
 #endif
 
+       if (fixup_thermal_trips(blob, "cpu-thermal"))
+               printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+       if (fixup_thermal_trips(blob, "soc-thermal"))
+               printf("Failed to update soc-thermal trip(s)");
+#endif
+
        return ft_add_optee_node(blob, bd);
 }
 #endif
--

2.34.1

#11 lore raw

Re: [PATCH] imx8m: fixup thermal trips

Adam,

So you want me to rebase this patch to upstream, update according to your review, and send this one instead of yours?

Best regards,
Andrejs Cainikovs.

Quoted 109 lines · Adam Ford
Quoted 29 lines · Andrejs Cainikovs

Hi Adam,

Quoted 25 lines · Adam Ford
Quoted 23 lines · Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal
grade.

Signed-off-by: Andrejs Cainikovs
<[email protected]>
---
 arch/arm/mach-imx/imx8m/soc.c | 50
+++++++++++++++++++++++++++++++++++

 1 file changed, 50 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0 -0

imx/imx8m/soc.c
index e93ecd2846..b451ece91f 100644

arch/arm/mach-imx/imx8m/soc.c +0 -0
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob,

u32
disabled_cores)
        return 0;
 }

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

No, this function should be static indeed.

With that change:

Quoted 67 lines
Quoted 66 lines
Quoted 65 lines
arch/arm/mach-imx/imx8m/soc.c +34 -0
+{
+       int minc, maxc;
+       int node, trip;
+
+       node = fdt_path_offset(blob, "/thermal-zones");
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, name);
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, "trips");
+       if (node < 0)
+               return node;
+
+       get_cpu_temp_grade(&minc, &maxc);
+
+       fdt_for_each_subnode(trip, blob, node) {
+               const char *type;
+               int temp, ret;
+
+               type = fdt_getprop(blob, trip, "type", NULL);
+               if (!type)
+                       continue;
+
+               temp = 0;
+               if (!strcmp(type, "critical")) {
+                       temp = 1000 * maxc;
+               } else if (!strcmp(type, "passive")) {
+                       temp = 1000 * (maxc - 10);
+               }
+               if (temp) {
+                       ret = fdt_setprop_u32(blob, trip,

"temperature", temp);
+                       if (ret)
+                               return ret;
+               }
+       }

arch/arm/mach-imx/imx8m/soc.c +4 -0
+
+       return 0;
+}
+

 int ft_system_setup(void *blob, bd_t *bd)
 {
 #ifdef CONFIG_IMX8MQ

arch/arm/mach-imx/imx8m/soc.c +7 -1
@@ -1128,6 +1171,13 @@ usb_modify_speed:
                 disable_cpu_nodes(blob, 2);
  #endif
 
+       if (fixup_thermal_trips(blob, "cpu-thermal"))
+               printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+       if (fixup_thermal_trips(blob, "soc-thermal"))
+               printf("Failed to update soc-thermal trip(s)");
+#endif
+
         return ft_add_optee_node(blob, bd);
  }
  #endif
--

2.34.1

author
#12 lore raw

Re: [PATCH] imx8m: fixup thermal trips

Quoted 5 lines · Andrejs Cainikovs

Adam,

So you want me to rebase this patch to upstream, update according to your review, and send this one instead of yours?

Go ahead. Yours has all the requested improvements already applied. I'm still playing catch up from being away for 2 weeks.

thanks

adam

Quoted 115 lines

Best regards,
Andrejs Cainikovs.

Quoted 109 lines · Adam Ford
Quoted 29 lines · Andrejs Cainikovs

Hi Adam,

Quoted 25 lines · Adam Ford
Quoted 23 lines · Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal
grade.

Signed-off-by: Andrejs Cainikovs
<[email protected]>

---
 arch/arm/mach-imx/imx8m/soc.c | 50
+++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0 -0

imx/imx8m/soc.c
index e93ecd2846..b451ece91f 100644

arch/arm/mach-imx/imx8m/soc.c +0 -0
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void *blob,

u32
disabled_cores)

        return 0;

}

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

No, this function should be static indeed.

With that change:

Quoted 67 lines
Quoted 66 lines
Quoted 65 lines
arch/arm/mach-imx/imx8m/soc.c +34 -0
+{
+       int minc, maxc;
+       int node, trip;
+
+       node = fdt_path_offset(blob, "/thermal-zones");
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, name);
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, "trips");
+       if (node < 0)
+               return node;
+
+       get_cpu_temp_grade(&minc, &maxc);
+
+       fdt_for_each_subnode(trip, blob, node) {
+               const char *type;
+               int temp, ret;
+
+               type = fdt_getprop(blob, trip, "type", NULL);
+               if (!type)
+                       continue;
+
+               temp = 0;
+               if (!strcmp(type, "critical")) {
+                       temp = 1000 * maxc;
+               } else if (!strcmp(type, "passive")) {
+                       temp = 1000 * (maxc - 10);
+               }
+               if (temp) {
+                       ret = fdt_setprop_u32(blob, trip,

"temperature", temp);

arch/arm/mach-imx/imx8m/soc.c +15 -1
+                       if (ret)
+                               return ret;
+               }
+       }
+
+       return 0;
+}
+
 int ft_system_setup(void *blob, bd_t *bd)
 {
 #ifdef CONFIG_IMX8MQ
@@ -1128,6 +1171,13 @@ usb_modify_speed:
                disable_cpu_nodes(blob, 2);
 #endif
 
+       if (fixup_thermal_trips(blob, "cpu-thermal"))
+               printf("Failed to update cpu-thermal trip(s)");
+#ifdef CONFIG_IMX8MP
+       if (fixup_thermal_trips(blob, "soc-thermal"))
+               printf("Failed to update soc-thermal trip(s)");
+#endif
+
        return ft_add_optee_node(blob, bd);
 }
 #endif
--

2.34.1

#13 lore raw

Re: [PATCH] imx8m: fixup thermal trips

Quoted 11 lines · Adam Ford
Quoted 6 lines · Andrejs Cainikovs

Adam,

So you want me to rebase this patch to upstream, update according to
your review, and send this one instead of yours?

Go ahead.  Yours has all the requested improvements already applied. I'm still playing catch up from being away for 2 weeks.

Ok, will do. Thanks.

Quoted 124 lines

thanks

adam

Quoted 119 lines

Best regards,
Andrejs Cainikovs.

Quoted 113 lines · Adam Ford
Quoted 30 lines · Andrejs Cainikovs

Hi Adam,

Quoted 26 lines · Adam Ford
Quoted 24 lines · Andrejs Cainikovs

Fixup thermal trips in Linux device tree according to SoC thermal
grade.

Signed-off-by: Andrejs Cainikovs
<[email protected]>
---
 arch/arm/mach-imx/imx8m/soc.c | 50
+++++++++++++++++++++++++++++++++++

 1 file changed, 50 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0 -0

imx/imx8m/soc.c
index e93ecd2846..b451ece91f 100644

arch/arm/mach-imx/imx8m/soc.c +0 -0
@@ -1001,6 +1001,49 @@ static int disable_cpu_nodes(void
 *blob,

u32
disabled_cores)
        return 0;
 }

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+int fixup_thermal_trips(void *blob, const char *name)

Is there any reason this function cannot be static?

No, this function should be static indeed.

With that change:

Quoted 70 lines
Quoted 69 lines
Quoted 68 lines
arch/arm/mach-imx/imx8m/soc.c +23 -0
+{
+       int minc, maxc;
+       int node, trip;
+
+       node = fdt_path_offset(blob, "/thermal-zones");
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, name);
+       if (node < 0)
+               return node;
+
+       node = fdt_subnode_offset(blob, node, "trips");
+       if (node < 0)
+               return node;
+
+       get_cpu_temp_grade(&minc, &maxc);
+
+       fdt_for_each_subnode(trip, blob, node) {
+               const char *type;
+               int temp, ret;
+
+               type = fdt_getprop(blob, trip, "type",

NULL);
+               if (!type)
+                       continue;
+
+               temp = 0;
+               if (!strcmp(type, "critical")) { +                       temp = 1000 * maxc;
+               } else if (!strcmp(type, "passive")) { +                       temp = 1000 * (maxc - 10); +               }
+               if (temp) {
+                       ret = fdt_setprop_u32(blob, trip, "temperature", temp);
+                       if (ret)
+                               return ret;
+               }
+       }

arch/arm/mach-imx/imx8m/soc.c +4 -0
+
+       return 0;
+}
+

 int ft_system_setup(void *blob, bd_t *bd)
 {
 #ifdef CONFIG_IMX8MQ

arch/arm/mach-imx/imx8m/soc.c +7 -0
@@ -1128,6 +1171,13 @@ usb_modify_speed:
                 disable_cpu_nodes(blob, 2);
  #endif
 
+       if (fixup_thermal_trips(blob, "cpu-thermal"))
+               printf("Failed to update cpu-thermal
 trip(s)");
+#ifdef CONFIG_IMX8MP
+       if (fixup_thermal_trips(blob, "soc-thermal"))
+               printf("Failed to update soc-thermal
 trip(s)");
+#endif
+
         return ft_add_optee_node(blob, bd);

 }
 #endif
--
2.34.1