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.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control fixes from Rafael Wysocki:
"Add locking to the Intel int340x thermal control driver to prevent its
thermal zone callbacks from racing with firmware-induced thermal trip
point updates (Srinivas Pandruvada, Rafael Wysocki)"

* tag 'thermal-6.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type()
thermal: intel: int340x: Protect trip temperature from concurrent updates

+23 -6
+22 -6
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
··· 44 44 int trip, int *temp) 45 45 { 46 46 struct int34x_thermal_zone *d = zone->devdata; 47 - int i; 47 + int i, ret = 0; 48 48 49 49 if (d->override_ops && d->override_ops->get_trip_temp) 50 50 return d->override_ops->get_trip_temp(zone, trip, temp); 51 + 52 + mutex_lock(&d->trip_mutex); 51 53 52 54 if (trip < d->aux_trip_nr) 53 55 *temp = d->aux_trips[trip]; ··· 68 66 } 69 67 } 70 68 if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT) 71 - return -EINVAL; 69 + ret = -EINVAL; 72 70 } 73 71 74 - return 0; 72 + mutex_unlock(&d->trip_mutex); 73 + 74 + return ret; 75 75 } 76 76 77 77 static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone, ··· 81 77 enum thermal_trip_type *type) 82 78 { 83 79 struct int34x_thermal_zone *d = zone->devdata; 84 - int i; 80 + int i, ret = 0; 85 81 86 82 if (d->override_ops && d->override_ops->get_trip_type) 87 83 return d->override_ops->get_trip_type(zone, trip, type); 84 + 85 + mutex_lock(&d->trip_mutex); 88 86 89 87 if (trip < d->aux_trip_nr) 90 88 *type = THERMAL_TRIP_PASSIVE; ··· 105 99 } 106 100 } 107 101 if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT) 108 - return -EINVAL; 102 + ret = -EINVAL; 109 103 } 110 104 111 - return 0; 105 + mutex_unlock(&d->trip_mutex); 106 + 107 + return ret; 112 108 } 113 109 114 110 static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, ··· 188 180 int trip_cnt = int34x_zone->aux_trip_nr; 189 181 int i; 190 182 183 + mutex_lock(&int34x_zone->trip_mutex); 184 + 191 185 int34x_zone->crt_trip_id = -1; 192 186 if (!int340x_thermal_get_trip_config(int34x_zone->adev->handle, "_CRT", 193 187 &int34x_zone->crt_temp)) ··· 217 207 int34x_zone->act_trips[i].valid = true; 218 208 } 219 209 210 + mutex_unlock(&int34x_zone->trip_mutex); 211 + 220 212 return trip_cnt; 221 213 } 222 214 EXPORT_SYMBOL_GPL(int340x_thermal_read_trips); ··· 241 229 GFP_KERNEL); 242 230 if (!int34x_thermal_zone) 243 231 return ERR_PTR(-ENOMEM); 232 + 233 + mutex_init(&int34x_thermal_zone->trip_mutex); 244 234 245 235 int34x_thermal_zone->adev = adev; 246 236 int34x_thermal_zone->override_ops = override_ops; ··· 295 281 acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); 296 282 kfree(int34x_thermal_zone->aux_trips); 297 283 err_trip_alloc: 284 + mutex_destroy(&int34x_thermal_zone->trip_mutex); 298 285 kfree(int34x_thermal_zone); 299 286 return ERR_PTR(ret); 300 287 } ··· 307 292 thermal_zone_device_unregister(int34x_thermal_zone->zone); 308 293 acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); 309 294 kfree(int34x_thermal_zone->aux_trips); 295 + mutex_destroy(&int34x_thermal_zone->trip_mutex); 310 296 kfree(int34x_thermal_zone); 311 297 } 312 298 EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
+1
drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h
··· 32 32 struct thermal_zone_device_ops *override_ops; 33 33 void *priv_data; 34 34 struct acpi_lpat_conversion_table *lpat_table; 35 + struct mutex trip_mutex; 35 36 }; 36 37 37 38 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,