Skip to content

Commit

Permalink
Merge tag 'thermal-6.10-rc1' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/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
  ...
  • Loading branch information
Linus Torvalds committed May 14, 2024
2 parents 4b95dc8 + 3a47fbd commit f952b6c
Show file tree
Hide file tree
Showing 44 changed files with 1,354 additions and 728 deletions.
12 changes: 7 additions & 5 deletions Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ description: Binding for Amlogic Thermal

properties:
compatible:
items:
- enum:
- amlogic,g12a-cpu-thermal
- amlogic,g12a-ddr-thermal
- const: amlogic,g12a-thermal
oneOf:
- items:
- enum:
- amlogic,g12a-cpu-thermal
- amlogic,g12a-ddr-thermal
- const: amlogic,g12a-thermal
- const: amlogic,a1-cpu-thermal

reg:
maxItems: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ properties:
oneOf:
- enum:
- loongson,ls2k1000-thermal
- loongson,ls2k2000-thermal
- items:
- enum:
- loongson,ls2k2000-thermal
- loongson,ls2k0500-thermal
- const: loongson,ls2k1000-thermal

reg:
maxItems: 1
minItems: 1
maxItems: 2

interrupts:
maxItems: 1
Expand All @@ -38,6 +40,24 @@ required:
- interrupts
- '#thermal-sensor-cells'

if:
properties:
compatible:
contains:
enum:
- loongson,ls2k2000-thermal

then:
properties:
reg:
minItems: 2
maxItems: 2

else:
properties:
reg:
maxItems: 1

unevaluatedProperties: false

examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ properties:
compatible:
enum:
- mediatek,mt7988-lvts-ap
- mediatek,mt8186-lvts
- mediatek,mt8188-lvts-ap
- mediatek,mt8188-lvts-mcu
- mediatek,mt8192-lvts-ap
- mediatek,mt8192-lvts-mcu
- mediatek,mt8195-lvts-ap
Expand Down Expand Up @@ -60,6 +63,8 @@ allOf:
compatible:
contains:
enum:
- mediatek,mt8188-lvts-ap
- mediatek,mt8188-lvts-mcu
- mediatek,mt8192-lvts-ap
- mediatek,mt8192-lvts-mcu
then:
Expand All @@ -75,6 +80,7 @@ allOf:
compatible:
contains:
enum:
- mediatek,mt8186-lvts
- mediatek,mt8195-lvts-ap
- mediatek,mt8195-lvts-mcu
then:
Expand Down
12 changes: 8 additions & 4 deletions Documentation/devicetree/bindings/thermal/qcom-lmh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ description:

properties:
compatible:
enum:
- qcom,sc8180x-lmh
- qcom,sdm845-lmh
- qcom,sm8150-lmh
oneOf:
- enum:
- qcom,sc8180x-lmh
- qcom,sdm845-lmh
- qcom,sm8150-lmh
- items:
- const: qcom,qcm2290-lmh
- const: qcom,sm8150-lmh

reg:
items:
Expand Down
58 changes: 58 additions & 0 deletions Documentation/devicetree/bindings/thermal/st,stih407-thermal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/thermal/st,stih407-thermal.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: STMicroelectronics STi digital thermal sensor (DTS)

maintainers:
- Patrice Chotard <patrice.chotard@foss.st.com>
- Lee Jones <lee@kernel.org>

allOf:
- $ref: thermal-sensor.yaml

properties:
compatible:
const: st,stih407-thermal

reg:
maxItems: 1

clocks:
maxItems: 1

clock-names:
items:
- const: thermal

interrupts:
description:
For thermal sensors for which no interrupt has been defined, a polling
delay of 1000ms will be used to read the temperature from device.
maxItems: 1

'#thermal-sensor-cells':
const: 0

required:
- compatible
- reg
- clocks
- clock-names

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
temperature-sensor@91a0000 {
compatible = "st,stih407-thermal";
reg = <0x91a0000 0x28>;
clock-names = "thermal";
clocks = <&CLK_SYSIN>;
interrupts = <GIC_SPI 205 IRQ_TYPE_EDGE_RISING>;
#thermal-sensor-cells = <0>;
};
...
32 changes: 0 additions & 32 deletions Documentation/devicetree/bindings/thermal/st-thermal.txt

This file was deleted.

10 changes: 10 additions & 0 deletions drivers/thermal/amlogic_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ static const struct amlogic_thermal_data amlogic_thermal_g12a_ddr_param = {
.regmap_config = &amlogic_thermal_regmap_config_g12a,
};

static const struct amlogic_thermal_data amlogic_thermal_a1_cpu_param = {
.u_efuse_off = 0x114,
.calibration_parameters = &amlogic_thermal_g12a,
.regmap_config = &amlogic_thermal_regmap_config_g12a,
};

static const struct of_device_id of_amlogic_thermal_match[] = {
{
.compatible = "amlogic,g12a-ddr-thermal",
Expand All @@ -229,6 +235,10 @@ static const struct of_device_id of_amlogic_thermal_match[] = {
.compatible = "amlogic,g12a-cpu-thermal",
.data = &amlogic_thermal_g12a_cpu_param,
},
{
.compatible = "amlogic,a1-cpu-thermal",
.data = &amlogic_thermal_a1_cpu_param,
},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_amlogic_thermal_match);
Expand Down
9 changes: 2 additions & 7 deletions drivers/thermal/armada_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,6 @@ static void armada_set_sane_name(struct platform_device *pdev,
struct armada_thermal_priv *priv)
{
const char *name = dev_name(&pdev->dev);
char *insane_char;

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

/* Then check there are no '-' or hwmon core will complain */
do {
insane_char = strpbrk(priv->zone_name, "-");
if (insane_char)
*insane_char = '_';
} while (insane_char);
/* Then ensure there are no '-' or hwmon core will complain */
strreplace(priv->zone_name, '-', '_');
}

/*
Expand Down
97 changes: 38 additions & 59 deletions drivers/thermal/gov_bang_bang.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,11 @@

#include "thermal_core.h"

static int thermal_zone_trip_update(struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{
int trip_index = thermal_zone_trip_id(tz, trip);
struct thermal_instance *instance;

if (!trip->hysteresis)
dev_info_once(&tz->device,
"Zero hysteresis value for thermal zone %s\n", tz->type);

dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
trip_index, trip->temperature, tz->temperature,
trip->hysteresis);

list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;

/* in case fan is in initial state, switch the fan off */
if (instance->target == THERMAL_NO_TARGET)
instance->target = 0;

/* in case fan is neither on nor off set the fan to active */
if (instance->target != 0 && instance->target != 1) {
pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
instance->name, instance->target);
instance->target = 1;
}

/*
* enable fan when temperature exceeds trip_temp and disable
* the fan in case it falls below trip_temp minus hysteresis
*/
if (instance->target == 0 && tz->temperature >= trip->temperature)
instance->target = 1;
else if (instance->target == 1 &&
tz->temperature < trip->temperature - trip->hysteresis)
instance->target = 0;

dev_dbg(&instance->cdev->device, "target=%d\n",
(int)instance->target);

mutex_lock(&instance->cdev->lock);
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}

return 0;
}

/**
* bang_bang_control - controls devices associated with the given zone
* @tz: thermal_zone_device
* @trip: the trip point
* @crossed_up: whether or not the trip has been crossed on the way up
*
* Regulation Logic: a two point regulation, deliver cooling state depending
* on the previous state shown in this diagram:
Expand All @@ -90,26 +41,54 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz,
* (trip_temp - hyst) so that the fan gets turned off again.
*
*/
static int bang_bang_control(struct thermal_zone_device *tz,
const struct thermal_trip *trip)
static void bang_bang_control(struct thermal_zone_device *tz,
const struct thermal_trip *trip,
bool crossed_up)
{
struct thermal_instance *instance;
int ret;

lockdep_assert_held(&tz->lock);

ret = thermal_zone_trip_update(tz, trip);
if (ret)
return ret;
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
thermal_zone_trip_id(tz, trip), trip->temperature,
tz->temperature, trip->hysteresis);

list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;

if (instance->target == THERMAL_NO_TARGET)
instance->target = 0;

if (instance->target != 0 && instance->target != 1) {
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
instance->target, instance->name);

instance->target = 1;
}

/*
* Enable the fan when the trip is crossed on the way up and
* disable it when the trip is crossed on the way down.
*/
if (instance->target == 0 && crossed_up)
instance->target = 1;
else if (instance->target == 1 && !crossed_up)
instance->target = 0;

dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);

mutex_lock(&instance->cdev->lock);
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}

list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);

return 0;
}

static struct thermal_governor thermal_gov_bang_bang = {
.name = "bang_bang",
.throttle = bang_bang_control,
.trip_crossed = bang_bang_control,
};
THERMAL_GOVERNOR_DECLARE(thermal_gov_bang_bang);
Loading

0 comments on commit f952b6c

Please sign in to comment.