Skip to content

Commit

Permalink
Merge thermal core changes for 6.9 to satisfy a dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael J. Wysocki committed Mar 5, 2024
2 parents f1f0c44 + 32abd25 commit 166d017
Show file tree
Hide file tree
Showing 28 changed files with 214 additions and 330 deletions.
1 change: 0 additions & 1 deletion arch/arm/configs/imx_v6_v7_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ CONFIG_SENSORS_IIO_HWMON=y
CONFIG_SENSORS_PWM_FAN=y
CONFIG_SENSORS_SY7636A=y
CONFIG_THERMAL_STATISTICS=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
CONFIG_CPU_THERMAL=y
CONFIG_IMX_THERMAL=y
CONFIG_WATCHDOG=y
Expand Down
61 changes: 22 additions & 39 deletions drivers/acpi/thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

#define ACPI_THERMAL_TRIP_PASSIVE (-1)

#define ACPI_THERMAL_MAX_NR_TRIPS (ACPI_THERMAL_MAX_ACTIVE + 3)

/*
* This exception is thrown out in two cases:
* 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
Expand Down Expand Up @@ -112,7 +114,6 @@ struct acpi_thermal {
unsigned long polling_frequency;
volatile u8 zombie;
struct acpi_thermal_trips trips;
struct thermal_trip *trip_table;
struct thermal_zone_device *thermal_zone;
int kelvin_offset; /* in millidegrees */
struct work_struct thermal_check_work;
Expand Down Expand Up @@ -451,26 +452,19 @@ static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index)
return false;
}

static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
static void acpi_thermal_get_trip_points(struct acpi_thermal *tz)
{
unsigned int count = 0;
int i;

if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE))
count++;
acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE);

for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
if (acpi_thermal_init_trip(tz, i))
count++;
else
if (!acpi_thermal_init_trip(tz, i))
break;

}

while (++i < ACPI_THERMAL_MAX_ACTIVE)
tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID;

return count;
}

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

static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
.bind = acpi_thermal_bind_cooling_device,
.unbind = acpi_thermal_unbind_cooling_device,
.get_temp = thermal_get_temp,
Expand Down Expand Up @@ -662,15 +656,16 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz)
}

static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
const struct thermal_trip *trip_table,
unsigned int trip_count,
int passive_delay)
{
int result;

tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz",
tz->trip_table,
trip_table,
trip_count,
0, tz,
tz,
&acpi_thermal_zone_ops,
NULL,
passive_delay,
Expand Down Expand Up @@ -823,10 +818,10 @@ static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz)

static int acpi_thermal_add(struct acpi_device *device)
{
struct thermal_trip trip_table[ACPI_THERMAL_MAX_NR_TRIPS] = { 0 };
struct acpi_thermal_trip *acpi_trip;
struct thermal_trip *trip;
struct acpi_thermal *tz;
unsigned int trip_count;
int crit_temp, hot_temp;
int passive_delay = 0;
int result;
Expand All @@ -848,21 +843,10 @@ static int acpi_thermal_add(struct acpi_device *device)
acpi_thermal_aml_dependency_fix(tz);

/* Get trip points [_CRT, _PSV, etc.] (required). */
trip_count = acpi_thermal_get_trip_points(tz);
acpi_thermal_get_trip_points(tz);

crit_temp = acpi_thermal_get_critical_trip(tz);
if (crit_temp != THERMAL_TEMP_INVALID)
trip_count++;

hot_temp = acpi_thermal_get_hot_trip(tz);
if (hot_temp != THERMAL_TEMP_INVALID)
trip_count++;

if (!trip_count) {
pr_warn(FW_BUG "No valid trip points!\n");
result = -ENODEV;
goto free_memory;
}

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

acpi_thermal_guess_offset(tz, crit_temp);

trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL);
if (!trip) {
result = -ENOMEM;
goto free_memory;
}

tz->trip_table = trip;
trip = trip_table;

if (crit_temp != THERMAL_TEMP_INVALID) {
trip->type = THERMAL_TRIP_CRITICAL;
Expand Down Expand Up @@ -923,9 +901,17 @@ static int acpi_thermal_add(struct acpi_device *device)
trip++;
}

result = acpi_thermal_register_thermal_zone(tz, trip_count, passive_delay);
if (trip == trip_table) {
pr_warn(FW_BUG "No valid trip points!\n");
result = -ENODEV;
goto free_memory;
}

result = acpi_thermal_register_thermal_zone(tz, trip_table,
trip - trip_table,
passive_delay);
if (result)
goto free_trips;
goto free_memory;

refcount_set(&tz->thermal_check_count, 3);
mutex_init(&tz->thermal_check_lock);
Expand All @@ -944,8 +930,6 @@ static int acpi_thermal_add(struct acpi_device *device)
flush_wq:
flush_workqueue(acpi_thermal_pm_queue);
acpi_thermal_unregister_thermal_zone(tz);
free_trips:
kfree(tz->trip_table);
free_memory:
acpi_thermal_free_thermal_zone(tz);

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

flush_workqueue(acpi_thermal_pm_queue);
acpi_thermal_unregister_thermal_zone(tz);
kfree(tz->trip_table);
acpi_thermal_free_thermal_zone(tz);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int cxgb4_thermal_init(struct adapter *adap)

snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name);
ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip,
0, adap,
adap,
&cxgb4_thermal_ops,
NULL, 0, 0);
if (IS_ERR(ch_thermal->tzdev)) {
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ static const struct thermal_trip default_thermal_trips[] = {
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_ASIC_TEMP_NORM,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{
/* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_ASIC_TEMP_HIGH,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{ /* Warning */
.type = THERMAL_TRIP_HOT,
.temperature = MLXSW_THERMAL_ASIC_TEMP_HOT,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
};

Expand All @@ -62,16 +65,19 @@ static const struct thermal_trip default_thermal_module_trips[] = {
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_MODULE_TEMP_NORM,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{
/* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_MODULE_TEMP_HIGH,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
{ /* Warning */
.type = THERMAL_TRIP_HOT,
.temperature = MLXSW_THERMAL_MODULE_TEMP_HOT,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
},
};

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

#define MLXSW_THERMAL_NUM_TRIPS ARRAY_SIZE(default_thermal_trips)

/* Make sure all trips are writable */
#define MLXSW_THERMAL_TRIP_MASK (BIT(MLXSW_THERMAL_NUM_TRIPS) - 1)

struct mlxsw_thermal;

struct mlxsw_thermal_module {
Expand Down Expand Up @@ -420,7 +423,6 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
module_tz->tzdev = thermal_zone_device_register_with_trips(tz_name,
module_tz->trips,
MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK,
module_tz,
&mlxsw_thermal_module_ops,
&mlxsw_thermal_params,
Expand Down Expand Up @@ -548,7 +550,6 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
gearbox_tz->tzdev = thermal_zone_device_register_with_trips(tz_name,
gearbox_tz->trips,
MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK,
gearbox_tz,
&mlxsw_thermal_gearbox_ops,
&mlxsw_thermal_params, 0,
Expand Down Expand Up @@ -773,7 +774,6 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
thermal->tzdev = thermal_zone_device_register_with_trips("mlxsw",
thermal->trips,
MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK,
thermal,
&mlxsw_thermal_ops,
&mlxsw_thermal_params, 0,
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/wireless/intel/iwlwifi/mvm/tt.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,6 @@ static struct thermal_zone_device_ops tzone_ops = {
.set_trip_temp = iwl_mvm_tzone_set_trip_temp,
};

/* make all trips writable */
#define IWL_WRITABLE_TRIPS_MSK (BIT(IWL_MAX_DTS_TRIPS) - 1)

static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
{
int i, ret;
Expand All @@ -692,11 +689,11 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
mvm->tz_device.trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP;
}
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
mvm->tz_device.trips,
IWL_MAX_DTS_TRIPS,
IWL_WRITABLE_TRIPS_MSK,
mvm, &tzone_ops,
NULL, 0, 0);
if (IS_ERR(mvm->tz_device.tzone)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/acerhdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ static int __init acerhdf_register_thermal(void)
return -EINVAL;

thz_dev = thermal_zone_device_register_with_trips("acerhdf", trips, ARRAY_SIZE(trips),
0, NULL, &acerhdf_dev_ops,
NULL, &acerhdf_dev_ops,
&acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
Expand Down
11 changes: 0 additions & 11 deletions drivers/thermal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ config THERMAL_OF
Say 'Y' here if you need to build thermal infrastructure
based on device tree.

config THERMAL_WRITABLE_TRIPS
bool "Enable writable trip points"
help
This option allows the system integrator to choose whether
trip temperatures can be changed from userspace. The
writable trips need to be specified when setting up the
thermal zone but the choice here takes precedence.

Say 'Y' here if you would like to allow userspace tools to
change trip temperatures.

choice
prompt "Default Thermal governor"
default THERMAL_DEFAULT_GOV_STEP_WISE
Expand Down
2 changes: 1 addition & 1 deletion drivers/thermal/da9062-thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static int da9062_thermal_probe(struct platform_device *pdev)
mutex_init(&thermal->lock);

thermal->zone = thermal_zone_device_register_with_trips(thermal->config->name,
trips, ARRAY_SIZE(trips), 0, thermal,
trips, ARRAY_SIZE(trips), thermal,
&da9062_thermal_ops, NULL, pp_tmp,
0);
if (IS_ERR(thermal->zone)) {
Expand Down
6 changes: 4 additions & 2 deletions drivers/thermal/imx_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ struct thermal_soc_data {
};

static struct thermal_trip trips[] = {
[IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE },
[IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE,
.flags = THERMAL_TRIP_FLAG_RW_TEMP },
[IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL },
};

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

imx_set_alarm_temp(data, temp);
trips[IMX_TRIP_PASSIVE].temperature = temp;

pm_runtime_put(data->dev);

Expand Down Expand Up @@ -699,7 +701,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone",
trips,
ARRAY_SIZE(trips),
BIT(IMX_TRIP_PASSIVE), data,
data,
&imx_tz_ops, NULL,
IMX_PASSIVE_DELAY,
IMX_POLLING_DELAY);
Expand Down
2 changes: 0 additions & 2 deletions drivers/thermal/intel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ config X86_PKG_TEMP_THERMAL
tristate "X86 package temperature thermal driver"
depends on X86_THERMAL_VECTOR
select THERMAL_GOV_USER_SPACE
select THERMAL_WRITABLE_TRIPS
select INTEL_TCC
default m
help
Expand All @@ -47,7 +46,6 @@ config INTEL_SOC_DTS_THERMAL
tristate "Intel SoCs DTS thermal driver"
depends on X86 && PCI && ACPI
select INTEL_SOC_DTS_IOSF_CORE
select THERMAL_WRITABLE_TRIPS
help
Enable this to register Intel SoCs (e.g. Bay Trail) platform digital
temperature sensor (DTS). These SoCs have two additional DTSs in
Expand Down
Loading

0 comments on commit 166d017

Please sign in to comment.