diff options
| -rw-r--r-- | drivers/thermal/power_allocator.c | 26 | ||||
| -rw-r--r-- | drivers/thermal/samsung/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 5 | ||||
| -rw-r--r-- | drivers/thermal/thermal_core.c | 1 |
4 files changed, 20 insertions, 14 deletions
diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c index 4672250b329f..63a448f9d93b 100644 --- a/drivers/thermal/power_allocator.c +++ b/drivers/thermal/power_allocator.c | |||
| @@ -229,7 +229,8 @@ static int allocate_power(struct thermal_zone_device *tz, | |||
| 229 | struct thermal_instance *instance; | 229 | struct thermal_instance *instance; |
| 230 | struct power_allocator_params *params = tz->governor_data; | 230 | struct power_allocator_params *params = tz->governor_data; |
| 231 | u32 *req_power, *max_power, *granted_power, *extra_actor_power; | 231 | u32 *req_power, *max_power, *granted_power, *extra_actor_power; |
| 232 | u32 total_req_power, max_allocatable_power; | 232 | u32 *weighted_req_power; |
| 233 | u32 total_req_power, max_allocatable_power, total_weighted_req_power; | ||
| 233 | u32 total_granted_power, power_range; | 234 | u32 total_granted_power, power_range; |
| 234 | int i, num_actors, total_weight, ret = 0; | 235 | int i, num_actors, total_weight, ret = 0; |
| 235 | int trip_max_desired_temperature = params->trip_max_desired_temperature; | 236 | int trip_max_desired_temperature = params->trip_max_desired_temperature; |
| @@ -247,16 +248,17 @@ static int allocate_power(struct thermal_zone_device *tz, | |||
| 247 | } | 248 | } |
| 248 | 249 | ||
| 249 | /* | 250 | /* |
| 250 | * We need to allocate three arrays of the same size: | 251 | * We need to allocate five arrays of the same size: |
| 251 | * req_power, max_power and granted_power. They are going to | 252 | * req_power, max_power, granted_power, extra_actor_power and |
| 252 | * be needed until this function returns. Allocate them all | 253 | * weighted_req_power. They are going to be needed until this |
| 253 | * in one go to simplify the allocation and deallocation | 254 | * function returns. Allocate them all in one go to simplify |
| 254 | * logic. | 255 | * the allocation and deallocation logic. |
| 255 | */ | 256 | */ |
| 256 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*max_power)); | 257 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*max_power)); |
| 257 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*granted_power)); | 258 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*granted_power)); |
| 258 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power)); | 259 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power)); |
| 259 | req_power = devm_kcalloc(&tz->device, num_actors * 4, | 260 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*weighted_req_power)); |
| 261 | req_power = devm_kcalloc(&tz->device, num_actors * 5, | ||
| 260 | sizeof(*req_power), GFP_KERNEL); | 262 | sizeof(*req_power), GFP_KERNEL); |
| 261 | if (!req_power) { | 263 | if (!req_power) { |
| 262 | ret = -ENOMEM; | 264 | ret = -ENOMEM; |
| @@ -266,8 +268,10 @@ static int allocate_power(struct thermal_zone_device *tz, | |||
| 266 | max_power = &req_power[num_actors]; | 268 | max_power = &req_power[num_actors]; |
| 267 | granted_power = &req_power[2 * num_actors]; | 269 | granted_power = &req_power[2 * num_actors]; |
| 268 | extra_actor_power = &req_power[3 * num_actors]; | 270 | extra_actor_power = &req_power[3 * num_actors]; |
| 271 | weighted_req_power = &req_power[4 * num_actors]; | ||
| 269 | 272 | ||
| 270 | i = 0; | 273 | i = 0; |
| 274 | total_weighted_req_power = 0; | ||
| 271 | total_req_power = 0; | 275 | total_req_power = 0; |
| 272 | max_allocatable_power = 0; | 276 | max_allocatable_power = 0; |
| 273 | 277 | ||
| @@ -289,13 +293,14 @@ static int allocate_power(struct thermal_zone_device *tz, | |||
| 289 | else | 293 | else |
| 290 | weight = instance->weight; | 294 | weight = instance->weight; |
| 291 | 295 | ||
| 292 | req_power[i] = frac_to_int(weight * req_power[i]); | 296 | weighted_req_power[i] = frac_to_int(weight * req_power[i]); |
| 293 | 297 | ||
| 294 | if (power_actor_get_max_power(cdev, tz, &max_power[i])) | 298 | if (power_actor_get_max_power(cdev, tz, &max_power[i])) |
| 295 | continue; | 299 | continue; |
| 296 | 300 | ||
| 297 | total_req_power += req_power[i]; | 301 | total_req_power += req_power[i]; |
| 298 | max_allocatable_power += max_power[i]; | 302 | max_allocatable_power += max_power[i]; |
| 303 | total_weighted_req_power += weighted_req_power[i]; | ||
| 299 | 304 | ||
| 300 | i++; | 305 | i++; |
| 301 | } | 306 | } |
| @@ -303,8 +308,9 @@ static int allocate_power(struct thermal_zone_device *tz, | |||
| 303 | power_range = pid_controller(tz, current_temp, control_temp, | 308 | power_range = pid_controller(tz, current_temp, control_temp, |
| 304 | max_allocatable_power); | 309 | max_allocatable_power); |
| 305 | 310 | ||
| 306 | divvy_up_power(req_power, max_power, num_actors, total_req_power, | 311 | divvy_up_power(weighted_req_power, max_power, num_actors, |
| 307 | power_range, granted_power, extra_actor_power); | 312 | total_weighted_req_power, power_range, granted_power, |
| 313 | extra_actor_power); | ||
| 308 | 314 | ||
| 309 | total_granted_power = 0; | 315 | total_granted_power = 0; |
| 310 | i = 0; | 316 | i = 0; |
diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index c8e35c1a43dc..e0da3865e060 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | config EXYNOS_THERMAL | 1 | config EXYNOS_THERMAL |
| 2 | tristate "Exynos thermal management unit driver" | 2 | tristate "Exynos thermal management unit driver" |
| 3 | depends on OF | 3 | depends on THERMAL_OF |
| 4 | help | 4 | help |
| 5 | If you say yes here you get support for the TMU (Thermal Management | 5 | If you say yes here you get support for the TMU (Thermal Management |
| 6 | Unit) driver for SAMSUNG EXYNOS series of SoCs. This driver initialises | 6 | Unit) driver for SAMSUNG EXYNOS series of SoCs. This driver initialises |
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 531f4b179871..c96ff10b869e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
| @@ -1296,7 +1296,6 @@ static struct thermal_zone_of_device_ops exynos_sensor_ops = { | |||
| 1296 | 1296 | ||
| 1297 | static int exynos_tmu_probe(struct platform_device *pdev) | 1297 | static int exynos_tmu_probe(struct platform_device *pdev) |
| 1298 | { | 1298 | { |
| 1299 | struct exynos_tmu_platform_data *pdata; | ||
| 1300 | struct exynos_tmu_data *data; | 1299 | struct exynos_tmu_data *data; |
| 1301 | int ret; | 1300 | int ret; |
| 1302 | 1301 | ||
| @@ -1318,8 +1317,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) | |||
| 1318 | if (ret) | 1317 | if (ret) |
| 1319 | goto err_sensor; | 1318 | goto err_sensor; |
| 1320 | 1319 | ||
| 1321 | pdata = data->pdata; | ||
| 1322 | |||
| 1323 | INIT_WORK(&data->irq_work, exynos_tmu_work); | 1320 | INIT_WORK(&data->irq_work, exynos_tmu_work); |
| 1324 | 1321 | ||
| 1325 | data->clk = devm_clk_get(&pdev->dev, "tmu_apbif"); | 1322 | data->clk = devm_clk_get(&pdev->dev, "tmu_apbif"); |
| @@ -1392,6 +1389,8 @@ err_clk_sec: | |||
| 1392 | if (!IS_ERR(data->clk_sec)) | 1389 | if (!IS_ERR(data->clk_sec)) |
| 1393 | clk_unprepare(data->clk_sec); | 1390 | clk_unprepare(data->clk_sec); |
| 1394 | err_sensor: | 1391 | err_sensor: |
| 1392 | if (!IS_ERR_OR_NULL(data->regulator)) | ||
| 1393 | regulator_disable(data->regulator); | ||
| 1395 | thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); | 1394 | thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); |
| 1396 | 1395 | ||
| 1397 | return ret; | 1396 | return ret; |
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 04659bfb888b..4ca211be4c0f 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c | |||
| @@ -1333,6 +1333,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, | |||
| 1333 | return -ENODEV; | 1333 | return -ENODEV; |
| 1334 | 1334 | ||
| 1335 | unbind: | 1335 | unbind: |
| 1336 | device_remove_file(&tz->device, &pos->weight_attr); | ||
| 1336 | device_remove_file(&tz->device, &pos->attr); | 1337 | device_remove_file(&tz->device, &pos->attr); |
| 1337 | sysfs_remove_link(&tz->device.kobj, pos->name); | 1338 | sysfs_remove_link(&tz->device.kobj, pos->name); |
| 1338 | release_idr(&tz->idr, &tz->lock, pos->id); | 1339 | release_idr(&tz->idr, &tz->lock, pos->id); |
