diff mbox series

[1/2] thermal: core: add initial support for cold and critical_cold trip point

Message ID 20231212221301.12581-1-ansuelsmth@gmail.com
State New
Headers show
Series [1/2] thermal: core: add initial support for cold and critical_cold trip point | expand

Commit Message

Christian Marangi Dec. 12, 2023, 10:13 p.m. UTC
Add initial support for cold and critical_cold trip point. Many if not
all hwmon and thermal device have normally trip point for hot
temperature and for cold temperature.

Till now only hot temperature were supported. Add support for also cold
temperature to permit complete definition of cold trip point in DT.

Thermal driver may use these additional trip point to correctly set
interrupt for cold temperature values and react based on that with
various measure like enabling attached heater, forcing higher voltage
and other specialaized peripherals.

For hwmon drivers this is needed as currently there is a problem with
setting the full operating range of the device for thermal devices
defined with hwmon. To better describe the problem, the following
example is needed:

In the scenario of a simple hwmon with an active trip point declared
and a cooling device attached, the hwmon subsystem currently set the
min and max trip point based on the single active trip point.
Thermal subsystem parse all the trip points and calculate the lowest and
the highest trip point and calls the .set_trip of hwmon to setup the
trip points.

The fact that we currently don't have a way to declare the cold/min
temperature values, makes the thermal subsystem to set the low value as
-INT_MAX.
For hwmon drivers that doesn't use clamp_value and actually reject
invalid values for the trip point, this results in the hwmon settings to
be rejected.

To permit to pass the correct range of trip point, permit to set in DT
also cold and critical_cold trip point.

Thermal driver may also define .cold and .critical_cold to act on these
trip point tripped and apply the required measure.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/thermal/thermal_core.c  | 13 +++++++++++++
 drivers/thermal/thermal_of.c    |  2 ++
 drivers/thermal/thermal_sysfs.c |  4 ++++
 drivers/thermal/thermal_trace.h |  4 ++++
 include/linux/thermal.h         |  2 ++
 include/uapi/linux/thermal.h    |  2 ++
 6 files changed, 27 insertions(+)

Comments

Rafael J. Wysocki Dec. 13, 2023, 12:01 p.m. UTC | #1
On Tue, Dec 12, 2023 at 11:17 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
>
> Add initial support for cold and critical_cold trip point. Many if not
> all hwmon and thermal device have normally trip point for hot
> temperature and for cold temperature.
>
> Till now only hot temperature were supported. Add support for also cold
> temperature to permit complete definition of cold trip point in DT.
>
> Thermal driver may use these additional trip point to correctly set
> interrupt for cold temperature values and react based on that with
> various measure like enabling attached heater, forcing higher voltage
> and other specialaized peripherals.
>
> For hwmon drivers this is needed as currently there is a problem with
> setting the full operating range of the device for thermal devices
> defined with hwmon. To better describe the problem, the following
> example is needed:
>
> In the scenario of a simple hwmon with an active trip point declared
> and a cooling device attached, the hwmon subsystem currently set the
> min and max trip point based on the single active trip point.
> Thermal subsystem parse all the trip points and calculate the lowest and
> the highest trip point and calls the .set_trip of hwmon to setup the
> trip points.
>
> The fact that we currently don't have a way to declare the cold/min
> temperature values, makes the thermal subsystem to set the low value as
> -INT_MAX.
> For hwmon drivers that doesn't use clamp_value and actually reject
> invalid values for the trip point, this results in the hwmon settings to
> be rejected.
>
> To permit to pass the correct range of trip point, permit to set in DT
> also cold and critical_cold trip point.
>
> Thermal driver may also define .cold and .critical_cold to act on these
> trip point tripped and apply the required measure.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Generally speaking, it is kind of late in the cycle for adding
significant new features like this.  We can get to it when 6.8-rc1 is
out, so please resend then.

Also it would be nice to define/document the cold and crtitical_cold
trip points somewhere and is there a better name for critical_cold?

> ---
>  drivers/thermal/thermal_core.c  | 13 +++++++++++++
>  drivers/thermal/thermal_of.c    |  2 ++
>  drivers/thermal/thermal_sysfs.c |  4 ++++
>  drivers/thermal/thermal_trace.h |  4 ++++
>  include/linux/thermal.h         |  2 ++
>  include/uapi/linux/thermal.h    |  2 ++
>  6 files changed, 27 insertions(+)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 9c17d35ccbbd..3c5ab560e72f 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -344,6 +344,17 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
>                 tz->ops->hot(tz);
>  }
>
> +static void handle_critical_cold_trips(struct thermal_zone_device *tz,
> +                                      const struct thermal_trip *trip)
> +{
> +       trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
> +
> +       if (trip->type == THERMAL_TRIP_CRITICAL_COLD && tz->ops->critical_cold)
> +               tz->ops->critical_cold(tz);
> +       else if (trip->type == THERMAL_TRIP_COLD && tz->ops->cold)
> +               tz->ops->cold(tz);
> +}
> +
>  static void handle_thermal_trip(struct thermal_zone_device *tz,
>                                 const struct thermal_trip *trip)
>  {
> @@ -365,6 +376,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
>
>         if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
>                 handle_critical_trips(tz, trip);
> +       else if (trip->type == THERMAL_TRIP_CRITICAL_COLD || trip->type == THERMAL_TRIP_COLD)
> +               handle_critical_cold_trips(tz, trip);
>         else
>                 handle_non_critical_trips(tz, trip);
>  }
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 1e0655b63259..95bc600bb4b8 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -60,6 +60,8 @@ static const char * const trip_types[] = {
>         [THERMAL_TRIP_PASSIVE]  = "passive",
>         [THERMAL_TRIP_HOT]      = "hot",
>         [THERMAL_TRIP_CRITICAL] = "critical",
> +       [THERMAL_TRIP_COLD]     = "cold",
> +       [THERMAL_TRIP_CRITICAL_COLD] = "critical_cold",
>  };
>
>  /**
> diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> index eef40d4f3063..e1e69e0991c2 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -106,6 +106,10 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
>                 return sprintf(buf, "critical\n");
>         case THERMAL_TRIP_HOT:
>                 return sprintf(buf, "hot\n");
> +       case THERMAL_TRIP_COLD:
> +               return sprintf(buf, "cold\n");
> +       case THERMAL_TRIP_CRITICAL_COLD:
> +               return sprintf(buf, "critical_cold\n");
>         case THERMAL_TRIP_PASSIVE:
>                 return sprintf(buf, "passive\n");
>         case THERMAL_TRIP_ACTIVE:
> diff --git a/drivers/thermal/thermal_trace.h b/drivers/thermal/thermal_trace.h
> index 459c8ce6cf3b..0a4f96075d7d 100644
> --- a/drivers/thermal/thermal_trace.h
> +++ b/drivers/thermal/thermal_trace.h
> @@ -11,6 +11,8 @@
>
>  TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
>  TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
> +TRACE_DEFINE_ENUM(THERMAL_TRIP_COLD);
> +TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL_COLD);
>  TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
>  TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
>
> @@ -18,6 +20,8 @@ TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
>         __print_symbolic(type,                                  \
>                          { THERMAL_TRIP_CRITICAL, "CRITICAL"},  \
>                          { THERMAL_TRIP_HOT,      "HOT"},       \
> +                        { THERMAL_TRIP_COLD,      "COLD"},     \
> +                        { THERMAL_TRIP_CRITICAL_COLD, "CRITICAL_COLD"}, \
>                          { THERMAL_TRIP_PASSIVE,  "PASSIVE"},   \
>                          { THERMAL_TRIP_ACTIVE,   "ACTIVE"})
>
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index cee814d5d1ac..d6345c9ec50d 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -84,6 +84,8 @@ struct thermal_zone_device_ops {
>                           const struct thermal_trip *, enum thermal_trend *);
>         void (*hot)(struct thermal_zone_device *);
>         void (*critical)(struct thermal_zone_device *);
> +       void (*cold)(struct thermal_zone_device *);
> +       void (*critical_cold)(struct thermal_zone_device *);
>  };
>
>  struct thermal_cooling_device_ops {
> diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h
> index fc78bf3aead7..7fa1ba0dff05 100644
> --- a/include/uapi/linux/thermal.h
> +++ b/include/uapi/linux/thermal.h
> @@ -14,6 +14,8 @@ enum thermal_trip_type {
>         THERMAL_TRIP_PASSIVE,
>         THERMAL_TRIP_HOT,
>         THERMAL_TRIP_CRITICAL,
> +       THERMAL_TRIP_COLD,
> +       THERMAL_TRIP_CRITICAL_COLD,
>  };
>
>  /* Adding event notification support elements */
> --
> 2.40.1
>
Christian Marangi Dec. 13, 2023, 12:06 p.m. UTC | #2
On Wed, Dec 13, 2023 at 01:01:51PM +0100, Rafael J. Wysocki wrote:
> On Tue, Dec 12, 2023 at 11:17 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
> >
> > Add initial support for cold and critical_cold trip point. Many if not
> > all hwmon and thermal device have normally trip point for hot
> > temperature and for cold temperature.
> >
> > Till now only hot temperature were supported. Add support for also cold
> > temperature to permit complete definition of cold trip point in DT.
> >
> > Thermal driver may use these additional trip point to correctly set
> > interrupt for cold temperature values and react based on that with
> > various measure like enabling attached heater, forcing higher voltage
> > and other specialaized peripherals.
> >
> > For hwmon drivers this is needed as currently there is a problem with
> > setting the full operating range of the device for thermal devices
> > defined with hwmon. To better describe the problem, the following
> > example is needed:
> >
> > In the scenario of a simple hwmon with an active trip point declared
> > and a cooling device attached, the hwmon subsystem currently set the
> > min and max trip point based on the single active trip point.
> > Thermal subsystem parse all the trip points and calculate the lowest and
> > the highest trip point and calls the .set_trip of hwmon to setup the
> > trip points.
> >
> > The fact that we currently don't have a way to declare the cold/min
> > temperature values, makes the thermal subsystem to set the low value as
> > -INT_MAX.
> > For hwmon drivers that doesn't use clamp_value and actually reject
> > invalid values for the trip point, this results in the hwmon settings to
> > be rejected.
> >
> > To permit to pass the correct range of trip point, permit to set in DT
> > also cold and critical_cold trip point.
> >
> > Thermal driver may also define .cold and .critical_cold to act on these
> > trip point tripped and apply the required measure.
> >
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> 
> Generally speaking, it is kind of late in the cycle for adding
> significant new features like this.  We can get to it when 6.8-rc1 is
> out, so please resend then.
>

Ok no problem.

> Also it would be nice to define/document the cold and crtitical_cold
> trip points somewhere and is there a better name for critical_cold?
> 

Ehhh I think critical_cold is the only correct one.
Thermal device normally have lowest low high and highest trip point. I
think the lowest has to match what we use for highest (critical). Using
coldest might be confusing and wouldn't display a critical condition of
low temp where the device can't work and immediate actions has to be
taken. 

> > ---
> >  drivers/thermal/thermal_core.c  | 13 +++++++++++++
> >  drivers/thermal/thermal_of.c    |  2 ++
> >  drivers/thermal/thermal_sysfs.c |  4 ++++
> >  drivers/thermal/thermal_trace.h |  4 ++++
> >  include/linux/thermal.h         |  2 ++
> >  include/uapi/linux/thermal.h    |  2 ++
> >  6 files changed, 27 insertions(+)
> >
> > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> > index 9c17d35ccbbd..3c5ab560e72f 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -344,6 +344,17 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
> >                 tz->ops->hot(tz);
> >  }
> >
> > +static void handle_critical_cold_trips(struct thermal_zone_device *tz,
> > +                                      const struct thermal_trip *trip)
> > +{
> > +       trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
> > +
> > +       if (trip->type == THERMAL_TRIP_CRITICAL_COLD && tz->ops->critical_cold)
> > +               tz->ops->critical_cold(tz);
> > +       else if (trip->type == THERMAL_TRIP_COLD && tz->ops->cold)
> > +               tz->ops->cold(tz);
> > +}
> > +
> >  static void handle_thermal_trip(struct thermal_zone_device *tz,
> >                                 const struct thermal_trip *trip)
> >  {
> > @@ -365,6 +376,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
> >
> >         if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
> >                 handle_critical_trips(tz, trip);
> > +       else if (trip->type == THERMAL_TRIP_CRITICAL_COLD || trip->type == THERMAL_TRIP_COLD)
> > +               handle_critical_cold_trips(tz, trip);
> >         else
> >                 handle_non_critical_trips(tz, trip);
> >  }
> > diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> > index 1e0655b63259..95bc600bb4b8 100644
> > --- a/drivers/thermal/thermal_of.c
> > +++ b/drivers/thermal/thermal_of.c
> > @@ -60,6 +60,8 @@ static const char * const trip_types[] = {
> >         [THERMAL_TRIP_PASSIVE]  = "passive",
> >         [THERMAL_TRIP_HOT]      = "hot",
> >         [THERMAL_TRIP_CRITICAL] = "critical",
> > +       [THERMAL_TRIP_COLD]     = "cold",
> > +       [THERMAL_TRIP_CRITICAL_COLD] = "critical_cold",
> >  };
> >
> >  /**
> > diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> > index eef40d4f3063..e1e69e0991c2 100644
> > --- a/drivers/thermal/thermal_sysfs.c
> > +++ b/drivers/thermal/thermal_sysfs.c
> > @@ -106,6 +106,10 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
> >                 return sprintf(buf, "critical\n");
> >         case THERMAL_TRIP_HOT:
> >                 return sprintf(buf, "hot\n");
> > +       case THERMAL_TRIP_COLD:
> > +               return sprintf(buf, "cold\n");
> > +       case THERMAL_TRIP_CRITICAL_COLD:
> > +               return sprintf(buf, "critical_cold\n");
> >         case THERMAL_TRIP_PASSIVE:
> >                 return sprintf(buf, "passive\n");
> >         case THERMAL_TRIP_ACTIVE:
> > diff --git a/drivers/thermal/thermal_trace.h b/drivers/thermal/thermal_trace.h
> > index 459c8ce6cf3b..0a4f96075d7d 100644
> > --- a/drivers/thermal/thermal_trace.h
> > +++ b/drivers/thermal/thermal_trace.h
> > @@ -11,6 +11,8 @@
> >
> >  TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
> >  TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
> > +TRACE_DEFINE_ENUM(THERMAL_TRIP_COLD);
> > +TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL_COLD);
> >  TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
> >  TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
> >
> > @@ -18,6 +20,8 @@ TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
> >         __print_symbolic(type,                                  \
> >                          { THERMAL_TRIP_CRITICAL, "CRITICAL"},  \
> >                          { THERMAL_TRIP_HOT,      "HOT"},       \
> > +                        { THERMAL_TRIP_COLD,      "COLD"},     \
> > +                        { THERMAL_TRIP_CRITICAL_COLD, "CRITICAL_COLD"}, \
> >                          { THERMAL_TRIP_PASSIVE,  "PASSIVE"},   \
> >                          { THERMAL_TRIP_ACTIVE,   "ACTIVE"})
> >
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index cee814d5d1ac..d6345c9ec50d 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -84,6 +84,8 @@ struct thermal_zone_device_ops {
> >                           const struct thermal_trip *, enum thermal_trend *);
> >         void (*hot)(struct thermal_zone_device *);
> >         void (*critical)(struct thermal_zone_device *);
> > +       void (*cold)(struct thermal_zone_device *);
> > +       void (*critical_cold)(struct thermal_zone_device *);
> >  };
> >
> >  struct thermal_cooling_device_ops {
> > diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h
> > index fc78bf3aead7..7fa1ba0dff05 100644
> > --- a/include/uapi/linux/thermal.h
> > +++ b/include/uapi/linux/thermal.h
> > @@ -14,6 +14,8 @@ enum thermal_trip_type {
> >         THERMAL_TRIP_PASSIVE,
> >         THERMAL_TRIP_HOT,
> >         THERMAL_TRIP_CRITICAL,
> > +       THERMAL_TRIP_COLD,
> > +       THERMAL_TRIP_CRITICAL_COLD,
> >  };
> >
> >  /* Adding event notification support elements */
> > --
> > 2.40.1
> >
Daniel Lezcano Dec. 13, 2023, 2:12 p.m. UTC | #3
On 12/12/2023 23:13, Christian Marangi wrote:
> Add initial support for cold and critical_cold trip point. Many if not
> all hwmon and thermal device have normally trip point for hot
> temperature and for cold temperature.
> 
> Till now only hot temperature were supported. Add support for also cold
> temperature to permit complete definition of cold trip point in DT.
> 
> Thermal driver may use these additional trip point to correctly set
> interrupt for cold temperature values and react based on that with
> various measure like enabling attached heater, forcing higher voltage
> and other specialaized peripherals.
> 
> For hwmon drivers this is needed as currently there is a problem with
> setting the full operating range of the device for thermal devices
> defined with hwmon. To better describe the problem, the following
> example is needed:
> 
> In the scenario of a simple hwmon with an active trip point declared
> and a cooling device attached, the hwmon subsystem currently set the
> min and max trip point based on the single active trip point.
> Thermal subsystem parse all the trip points and calculate the lowest and
> the highest trip point and calls the .set_trip of hwmon to setup the
> trip points.
> 
> The fact that we currently don't have a way to declare the cold/min
> temperature values, makes the thermal subsystem to set the low value as
> -INT_MAX.
> For hwmon drivers that doesn't use clamp_value and actually reject
> invalid values for the trip point, this results in the hwmon settings to
> be rejected.
> 
> To permit to pass the correct range of trip point, permit to set in DT
> also cold and critical_cold trip point.
> 
> Thermal driver may also define .cold and .critical_cold to act on these
> trip point tripped and apply the required measure.

Agree with the feature but we need to clarify the semantic of the trip 
points first. What actions do we expect for them in order to have like a 
mirror reflection of the existing hot trip points.

What action do you expect with:

  - 'cold' ?

  - 'critical_cold' ?



> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Why are there two different names for the same email address?

  - Christian Marangi <ansuelsmth@gmail.com>
  - Ansuel Smith <ansuelsmth@gmail.com>


> ---
>   drivers/thermal/thermal_core.c  | 13 +++++++++++++
>   drivers/thermal/thermal_of.c    |  2 ++
>   drivers/thermal/thermal_sysfs.c |  4 ++++
>   drivers/thermal/thermal_trace.h |  4 ++++
>   include/linux/thermal.h         |  2 ++
>   include/uapi/linux/thermal.h    |  2 ++
>   6 files changed, 27 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 9c17d35ccbbd..3c5ab560e72f 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -344,6 +344,17 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
>   		tz->ops->hot(tz);
>   }
>   
> +static void handle_critical_cold_trips(struct thermal_zone_device *tz,
> +				       const struct thermal_trip *trip)
> +{
> +	trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
> +
> +	if (trip->type == THERMAL_TRIP_CRITICAL_COLD && tz->ops->critical_cold)
> +		tz->ops->critical_cold(tz);
> +	else if (trip->type == THERMAL_TRIP_COLD && tz->ops->cold)
> +		tz->ops->cold(tz);
> +}
> +
>   static void handle_thermal_trip(struct thermal_zone_device *tz,
>   				const struct thermal_trip *trip)
>   {
> @@ -365,6 +376,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
>   
>   	if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
>   		handle_critical_trips(tz, trip);
> +	else if (trip->type == THERMAL_TRIP_CRITICAL_COLD || trip->type == THERMAL_TRIP_COLD)
> +		handle_critical_cold_trips(tz, trip);
>   	else
>   		handle_non_critical_trips(tz, trip);
>   }
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 1e0655b63259..95bc600bb4b8 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -60,6 +60,8 @@ static const char * const trip_types[] = {
>   	[THERMAL_TRIP_PASSIVE]	= "passive",
>   	[THERMAL_TRIP_HOT]	= "hot",
>   	[THERMAL_TRIP_CRITICAL]	= "critical",
> +	[THERMAL_TRIP_COLD]	= "cold",
> +	[THERMAL_TRIP_CRITICAL_COLD] = "critical_cold",
>   };
>   
>   /**
> diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> index eef40d4f3063..e1e69e0991c2 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -106,6 +106,10 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
>   		return sprintf(buf, "critical\n");
>   	case THERMAL_TRIP_HOT:
>   		return sprintf(buf, "hot\n");
> +	case THERMAL_TRIP_COLD:
> +		return sprintf(buf, "cold\n");
> +	case THERMAL_TRIP_CRITICAL_COLD:
> +		return sprintf(buf, "critical_cold\n");
>   	case THERMAL_TRIP_PASSIVE:
>   		return sprintf(buf, "passive\n");
>   	case THERMAL_TRIP_ACTIVE:
> diff --git a/drivers/thermal/thermal_trace.h b/drivers/thermal/thermal_trace.h
> index 459c8ce6cf3b..0a4f96075d7d 100644
> --- a/drivers/thermal/thermal_trace.h
> +++ b/drivers/thermal/thermal_trace.h
> @@ -11,6 +11,8 @@
>   
>   TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
>   TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
> +TRACE_DEFINE_ENUM(THERMAL_TRIP_COLD);
> +TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL_COLD);
>   TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
>   TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
>   
> @@ -18,6 +20,8 @@ TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
>   	__print_symbolic(type,					\
>   			 { THERMAL_TRIP_CRITICAL, "CRITICAL"},	\
>   			 { THERMAL_TRIP_HOT,      "HOT"},	\
> +			 { THERMAL_TRIP_COLD,      "COLD"},	\
> +			 { THERMAL_TRIP_CRITICAL_COLD, "CRITICAL_COLD"}, \
>   			 { THERMAL_TRIP_PASSIVE,  "PASSIVE"},	\
>   			 { THERMAL_TRIP_ACTIVE,   "ACTIVE"})
>   
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index cee814d5d1ac..d6345c9ec50d 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -84,6 +84,8 @@ struct thermal_zone_device_ops {
>   			  const struct thermal_trip *, enum thermal_trend *);
>   	void (*hot)(struct thermal_zone_device *);
>   	void (*critical)(struct thermal_zone_device *);
> +	void (*cold)(struct thermal_zone_device *);
> +	void (*critical_cold)(struct thermal_zone_device *);
>   };
>   
>   struct thermal_cooling_device_ops {
> diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h
> index fc78bf3aead7..7fa1ba0dff05 100644
> --- a/include/uapi/linux/thermal.h
> +++ b/include/uapi/linux/thermal.h
> @@ -14,6 +14,8 @@ enum thermal_trip_type {
>   	THERMAL_TRIP_PASSIVE,
>   	THERMAL_TRIP_HOT,
>   	THERMAL_TRIP_CRITICAL,
> +	THERMAL_TRIP_COLD,
> +	THERMAL_TRIP_CRITICAL_COLD,
>   };
>   
>   /* Adding event notification support elements */
Christian Marangi Dec. 13, 2023, 2:20 p.m. UTC | #4
On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
> On 12/12/2023 23:13, Christian Marangi wrote:
> > Add initial support for cold and critical_cold trip point. Many if not
> > all hwmon and thermal device have normally trip point for hot
> > temperature and for cold temperature.
> > 
> > Till now only hot temperature were supported. Add support for also cold
> > temperature to permit complete definition of cold trip point in DT.
> > 
> > Thermal driver may use these additional trip point to correctly set
> > interrupt for cold temperature values and react based on that with
> > various measure like enabling attached heater, forcing higher voltage
> > and other specialaized peripherals.
> > 
> > For hwmon drivers this is needed as currently there is a problem with
> > setting the full operating range of the device for thermal devices
> > defined with hwmon. To better describe the problem, the following
> > example is needed:
> > 
> > In the scenario of a simple hwmon with an active trip point declared
> > and a cooling device attached, the hwmon subsystem currently set the
> > min and max trip point based on the single active trip point.
> > Thermal subsystem parse all the trip points and calculate the lowest and
> > the highest trip point and calls the .set_trip of hwmon to setup the
> > trip points.
> > 
> > The fact that we currently don't have a way to declare the cold/min
> > temperature values, makes the thermal subsystem to set the low value as
> > -INT_MAX.
> > For hwmon drivers that doesn't use clamp_value and actually reject
> > invalid values for the trip point, this results in the hwmon settings to
> > be rejected.
> > 
> > To permit to pass the correct range of trip point, permit to set in DT
> > also cold and critical_cold trip point.
> > 
> > Thermal driver may also define .cold and .critical_cold to act on these
> > trip point tripped and apply the required measure.
> 
> Agree with the feature but we need to clarify the semantic of the trip
> points first. What actions do we expect for them in order to have like a
> mirror reflection of the existing hot trip points.
> 
> What action do you expect with:
> 
>  - 'cold' ?
> 
>  - 'critical_cold' ?
> 
>

This is more of a sensible topic but I think it's the thermal driver
that needs to implement these. As said in the commit description,
examples are setting higher voltage from the attached regulator,
enabling some hardware heater.

Maybe with critical cold bigger measure can be applied. Currently for
critical trip point we shutdown the system (if the critical ops is not
declared) but with critical_cold condition I think it won't work... I
expect a system in -40°C would just lock up/glitch so rebooting in that
condition won't change a thing...

Anyway yes we can define a shutdown by default for that but IMHO it
wouldn't make much sense.

> 
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> 
> Why are there two different names for the same email address?
> 
>  - Christian Marangi <ansuelsmth@gmail.com>
>  - Ansuel Smith <ansuelsmth@gmail.com>
> 

Stupid mistake in my ""childhood"". Ansuel it's my second name, when I
understood things have started to become more serious I fixed the very
stupid thing and started using correct naming. I'm extremely sorry for
the mistake I did and I know all the problems it does cause doing that.

> 
> > ---
> >   drivers/thermal/thermal_core.c  | 13 +++++++++++++
> >   drivers/thermal/thermal_of.c    |  2 ++
> >   drivers/thermal/thermal_sysfs.c |  4 ++++
> >   drivers/thermal/thermal_trace.h |  4 ++++
> >   include/linux/thermal.h         |  2 ++
> >   include/uapi/linux/thermal.h    |  2 ++
> >   6 files changed, 27 insertions(+)
> > 
> > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> > index 9c17d35ccbbd..3c5ab560e72f 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -344,6 +344,17 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
> >   		tz->ops->hot(tz);
> >   }
> > +static void handle_critical_cold_trips(struct thermal_zone_device *tz,
> > +				       const struct thermal_trip *trip)
> > +{
> > +	trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
> > +
> > +	if (trip->type == THERMAL_TRIP_CRITICAL_COLD && tz->ops->critical_cold)
> > +		tz->ops->critical_cold(tz);
> > +	else if (trip->type == THERMAL_TRIP_COLD && tz->ops->cold)
> > +		tz->ops->cold(tz);
> > +}
> > +
> >   static void handle_thermal_trip(struct thermal_zone_device *tz,
> >   				const struct thermal_trip *trip)
> >   {
> > @@ -365,6 +376,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
> >   	if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
> >   		handle_critical_trips(tz, trip);
> > +	else if (trip->type == THERMAL_TRIP_CRITICAL_COLD || trip->type == THERMAL_TRIP_COLD)
> > +		handle_critical_cold_trips(tz, trip);
> >   	else
> >   		handle_non_critical_trips(tz, trip);
> >   }
> > diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> > index 1e0655b63259..95bc600bb4b8 100644
> > --- a/drivers/thermal/thermal_of.c
> > +++ b/drivers/thermal/thermal_of.c
> > @@ -60,6 +60,8 @@ static const char * const trip_types[] = {
> >   	[THERMAL_TRIP_PASSIVE]	= "passive",
> >   	[THERMAL_TRIP_HOT]	= "hot",
> >   	[THERMAL_TRIP_CRITICAL]	= "critical",
> > +	[THERMAL_TRIP_COLD]	= "cold",
> > +	[THERMAL_TRIP_CRITICAL_COLD] = "critical_cold",
> >   };
> >   /**
> > diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> > index eef40d4f3063..e1e69e0991c2 100644
> > --- a/drivers/thermal/thermal_sysfs.c
> > +++ b/drivers/thermal/thermal_sysfs.c
> > @@ -106,6 +106,10 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
> >   		return sprintf(buf, "critical\n");
> >   	case THERMAL_TRIP_HOT:
> >   		return sprintf(buf, "hot\n");
> > +	case THERMAL_TRIP_COLD:
> > +		return sprintf(buf, "cold\n");
> > +	case THERMAL_TRIP_CRITICAL_COLD:
> > +		return sprintf(buf, "critical_cold\n");
> >   	case THERMAL_TRIP_PASSIVE:
> >   		return sprintf(buf, "passive\n");
> >   	case THERMAL_TRIP_ACTIVE:
> > diff --git a/drivers/thermal/thermal_trace.h b/drivers/thermal/thermal_trace.h
> > index 459c8ce6cf3b..0a4f96075d7d 100644
> > --- a/drivers/thermal/thermal_trace.h
> > +++ b/drivers/thermal/thermal_trace.h
> > @@ -11,6 +11,8 @@
> >   TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
> >   TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
> > +TRACE_DEFINE_ENUM(THERMAL_TRIP_COLD);
> > +TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL_COLD);
> >   TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
> >   TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
> > @@ -18,6 +20,8 @@ TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
> >   	__print_symbolic(type,					\
> >   			 { THERMAL_TRIP_CRITICAL, "CRITICAL"},	\
> >   			 { THERMAL_TRIP_HOT,      "HOT"},	\
> > +			 { THERMAL_TRIP_COLD,      "COLD"},	\
> > +			 { THERMAL_TRIP_CRITICAL_COLD, "CRITICAL_COLD"}, \
> >   			 { THERMAL_TRIP_PASSIVE,  "PASSIVE"},	\
> >   			 { THERMAL_TRIP_ACTIVE,   "ACTIVE"})
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index cee814d5d1ac..d6345c9ec50d 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -84,6 +84,8 @@ struct thermal_zone_device_ops {
> >   			  const struct thermal_trip *, enum thermal_trend *);
> >   	void (*hot)(struct thermal_zone_device *);
> >   	void (*critical)(struct thermal_zone_device *);
> > +	void (*cold)(struct thermal_zone_device *);
> > +	void (*critical_cold)(struct thermal_zone_device *);
> >   };
> >   struct thermal_cooling_device_ops {
> > diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h
> > index fc78bf3aead7..7fa1ba0dff05 100644
> > --- a/include/uapi/linux/thermal.h
> > +++ b/include/uapi/linux/thermal.h
> > @@ -14,6 +14,8 @@ enum thermal_trip_type {
> >   	THERMAL_TRIP_PASSIVE,
> >   	THERMAL_TRIP_HOT,
> >   	THERMAL_TRIP_CRITICAL,
> > +	THERMAL_TRIP_COLD,
> > +	THERMAL_TRIP_CRITICAL_COLD,
> >   };
> >   /* Adding event notification support elements */
> 
> -- 
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
>
Rafael J. Wysocki Dec. 13, 2023, 2:39 p.m. UTC | #5
On Wed, Dec 13, 2023 at 1:06 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
>
> On Wed, Dec 13, 2023 at 01:01:51PM +0100, Rafael J. Wysocki wrote:
> > On Tue, Dec 12, 2023 at 11:17 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
> > >
> > > Add initial support for cold and critical_cold trip point. Many if not
> > > all hwmon and thermal device have normally trip point for hot
> > > temperature and for cold temperature.
> > >
> > > Till now only hot temperature were supported. Add support for also cold
> > > temperature to permit complete definition of cold trip point in DT.
> > >
> > > Thermal driver may use these additional trip point to correctly set
> > > interrupt for cold temperature values and react based on that with
> > > various measure like enabling attached heater, forcing higher voltage
> > > and other specialaized peripherals.
> > >
> > > For hwmon drivers this is needed as currently there is a problem with
> > > setting the full operating range of the device for thermal devices
> > > defined with hwmon. To better describe the problem, the following
> > > example is needed:
> > >
> > > In the scenario of a simple hwmon with an active trip point declared
> > > and a cooling device attached, the hwmon subsystem currently set the
> > > min and max trip point based on the single active trip point.
> > > Thermal subsystem parse all the trip points and calculate the lowest and
> > > the highest trip point and calls the .set_trip of hwmon to setup the
> > > trip points.
> > >
> > > The fact that we currently don't have a way to declare the cold/min
> > > temperature values, makes the thermal subsystem to set the low value as
> > > -INT_MAX.
> > > For hwmon drivers that doesn't use clamp_value and actually reject
> > > invalid values for the trip point, this results in the hwmon settings to
> > > be rejected.
> > >
> > > To permit to pass the correct range of trip point, permit to set in DT
> > > also cold and critical_cold trip point.
> > >
> > > Thermal driver may also define .cold and .critical_cold to act on these
> > > trip point tripped and apply the required measure.
> > >
> > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> >
> > Generally speaking, it is kind of late in the cycle for adding
> > significant new features like this.  We can get to it when 6.8-rc1 is
> > out, so please resend then.
> >
>
> Ok no problem.
>
> > Also it would be nice to define/document the cold and crtitical_cold
> > trip points somewhere and is there a better name for critical_cold?
> >
>
> Ehhh I think critical_cold is the only correct one.
> Thermal device normally have lowest low high and highest trip point. I
> think the lowest has to match what we use for highest (critical). Using
> coldest might be confusing and wouldn't display a critical condition of
> low temp where the device can't work and immediate actions has to be
> taken.

So at least make it shorter, like crit_cold?
Rafael J. Wysocki Dec. 13, 2023, 2:43 p.m. UTC | #6
On Wed, Dec 13, 2023 at 3:20 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
>
> On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
> > On 12/12/2023 23:13, Christian Marangi wrote:
> > > Add initial support for cold and critical_cold trip point. Many if not
> > > all hwmon and thermal device have normally trip point for hot
> > > temperature and for cold temperature.
> > >
> > > Till now only hot temperature were supported. Add support for also cold
> > > temperature to permit complete definition of cold trip point in DT.
> > >
> > > Thermal driver may use these additional trip point to correctly set
> > > interrupt for cold temperature values and react based on that with
> > > various measure like enabling attached heater, forcing higher voltage
> > > and other specialaized peripherals.
> > >
> > > For hwmon drivers this is needed as currently there is a problem with
> > > setting the full operating range of the device for thermal devices
> > > defined with hwmon. To better describe the problem, the following
> > > example is needed:
> > >
> > > In the scenario of a simple hwmon with an active trip point declared
> > > and a cooling device attached, the hwmon subsystem currently set the
> > > min and max trip point based on the single active trip point.
> > > Thermal subsystem parse all the trip points and calculate the lowest and
> > > the highest trip point and calls the .set_trip of hwmon to setup the
> > > trip points.
> > >
> > > The fact that we currently don't have a way to declare the cold/min
> > > temperature values, makes the thermal subsystem to set the low value as
> > > -INT_MAX.
> > > For hwmon drivers that doesn't use clamp_value and actually reject
> > > invalid values for the trip point, this results in the hwmon settings to
> > > be rejected.
> > >
> > > To permit to pass the correct range of trip point, permit to set in DT
> > > also cold and critical_cold trip point.
> > >
> > > Thermal driver may also define .cold and .critical_cold to act on these
> > > trip point tripped and apply the required measure.
> >
> > Agree with the feature but we need to clarify the semantic of the trip
> > points first. What actions do we expect for them in order to have like a
> > mirror reflection of the existing hot trip points.
> >
> > What action do you expect with:
> >
> >  - 'cold' ?
> >
> >  - 'critical_cold' ?
> >
> >
>
> This is more of a sensible topic but I think it's the thermal driver
> that needs to implement these. As said in the commit description,
> examples are setting higher voltage from the attached regulator,
> enabling some hardware heater.

So how is it different from an active trip point?  There are heating
rather than cooling devices associated with it, but other than this??

> Maybe with critical cold bigger measure can be applied. Currently for
> critical trip point we shutdown the system (if the critical ops is not
> declared) but with critical_cold condition I think it won't work... I
> expect a system in -40°C would just lock up/glitch so rebooting in that
> condition won't change a thing...
>
> Anyway yes we can define a shutdown by default for that but IMHO it
> wouldn't make much sense.

So why do you want to add it at all?
Rafael J. Wysocki Dec. 13, 2023, 2:51 p.m. UTC | #7
On Wed, Dec 13, 2023 at 3:43 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Wed, Dec 13, 2023 at 3:20 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
> >
> > On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
> > > On 12/12/2023 23:13, Christian Marangi wrote:
> > > > Add initial support for cold and critical_cold trip point. Many if not
> > > > all hwmon and thermal device have normally trip point for hot
> > > > temperature and for cold temperature.
> > > >
> > > > Till now only hot temperature were supported. Add support for also cold
> > > > temperature to permit complete definition of cold trip point in DT.
> > > >
> > > > Thermal driver may use these additional trip point to correctly set
> > > > interrupt for cold temperature values and react based on that with
> > > > various measure like enabling attached heater, forcing higher voltage
> > > > and other specialaized peripherals.
> > > >
> > > > For hwmon drivers this is needed as currently there is a problem with
> > > > setting the full operating range of the device for thermal devices
> > > > defined with hwmon. To better describe the problem, the following
> > > > example is needed:
> > > >
> > > > In the scenario of a simple hwmon with an active trip point declared
> > > > and a cooling device attached, the hwmon subsystem currently set the
> > > > min and max trip point based on the single active trip point.
> > > > Thermal subsystem parse all the trip points and calculate the lowest and
> > > > the highest trip point and calls the .set_trip of hwmon to setup the
> > > > trip points.
> > > >
> > > > The fact that we currently don't have a way to declare the cold/min
> > > > temperature values, makes the thermal subsystem to set the low value as
> > > > -INT_MAX.
> > > > For hwmon drivers that doesn't use clamp_value and actually reject
> > > > invalid values for the trip point, this results in the hwmon settings to
> > > > be rejected.
> > > >
> > > > To permit to pass the correct range of trip point, permit to set in DT
> > > > also cold and critical_cold trip point.
> > > >
> > > > Thermal driver may also define .cold and .critical_cold to act on these
> > > > trip point tripped and apply the required measure.
> > >
> > > Agree with the feature but we need to clarify the semantic of the trip
> > > points first. What actions do we expect for them in order to have like a
> > > mirror reflection of the existing hot trip points.
> > >
> > > What action do you expect with:
> > >
> > >  - 'cold' ?
> > >
> > >  - 'critical_cold' ?
> > >
> > >
> >
> > This is more of a sensible topic but I think it's the thermal driver
> > that needs to implement these. As said in the commit description,
> > examples are setting higher voltage from the attached regulator,
> > enabling some hardware heater.
>
> So how is it different from an active trip point?  There are heating
> rather than cooling devices associated with it, but other than this??

And, of course, the mitigation would trigger when crossed on the way
down and the hysteresis value would be added to the temperature.

So it all looks like a "reverse" active trip point.

> > Maybe with critical cold bigger measure can be applied. Currently for
> > critical trip point we shutdown the system (if the critical ops is not
> > declared) but with critical_cold condition I think it won't work... I
> > expect a system in -40°C would just lock up/glitch so rebooting in that
> > condition won't change a thing...
> >
> > Anyway yes we can define a shutdown by default for that but IMHO it
> > wouldn't make much sense.
>
> So why do you want to add it at all?
Christian Marangi Dec. 13, 2023, 2:56 p.m. UTC | #8
On Wed, Dec 13, 2023 at 03:43:54PM +0100, Rafael J. Wysocki wrote:
> On Wed, Dec 13, 2023 at 3:20 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
> >
> > On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
> > > On 12/12/2023 23:13, Christian Marangi wrote:
> > > > Add initial support for cold and critical_cold trip point. Many if not
> > > > all hwmon and thermal device have normally trip point for hot
> > > > temperature and for cold temperature.
> > > >
> > > > Till now only hot temperature were supported. Add support for also cold
> > > > temperature to permit complete definition of cold trip point in DT.
> > > >
> > > > Thermal driver may use these additional trip point to correctly set
> > > > interrupt for cold temperature values and react based on that with
> > > > various measure like enabling attached heater, forcing higher voltage
> > > > and other specialaized peripherals.
> > > >
> > > > For hwmon drivers this is needed as currently there is a problem with
> > > > setting the full operating range of the device for thermal devices
> > > > defined with hwmon. To better describe the problem, the following
> > > > example is needed:
> > > >
> > > > In the scenario of a simple hwmon with an active trip point declared
> > > > and a cooling device attached, the hwmon subsystem currently set the
> > > > min and max trip point based on the single active trip point.
> > > > Thermal subsystem parse all the trip points and calculate the lowest and
> > > > the highest trip point and calls the .set_trip of hwmon to setup the
> > > > trip points.
> > > >
> > > > The fact that we currently don't have a way to declare the cold/min
> > > > temperature values, makes the thermal subsystem to set the low value as
> > > > -INT_MAX.
> > > > For hwmon drivers that doesn't use clamp_value and actually reject
> > > > invalid values for the trip point, this results in the hwmon settings to
> > > > be rejected.
> > > >
> > > > To permit to pass the correct range of trip point, permit to set in DT
> > > > also cold and critical_cold trip point.
> > > >
> > > > Thermal driver may also define .cold and .critical_cold to act on these
> > > > trip point tripped and apply the required measure.
> > >
> > > Agree with the feature but we need to clarify the semantic of the trip
> > > points first. What actions do we expect for them in order to have like a
> > > mirror reflection of the existing hot trip points.
> > >
> > > What action do you expect with:
> > >
> > >  - 'cold' ?
> > >
> > >  - 'critical_cold' ?
> > >
> > >
> >
> > This is more of a sensible topic but I think it's the thermal driver
> > that needs to implement these. As said in the commit description,
> > examples are setting higher voltage from the attached regulator,
> > enabling some hardware heater.
> 
> So how is it different from an active trip point?  There are heating
> rather than cooling devices associated with it, but other than this??
>
Rafael J. Wysocki Dec. 13, 2023, 3:03 p.m. UTC | #9
On Wed, Dec 13, 2023 at 3:56 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
>
> On Wed, Dec 13, 2023 at 03:43:54PM +0100, Rafael J. Wysocki wrote:
> > On Wed, Dec 13, 2023 at 3:20 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
> > >
> > > On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
> > > > On 12/12/2023 23:13, Christian Marangi wrote:
> > > > > Add initial support for cold and critical_cold trip point. Many if not
> > > > > all hwmon and thermal device have normally trip point for hot
> > > > > temperature and for cold temperature.
> > > > >
> > > > > Till now only hot temperature were supported. Add support for also cold
> > > > > temperature to permit complete definition of cold trip point in DT.
> > > > >
> > > > > Thermal driver may use these additional trip point to correctly set
> > > > > interrupt for cold temperature values and react based on that with
> > > > > various measure like enabling attached heater, forcing higher voltage
> > > > > and other specialaized peripherals.
> > > > >
> > > > > For hwmon drivers this is needed as currently there is a problem with
> > > > > setting the full operating range of the device for thermal devices
> > > > > defined with hwmon. To better describe the problem, the following
> > > > > example is needed:
> > > > >
> > > > > In the scenario of a simple hwmon with an active trip point declared
> > > > > and a cooling device attached, the hwmon subsystem currently set the
> > > > > min and max trip point based on the single active trip point.
> > > > > Thermal subsystem parse all the trip points and calculate the lowest and
> > > > > the highest trip point and calls the .set_trip of hwmon to setup the
> > > > > trip points.
> > > > >
> > > > > The fact that we currently don't have a way to declare the cold/min
> > > > > temperature values, makes the thermal subsystem to set the low value as
> > > > > -INT_MAX.
> > > > > For hwmon drivers that doesn't use clamp_value and actually reject
> > > > > invalid values for the trip point, this results in the hwmon settings to
> > > > > be rejected.
> > > > >
> > > > > To permit to pass the correct range of trip point, permit to set in DT
> > > > > also cold and critical_cold trip point.
> > > > >
> > > > > Thermal driver may also define .cold and .critical_cold to act on these
> > > > > trip point tripped and apply the required measure.
> > > >
> > > > Agree with the feature but we need to clarify the semantic of the trip
> > > > points first. What actions do we expect for them in order to have like a
> > > > mirror reflection of the existing hot trip points.
> > > >
> > > > What action do you expect with:
> > > >
> > > >  - 'cold' ?
> > > >
> > > >  - 'critical_cold' ?
> > > >
> > > >
> > >
> > > This is more of a sensible topic but I think it's the thermal driver
> > > that needs to implement these. As said in the commit description,
> > > examples are setting higher voltage from the attached regulator,
> > > enabling some hardware heater.
> >
> > So how is it different from an active trip point?  There are heating
> > rather than cooling devices associated with it, but other than this??
> >
>
> From what I read from documentation, active trip point are used to
> trigger cooling-device. Cold (and crit_cold) are to setup trip point to
> the device. The device will normally trigger an interrupt

Well, that's how thermal sensors work in general IIUC.

> (or even internally with the correct register set autonomously apply some measure
> to handle the problem)
>
> In theory it's possible to have passive trip point for cold condition
> but still we lack any definition of the lower spectrum of the trip
> point.

Such that it will increase power of some devices in order to warm the
system up?  Fair enough.

> > > Maybe with critical cold bigger measure can be applied. Currently for
> > > critical trip point we shutdown the system (if the critical ops is not
> > > declared) but with critical_cold condition I think it won't work... I
> > > expect a system in -40°C would just lock up/glitch so rebooting in that
> > > condition won't change a thing...
> > >
> > > Anyway yes we can define a shutdown by default for that but IMHO it
> > > wouldn't make much sense.
> >
> > So why do you want to add it at all?
>
> Again it's really to fill a hole we have from a long time... One example
> is the qcom tsens driver that have trip point for cold and crit_cold.
> Those in theory can be set in DT with the trip point but we lack any
> definition for them. (using passive trip point would be confusing IMHO)
>
> Another example is an Aquantia PHY that have register for the cold and
> critical_cold trip point.

My point is about the crit_cold trips in particular.  If there is no
common action to trigger when they are crossed, what are they actually
good for?

> Currently defining a critical trip point for the negative temp results
> in the system shutdown.

Sure.
Daniel Lezcano Dec. 13, 2023, 3:10 p.m. UTC | #10
On 13/12/2023 15:20, Christian Marangi wrote:
> On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
>> On 12/12/2023 23:13, Christian Marangi wrote:
>>> Add initial support for cold and critical_cold trip point. Many if not
>>> all hwmon and thermal device have normally trip point for hot
>>> temperature and for cold temperature.
>>>
>>> Till now only hot temperature were supported. Add support for also cold
>>> temperature to permit complete definition of cold trip point in DT.
>>>
>>> Thermal driver may use these additional trip point to correctly set
>>> interrupt for cold temperature values and react based on that with
>>> various measure like enabling attached heater, forcing higher voltage
>>> and other specialaized peripherals.
>>>
>>> For hwmon drivers this is needed as currently there is a problem with
>>> setting the full operating range of the device for thermal devices
>>> defined with hwmon. To better describe the problem, the following
>>> example is needed:
>>>
>>> In the scenario of a simple hwmon with an active trip point declared
>>> and a cooling device attached, the hwmon subsystem currently set the
>>> min and max trip point based on the single active trip point.
>>> Thermal subsystem parse all the trip points and calculate the lowest and
>>> the highest trip point and calls the .set_trip of hwmon to setup the
>>> trip points.
>>>
>>> The fact that we currently don't have a way to declare the cold/min
>>> temperature values, makes the thermal subsystem to set the low value as
>>> -INT_MAX.
>>> For hwmon drivers that doesn't use clamp_value and actually reject
>>> invalid values for the trip point, this results in the hwmon settings to
>>> be rejected.
>>>
>>> To permit to pass the correct range of trip point, permit to set in DT
>>> also cold and critical_cold trip point.
>>>
>>> Thermal driver may also define .cold and .critical_cold to act on these
>>> trip point tripped and apply the required measure.
>>
>> Agree with the feature but we need to clarify the semantic of the trip
>> points first. What actions do we expect for them in order to have like a
>> mirror reflection of the existing hot trip points.
>>
>> What action do you expect with:
>>
>>   - 'cold' ?
>>
>>   - 'critical_cold' ?
>>
>>
> 
> This is more of a sensible topic but I think it's the thermal driver
> that needs to implement these. As said in the commit description,
> examples are setting higher voltage from the attached regulator,
> enabling some hardware heater.

That is a warming device. In the thermal framework design it is part of 
the mitigation device actors like a cooling device. The driver does not 
have to deal with that.

> Maybe with critical cold bigger measure can be applied. Currently for
> critical trip point we shutdown the system (if the critical ops is not
> declared) but with critical_cold condition I think it won't work... I
> expect a system in -40°C would just lock up/glitch so rebooting in that
> condition won't change a thing...

 From my POV, a critical trip point is for a too hot or too cold trip 
point. The temperature should be set before the system will be 
malfunctioning, so a halt (or reboot if set) should work.

I'm not in favor of adding more callbacks if we can avoid them. Passing 
the trip point to the critical callback makes more sense to me.

> Anyway yes we can define a shutdown by default for that but IMHO it
> wouldn't make much sense.

Why? If the device is about to go to out of the functioning range, then 
it makes sense to shut it down. IIRC, electric signals lose their 
stability below the lower bound temperature.

There is the point about the mitigation to stay above a certain 
temperature. If the devices do not have any kind a 'warming' device, 
then an alternative would be to have a generic warming device mirroring 
the cooling device with a duty cycles at different performance states. 
With this case, we may need another trip point type for a governor which 
should handle that.

So we end up with the question: shall we add trip point types or trip 
point properties?

1. Trip point types

  - active / passive : mitigate
  - hot : notify userspace
  - critical : halt by default
  - cold : do something
  - cold_crit : do something else with a callback

2. Trip point types + property

  - active / passive : mitigate
    - hot : cool down
    - cold : warm up

  - hot : notify userspace
  - cold : notify userspace

  - critical:
   - hot : shutdown (or callback + trip)
   - cold : shutdown (or callback + trip)

That implies there are two models:

1. We assume cold / hot trip points are symmetric features of the 
thermal management. So we do mitigation using governors, if that 
mitigation fails then we end up with critical actions. A consistent 
behavior between temperature increase or decrease. From my POV, I prefer 
this approach because it reflects nicely the functioning range temperature.

2. We handle the cold situation differently by doing a on/off action on 
a specific device. That is an asymmetric approach.
Rafael J. Wysocki Dec. 13, 2023, 3:16 p.m. UTC | #11
On Wed, Dec 13, 2023 at 4:10 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> On 13/12/2023 15:20, Christian Marangi wrote:
> > On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
> >> On 12/12/2023 23:13, Christian Marangi wrote:
> >>> Add initial support for cold and critical_cold trip point. Many if not
> >>> all hwmon and thermal device have normally trip point for hot
> >>> temperature and for cold temperature.
> >>>
> >>> Till now only hot temperature were supported. Add support for also cold
> >>> temperature to permit complete definition of cold trip point in DT.
> >>>
> >>> Thermal driver may use these additional trip point to correctly set
> >>> interrupt for cold temperature values and react based on that with
> >>> various measure like enabling attached heater, forcing higher voltage
> >>> and other specialaized peripherals.
> >>>
> >>> For hwmon drivers this is needed as currently there is a problem with
> >>> setting the full operating range of the device for thermal devices
> >>> defined with hwmon. To better describe the problem, the following
> >>> example is needed:
> >>>
> >>> In the scenario of a simple hwmon with an active trip point declared
> >>> and a cooling device attached, the hwmon subsystem currently set the
> >>> min and max trip point based on the single active trip point.
> >>> Thermal subsystem parse all the trip points and calculate the lowest and
> >>> the highest trip point and calls the .set_trip of hwmon to setup the
> >>> trip points.
> >>>
> >>> The fact that we currently don't have a way to declare the cold/min
> >>> temperature values, makes the thermal subsystem to set the low value as
> >>> -INT_MAX.
> >>> For hwmon drivers that doesn't use clamp_value and actually reject
> >>> invalid values for the trip point, this results in the hwmon settings to
> >>> be rejected.
> >>>
> >>> To permit to pass the correct range of trip point, permit to set in DT
> >>> also cold and critical_cold trip point.
> >>>
> >>> Thermal driver may also define .cold and .critical_cold to act on these
> >>> trip point tripped and apply the required measure.
> >>
> >> Agree with the feature but we need to clarify the semantic of the trip
> >> points first. What actions do we expect for them in order to have like a
> >> mirror reflection of the existing hot trip points.
> >>
> >> What action do you expect with:
> >>
> >>   - 'cold' ?
> >>
> >>   - 'critical_cold' ?
> >>
> >>
> >
> > This is more of a sensible topic but I think it's the thermal driver
> > that needs to implement these. As said in the commit description,
> > examples are setting higher voltage from the attached regulator,
> > enabling some hardware heater.
>
> That is a warming device. In the thermal framework design it is part of
> the mitigation device actors like a cooling device. The driver does not
> have to deal with that.
>
> > Maybe with critical cold bigger measure can be applied. Currently for
> > critical trip point we shutdown the system (if the critical ops is not
> > declared) but with critical_cold condition I think it won't work... I
> > expect a system in -40°C would just lock up/glitch so rebooting in that
> > condition won't change a thing...
>
>  From my POV, a critical trip point is for a too hot or too cold trip
> point. The temperature should be set before the system will be
> malfunctioning, so a halt (or reboot if set) should work.
>
> I'm not in favor of adding more callbacks if we can avoid them. Passing
> the trip point to the critical callback makes more sense to me.
>
> > Anyway yes we can define a shutdown by default for that but IMHO it
> > wouldn't make much sense.
>
> Why? If the device is about to go to out of the functioning range, then
> it makes sense to shut it down. IIRC, electric signals lose their
> stability below the lower bound temperature.
>
> There is the point about the mitigation to stay above a certain
> temperature. If the devices do not have any kind a 'warming' device,
> then an alternative would be to have a generic warming device mirroring
> the cooling device with a duty cycles at different performance states.
> With this case, we may need another trip point type for a governor which
> should handle that.
>
> So we end up with the question: shall we add trip point types or trip
> point properties?
>
> 1. Trip point types
>
>   - active / passive : mitigate
>   - hot : notify userspace
>   - critical : halt by default
>   - cold : do something
>   - cold_crit : do something else with a callback
>
> 2. Trip point types + property
>
>   - active / passive : mitigate
>     - hot : cool down
>     - cold : warm up
>
>   - hot : notify userspace
>   - cold : notify userspace
>
>   - critical:
>    - hot : shutdown (or callback + trip)
>    - cold : shutdown (or callback + trip)
>
> That implies there are two models:
>
> 1. We assume cold / hot trip points are symmetric features of the
> thermal management. So we do mitigation using governors, if that
> mitigation fails then we end up with critical actions. A consistent
> behavior between temperature increase or decrease. From my POV, I prefer
> this approach because it reflects nicely the functioning range temperature.

I agree here, FWIW.

> 2. We handle the cold situation differently by doing a on/off action on
> a specific device. That is an asymmetric approach.
Daniel Lezcano Dec. 13, 2023, 4 p.m. UTC | #12
On 13/12/2023 15:56, Christian Marangi wrote:
> On Wed, Dec 13, 2023 at 03:43:54PM +0100, Rafael J. Wysocki wrote:
>> On Wed, Dec 13, 2023 at 3:20 PM Christian Marangi <ansuelsmth@gmail.com> wrote:
>>>
>>> On Wed, Dec 13, 2023 at 03:12:41PM +0100, Daniel Lezcano wrote:
>>>> On 12/12/2023 23:13, Christian Marangi wrote:
>>>>> Add initial support for cold and critical_cold trip point. Many if not
>>>>> all hwmon and thermal device have normally trip point for hot
>>>>> temperature and for cold temperature.
>>>>>
>>>>> Till now only hot temperature were supported. Add support for also cold
>>>>> temperature to permit complete definition of cold trip point in DT.
>>>>>
>>>>> Thermal driver may use these additional trip point to correctly set
>>>>> interrupt for cold temperature values and react based on that with
>>>>> various measure like enabling attached heater, forcing higher voltage
>>>>> and other specialaized peripherals.
>>>>>
>>>>> For hwmon drivers this is needed as currently there is a problem with
>>>>> setting the full operating range of the device for thermal devices
>>>>> defined with hwmon. To better describe the problem, the following
>>>>> example is needed:
>>>>>
>>>>> In the scenario of a simple hwmon with an active trip point declared
>>>>> and a cooling device attached, the hwmon subsystem currently set the
>>>>> min and max trip point based on the single active trip point.
>>>>> Thermal subsystem parse all the trip points and calculate the lowest and
>>>>> the highest trip point and calls the .set_trip of hwmon to setup the
>>>>> trip points.
>>>>>
>>>>> The fact that we currently don't have a way to declare the cold/min
>>>>> temperature values, makes the thermal subsystem to set the low value as
>>>>> -INT_MAX.
>>>>> For hwmon drivers that doesn't use clamp_value and actually reject
>>>>> invalid values for the trip point, this results in the hwmon settings to
>>>>> be rejected.
>>>>>
>>>>> To permit to pass the correct range of trip point, permit to set in DT
>>>>> also cold and critical_cold trip point.
>>>>>
>>>>> Thermal driver may also define .cold and .critical_cold to act on these
>>>>> trip point tripped and apply the required measure.
>>>>
>>>> Agree with the feature but we need to clarify the semantic of the trip
>>>> points first. What actions do we expect for them in order to have like a
>>>> mirror reflection of the existing hot trip points.
>>>>
>>>> What action do you expect with:
>>>>
>>>>   - 'cold' ?
>>>>
>>>>   - 'critical_cold' ?
>>>>
>>>>
>>>
>>> This is more of a sensible topic but I think it's the thermal driver
>>> that needs to implement these. As said in the commit description,
>>> examples are setting higher voltage from the attached regulator,
>>> enabling some hardware heater.
>>
>> So how is it different from an active trip point?  There are heating
>> rather than cooling devices associated with it, but other than this??
>>
> 
>  From what I read from documentation, active trip point are used to
> trigger cooling-device. Cold (and crit_cold) are to setup trip point to
> the device. The device will normally trigger an interrupt (or even
> internally with the correct register set autonomously apply some measure
> to handle the problem)

Actually what specifies an active cooling device is it requires energy 
in order to operate. More precisely, the goal of an active cooling 
device is too move the heat from one place to another place. So the 
system, instead of relying on the natural convection thermal transfer, 
will force this transfer. So the "active" means external system + energy.

> In theory it's possible to have passive trip point for cold condition
> but still we lack any definition of the lower spectrum of the trip
> point.

Yes, absolutely :) And that is why I think we should clarify that to 
conform to the general semantic of the thermal management. If we define 
things in the thermal framework but having a different meaning in the 
thermal management vocabulary. That will be really odd and look amateur 
work :)

In the lower spectrum, an external warming device where we use energy to 
provide some heat is active. But if we use some kind of software 
solution (like what suggested before), we indeed use energy, but the 
solution is internal to the system, so I do believe we can consider it 
as passive.

IMO, we should see, especially on mobile, passive trip point for too 
hot, and active trip point for too cold. That would not surprising as 
the former has too much energy generated and the latter not enough energy.

(BTW, as a side note, active or passive trip points do not really make 
sense to me. It is the mitigation devices which are active or passive).

For the systems which do not have a dedicated warming up hardware, we 
should implement a "warming device" as a passive one (which is a 
different story from your proposal I agree).


>>> Maybe with critical cold bigger measure can be applied. Currently for
>>> critical trip point we shutdown the system (if the critical ops is not
>>> declared) but with critical_cold condition I think it won't work... I
>>> expect a system in -40°C would just lock up/glitch so rebooting in that
>>> condition won't change a thing...
>>>
>>> Anyway yes we can define a shutdown by default for that but IMHO it
>>> wouldn't make much sense.
>>
>> So why do you want to add it at all?
> 
> Again it's really to fill a hole we have from a long time... One example
> is the qcom tsens driver that have trip point for cold and crit_cold.
> Those in theory can be set in DT with the trip point but we lack any
> definition for them. (using passive trip point would be confusing IMHO)
> 
> Another example is an Aquantia PHY that have register for the cold and
> critical_cold trip point.
> 
> Currently defining a critical trip point for the negative temp results
> in the system shutdown.

Yes, and the more I think about it, the more I'm inclined to have:

  * trip (active|passive) + hot|cold
  * trip cold (meaning "really too cold")
  * trip hot (meaning "really too hot")
  * trip critical (meaning "I'm about to collapse")

We may have also active devices with multiple level of warm up, so it 
will need to be managed by a governor like the step wise.
diff mbox series

Patch

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 9c17d35ccbbd..3c5ab560e72f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -344,6 +344,17 @@  static void handle_critical_trips(struct thermal_zone_device *tz,
 		tz->ops->hot(tz);
 }
 
+static void handle_critical_cold_trips(struct thermal_zone_device *tz,
+				       const struct thermal_trip *trip)
+{
+	trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
+
+	if (trip->type == THERMAL_TRIP_CRITICAL_COLD && tz->ops->critical_cold)
+		tz->ops->critical_cold(tz);
+	else if (trip->type == THERMAL_TRIP_COLD && tz->ops->cold)
+		tz->ops->cold(tz);
+}
+
 static void handle_thermal_trip(struct thermal_zone_device *tz,
 				const struct thermal_trip *trip)
 {
@@ -365,6 +376,8 @@  static void handle_thermal_trip(struct thermal_zone_device *tz,
 
 	if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
 		handle_critical_trips(tz, trip);
+	else if (trip->type == THERMAL_TRIP_CRITICAL_COLD || trip->type == THERMAL_TRIP_COLD)
+		handle_critical_cold_trips(tz, trip);
 	else
 		handle_non_critical_trips(tz, trip);
 }
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 1e0655b63259..95bc600bb4b8 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -60,6 +60,8 @@  static const char * const trip_types[] = {
 	[THERMAL_TRIP_PASSIVE]	= "passive",
 	[THERMAL_TRIP_HOT]	= "hot",
 	[THERMAL_TRIP_CRITICAL]	= "critical",
+	[THERMAL_TRIP_COLD]	= "cold",
+	[THERMAL_TRIP_CRITICAL_COLD] = "critical_cold",
 };
 
 /**
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index eef40d4f3063..e1e69e0991c2 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -106,6 +106,10 @@  trip_point_type_show(struct device *dev, struct device_attribute *attr,
 		return sprintf(buf, "critical\n");
 	case THERMAL_TRIP_HOT:
 		return sprintf(buf, "hot\n");
+	case THERMAL_TRIP_COLD:
+		return sprintf(buf, "cold\n");
+	case THERMAL_TRIP_CRITICAL_COLD:
+		return sprintf(buf, "critical_cold\n");
 	case THERMAL_TRIP_PASSIVE:
 		return sprintf(buf, "passive\n");
 	case THERMAL_TRIP_ACTIVE:
diff --git a/drivers/thermal/thermal_trace.h b/drivers/thermal/thermal_trace.h
index 459c8ce6cf3b..0a4f96075d7d 100644
--- a/drivers/thermal/thermal_trace.h
+++ b/drivers/thermal/thermal_trace.h
@@ -11,6 +11,8 @@ 
 
 TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
 TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
+TRACE_DEFINE_ENUM(THERMAL_TRIP_COLD);
+TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL_COLD);
 TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
 TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
 
@@ -18,6 +20,8 @@  TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
 	__print_symbolic(type,					\
 			 { THERMAL_TRIP_CRITICAL, "CRITICAL"},	\
 			 { THERMAL_TRIP_HOT,      "HOT"},	\
+			 { THERMAL_TRIP_COLD,      "COLD"},	\
+			 { THERMAL_TRIP_CRITICAL_COLD, "CRITICAL_COLD"}, \
 			 { THERMAL_TRIP_PASSIVE,  "PASSIVE"},	\
 			 { THERMAL_TRIP_ACTIVE,   "ACTIVE"})
 
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index cee814d5d1ac..d6345c9ec50d 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -84,6 +84,8 @@  struct thermal_zone_device_ops {
 			  const struct thermal_trip *, enum thermal_trend *);
 	void (*hot)(struct thermal_zone_device *);
 	void (*critical)(struct thermal_zone_device *);
+	void (*cold)(struct thermal_zone_device *);
+	void (*critical_cold)(struct thermal_zone_device *);
 };
 
 struct thermal_cooling_device_ops {
diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h
index fc78bf3aead7..7fa1ba0dff05 100644
--- a/include/uapi/linux/thermal.h
+++ b/include/uapi/linux/thermal.h
@@ -14,6 +14,8 @@  enum thermal_trip_type {
 	THERMAL_TRIP_PASSIVE,
 	THERMAL_TRIP_HOT,
 	THERMAL_TRIP_CRITICAL,
+	THERMAL_TRIP_COLD,
+	THERMAL_TRIP_CRITICAL_COLD,
 };
 
 /* Adding event notification support elements */