The following commit has been merged in the master branch:
commit ab33da3a220809e4b18fd8782785c90d02a96795
Merge: 3fdd8ea39f0bcb6acff160a1fc6e331e7b21cbfc 3669716401921c4c545ac2998d7c67f9727ee056
Author: Rafael J. Wysocki <rafael.j.wysocki(a)intel.com>
Date: Mon Jul 15 20:43:21 2024 +0200
Merge branch 'thermal-core'
Merge updates related to the thermal core for 6.11-rc1:
- Redesign the .set_trip_temp() thermal zone callback to take a trip
pointer instead of a trip ID and update its users (Rafael Wysocki).
- Avoid using invalid combinations of polling_delay and passive_delay
thermal zone parameters (Rafael Wysocki).
- Update a cooling device registration function to take a const
argument (Krzysztof Kozlowski).
- Make the uniphier thermal driver use thermal_zone_for_each_trip() for
walking trip points (Rafael Wysocki).
* thermal-core:
thermal: core: Add sanity checks for polling_delay and passive_delay
thermal: trip: Fold __thermal_zone_get_trip() into its caller
thermal: trip: Pass trip pointer to .set_trip_temp() thermal zone callback
thermal: imx: Drop critical trip check from imx_set_trip_temp()
thermal: trip: Add conversion macros for thermal trip priv field
thermal: helpers: Introduce thermal_trip_is_bound_to_cdev()
thermal: core: Change passive_delay and polling_delay data type
thermal: core: constify 'type' in devm_thermal_of_cooling_device_register()
thermal: uniphier: Use thermal_zone_for_each_trip() for walking trip points
diff --combined drivers/thermal/imx_thermal.c
index 432d21cbd2b3b,6ad97309bc0a7..091fb30dedf3b
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@@ -331,25 -331,16 +331,16 @@@ static int imx_change_mode(struct therm
return 0;
}
- static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
- int temp)
+ static int imx_set_trip_temp(struct thermal_zone_device *tz,
+ const struct thermal_trip *trip, int temp)
{
struct imx_thermal_data *data = thermal_zone_device_priv(tz);
- struct thermal_trip trip;
int ret;
ret = pm_runtime_resume_and_get(data->dev);
if (ret < 0)
return ret;
- ret = __thermal_zone_get_trip(tz, trip_id, &trip);
- if (ret)
- return ret;
-
- /* do not allow changing critical threshold */
- if (trip.type == THERMAL_TRIP_CRITICAL)
- return -EPERM;
-
/* do not allow passive to be set higher than critical */
if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
return -EINVAL;
@@@ -601,29 -592,28 +592,29 @@@ static inline void imx_thermal_unregist
static int imx_thermal_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct imx_thermal_data *data;
struct regmap *map;
int measure_freq;
int ret;
- data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- data->dev = &pdev->dev;
+ data->dev = dev;
- map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "fsl,tempmon");
+ map = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,tempmon");
if (IS_ERR(map)) {
ret = PTR_ERR(map);
- dev_err(&pdev->dev, "failed to get tempmon regmap: %d\n", ret);
+ dev_err(dev, "failed to get tempmon regmap: %d\n", ret);
return ret;
}
data->tempmon = map;
- data->socdata = of_device_get_match_data(&pdev->dev);
+ data->socdata = of_device_get_match_data(dev);
if (!data->socdata) {
- dev_err(&pdev->dev, "no device match found\n");
+ dev_err(dev, "no device match found\n");
return -ENODEV;
}
@@@ -646,15 -636,15 +637,15 @@@
platform_set_drvdata(pdev, data);
- if (of_property_present(pdev->dev.of_node, "nvmem-cells")) {
+ if (of_property_present(dev->of_node, "nvmem-cells")) {
ret = imx_init_from_nvmem_cells(pdev);
if (ret)
- return dev_err_probe(&pdev->dev, ret,
+ return dev_err_probe(dev, ret,
"failed to init from nvmem\n");
} else {
ret = imx_init_from_tempmon_data(pdev);
if (ret) {
- dev_err(&pdev->dev, "failed to init from fsl,tempmon-data\n");
+ dev_err(dev, "failed to init from fsl,tempmon-data\n");
return ret;
}
}
@@@ -674,12 -664,15 +665,12 @@@
ret = imx_thermal_register_legacy_cooling(data);
if (ret)
- return dev_err_probe(&pdev->dev, ret,
+ return dev_err_probe(dev, ret,
"failed to register cpufreq cooling device\n");
- data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
+ data->thermal_clk = devm_clk_get(dev, NULL);
if (IS_ERR(data->thermal_clk)) {
- ret = PTR_ERR(data->thermal_clk);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev,
- "failed to get thermal clk: %d\n", ret);
+ ret = dev_err_probe(dev, PTR_ERR(data->thermal_clk), "failed to get thermal clk\n");
goto legacy_cleanup;
}
@@@ -692,7 -685,7 +683,7 @@@
*/
ret = clk_prepare_enable(data->thermal_clk);
if (ret) {
- dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
+ dev_err(dev, "failed to enable thermal clk: %d\n", ret);
goto legacy_cleanup;
}
@@@ -705,12 -698,12 +696,12 @@@
IMX_POLLING_DELAY);
if (IS_ERR(data->tz)) {
ret = PTR_ERR(data->tz);
- dev_err(&pdev->dev,
- "failed to register thermal zone device %d\n", ret);
+ dev_err(dev, "failed to register thermal zone device %d\n",
+ ret);
goto clk_disable;
}
- dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
+ dev_info(dev, "%s CPU temperature grade - max:%dC"
" critical:%dC passive:%dC\n", data->temp_grade,
data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000,
trips[IMX_TRIP_PASSIVE].temperature / 1000);
@@@ -734,7 -727,7 +725,7 @@@
usleep_range(20, 50);
/* the core was configured and enabled just before */
- pm_runtime_set_active(&pdev->dev);
+ pm_runtime_set_active(dev);
pm_runtime_enable(data->dev);
ret = pm_runtime_resume_and_get(data->dev);
@@@ -746,11 -739,11 +737,11 @@@
if (ret)
goto thermal_zone_unregister;
- ret = devm_request_threaded_irq(&pdev->dev, data->irq,
+ ret = devm_request_threaded_irq(dev, data->irq,
imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,
0, "imx_thermal", data);
if (ret < 0) {
- dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret);
+ dev_err(dev, "failed to request alarm irq: %d\n", ret);
goto thermal_zone_unregister;
}
diff --combined drivers/thermal/thermal_core.c
index 3c03d657d98c5,24e0520340f67..8795187fbc526
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@@ -300,8 -300,6 +300,8 @@@ static void monitor_thermal_zone(struc
thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
else if (tz->polling_delay_jiffies)
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
+ else if (tz->temperature == THERMAL_TEMP_INVALID)
+ thermal_zone_device_set_polling(tz, msecs_to_jiffies(THERMAL_RECHECK_DELAY_MS));
}
static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz)
@@@ -487,14 -485,16 +487,14 @@@ static void thermal_trip_crossed(struc
thermal_governor_trip_crossed(governor, tz, trip, crossed_up);
}
-static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a,
+static int thermal_trip_notify_cmp(void *not_used, const struct list_head *a,
const struct list_head *b)
{
struct thermal_trip_desc *tda = container_of(a, struct thermal_trip_desc,
notify_list_node);
struct thermal_trip_desc *tdb = container_of(b, struct thermal_trip_desc,
notify_list_node);
- int ret = tdb->notify_temp - tda->notify_temp;
-
- return ascending ? ret : -ret;
+ return tda->notify_temp - tdb->notify_temp;
}
void __thermal_zone_device_update(struct thermal_zone_device *tz,
@@@ -514,7 -514,7 +514,7 @@@
update_temperature(tz);
if (tz->temperature == THERMAL_TEMP_INVALID)
- return;
+ goto monitor;
tz->notify_event = event;
@@@ -523,12 -523,12 +523,12 @@@
thermal_zone_set_trips(tz);
- list_sort(&way_up_list, &way_up_list, thermal_trip_notify_cmp);
+ list_sort(NULL, &way_up_list, thermal_trip_notify_cmp);
list_for_each_entry(td, &way_up_list, notify_list_node)
thermal_trip_crossed(tz, &td->trip, governor, true);
list_sort(NULL, &way_down_list, thermal_trip_notify_cmp);
- list_for_each_entry(td, &way_down_list, notify_list_node)
+ list_for_each_entry_reverse(td, &way_down_list, notify_list_node)
thermal_trip_crossed(tz, &td->trip, governor, false);
if (governor->manage)
@@@ -536,7 -536,6 +536,7 @@@
thermal_debug_update_trip_stats(tz);
+monitor:
monitor_thermal_zone(tz);
}
@@@ -1130,7 -1129,7 +1130,7 @@@ static void thermal_cooling_device_rele
struct thermal_cooling_device *
devm_thermal_of_cooling_device_register(struct device *dev,
struct device_node *np,
- char *type, void *devdata,
+ const char *type, void *devdata,
const struct thermal_cooling_device_ops *ops)
{
struct thermal_cooling_device **ptr, *tcd;
@@@ -1357,7 -1356,8 +1357,8 @@@ thermal_zone_device_register_with_trips
int num_trips, void *devdata,
const struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp,
- int passive_delay, int polling_delay)
+ unsigned int passive_delay,
+ unsigned int polling_delay)
{
const struct thermal_trip *trip = trips;
struct thermal_zone_device *tz;
@@@ -1390,6 -1390,14 +1391,14 @@@
if (num_trips > 0 && !trips)
return ERR_PTR(-EINVAL);
+ if (polling_delay) {
+ if (passive_delay > polling_delay)
+ return ERR_PTR(-EINVAL);
+
+ if (!passive_delay)
+ passive_delay = polling_delay;
+ }
+
if (!thermal_class)
return ERR_PTR(-ENODEV);
--
LinuxNextTracking