Skip to content

Commit cca52f6

Browse files
committed
thermal: intel: Set THERMAL_TRIP_FLAG_RW_TEMP directly
Some Intel thermal drivers need/want the temperature of their trip points to be set by user space via sysfs and so they pass nonzero writable trip masks during thermal zone registration for this purpose. It is now possible to achieve the same result by setting the THERMAL_TRIP_FLAG_RW_TEMP trip flag directly, so modify the drivers in question to do that instead of using a nonzero writable trips mask. No intentional functional impact. Note that this change is requisite for dropping the mask argument from thermal_zone_device_register_with_trips() going forward. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 46f5bef commit cca52f6

File tree

6 files changed

+38
-55
lines changed

6 files changed

+38
-55
lines changed

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
129129
struct thermal_trip *zone_trips;
130130
unsigned long long trip_cnt = 0;
131131
unsigned long long hyst;
132-
int trip_mask = 0;
133132
acpi_status status;
134133
int i, ret;
135134

@@ -140,10 +139,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
140139
int34x_zone->adev = adev;
141140

142141
status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt);
143-
if (ACPI_SUCCESS(status)) {
142+
if (ACPI_SUCCESS(status))
144143
int34x_zone->aux_trip_nr = trip_cnt;
145-
trip_mask = BIT(trip_cnt) - 1;
146-
}
147144

148145
zone_trips = kzalloc(sizeof(*zone_trips) * (trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT),
149146
GFP_KERNEL);
@@ -155,6 +152,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
155152
for (i = 0; i < trip_cnt; i++) {
156153
zone_trips[i].type = THERMAL_TRIP_PASSIVE;
157154
zone_trips[i].temperature = THERMAL_TEMP_INVALID;
155+
zone_trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
158156
}
159157

160158
trip_cnt = int340x_thermal_read_trips(adev, zone_trips, trip_cnt);
@@ -173,7 +171,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
173171
int34x_zone->zone = thermal_zone_device_register_with_trips(
174172
acpi_device_bid(adev),
175173
zone_trips, trip_cnt,
176-
trip_mask, int34x_zone,
174+
0, int34x_zone,
177175
&zone_ops,
178176
&int340x_thermal_params,
179177
0, 0);

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
249249
struct proc_thermal_pci *pci_info;
250250
struct thermal_trip psv_trip = {
251251
.type = THERMAL_TRIP_PASSIVE,
252+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
252253
};
253254
int irq_flag = 0, irq, ret;
254255
bool msi_irq = false;
@@ -289,7 +290,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
289290
psv_trip.temperature = get_trip_temp(pci_info);
290291

291292
pci_info->tzone = thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip,
292-
1, 1, pci_info,
293+
1, 0, pci_info,
293294
&tzone_ops,
294295
&tzone_params, 0, 0);
295296
if (IS_ERR(pci_info->tzone)) {

drivers/thermal/intel/intel_quark_dts_thermal.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@
9393

9494
/* Quark DTS has 2 trip points: hot & catastrophic */
9595
#define QRK_MAX_DTS_TRIPS 2
96-
/* If DTS not locked, all trip points are configurable */
97-
#define QRK_DTS_WR_MASK_SET 0x3
98-
/* If DTS locked, all trip points are not configurable */
99-
#define QRK_DTS_WR_MASK_CLR 0
10096

10197
#define DEFAULT_POLL_DELAY 2000
10298

@@ -323,7 +319,6 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
323319
struct soc_sensor_entry *aux_entry;
324320
int err;
325321
u32 out;
326-
int wr_mask;
327322

328323
aux_entry = kzalloc(sizeof(*aux_entry), GFP_KERNEL);
329324
if (!aux_entry) {
@@ -337,13 +332,7 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
337332
if (err)
338333
goto err_ret;
339334

340-
if (out & QRK_DTS_LOCK_BIT) {
341-
aux_entry->locked = true;
342-
wr_mask = QRK_DTS_WR_MASK_CLR;
343-
} else {
344-
aux_entry->locked = false;
345-
wr_mask = QRK_DTS_WR_MASK_SET;
346-
}
335+
aux_entry->locked = !!(out & QRK_DTS_LOCK_BIT);
347336

348337
/* Store DTS default state if DTS registers are not locked */
349338
if (!aux_entry->locked) {
@@ -360,6 +349,9 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
360349
&aux_entry->store_ptps);
361350
if (err)
362351
goto err_ret;
352+
353+
trips[QRK_DTS_ID_TP_CRITICAL].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
354+
trips[QRK_DTS_ID_TP_HOT].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
363355
}
364356

365357
trips[QRK_DTS_ID_TP_CRITICAL].temperature = get_trip_temp(QRK_DTS_ID_TP_CRITICAL);
@@ -371,8 +363,8 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
371363
aux_entry->tzone = thermal_zone_device_register_with_trips("quark_dts",
372364
trips,
373365
QRK_MAX_DTS_TRIPS,
374-
wr_mask,
375-
aux_entry, &tzone_ops,
366+
0, aux_entry,
367+
&tzone_ops,
376368
NULL, 0, polling_delay);
377369
if (IS_ERR(aux_entry->tzone)) {
378370
err = PTR_ERR(aux_entry->tzone);

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,10 @@ static void remove_dts_thermal_zone(struct intel_soc_dts_sensor_entry *dts)
202202
}
203203

204204
static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
205-
struct thermal_trip *trips,
206-
bool critical_trip)
205+
struct thermal_trip *trips)
207206
{
208-
int writable_trip_cnt = SOC_MAX_DTS_TRIPS;
209207
char name[10];
210-
unsigned long trip;
211-
int trip_mask;
212-
unsigned long ptps;
213208
u32 store_ptps;
214-
unsigned long i;
215209
int ret;
216210

217211
/* Store status to restor on exit */
@@ -222,27 +216,21 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
222216

223217
dts->id = id;
224218

225-
if (critical_trip)
226-
writable_trip_cnt--;
227-
228-
trip_mask = GENMASK(writable_trip_cnt - 1, 0);
229-
230219
/* Check if the writable trip we provide is not used by BIOS */
231220
ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
232221
SOC_DTS_OFFSET_PTPS, &store_ptps);
233-
if (ret)
234-
trip_mask = 0;
235-
else {
236-
ptps = store_ptps;
237-
for_each_set_clump8(i, trip, &ptps, writable_trip_cnt * 8)
238-
trip_mask &= ~BIT(i / 8);
222+
if (!ret) {
223+
int i;
224+
225+
for (i = 0; i <= 1; i++) {
226+
if (store_ptps & (0xFFU << i * 8))
227+
trips[i].flags &= ~THERMAL_TRIP_FLAG_RW_TEMP;
228+
}
239229
}
240-
dts->trip_mask = trip_mask;
241230
snprintf(name, sizeof(name), "soc_dts%d", id);
242231
dts->tzone = thermal_zone_device_register_with_trips(name, trips,
243232
SOC_MAX_DTS_TRIPS,
244-
trip_mask,
245-
dts, &tzone_ops,
233+
0, dts, &tzone_ops,
246234
NULL, 0, 0);
247235
if (IS_ERR(dts->tzone)) {
248236
ret = PTR_ERR(dts->tzone);
@@ -304,6 +292,14 @@ static void dts_trips_reset(struct intel_soc_dts_sensors *sensors, int dts_index
304292
update_trip_temp(sensors, 1, 0);
305293
}
306294

295+
static void set_trip(struct thermal_trip *trip, enum thermal_trip_type type,
296+
u8 flags, int temp)
297+
{
298+
trip->type = type;
299+
trip->flags = flags;
300+
trip->temperature = temp;
301+
}
302+
307303
struct intel_soc_dts_sensors *
308304
intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type,
309305
bool critical_trip, int crit_offset)
@@ -331,36 +327,33 @@ intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type,
331327
sensors->tj_max = tj_max * 1000;
332328

333329
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
334-
enum thermal_trip_type trip_type;
335330
int temp;
336331

337332
sensors->soc_dts[i].sensors = sensors;
338333

334+
set_trip(&trips[i][0], THERMAL_TRIP_PASSIVE,
335+
THERMAL_TRIP_FLAG_RW_TEMP, 0);
336+
339337
ret = update_trip_temp(sensors, 0, 0);
340338
if (ret)
341339
goto err_reset_trips;
342340

343-
trips[i][0].type = THERMAL_TRIP_PASSIVE;
344-
trips[i][0].temperature = 0;
345-
346341
if (critical_trip) {
347-
trip_type = THERMAL_TRIP_CRITICAL;
348342
temp = sensors->tj_max - crit_offset;
343+
set_trip(&trips[i][1], THERMAL_TRIP_CRITICAL, 0, temp);
349344
} else {
350-
trip_type = THERMAL_TRIP_PASSIVE;
345+
set_trip(&trips[i][1], THERMAL_TRIP_PASSIVE,
346+
THERMAL_TRIP_FLAG_RW_TEMP, 0);
351347
temp = 0;
352348
}
349+
353350
ret = update_trip_temp(sensors, 1, temp);
354351
if (ret)
355352
goto err_reset_trips;
356-
357-
trips[i][1].type = trip_type;
358-
trips[i][1].temperature = temp;
359353
}
360354

361355
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
362-
ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], trips[i],
363-
critical_trip);
356+
ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], trips[i]);
364357
if (ret)
365358
goto err_remove_zone;
366359
}

drivers/thermal/intel/intel_soc_dts_iosf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct intel_soc_dts_sensors;
2828
struct intel_soc_dts_sensor_entry {
2929
int id;
3030
u32 store_status;
31-
u32 trip_mask;
3231
struct thermal_zone_device *tzone;
3332
struct intel_soc_dts_sensors *sensors;
3433
};

drivers/thermal/intel/x86_pkg_temp_thermal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static int pkg_temp_thermal_trips_init(int cpu, int tj_max,
295295
tj_max - thres_reg_value * 1000 : THERMAL_TEMP_INVALID;
296296

297297
trips[i].type = THERMAL_TRIP_PASSIVE;
298+
trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
298299

299300
pr_debug("%s: cpu=%d, trip=%d, temp=%d\n",
300301
__func__, cpu, i, trips[i].temperature);
@@ -337,8 +338,7 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
337338
INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn);
338339
zonedev->cpu = cpu;
339340
zonedev->tzone = thermal_zone_device_register_with_trips("x86_pkg_temp",
340-
trips, thres_count,
341-
(thres_count == MAX_NUMBER_OF_TRIPS) ? 0x03 : 0x01,
341+
trips, thres_count, 0,
342342
zonedev, &tzone_ops, &pkg_temp_tz_params, 0, 0);
343343
if (IS_ERR(zonedev->tzone)) {
344344
err = PTR_ERR(zonedev->tzone);

0 commit comments

Comments
 (0)