Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'thermal-6.10-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control fixes from Rafael Wysocki:
"These fix the MediaTek lvts_thermal driver and the handling of trip
points that start as invalid and are adjusted later by user space via
sysfs.

Specifics:

- Fix and clean up the MediaTek lvts_thermal driver (Julien Panis)

- Prevent invalid trip point handling from triggering spurious trip
point crossing events and allow passive polling to stop when a
passive trip point involved in it becomes invalid (Rafael Wysocki)"

* tag 'thermal-6.10-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
thermal: core: Fix the handling of invalid trip points
thermal/drivers/mediatek/lvts_thermal: Fix wrong lvts_ctrl index
thermal/drivers/mediatek/lvts_thermal: Remove unused members from struct lvts_ctrl_data
thermal/drivers/mediatek/lvts_thermal: Check NULL ptr on lvts_data

+35 -7
+9 -6
drivers/thermal/mediatek/lvts_thermal.c
··· 105 105 106 106 struct lvts_ctrl_data { 107 107 struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX]; 108 - int cal_offset[LVTS_SENSOR_MAX]; 109 - int num_lvts_sensor; 110 108 u8 valid_sensor_mask; 111 109 int offset; 112 110 int mode; ··· 116 118 ((s2) ? BIT(2) : 0) | \ 117 119 ((s3) ? BIT(3) : 0)) 118 120 119 - #define lvts_for_each_valid_sensor(i, lvts_ctrl_data) \ 121 + #define lvts_for_each_valid_sensor(i, lvts_ctrl) \ 120 122 for ((i) = 0; (i) < LVTS_SENSOR_MAX; (i)++) \ 121 - if (!((lvts_ctrl_data)->valid_sensor_mask & BIT(i))) \ 123 + if (!((lvts_ctrl)->valid_sensor_mask & BIT(i))) \ 122 124 continue; \ 123 125 else 124 126 ··· 145 147 const struct lvts_data *lvts_data; 146 148 u32 calibration[LVTS_SENSOR_MAX]; 147 149 u32 hw_tshut_raw_temp; 150 + u8 valid_sensor_mask; 148 151 int mode; 149 152 void __iomem *base; 150 153 int low_thresh; ··· 357 358 if (high > lvts_ctrl->high_thresh) 358 359 return true; 359 360 360 - lvts_for_each_valid_sensor(i, lvts_ctrl->lvts_data->lvts_ctrl) 361 + lvts_for_each_valid_sensor(i, lvts_ctrl) 361 362 if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh 362 363 && lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh) 363 364 return false; ··· 617 618 lvts_sensor[i].low_thresh = INT_MIN; 618 619 lvts_sensor[i].high_thresh = INT_MIN; 619 620 }; 621 + 622 + lvts_ctrl->valid_sensor_mask = lvts_ctrl_data->valid_sensor_mask; 620 623 621 624 return 0; 622 625 } ··· 1115 1114 u32 *sensor_bitmap = lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE ? 1116 1115 sensor_imm_bitmap : sensor_filt_bitmap; 1117 1116 1118 - lvts_for_each_valid_sensor(i, lvts_ctrl->lvts_data->lvts_ctrl) { 1117 + lvts_for_each_valid_sensor(i, lvts_ctrl) { 1119 1118 1120 1119 int dt_id = lvts_sensors[i].dt_id; 1121 1120 ··· 1272 1271 return -ENOMEM; 1273 1272 1274 1273 lvts_data = of_device_get_match_data(dev); 1274 + if (!lvts_data) 1275 + return -ENODEV; 1275 1276 1276 1277 lvts_td->clk = devm_clk_get_enabled(dev, NULL); 1277 1278 if (IS_ERR(lvts_td->clk))
+8 -1
drivers/thermal/thermal_core.c
··· 1398 1398 tz->device.class = thermal_class; 1399 1399 tz->devdata = devdata; 1400 1400 tz->num_trips = num_trips; 1401 - for_each_trip_desc(tz, td) 1401 + for_each_trip_desc(tz, td) { 1402 1402 td->trip = *trip++; 1403 + /* 1404 + * Mark all thresholds as invalid to start with even though 1405 + * this only matters for the trips that start as invalid and 1406 + * become valid later. 1407 + */ 1408 + td->threshold = INT_MAX; 1409 + } 1403 1410 1404 1411 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); 1405 1412 thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay);
+18
drivers/thermal/thermal_trip.c
··· 152 152 if (trip->temperature == temp) 153 153 return; 154 154 155 + if (temp == THERMAL_TEMP_INVALID) { 156 + struct thermal_trip_desc *td = trip_to_trip_desc(trip); 157 + 158 + if (trip->type == THERMAL_TRIP_PASSIVE && 159 + tz->temperature >= td->threshold) { 160 + /* 161 + * The trip has been crossed, so the thermal zone's 162 + * passive count needs to be adjusted. 163 + */ 164 + tz->passive--; 165 + WARN_ON_ONCE(tz->passive < 0); 166 + } 167 + /* 168 + * Invalidate the threshold to avoid triggering a spurious 169 + * trip crossing notification when the trip becomes valid. 170 + */ 171 + td->threshold = INT_MAX; 172 + } 155 173 trip->temperature = temp; 156 174 thermal_notify_tz_trip_change(tz, trip); 157 175 }