Skip to content

Commit f952b6c

Browse files
committed
Merge tag 'thermal-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control updates from Rafael Wysocki: "The most significant part of this is a rework of thermal governors, including a redesign of the thermal governor interface and changes to make some of them take trip point hysteresis into account properly, as well as some related cleanups of the thermal governors and thermal core. The above is based on preliminary changes refactoring thermal data structures and moving the definitions of some of them into the thermal core which also ensure that trip point crossing notifications will be sent to user space via netlink and recorded in the debug statistics in temperature order. In addition, netlink bind/unbind notifications are added to the thermal core and the Intel HFI driver is modified to use them to avoid sending netlink messages until there are subscribers. Apart from that, multiple thermal drivers are updated which includes new hardware support (MediaTek MT8188 and MT8186, Amlogic A1 thermal sensor, Loongson-2K2000, Lmh QCM2290), fixes, cleanups and documentation updates, and the recently added thermal debug code is fixed and cleaned up. Specifics: - Redesign the thermal governor interface to allow the governors to work in a more straightforward way (Rafael Wysocki) - Make thermal governors take the current trip point thresholds into account in their computations which allows trip hysteresis to be observed more accurately (Rafael Wysocki) - Make the thermal core manage passive polling for thermal zones and remove passive polling management from thermal governors (Rafael Wysocki) - Refactor trip point representation and move the definition of thermal governor and thermal zone device structures to the thermal core (Rafael Wysocki) - Sort trip point crossing notifications and debug recording of trip point crossing events by temperature (Rafael Wysocki) - Improve the handling of cooling device states and thermal mitigation episodes in progress in the thermal debug code (Rafael Wysocki) - Avoid excessive updates of trip point statistics and clean up the printing of thermal mitigation episode information (Rafael Wysocki) - Clean up thermal governors and thermal core (Rafael Wysocki) - Allow thermal drivers to register notifiers that will be invoked on netlink events like BIND and UNBIND, so that they can adjust their activity depending on whether or not there are any subscribers of netlink messages coming from them, and make the Intel HFI driver use this mechanism (Stanislaw Gruszka) - Adjust the update delay and capabilities-per-event values in the Intel HFI thermal driver to prevent it from missing events and allow it to process more data in one go (Ricardo Neri) - Add missing MODULE_DESCRIPTION() to multiple files in the int340x_thermal and intel_soc_dts_iosf drivers (Srinivas Pandruvada) - Replace deprecated strncpy() with strscpy() in the int340x_thermal driver (Justin Stitt) - Add QCM2290 compatible DT bindings for Lmh and fix a NULL pointer dereference in the lmh driver when the SCM is not present (Konrad Dybcio) - Use the strreplace() function instead of doing it manually in the Armada driver (Rasmus Villemoes) - Convert st,stih407-thermal to DT schema and fix up missing properties (Raphael Gallais-Pou) - Add suspend/resume by restoring the context of the tsens sensor (Priyansh Jain) - Support A1 SoC family Thermal Sensor controller and add the DT bindings (Dmitry Rokosov) - Improve the temperature approximation calculation and consolidate the Tj constant into a shared area of the structure instead of duplicating it on the Rcar Gen3 (Niklas Söderlund) - Fix the Mediatek LVTS sensor coefficient for the MT8192 in order to support it correctly (Hsin-Te Yuan) - Fix a NULL pointer dereference in the tsens driver when the function compute_intercept_slope() is called with a NULL parameter (Aleksandr Mishin) - Remove some unused fields in struct qpnp_tm_chip and k3_bandgap (Christophe Jaillet) - Fix up calibration efuse data decoding, consolidate the code by checking boundaries and refactor some part of the LVTS Mediatek driver. After setting the scene, add MT8186 and MT8188 along with the DT bindings (Nicolas Pitre) - Add Loongson-2K2000 support after some minor code adjustements and providing the DT bindings definition (Binbin Zhou)" * tag 'thermal-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (72 commits) thermal: intel: hfi: Increase the number of CPU capabilities per netlink event thermal: intel: hfi: Rename HFI_MAX_THERM_NOTIFY_COUNT thermal: intel: hfi: Shorten the thermal netlink event delay to 100ms thermal: intel: hfi: Rename HFI_UPDATE_INTERVAL thermal: intel: Add missing module description thermal: core: Move passive polling management to the core thermal: core: Do not call handle_thermal_trip() if zone temperature is invalid thermal: trip: Add missing empty code line thermal/debugfs: Avoid printing zero duration for mitigation events in progress thermal/debugfs: Pass cooling device state to thermal_debug_cdev_add() thermal/debugfs: Create records for cdev states as they get used thermal: core: Introduce thermal_governor_trip_crossed() thermal/debugfs: Make tze_seq_show() skip invalid trips and trips with no stats thermal/debugfs: Rename thermal_debug_update_temp() to thermal_debug_update_trip_stats() thermal/debugfs: Clean up thermal_debug_update_temp() thermal/debugfs: Avoid excessive updates of trip point statistics thermal: core: Relocate critical and hot trip handling thermal: core: Drop the .throttle() governor callback thermal: gov_user_space: Use .trip_crossed() instead of .throttle() thermal: gov_fair_share: Eliminate unnecessary integer divisions ...
2 parents 4b95dc8 + 3a47fbd commit f952b6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1354
-728
lines changed

Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ description: Binding for Amlogic Thermal
1313

1414
properties:
1515
compatible:
16-
items:
17-
- enum:
18-
- amlogic,g12a-cpu-thermal
19-
- amlogic,g12a-ddr-thermal
20-
- const: amlogic,g12a-thermal
16+
oneOf:
17+
- items:
18+
- enum:
19+
- amlogic,g12a-cpu-thermal
20+
- amlogic,g12a-ddr-thermal
21+
- const: amlogic,g12a-thermal
22+
- const: amlogic,a1-cpu-thermal
2123

2224
reg:
2325
maxItems: 1

Documentation/devicetree/bindings/thermal/loongson,ls2k-thermal.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ properties:
1818
oneOf:
1919
- enum:
2020
- loongson,ls2k1000-thermal
21+
- loongson,ls2k2000-thermal
2122
- items:
2223
- enum:
23-
- loongson,ls2k2000-thermal
24+
- loongson,ls2k0500-thermal
2425
- const: loongson,ls2k1000-thermal
2526

2627
reg:
27-
maxItems: 1
28+
minItems: 1
29+
maxItems: 2
2830

2931
interrupts:
3032
maxItems: 1
@@ -38,6 +40,24 @@ required:
3840
- interrupts
3941
- '#thermal-sensor-cells'
4042

43+
if:
44+
properties:
45+
compatible:
46+
contains:
47+
enum:
48+
- loongson,ls2k2000-thermal
49+
50+
then:
51+
properties:
52+
reg:
53+
minItems: 2
54+
maxItems: 2
55+
56+
else:
57+
properties:
58+
reg:
59+
maxItems: 1
60+
4161
unevaluatedProperties: false
4262

4363
examples:

Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ properties:
1919
compatible:
2020
enum:
2121
- mediatek,mt7988-lvts-ap
22+
- mediatek,mt8186-lvts
23+
- mediatek,mt8188-lvts-ap
24+
- mediatek,mt8188-lvts-mcu
2225
- mediatek,mt8192-lvts-ap
2326
- mediatek,mt8192-lvts-mcu
2427
- mediatek,mt8195-lvts-ap
@@ -60,6 +63,8 @@ allOf:
6063
compatible:
6164
contains:
6265
enum:
66+
- mediatek,mt8188-lvts-ap
67+
- mediatek,mt8188-lvts-mcu
6368
- mediatek,mt8192-lvts-ap
6469
- mediatek,mt8192-lvts-mcu
6570
then:
@@ -75,6 +80,7 @@ allOf:
7580
compatible:
7681
contains:
7782
enum:
83+
- mediatek,mt8186-lvts
7884
- mediatek,mt8195-lvts-ap
7985
- mediatek,mt8195-lvts-mcu
8086
then:

Documentation/devicetree/bindings/thermal/qcom-lmh.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ description:
1717

1818
properties:
1919
compatible:
20-
enum:
21-
- qcom,sc8180x-lmh
22-
- qcom,sdm845-lmh
23-
- qcom,sm8150-lmh
20+
oneOf:
21+
- enum:
22+
- qcom,sc8180x-lmh
23+
- qcom,sdm845-lmh
24+
- qcom,sm8150-lmh
25+
- items:
26+
- const: qcom,qcm2290-lmh
27+
- const: qcom,sm8150-lmh
2428

2529
reg:
2630
items:
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/thermal/st,stih407-thermal.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: STMicroelectronics STi digital thermal sensor (DTS)
8+
9+
maintainers:
10+
- Patrice Chotard <patrice.chotard@foss.st.com>
11+
- Lee Jones <lee@kernel.org>
12+
13+
allOf:
14+
- $ref: thermal-sensor.yaml
15+
16+
properties:
17+
compatible:
18+
const: st,stih407-thermal
19+
20+
reg:
21+
maxItems: 1
22+
23+
clocks:
24+
maxItems: 1
25+
26+
clock-names:
27+
items:
28+
- const: thermal
29+
30+
interrupts:
31+
description:
32+
For thermal sensors for which no interrupt has been defined, a polling
33+
delay of 1000ms will be used to read the temperature from device.
34+
maxItems: 1
35+
36+
'#thermal-sensor-cells':
37+
const: 0
38+
39+
required:
40+
- compatible
41+
- reg
42+
- clocks
43+
- clock-names
44+
45+
unevaluatedProperties: false
46+
47+
examples:
48+
- |
49+
#include <dt-bindings/interrupt-controller/arm-gic.h>
50+
temperature-sensor@91a0000 {
51+
compatible = "st,stih407-thermal";
52+
reg = <0x91a0000 0x28>;
53+
clock-names = "thermal";
54+
clocks = <&CLK_SYSIN>;
55+
interrupts = <GIC_SPI 205 IRQ_TYPE_EDGE_RISING>;
56+
#thermal-sensor-cells = <0>;
57+
};
58+
...

Documentation/devicetree/bindings/thermal/st-thermal.txt

Lines changed: 0 additions & 32 deletions
This file was deleted.

drivers/thermal/amlogic_thermal.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ static const struct amlogic_thermal_data amlogic_thermal_g12a_ddr_param = {
220220
.regmap_config = &amlogic_thermal_regmap_config_g12a,
221221
};
222222

223+
static const struct amlogic_thermal_data amlogic_thermal_a1_cpu_param = {
224+
.u_efuse_off = 0x114,
225+
.calibration_parameters = &amlogic_thermal_g12a,
226+
.regmap_config = &amlogic_thermal_regmap_config_g12a,
227+
};
228+
223229
static const struct of_device_id of_amlogic_thermal_match[] = {
224230
{
225231
.compatible = "amlogic,g12a-ddr-thermal",
@@ -229,6 +235,10 @@ static const struct of_device_id of_amlogic_thermal_match[] = {
229235
.compatible = "amlogic,g12a-cpu-thermal",
230236
.data = &amlogic_thermal_g12a_cpu_param,
231237
},
238+
{
239+
.compatible = "amlogic,a1-cpu-thermal",
240+
.data = &amlogic_thermal_a1_cpu_param,
241+
},
232242
{ /* sentinel */ }
233243
};
234244
MODULE_DEVICE_TABLE(of, of_amlogic_thermal_match);

drivers/thermal/armada_thermal.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,6 @@ static void armada_set_sane_name(struct platform_device *pdev,
763763
struct armada_thermal_priv *priv)
764764
{
765765
const char *name = dev_name(&pdev->dev);
766-
char *insane_char;
767766

768767
if (strlen(name) > THERMAL_NAME_LENGTH) {
769768
/*
@@ -781,12 +780,8 @@ static void armada_set_sane_name(struct platform_device *pdev,
781780
/* Save the name locally */
782781
strscpy(priv->zone_name, name, THERMAL_NAME_LENGTH);
783782

784-
/* Then check there are no '-' or hwmon core will complain */
785-
do {
786-
insane_char = strpbrk(priv->zone_name, "-");
787-
if (insane_char)
788-
*insane_char = '_';
789-
} while (insane_char);
783+
/* Then ensure there are no '-' or hwmon core will complain */
784+
strreplace(priv->zone_name, '-', '_');
790785
}
791786

792787
/*

drivers/thermal/gov_bang_bang.c

Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,11 @@
1313

1414
#include "thermal_core.h"
1515

16-
static int thermal_zone_trip_update(struct thermal_zone_device *tz,
17-
const struct thermal_trip *trip)
18-
{
19-
int trip_index = thermal_zone_trip_id(tz, trip);
20-
struct thermal_instance *instance;
21-
22-
if (!trip->hysteresis)
23-
dev_info_once(&tz->device,
24-
"Zero hysteresis value for thermal zone %s\n", tz->type);
25-
26-
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
27-
trip_index, trip->temperature, tz->temperature,
28-
trip->hysteresis);
29-
30-
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
31-
if (instance->trip != trip)
32-
continue;
33-
34-
/* in case fan is in initial state, switch the fan off */
35-
if (instance->target == THERMAL_NO_TARGET)
36-
instance->target = 0;
37-
38-
/* in case fan is neither on nor off set the fan to active */
39-
if (instance->target != 0 && instance->target != 1) {
40-
pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
41-
instance->name, instance->target);
42-
instance->target = 1;
43-
}
44-
45-
/*
46-
* enable fan when temperature exceeds trip_temp and disable
47-
* the fan in case it falls below trip_temp minus hysteresis
48-
*/
49-
if (instance->target == 0 && tz->temperature >= trip->temperature)
50-
instance->target = 1;
51-
else if (instance->target == 1 &&
52-
tz->temperature < trip->temperature - trip->hysteresis)
53-
instance->target = 0;
54-
55-
dev_dbg(&instance->cdev->device, "target=%d\n",
56-
(int)instance->target);
57-
58-
mutex_lock(&instance->cdev->lock);
59-
instance->cdev->updated = false; /* cdev needs update */
60-
mutex_unlock(&instance->cdev->lock);
61-
}
62-
63-
return 0;
64-
}
65-
6616
/**
6717
* bang_bang_control - controls devices associated with the given zone
6818
* @tz: thermal_zone_device
6919
* @trip: the trip point
20+
* @crossed_up: whether or not the trip has been crossed on the way up
7021
*
7122
* Regulation Logic: a two point regulation, deliver cooling state depending
7223
* on the previous state shown in this diagram:
@@ -90,26 +41,54 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz,
9041
* (trip_temp - hyst) so that the fan gets turned off again.
9142
*
9243
*/
93-
static int bang_bang_control(struct thermal_zone_device *tz,
94-
const struct thermal_trip *trip)
44+
static void bang_bang_control(struct thermal_zone_device *tz,
45+
const struct thermal_trip *trip,
46+
bool crossed_up)
9547
{
9648
struct thermal_instance *instance;
97-
int ret;
9849

9950
lockdep_assert_held(&tz->lock);
10051

101-
ret = thermal_zone_trip_update(tz, trip);
102-
if (ret)
103-
return ret;
52+
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
53+
thermal_zone_trip_id(tz, trip), trip->temperature,
54+
tz->temperature, trip->hysteresis);
55+
56+
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
57+
if (instance->trip != trip)
58+
continue;
59+
60+
if (instance->target == THERMAL_NO_TARGET)
61+
instance->target = 0;
62+
63+
if (instance->target != 0 && instance->target != 1) {
64+
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
65+
instance->target, instance->name);
66+
67+
instance->target = 1;
68+
}
69+
70+
/*
71+
* Enable the fan when the trip is crossed on the way up and
72+
* disable it when the trip is crossed on the way down.
73+
*/
74+
if (instance->target == 0 && crossed_up)
75+
instance->target = 1;
76+
else if (instance->target == 1 && !crossed_up)
77+
instance->target = 0;
78+
79+
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
80+
81+
mutex_lock(&instance->cdev->lock);
82+
instance->cdev->updated = false; /* cdev needs update */
83+
mutex_unlock(&instance->cdev->lock);
84+
}
10485

10586
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
10687
thermal_cdev_update(instance->cdev);
107-
108-
return 0;
10988
}
11089

11190
static struct thermal_governor thermal_gov_bang_bang = {
11291
.name = "bang_bang",
113-
.throttle = bang_bang_control,
92+
.trip_crossed = bang_bang_control,
11493
};
11594
THERMAL_GOVERNOR_DECLARE(thermal_gov_bang_bang);

0 commit comments

Comments
 (0)