Skip to content

Commit a5088ee

Browse files
committed
Merge tag 'thermal-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control updates from Rafael Wysocki: "The most significant part of this update is the thermal control DT initialization rework from Daniel Lezcano and the following conversion of drivers to use the new API introduced by it Apart from that, the maximum number of trip points in a thermal zone is increased and there are some fixes and code cleanups Specifics: - Rework the device tree initialization, convert the drivers to the new API and remove the old OF code (Daniel Lezcano) - Fix return value to -ENODEV when searching for a specific thermal zone which does not exist (Daniel Lezcano) - Fix the return value inspection in of_thermal_zone_find() (Dan Carpenter) - Fix kernel panic when KASAN is enabled as it detects use after free when unregistering a thermal zone (Daniel Lezcano) - Move the set_trip ops inside the therma sysfs code (Daniel Lezcano) - Remove unnecessary error message as it is already shown in the underlying function (Jiapeng Chong) - Rework the monitoring path and move the locks upper in the call stack to fix some potentials race windows (Daniel Lezcano) - Fix lockdep_assert() warning introduced by the lock rework (Daniel Lezcano) - Do not lock thermal zone mutex in the user space governor (Rafael Wysocki) - Revert the Mellanox 'hotter thermal zone' feature because it is already handled in the thermal framework core code (Daniel Lezcano) - Increase maximum number of trip points in the thermal core (Sumeet Pawnikar) - Replace strlcpy() with unused retval with strscpy() in the core thermal control code (Wolfram Sang) - Use module_pci_driver() macro in the int340x processor_thermal driver (Shang XiaoJing) - Use get_cpu() instead of smp_processor_id() in the intel_powerclamp thermal driver to prevent it from crashing and remove unused accounting for IRQ wakes from it (Srinivas Pandruvada) - Consolidate priv->data_vault checks in int340x_thermal (Rafael Wysocki) - Check the policy first in cpufreq_cooling_register() (Xuewen Yan) - Drop redundant error message from da9062-thermal (zhaoxiao) - Drop of_match_ptr() from thermal_mmio (Jean Delvare)" * tag 'thermal-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (55 commits) thermal: core: Increase maximum number of trip points thermal: int340x: processor_thermal: Use module_pci_driver() macro thermal: intel_powerclamp: Remove accounting for IRQ wakes thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash thermal: int340x_thermal: Consolidate priv->data_vault checks thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register() thermal: Drop duplicate words from comments thermal: move from strlcpy() with unused retval to strscpy() thermal: da9062-thermal: Drop redundant error message thermal/drivers/thermal_mmio: Drop of_match_ptr() thermal: gov_user_space: Do not lock thermal zone mutex Revert "mlxsw: core: Add the hottest thermal zone detection" thermal/core: Fix lockdep_assert() warning thermal/core: Move the mutex inside the thermal_zone_device_update() function thermal/core: Move the thermal zone lock out of the governors thermal/governors: Group the thermal zone lock inside the throttle function thermal/core: Rework the monitoring a bit thermal/core: Rearm the monitoring only one time thermal/drivers/qcom/spmi-adc-tm5: Remove unnecessary print function dev_err() thermal/of: Remove old OF code ...
2 parents c79e6fa + 2e70ea7 commit a5088ee

Some content is hidden

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

60 files changed

+835
-1388
lines changed

drivers/ata/ahci_imx.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio)
327327
}
328328

329329
/* SATA AHCI temperature monitor */
330-
static int sata_ahci_read_temperature(void *dev, int *temp)
330+
static int __sata_ahci_read_temperature(void *dev, int *temp)
331331
{
332332
u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;
333333
u32 str1, str2, str3, str4;
@@ -416,21 +416,26 @@ static int sata_ahci_read_temperature(void *dev, int *temp)
416416
return 0;
417417
}
418418

419+
static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int *temp)
420+
{
421+
return __sata_ahci_read_temperature(tz->devdata, temp);
422+
}
423+
419424
static ssize_t sata_ahci_show_temp(struct device *dev,
420425
struct device_attribute *da,
421426
char *buf)
422427
{
423428
unsigned int temp = 0;
424429
int err;
425430

426-
err = sata_ahci_read_temperature(dev, &temp);
431+
err = __sata_ahci_read_temperature(dev, &temp);
427432
if (err < 0)
428433
return err;
429434

430435
return sprintf(buf, "%u\n", temp);
431436
}
432437

433-
static const struct thermal_zone_of_device_ops fsl_sata_ahci_of_thermal_ops = {
438+
static const struct thermal_zone_device_ops fsl_sata_ahci_of_thermal_ops = {
434439
.get_temp = sata_ahci_read_temperature,
435440
};
436441

@@ -1131,8 +1136,8 @@ static int imx_ahci_probe(struct platform_device *pdev)
11311136
ret = PTR_ERR(hwmon_dev);
11321137
goto disable_clk;
11331138
}
1134-
devm_thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev,
1135-
&fsl_sata_ahci_of_thermal_ops);
1139+
devm_thermal_of_zone_register(hwmon_dev, 0, hwmon_dev,
1140+
&fsl_sata_ahci_of_thermal_ops);
11361141
dev_info(dev, "%s: sensor 'sata_ahci'\n", dev_name(hwmon_dev));
11371142
}
11381143

drivers/hwmon/hwmon.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ static DEFINE_IDA(hwmon_ida);
151151
* between hwmon and thermal_sys modules.
152152
*/
153153
#ifdef CONFIG_THERMAL_OF
154-
static int hwmon_thermal_get_temp(void *data, int *temp)
154+
static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
155155
{
156-
struct hwmon_thermal_data *tdata = data;
156+
struct hwmon_thermal_data *tdata = tz->devdata;
157157
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
158158
int ret;
159159
long t;
@@ -168,9 +168,9 @@ static int hwmon_thermal_get_temp(void *data, int *temp)
168168
return 0;
169169
}
170170

171-
static int hwmon_thermal_set_trips(void *data, int low, int high)
171+
static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
172172
{
173-
struct hwmon_thermal_data *tdata = data;
173+
struct hwmon_thermal_data *tdata = tz->devdata;
174174
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
175175
const struct hwmon_chip_info *chip = hwdev->chip;
176176
const struct hwmon_channel_info **info = chip->info;
@@ -203,7 +203,7 @@ static int hwmon_thermal_set_trips(void *data, int low, int high)
203203
return 0;
204204
}
205205

206-
static const struct thermal_zone_of_device_ops hwmon_thermal_ops = {
206+
static const struct thermal_zone_device_ops hwmon_thermal_ops = {
207207
.get_temp = hwmon_thermal_get_temp,
208208
.set_trips = hwmon_thermal_set_trips,
209209
};
@@ -227,8 +227,8 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index)
227227
tdata->dev = dev;
228228
tdata->index = index;
229229

230-
tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata,
231-
&hwmon_thermal_ops);
230+
tzd = devm_thermal_of_zone_register(dev, index, tdata,
231+
&hwmon_thermal_ops);
232232
if (IS_ERR(tzd)) {
233233
if (PTR_ERR(tzd) != -ENODEV)
234234
return PTR_ERR(tzd);

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,9 @@ struct pmbus_thermal_data {
12701270
struct pmbus_sensor *sensor;
12711271
};
12721272

1273-
static int pmbus_thermal_get_temp(void *data, int *temp)
1273+
static int pmbus_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
12741274
{
1275-
struct pmbus_thermal_data *tdata = data;
1275+
struct pmbus_thermal_data *tdata = tz->devdata;
12761276
struct pmbus_sensor *sensor = tdata->sensor;
12771277
struct pmbus_data *pmbus_data = tdata->pmbus_data;
12781278
struct i2c_client *client = to_i2c_client(pmbus_data->dev);
@@ -1296,7 +1296,7 @@ static int pmbus_thermal_get_temp(void *data, int *temp)
12961296
return ret;
12971297
}
12981298

1299-
static const struct thermal_zone_of_device_ops pmbus_thermal_ops = {
1299+
static const struct thermal_zone_device_ops pmbus_thermal_ops = {
13001300
.get_temp = pmbus_thermal_get_temp,
13011301
};
13021302

@@ -1314,8 +1314,8 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data,
13141314
tdata->sensor = sensor;
13151315
tdata->pmbus_data = pmbus_data;
13161316

1317-
tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata,
1318-
&pmbus_thermal_ops);
1317+
tzd = devm_thermal_of_zone_register(dev, index, tdata,
1318+
&pmbus_thermal_ops);
13191319
/*
13201320
* If CONFIG_THERMAL_OF is disabled, this returns -ENODEV,
13211321
* so ignore that error but forward any other error.

drivers/hwmon/scpi-hwmon.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
6262
}
6363
}
6464

65-
static int scpi_read_temp(void *dev, int *temp)
65+
static int scpi_read_temp(struct thermal_zone_device *tz, int *temp)
6666
{
67-
struct scpi_thermal_zone *zone = dev;
67+
struct scpi_thermal_zone *zone = tz->devdata;
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];
@@ -121,7 +121,7 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf)
121121
return sprintf(buf, "%s\n", sensor->info.name);
122122
}
123123

124-
static const struct thermal_zone_of_device_ops scpi_sensor_ops = {
124+
static const struct thermal_zone_device_ops scpi_sensor_ops = {
125125
.get_temp = scpi_read_temp,
126126
};
127127

@@ -275,10 +275,10 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
275275

276276
zone->sensor_id = i;
277277
zone->scpi_sensors = scpi_sensors;
278-
z = devm_thermal_zone_of_sensor_register(dev,
279-
sensor->info.sensor_id,
280-
zone,
281-
&scpi_sensor_ops);
278+
z = devm_thermal_of_zone_register(dev,
279+
sensor->info.sensor_id,
280+
zone,
281+
&scpi_sensor_ops);
282282
/*
283283
* The call to thermal_zone_of_sensor_register returns
284284
* an error for sensors that are not associated with

drivers/iio/adc/sun4i-gpadc-iio.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)
412412
return 0;
413413
}
414414

415-
static int sun4i_gpadc_get_temp(void *data, int *temp)
415+
static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp)
416416
{
417-
struct sun4i_gpadc_iio *info = data;
417+
struct sun4i_gpadc_iio *info = tz->devdata;
418418
int val, scale, offset;
419419

420420
if (sun4i_gpadc_temp_read(info->indio_dev, &val))
@@ -428,7 +428,7 @@ static int sun4i_gpadc_get_temp(void *data, int *temp)
428428
return 0;
429429
}
430430

431-
static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = {
431+
static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
432432
.get_temp = &sun4i_gpadc_get_temp,
433433
};
434434

@@ -637,9 +637,9 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
637637
pm_runtime_enable(&pdev->dev);
638638

639639
if (IS_ENABLED(CONFIG_THERMAL_OF)) {
640-
info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
641-
0, info,
642-
&sun4i_ts_tz_ops);
640+
info->tzd = devm_thermal_of_zone_register(info->sensor_device,
641+
0, info,
642+
&sun4i_ts_tz_ops);
643643
/*
644644
* Do not fail driver probing when failing to register in
645645
* thermal because no thermal DT node is found.
@@ -681,8 +681,6 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)
681681
if (!IS_ENABLED(CONFIG_THERMAL_OF))
682682
return 0;
683683

684-
thermal_zone_of_sensor_unregister(info->sensor_device, info->tzd);
685-
686684
if (!info->no_irq)
687685
iio_map_array_unregister(indio_dev);
688686

drivers/input/touchscreen/sun4i-ts.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)
192192
return 0;
193193
}
194194

195-
static int sun4i_get_tz_temp(void *data, int *temp)
195+
static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp)
196196
{
197-
return sun4i_get_temp(data, temp);
197+
return sun4i_get_temp(tz->devdata, temp);
198198
}
199199

200-
static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = {
200+
static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
201201
.get_temp = sun4i_get_tz_temp,
202202
};
203203

@@ -356,8 +356,8 @@ static int sun4i_ts_probe(struct platform_device *pdev)
356356
if (IS_ERR(hwmon))
357357
return PTR_ERR(hwmon);
358358

359-
thermal = devm_thermal_zone_of_sensor_register(ts->dev, 0, ts,
360-
&sun4i_ts_tz_ops);
359+
thermal = devm_thermal_of_zone_register(ts->dev, 0, ts,
360+
&sun4i_ts_tz_ops);
361361
if (IS_ERR(thermal))
362362
return PTR_ERR(thermal);
363363

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#define MLXSW_THERMAL_ASIC_TEMP_HOT 105000 /* 105C */
2222
#define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */
2323
#define MLXSW_THERMAL_MODULE_TEMP_SHIFT (MLXSW_THERMAL_HYSTERESIS_TEMP * 2)
24-
#define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0)
2524
#define MLXSW_THERMAL_MAX_STATE 10
2625
#define MLXSW_THERMAL_MIN_STATE 2
2726
#define MLXSW_THERMAL_MAX_DUTY 255
@@ -101,8 +100,6 @@ struct mlxsw_thermal {
101100
struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];
102101
u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1];
103102
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
104-
unsigned int tz_highest_score;
105-
struct thermal_zone_device *tz_highest_dev;
106103
struct mlxsw_thermal_area line_cards[];
107104
};
108105

@@ -193,34 +190,6 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
193190
return 0;
194191
}
195192

196-
static void mlxsw_thermal_tz_score_update(struct mlxsw_thermal *thermal,
197-
struct thermal_zone_device *tzdev,
198-
struct mlxsw_thermal_trip *trips,
199-
int temp)
200-
{
201-
struct mlxsw_thermal_trip *trip = trips;
202-
unsigned int score, delta, i, shift = 1;
203-
204-
/* Calculate thermal zone score, if temperature is above the hot
205-
* threshold score is set to MLXSW_THERMAL_TEMP_SCORE_MAX.
206-
*/
207-
score = MLXSW_THERMAL_TEMP_SCORE_MAX;
208-
for (i = MLXSW_THERMAL_TEMP_TRIP_NORM; i < MLXSW_THERMAL_NUM_TRIPS;
209-
i++, trip++) {
210-
if (temp < trip->temp) {
211-
delta = DIV_ROUND_CLOSEST(temp, trip->temp - temp);
212-
score = delta * shift;
213-
break;
214-
}
215-
shift *= 256;
216-
}
217-
218-
if (score > thermal->tz_highest_score) {
219-
thermal->tz_highest_score = score;
220-
thermal->tz_highest_dev = tzdev;
221-
}
222-
}
223-
224193
static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
225194
struct thermal_cooling_device *cdev)
226195
{
@@ -286,9 +255,6 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
286255
return err;
287256
}
288257
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
289-
if (temp > 0)
290-
mlxsw_thermal_tz_score_update(thermal, tzdev, thermal->trips,
291-
temp);
292258

293259
*p_temp = temp;
294260
return 0;
@@ -349,21 +315,6 @@ static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev,
349315
return 0;
350316
}
351317

352-
static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev,
353-
int trip, enum thermal_trend *trend)
354-
{
355-
struct mlxsw_thermal *thermal = tzdev->devdata;
356-
357-
if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS)
358-
return -EINVAL;
359-
360-
if (tzdev == thermal->tz_highest_dev)
361-
return 1;
362-
363-
*trend = THERMAL_TREND_STABLE;
364-
return 0;
365-
}
366-
367318
static struct thermal_zone_params mlxsw_thermal_params = {
368319
.no_hwmon = true,
369320
};
@@ -377,7 +328,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = {
377328
.set_trip_temp = mlxsw_thermal_set_trip_temp,
378329
.get_trip_hyst = mlxsw_thermal_get_trip_hyst,
379330
.set_trip_hyst = mlxsw_thermal_set_trip_hyst,
380-
.get_trend = mlxsw_thermal_trend_get,
381331
};
382332

383333
static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
@@ -463,7 +413,6 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
463413
int temp, crit_temp, emerg_temp;
464414
struct device *dev;
465415
u16 sensor_index;
466-
int err;
467416

468417
dev = thermal->bus_info->dev;
469418
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + tz->module;
@@ -479,10 +428,8 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
479428
return 0;
480429

481430
/* Update trip points. */
482-
err = mlxsw_thermal_module_trips_update(dev, thermal->core, tz,
483-
crit_temp, emerg_temp);
484-
if (!err && temp > 0)
485-
mlxsw_thermal_tz_score_update(thermal, tzdev, tz->trips, temp);
431+
mlxsw_thermal_module_trips_update(dev, thermal->core, tz,
432+
crit_temp, emerg_temp);
486433

487434
return 0;
488435
}
@@ -546,22 +493,6 @@ mlxsw_thermal_module_trip_hyst_set(struct thermal_zone_device *tzdev, int trip,
546493
return 0;
547494
}
548495

549-
static int mlxsw_thermal_module_trend_get(struct thermal_zone_device *tzdev,
550-
int trip, enum thermal_trend *trend)
551-
{
552-
struct mlxsw_thermal_module *tz = tzdev->devdata;
553-
struct mlxsw_thermal *thermal = tz->parent;
554-
555-
if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS)
556-
return -EINVAL;
557-
558-
if (tzdev == thermal->tz_highest_dev)
559-
return 1;
560-
561-
*trend = THERMAL_TREND_STABLE;
562-
return 0;
563-
}
564-
565496
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
566497
.bind = mlxsw_thermal_module_bind,
567498
.unbind = mlxsw_thermal_module_unbind,
@@ -571,7 +502,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
571502
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
572503
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
573504
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
574-
.get_trend = mlxsw_thermal_module_trend_get,
575505
};
576506

577507
static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
@@ -592,8 +522,6 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
592522
return err;
593523

594524
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
595-
if (temp > 0)
596-
mlxsw_thermal_tz_score_update(thermal, tzdev, tz->trips, temp);
597525

598526
*p_temp = temp;
599527
return 0;
@@ -608,7 +536,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
608536
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
609537
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
610538
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
611-
.get_trend = mlxsw_thermal_module_trend_get,
612539
};
613540

614541
static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,

0 commit comments

Comments
 (0)