Code Review
/
kvmfornfv.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git]
/
kernel
/
drivers
/
thermal
/
fair_share.c
diff --git
a/kernel/drivers/thermal/fair_share.c
b/kernel/drivers/thermal/fair_share.c
index
6e0a3fb
..
34fe365
100644
(file)
--- a/
kernel/drivers/thermal/fair_share.c
+++ b/
kernel/drivers/thermal/fair_share.c
@@
-34,7
+34,7
@@
static int get_trip_level(struct thermal_zone_device *tz)
{
int count = 0;
static int get_trip_level(struct thermal_zone_device *tz)
{
int count = 0;
-
unsigned long
trip_temp;
+
int
trip_temp;
enum thermal_trip_type trip_type;
if (tz->trips == 0 || !tz->ops->get_trip_temp)
enum thermal_trip_type trip_type;
if (tz->trips == 0 || !tz->ops->get_trip_temp)
@@
-59,17
+59,17
@@
static int get_trip_level(struct thermal_zone_device *tz)
}
static long get_target_state(struct thermal_zone_device *tz,
}
static long get_target_state(struct thermal_zone_device *tz,
- struct thermal_cooling_device *cdev, int
weight
, int level)
+ struct thermal_cooling_device *cdev, int
percentage
, int level)
{
unsigned long max_state;
cdev->ops->get_max_state(cdev, &max_state);
{
unsigned long max_state;
cdev->ops->get_max_state(cdev, &max_state);
- return (long)(
weight
* level * max_state) / (100 * tz->trips);
+ return (long)(
percentage
* level * max_state) / (100 * tz->trips);
}
/**
}
/**
- * fair_share_throttle - throttles devices ass
c
ciated with the given zone
+ * fair_share_throttle - throttles devices ass
o
ciated with the given zone
* @tz - thermal_zone_device
*
* Throttling Logic: This uses three parameters to calculate the new
* @tz - thermal_zone_device
*
* Throttling Logic: This uses three parameters to calculate the new
@@
-77,7
+77,7
@@
static long get_target_state(struct thermal_zone_device *tz,
*
* Parameters used for Throttling:
* P1. max_state: Maximum throttle state exposed by the cooling device.
*
* Parameters used for Throttling:
* P1. max_state: Maximum throttle state exposed by the cooling device.
- * P2.
weight
[i]/100:
+ * P2.
percentage
[i]/100:
* How 'effective' the 'i'th device is, in cooling the given zone.
* P3. cur_trip_level/max_no_of_trips:
* This describes the extent to which the devices should be throttled.
* How 'effective' the 'i'th device is, in cooling the given zone.
* P3. cur_trip_level/max_no_of_trips:
* This describes the extent to which the devices should be throttled.
@@
-88,28
+88,33
@@
static long get_target_state(struct thermal_zone_device *tz,
*/
static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
{
*/
static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
{
- const struct thermal_zone_params *tzp;
- struct thermal_cooling_device *cdev;
struct thermal_instance *instance;
struct thermal_instance *instance;
- int i;
+ int total_weight = 0;
+ int total_instance = 0;
int cur_trip_level = get_trip_level(tz);
int cur_trip_level = get_trip_level(tz);
- if (!tz->tzp || !tz->tzp->tbp)
- return -EINVAL;
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+ if (instance->trip != trip)
+ continue;
+
+ total_weight += instance->weight;
+ total_instance++;
+ }
- tzp = tz->tzp;
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+ int percentage;
+ struct thermal_cooling_device *cdev = instance->cdev;
- for (i = 0; i < tzp->num_tbps; i++) {
- if (!tzp->tbp[i].cdev)
+ if (instance->trip != trip)
continue;
continue;
- cdev = tzp->tbp[i].cdev;
-
instance = get_thermal_instance(tz, cdev, trip)
;
- if (!instance)
-
continue
;
+ if (!total_weight)
+
percentage = 100 / total_instance
;
+ else
+
percentage = (instance->weight * 100) / total_weight
;
- instance->target = get_target_state(tz, cdev,
-
tzp->tbp[i].weight,
cur_trip_level);
+ instance->target = get_target_state(tz, cdev,
percentage,
+
cur_trip_level);
instance->cdev->updated = false;
thermal_cdev_update(cdev);
instance->cdev->updated = false;
thermal_cdev_update(cdev);