diff mbox

[11/13] Thermal: Add a notification API

Message ID 1344516365-7230-12-git-send-email-durgadoss.r@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

durgadoss.r@intel.com Aug. 9, 2012, 12:46 p.m. UTC
This patch adds a notification API which the sensor drivers'
can use to notify the framework. The framework then takes
care of the throttling according to the configured policy.

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
---
 drivers/thermal/thermal_sys.c |   18 ++++++++++++++++++
 include/linux/thermal.h       |    1 +
 2 files changed, 19 insertions(+)

Comments

Zhang, Rui Aug. 13, 2012, 7:02 a.m. UTC | #1
On ?, 2012-08-09 at 18:16 +0530, Durgadoss R wrote:
> This patch adds a notification API which the sensor drivers'
> can use to notify the framework. The framework then takes
> care of the throttling according to the configured policy.
> 
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> ---
>  drivers/thermal/thermal_sys.c |   18 ++++++++++++++++++
>  include/linux/thermal.h       |    1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 193d071..6931d81 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -1309,6 +1309,24 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
>  }
>  EXPORT_SYMBOL(thermal_cooling_device_unregister);
>  
> +/**
> + * notify_thermal_framework - Sensor drivers use this API to notify framework
> + * @tz:		thermal zone device
> + * @trip:	indicates which trip point has been crossed
> + *
> + * This function handles the trip events from sensor drivers. It starts
> + * throttling the cooling devices according to the policy configured.
> + * For CRITICAL and HOT trip points, this notifies the respective drivers,
> + * and does actual throttling for other trip points i.e ACTIVE and PASSIVE.
> + * The throttling policy is based on the configured platform data; if no
> + * platform data is provided, this uses the step_wise throttling policy.
> + */
> +void notify_thermal_framework(struct thermal_zone_device *tz, int trip)
> +{
> +	handle_thermal_trip(tz, trip);
> +}
> +EXPORT_SYMBOL(notify_thermal_framework);
> +
why thermal_zone_device_update() can not work here?

thanks,
rui
>  static int create_policy_attr(struct thermal_zone_device *tz)
>  {
>  	sysfs_attr_init(&tz->policy_attr.attr);
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 3bdf5f2..a3a0144 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -246,6 +246,7 @@ int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_cooling_device *get_cdev_by_name(const char *);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> +void notify_thermal_framework(struct thermal_zone_device *, int);
>  
>  /*
>   * The platform layer shall define a 'function' that provides the


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
durgadoss.r@intel.com Aug. 13, 2012, 7:46 a.m. UTC | #2
SGkgUnVpLA0KDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogWmhhbmcs
IFJ1aQ0KPiBTZW50OiBNb25kYXksIEF1Z3VzdCAxMywgMjAxMiAxMjozMyBQTQ0KPiBUbzogUiwg
RHVyZ2Fkb3NzDQo+IENjOiBsZW5iQGtlcm5lbC5vcmc7IHJqd0BzaXNrLnBsOyBsaW51eC1hY3Bp
QHZnZXIua2VybmVsLm9yZzsgbGludXgtDQo+IHBtQHZnZXIua2VybmVsLm9yZzsgZWR1YXJkby52
YWxlbnRpbkB0aS5jb207IGFtaXQua2FjaGhhcEBsaW5hcm8ub3JnOw0KPiB3bmlAbnZpZGlhLmNv
bQ0KPiBTdWJqZWN0OiBSZTogW1BBVENIIDExLzEzXSBUaGVybWFsOiBBZGQgYSBub3RpZmljYXRp
b24gQVBJDQo+IA0KPiBPbiDlm5ssIDIwMTItMDgtMDkgYXQgMTg6MTYgKzA1MzAsIER1cmdhZG9z
cyBSIHdyb3RlOg0KPiA+IFRoaXMgcGF0Y2ggYWRkcyBhIG5vd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gdHJpcCk7DQo+ID4gK30NCj4gPiArRVhQT1JUX1NZTUJPTChub3RpZnlfdGhlcm1hbF9m
cmFtZXdvcmspOw0KPiA+ICsNCj4gd2h5IHRoZXJtYWxfem9uZV9kZXZpY2VfdXBkYXRlKCkgY2Fu
IG5vdCB3b3JrIGhlcmU/DQoNCkl0IGNhbiB3b3JrLiBCdXQgdGhlcm1hbF96b25lX2RldmljZV91
cGRhdGUoKSBnb2VzIG92ZXIgdGhlDQpsaXN0IG9mIGFsbCB0cmlwIHBvaW50cyB3aGVyZWFzIGhl
cmUgd2Uga25vdyAndHJpcCcgaXMgdGhlIHRyaXAgcG9pbnQNCnRoYXQgd2UgaGF2ZSB0byBoYW5k
bGUgbm93LiBTbywgd2h5IGRvIHdlIG5lZWQgdG8gaXRlcmF0ZSBvdmVyIGFsbCB0cmlwDQpwb2lu
dHMgYWdhaW4gPw0KVGhhdOKAmXMgd2h5IGl0IGlzIGltcGxlbWVudGVkIHRoaXMgd2F5Lg0KDQpU
aGFua3MsDQpEdXJnYQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eduardo Valentin Aug. 21, 2012, 5:17 a.m. UTC | #3
Hello,

On Mon, Aug 13, 2012 at 07:46:20AM +0000, R, Durgadoss wrote:
> Hi Rui,
> 
> 
> > -----Original Message-----
> > From: Zhang, Rui
> > Sent: Monday, August 13, 2012 12:33 PM
> > To: R, Durgadoss
> > Cc: lenb@kernel.org; rjw@sisk.pl; linux-acpi@vger.kernel.org; linux-
> > pm@vger.kernel.org; eduardo.valentin@ti.com; amit.kachhap@linaro.org;
> > wni@nvidia.com
> > Subject: Re: [PATCH 11/13] Thermal: Add a notification API
> > 
> > On ?, 2012-08-09 at 18:16 +0530, Durgadoss R wrote:
> > > This patch adds a notification API which the sensor drivers'
> > > can use to notify the framework. The framework then takes
> > > care of the throttling according to the configured policy.
> > >
> > > Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> > > ---
> > >  drivers/thermal/thermal_sys.c |   18 ++++++++++++++++++
> > >  include/linux/thermal.h       |    1 +
> > >  2 files changed, 19 insertions(+)
> > >
> > > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > > index 193d071..6931d81 100644
> > > --- a/drivers/thermal/thermal_sys.c
> > > +++ b/drivers/thermal/thermal_sys.c
> > > @@ -1309,6 +1309,24 @@ void thermal_cooling_device_unregister(struct
> > thermal_cooling_device *cdev)
> > >  }
> > >  EXPORT_SYMBOL(thermal_cooling_device_unregister);
> > >
> > > +/**
> > > + * notify_thermal_framework - Sensor drivers use this API to notify
> > framework
> > > + * @tz:		thermal zone device
> > > + * @trip:	indicates which trip point has been crossed
> > > + *
> > > + * This function handles the trip events from sensor drivers. It starts
> > > + * throttling the cooling devices according to the policy configured.
> > > + * For CRITICAL and HOT trip points, this notifies the respective drivers,
> > > + * and does actual throttling for other trip points i.e ACTIVE and PASSIVE.
> > > + * The throttling policy is based on the configured platform data; if no
> > > + * platform data is provided, this uses the step_wise throttling policy.
> > > + */
> > > +void notify_thermal_framework(struct thermal_zone_device *tz, int trip)
> > > +{
> > > +	handle_thermal_trip(tz, trip);
> > > +}
> > > +EXPORT_SYMBOL(notify_thermal_framework);
> > > +
> > why thermal_zone_device_update() can not work here?
> 
> It can work. But thermal_zone_device_update() goes over the
> list of all trip points whereas here we know 'trip' is the trip point
> that we have to handle now. So, why do we need to iterate over all trip
> points again ?
> That’s why it is implemented this way.

I see. But there is no example of usage of this API on this series?

> 
> Thanks,
> Durga
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 193d071..6931d81 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1309,6 +1309,24 @@  void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
 }
 EXPORT_SYMBOL(thermal_cooling_device_unregister);
 
+/**
+ * notify_thermal_framework - Sensor drivers use this API to notify framework
+ * @tz:		thermal zone device
+ * @trip:	indicates which trip point has been crossed
+ *
+ * This function handles the trip events from sensor drivers. It starts
+ * throttling the cooling devices according to the policy configured.
+ * For CRITICAL and HOT trip points, this notifies the respective drivers,
+ * and does actual throttling for other trip points i.e ACTIVE and PASSIVE.
+ * The throttling policy is based on the configured platform data; if no
+ * platform data is provided, this uses the step_wise throttling policy.
+ */
+void notify_thermal_framework(struct thermal_zone_device *tz, int trip)
+{
+	handle_thermal_trip(tz, trip);
+}
+EXPORT_SYMBOL(notify_thermal_framework);
+
 static int create_policy_attr(struct thermal_zone_device *tz)
 {
 	sysfs_attr_init(&tz->policy_attr.attr);
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 3bdf5f2..a3a0144 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -246,6 +246,7 @@  int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_cooling_device *get_cdev_by_name(const char *);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
+void notify_thermal_framework(struct thermal_zone_device *, int);
 
 /*
  * The platform layer shall define a 'function' that provides the