Thermal control fixes for 6.14-rc5
- Fix parsing cooling-maps in DT for trip points with more than one cooling device (Rafael Wysocki). - Fix granted_power computation in the Power Allocator thermal governor and make it update total_weight on configuration changes after the thermal zone has been registered (Yu-Che Cheng). -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmfCI+wSHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRxiaQP/jo3HmmpvrN8ZNURzAFKa5lx8i1eNHdp npEN9FBL22IcTjoZKjoFUoniC1PBU1NRGz3v9Wz0jXLDQNiAx/apYwuUTFFafWIN hDjssxANylbuEIe4yyyiGDo+YoZ7ANUCutJJL53Y2f4BqD4x3iQbAnTY8HGdEKdB WmRMYiC/1JnBW+LaFKl0d8n7Q7Yk39FvgECiELT1HPyZmLGh3pkEVzURjEyzRsgF Sb85SWO2YOd5Vth2Ujwe2cbUkNBN+jUnLaMqY+NxQG5Ee57gKgLF9XvUaV2X1WzG ceH5gy+P7/eYHeosjacCyCtVKrgVzVz4RLhoYsvJMvWcEUYmhmaB4eqUmSEuQuCX W/WsXxvAsks+ZlzGlIASksxfvkNwegXAOOUdPuUocrc3Ft1nK4w0UOnrGHBHy/lJ BrDRvIt6a4vtQrLGugvB96rUVRrx3TqjePrU/DZ3vrpLqVyXSdADtf8eRdmV9Aow 53iQNf3Q1u4UTzomKB0ilPEo79PAfdOwZIYQ6KF+nF/wf/lgllrlaWvQhx0EG7QX Dcyg/Z0cZSOfRr/06cWd/cXJVOqL8lb+nTn8wWKE0KHOM59sBHhlN1Nk6LdSSSMq Duj7t0fDT1F9kN9UUM9CZtw+vZmL2igouAscugq81Czuai4hvXUibFygAraMJ995 tQKsbZvhlgQC =0H8e -----END PGP SIGNATURE----- Merge tag 'thermal-6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull thermal control fixes from Rafael Wysocki: "These fix the processing of DT thermal properties and the Power Allocator thermal governor: - Fix parsing cooling-maps in DT for trip points with more than one cooling device (Rafael Wysocki) - Fix granted_power computation in the Power Allocator thermal governor and make it update total_weight on configuration changes after the thermal zone has been registered (Yu-Che Cheng)" * tag 'thermal-6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal: gov_power_allocator: Update total_weight on bind and cdev updates thermal/of: Fix cdev lookup in thermal_of_should_bind() thermal: gov_power_allocator: Fix incorrect calculation in divvy_up_power()
This commit is contained in:
commit
03d38806a9
2 changed files with 52 additions and 30 deletions
|
@ -370,7 +370,7 @@ static void divvy_up_power(struct power_actor *power, int num_actors,
|
|||
|
||||
for (i = 0; i < num_actors; i++) {
|
||||
struct power_actor *pa = &power[i];
|
||||
u64 req_range = (u64)pa->req_power * power_range;
|
||||
u64 req_range = (u64)pa->weighted_req_power * power_range;
|
||||
|
||||
pa->granted_power = DIV_ROUND_CLOSEST_ULL(req_range,
|
||||
total_req_power);
|
||||
|
@ -641,6 +641,22 @@ clean_state:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void power_allocator_update_weight(struct power_allocator_params *params)
|
||||
{
|
||||
const struct thermal_trip_desc *td;
|
||||
struct thermal_instance *instance;
|
||||
|
||||
if (!params->trip_max)
|
||||
return;
|
||||
|
||||
td = trip_to_trip_desc(params->trip_max);
|
||||
|
||||
params->total_weight = 0;
|
||||
list_for_each_entry(instance, &td->thermal_instances, trip_node)
|
||||
if (power_actor_is_valid(instance))
|
||||
params->total_weight += instance->weight;
|
||||
}
|
||||
|
||||
static void power_allocator_update_tz(struct thermal_zone_device *tz,
|
||||
enum thermal_notify_event reason)
|
||||
{
|
||||
|
@ -656,16 +672,12 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz,
|
|||
if (power_actor_is_valid(instance))
|
||||
num_actors++;
|
||||
|
||||
if (num_actors == params->num_actors)
|
||||
return;
|
||||
if (num_actors != params->num_actors)
|
||||
allocate_actors_buffer(params, num_actors);
|
||||
|
||||
allocate_actors_buffer(params, num_actors);
|
||||
break;
|
||||
fallthrough;
|
||||
case THERMAL_INSTANCE_WEIGHT_CHANGED:
|
||||
params->total_weight = 0;
|
||||
list_for_each_entry(instance, &td->thermal_instances, trip_node)
|
||||
if (power_actor_is_valid(instance))
|
||||
params->total_weight += instance->weight;
|
||||
power_allocator_update_weight(params);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -731,6 +743,8 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
|
|||
|
||||
tz->governor_data = params;
|
||||
|
||||
power_allocator_update_weight(params);
|
||||
|
||||
return 0;
|
||||
|
||||
free_params:
|
||||
|
|
|
@ -274,6 +274,34 @@ static bool thermal_of_get_cooling_spec(struct device_node *map_np, int index,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool thermal_of_cm_lookup(struct device_node *cm_np,
|
||||
const struct thermal_trip *trip,
|
||||
struct thermal_cooling_device *cdev,
|
||||
struct cooling_spec *c)
|
||||
{
|
||||
for_each_child_of_node_scoped(cm_np, child) {
|
||||
struct device_node *tr_np;
|
||||
int count, i;
|
||||
|
||||
tr_np = of_parse_phandle(child, "trip", 0);
|
||||
if (tr_np != trip->priv)
|
||||
continue;
|
||||
|
||||
/* The trip has been found, look up the cdev. */
|
||||
count = of_count_phandle_with_args(child, "cooling-device",
|
||||
"#cooling-cells");
|
||||
if (count <= 0)
|
||||
pr_err("Add a cooling_device property with at least one device\n");
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (thermal_of_get_cooling_spec(child, i, cdev, c))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool thermal_of_should_bind(struct thermal_zone_device *tz,
|
||||
const struct thermal_trip *trip,
|
||||
struct thermal_cooling_device *cdev,
|
||||
|
@ -293,27 +321,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz,
|
|||
goto out;
|
||||
|
||||
/* Look up the trip and the cdev in the cooling maps. */
|
||||
for_each_child_of_node_scoped(cm_np, child) {
|
||||
struct device_node *tr_np;
|
||||
int count, i;
|
||||
|
||||
tr_np = of_parse_phandle(child, "trip", 0);
|
||||
if (tr_np != trip->priv)
|
||||
continue;
|
||||
|
||||
/* The trip has been found, look up the cdev. */
|
||||
count = of_count_phandle_with_args(child, "cooling-device", "#cooling-cells");
|
||||
if (count <= 0)
|
||||
pr_err("Add a cooling_device property with at least one device\n");
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
result = thermal_of_get_cooling_spec(child, i, cdev, c);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
result = thermal_of_cm_lookup(cm_np, trip, cdev, c);
|
||||
|
||||
of_node_put(cm_np);
|
||||
out:
|
||||
|
|
Loading…
Add table
Reference in a new issue