Message ID | 20220617071411.187542-1-francesco.dolcini@toradex.com |
---|---|
Headers | show |
Series | imx: thermal: Allow trip point configuration from DT | expand |
> Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point configuration > from DT > > This series allows to specify the imx thermal drivers trip point from the device > tree, without this change the threshold are hard-coded and this might not be > correct given the thermal design of the final system. > The threshold is set dynamically based on the part market temp grade. I am little confused why need to specify it in DT? I saw in 'PATCH 5/9', you provide a threshold table based temp grade, why not use the threshold from ' imx_init_temp_grade'? BR Jacky Bai > This change is backward compatible with the existing device tree, and even > with this change in by default the thresholds are the same as before. > > Toradex board are also updated to use a system-specific thresholds. > > Discussion on the current design is here: > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.ke > rnel.org%2Fall%2F4ba1d7d2-3e8c-ba60-37fd-9598f415c076%40linaro.org%2 > F&data=05%7C01%7Cping.bai%40nxp.com%7C3bd9173c93184270acee > 08da5030fdfb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6379 > 10468593014918%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAi > LCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C& > amp;sdata=L0T4514vcK0Nl1Vv9EVNdhDJMpBGqIRP68GFKVeBvwg%3D& > ;reserved=0 > > One side note, after this change the dtbs checker starts complaining with this > message > > ``` > linux/arch/arm/boot/dts/imx6dl-alti6p.dtb: tempmon: > '#thermal-sensor-cells' does not match any of the regexes: > '^(automotive|commercial|extended-commercial|industrial)-thermal$', > 'pinctrl-[0-9]+' > From schema: > linux/Documentation/devicetree/bindings/thermal/imx-thermal.yaml > ``` > > to my understanding this is just a side effect, '#thermal-sensor-cells' is not > changed in any way by this series. I can fix that, I wonder if I should remove > the property from the imx dtsi files or add it to the binding yaml definition, not > sure about it. > Anybody can advise? > > Changes in v2: > - fix build error without CONFIG_THERMAL_OF > - more verbose error reporting in case the dts is not correct > - additional comment on the threshold fixup in case the passive threshold is > higher than critical > - while parsing the dts thermal, return immediately if the node is not there > > > Francesco Dolcini (9): > dt-bindings: thermal: Define trips node in $defs > thermal: thermal: Export OF trip helper function > dt-bindings: thermal: imx: Add trips point > imx: thermal: Configure trip point from DT > ARM: dts: imx[67]: Add trips points > ARM: dts: imx6qdl-apalis: Set CPU critical trip point > ARM: dts: imx7-colibri: Set CPU critical trip point > ARM: dts: imx6ull-colibri: Set CPU critical trip point > ARM: dts: imx6qdl-colibri: Set CPU critical trip point > > .../bindings/thermal/imx-thermal.yaml | 27 ++++ > .../bindings/thermal/thermal-zones.yaml | 130 +++++++++--------- > arch/arm/boot/dts/imx-thermal.dtsi | 61 ++++++++ > arch/arm/boot/dts/imx6qdl-apalis.dtsi | 12 ++ > arch/arm/boot/dts/imx6qdl-colibri.dtsi | 12 ++ > arch/arm/boot/dts/imx6qdl.dtsi | 2 + > arch/arm/boot/dts/imx6sl.dtsi | 2 + > arch/arm/boot/dts/imx6sll.dtsi | 2 + > arch/arm/boot/dts/imx6sx.dtsi | 2 + > arch/arm/boot/dts/imx6ul.dtsi | 2 + > arch/arm/boot/dts/imx6ull-colibri.dtsi | 12 ++ > arch/arm/boot/dts/imx7-colibri.dtsi | 12 ++ > arch/arm/boot/dts/imx7s.dtsi | 2 + > drivers/thermal/imx_thermal.c | 58 ++++++++ > drivers/thermal/thermal_core.h | 7 + > drivers/thermal/thermal_of.c | 5 +- > 16 files changed, 283 insertions(+), 65 deletions(-) create mode 100644 > arch/arm/boot/dts/imx-thermal.dtsi > > -- > 2.25.1
Hello Jacky, On Fri, Jun 17, 2022 at 07:31:25AM +0000, Jacky Bai wrote: > > Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point configuration > > from DT > > > > This series allows to specify the imx thermal drivers trip point from the device > > tree, without this change the threshold are hard-coded and this might not be > > correct given the thermal design of the final system. > > > > The threshold is set dynamically based on the part market temp grade. > I am little confused why need to specify it in DT? I saw in 'PATCH > 5/9', you provide a threshold table based temp grade, why not use the > threshold from ' imx_init_temp_grade'? The problem with the existing temperature thresholds is that they are hard-coded into the driver, there is no way to change those to match the actual final system thermal design. After various discussions [1][2] with Marco, Daniel and Lucas it was agreed that the actual trip is indeed a system property and therefore should be described in the device tree. This series make it possible in a backward compatible way, this new possibility is than used to override the threshold in some system-specific dts (see patches 6,7,8 and 9). Francesco [1] https://lore.kernel.org/all/20220420091300.179753-1-francesco.dolcini@toradex.com/ [2] https://lore.kernel.org/all/20220516190001.147919-1-francesco.dolcini@toradex.com/
Hi Francesco, > Subject: Re: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point > configuration from DT > > Hello Jacky, > > On Fri, Jun 17, 2022 at 07:31:25AM +0000, Jacky Bai wrote: > > > Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point > > > configuration from DT > > > > > > This series allows to specify the imx thermal drivers trip point > > > from the device tree, without this change the threshold are > > > hard-coded and this might not be correct given the thermal design of the > final system. > > > > > > > The threshold is set dynamically based on the part market temp grade. > > I am little confused why need to specify it in DT? I saw in 'PATCH > > 5/9', you provide a threshold table based temp grade, why not use the > > threshold from ' imx_init_temp_grade'? > > The problem with the existing temperature thresholds is that they are > hard-coded into the driver, there is no way to change those to match the > actual final system thermal design. > > After various discussions [1][2] with Marco, Daniel and Lucas it was agreed > that the actual trip is indeed a system property and therefore should be > described in the device tree. This series make it possible in a backward > compatible way, this new possibility is than used to override the threshold in > some system-specific dts (see patches 6,7,8 and 9). > Thx. Yes, in current driver design, the critical trip is fixed at 5 Celsius lower than the MAX limited. So the purpose of this patch is just want to override this limitation to adjust it based on system need? BR Jacky Bai > Francesco >
On Fri, Jun 17, 2022 at 07:51:53AM +0000, Jacky Bai wrote: > > On Fri, Jun 17, 2022 at 07:31:25AM +0000, Jacky Bai wrote: > > > > Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point > > > > configuration from DT > > > > > > > > This series allows to specify the imx thermal drivers trip point > > > > from the device tree, without this change the threshold are > > > > hard-coded and this might not be correct given the thermal design of the > > final system. > > > > > > > > > > The threshold is set dynamically based on the part market temp grade. > > > I am little confused why need to specify it in DT? I saw in 'PATCH > > > 5/9', you provide a threshold table based temp grade, why not use the > > > threshold from ' imx_init_temp_grade'? > > > > The problem with the existing temperature thresholds is that they are > > hard-coded into the driver, there is no way to change those to match the > > actual final system thermal design. > > > > After various discussions [1][2] with Marco, Daniel and Lucas it was agreed > > that the actual trip is indeed a system property and therefore should be > > described in the device tree. This series make it possible in a backward > > compatible way, this new possibility is than used to override the threshold in > > some system-specific dts (see patches 6,7,8 and 9). > > > > Thx. Yes, in current driver design, the critical trip is fixed at 5 Celsius lower than the MAX limited. > So the purpose of this patch is just want to override this limitation to adjust it based on system need? Correct (including the passive trip, for completeness). Francesco
Hi Francesco, On 17. 06. 22 9:55, Francesco Dolcini wrote: > On Fri, Jun 17, 2022 at 07:51:53AM +0000, Jacky Bai wrote: >>> On Fri, Jun 17, 2022 at 07:31:25AM +0000, Jacky Bai wrote: >>>>> Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point >>>>> configuration from DT >>>>> >>>>> This series allows to specify the imx thermal drivers trip point >>>>> from the device tree, without this change the threshold are >>>>> hard-coded and this might not be correct given the thermal design of the >>> final system. >>>>> >>>> >>>> The threshold is set dynamically based on the part market temp grade. >>>> I am little confused why need to specify it in DT? I saw in 'PATCH >>>> 5/9', you provide a threshold table based temp grade, why not use the >>>> threshold from ' imx_init_temp_grade'? >>> >>> The problem with the existing temperature thresholds is that they are >>> hard-coded into the driver, there is no way to change those to match the >>> actual final system thermal design. AFAIK you can change the trip point from user space if you build with THERMAL_WRITABLE_TRIPS so in fact you can adapt it to the final system design. We did exactly that when we swapped imx6 dual for imx6 quad but did not have enough space for adequate heat sink. I do not want to question usefulness of this series though, I agree with the idea. Michal
Hi Francesco, thanks for your patch. On 22-06-17, Francesco Dolcini wrote: > Allow over-writing critical and passive trip point for each > temperature grade from the device tree, by default the pre-existing > hard-coded trip points are used. > > This change enables configuring the system thermal characteristics into > the system-specific device tree instead of relying on global hard-coded > temperature thresholds that does not take into account the specific > system thermal design. > > Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> > --- > v2: > - return immediately if no thermal node present in the dts > - use dev_info instead of dev_dbg if there is an invalid trip > - additional comment in case passive trip point is higher than critical > --- > drivers/thermal/imx_thermal.c | 58 +++++++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c > index 16663373b682..a964baf802fc 100644 > --- a/drivers/thermal/imx_thermal.c > +++ b/drivers/thermal/imx_thermal.c > @@ -17,6 +17,8 @@ > #include <linux/nvmem-consumer.h> > #include <linux/pm_runtime.h> > > +#include "thermal_core.h" > + > #define REG_SET 0x4 > #define REG_CLR 0x8 > #define REG_TOG 0xc > @@ -479,36 +481,92 @@ static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1) > return 0; > } > > +static void imx_init_temp_from_of(struct platform_device *pdev, const char *name) > +{ > + struct imx_thermal_data *data = platform_get_drvdata(pdev); > + struct device_node *thermal, *trips, *trip_point; > + > + thermal = of_get_child_by_name(pdev->dev.of_node, name); > + if (!thermal) > + return; > + > + trips = of_get_child_by_name(thermal, "trips"); > + > + for_each_child_of_node(trips, trip_point) { > + struct thermal_trip t; > + > + if (thermal_of_populate_trip(trip_point, &t)) > + continue; > + > + switch (t.type) { > + case THERMAL_TRIP_PASSIVE: > + data->temp_passive = t.temperature; > + break; > + case THERMAL_TRIP_CRITICAL: Should we check also the temp_critical and temp_passive not exceeding the temp_max? Sry. that it came not earlier in my mind. So system damage is avoided. Apart of this note, the patch is lgtm. Regards, Marco > + data->temp_critical = t.temperature; > + break; > + default: > + dev_info(&pdev->dev, "Ignoring trip type %d\n", t.type); > + break; > + } > + }; > + > + of_node_put(trips); > + of_node_put(thermal); > + > + if (data->temp_passive >= data->temp_critical) { > + dev_warn(&pdev->dev, > + "passive trip point must be lower than critical, fixing it up\n"); > + /* > + * In case of misconfiguration set passive temperature to > + * 5°C less than critical, this seems like a reasonable > + * default and the same is done when no thermal trips are > + * available in the device tree. > + */ > + data->temp_passive = data->temp_critical - (1000 * 5); > + } > +} > + > static void imx_init_temp_grade(struct platform_device *pdev, u32 ocotp_mem0) > { > struct imx_thermal_data *data = platform_get_drvdata(pdev); > + const char *thermal_node_name; > > /* The maximum die temp is specified by the Temperature Grade */ > switch ((ocotp_mem0 >> 6) & 0x3) { > case 0: /* Commercial (0 to 95 °C) */ > + thermal_node_name = "commercial-thermal"; > data->temp_grade = "Commercial"; > data->temp_max = 95000; > break; > case 1: /* Extended Commercial (-20 °C to 105 °C) */ > + thermal_node_name = "extended-commercial-thermal"; > data->temp_grade = "Extended Commercial"; > data->temp_max = 105000; > break; > case 2: /* Industrial (-40 °C to 105 °C) */ > + thermal_node_name = "industrial-thermal"; > data->temp_grade = "Industrial"; > data->temp_max = 105000; > break; > case 3: /* Automotive (-40 °C to 125 °C) */ > + thermal_node_name = "automotive-thermal"; > data->temp_grade = "Automotive"; > data->temp_max = 125000; > break; > } > > /* > + * Set defaults trips > + * > * Set the critical trip point at 5 °C under max > * Set the passive trip point at 10 °C under max (changeable via sysfs) > */ > data->temp_critical = data->temp_max - (1000 * 5); > data->temp_passive = data->temp_max - (1000 * 10); > + > + /* Override critical/passive temperature from devicetree */ > + imx_init_temp_from_of(pdev, thermal_node_name); > } > > static int imx_init_from_tempmon_data(struct platform_device *pdev) > -- > 2.25.1 > >
On Fri, Jun 17, 2022 at 10:40:17AM +0200, Marco Felsch wrote: > On 22-06-17, Francesco Dolcini wrote: > > Allow over-writing critical and passive trip point for each > > temperature grade from the device tree, by default the pre-existing > > hard-coded trip points are used. > > > > This change enables configuring the system thermal characteristics into > > the system-specific device tree instead of relying on global hard-coded > > temperature thresholds that does not take into account the specific > > system thermal design. > > > > Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> > > --- > > v2: > > - return immediately if no thermal node present in the dts > > - use dev_info instead of dev_dbg if there is an invalid trip > > - additional comment in case passive trip point is higher than critical > > --- > > drivers/thermal/imx_thermal.c | 58 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 58 insertions(+) > > > > diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c > > index 16663373b682..a964baf802fc 100644 > > --- a/drivers/thermal/imx_thermal.c > > +++ b/drivers/thermal/imx_thermal.c > > @@ -17,6 +17,8 @@ > > #include <linux/nvmem-consumer.h> > > #include <linux/pm_runtime.h> > > > > +#include "thermal_core.h" > > + > > #define REG_SET 0x4 > > #define REG_CLR 0x8 > > #define REG_TOG 0xc > > @@ -479,36 +481,92 @@ static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1) > > return 0; > > } > > > > +static void imx_init_temp_from_of(struct platform_device *pdev, const char *name) > > +{ > > + struct imx_thermal_data *data = platform_get_drvdata(pdev); > > + struct device_node *thermal, *trips, *trip_point; > > + > > + thermal = of_get_child_by_name(pdev->dev.of_node, name); > > + if (!thermal) > > + return; > > + > > + trips = of_get_child_by_name(thermal, "trips"); > > + > > + for_each_child_of_node(trips, trip_point) { > > + struct thermal_trip t; > > + > > + if (thermal_of_populate_trip(trip_point, &t)) > > + continue; > > + > > + switch (t.type) { > > + case THERMAL_TRIP_PASSIVE: > > + data->temp_passive = t.temperature; > > + break; > > + case THERMAL_TRIP_CRITICAL: > > Should we check also the temp_critical and temp_passive not exceeding > the temp_max? Sry. that it came not earlier in my mind. So system damage > is avoided. I would not add such kind of restriction in the code. I can think of multiple situations in which a system designer would prefer to take the chances of burning a silicon (or more likely just age it a little bit faster) than to just shut down the system. In the end whoever is building the system should be empowered to do something like that and it's no different from what it's already possible with thermal_of driver for example. In addition to that from a system debug prospective all the threshold (max, passive, critical) are already available in the kernel logs. Francesco
Hello Michal, On Fri, Jun 17, 2022 at 10:36:17AM +0200, Michal Vokáč wrote: > On 17. 06. 22 9:55, Francesco Dolcini wrote: > > On Fri, Jun 17, 2022 at 07:51:53AM +0000, Jacky Bai wrote: > > > > On Fri, Jun 17, 2022 at 07:31:25AM +0000, Jacky Bai wrote: > > > > > > Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point > > > > > > configuration from DT > > > > > > > > > > > > This series allows to specify the imx thermal drivers trip point > > > > > > from the device tree, without this change the threshold are > > > > > > hard-coded and this might not be correct given the thermal design of the > > > > final system. > > > > > > > > > > > > > > > > The threshold is set dynamically based on the part market temp grade. > > > > > I am little confused why need to specify it in DT? I saw in 'PATCH > > > > > 5/9', you provide a threshold table based temp grade, why not use the > > > > > threshold from ' imx_init_temp_grade'? > > > > > > > > The problem with the existing temperature thresholds is that they are > > > > hard-coded into the driver, there is no way to change those to match the > > > > actual final system thermal design. > > AFAIK you can change the trip point from user space if you build > with THERMAL_WRITABLE_TRIPS so in fact you can adapt it to the final > system design. > > We did exactly that when we swapped imx6 dual for imx6 quad but did not > have enough space for adequate heat sink. When I investigated this only the passive threshold was writeable from user-space/sysfs, and Daniel was against any patch to allow changing also the critical one [0]. Francesco [0] https://lore.kernel.org/all/4de41b5e-1fa6-ece4-9d9a-2656d399b452@linaro.org/
On 22-06-17, Francesco Dolcini wrote: > On Fri, Jun 17, 2022 at 10:40:17AM +0200, Marco Felsch wrote: > > On 22-06-17, Francesco Dolcini wrote: > > > Allow over-writing critical and passive trip point for each > > > temperature grade from the device tree, by default the pre-existing > > > hard-coded trip points are used. > > > > > > This change enables configuring the system thermal characteristics into > > > the system-specific device tree instead of relying on global hard-coded > > > temperature thresholds that does not take into account the specific > > > system thermal design. > > > > > > Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> > > > --- > > > v2: > > > - return immediately if no thermal node present in the dts > > > - use dev_info instead of dev_dbg if there is an invalid trip > > > - additional comment in case passive trip point is higher than critical > > > --- > > > drivers/thermal/imx_thermal.c | 58 +++++++++++++++++++++++++++++++++++ > > > 1 file changed, 58 insertions(+) > > > > > > diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c > > > index 16663373b682..a964baf802fc 100644 > > > --- a/drivers/thermal/imx_thermal.c > > > +++ b/drivers/thermal/imx_thermal.c > > > @@ -17,6 +17,8 @@ > > > #include <linux/nvmem-consumer.h> > > > #include <linux/pm_runtime.h> > > > > > > +#include "thermal_core.h" > > > + > > > #define REG_SET 0x4 > > > #define REG_CLR 0x8 > > > #define REG_TOG 0xc > > > @@ -479,36 +481,92 @@ static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1) > > > return 0; > > > } > > > > > > +static void imx_init_temp_from_of(struct platform_device *pdev, const char *name) > > > +{ > > > + struct imx_thermal_data *data = platform_get_drvdata(pdev); > > > + struct device_node *thermal, *trips, *trip_point; > > > + > > > + thermal = of_get_child_by_name(pdev->dev.of_node, name); > > > + if (!thermal) > > > + return; > > > + > > > + trips = of_get_child_by_name(thermal, "trips"); > > > + > > > + for_each_child_of_node(trips, trip_point) { > > > + struct thermal_trip t; > > > + > > > + if (thermal_of_populate_trip(trip_point, &t)) > > > + continue; > > > + > > > + switch (t.type) { > > > + case THERMAL_TRIP_PASSIVE: > > > + data->temp_passive = t.temperature; > > > + break; > > > + case THERMAL_TRIP_CRITICAL: > > > > Should we check also the temp_critical and temp_passive not exceeding > > the temp_max? Sry. that it came not earlier in my mind. So system damage > > is avoided. > > I would not add such kind of restriction in the code. I can think of > multiple situations in which a system designer would prefer to take the > chances of burning a silicon (or more likely just age it a little bit > faster) than to just shut down the system. > > In the end whoever is building the system should be empowered to do > something like that and it's no different from what it's already possible > with thermal_of driver for example. > > In addition to that from a system debug prospective all the threshold > (max, passive, critical) are already available in the kernel logs. Okay, fine with me since you provided dt-snippets with the correct temperature. But we should really print a warning since this is a abnormal usage and the user should be warned. Regards, Marco > > Francesco > >
On 17/06/2022 00:14, Francesco Dolcini wrote: > This series allows to specify the imx thermal drivers trip point from the device tree, > without this change the threshold are hard-coded and this might not be correct given the > thermal design of the final system. Why resending? What was wrong with your v2 to which I replied? Best regards, Krzysztof
On 17/06/2022 00:42, Francesco Dolcini wrote: > Hello Jacky, > > On Fri, Jun 17, 2022 at 07:31:25AM +0000, Jacky Bai wrote: >>> Subject: [RESEND PATCH v2 0/9] imx: thermal: Allow trip point configuration >>> from DT >>> >>> This series allows to specify the imx thermal drivers trip point from the device >>> tree, without this change the threshold are hard-coded and this might not be >>> correct given the thermal design of the final system. >>> >> >> The threshold is set dynamically based on the part market temp grade. >> I am little confused why need to specify it in DT? I saw in 'PATCH >> 5/9', you provide a threshold table based temp grade, why not use the >> threshold from ' imx_init_temp_grade'? > > The problem with the existing temperature thresholds is that they are > hard-coded into the driver, there is no way to change those to match the > actual final system thermal design. > > After various discussions [1][2] with Marco, Daniel and Lucas it was agreed > that the actual trip is indeed a system property and therefore should be > described in the device tree. This series make it possible in a > backward compatible way, this new possibility is than used to override the > threshold in some system-specific dts (see patches 6,7,8 and 9). > > Francesco > > [1] https://lore.kernel.org/all/20220420091300.179753-1-francesco.dolcini@toradex.com/ > [2] https://lore.kernel.org/all/20220516190001.147919-1-francesco.dolcini@toradex.com/ > As I responded to your v2, thermal is not really special and other types of devices and other SoCs might be affected as well. Best regards, Krzysztof
On Fri, Jun 17, 2022 at 06:06:40PM -0700, Krzysztof Kozlowski wrote: > On 17/06/2022 00:14, Francesco Dolcini wrote: > > This series allows to specify the imx thermal drivers trip point from the device tree, > > without this change the threshold are hard-coded and this might not be correct given the > > thermal design of the final system. > > Why resending? What was wrong with your v2 to which I replied? Wrong subject in the cover letter, I had v1 instead of v2. I thought this was going to confuse people, therefore I resent. My mistake to not have explicitly written the reason of the resend. Francesco