Skip to content

Commit 166d017

Browse files
committed
Merge thermal core changes for 6.9 to satisfy a dependency.
2 parents f1f0c44 + 32abd25 commit 166d017

28 files changed

+214
-330
lines changed

arch/arm/configs/imx_v6_v7_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ CONFIG_SENSORS_IIO_HWMON=y
228228
CONFIG_SENSORS_PWM_FAN=y
229229
CONFIG_SENSORS_SY7636A=y
230230
CONFIG_THERMAL_STATISTICS=y
231-
CONFIG_THERMAL_WRITABLE_TRIPS=y
232231
CONFIG_CPU_THERMAL=y
233232
CONFIG_IMX_THERMAL=y
234233
CONFIG_WATCHDOG=y

drivers/acpi/thermal.c

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
#define ACPI_THERMAL_TRIP_PASSIVE (-1)
4949

50+
#define ACPI_THERMAL_MAX_NR_TRIPS (ACPI_THERMAL_MAX_ACTIVE + 3)
51+
5052
/*
5153
* This exception is thrown out in two cases:
5254
* 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
@@ -112,7 +114,6 @@ struct acpi_thermal {
112114
unsigned long polling_frequency;
113115
volatile u8 zombie;
114116
struct acpi_thermal_trips trips;
115-
struct thermal_trip *trip_table;
116117
struct thermal_zone_device *thermal_zone;
117118
int kelvin_offset; /* in millidegrees */
118119
struct work_struct thermal_check_work;
@@ -451,26 +452,19 @@ static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index)
451452
return false;
452453
}
453454

454-
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
455+
static void acpi_thermal_get_trip_points(struct acpi_thermal *tz)
455456
{
456-
unsigned int count = 0;
457457
int i;
458458

459-
if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE))
460-
count++;
459+
acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE);
461460

462461
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
463-
if (acpi_thermal_init_trip(tz, i))
464-
count++;
465-
else
462+
if (!acpi_thermal_init_trip(tz, i))
466463
break;
467-
468464
}
469465

470466
while (++i < ACPI_THERMAL_MAX_ACTIVE)
471467
tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID;
472-
473-
return count;
474468
}
475469

476470
/* sys I/F for generic thermal sysfs support */
@@ -626,7 +620,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
626620
return acpi_thermal_bind_unbind_cdev(thermal, cdev, false);
627621
}
628622

629-
static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
623+
static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
630624
.bind = acpi_thermal_bind_cooling_device,
631625
.unbind = acpi_thermal_unbind_cooling_device,
632626
.get_temp = thermal_get_temp,
@@ -662,15 +656,16 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz)
662656
}
663657

664658
static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
659+
const struct thermal_trip *trip_table,
665660
unsigned int trip_count,
666661
int passive_delay)
667662
{
668663
int result;
669664

670665
tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz",
671-
tz->trip_table,
666+
trip_table,
672667
trip_count,
673-
0, tz,
668+
tz,
674669
&acpi_thermal_zone_ops,
675670
NULL,
676671
passive_delay,
@@ -823,10 +818,10 @@ static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz)
823818

824819
static int acpi_thermal_add(struct acpi_device *device)
825820
{
821+
struct thermal_trip trip_table[ACPI_THERMAL_MAX_NR_TRIPS] = { 0 };
826822
struct acpi_thermal_trip *acpi_trip;
827823
struct thermal_trip *trip;
828824
struct acpi_thermal *tz;
829-
unsigned int trip_count;
830825
int crit_temp, hot_temp;
831826
int passive_delay = 0;
832827
int result;
@@ -848,21 +843,10 @@ static int acpi_thermal_add(struct acpi_device *device)
848843
acpi_thermal_aml_dependency_fix(tz);
849844

850845
/* Get trip points [_CRT, _PSV, etc.] (required). */
851-
trip_count = acpi_thermal_get_trip_points(tz);
846+
acpi_thermal_get_trip_points(tz);
852847

853848
crit_temp = acpi_thermal_get_critical_trip(tz);
854-
if (crit_temp != THERMAL_TEMP_INVALID)
855-
trip_count++;
856-
857849
hot_temp = acpi_thermal_get_hot_trip(tz);
858-
if (hot_temp != THERMAL_TEMP_INVALID)
859-
trip_count++;
860-
861-
if (!trip_count) {
862-
pr_warn(FW_BUG "No valid trip points!\n");
863-
result = -ENODEV;
864-
goto free_memory;
865-
}
866850

867851
/* Get temperature [_TMP] (required). */
868852
result = acpi_thermal_get_temperature(tz);
@@ -881,13 +865,7 @@ static int acpi_thermal_add(struct acpi_device *device)
881865

882866
acpi_thermal_guess_offset(tz, crit_temp);
883867

884-
trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL);
885-
if (!trip) {
886-
result = -ENOMEM;
887-
goto free_memory;
888-
}
889-
890-
tz->trip_table = trip;
868+
trip = trip_table;
891869

892870
if (crit_temp != THERMAL_TEMP_INVALID) {
893871
trip->type = THERMAL_TRIP_CRITICAL;
@@ -923,9 +901,17 @@ static int acpi_thermal_add(struct acpi_device *device)
923901
trip++;
924902
}
925903

926-
result = acpi_thermal_register_thermal_zone(tz, trip_count, passive_delay);
904+
if (trip == trip_table) {
905+
pr_warn(FW_BUG "No valid trip points!\n");
906+
result = -ENODEV;
907+
goto free_memory;
908+
}
909+
910+
result = acpi_thermal_register_thermal_zone(tz, trip_table,
911+
trip - trip_table,
912+
passive_delay);
927913
if (result)
928-
goto free_trips;
914+
goto free_memory;
929915

930916
refcount_set(&tz->thermal_check_count, 3);
931917
mutex_init(&tz->thermal_check_lock);
@@ -944,8 +930,6 @@ static int acpi_thermal_add(struct acpi_device *device)
944930
flush_wq:
945931
flush_workqueue(acpi_thermal_pm_queue);
946932
acpi_thermal_unregister_thermal_zone(tz);
947-
free_trips:
948-
kfree(tz->trip_table);
949933
free_memory:
950934
acpi_thermal_free_thermal_zone(tz);
951935

@@ -966,7 +950,6 @@ static void acpi_thermal_remove(struct acpi_device *device)
966950

967951
flush_workqueue(acpi_thermal_pm_queue);
968952
acpi_thermal_unregister_thermal_zone(tz);
969-
kfree(tz->trip_table);
970953
acpi_thermal_free_thermal_zone(tz);
971954
}
972955

drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int cxgb4_thermal_init(struct adapter *adap)
6060

6161
snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name);
6262
ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip,
63-
0, adap,
63+
adap,
6464
&cxgb4_thermal_ops,
6565
NULL, 0, 0);
6666
if (IS_ERR(ch_thermal->tzdev)) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ static const struct thermal_trip default_thermal_trips[] = {
4444
.type = THERMAL_TRIP_ACTIVE,
4545
.temperature = MLXSW_THERMAL_ASIC_TEMP_NORM,
4646
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
47+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
4748
},
4849
{
4950
/* In range - 40-100% PWM */
5051
.type = THERMAL_TRIP_ACTIVE,
5152
.temperature = MLXSW_THERMAL_ASIC_TEMP_HIGH,
5253
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
54+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
5355
},
5456
{ /* Warning */
5557
.type = THERMAL_TRIP_HOT,
5658
.temperature = MLXSW_THERMAL_ASIC_TEMP_HOT,
59+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
5760
},
5861
};
5962

@@ -62,16 +65,19 @@ static const struct thermal_trip default_thermal_module_trips[] = {
6265
.type = THERMAL_TRIP_ACTIVE,
6366
.temperature = MLXSW_THERMAL_MODULE_TEMP_NORM,
6467
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
68+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
6569
},
6670
{
6771
/* In range - 40-100% PWM */
6872
.type = THERMAL_TRIP_ACTIVE,
6973
.temperature = MLXSW_THERMAL_MODULE_TEMP_HIGH,
7074
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
75+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
7176
},
7277
{ /* Warning */
7378
.type = THERMAL_TRIP_HOT,
7479
.temperature = MLXSW_THERMAL_MODULE_TEMP_HOT,
80+
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
7581
},
7682
};
7783

@@ -92,9 +98,6 @@ static const struct mlxsw_cooling_states default_cooling_states[] = {
9298

9399
#define MLXSW_THERMAL_NUM_TRIPS ARRAY_SIZE(default_thermal_trips)
94100

95-
/* Make sure all trips are writable */
96-
#define MLXSW_THERMAL_TRIP_MASK (BIT(MLXSW_THERMAL_NUM_TRIPS) - 1)
97-
98101
struct mlxsw_thermal;
99102

100103
struct mlxsw_thermal_module {
@@ -420,7 +423,6 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
420423
module_tz->tzdev = thermal_zone_device_register_with_trips(tz_name,
421424
module_tz->trips,
422425
MLXSW_THERMAL_NUM_TRIPS,
423-
MLXSW_THERMAL_TRIP_MASK,
424426
module_tz,
425427
&mlxsw_thermal_module_ops,
426428
&mlxsw_thermal_params,
@@ -548,7 +550,6 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
548550
gearbox_tz->tzdev = thermal_zone_device_register_with_trips(tz_name,
549551
gearbox_tz->trips,
550552
MLXSW_THERMAL_NUM_TRIPS,
551-
MLXSW_THERMAL_TRIP_MASK,
552553
gearbox_tz,
553554
&mlxsw_thermal_gearbox_ops,
554555
&mlxsw_thermal_params, 0,
@@ -773,7 +774,6 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
773774
thermal->tzdev = thermal_zone_device_register_with_trips("mlxsw",
774775
thermal->trips,
775776
MLXSW_THERMAL_NUM_TRIPS,
776-
MLXSW_THERMAL_TRIP_MASK,
777777
thermal,
778778
&mlxsw_thermal_ops,
779779
&mlxsw_thermal_params, 0,

drivers/net/wireless/intel/iwlwifi/mvm/tt.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,6 @@ static struct thermal_zone_device_ops tzone_ops = {
667667
.set_trip_temp = iwl_mvm_tzone_set_trip_temp,
668668
};
669669

670-
/* make all trips writable */
671-
#define IWL_WRITABLE_TRIPS_MSK (BIT(IWL_MAX_DTS_TRIPS) - 1)
672-
673670
static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
674671
{
675672
int i, ret;
@@ -692,11 +689,11 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
692689
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
693690
mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
694691
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
692+
mvm->tz_device.trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP;
695693
}
696694
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
697695
mvm->tz_device.trips,
698696
IWL_MAX_DTS_TRIPS,
699-
IWL_WRITABLE_TRIPS_MSK,
700697
mvm, &tzone_ops,
701698
NULL, 0, 0);
702699
if (IS_ERR(mvm->tz_device.tzone)) {

drivers/platform/x86/acerhdf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static int __init acerhdf_register_thermal(void)
678678
return -EINVAL;
679679

680680
thz_dev = thermal_zone_device_register_with_trips("acerhdf", trips, ARRAY_SIZE(trips),
681-
0, NULL, &acerhdf_dev_ops,
681+
NULL, &acerhdf_dev_ops,
682682
&acerhdf_zone_params, 0,
683683
(kernelmode) ? interval*1000 : 0);
684684
if (IS_ERR(thz_dev))

drivers/thermal/Kconfig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@ config THERMAL_OF
8383
Say 'Y' here if you need to build thermal infrastructure
8484
based on device tree.
8585

86-
config THERMAL_WRITABLE_TRIPS
87-
bool "Enable writable trip points"
88-
help
89-
This option allows the system integrator to choose whether
90-
trip temperatures can be changed from userspace. The
91-
writable trips need to be specified when setting up the
92-
thermal zone but the choice here takes precedence.
93-
94-
Say 'Y' here if you would like to allow userspace tools to
95-
change trip temperatures.
96-
9786
choice
9887
prompt "Default Thermal governor"
9988
default THERMAL_DEFAULT_GOV_STEP_WISE

drivers/thermal/da9062-thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int da9062_thermal_probe(struct platform_device *pdev)
197197
mutex_init(&thermal->lock);
198198

199199
thermal->zone = thermal_zone_device_register_with_trips(thermal->config->name,
200-
trips, ARRAY_SIZE(trips), 0, thermal,
200+
trips, ARRAY_SIZE(trips), thermal,
201201
&da9062_thermal_ops, NULL, pp_tmp,
202202
0);
203203
if (IS_ERR(thermal->zone)) {

drivers/thermal/imx_thermal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ struct thermal_soc_data {
115115
};
116116

117117
static struct thermal_trip trips[] = {
118-
[IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE },
118+
[IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE,
119+
.flags = THERMAL_TRIP_FLAG_RW_TEMP },
119120
[IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL },
120121
};
121122

@@ -354,6 +355,7 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
354355
return -EINVAL;
355356

356357
imx_set_alarm_temp(data, temp);
358+
trips[IMX_TRIP_PASSIVE].temperature = temp;
357359

358360
pm_runtime_put(data->dev);
359361

@@ -699,7 +701,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
699701
data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone",
700702
trips,
701703
ARRAY_SIZE(trips),
702-
BIT(IMX_TRIP_PASSIVE), data,
704+
data,
703705
&imx_tz_ops, NULL,
704706
IMX_PASSIVE_DELAY,
705707
IMX_POLLING_DELAY);

drivers/thermal/intel/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ config X86_PKG_TEMP_THERMAL
2323
tristate "X86 package temperature thermal driver"
2424
depends on X86_THERMAL_VECTOR
2525
select THERMAL_GOV_USER_SPACE
26-
select THERMAL_WRITABLE_TRIPS
2726
select INTEL_TCC
2827
default m
2928
help
@@ -47,7 +46,6 @@ config INTEL_SOC_DTS_THERMAL
4746
tristate "Intel SoCs DTS thermal driver"
4847
depends on X86 && PCI && ACPI
4948
select INTEL_SOC_DTS_IOSF_CORE
50-
select THERMAL_WRITABLE_TRIPS
5149
help
5250
Enable this to register Intel SoCs (e.g. Bay Trail) platform digital
5351
temperature sensor (DTS). These SoCs have two additional DTSs in

0 commit comments

Comments
 (0)