lkml.org 
[lkml]   [2023]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 5/5] thermal/core: Sort the trip points when registering a thermal zone
From

Hi Rui,

On 19/01/2023 08:22, Zhang, Rui wrote:
> On Wed, 2023-01-18 at 22:11 +0100, Daniel Lezcano wrote:

[ ... ]

>> +int thermal_trip_sort(struct thermal_trip *trips, int num_trips)
>> +{
>> + struct thermal_trip tt;
>> + int sorted = 0;
>> + int i, j;
>> +
>> + for (i = 0; i < num_trips; i++) {
>> +
>> + for (j = i + 1; j < num_trips; j++) {
>> +
>> + if (trips[i].temperature <
>> trips[j].temperature) {
>> + tt = trips[i];
>> + trips[i] = trips[j];
>> + trips[j] = tt;
>> + sorted++;
>> + }
>> + }
>> + }
>> +
>> + return sorted;
>> +}
>> +
> When this happens, the index(trip_id) of each trip is changed, but we
> pass the new trip_id to .get_trip_temp()/.set_trip_temp() callbacks.

If we pass the thermal trips to the
thermal_zone_device_register_with_trips(), .get_trip_temp,
.get_trip_hyst and .get_trip_type are not used.

.set_trip_temp is called from sysfs, where the trip_id is read from the
file name. This trip_id will be correct in this case, as the files are
created after sorting the array.

> This will confuse the drivers and update the wrong trips, right?

No, because at the moment we use the generic trip structure, it is
handled by the thermal framework.

The drivers do not have to deal with the trip id or assuming its value
given a trip point after registering the thermal zone. If it does, we
should fix the driver as the trip_id is a framework internal value.

The trip_id is just an index to be passed around, so whatever the value,
it should point to the right trip point.

For instance, the device tree describes the trip point and they could be
in any order, all the DT based drivers are agnostic of the trip_id.

If there is an update of the trip points, we read the trip points
definition again and do an update of all of them.

> IMO, we need a map between thermal core trips and unsorted driver
> trips.

That what I proposed several months ago but we concluded that would
another extra level of complexity. So we decided to replace all the
.get_trip_* by a generic trip point structure handled by the thermal
framework itself.

Hopefully, soon we will have all .get_trip* gone with a nice cleanup of
the drivers and the core framework.


--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

\
 
 \ /
  Last update: 2023-03-26 23:47    [W:0.061 / U:1.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site