Re: [RFC PATCH 6/12] thermal: introduce active cooling algorithm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Mon, Jun 11, 2012 at 02:38:24PM +0800, Zhang Rui wrote:
> On 一, 2012-06-11 at 10:21 +0530, Amit Kachhap wrote:
> > On 11 June 2012 08:50, Zhang Rui <rui.zhang@xxxxxxxxx> wrote:
> > >
> > > Introduce thermal_zone_trip_update() to update the cooling state
> > > of all the cooling devices that are binded to an active trip point.
> > >
> > > This will be used for passive cooling as well, in the future patches.
> > > as both active and passive cooling can share the same algorithm,
> > > which is
> > >
> > > 1. if the temperature is higher than a trip point,
> > >   a. if the trend is THERMAL_TREND_RAISING, use higher cooling
> > >      state for this trip point
> > >   b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
> > >      state for this trip point
> > >
> > > 2. if the temperature is lower than a trip point, use lower
> > >   cooling state for this trip point.
> > >
> > > Signed-off-by: Zhang Rui <rui.zhang@xxxxxxxxx>
> > > ---
> > >  drivers/acpi/thermal.c        |    7 ++-
> > >  drivers/thermal/thermal_sys.c |   91 ++++++++++++++++++++++++++++++------------
> > >  2 files changed, 71 insertions(+), 27 deletions(-)
> > >
> > > Index: rtd3/drivers/thermal/thermal_sys.c
> > > ===================================================================
> > > --- rtd3.orig/drivers/thermal/thermal_sys.c
> > > +++ rtd3/drivers/thermal/thermal_sys.c
> > > @@ -1035,6 +1035,70 @@ void thermal_cooling_device_unregister(s
> > >  }
> > >  EXPORT_SYMBOL(thermal_cooling_device_unregister);
> > >
> > > +/*
> > > + * Cooling algorithm for active trip points
> > > + *
> > > + * 1. if the temperature is higher than a trip point,
> > > + *    a. if the trend is THERMAL_TREND_RAISING, use higher cooling
> > > + *       state for this trip point
> > > + *    b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
> > > + *       state for this trip point
> > > + *
> > > + * 2. if the temperature is lower than a trip point, use lower
> > > + *    cooling state for this trip point
> > > + *
> > > + * Note that this behaves the same as the previous passive cooling
> > > + * algorithm.
> > > + */
> > > +
> > > +static void thermal_zone_trip_update(struct thermal_zone_device *tz,
> > > +                                    int trip, long temp)
> > > +{
> > > +       struct thermal_cooling_device_instance *instance;
> > > +       struct thermal_cooling_device *cdev = NULL;
> > > +       unsigned long cur_state, max_state;
> > > +       long trip_temp;
> > > +       enum thermal_trend trend;
> > > +
> > > +       tz->ops->get_trip_temp(tz, trip, &trip_temp);
> > > +
> > > +       if (temp >= trip_temp) {
> > > +               thermal_get_trend(tz, trip, &trend);
> > > +
> > > +               list_for_each_entry(instance, &tz->cooling_devices, node) {
> > > +                       if (instance->trip != trip)
> > > +                               continue;
> > > +
> > > +                       cdev = instance->cdev;
> > > +
> > > +                       cdev->ops->get_cur_state(cdev, &cur_state);
> > > +                       cdev->ops->get_max_state(cdev, &max_state);
> > > +
> > > +                       if (trend == THERMAL_TREND_RAISING) {
> > > +                               cur_state = cur_state < instance->upper ?
> > > +                                           (cur_state + 1) : instance->upper;
> > > +                       } else if (trend == THERMAL_TREND_DROPPING) {
> > > +                               cur_state = cur_state > instance->lower ?
> > > +                                   (cur_state - 1) : instance->lower;
> > > +                       }
> > > +                       cdev->ops->set_cur_state(cdev, cur_state);
> > > +               }
> > > +       } else {        /* below trip */
> > > +               list_for_each_entry(instance, &tz->cooling_devices, node) {
> > > +                       if (instance->trip != trip)
> > > +                               continue;
> > Can we use the trend callback here even if the current temperature is
> > less than the trip temperature. Basically according to trend it should
> > deactivate the cooling devices as done for activating cooling devices.
> 
> yes, this depends on the cooling algorithm we want to use.
> When the temperature is lower than the trip point, if we want to stop
> the fan immediately instead of spinning down step by step, we can do
> this.
> 
> Actually, what we are discussing right now should be some cooling
> governor stuff. which I'm not sure if we should introduce to the generic
> thermal manager or not, right now. :)

Rui, this is an interesting point. Do you have plans to have governor like approach
in the generic thermal fw? Or are you sticking to the zone/cooling binding?

> 
> thanks,
> rui
> 
> > > +
> > > +                       cdev = instance->cdev;
> > > +                       cdev->ops->get_cur_state(cdev, &cur_state);
> > > +
> > > +                       cur_state = cur_state > instance->lower ?
> > > +                                   (cur_state - 1) : instance->lower;
> > > +                       cdev->ops->set_cur_state(cdev, cur_state);
> > > +               }
> > > +       }
> > > +
> > > +       return;
> > > +}
> > >  /**
> > >  * thermal_zone_device_update - force an update of a thermal zone's state
> > >  * @ttz:       the thermal zone to update
> > > @@ -1045,9 +1109,6 @@ void thermal_zone_device_update(struct t
> > >        int count, ret = 0;
> > >        long temp, trip_temp;
> > >        enum thermal_trip_type trip_type;
> > > -       struct thermal_cooling_device_instance *instance;
> > > -       struct thermal_cooling_device *cdev;
> > > -       unsigned long cur_state, max_state;
> > >
> > >        mutex_lock(&tz->lock);
> > >
> > > @@ -1083,29 +1144,7 @@ void thermal_zone_device_update(struct t
> > >                                        tz->ops->notify(tz, count, trip_type);
> > >                        break;
> > >                case THERMAL_TRIP_ACTIVE:
> > > -                       list_for_each_entry(instance, &tz->cooling_devices,
> > > -                                           node) {
> > > -                               if (instance->trip != count)
> > > -                                       continue;
> > > -
> > > -                               cdev = instance->cdev;
> > > -
> > > -                               cdev->ops->get_cur_state(cdev, &cur_state);
> > > -                               cdev->ops->get_max_state(cdev, &max_state);
> > > -
> > > -                               if (temp >= trip_temp)
> > > -                                       cur_state =
> > > -                                               cur_state < instance->upper ?
> > > -                                               (cur_state + 1) :
> > > -                                               instance->upper;
> > > -                               else
> > > -                                       cur_state =
> > > -                                               cur_state > instance->lower ?
> > > -                                               (cur_state - 1) :
> > > -                                               instance->lower;
> > > -
> > > -                               cdev->ops->set_cur_state(cdev, cur_state);
> > > -                       }
> > > +                       thermal_zone_trip_update(tz, count, temp);
> > >                        break;
> > >                case THERMAL_TRIP_PASSIVE:
> > >                        if (temp >= trip_temp || tz->passive)
> > > Index: rtd3/drivers/acpi/thermal.c
> > > ===================================================================
> > > --- rtd3.orig/drivers/acpi/thermal.c
> > > +++ rtd3/drivers/acpi/thermal.c
> > > @@ -717,7 +717,12 @@ static int thermal_get_trend(struct ther
> > >        if (thermal_get_trip_type(thermal, trip, &type))
> > >                return -EINVAL;
> > >
> > > -       /* Only PASSIVE trip points need TREND */
> > > +       if (type == THERMAL_TRIP_ACTIVE) {
> > > +               /* aggressive active cooling */
> > > +               *trend = THERMAL_TREND_RAISING;
> > > +               return 0;
> > > +       }
> > > +
> > >        if (type != THERMAL_TRIP_PASSIVE)
> > >                return -EINVAL;
> > >
> > >
> > >
> 
> 
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/linux-pm



[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux