aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorKapileshwar Singh <kapileshwar.singh@arm.com>2015-02-18 11:04:21 -0500
committerEduardo Valentin <edubezval@gmail.com>2015-05-05 00:27:50 -0400
commit6cd9e9f629f11b9412d4e9aa294c029dbb36b3cf (patch)
tree33ef735ad3704b0596eab47e24a22853ca9c31a1 /drivers/thermal
parent5ebe6afaf0057ac3eaeb98defd5456894b446d22 (diff)
thermal: of: fix cooling device weights in device tree
Currently you can specify the weight of the cooling device in the device tree but that information is not populated to the thermal_bind_params where the fair share governor expects it to be. The of thermal zone device doesn't have a thermal_bind_params structure and arguably it's better to pass the weight inside the thermal_instance as it is specific to the bind of a cooling device to a thermal zone parameter. Core thermal code is fixed to populate the weight in the instance from the thermal_bind_params, so platform code that was passing the weight inside the thermal_bind_params continue to work seamlessly. While we are at it, create a default value for the weight parameter for those thermal zones that currently don't define it and remove the hardcoded default in of-thermal. Cc: Zhang Rui <rui.zhang@intel.com> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Len Brown <lenb@kernel.org> Cc: Peter Feuerer <peter@piie.net> Cc: Darren Hart <dvhart@infradead.org> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Kukjin Kim <kgene@kernel.org> Cc: Durgadoss R <durgadoss.r@intel.com> Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/db8500_thermal.c2
-rw-r--r--drivers/thermal/fair_share.c2
-rw-r--r--drivers/thermal/imx_thermal.c3
-rw-r--r--drivers/thermal/of-thermal.c5
-rw-r--r--drivers/thermal/thermal_core.c22
-rw-r--r--drivers/thermal/thermal_core.h1
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-thermal-common.c3
7 files changed, 26 insertions, 12 deletions
diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index 20adfbe27df1..2fb273c4baa9 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -76,7 +76,7 @@ static int db8500_cdev_bind(struct thermal_zone_device *thermal,
76 upper = lower = i > max_state ? max_state : i; 76 upper = lower = i > max_state ? max_state : i;
77 77
78 ret = thermal_zone_bind_cooling_device(thermal, i, cdev, 78 ret = thermal_zone_bind_cooling_device(thermal, i, cdev,
79 upper, lower); 79 upper, lower, THERMAL_WEIGHT_DEFAULT);
80 80
81 dev_info(&cdev->device, "%s bind to %d: %d-%s\n", cdev->type, 81 dev_info(&cdev->device, "%s bind to %d: %d-%s\n", cdev->type,
82 i, ret, ret ? "fail" : "succeed"); 82 i, ret, ret ? "fail" : "succeed");
diff --git a/drivers/thermal/fair_share.c b/drivers/thermal/fair_share.c
index 6e0a3fbfae86..c3b25187b467 100644
--- a/drivers/thermal/fair_share.c
+++ b/drivers/thermal/fair_share.c
@@ -109,7 +109,7 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
109 continue; 109 continue;
110 110
111 instance->target = get_target_state(tz, cdev, 111 instance->target = get_target_state(tz, cdev,
112 tzp->tbp[i].weight, cur_trip_level); 112 instance->weight, cur_trip_level);
113 113
114 instance->cdev->updated = false; 114 instance->cdev->updated = false;
115 thermal_cdev_update(cdev); 115 thermal_cdev_update(cdev);
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 2ccbc0788353..fde4c2876d14 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -306,7 +306,8 @@ static int imx_bind(struct thermal_zone_device *tz,
306 306
307 ret = thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev, 307 ret = thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev,
308 THERMAL_NO_LIMIT, 308 THERMAL_NO_LIMIT,
309 THERMAL_NO_LIMIT); 309 THERMAL_NO_LIMIT,
310 THERMAL_WEIGHT_DEFAULT);
310 if (ret) { 311 if (ret) {
311 dev_err(&tz->device, 312 dev_err(&tz->device,
312 "binding zone %s with cdev %s failed:%d\n", 313 "binding zone %s with cdev %s failed:%d\n",
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 668fb1bdea9e..c606b85ea9f4 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -227,7 +227,8 @@ static int of_thermal_bind(struct thermal_zone_device *thermal,
227 ret = thermal_zone_bind_cooling_device(thermal, 227 ret = thermal_zone_bind_cooling_device(thermal,
228 tbp->trip_id, cdev, 228 tbp->trip_id, cdev,
229 tbp->max, 229 tbp->max,
230 tbp->min); 230 tbp->min,
231 tbp->usage);
231 if (ret) 232 if (ret)
232 return ret; 233 return ret;
233 } 234 }
@@ -581,7 +582,7 @@ static int thermal_of_populate_bind_params(struct device_node *np,
581 u32 prop; 582 u32 prop;
582 583
583 /* Default weight. Usage is optional */ 584 /* Default weight. Usage is optional */
584 __tbp->usage = 0; 585 __tbp->usage = THERMAL_WEIGHT_DEFAULT;
585 ret = of_property_read_u32(np, "contribution", &prop); 586 ret = of_property_read_u32(np, "contribution", &prop);
586 if (ret == 0) 587 if (ret == 0)
587 __tbp->usage = prop; 588 __tbp->usage = prop;
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 4108db7e10c1..a6cb9b78b629 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -218,7 +218,8 @@ static void print_bind_err_msg(struct thermal_zone_device *tz,
218 218
219static void __bind(struct thermal_zone_device *tz, int mask, 219static void __bind(struct thermal_zone_device *tz, int mask,
220 struct thermal_cooling_device *cdev, 220 struct thermal_cooling_device *cdev,
221 unsigned long *limits) 221 unsigned long *limits,
222 unsigned int weight)
222{ 223{
223 int i, ret; 224 int i, ret;
224 225
@@ -233,7 +234,8 @@ static void __bind(struct thermal_zone_device *tz, int mask,
233 upper = limits[i * 2 + 1]; 234 upper = limits[i * 2 + 1];
234 } 235 }
235 ret = thermal_zone_bind_cooling_device(tz, i, cdev, 236 ret = thermal_zone_bind_cooling_device(tz, i, cdev,
236 upper, lower); 237 upper, lower,
238 weight);
237 if (ret) 239 if (ret)
238 print_bind_err_msg(tz, cdev, ret); 240 print_bind_err_msg(tz, cdev, ret);
239 } 241 }
@@ -280,7 +282,8 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
280 continue; 282 continue;
281 tzp->tbp[i].cdev = cdev; 283 tzp->tbp[i].cdev = cdev;
282 __bind(pos, tzp->tbp[i].trip_mask, cdev, 284 __bind(pos, tzp->tbp[i].trip_mask, cdev,
283 tzp->tbp[i].binding_limits); 285 tzp->tbp[i].binding_limits,
286 tzp->tbp[i].weight);
284 } 287 }
285 } 288 }
286 289
@@ -319,7 +322,8 @@ static void bind_tz(struct thermal_zone_device *tz)
319 continue; 322 continue;
320 tzp->tbp[i].cdev = pos; 323 tzp->tbp[i].cdev = pos;
321 __bind(tz, tzp->tbp[i].trip_mask, pos, 324 __bind(tz, tzp->tbp[i].trip_mask, pos,
322 tzp->tbp[i].binding_limits); 325 tzp->tbp[i].binding_limits,
326 tzp->tbp[i].weight);
323 } 327 }
324 } 328 }
325exit: 329exit:
@@ -713,7 +717,8 @@ passive_store(struct device *dev, struct device_attribute *attr,
713 thermal_zone_bind_cooling_device(tz, 717 thermal_zone_bind_cooling_device(tz,
714 THERMAL_TRIPS_NONE, cdev, 718 THERMAL_TRIPS_NONE, cdev,
715 THERMAL_NO_LIMIT, 719 THERMAL_NO_LIMIT,
716 THERMAL_NO_LIMIT); 720 THERMAL_NO_LIMIT,
721 THERMAL_WEIGHT_DEFAULT);
717 } 722 }
718 mutex_unlock(&thermal_list_lock); 723 mutex_unlock(&thermal_list_lock);
719 if (!tz->passive_delay) 724 if (!tz->passive_delay)
@@ -931,6 +936,9 @@ static const struct attribute_group *cooling_device_attr_groups[] = {
931 * @lower: the Minimum cooling state can be used for this trip point. 936 * @lower: the Minimum cooling state can be used for this trip point.
932 * THERMAL_NO_LIMIT means no lower limit, 937 * THERMAL_NO_LIMIT means no lower limit,
933 * and the cooling device can be in cooling state 0. 938 * and the cooling device can be in cooling state 0.
939 * @weight: The weight of the cooling device to be bound to the
940 * thermal zone. Use THERMAL_WEIGHT_DEFAULT for the
941 * default value
934 * 942 *
935 * This interface function bind a thermal cooling device to the certain trip 943 * This interface function bind a thermal cooling device to the certain trip
936 * point of a thermal zone device. 944 * point of a thermal zone device.
@@ -941,7 +949,8 @@ static const struct attribute_group *cooling_device_attr_groups[] = {
941int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, 949int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
942 int trip, 950 int trip,
943 struct thermal_cooling_device *cdev, 951 struct thermal_cooling_device *cdev,
944 unsigned long upper, unsigned long lower) 952 unsigned long upper, unsigned long lower,
953 unsigned int weight)
945{ 954{
946 struct thermal_instance *dev; 955 struct thermal_instance *dev;
947 struct thermal_instance *pos; 956 struct thermal_instance *pos;
@@ -986,6 +995,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
986 dev->upper = upper; 995 dev->upper = upper;
987 dev->lower = lower; 996 dev->lower = lower;
988 dev->target = THERMAL_NO_TARGET; 997 dev->target = THERMAL_NO_TARGET;
998 dev->weight = weight;
989 999
990 result = get_idr(&tz->idr, &tz->lock, &dev->id); 1000 result = get_idr(&tz->idr, &tz->lock, &dev->id);
991 if (result) 1001 if (result)
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 0531c752fbbb..7a465e9d456c 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -48,6 +48,7 @@ struct thermal_instance {
48 struct device_attribute attr; 48 struct device_attribute attr;
49 struct list_head tz_node; /* node in tz->thermal_instances */ 49 struct list_head tz_node; /* node in tz->thermal_instances */
50 struct list_head cdev_node; /* node in cdev->thermal_instances */ 50 struct list_head cdev_node; /* node in cdev->thermal_instances */
51 unsigned int weight; /* The weight of the cooling device */
51}; 52};
52 53
53int thermal_register_governor(struct thermal_governor *); 54int thermal_register_governor(struct thermal_governor *);
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index a38c1756442a..cb45e729adb5 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -146,7 +146,8 @@ static int ti_thermal_bind(struct thermal_zone_device *thermal,
146 return thermal_zone_bind_cooling_device(thermal, 0, cdev, 146 return thermal_zone_bind_cooling_device(thermal, 0, cdev,
147 /* bind with min and max states defined by cpu_cooling */ 147 /* bind with min and max states defined by cpu_cooling */
148 THERMAL_NO_LIMIT, 148 THERMAL_NO_LIMIT,
149 THERMAL_NO_LIMIT); 149 THERMAL_NO_LIMIT,
150 THERMAL_WEIGHT_DEFAULT);
150} 151}
151 152
152/* Unbind callback functions for thermal zone */ 153/* Unbind callback functions for thermal zone */