Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit ab33da3

Browse files
committed
Merge branch 'thermal-core'
Merge updates related to the thermal core for 6.11-rc1: - Redesign the .set_trip_temp() thermal zone callback to take a trip pointer instead of a trip ID and update its users (Rafael Wysocki). - Avoid using invalid combinations of polling_delay and passive_delay thermal zone parameters (Rafael Wysocki). - Update a cooling device registration function to take a const argument (Krzysztof Kozlowski). - Make the uniphier thermal driver use thermal_zone_for_each_trip() for walking trip points (Rafael Wysocki). * thermal-core: thermal: core: Add sanity checks for polling_delay and passive_delay thermal: trip: Fold __thermal_zone_get_trip() into its caller thermal: trip: Pass trip pointer to .set_trip_temp() thermal zone callback thermal: imx: Drop critical trip check from imx_set_trip_temp() thermal: trip: Add conversion macros for thermal trip priv field thermal: helpers: Introduce thermal_trip_is_bound_to_cdev() thermal: core: Change passive_delay and polling_delay data type thermal: core: constify 'type' in devm_thermal_of_cooling_device_register() thermal: uniphier: Use thermal_zone_for_each_trip() for walking trip points
2 parents 3fdd8ea + 3669716 commit ab33da3

File tree

15 files changed

+145
-109
lines changed

15 files changed

+145
-109
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/tt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
638638
}
639639

640640
static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
641-
int trip, int temp)
641+
const struct thermal_trip *trip, int temp)
642642
{
643643
struct iwl_mvm *mvm = thermal_zone_device_priv(device);
644644
int ret;

drivers/thermal/imx_thermal.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,25 +331,16 @@ static int imx_change_mode(struct thermal_zone_device *tz,
331331
return 0;
332332
}
333333

334-
static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
335-
int temp)
334+
static int imx_set_trip_temp(struct thermal_zone_device *tz,
335+
const struct thermal_trip *trip, int temp)
336336
{
337337
struct imx_thermal_data *data = thermal_zone_device_priv(tz);
338-
struct thermal_trip trip;
339338
int ret;
340339

341340
ret = pm_runtime_resume_and_get(data->dev);
342341
if (ret < 0)
343342
return ret;
344343

345-
ret = __thermal_zone_get_trip(tz, trip_id, &trip);
346-
if (ret)
347-
return ret;
348-
349-
/* do not allow changing critical threshold */
350-
if (trip.type == THERMAL_TRIP_CRITICAL)
351-
return -EPERM;
352-
353344
/* do not allow passive to be set higher than critical */
354345
if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
355346
return -EINVAL;

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
3939
}
4040

4141
static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
42-
int trip, int temp)
42+
const struct thermal_trip *trip, int temp)
4343
{
4444
struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
45-
char name[] = {'P', 'A', 'T', '0' + trip, '\0'};
45+
unsigned int trip_index = THERMAL_TRIP_PRIV_TO_INT(trip->priv);
46+
char name[] = {'P', 'A', 'T', '0' + trip_index, '\0'};
4647
acpi_status status;
4748

48-
if (trip > 9)
49+
if (trip_index > 9)
4950
return -EINVAL;
5051

5152
status = acpi_execute_simple_method(d->adev->handle, name,
@@ -62,16 +63,6 @@ static void int340x_thermal_critical(struct thermal_zone_device *zone)
6263
thermal_zone_device_type(zone));
6364
}
6465

65-
static inline void *int_to_trip_priv(int i)
66-
{
67-
return (void *)(long)i;
68-
}
69-
70-
static inline int trip_priv_to_int(const struct thermal_trip *trip)
71-
{
72-
return (long)trip->priv;
73-
}
74-
7566
static int int340x_thermal_read_trips(struct acpi_device *zone_adev,
7667
struct thermal_trip *zone_trips,
7768
int trip_cnt)
@@ -106,7 +97,7 @@ static int int340x_thermal_read_trips(struct acpi_device *zone_adev,
10697
break;
10798

10899
zone_trips[trip_cnt].type = THERMAL_TRIP_ACTIVE;
109-
zone_trips[trip_cnt].priv = int_to_trip_priv(i);
100+
zone_trips[trip_cnt].priv = THERMAL_INT_TO_TRIP_PRIV(i);
110101
trip_cnt++;
111102
}
112103

@@ -154,6 +145,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
154145
zone_trips[i].type = THERMAL_TRIP_PASSIVE;
155146
zone_trips[i].temperature = THERMAL_TEMP_INVALID;
156147
zone_trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
148+
zone_trips[i].priv = THERMAL_INT_TO_TRIP_PRIV(i);
157149
}
158150

159151
trip_cnt = int340x_thermal_read_trips(adev, zone_trips, trip_cnt);
@@ -224,7 +216,7 @@ static int int340x_update_one_trip(struct thermal_trip *trip, void *arg)
224216
break;
225217
case THERMAL_TRIP_ACTIVE:
226218
err = thermal_acpi_active_trip_temp(zone_adev,
227-
trip_priv_to_int(trip),
219+
THERMAL_TRIP_PRIV_TO_INT(trip->priv),
228220
&temp);
229221
break;
230222
default:

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
194194
return 0;
195195
}
196196

197-
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
197+
static int sys_set_trip_temp(struct thermal_zone_device *tzd,
198+
const struct thermal_trip *trip, int temp)
198199
{
199200
struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd);
200201
int tjmax, _temp;

drivers/thermal/intel/intel_quark_dts_thermal.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static int get_trip_temp(int trip)
195195
}
196196

197197
static int update_trip_temp(struct soc_sensor_entry *aux_entry,
198-
int trip, int temp)
198+
int trip_index, int temp)
199199
{
200200
u32 out;
201201
u32 temp_out;
@@ -230,9 +230,9 @@ static int update_trip_temp(struct soc_sensor_entry *aux_entry,
230230
*/
231231
temp_out = temp + QRK_DTS_TEMP_BASE;
232232
out = (store_ptps & ~(QRK_DTS_MASK_TP_THRES <<
233-
(trip * QRK_DTS_SHIFT_TP)));
233+
(trip_index * QRK_DTS_SHIFT_TP)));
234234
out |= (temp_out & QRK_DTS_MASK_TP_THRES) <<
235-
(trip * QRK_DTS_SHIFT_TP);
235+
(trip_index * QRK_DTS_SHIFT_TP);
236236

237237
ret = iosf_mbi_write(QRK_MBI_UNIT_RMU, MBI_REG_WRITE,
238238
QRK_DTS_REG_OFFSET_PTPS, out);
@@ -242,10 +242,26 @@ static int update_trip_temp(struct soc_sensor_entry *aux_entry,
242242
return ret;
243243
}
244244

245-
static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
246-
int temp)
245+
static inline int sys_set_trip_temp(struct thermal_zone_device *tzd,
246+
const struct thermal_trip *trip,
247+
int temp)
247248
{
248-
return update_trip_temp(thermal_zone_device_priv(tzd), trip, temp);
249+
unsigned int trip_index;
250+
251+
switch (trip->type) {
252+
case THERMAL_TRIP_HOT:
253+
trip_index = QRK_DTS_ID_TP_HOT;
254+
break;
255+
256+
case THERMAL_TRIP_CRITICAL:
257+
trip_index = QRK_DTS_ID_TP_CRITICAL;
258+
break;
259+
260+
default:
261+
return -EINVAL;
262+
}
263+
264+
return update_trip_temp(thermal_zone_device_priv(tzd), trip_index, temp);
249265
}
250266

251267
static int sys_get_curr_temp(struct thermal_zone_device *tzd,

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,20 @@ static int update_trip_temp(struct intel_soc_dts_sensors *sensors,
129129
return status;
130130
}
131131

132-
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
132+
static int sys_set_trip_temp(struct thermal_zone_device *tzd,
133+
const struct thermal_trip *trip,
133134
int temp)
134135
{
135136
struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);
136137
struct intel_soc_dts_sensors *sensors = dts->sensors;
138+
unsigned int trip_index = THERMAL_TRIP_PRIV_TO_INT(trip->priv);
137139
int status;
138140

139141
if (temp > sensors->tj_max)
140142
return -EINVAL;
141143

142144
mutex_lock(&sensors->dts_update_lock);
143-
status = update_trip_temp(sensors, trip, temp);
145+
status = update_trip_temp(sensors, trip_index, temp);
144146
mutex_unlock(&sensors->dts_update_lock);
145147

146148
return status;
@@ -293,11 +295,12 @@ static void dts_trips_reset(struct intel_soc_dts_sensors *sensors, int dts_index
293295
}
294296

295297
static void set_trip(struct thermal_trip *trip, enum thermal_trip_type type,
296-
u8 flags, int temp)
298+
u8 flags, int temp, unsigned int index)
297299
{
298300
trip->type = type;
299301
trip->flags = flags;
300302
trip->temperature = temp;
303+
trip->priv = THERMAL_INT_TO_TRIP_PRIV(index);
301304
}
302305

303306
struct intel_soc_dts_sensors *
@@ -332,18 +335,18 @@ intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type,
332335
sensors->soc_dts[i].sensors = sensors;
333336

334337
set_trip(&trips[i][0], THERMAL_TRIP_PASSIVE,
335-
THERMAL_TRIP_FLAG_RW_TEMP, 0);
338+
THERMAL_TRIP_FLAG_RW_TEMP, 0, 0);
336339

337340
ret = update_trip_temp(sensors, 0, 0);
338341
if (ret)
339342
goto err_reset_trips;
340343

341344
if (critical_trip) {
342345
temp = sensors->tj_max - crit_offset;
343-
set_trip(&trips[i][1], THERMAL_TRIP_CRITICAL, 0, temp);
346+
set_trip(&trips[i][1], THERMAL_TRIP_CRITICAL, 0, temp, 1);
344347
} else {
345348
set_trip(&trips[i][1], THERMAL_TRIP_PASSIVE,
346-
THERMAL_TRIP_FLAG_RW_TEMP, 0);
349+
THERMAL_TRIP_FLAG_RW_TEMP, 0, 1);
347350
temp = 0;
348351
}
349352

drivers/thermal/intel/x86_pkg_temp_thermal.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
119119
}
120120

121121
static int
122-
sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
122+
sys_set_trip_temp(struct thermal_zone_device *tzd,
123+
const struct thermal_trip *trip, int temp)
123124
{
124125
struct zone_device *zonedev = thermal_zone_device_priv(tzd);
126+
unsigned int trip_index = THERMAL_TRIP_PRIV_TO_INT(trip->priv);
125127
u32 l, h, mask, shift, intr;
126128
int tj_max, val, ret;
127129

@@ -132,15 +134,15 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
132134

133135
val = (tj_max - temp)/1000;
134136

135-
if (trip >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f)
137+
if (trip_index >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f)
136138
return -EINVAL;
137139

138140
ret = rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,
139141
&l, &h);
140142
if (ret < 0)
141143
return ret;
142144

143-
if (trip) {
145+
if (trip_index) {
144146
mask = THERM_MASK_THRESHOLD1;
145147
shift = THERM_SHIFT_THRESHOLD1;
146148
intr = THERM_INT_THRESHOLD1_ENABLE;
@@ -296,6 +298,7 @@ static int pkg_temp_thermal_trips_init(int cpu, int tj_max,
296298

297299
trips[i].type = THERMAL_TRIP_PASSIVE;
298300
trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
301+
trips[i].priv = THERMAL_INT_TO_TRIP_PRIV(i);
299302

300303
pr_debug("%s: cpu=%d, trip=%d, temp=%d\n",
301304
__func__, cpu, i, trips[i].temperature);

drivers/thermal/qcom/qcom-spmi-temp-alarm.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,13 @@ static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip,
261261
return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg);
262262
}
263263

264-
static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)
264+
static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz,
265+
const struct thermal_trip *trip, int temp)
265266
{
266267
struct qpnp_tm_chip *chip = thermal_zone_device_priv(tz);
267-
struct thermal_trip trip;
268268
int ret;
269269

270-
ret = __thermal_zone_get_trip(chip->tz_dev, trip_id, &trip);
271-
if (ret)
272-
return ret;
273-
274-
if (trip.type != THERMAL_TRIP_CRITICAL)
270+
if (trip->type != THERMAL_TRIP_CRITICAL)
275271
return 0;
276272

277273
mutex_lock(&chip->lock);

drivers/thermal/tegra/soctherm.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,23 +582,18 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)
582582
return temp;
583583
}
584584

585-
static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)
585+
static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz,
586+
const struct thermal_trip *trip, int temp)
586587
{
587588
struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);
588589
struct tegra_soctherm *ts = zone->ts;
589-
struct thermal_trip trip;
590590
const struct tegra_tsensor_group *sg = zone->sg;
591591
struct device *dev = zone->dev;
592-
int ret;
593592

594593
if (!tz)
595594
return -EINVAL;
596595

597-
ret = __thermal_zone_get_trip(tz, trip_id, &trip);
598-
if (ret)
599-
return ret;
600-
601-
if (trip.type == THERMAL_TRIP_CRITICAL) {
596+
if (trip->type == THERMAL_TRIP_CRITICAL) {
602597
/*
603598
* If thermtrips property is set in DT,
604599
* doesn't need to program critical type trip to HW,
@@ -609,7 +604,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip
609604
else
610605
return 0;
611606

612-
} else if (trip.type == THERMAL_TRIP_HOT) {
607+
} else if (trip->type == THERMAL_TRIP_HOT) {
613608
int i;
614609

615610
for (i = 0; i < THROTTLE_SIZE; i++) {
@@ -620,7 +615,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip
620615
continue;
621616

622617
cdev = ts->throt_cfgs[i].cdev;
623-
if (get_thermal_instance(tz, cdev, trip_id))
618+
if (thermal_trip_is_bound_to_cdev(tz, trip, cdev))
624619
stc = find_throttle_cfg_by_name(ts, cdev->type);
625620
else
626621
continue;

drivers/thermal/thermal_core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ static void thermal_cooling_device_release(struct device *dev, void *res)
11301130
struct thermal_cooling_device *
11311131
devm_thermal_of_cooling_device_register(struct device *dev,
11321132
struct device_node *np,
1133-
char *type, void *devdata,
1133+
const char *type, void *devdata,
11341134
const struct thermal_cooling_device_ops *ops)
11351135
{
11361136
struct thermal_cooling_device **ptr, *tcd;
@@ -1357,7 +1357,8 @@ thermal_zone_device_register_with_trips(const char *type,
13571357
int num_trips, void *devdata,
13581358
const struct thermal_zone_device_ops *ops,
13591359
const struct thermal_zone_params *tzp,
1360-
int passive_delay, int polling_delay)
1360+
unsigned int passive_delay,
1361+
unsigned int polling_delay)
13611362
{
13621363
const struct thermal_trip *trip = trips;
13631364
struct thermal_zone_device *tz;
@@ -1390,6 +1391,14 @@ thermal_zone_device_register_with_trips(const char *type,
13901391
if (num_trips > 0 && !trips)
13911392
return ERR_PTR(-EINVAL);
13921393

1394+
if (polling_delay) {
1395+
if (passive_delay > polling_delay)
1396+
return ERR_PTR(-EINVAL);
1397+
1398+
if (!passive_delay)
1399+
passive_delay = polling_delay;
1400+
}
1401+
13931402
if (!thermal_class)
13941403
return ERR_PTR(-ENODEV);
13951404

0 commit comments

Comments
 (0)