Skip to content

Commit b429b6f

Browse files
committed
thermal: intel: intel_soc_dts_iosf: Always use 2 trips
Both the existing callers of intel_soc_dts_iosf_init() pass 2 as the trip count argument, so it can be replaced with SOC_MAX_DTS_TRIPS everywhere in the code and the trip_count argument of that function can be dropped. This also allows the trip_count field to be dropped from struct intel_soc_dts_sensor_entry, as it is always equal to 2, and some related code can be simplified. Make changes accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
1 parent e49c8ed commit b429b6f

4 files changed

Lines changed: 15 additions & 24 deletions

File tree

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci_legacy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
5959
* ACPI/MSR. So we don't want to fail for auxiliary DTSs.
6060
*/
6161
proc_priv->soc_dts = intel_soc_dts_iosf_init(
62-
INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0);
62+
INTEL_SOC_DTS_INTERRUPT_MSI, 0);
6363

6464
if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) {
6565
ret = pci_enable_msi(pdev);

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
/* DTS encoding for TJ MAX temperature */
3838
#define SOC_DTS_TJMAX_ENCODING 0x7F
3939

40-
/* Only 2 out of 4 is allowed for OSPM */
41-
#define SOC_MAX_DTS_TRIPS 2
42-
4340
/* Mask for two trips in status bits */
4441
#define SOC_DTS_TRIP_MASK 0x03
4542

@@ -253,12 +250,10 @@ static void remove_dts_thermal_zone(struct intel_soc_dts_sensor_entry *dts)
253250
}
254251

255252
static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
256-
bool notification_support, int trip_cnt,
257-
int read_only_trip_cnt)
253+
bool notification_support, int read_only_trip_cnt)
258254
{
259255
char name[10];
260256
unsigned long trip;
261-
int trip_count = 0;
262257
int trip_mask = 0;
263258
int writable_trip_cnt = 0;
264259
unsigned long ptps;
@@ -274,8 +269,7 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
274269

275270
dts->id = id;
276271
if (notification_support) {
277-
trip_count = min(SOC_MAX_DTS_TRIPS, trip_cnt);
278-
writable_trip_cnt = trip_count - read_only_trip_cnt;
272+
writable_trip_cnt = SOC_MAX_DTS_TRIPS - read_only_trip_cnt;
279273
trip_mask = GENMASK(writable_trip_cnt - 1, 0);
280274
}
281275

@@ -290,10 +284,9 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
290284
trip_mask &= ~BIT(i / 8);
291285
}
292286
dts->trip_mask = trip_mask;
293-
dts->trip_count = trip_count;
294287
snprintf(name, sizeof(name), "soc_dts%d", id);
295288
dts->tzone = thermal_zone_device_register(name,
296-
trip_count,
289+
SOC_MAX_DTS_TRIPS,
297290
trip_mask,
298291
dts, &tzone_ops,
299292
NULL, 0, 0);
@@ -324,11 +317,10 @@ int intel_soc_dts_iosf_add_read_only_critical_trip(
324317
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
325318
struct intel_soc_dts_sensor_entry *entry = &sensors->soc_dts[i];
326319
int temp = sensors->tj_max - critical_offset;
327-
unsigned long count = entry->trip_count;
328320
unsigned long mask = entry->trip_mask;
329321

330-
j = find_first_zero_bit(&mask, count);
331-
if (j < count)
322+
j = find_first_zero_bit(&mask, SOC_MAX_DTS_TRIPS);
323+
if (j < SOC_MAX_DTS_TRIPS)
332324
return update_trip_temp(entry, j, temp, THERMAL_TRIP_CRITICAL);
333325
}
334326

@@ -372,8 +364,7 @@ void intel_soc_dts_iosf_interrupt_handler(struct intel_soc_dts_sensors *sensors)
372364
EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_interrupt_handler);
373365

374366
struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
375-
enum intel_soc_dts_interrupt_type intr_type, int trip_count,
376-
int read_only_trip_count)
367+
enum intel_soc_dts_interrupt_type intr_type, int read_only_trip_count)
377368
{
378369
struct intel_soc_dts_sensors *sensors;
379370
bool notification;
@@ -384,7 +375,7 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
384375
if (!iosf_mbi_available())
385376
return ERR_PTR(-ENODEV);
386377

387-
if (!trip_count || read_only_trip_count > trip_count)
378+
if (read_only_trip_count > SOC_MAX_DTS_TRIPS)
388379
return ERR_PTR(-EINVAL);
389380

390381
tj_max = intel_tcc_get_tjmax(-1);
@@ -406,8 +397,7 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
406397
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
407398
sensors->soc_dts[i].sensors = sensors;
408399
ret = add_dts_thermal_zone(i, &sensors->soc_dts[i],
409-
notification, trip_count,
410-
read_only_trip_count);
400+
notification, read_only_trip_count);
411401
if (ret)
412402
goto err_free;
413403
}

drivers/thermal/intel/intel_soc_dts_iosf.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
/* DTS0 and DTS 1 */
1313
#define SOC_MAX_DTS_SENSORS 2
1414

15+
/* Only 2 out of 4 is allowed for OSPM */
16+
#define SOC_MAX_DTS_TRIPS 2
17+
1518
enum intel_soc_dts_interrupt_type {
1619
INTEL_SOC_DTS_INTERRUPT_NONE,
1720
INTEL_SOC_DTS_INTERRUPT_APIC,
@@ -26,8 +29,7 @@ struct intel_soc_dts_sensor_entry {
2629
int id;
2730
u32 store_status;
2831
u32 trip_mask;
29-
u32 trip_count;
30-
enum thermal_trip_type trip_types[2];
32+
enum thermal_trip_type trip_types[SOC_MAX_DTS_TRIPS];
3133
struct thermal_zone_device *tzone;
3234
struct intel_soc_dts_sensors *sensors;
3335
};
@@ -41,8 +43,7 @@ struct intel_soc_dts_sensors {
4143
};
4244

4345
struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
44-
enum intel_soc_dts_interrupt_type intr_type, int trip_count,
45-
int read_only_trip_count);
46+
enum intel_soc_dts_interrupt_type intr_type, int read_only_trip_count);
4647
void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors);
4748
void intel_soc_dts_iosf_interrupt_handler(
4849
struct intel_soc_dts_sensors *sensors);

drivers/thermal/intel/intel_soc_dts_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int __init intel_soc_thermal_init(void)
5151
return -ENODEV;
5252

5353
/* Create a zone with 2 trips with marked as read only */
54-
soc_dts = intel_soc_dts_iosf_init(INTEL_SOC_DTS_INTERRUPT_APIC, 2, 1);
54+
soc_dts = intel_soc_dts_iosf_init(INTEL_SOC_DTS_INTERRUPT_APIC, 1);
5555
if (IS_ERR(soc_dts)) {
5656
err = PTR_ERR(soc_dts);
5757
return err;

0 commit comments

Comments
 (0)