Skip to content

Commit b827968

Browse files
committed
Merge: Update thermal/core to v6.12
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5356 JIRA: https://issues.redhat.com/browse/RHEL-61357 Omitted-fix: 423de5b ("thermal/of: Fix cdev lookup in thermal_of_should_bind()") - this just landed upstream and will be addressed in the future. Signed-off-by: David Arcari <[email protected]> Approved-by: Eric Chanudet <[email protected]> Approved-by: José Ignacio Tornos Martínez <[email protected]> Approved-by: Mark Langsdorf <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents 050e761 + 63cf6ca commit b827968

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1247
-1429
lines changed

Documentation/driver-api/thermal/sysfs-api.rst

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ temperature) and throttle appropriate devices.
6060
ops:
6161
thermal zone device call-backs.
6262

63-
.bind:
64-
bind the thermal zone device with a thermal cooling device.
65-
.unbind:
66-
unbind the thermal zone device with a thermal cooling device.
63+
.should_bind:
64+
check whether or not a given cooling device should be bound to
65+
a given trip point in this thermal zone.
6766
.get_temp:
6867
get the current temperature of the thermal zone.
6968
.set_trips:
@@ -251,56 +250,6 @@ temperature) and throttle appropriate devices.
251250
It deletes the corresponding entry from /sys/class/thermal folder and
252251
unbinds itself from all the thermal zone devices using it.
253252

254-
1.3 interface for binding a thermal zone device with a thermal cooling device
255-
-----------------------------------------------------------------------------
256-
257-
::
258-
259-
int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
260-
int trip, struct thermal_cooling_device *cdev,
261-
unsigned long upper, unsigned long lower, unsigned int weight);
262-
263-
This interface function binds a thermal cooling device to a particular trip
264-
point of a thermal zone device.
265-
266-
This function is usually called in the thermal zone device .bind callback.
267-
268-
tz:
269-
the thermal zone device
270-
cdev:
271-
thermal cooling device
272-
trip:
273-
indicates which trip point in this thermal zone the cooling device
274-
is associated with.
275-
upper:
276-
the Maximum cooling state for this trip point.
277-
THERMAL_NO_LIMIT means no upper limit,
278-
and the cooling device can be in max_state.
279-
lower:
280-
the Minimum cooling state can be used for this trip point.
281-
THERMAL_NO_LIMIT means no lower limit,
282-
and the cooling device can be in cooling state 0.
283-
weight:
284-
the influence of this cooling device in this thermal
285-
zone. See 1.4.1 below for more information.
286-
287-
::
288-
289-
int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
290-
int trip, struct thermal_cooling_device *cdev);
291-
292-
This interface function unbinds a thermal cooling device from a particular
293-
trip point of a thermal zone device. This function is usually called in
294-
the thermal zone device .unbind callback.
295-
296-
tz:
297-
the thermal zone device
298-
cdev:
299-
thermal cooling device
300-
trip:
301-
indicates which trip point in this thermal zone the cooling device
302-
is associated with.
303-
304253
1.4 Thermal Zone Parameters
305254
---------------------------
306255

@@ -371,8 +320,6 @@ Thermal cooling device sys I/F, created once it's registered::
371320

372321
Then next two dynamic attributes are created/removed in pairs. They represent
373322
the relationship between a thermal zone and its associated cooling device.
374-
They are created/removed for each successful execution of
375-
thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
376323

377324
::
378325

@@ -464,14 +411,7 @@ are supposed to implement the callback. If they don't, the thermal
464411
framework calculated the trend by comparing the previous and the current
465412
temperature values.
466413

467-
4.2. get_thermal_instance
468-
-------------------------
469-
470-
This function returns the thermal_instance corresponding to a given
471-
{thermal_zone, cooling_device, trip_point} combination. Returns NULL
472-
if such an instance does not exist.
473-
474-
4.3. thermal_cdev_update
414+
4.2. thermal_cdev_update
475415
------------------------
476416

477417
This function serves as an arbitrator to set the state of a cooling

drivers/acpi/thermal.c

Lines changed: 37 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
#define ACPI_THERMAL_TRIP_PASSIVE (-1)
4949

50+
#define ACPI_THERMAL_MAX_NR_TRIPS (ACPI_THERMAL_MAX_ACTIVE + 3)
51+
5052
/*
5153
* This exception is thrown out in two cases:
5254
* 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
@@ -112,7 +114,6 @@ struct acpi_thermal {
112114
unsigned long polling_frequency;
113115
volatile u8 zombie;
114116
struct acpi_thermal_trips trips;
115-
struct thermal_trip *trip_table;
116117
struct thermal_zone_device *thermal_zone;
117118
int kelvin_offset; /* in millidegrees */
118119
struct work_struct thermal_check_work;
@@ -167,11 +168,17 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
167168

168169
static int acpi_thermal_temp(struct acpi_thermal *tz, int temp_deci_k)
169170
{
171+
int temp;
172+
170173
if (temp_deci_k == THERMAL_TEMP_INVALID)
171174
return THERMAL_TEMP_INVALID;
172175

173-
return deci_kelvin_to_millicelsius_with_offset(temp_deci_k,
176+
temp = deci_kelvin_to_millicelsius_with_offset(temp_deci_k,
174177
tz->kelvin_offset);
178+
if (temp <= 0)
179+
return THERMAL_TEMP_INVALID;
180+
181+
return temp;
175182
}
176183

177184
static bool acpi_thermal_trip_valid(struct acpi_thermal_trip *acpi_trip)
@@ -451,26 +458,19 @@ static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index)
451458
return false;
452459
}
453460

454-
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
461+
static void acpi_thermal_get_trip_points(struct acpi_thermal *tz)
455462
{
456-
unsigned int count = 0;
457463
int i;
458464

459-
if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE))
460-
count++;
465+
acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE);
461466

462467
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
463-
if (acpi_thermal_init_trip(tz, i))
464-
count++;
465-
else
468+
if (!acpi_thermal_init_trip(tz, i))
466469
break;
467-
468470
}
469471

470472
while (++i < ACPI_THERMAL_MAX_ACTIVE)
471473
tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID;
472-
473-
return count;
474474
}
475475

476476
/* sys I/F for generic thermal sysfs support */
@@ -558,77 +558,31 @@ static void acpi_thermal_zone_device_critical(struct thermal_zone_device *therma
558558
thermal_zone_device_critical(thermal);
559559
}
560560

561-
struct acpi_thermal_bind_data {
562-
struct thermal_zone_device *thermal;
563-
struct thermal_cooling_device *cdev;
564-
bool bind;
565-
};
566-
567-
static int bind_unbind_cdev_cb(struct thermal_trip *trip, void *arg)
561+
static bool acpi_thermal_should_bind_cdev(struct thermal_zone_device *thermal,
562+
const struct thermal_trip *trip,
563+
struct thermal_cooling_device *cdev,
564+
struct cooling_spec *c)
568565
{
569566
struct acpi_thermal_trip *acpi_trip = trip->priv;
570-
struct acpi_thermal_bind_data *bd = arg;
571-
struct thermal_zone_device *thermal = bd->thermal;
572-
struct thermal_cooling_device *cdev = bd->cdev;
573567
struct acpi_device *cdev_adev = cdev->devdata;
574568
int i;
575569

576570
/* Skip critical and hot trips. */
577571
if (!acpi_trip)
578-
return 0;
572+
return false;
579573

580574
for (i = 0; i < acpi_trip->devices.count; i++) {
581575
acpi_handle handle = acpi_trip->devices.handles[i];
582-
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
583-
584-
if (adev != cdev_adev)
585-
continue;
586-
587-
if (bd->bind) {
588-
int ret;
589-
590-
ret = thermal_bind_cdev_to_trip(thermal, trip, cdev,
591-
THERMAL_NO_LIMIT,
592-
THERMAL_NO_LIMIT,
593-
THERMAL_WEIGHT_DEFAULT);
594-
if (ret)
595-
return ret;
596-
} else {
597-
thermal_unbind_cdev_from_trip(thermal, trip, cdev);
598-
}
599-
}
600-
601-
return 0;
602-
}
603-
604-
static int acpi_thermal_bind_unbind_cdev(struct thermal_zone_device *thermal,
605-
struct thermal_cooling_device *cdev,
606-
bool bind)
607-
{
608-
struct acpi_thermal_bind_data bd = {
609-
.thermal = thermal, .cdev = cdev, .bind = bind
610-
};
611-
612-
return for_each_thermal_trip(thermal, bind_unbind_cdev_cb, &bd);
613-
}
614576

615-
static int
616-
acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
617-
struct thermal_cooling_device *cdev)
618-
{
619-
return acpi_thermal_bind_unbind_cdev(thermal, cdev, true);
620-
}
577+
if (acpi_fetch_acpi_dev(handle) == cdev_adev)
578+
return true;
579+
}
621580

622-
static int
623-
acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
624-
struct thermal_cooling_device *cdev)
625-
{
626-
return acpi_thermal_bind_unbind_cdev(thermal, cdev, false);
581+
return false;
627582
}
628583

629-
static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
630-
.bind = acpi_thermal_bind_cooling_device,
631-
.unbind = acpi_thermal_unbind_cooling_device,
584+
static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
585+
.should_bind = acpi_thermal_should_bind_cdev,
632586
.get_temp = thermal_get_temp,
633587
.get_trend = thermal_get_trend,
634588
.hot = acpi_thermal_zone_device_hot,
@@ -662,14 +616,15 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz)
662616
}
663617

664618
static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
619+
const struct thermal_trip *trip_table,
665620
unsigned int trip_count,
666621
int passive_delay)
667622
{
668623
int result;
669624

670625
if (trip_count)
671626
tz->thermal_zone = thermal_zone_device_register_with_trips(
672-
"acpitz", tz->trip_table, trip_count, 0, tz,
627+
"acpitz", trip_table, trip_count, tz,
673628
&acpi_thermal_zone_ops, NULL, passive_delay,
674629
tz->polling_frequency * 100);
675630
else
@@ -824,10 +779,10 @@ static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz)
824779

825780
static int acpi_thermal_add(struct acpi_device *device)
826781
{
782+
struct thermal_trip trip_table[ACPI_THERMAL_MAX_NR_TRIPS] = { 0 };
827783
struct acpi_thermal_trip *acpi_trip;
828784
struct thermal_trip *trip;
829785
struct acpi_thermal *tz;
830-
unsigned int trip_count;
831786
int crit_temp, hot_temp;
832787
int passive_delay = 0;
833788
int result;
@@ -849,21 +804,10 @@ static int acpi_thermal_add(struct acpi_device *device)
849804
acpi_thermal_aml_dependency_fix(tz);
850805

851806
/* Get trip points [_CRT, _PSV, etc.] (required). */
852-
trip_count = acpi_thermal_get_trip_points(tz);
807+
acpi_thermal_get_trip_points(tz);
853808

854809
crit_temp = acpi_thermal_get_critical_trip(tz);
855-
if (crit_temp != THERMAL_TEMP_INVALID)
856-
trip_count++;
857-
858810
hot_temp = acpi_thermal_get_hot_trip(tz);
859-
if (hot_temp != THERMAL_TEMP_INVALID)
860-
trip_count++;
861-
862-
if (!trip_count) {
863-
pr_warn(FW_BUG "No valid trip points!\n");
864-
result = -ENODEV;
865-
goto free_memory;
866-
}
867811

868812
/* Get temperature [_TMP] (required). */
869813
result = acpi_thermal_get_temperature(tz);
@@ -882,13 +826,7 @@ static int acpi_thermal_add(struct acpi_device *device)
882826

883827
acpi_thermal_guess_offset(tz, crit_temp);
884828

885-
trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL);
886-
if (!trip) {
887-
result = -ENOMEM;
888-
goto free_memory;
889-
}
890-
891-
tz->trip_table = trip;
829+
trip = trip_table;
892830

893831
if (crit_temp != THERMAL_TEMP_INVALID) {
894832
trip->type = THERMAL_TRIP_CRITICAL;
@@ -924,12 +862,17 @@ static int acpi_thermal_add(struct acpi_device *device)
924862
trip++;
925863
}
926864

927-
if (trip == tz->trip_table)
865+
if (trip == trip_table) {
928866
pr_warn(FW_BUG "No valid trip points!\n");
867+
result = -ENODEV;
868+
goto free_memory;
869+
}
929870

930-
result = acpi_thermal_register_thermal_zone(tz, trip_count, passive_delay);
871+
result = acpi_thermal_register_thermal_zone(tz, trip_table,
872+
trip - trip_table,
873+
passive_delay);
931874
if (result)
932-
goto free_trips;
875+
goto free_memory;
933876

934877
refcount_set(&tz->thermal_check_count, 3);
935878
mutex_init(&tz->thermal_check_lock);
@@ -948,8 +891,6 @@ static int acpi_thermal_add(struct acpi_device *device)
948891
flush_wq:
949892
flush_workqueue(acpi_thermal_pm_queue);
950893
acpi_thermal_unregister_thermal_zone(tz);
951-
free_trips:
952-
kfree(tz->trip_table);
953894
free_memory:
954895
acpi_thermal_free_thermal_zone(tz);
955896

@@ -970,8 +911,7 @@ static void acpi_thermal_remove(struct acpi_device *device)
970911

971912
flush_workqueue(acpi_thermal_pm_queue);
972913
acpi_thermal_unregister_thermal_zone(tz);
973-
kfree(tz->trip_table);
974-
kfree(tz);
914+
acpi_thermal_free_thermal_zone(tz);
975915
}
976916

977917
#ifdef CONFIG_PM_SLEEP

drivers/hwmon/hwmon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static DEFINE_IDA(hwmon_ida);
137137
#ifdef CONFIG_THERMAL_OF
138138
static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
139139
{
140-
struct hwmon_thermal_data *tdata = tz->devdata;
140+
struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz);
141141
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
142142
int ret;
143143
long t;
@@ -154,7 +154,7 @@ static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
154154

155155
static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
156156
{
157-
struct hwmon_thermal_data *tdata = tz->devdata;
157+
struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz);
158158
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
159159
const struct hwmon_chip_info *chip = hwdev->chip;
160160
const struct hwmon_channel_info * const *info = chip->info;

drivers/hwmon/scpi-hwmon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
6464

6565
static int scpi_read_temp(struct thermal_zone_device *tz, int *temp)
6666
{
67-
struct scpi_thermal_zone *zone = tz->devdata;
67+
struct scpi_thermal_zone *zone = thermal_zone_device_priv(tz);
6868
struct scpi_sensors *scpi_sensors = zone->scpi_sensors;
6969
struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
7070
struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];

drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int cxgb4_thermal_init(struct adapter *adap)
6060

6161
snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name);
6262
ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip,
63-
0, adap,
63+
adap,
6464
&cxgb4_thermal_ops,
6565
NULL, 0, 0);
6666
if (IS_ERR(ch_thermal->tzdev)) {

0 commit comments

Comments
 (0)