Commit graph

2592 commits

Author SHA1 Message Date
Daniel Lezcano
abda7383ec thermal: Remove debug or error messages in get_temp() ops
Some get_temp() ops implementation are showing an error or a debug
message if the reading of the sensor fails.

The debug message is already displayed from the call site of this
ops. So we can remove it.

On the other side, the error should not be displayed because in
production that can raise tons of messages.

Finally, some drivers are showing a debug message with the
temperature, this is also accessible through the trace from the core
code in the temperature_update() function.

Another benefit is the dev_* messages are accessing the thermal zone
device field from the structure, so we encapsulate even more the code
by preventing these accesses.

Remove those messages.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> #Armada
Acked-by: Florian Fainelli <f.fainelli@gmail.com> #brcmstb_thermal.c
Acked-by: Heiko Stuebner <heiko@sntech.de> #rockchip
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-03 20:45:02 +01:00
Daniel Lezcano
4216e81532 thermal/core: Show a debug message when get_temp() fails
The different thermal drivers are showing an error in case the
get_temp() fails. Actually no traces should be displayed in the
backend ops but in the call site of this ops.

Furthermore, the message is often a dev_dbg message where the
tz->device is used, thus using the internal of the structure from the
driver.

Show a debug message if the thermal_zone_get_temp() fails to read the
sensor temperature, so code showing the message is factored out and
the tz->device accesss is in the scope of the thermal core framework.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-03 20:45:02 +01:00
Daniel Lezcano
5f68d0785e thermal/core: Use the thermal zone 'devdata' accessor in thermal located drivers
The thermal zone device structure is exposed to the different drivers
and obviously they access the internals while that should be
restricted to the core thermal code.

In order to self-encapsulate the thermal core code, we need to prevent
the drivers accessing directly the thermal zone structure and provide
accessor functions to deal with.

Use the devdata accessor introduced in the previous patch.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> #R-Car
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek auxadc and lvts
Reviewed-by: Balsam CHIHI <bchihi@baylibre.com> #Mediatek lvts
Reviewed-by: Adam Ward <DLG-Adam.Ward.opensource@dm.renesas.com> #da9062
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>  #spread
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> #sun8i_thermal
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com> #Broadcom
Reviewed-by: Dhruva Gole <d-gole@ti.com> # K3 bandgap
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Heiko Stuebner <heiko@sntech.de> #rockchip
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> #uniphier
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-03 20:45:02 +01:00
Daniel Lezcano
a6ff3c0021 thermal/core: Add a thermal zone 'devdata' accessor
The thermal zone device structure is exposed to the different drivers
and obviously they access the internals while that should be
restricted to the core thermal code.

In order to self-encapsulate the thermal core code, we need to prevent
the drivers accessing directly the thermal zone structure and provide
accessor functions to deal with.

Provide an accessor to the 'devdata' structure and make use of it in
the different drivers.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-03 20:45:02 +01:00
Srinivas Pandruvada
52f04f10b9 thermal: intel: int340x: processor_thermal: Fix deadlock
When user space updates the trip point there is a deadlock, which results
in caller gets blocked forever.

Commit 05eeee2b51 ("thermal/core: Protect sysfs accesses to thermal
operations with thermal zone mutex"), added a mutex for tz->lock in the
function trip_point_temp_store(). Hence, trip set callback() can't
call any thermal zone API as they are protected with the same mutex lock.

The callback here calling thermal_zone_device_enable(), which will result
in deadlock.

Move the thermal_zone_device_enable() to proc_thermal_pci_probe() to
avoid this deadlock.

Fixes: 05eeee2b51 ("thermal/core: Protect sysfs accesses to thermal operations with thermal zone mutex")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
Cc: 6.2+ <stable@vger.kernel.org> # 6.2+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-03 20:34:49 +01:00
Linus Torvalds
0a3f9a6b02 More thermal control updates for 6.3-rc1
- Fix an error pointer dereference in the quark_dts Intel thermal
    driver (Dan Carpenter).
 
  - Fix the intel_bxt_pmic_thermal driver Kconfig entry to select REGMAP
    which is not user-visible instead of depending on it (Randy Dunlap).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmQCNywSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxQlQQAIFDTFEThpzIoL6uiLsr9Omfqi0HsJ/H
 3X82UgUo6ra7LDl9J2WoP05e9ugzPhoBuZHCQOWAeYmqEk76Wc54tQQCXnxdDEVo
 gEUEq/ReKayMlk0uws2knqn7y7c/exFIwSLbZHAVpp6lpvLDv76ZBP/O410oYLjm
 3u7BXH3usQk51PVj0YkUY/Bw55Bpz+8z1v2FQier8CIrOnQyYW3Q5L2UKNON8DCy
 eB6wohuihpBEnecjhXdrLvU3iCMK7/a3+ztNRdNP4lJq5VDv8K9fl1Bt4/9N2KXv
 0zpAQ9FpTJwIoEK2ToULGF1i6OK7uw0wBC3akuyMdiyYifB6eIWPY/4YyzPIb9L3
 w+63VBcbv5IxXm3qB04gXbqk+i9oRTOlsfbgDsVeRaDM689c8X+JHTa3st0oFiYC
 HBS8LB3NivdxM1u3eN09zY17uM7taRD7mOD99cXWKCUBDFKzpk7iXkXAAh/+Ep3C
 pge0W1xprfPQHnz/E3GhxzwCjrffZFadPXrzPthP2N+FiYHCzv/K0l6yQrjpxoM6
 grMQss5pD5vyeJbGWgYgFO9qoMHUiM7T/wlZIcEWyunUw13zHK5KSQpsaUZu5afc
 5VUmCo3zxjke+vfiHLQsSrrHYfm1FDQhRJyRZ0n0UZypVLvRna1ASUZIotmvLJO1
 AIHrcI0OZQWp
 =dH0U
 -----END PGP SIGNATURE-----

Merge tag 'thermal-6.3-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more thermal control updates from Rafael Wysocki:
 "These fix two issues in the Intel thermal control drivers.

  Specifics:

   - Fix an error pointer dereference in the quark_dts Intel thermal
     driver (Dan Carpenter)

   - Fix the intel_bxt_pmic_thermal driver Kconfig entry to select
     REGMAP which is not user-visible instead of depending on it (Randy
     Dunlap)"

* tag 'thermal-6.3-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal: intel: BXT_PMIC: select REGMAP instead of depending on it
  thermal: intel: quark_dts: fix error pointer dereference
2023-03-03 10:41:59 -08:00
Randy Dunlap
1467fb9603 thermal: intel: BXT_PMIC: select REGMAP instead of depending on it
REGMAP is a hidden (not user visible) symbol. Users cannot set it
directly thru "make *config", so drivers should select it instead of
depending on it if they need it.

Consistently using "select" or "depends on" can also help reduce
Kconfig circular dependency issues.

Therefore, change the use of "depends on REGMAP" to "select REGMAP".

Fixes: b474303ffd ("thermal: add Intel BXT WhiskeyCove PMIC thermal driver")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-01 19:32:00 +01:00
Dan Carpenter
f1b930e740 thermal: intel: quark_dts: fix error pointer dereference
If alloc_soc_dts() fails, then we can just return.  Trying to free
"soc_dts" will lead to an Oops.

Fixes: 8c18769396 ("thermal: intel Quark SoC X1000 DTS thermal driver")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-01 19:28:57 +01:00
Linus Torvalds
11c7052998 ARM: SoC drivers for 6.3
As usual, there are lots of minor driver changes across SoC platforms
 from  NXP, Amlogic, AMD Zynq, Mediatek, Qualcomm, Apple and Samsung.
 These usually add support for additional chip variations in existing
 drivers, but also add features or bugfixes.
 
 The SCMI firmware subsystem gains a unified raw userspace interface
 through debugfs, which can be used for validation purposes.
 
 Newly added drivers include:
 
  - New power management drivers for StarFive JH7110, Allwinner D1 and
    Renesas RZ/V2M
 
  - A driver for Qualcomm battery and power supply status
 
  - A SoC device driver for identifying Nuvoton WPCM450 chips
 
  - A regulator coupler driver for Mediatek MT81xxv
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmPtSN8ACgkQmmx57+YA
 GNkOSw/+JS5tElm/ZP7c3uWYp6uwvcb0jUlKW/U3aCtPiPEcYDLEqIEXwcNdaDMh
 m4rW3GYlW0IRL3FsyuYkSLx+EIIUIfs40wldYXJOqRDj0XasndiloIwltOQJGfd9
 C/UVM0FpJdxMJrcBMFgwLLQCIbAVnhHP34i6ppDRgxW/MfTeiCaaG6fnS70iv6mC
 oh2N7FoZSKDtTrFtlR5TqFiK5v/W1CgNJVuglkFB0ceFpjyBpp/8AT0FGS887xCz
 IYSTqm4Q/79vaZXI1Y2oog257cgdwsVqgPrnK5CuSFhTnAcJMCekiFelHq8Yhyuk
 Rw7j/B3KO3AOaxmR75c6SZdeZ+VHgUMRC/RKe3fay0sm3Zea2kAIPXA6Zn+r/cxb
 8M94V59qBz+f8XmpXRTK1UR3s3EbwFIuNyuDIkeorMtpSKtvqJXmZxGDwNIfXr2F
 /voo++MKjzdtdxdW/D/5Tc9DC0Pyb4HLi0EYj2QCzA03njmfLDF1w73NfzMec+GD
 R1zAd3FEbiJQx8Hin0PSPjYXpfMnkjkGAEcE9N9Ralg4ewNWAxfOFsAhHKTZNssL
 pitTAvHR/+dXtvkX7FUi2l/6fqn8nJUrg/xRazPPp3scRbpuk8m6P4MNr3/lsaHk
 HTQ/hYwDdecWLvKXjw5y9yIr3yhLmPPcloTVIIFFjsM0t8b+d9E=
 =p6Xp
 -----END PGP SIGNATURE-----

Merge tag 'soc-drivers-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC driver updates from Arnd Bergmann:
 "As usual, there are lots of minor driver changes across SoC platforms
  from NXP, Amlogic, AMD Zynq, Mediatek, Qualcomm, Apple and Samsung.
  These usually add support for additional chip variations in existing
  drivers, but also add features or bugfixes.

  The SCMI firmware subsystem gains a unified raw userspace interface
  through debugfs, which can be used for validation purposes.

  Newly added drivers include:

   - New power management drivers for StarFive JH7110, Allwinner D1 and
     Renesas RZ/V2M

   - A driver for Qualcomm battery and power supply status

   - A SoC device driver for identifying Nuvoton WPCM450 chips

   - A regulator coupler driver for Mediatek MT81xxv"

* tag 'soc-drivers-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (165 commits)
  power: supply: Introduce Qualcomm PMIC GLINK power supply
  soc: apple: rtkit: Do not copy the reg state structure to the stack
  soc: sunxi: SUN20I_PPU should depend on PM
  memory: renesas-rpc-if: Remove redundant division of dummy
  soc: qcom: socinfo: Add IDs for IPQ5332 and its variant
  dt-bindings: arm: qcom,ids: Add IDs for IPQ5332 and its variant
  dt-bindings: power: qcom,rpmpd: add RPMH_REGULATOR_LEVEL_LOW_SVS_L1
  firmware: qcom_scm: Move qcom_scm.h to include/linux/firmware/qcom/
  MAINTAINERS: Update qcom CPR maintainer entry
  dt-bindings: firmware: document Qualcomm SM8550 SCM
  dt-bindings: firmware: qcom,scm: add qcom,scm-sa8775p compatible
  soc: qcom: socinfo: Add Soc IDs for IPQ8064 and variants
  dt-bindings: arm: qcom,ids: Add Soc IDs for IPQ8064 and variants
  soc: qcom: socinfo: Add support for new field in revision 17
  soc: qcom: smd-rpm: Add IPQ9574 compatible
  soc: qcom: pmic_glink: remove redundant calculation of svid
  soc: qcom: stats: Populate all subsystem debugfs files
  dt-bindings: soc: qcom,rpmh-rsc: Update to allow for generic nodes
  soc: qcom: pmic_glink: add CONFIG_NET/CONFIG_OF dependencies
  soc: qcom: pmic_glink: Introduce altmode support
  ...
2023-02-27 10:04:49 -08:00
Alain Volmat
6828e402d0 thermal/drivers/st: Remove syscfg based driver
The syscfg based thermal driver is only supporting STiH415 STiH416 and
STiD127 platforms which are all no more supported.  We can thus safely
remove this driver since the remaining STi platform STiH407/STiH410
and STiH418 are all using the memmap based thermal driver.

Signed-off-by: Alain Volmat <avolmat@me.com>
Link: https://lore.kernel.org/r/20230209091659.1409-7-avolmat@me.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:30:04 +01:00
Daniel Lezcano
9272d2d43b thermal: Remove core header inclusion from drivers
As the name states "thermal_core.h" is the header file for the core
components of the thermal framework.

Too many drivers are including it. Hopefully the recent cleanups
helped to self encapsulate the code a bit more and prevented the
drivers to need this header.

Remove this inclusion in every place where it is possible.

Some other drivers did a confusion with the core header and the one
exported in linux/thermal.h. They include the former instead of the
latter. The changes also fix this.

The tegra/soctherm driver still remains as it uses an internal
function which need to be replaced.

The Intel HFI driver uses the netlink internal framework core and
should be changed to prevent to deal with the internals.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> # armada_thermal.c
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> # uniphier_thermal.c
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> # rcar_gen3_thermal.c
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> # amlogic_thermal.c
Acked-by: Florian Fainelli <f.fainelli@gmail.com> # bcm2835_thermal.c
Acked-by: Thierry Reding <treding@nvidia.com> # tegra30-tsensor.c
Link: https://lore.kernel.org/r/20230206153432.1017282-1-daniel.lezcano@linaro.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:29:48 +01:00
Yongqin Liu
15cc25829a thermal/drivers/hisi: Drop second sensor hi3660
The commit 74c8e6bffb ("driver core: Add __alloc_size hint to devm
allocators") exposes a panic "BRK handler: Fatal exception" on the
hi3660_thermal_probe funciton.
This is because the function allocates memory for only one
sensors array entry, but tries to fill up a second one.

Fix this by removing the unneeded second access.

Fixes: 7d3a2a2bba ("thermal/drivers/hisi: Fix number of sensors on hi3660")
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Link: https://lore.kernel.org/linux-mm/20221101223321.1326815-5-keescook@chromium.org/
Link: https://lore.kernel.org/r/20230210141507.71014-1-yongqin.liu@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:29:33 +01:00
Niklas Söderlund
47b2d3d2ed thermal/drivers/rcar_gen3_thermal: Fix device initialization
The thermal zone is registered before the device is register and the
thermal coefficients are calculated, providing a window for very
incorrect readings.

The reason why the zone was register before the device was fully
initialized was that the presence of the set_trips() callback is used to
determine if the driver supports interrupt or not, as it is not defined
if the device is incapable of interrupts.

Fix this by using the operations structure in the private data instead
of the zone to determine if interrupts are available or not, and
initialize the device before registering the zone.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20230208190333.3159879-4-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:29:23 +01:00
Niklas Söderlund
aef43e0493 thermal/drivers/rcar_gen3_thermal: Create device local ops struct
The callback operations are modified on a driver global level. If one
device tree description do not define interrupts, the set_trips()
operation was disabled globally for all users of the driver.

Fix this by creating a device local copy of the operations structure and
modify the copy depending on what the device can do.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20230208190333.3159879-3-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:29:15 +01:00
Niklas Söderlund
1c63f8cd01 thermal/drivers/rcar_gen3_thermal: Do not call set_trips() when resuming
There is no need to explicitly call set_trips() when resuming from
suspend. The thermal framework calls thermal_zone_device_update() that
restores the trip points.

Suggested-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20230208190333.3159879-2-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:29:07 +01:00
Geert Uytterhoeven
883d155299 thermal/drivers/rcar_gen3: Add support for R-Car V4H
Add support for the Thermal Sensor/Chip Internal Voltage Monitor/Core
Voltage Monitor (THS/CIVM/CVM) on the Renesas R-Car V4H (R8A779G0) SoC.

According to the R-Car V4H Hardware User's Manual Rev. 0.70, the
(preliminary) conversion formula for the thermal sensor is the same as
for most other R-Car Gen3 and Gen4 SoCs, while the (preliminary)
conversion formula for the chip internal voltage monitor differs.
As the driver only uses the former, no further changes are needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/852048eb5f4cc001be7a97744f4c5caea912d071.1675958665.git.geert+renesas@glider.be
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:28:58 +01:00
Balsam CHIHI
f5f633b182 thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver
The Low Voltage Thermal Sensor (LVTS) is a multiple sensors, multi
controllers contained in a thermal domain.

A thermal domains can be the MCU or the AP.

Each thermal domains contain up to seven controllers, each thermal
controller handle up to four thermal sensors.

The LVTS has two Finite State Machines (FSM), one to handle the
functionin temperatures range like hot or cold temperature and another
one to handle monitoring trip point. The FSM notifies via interrupts
when a trip point is crossed.

The interrupt is managed at the thermal controller level, so when an
interrupt occurs, the driver has to find out which sensor triggered
such an interrupt.

The sampling of the thermal can be filtered or immediate. For the
former, the LVTS measures several points and applies a low pass
filter.

Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

On MT8195 Tomato Chromebook:

Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230209105628.50294-5-bchihi@baylibre.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:28:42 +01:00
Balsam CHIHI
fad399ebdd thermal/drivers/mediatek: Relocate driver to mediatek folder
Add MediaTek proprietary folder to upstream more thermal zone and cooler
drivers, relocate the original thermal controller driver to it, and rename it
as "auxadc_thermal.c" to show its purpose more clearly.

Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230209105628.50294-2-bchihi@baylibre.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-15 17:28:25 +01:00
Rafael J. Wysocki
badf1f9050 Merge branch 'thermal-intel'
Merge thermal control changes related to Intel platforms for 6.3-rc1:

 - Rework ACPI helper functions for thermal control to retrieve a trip
   point temperature instead of initializing a trip point objetc (Rafael
   Wysocki).

 - Clean up and improve the int340x thermal driver ((Rafael Wysocki).

 - Simplify and clean up the intel_pch thermal driver ((Rafael Wysocki).

 - Fix the Intel powerclamp thermal driver and make it use the common
   idle injection framework (Srinivas Pandruvada).

 - Add two module parameters, cpumask and max_idle, to the Intel powerclamp
   thermal driver to allow it to affect only a specific subset of CPUs
   instead of all of them (Srinivas Pandruvada).

 - Make the Intel quark_dts thermal driver Use generic trip point
   objects instead of its own trip point representation (Daniel
   Lezcano).

 - Add toctree entry for thermal documents and fix two issues in the
   Intel powerclamp driver documentation (Bagas Sanjaya).

* thermal-intel: (25 commits)
  Documentation: powerclamp: Fix numbered lists formatting
  Documentation: powerclamp: Escape wildcard in cpumask description
  Documentation: admin-guide: Add toctree entry for thermal docs
  thermal: intel: powerclamp: Add two module parameters
  Documentation: admin-guide: Move intel_powerclamp documentation
  thermal: intel: powerclamp: Fix duration module parameter
  thermal: intel: powerclamp: Return last requested state as cur_state
  thermal: intel: quark_dts: Use generic trip points
  thermal: intel: powerclamp: Use powercap idle-inject feature
  powercap: idle_inject: Add update callback
  powercap: idle_inject: Export symbols
  thermal: intel: powerclamp: Fix cur_state for multi package system
  thermal: intel: intel_pch: Drop struct board_info
  thermal: intel: intel_pch: Rename board ID symbols
  thermal: intel: intel_pch: Fold suspend and resume routines into their callers
  thermal: intel: intel_pch: Fold two functions into their callers
  thermal: intel: intel_pch: Eliminate device operations object
  thermal: intel: intel_pch: Rename device operations callbacks
  thermal: intel: intel_pch: Eliminate redundant return pointers
  thermal: intel: intel_pch: Make pch_wpt_add_acpi_psv_trip() return int
  ...
2023-02-15 17:18:08 +01:00
Rafael J. Wysocki
c3bd6d539f Merge branch 'thermal-core'
Merge thermal control core changes for 6.3-rc1:

 - Clean up thermal device unregistration code (Viresh Kumar).

 - Fix and clean up thermal control core initialization error code
   paths (Daniel Lezcano).

 - Relocate the trip points handling code into a separate file (Daniel
   Lezcano).

 - Make the thermal core fail registration of thermal zones and cooling
   devices if the thermal class has not been registered (Rafael Wysocki).

 - Make the core thermal control code use sysfs_emit_at() instead of
   scnprintf() where applicable (ye xingchen).

* thermal-core:
  thermal: core: Use sysfs_emit_at() instead of scnprintf()
  thermal: Fail object registration if thermal class is not registered
  thermal/core: Move the thermal trip code to a dedicated file
  thermal/core: Remove unneeded ida_destroy()
  thermal/core: Fix unregistering netlink at thermal init time
  thermal: core: Use device_unregister() instead of device_del/put()
  thermal: core: Move cdev cleanup to thermal_release()
2023-02-15 17:08:30 +01:00
Arnd Bergmann
68907175ec More Qualcomm driver updates for 6.3
The qcom_scm.h file is moved into firmware/qcom, to avoid having any
 Qualcomm-specific files directly in include/linux.
 
 Support for PMIC GLINK is introduced, which on newer Qualcomm platforms
 provides an interface to the firmware implementing battery management
 and USB Type-C handling. Together with the base driver comes the custom
 altmode support driver.
 
 SMD RPM gains support for IPQ9574, and socinfo is extended with support
 for revision 17 of the information format and soc_id for IPQ5332 and
 IPQ8064 are added.
 
 The qcom_stats  is changes not to fail when not all parts are
 initialized.
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCAAzFiEEBd4DzF816k8JZtUlCx85Pw2ZrcUFAmPmiz4VHGFuZGVyc3Nv
 bkBrZXJuZWwub3JnAAoJEAsfOT8Nma3FMZ8QANXJEr7U2KX/yd4riBju6Btn0unl
 I8TR5XlaQAoBUbyp4yTcCUfCe0mEiNcE/YgJwzSKY3mNxc9vLhn1GgqdF+5RFTZw
 0H8GBjUpQiRoCC2+pq3YCEisQ49HYXy9W3ys6t1Y3l8xUDLhw5CkeKOGQCqeBDX7
 pCflPy7HFUQwPhGt7AOmpNj8+Kh4GnpJHF3D2ShAMFNOn4+l0v8Gh7zDw62FmhBg
 gjA7eS2aZS7KmqEJMAC4dEFdmhvvN+a80KaWNOOQn2sdLtD64pRW2hknxinPRN+t
 dGQKeD+VGFHLfxWO40Lv0nP8P/EWjXiZdhO8HXLmVjHC56G/MG8AW0BkvxW9jPAa
 QGlzY0TbEbi0MbbAnyCJTy6USGtVUZbEmfcZ8r3rUJX5xO8eszSjueD6fH/nKIgo
 hDIIG8nSLf5TCY+NJzGr8dKENiElsgsfdNAypoX6kpXCRUCXxkiKlWzy/3oywVcO
 bKm5xs76YNNaANFf46oO6kts7nrOcegyTAdvauFemy1Q3KSWQuFP4jNpcRvWnVMN
 8/BlQ+a5uGofN/wwHS2CPmE1r8njEqlPc7wWNc0ugoRO4kAUtB2UldjjS/ZfaFvH
 BZiDDXhjScPj8lKk4kzGOb34W5AKkwFbTwSR1oN0ckW9UNDx51pNu72YlU8WLydV
 VHmzD9ndTkWSmp7W
 =+KgT
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmPqVbkACgkQmmx57+YA
 GNnlFRAAuaoe9/7kOAliVks4vkJ8284POk50kuS5llzNAP4BPsQIJakE6dOOiTY1
 01qbvTlu5pK+f2ls+3WQYr5Rhgck4BUEFD+t9WcPtOpB1uq0puyWj3fwuErjDFJv
 S6nKp2P0tpru5VzQFPROyrBCw5Zlkc0U9FID4P1Ub5ulxxDWJ4ODb9Q+C9DtDxJo
 HuUGRnGPLmAJd4ymKzCtnqcg3gocFdrl9K+msFuJwAgdZ0xB893l3wyOFn2k97Uh
 8m8WEI/NbCTfDEjag3+yx9Sl3rZhtav0EnlIqowBHQFvxFaBDnvW6H4QmNRugAog
 +kH1hVzojj35jDllwL07OJzdjqW497Z9i+MEGz45h/8FvvdqJ+71UTkOwr+vnWKu
 zuEzEfM+bB434UBCQihJ7emx7eCac3TP3Von/NigDDBIXDu8iqNgUNmB8eNyN+gJ
 Db1mdatG4TuSEqnzetX4XKLP3eydxG8lkEZDOcWlhRz8CSWx9KkBU7W+hVNCBLdV
 kdhjvZpb5cRcqc/KsS22hmB3HIoISGkLrBOvqs375+Sg9PFxBGst+q24kf9MEDFz
 ypj/CRiMzkNq8IBwGF003CVhDHmlloq2afQ7YX0w1sEE0XOCIDE0YWNNb9fcoTAC
 MeDL9R4VgfjR/8Bj7zgnYOMAt6hRoHXsZ1gtS29doIH5iLdTXVI=
 =8eLr
 -----END PGP SIGNATURE-----

Merge tag 'qcom-drivers-for-6.3-2' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into soc/drivers

More Qualcomm driver updates for 6.3

The qcom_scm.h file is moved into firmware/qcom, to avoid having any
Qualcomm-specific files directly in include/linux.

Support for PMIC GLINK is introduced, which on newer Qualcomm platforms
provides an interface to the firmware implementing battery management
and USB Type-C handling. Together with the base driver comes the custom
altmode support driver.

SMD RPM gains support for IPQ9574, and socinfo is extended with support
for revision 17 of the information format and soc_id for IPQ5332 and
IPQ8064 are added.

The qcom_stats  is changes not to fail when not all parts are
initialized.

* tag 'qcom-drivers-for-6.3-2' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux:
  soc: qcom: socinfo: Add IDs for IPQ5332 and its variant
  dt-bindings: arm: qcom,ids: Add IDs for IPQ5332 and its variant
  dt-bindings: power: qcom,rpmpd: add RPMH_REGULATOR_LEVEL_LOW_SVS_L1
  firmware: qcom_scm: Move qcom_scm.h to include/linux/firmware/qcom/
  MAINTAINERS: Update qcom CPR maintainer entry
  dt-bindings: firmware: document Qualcomm SM8550 SCM
  dt-bindings: firmware: qcom,scm: add qcom,scm-sa8775p compatible
  soc: qcom: socinfo: Add Soc IDs for IPQ8064 and variants
  dt-bindings: arm: qcom,ids: Add Soc IDs for IPQ8064 and variants
  soc: qcom: socinfo: Add support for new field in revision 17
  soc: qcom: smd-rpm: Add IPQ9574 compatible
  soc: qcom: pmic_glink: remove redundant calculation of svid
  soc: qcom: stats: Populate all subsystem debugfs files
  dt-bindings: soc: qcom,rpmh-rsc: Update to allow for generic nodes
  soc: qcom: pmic_glink: add CONFIG_NET/CONFIG_OF dependencies
  soc: qcom: pmic_glink: Introduce altmode support
  soc: qcom: pmic_glink: Introduce base PMIC GLINK driver
  dt-bindings: soc: qcom: Introduce PMIC GLINK binding
  soc: qcom: dcc: Drop driver for now

Link: https://lore.kernel.org/r/20230210182242.2023901-1-andersson@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2023-02-13 16:22:33 +01:00
Srinivas Pandruvada
ebf5197102 thermal: intel: powerclamp: Add two module parameters
In some use cases, it is desirable to only inject idle on certain set
of CPUs. For example on Alder Lake systems, it is possible that we force
idle only on P-Cores for thermal reasons. Also the idle percent can be
more than 50% if we only choose partial set of CPUs in the system.

Introduce 2 new module parameters for this purpose. They can be only
changed when the cooling device is inactive.

cpumask (Read/Write): A bit mask of CPUs to inject idle. The format of
this bitmask is same as used in other subsystems like in
/proc/irq/*/smp_affinity. The mask is comma separated 32 bit groups.
Each CPU is one bit. For example for 256 CPU system the full mask is:
ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff
The rightmost mask is for CPU 0-32.

max_idle (Read/Write): Maximum injected idle time to the total CPU time
ratio in percent range from 1 to 100. Even if the cooling device max_state
is always 100 (100%), this parameter allows to add a max idle percent
limit. The default is 50, to match the current implementation of powerclamp
driver. Also doesn't allow value more than 75, if the cpumask includes
every CPU present in the system.

Also when the cpumask doesn't include every CPU, there is no use of
compensation using package C-state idle counters. Hence don't start
package C-state polling thread even for a single package or a single die
system in this case.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-09 21:01:06 +01:00
ye xingchen
5bbafd4362 thermal: core: Use sysfs_emit_at() instead of scnprintf()
Follow the advice in Documentation/filesystems/sysfs.rst that show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-09 20:39:48 +01:00
Srinivas Pandruvada
966d0ab673 thermal: intel: powerclamp: Fix duration module parameter
After the switch to use the powercap/idle-inject framework in the Intel
powerclamp driver, the idle duration unit is microsecond.

However, the module parameter for idle duration is in milliseconds, so
convert it to microseconds in the "set" callback and back to milliseconds
in a new "get" callback.

While here, also use mutex protection for setting and getting "duration".

The other uses of "duration" are already protected by the mutex.

Fixes: 8526eb7fc7 ("thermal: intel: powerclamp: Use powercap idle-inject feature")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-09 19:57:35 +01:00
Elliot Berman
3bf90eca76 firmware: qcom_scm: Move qcom_scm.h to include/linux/firmware/qcom/
Move include/linux/qcom_scm.h to include/linux/firmware/qcom/qcom_scm.h.
This removes 1 of a few remaining Qualcomm-specific headers into a more
approciate subdirectory under include/.

Suggested-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230203210956.3580811-1-quic_eberman@quicinc.com
2023-02-08 19:15:16 -08:00
Srinivas Pandruvada
6210849654 thermal: intel: powerclamp: Return last requested state as cur_state
When the user is reading cur_state from the thermal cooling device for
Intel powerclamp device:
 - It returns the idle ratio from Package C-state counters when
   there is active idle injection session.
 - -1, when there is no active idle injection session.

This information is not very useful as the package C-state counters vary
a lot from read to read. Instead just return the last requested cur_state.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-07 20:51:15 +01:00
Daniel Lezcano
72ffc28f2f thermal: intel: quark_dts: Use generic trip points
Make the intel_quark_dts_thermal driver register an array of generic
trip points along with the thermal zone and drop the trip points
thermal zone callbacks that are not used any more from it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-03 14:49:26 +01:00
Srinivas Pandruvada
8526eb7fc7 thermal: intel: powerclamp: Use powercap idle-inject feature
There are two idle injection implementation in the Linux kernel. One
via intel_powerclamp and the other using powercap/idle_inject. Both
implementation end up in calling play_idle* function from a FIFO
priority thread. Both can't be used at the same time.

It is better to use one idle injection framework for better
maintainability. In this way, there is only one caller for play_idle.

Here powercap/idle_inject can be used for both per-core and for system
wide idle injection. This framework has a well defined interface which
allow registry for per-core or for all CPUs (system wide).

This reduces code complexity in the intel powerclamp driver as all the
per CPU kthreads, delayed work and calls to play_idle can be removed.

The changes include:
 - Remove unneeded include files
 - Remove per CPU kthread workers: balancing_work and idle_injection_work.
 - Reuse the compensation related code by moving from previous worker
   thread to idle_injection callback.
 - Adjust the idle_duration and runtime by using powercap/idle_inject
   interface.
 - Remove all variables, which are not required once powercap/idle_inject
   is used.
 - Add mutex to avoid race during removal of idle injection during module
   unload and user action to change idle inject percent. Also for
   protection during dynamic adjustment of run and idle time from
   update() callback.
 - Remove online/offline callbacks to designate control CPU
 - Use cpu_present_mask global variable for CPU mask
 - Remove hot plug locks

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-03 14:48:34 +01:00
Srinivas Pandruvada
8e47363588 thermal: intel: powerclamp: Fix cur_state for multi package system
The powerclamp cooling device cur_state shows actual idle observed by
package C-state idle counters. But the implementation is not sufficient
for multi package or multi die system. The cur_state value is incorrect.
On these systems, these counters must be read from each package/die and
somehow aggregate them. But there is no good method for aggregation.

It was not a problem when explicit CPU model addition was required to
enable intel powerclamp. In this way certain CPU models could have
been avoided. But with the removal of CPU model check with the
availability of Package C-state counters, the driver is loaded on most
of the recent systems.

For multi package/die systems, just show the actual target idle state,
the system is trying to achieve. In powerclamp this is the user set
state minus one.

Also there is no use of starting a worker thread for polling package
C-state counters and applying any compensation for multiple package
or multiple die systems.

Fixes: b721ca0d19 ("thermal/powerclamp: remove cpu whitelist")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 4.14+ <stable@vger.kernel.org> # 4.14+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-02 21:08:32 +01:00
Rafael J. Wysocki
2153a87ff9 thermal: intel: intel_pch: Drop struct board_info
Because the only member of struct board_info is the name, the
board_info[] array of struct board_info elements can be replaced with
an array of strings.

Modify the code accordingly and drop struct board_info.

No intentional functional impact.

Suggested-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 21:06:24 +01:00
Rafael J. Wysocki
ae98e57a6e thermal: intel: intel_pch: Rename board ID symbols
Use capitals in the names of the board ID symbols and add the PCH_
prefix to each of them for consistency.

Also rename the board_ids enum accordingly.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 21:06:15 +01:00
Rafael J. Wysocki
c5f43242f4 thermal: intel: intel_pch: Fold suspend and resume routines into their callers
Fold pch_suspend() and pch_resume(), that each have only one caller,
into their respective callers to make the code somewhat easier to
follow.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 21:06:09 +01:00
Rafael J. Wysocki
35c87f948d thermal: intel: intel_pch: Fold two functions into their callers
Fold two functions, pch_hw_init() and pch_get_temp(), that each have
only one caller, into their respective callers to make the code somewhat
easier to follow.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 21:04:01 +01:00
Rafael J. Wysocki
86cb1004b6 thermal: intel: intel_pch: Eliminate device operations object
The same device operations object is pointed to by all of the board
configurations in the driver, so effectively the same operations
callbacks are used by all of them which only adds overhead (that can
be significant due to retpolines) for no real purpose.

For this reason, drop the device operations object and replace the
respective callback invocations by direct calls to the specific
functions that were previously pointed to by callback pointers.

No intentional change in behavior.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:40:39 +01:00
Rafael J. Wysocki
1aa4f925d8 thermal: intel: intel_pch: Rename device operations callbacks
Because the same device operations callbacks are used for all supported
boards, they are in fact generic, so rename them to reflect that.

Also rename the operations object itself for consistency.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:40:39 +01:00
Rafael J. Wysocki
558718f4d3 thermal: intel: intel_pch: Eliminate redundant return pointers
Both pch_wpt_init() and pch_wpt_get_temp() can return the proper
result via their return values, so they do not need to use return
pointers.

Modify them accordingly.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:40:39 +01:00
Rafael J. Wysocki
2cee73568e thermal: intel: intel_pch: Make pch_wpt_add_acpi_psv_trip() return int
Modify pch_wpt_add_acpi_psv_trip() to return an int value instead of
using a return pointer for that.

While at it, drop an excessive empty code line.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:40:39 +01:00
Rafael J. Wysocki
1bcebcab88 thermal: intel: int340x: Improve int340x_thermal_set_trip_temp()
Instead of using snprintf() to populate the ACPI object name in
int340x_thermal_set_trip_temp(), use an appropriate initializer
and make the function fail if its trip argument is greater than 9,
because ACPI object names can only be 4 characters long and it does
not make sense to even try to evaluate objects with longer names (that
argument is guaranteed to be non-negative, because it comes from the
thermal code that will not pass negative trip numbers to zone
callbacks).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:31:04 +01:00
Rafael J. Wysocki
d0009d14e9 thermal: intel: int340x: Drop pointless cast to unsigned long
The explicit casting from int to unsigned long in
int340x_thermal_get_zone_temp() is pointless, becuase the multiplication
result is cast back to int by the assignment in the same statement, so
drop it.

No expected functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:31:04 +01:00
Rafael J. Wysocki
67c6945867 thermal: intel: int340x: Rename variable in int340x_thermal_zone_add()
Rename local variables int34x_thermal_zone in int340x_thermal_zone_add()
and int340x_thermal_zone_remove() to int34x_zone which allows a number
of code lines to be shorter and easier to read and adjust some white
space for consistency.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:31:04 +01:00
Rafael J. Wysocki
be014c789c thermal: intel: int340x: Assorted minor cleanups
Improve some inconsistent usage of white space in int340x_thermal_zone.c,
fix up one coding style issue in it (missing braces around an else
branch of a conditional) and while at it replace a !ACPI_FAILURE()
check with an equivalent ACPI_SUCCESS() one.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
2023-02-02 15:31:04 +01:00
Rafael J. Wysocki
dd3b3d160e thermal: ACPI: Make helpers retrieve temperature only
It is slightly better to make the ACPI thermal helper functions retrieve
the trip point temperature only instead of doing the full trip point
initialization, because they are also used for updating some already
registered trip points, in which case initializing a new trip just
in order to update the temperature of an existing one is somewhat
wasteful.

Modify the ACPI thermal helpers accordingly and update their users.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-02-02 15:26:45 +01:00
Rafael J. Wysocki
f364beb5b6 Merge branch 'thermal-intel'
Merge changes affecting thermal control on Intel platforms for 6.3-rc1:

 - Consolidate code accessing the Intel TCC (Thermal Control Circuitry)
   MSRs by introducing library functions for that and making the
   TCC-related code in thermal drivers use them (Zhang Rui).

 - Enhance the x86_pkg_temp_thermal driver to support dynamic tjmax
   changes (Zhang Rui).

 - Address an "unsigned expression compared with zero" warning in the
   intel_soc_dts_iosf thermal driver (Yang Li).

 - Update comments regarding two functions in the Intel Menlow thermal
   driver (Deming Wang).

 - Use sysfs_emit_at() instead of scnprintf() in the int340x thermal
   driver (ye xingchen).

 - Make the intel_pch thermal driver support the Wellsburg PCH (Tim
   Zimmermann).

 - Add trip point initialization helper functions for ACPI-defined trip
   points and modify two thermal drivers to use them (Rafael Wysocki,
   Daniel Lezcano).

 - Modify the intel_pch and processor_thermal_device_pci thermal drivers
   use generic trip point tables instead of thermal zone trip point
   callbacks (Daniel Lezcano).

 - Add production mode attribute sysfs attribute to the int340x thermal
   driver (Srinivas Pandruvada).

 - Rework dynamic trip point updates handling and locking in the int340x
   thermal driver (Rafael Wysocki).

 - Make the int340x thermal driver use a generic trip points table
   instead of thermal zone trip point callbacks (Rafael Wysocki, Daniel
   Lezcano).

* thermal-intel:
  thermal: intel: int340x: Use generic trip points table
  thermal: intel: int340x: Use zone lock for synchronization
  thermal: intel: int340x: Rework updating trip points
  thermal: ACPI: Initialize trips if temperature is out of range
  thermal: intel: processor_thermal_device_pci: Use generic trip point
  thermal: intel: int340x: Add production mode attribute
  thermal: intel: intel_pch: Use generic trip points
  thermal: ACPI: Add ACPI trip point routines
  thermal: intel: intel_pch: Add support for Wellsburg PCH
  thermal: int340x_thermal: Use sysfs_emit_at() instead of scnprintf()
  thermal: intel: menlow: Update function descriptions
  thermal: intel: Fix unsigned comparison with less than zero
  thermal/x86_pkg_temp_thermal: Add support for handling dynamic tjmax
  thermal/x86_pkg_temp_thermal: Use Intel TCC library
  thermal/intel/intel_tcc_cooling: Use Intel TCC library
  thermal/intel/intel_soc_dts_iosf: Use Intel TCC library
  thermal/int340x/processor_thermal: Use Intel TCC library
  thermal/intel: Introduce Intel TCC library
2023-01-30 14:13:26 +01:00
Rafael J. Wysocki
79b2027097 Merge back thermal control material for 6.3. 2023-01-27 15:55:23 +01:00
Rafael J. Wysocki
f4118dbe61 thermal: intel: int340x: Use generic trip points table
Modify int340x_thermal_zone_add() to register the thermal zone along
with a trip points table, which allows the trip-related zone callbacks
to be dropped, because they are not needed any more.

In order to consolidate the code, use ACPI trip library functions to
populate generic trip points in int340x_thermal_read_trips() and to
update them in int340x_thermal_update_trips().

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Co-developed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-27 15:11:12 +01:00
Rafael J. Wysocki
9e9b7e182c thermal: intel: int340x: Use zone lock for synchronization
Because the ->get_trip_temp() and ->get_trip_type() thermal zone
callbacks are only invoked from __thermal_zone_get_trip() which is
always called by the thermal core under the zone lock, it is sufficient
for int340x_thermal_update_trips() to acquire the zone lock for mutual
exclusion with those callbacks.

Accordingly, modify int340x_thermal_update_trips() to use the zone lock
instead of the internal trip_mutex and drop the latter which is not
necessary any more.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-27 15:11:12 +01:00
Rafael J. Wysocki
b1bf9dbffc thermal: intel: int340x: Rework updating trip points
It is generally invalid to change the trip point indices after they have
been exposed via sysfs.

Moreover, the thermal objects in the ACPI namespace cannot go away and
appear on the fly.  In practice, the only thing that can happen when the
INT3403_PERF_TRIP_POINT_CHANGED notification is sent by the platform
firmware is a change of the return values of those thermal objects.

For this reason, add a special function for updating the trip point
temperatures after re-evaluating the respective ACPI thermal objects
and change int3403_notify() to invoke it instead of
int340x_thermal_read_trips() that would change the trip point indices
on errors.  Also remove the locking from the latter, because it is only
called before registering the thermal zone and it cannot race with the
zone's callbacks.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-27 15:11:12 +01:00
Rafael J. Wysocki
97efecfdbf thermal: ACPI: Initialize trips if temperature is out of range
In some cases it is still useful to register a trip point if the
temperature returned by the corresponding ACPI thermal object (for
example, _HOT) is invalid to start with, because the same ACPI
thermal object may start to return a valid temperature after a
system configuration change (for example, from an AC power source
to battery an vice versa).

For this reason, if the ACPI thermal object evaluated by
thermal_acpi_trip_init() successfully returns a temperature value that
is out of the range of values taken into account, initialize the trip
point using THERMAL_TEMP_INVALID as the temperature value instead of
returning an error to allow the user of the trip point to decide what
to do with it.

Also update pch_wpt_add_acpi_psv_trip() to reject trip points with
invalid temperature values.

Fixes: 7a0e397488 ("thermal: ACPI: Add ACPI trip point routines")
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-27 15:09:47 +01:00
Rafael J. Wysocki
a5c926acd0 Merge back Intel thermal control changes for 6.3. 2023-01-27 15:08:08 +01:00
Rafael J. Wysocki
02be605946 - Fix kerneldoc format errors for Rockchip, Mediatek and Uniphier
(Randy Dunlap)
 
 - Add the missing 'qcom,adc-tm7' compatible string in the dt-bindings
   (Krzysztof Kozlowski)
 
 - Improve the calibration routine by relying on the nvmem to read the
   values and provide a set of fixes for the QCom tsens driver (Dmitry
   Baryshkov)
 
 - Remove the duplicate interrupt setting routine in the QCom tsens
   driver (Daniel Lezcano)
 
 - Fix a wrong loop condition in the i.MX SC thermal driver and add the
   iMX8QM sensors (Viorel Suman)
 
 - Fix header inclusion asm-generic.h by asm.h for the
   qcom-spmi-adc-tm5 driver (Andy Shevchenko)
 
 - Use the devm_platform_get_and_ioremap_resource() combo function in
   all the drivers where the conversion applies (Ye Xingchen)
 
 - Replace a literal mask by an existing corresponding macro (Yangtao
   Li)
 
 - Add support for MT7986 and MT7981 (Daniel Golle)
 
 - Use thermal_zone_get_crit_temp() for the Armada thermal driver
   (Daniel Lezcano)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAmPSo/wACgkQqDIjiipP
 6E8jPAf/dSGd92V/BEbPDNL3OvhW7duX1g05HLwnjSLo4r2W/I+YFsmLkaJ81iPj
 E/gC29jHw6TAQN9DrEMRnjmHGH8SBPrphfZMM7Sbh3pgzTPGW5tXQln8ysbh+JUr
 0Aj4O6sA5mvcjd7r7u5JITGUHzZCm3L4Gv9bzr6O8M425u3di1PlI8XMsdaKBy5q
 N4zYR8yFCgbgM3ujjy/J4fYWRRTcYQ9kExa/OxvMDtZS4shBK34VN9IVt3z/W+Vs
 zNxKRynUZcVYddEZwYcBV+aTVAyFGLr5s5y6dzPo33h4M+Rl6reNE86el28fglu0
 diZK79mef3KtV8Dn6lw9r+Fd/6heHw==
 =ZJEq
 -----END PGP SIGNATURE-----

Merge tag 'thermal-v6.3-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux into thermal-next

Pull thermal control material for 6.3-rc1 from Daniel Lezcano:

"- Fix kerneldoc format errors for Rockchip, Mediatek and Uniphier
   (Randy Dunlap)

 - Add the missing 'qcom,adc-tm7' compatible string in the dt-bindings
   (Krzysztof Kozlowski)

 - Improve the calibration routine by relying on the nvmem to read the
   values and provide a set of fixes for the QCom tsens driver (Dmitry
   Baryshkov)

 - Remove the duplicate interrupt setting routine in the QCom tsens
   driver (Daniel Lezcano)

 - Fix a wrong loop condition in the i.MX SC thermal driver and add the
   iMX8QM sensors (Viorel Suman)

 - Fix header inclusion asm-generic.h by asm.h for the
   qcom-spmi-adc-tm5 driver (Andy Shevchenko)

 - Use the devm_platform_get_and_ioremap_resource() combo function in
   all the drivers where the conversion applies (Ye Xingchen)

 - Replace a literal mask by an existing corresponding macro (Yangtao
   Li)

 - Add support for MT7986 and MT7981 (Daniel Golle)

 - Use thermal_zone_get_crit_temp() for the Armada thermal driver
   (Daniel Lezcano)"

* tag 'thermal-v6.3-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (35 commits)
  thermal/drivers/armada: Use the thermal_zone_get_crit_temp()
  thermal/drivers/mtk: Add support for MT7986 and MT7981
  thermal/drivers/mtk: Use function pointer for raw_to_mcelsius
  thermal/drivers/sun8i: Convert to use macro
  thermal/drivers/spear: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/kirkwood: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/thermal_mmio: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/rockchip: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/mtk_thermal: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/armada: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/dove: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/bcm2835: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/brcmstb_thermal: Use devm_platform_get_and_ioremap_resource()
  thermal/drivers/qcom-spmi-adc-tm5: Use asm intead of asm-generic
  thermal/drivers/imx_sc_thermal: Add iMX8QM sensors
  thermal/drivers/imx_sc_thermal: Fix the loop condition
  thermal/drivers/qcom: Remove duplicate set next trip point interrupt code
  thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956
  thermal/drivers/tsens: Drop single-cell code for msm8939
  thermal/drivers/tsens: Drop single-cell code for mdm9607
  ...
2023-01-26 17:21:24 +01:00
Daniel Lezcano
e90eb1df70 thermal: intel: processor_thermal_device_pci: Use generic trip point
Make proc_thermal_pci_probe() register the TCPU_PCI thermal zone along
with the trip point used by it and drop the zone callbacks related to
this trip point that are not needed any more.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-26 16:17:28 +01:00
Srinivas Pandruvada
5c36cf2784 thermal: intel: int340x: Add production mode attribute
It is possible that the system manufacturer locks down thermal tuning
beyond what is usually done on the given platform. In that case user
space calibration tools should not try to adjust the thermal
configuration of the system.

To allow user space to check if that is the case, add a new sysfs
attribute "production_mode" that will be present when the ACPI DCFG
method is present under the INT3400 device object in the ACPI Namespace.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-26 14:47:16 +01:00
Rafael J. Wysocki
9e0a9be24b thermal: Fail object registration if thermal class is not registered
If thermal_class is not registered with the driver core, there is no way
to expose the interfaces used by the thermal control framework, so
prevent thermal zones and cooling devices from being registered in
that case by returning an error from object registration functions.

For this purpose, use a thermal_class pointer that will be NULL if the
class is not registered.  To avoid wasting memory in that case, allocate
the thermal class object dynamically and if it fails to register, free
it and clear the thermal_class pointer to NULL.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-25 16:51:19 +01:00
Daniel Lezcano
5b8de18ee9 thermal/core: Move the thermal trip code to a dedicated file
The thermal_core.c files contains a lot of functions handling
different thermal components like the governors, the trip points, the
cooling device, the OF cooling device, etc ...

This organization does not help to migrate to a more sane code where
there is a better self-encapsulation as all the components' internals
can be directly accessed from a single file.

For the sake of clarity, let's move the thermal trip points code in a
dedicated thermal_trip.c file and add a function to browse all the
trip points like we do with the thermal zones, the govenors and the
cooling devices.

The same can be done for the cooling devices and the governor code but
that will come later as the current work in the thermal framework is
to fix the trip point handling and use a generic trip point structure.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-25 16:40:39 +01:00
Daniel Lezcano
b57d62862d thermal/core: Remove unneeded ida_destroy()
As per documentation for the ida_destroy() function: "If the IDA is
already empty, there is no need to call this function."

The thermal framework is in the init sequence, so the ida was not yet
used and consequently it is empty in case of error.

There is no need to call ida_destroy(), let's remove the calls.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-25 16:40:39 +01:00
Daniel Lezcano
58d1c9fd0e thermal/core: Fix unregistering netlink at thermal init time
The thermal subsystem initialization miss an netlink unregistering
function in the error. Add it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-25 16:40:39 +01:00
Rafael J. Wysocki
acd7e9ee57 thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type()
In order to prevent int340x_thermal_get_trip_type() from possibly
racing with int340x_thermal_read_trips() invoked by int3403_notify()
add locking to it in analogy with int340x_thermal_get_trip_temp().

Fixes: 6757a7abe4 ("thermal: intel: int340x: Protect trip temperature from concurrent updates")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-25 15:37:21 +01:00
Srinivas Pandruvada
6757a7abe4 thermal: intel: int340x: Protect trip temperature from concurrent updates
Trip temperatures are read using ACPI methods and stored in the memory
during zone initializtion and when the firmware sends a notification for
change. This trip temperature is returned when the thermal core calls via
callback get_trip_temp().

But it is possible that while updating the memory copy of the trips when
the firmware sends a notification for change, thermal core is reading the
trip temperature via the callback get_trip_temp(). This may return invalid
trip temperature.

To address this add a mutex to protect the invalid temperature reads in
the callback get_trip_temp() and int340x_thermal_read_trips().

Fixes: 5fbf7f27fa ("Thermal/int340x: Add common thermal zone handler")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 5.0+ <stable@vger.kernel.org> # 5.0+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-24 21:28:19 +01:00
Daniel Lezcano
fee19c6921 thermal: intel: intel_pch: Use generic trip points
The thermal framework gives the possibility to register the trip
points along with the thermal zone.  When that is done, no get_trip_*
callbacks are needed and they can be removed.

Convert the existing callbacks content logic into generic trip points
initialization code and register them along with the thermal zone.

In order to consolidate the code, use an ACPI trip library function
to populate a generic trip point.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
[ rjw: Subject and changelog edits, rebase ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2023-01-24 21:13:42 +01:00
Rafael J. Wysocki
7a0e397488 thermal: ACPI: Add ACPI trip point routines
Add library routines to populate a generic thermal trip point
structure with data obtained by evaluating a specific object in the
ACPI Namespace.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Co-developed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2023-01-24 21:13:42 +01:00
Tim Zimmermann
40dc192908 thermal: intel: intel_pch: Add support for Wellsburg PCH
Add the PCI ID for the Wellsburg C610 series chipset PCH.

The driver can read the temperature from the Wellsburg PCH with only
the PCI ID added and no other modifications.

Signed-off-by: Tim Zimmermann <tim@linux4.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-24 21:13:25 +01:00
Rafael J. Wysocki
8ef0ca4a17 Merge back other thermal control material for 6.3.
* thermal: (734 commits)
  thermal: core: call put_device() only after device_register() fails
  Linux 6.2-rc4
  kbuild: Fix CFI hash randomization with KASAN
  firmware: coreboot: Check size of table entry and use flex-array
  kallsyms: Fix scheduling with interrupts disabled in self-test
  ata: pata_cs5535: Don't build on UML
  lockref: stop doing cpu_relax in the cmpxchg loop
  x86/pci: Treat EfiMemoryMappedIO as reservation of ECAM space
  efi: tpm: Avoid READ_ONCE() for accessing the event log
  io_uring: lock overflowing for IOPOLL
  ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF
  iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe()
  iommu/iova: Fix alloc iova overflows issue
  iommu: Fix refcount leak in iommu_device_claim_dma_owner
  iommu/arm-smmu-v3: Don't unregister on shutdown
  iommu/arm-smmu: Don't unregister on shutdown
  iommu/arm-smmu: Report IOMMU_CAP_CACHE_COHERENCY even betterer
  platform/x86: thinkpad_acpi: Fix profile mode display in AMT mode
  ALSA: usb-audio: Fix possible NULL pointer dereference in snd_usb_pcm_has_fixed_rate()
  platform/x86: int3472/discrete: Ensure the clk/power enable pins are in output mode
  ...
2023-01-24 21:12:49 +01:00
Viresh Kumar
47e3f00074 thermal: core: Use device_unregister() instead of device_del/put()
Lets not open code device_unregister() unnecessarily.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-24 20:22:55 +01:00
Viresh Kumar
e398421fd0 thermal: core: Move cdev cleanup to thermal_release()
thermal_release() already frees cdev, let it do rest of the cleanup as
well in order to simplify the error paths in
__thermal_cooling_device_register().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-24 20:21:49 +01:00
Daniel Lezcano
8c5ee9155f thermal/drivers/armada: Use the thermal_zone_get_crit_temp()
The driver browses the trip point to find out the critical trip
temperature. However the function thermal_zone_get_crit_temp() does
already that, so the routine is pointless in the driver.

Use thermal_zone_get_crit_temp() instead of inspecting all the trip
points.

In addition, the hysteresis value is set to zero. A critical trip
point does not have a hysteresis.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20230118222610.186088-1-daniel.lezcano@linaro.org
2023-01-24 12:37:56 +01:00
Daniel Golle
248da1fc84 thermal/drivers/mtk: Add support for MT7986 and MT7981
Add support for V3 generation thermal found in MT7986 and MT7981 SoCs.
Brings code to assign values from efuse as well as new function to
convert raw temperature to millidegree celsius, as found in MediaTek's
SDK sources (but cleaned up and de-duplicated)

[1]: baf36c7eef

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/2d341fc45266217249586eb4bd3be3ac4ca83a12.1674055882.git.daniel@makrotopia.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-24 11:44:01 +01:00
Daniel Golle
4f2ee0aa2e thermal/drivers/mtk: Use function pointer for raw_to_mcelsius
Instead of having if-else logic selecting either raw_to_mcelsius_v1 or
raw_to_mcelsius_v2 in mtk_thermal_bank_temperature introduce a function
pointer raw_to_mcelsius to struct mtk_thermal which is initialized in the
probe function.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/69c17529e8418da3eec703dde31e1b01e5b0f7e8.1674055882.git.daniel@makrotopia.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-24 11:43:22 +01:00
Yangtao Li
d69e7041a3 thermal/drivers/sun8i: Convert to use macro
Use TEMP_CALIB_MASK macro instead of raw number.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230123102319.37710-1-frank.li@vivo.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-24 11:43:22 +01:00
Rafael J. Wysocki
a2c81dc59d Merge back thermal control material for 6.3. 2023-01-23 18:52:53 +01:00
ye xingchen
763bd29fd3 thermal: int340x_thermal: Use sysfs_emit_at() instead of scnprintf()
Follow the advice of the Documentation/filesystems/sysfs.rst that show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
[ rjw: Subject rewrite ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-20 17:59:35 +01:00
Viresh Kumar
6c54b7bc8a thermal: core: call put_device() only after device_register() fails
put_device() shouldn't be called before a prior call to
device_register(). __thermal_cooling_device_register() doesn't follow
that properly and needs fixing. Also
thermal_cooling_device_destroy_sysfs() is getting called unnecessarily
on few error paths.

Fix all this by placing the calls at the right place.

Based on initial work done by Caleb Connolly.

Fixes: 4748f9687c ("thermal: core: fix some possible name leaks in error paths")
Fixes: c408b3d1d9 ("thermal: Validate new state in cur_state_store()")
Reported-by: Caleb Connolly <caleb.connolly@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Frank Rowand <frowand.list@gmail.com>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
Tested-by: Caleb Connolly <caleb.connolly@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-19 21:06:41 +01:00
ye xingchen
f8887fdcf2 thermal/drivers/spear: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181644433003839@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:23:25 +01:00
ye xingchen
821e430979 thermal/drivers/kirkwood: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181642412733780@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:22:50 +01:00
ye xingchen
c818c6d15d thermal/drivers/thermal_mmio: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181641194943741@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:22:19 +01:00
ye xingchen
2484b632ac thermal/drivers/rockchip: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181639300333679@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:21:59 +01:00
ye xingchen
f7f6d37132 thermal/drivers/mtk_thermal: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181637472073620@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:21:35 +01:00
ye xingchen
9b22743b93 thermal/drivers/armada: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181634379503534@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:20:47 +01:00
ye xingchen
b5d6ec4d3a thermal/drivers/dove: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202301181633059433484@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:18:47 +01:00
ye xingchen
142887ec97 thermal/drivers/bcm2835: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/202301181636223863583@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:14:11 +01:00
ye xingchen
780e220dc6 thermal/drivers/brcmstb_thermal: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/202301181631362083446@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 22:12:56 +01:00
Deming Wang
a30e65792c thermal: intel: menlow: Update function descriptions
Update function parameter descriptions for sensor_get_auxtrip() and
sensor_set_auxtrip().

[ rjw: New changelog, subject edits ]
Signed-off-by: Deming Wang <wangdeming@inspur.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-18 21:02:36 +01:00
Andy Shevchenko
5618f1bee2 thermal/drivers/qcom-spmi-adc-tm5: Use asm intead of asm-generic
There is no point to specify asm-generic for the unaligned.h.
Drop the 'generic' suffix.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230103145339.40501-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-18 09:17:28 +01:00
Viorel Suman
1cea99593c thermal/drivers/imx_sc_thermal: Add iMX8QM sensors
Add iMX8QM sensors. As stated in 31fd4b9db1 ("thermal/drivers/imx_sc:
Rely on the platform data to get the resource id"):

    The thermal OF code returns -ENODEV if the thermal zone registration
    with a specific id fails because the description is not available in
    the DT for such a sensor id. In this case we continue with the other
    ids without bailing out with an error.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Link: https://lore.kernel.org/r/20230117091956.61729-2-viorel.suman@oss.nxp.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-17 10:28:13 +01:00
Viorel Suman
4b26b7c9cd thermal/drivers/imx_sc_thermal: Fix the loop condition
The minimal resource ID is 0: IMX_SC_R_AP_0=0, so fix
the loop condition. Aside of this - constify the array.

Fixes: 31fd4b9db1 ("thermal/drivers/imx_sc: Rely on the platform data to get the resource id")
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Dong Aisheng <Aisheng.dong@nxp.com>
Link: https://lore.kernel.org/r/20230117091956.61729-1-viorel.suman@oss.nxp.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-17 10:28:07 +01:00
Daniel Lezcano
df715f26cb thermal/drivers/qcom: Remove duplicate set next trip point interrupt code
The tsens driver reprogram the next trip points in the irq
handler. This function then call thermal_zone_device_update().

However, thermal_zone_device_update() calls thermal_zone_set_trips()
and from there it calls the backend 'set_trips' ops. This one in turn
reprogram the next trip points (low/high).

Consequently, the code setting the next trip points interrupt in the
interrupt handle is not needed and could be removed.

Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Acked-by: Amit Kucheria <amitk@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230116101955.3961427-1-daniel.lezcano@linaro.org
2023-01-16 13:05:24 +01:00
Dmitry Baryshkov
3a908971f7 thermal/drivers/tsens: Drop single-cell code for msm8976/msm8956
There is no dtsi file for msm8976 in the kernel sources. Drop the
compatibility with unofficial dtsi and remove support for handling the
single-cell calibration data on msm8976.

Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230101194034.831222-15-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
dfadb4599a thermal/drivers/tsens: Drop single-cell code for msm8939
There is no dtsi file for msm8939 in the kernel sources. Drop the
compatibility with unofficial dtsi and remove support for handling the
single-cell calibration data on msm8939.

Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-14-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
51d78b8b1b thermal/drivers/tsens: Drop single-cell code for mdm9607
There is no dtsi file for mdm9607 in the kernel sources. Drop the
compatibility with unofficial dtsi and remove support for handling the
single-cell calibration data on mdm9607.

Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-13-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
913d32e278 thermal/drivers/tsens: Rework legacy calibration data parsers
Rework existing calibration parsing code to use simple data structure
describing data layout. This allows us to drop all the mask & shift
values, replacing them with data tables.

The code for msm8974 is not reworked, as it has separate calibration and
backup data.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-12-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
439f2409a2 thermal/drivers/tsens: Support using nvmem cells for msm8974 calibration
MSM8974 has two sets of calibration data: main one and backup. Add
support for parsing both sets of calibration data from nvmem cells.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-11-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
498d245749 thermal/drivers/tsens: Support using nvmem cells for calibration data
Add a unified function using nvmem cells for parsing the calibration
data rather than parsing the calibration blob manually.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-10-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
903238a33c thermal/drivers/tsens: limit num_sensors to 9 for msm8939
On msm8939 last (hwid=10) sensor was added in the hw revision 3.0.
Calibration data for it was placed outside of the main calibration data
blob, so it is not accessible by the current blob-parsing code.

Moreover data for the sensor's p2 is not contiguous in the fuses. This
makes it hard to use nvmem_cell API to parse calibration data in a
generic way.

Since the sensor doesn't seem to be actually used by the existing
hardware, disable the sensor for now.

Fixes: 332bc8ebab ("thermal: qcom: tsens-v0_1: Add support for MSM8939")
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-9-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
5aec3b035e thermal/drivers/tsens: fix slope values for msm8939
According to the vendor kernels (msm-3.10, 3.14 and 3.18), msm8939
uses non-standard slope values for calibrating the sensors. Fill them
accordingly.

Fixes: 332bc8ebab ("thermal: qcom: tsens-v0_1: Add support for MSM8939")
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-8-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
a7d3006be5 thermal/drivers/tsens: Sort out msm8976 vs msm8956 data
Tsens driver mentions that msm8976 data should be used for both msm8976
and msm8956 SoCs. This is not quite correct, as according to the
vendor kernels, msm8976 should use standard slope values (3200), while
msm8956 really uses the slope values found in the driver.

Add separate compatibility string for msm8956, move slope value
overrides to the corresponding init function and use the standard
compute_intercept_slope() function for both platforms.

Fixes: 0e58029017 ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-7-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
3bf0ea99e2 thermal/drivers/tsens: Drop msm8976-specific defines
Drop msm8976-specific defines, which duplicate generic ones.

Fixes: 0e58029017 ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-6-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Dmitry Baryshkov
ca7b70b19e thermal/drivers/tsens: Drop unnecessary hw_ids
The tsens driver defaults to using hw_id equal to the index of the
sensor. Thus it is superfluous to declare such hw_id arrays. Drop such
arrays from mdm9607 and msm8976 data.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230101194034.831222-5-dmitry.baryshkov@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:30 +01:00
Randy Dunlap
5bc494a8ce thermal/drivers/uniphier: Use regular comment syntax
Use "/*" comment for the file's initial comment since it is not
in kernel-doc format. This prevents a kernel-doc warning:

drivers/thermal/uniphier_thermal.c:26: warning: expecting prototype for uniphier_thermal.c(). Prototype was for PVTCTLEN() instead

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230113064507.17224-1-rdunlap@infradead.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:29 +01:00
Randy Dunlap
6d5dad7b98 thermal/drivers/rockchip: Fix kernel-doc warnings
Don't use "/**" to begin non-kernel-doc comments.
Convert one function description to kernel-doc format.
Prevents these kernel-doc warnings:

drivers/thermal/rockchip_thermal.c:64: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
 * The max sensors is two in rockchip SoCs.
drivers/thermal/rockchip_thermal.c:179: warning: expecting prototype for TSADC Sensor Register description(). Prototype was for TSADCV2_USER_CON() instead
drivers/thermal/rockchip_thermal.c:1342: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
 * Reset TSADC Controller, reset all tsadc registers.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Link: https://lore.kernel.org/r/20230113064500.16103-1-rdunlap@infradead.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:29 +01:00
Randy Dunlap
3291651c0a thermal/drivers/mtk_thermal: Fix kernel-doc function name
Use the correct function name in a kernel-doc comment to prevent
a warning:

drivers/thermal/mtk_thermal.c:562: warning: expecting prototype for raw_to_mcelsius(). Prototype was for raw_to_mcelsius_v1() instead

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Link: https://lore.kernel.org/r/20230113064449.15061-1-rdunlap@infradead.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-16 11:22:29 +01:00
Yang Li
e7fcfe67f9 thermal: intel: Fix unsigned comparison with less than zero
The return value from the call to intel_tcc_get_tjmax() is int, which can
be a negative error code. However, the return value is being assigned to
an u32 variable 'tj_max', so making 'tj_max' an int.

Eliminate the following warning:
./drivers/thermal/intel/intel_soc_dts_iosf.c:394:5-11: WARNING: Unsigned expression compared with zero: tj_max < 0

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3637
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-01-10 20:33:26 +01:00
Xu Panda
3a151494dc thermal/drivers/armada: Use strscpy() to instead of strncpy()
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
Link: https://lore.kernel.org/r/202212280945491860150@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2023-01-06 14:14:48 +01:00
Johan Hovold
59edcd91d8 thermal/drivers/qcom: Fix lock inversion
The thermal-zone-device lock is held by core when setting trip points
and the driver takes its chip lock in the corresponding callback.

Fetching the thermal trip points using thermal_zone_get_trip() also
involves taking the thermal-zone-device lock, which means that the chip
lock can not be held when doing so.

Drop the chip lock temporarily during probe to avoid the lock inversion
that was detected by lockdep:

  ======================================================
  WARNING: possible circular locking dependency detected
  6.1.0-next-20221213 #122 Not tainted
  ------------------------------------------------------
  systemd-udevd/264 is trying to acquire lock:
  ffff741e444a0920 (&chip->lock){+.+.}-{3:3}, at: qpnp_tm_get_temp+0xb4/0x1b0 [qcom_spmi_temp_alarm]

  but task is already holding lock:
  ffff741e44341618 (&tz->lock){+.+.}-{3:3}, at: thermal_zone_device_update+0x2c/0x70

  which lock already depends on the new lock.

Fixes: 78c3e2429be8 ("thermal/drivers/qcom: Use generic thermal_zone_get_trip() function")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20221214131617.2447-5-johan+linaro@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2023-01-06 14:14:48 +01:00
Johan Hovold
b0b5d063d6 thermal/drivers/tegra: Fix set_trip_temp() deadlock
The set_trip_temp() callback is used when changing the trip temperature
through sysfs. As it is called with the thermal-zone-device lock held
it must not use thermal_zone_get_trip() directly or it will deadlock.

Fixes: 56d7b397cc29 ("thermal/drivers/tegra: Use generic thermal_zone_get_trip() function")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20221214131617.2447-4-johan+linaro@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2023-01-06 14:14:48 +01:00
Johan Hovold
e6ec64f852 thermal/drivers/qcom: Fix set_trip_temp() deadlock
The set_trip_temp() callback is used when changing the trip temperature
through sysfs. As it is called with the thermal-zone-device lock held
it must not use thermal_zone_get_trip() directly or it will deadlock.

Fixes: 78c3e2429be8 ("thermal/drivers/qcom: Use generic thermal_zone_get_trip() function")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20221214131617.2447-2-johan+linaro@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2023-01-06 14:14:48 +01:00
Jon Hunter
5f28ecc1e9 thermal/drivers/tegra: Fix crash when getting critical temp
Commit 13bea86623be ("thermal/of: Remove of_thermal_get_crit_temp()")
removed the function of_thermal_get_crit_temp() and this is causing a
NULL pointer deference crash when attempting to call the 'get_crit_temp'
function pointer because this function pointer is no longer initialised.
Fix this by replacing the call to the 'get_crit_temp' function pointer
with a call to the function thermal_zone_get_crit_temp() instead.

Fixes: 13bea86623be ("thermal/of: Remove of_thermal_get_crit_temp()")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://lore.kernel.org/r/20221010150311.40384-1-jonathanh@nvidia.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-06 14:14:48 +01:00
Daniel Lezcano
a1c306375b thermal/drivers/exynos: Fix NULL pointer dereference when getting the critical temp
The driver is assuming the get_critical temperature exists as it is
inherited by the thermal of ops. But this one has been removed in
favor of the generic one.

Use the generic thermal_zone_get_crit_temp() function instead

Fixes: 13bea86623be ("thermal/of: Remove of_thermal_get_crit_temp(")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-01-06 14:14:48 +01:00
Daniel Lezcano
d3ecaf17b5 thermal/drivers/intel: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-30-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
0d2d586a86 thermal/intel/int340x: Replace parameter to simplify
In the process of replacing the get_trip_* ops by the generic trip
points, the current code has an 'override' property to add another
indirection to a different ops.

Rework this approach to prevent this indirection and make the code
ready for the generic trip points conversion.

Actually the get_temp() is different regarding the platform, so it is
pointless to add a new set of ops but just create dynamically the ops
at init time.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-29-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
69cf4eaa68 thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid()
The macros:

ti_thermal_get_trip_value()
 ti_thermal_trip_is_valid()

are unused. Remove them.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-26-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
060b39d934 thermal/drivers/da9062: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Adam Ward <DLG-Adam.Ward.opensource@dm.renesas.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-25-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
52945c1c65 thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-24-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
0b6a3e459e thermal/drivers/rcar: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20221003092602.1323944-23-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
30233a229f thermal/drivers/imx: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-22-daniel.lezcano@linaro.org
2023-01-06 14:14:48 +01:00
Daniel Lezcano
28fd2cd9b3 thermal/drivers/st: Use generic trip points
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert to the generic trip points

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-21-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
aacfbf15e0 thermal/of: Remove of_thermal_get_crit_temp()
The generic version of of_thermal_get_crit_temp() can be used. Let's
remove this ops which is pointless.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-20-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
810245133e thermal/of: Remove of_thermal_set_trip_hyst()
The thermal core is providing the generic thermal_zone_set_trip()
function which does exactly what the OF ops function is doing.

It is pointless to define our own version, just remove the ops and the
thermal_zone_set_trip() will take care of it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-19-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
f9061f4e15 thermal/of: Remove of_thermal_is_trip_valid()
There is no benefit with the of_thermal_is_trip_valid() function as it
does the check the thermal_zone_get_trip() is already doing for the
sake of getting the trip point.

As all the calls have been replaced by thermal_zone_get_trip(), there
is no more users of of_thermal_is_trip_valid().

Remove the function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-18-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
2480b02a36 thermal/of: Remove of_thermal_get_ntrips()
The thermal OF code uses the generic trip points to initialize the
thermal zone. Consequently thermal_zone_get_num_trips() can be used
and the of_thermal_get_ntrips() is no longer needed. Remove it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-17-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
d5299c1b82 thermal/drivers/rcar_gen3: Use the generic function to get the number of trips
The thermal core framework allows to get the number of thermal trips,
use it instead of visiting the thermal core structure internals.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20221003092602.1323944-16-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
eb2bb3be13 thermal/drivers/armada: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-15-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
1fa86b0a36 thermal/drivers/qcom: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Amit Kucheria <amitk@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-14-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
68a306cc83 thermal/drivers/hisi: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-13-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
c7ed8cab40 thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-12-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
735a968d2f thermal/drivers/tegra: Use generic thermal_zone_get_trip() function
Replace a single call to thermal_zone_get_trip() to get a trip point
instead of calling the different ops->get_trip*

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-11-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
03ef4855a8 thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip()
The thermal_zone_get_trip() does the same check as
of_thermal_is_trip_valid(). Replace the call to
of_thermal_is_trip_valid() by thermal_zone_get_trip().

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-10-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
a3b3dd381a thermal/drivers/exynos: of_thermal_get_ntrips()
The thermal core framework allows to get the number of thermal trips,
use it instead of visiting the thermal core structure internals.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-9-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
ca38255e92 thermal/drivers/exynos: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-8-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
5c4855d765 thermal/of: Remove unused functions
Remove the dead code: of_thermal_get_trip_points()

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-7-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
453a55a97b thermal/of: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

The thermal OF code uses the thermal_zone_device_register_with_trips()
function. It builds the trips array and pass it to the register
function. That means the get_trip_* ops are duplicated with what does
already the core code.

Remove them.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-6-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
7f725a23f2 thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions
The governors are using the ops->get_trip_* functions, Replace these
calls with thermal_zone_get_trip().

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> # IPA
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-5-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
2e38a2a981 thermal/core: Add a generic thermal_zone_set_trip() function
The thermal zone ops defines a set_trip callback where we can invoke
the backend driver to set an interrupt for the next trip point
temperature being crossed the way up or down, or setting the low level
with the hysteresis.

The ops is only called from the thermal sysfs code where the userspace
has the ability to modify a trip point characteristic.

With the effort of encapsulating the thermal framework core code,
let's create a thermal_zone_set_trip() which is the writable side of
the thermal_zone_get_trip() and put there all the ops encapsulation.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-4-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
0614755dbf thermal/sysfs: Always expose hysteresis attributes
Instead of avoiding to expose the hysteresis attributes of a thermal
zone when its get_trip_hyst() operation is not defined, which is
confusing, expose them always and use the default
thermal_zone_get_trip() function returning 0 hysteresis when that
operation is not present.

The hysteresis of 0 is perfectly valid, so this change should not
introduce any backwards compatibility issues.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-3-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Daniel Lezcano
7c3d5c20dc thermal/core: Add a generic thermal_zone_get_trip() function
The thermal_zone_device_ops structure defines a set of ops family,
get_trip_temp(), get_trip_hyst(), get_trip_type(). Each of them is
returning a property of a trip point.

The result is the code is calling the ops everywhere to get a trip
point which is supposed to be defined in the backend driver. It is a
non-sense as a thermal trip can be generic and used by the backend
driver to declare its trip points.

Part of the thermal framework has been changed and all the OF thermal
drivers are using the same definition for the trip point and use a
thermal zone registration variant to pass those trip points which are
part of the thermal zone device structure.

Consequently, we can use a generic function to get the trip points
when they are stored in the thermal zone device structure.

This approach can be generalized to all the drivers and we can get rid
of the ops->get_trip_*. That will result to a much more simpler code
and make possible to rework how the thermal trip are handled in the
thermal core framework as discussed previously.

This change adds a function thermal_zone_get_trip() where we get the
thermal trip point structure which contains all the properties (type,
temp, hyst) instead of doing multiple calls to ops->get_trip_*.

That opens the door for trip point extension with more attributes. For
instance, replacing the trip points disabled bitmask with a 'disabled'
field in the structure.

Here we replace all the calls to ops->get_trip_* in the thermal core
code with a call to the thermal_zone_get_trip() function.

The thermal zone ops defines a callback to retrieve the critical
temperature. As the trip handling is being reworked, all the trip
points will be the same whatever the driver and consequently finding
the critical trip temperature will be just a loop to search for a
critical trip point type.

Provide such a generic function, so we encapsulate the ops
get_crit_temp() which can be removed when all the backend drivers are
using the generic trip points handling.

While at it, add the thermal_zone_get_num_trips() to encapsulate the
code more and reduce the grip with the thermal framework internals.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Link: https://lore.kernel.org/r/20221003092602.1323944-2-daniel.lezcano@linaro.org
2023-01-06 14:14:47 +01:00
Zhang Rui
58374a3970 thermal/x86_pkg_temp_thermal: Add support for handling dynamic tjmax
Tjmax value retrieved from MSR_IA32_TEMPERATURE_TARGET can be changed at
runtime when the Intel SST-PP (Intel Speed Select Technology -
Performance Profile) level is changed.

Enhance the code to use updated tjmax when programming the thermal
interrupt thresholds.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:57:38 +01:00
Zhang Rui
983eb370cb thermal/x86_pkg_temp_thermal: Use Intel TCC library
Cleanup the code by using Intel TCC library for TCC (Thermal Control
Circuitry) MSR access.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:57:38 +01:00
Zhang Rui
4e3ecc2898 thermal/intel/intel_tcc_cooling: Use Intel TCC library
Cleanup the code by using Intel TCC library for TCC (Thermal Control
Circuitry) MSR access.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:57:38 +01:00
Zhang Rui
955fb8719e thermal/intel/intel_soc_dts_iosf: Use Intel TCC library
Cleanup the code by using Intel TCC library for TCC (Thermal Control
Circuitry) MSR access.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:57:38 +01:00
Zhang Rui
d91a4714e5 thermal/int340x/processor_thermal: Use Intel TCC library
Cleanup the code by using Intel TCC library for TCC (Thermal Control
Circuitry) MSR access.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:57:38 +01:00
Zhang Rui
a3c1f066e1 thermal/intel: Introduce Intel TCC library
There are several different drivers that accesses the Intel TCC
(thermal control circuitry) MSRs, and each of them has its own
implementation for the same functionalities, e.g. getting the current
temperature, getting the tj_max, and getting/setting the tj_max offset.

Introduce a library to unify the code for Intel CPU TCC MSR access.

At the same time, ensure the temperature is got based on the updated
tjmax value because tjmax can be changed at runtime for cases like
the Intel SST-PP (Intel Speed Select Technology - Performance Profile)
level change.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:57:38 +01:00
Srinivas Pandruvada
b878d3ba9b thermal: int340x: Add missing attribute for data rate base
Commit 473be51142 ("thermal: int340x: processor_thermal: Add RFIM
driver")' added rfi_restriction_data_rate_base string, mmio details and
documentation, but missed adding attribute to sysfs.

Add missing sysfs attribute.

Fixes: 473be51142 ("thermal: int340x: processor_thermal: Add RFIM driver")
Cc: 5.11+ <stable@vger.kernel.org> # v5.11+
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-30 19:48:37 +01:00
Linus Torvalds
601c1aa855 More thermal control updates for 6.2-rc1
- Avoid clearing the HFI status bit on systems without HFI support
    which triggers unchecked MSR access errors (Srinivas Pandruvada).
 
  - Add sm8450 and sm8550 QCom compatible string to DT bindings (Luca
    Weiss, Neil Armstrong).
 
  - Use devm_platform_get_and_ioremap_resource on the ST platform to
    group two calls into a single one (Minghao Chi).
 
  - Use GENMASK instead of bitmaps and validate the temperature after
    reading it in the imx8mm_thermal driver (Marcus Folkesson).
 
  - Convert generic-adc-thermal to DT schema (Rob Herring).
 
  - Fix debug print message with inverted logic in the k3_j72xx_bandgap
    driver (Keerthy).
 
  - Fix memory leak on thermal_of_zone_register() failure (Ido Schimmel).
 
  - Add support for IPQ8074 in the tsens thermal driver along with the DT
    bindings (Robert Marko).
 
  - Fix and rework the debugfs code in the tsens driver (Christian
    Marangi).
 
  - Add calibration and DT documentation for the imx8mm driver (Marek
    Vasut).
 
  - Add DT bindings and compatible for the Mediatek SoCs mt7981 and
    mt7983 (Daniel Golle).
 
  - Don't show an error message if it happens at probe time while it
    will be deferred on the QCom SPMI ADC driver (Johan Hovold).
 
  - Add HWMon support for the imx8mm board (Alexander Stein).
 
  - Remove pointless include from the power allocator governor (Christophe
    JAILLET).
 
  - Add interrupt DT bindings for QCom SoCs SC8280XP, SM6350 and SM8450
    (Krzysztof Kozlowski).
 
  - Fix inaccurate warning message for the QCom tsens gen2 (Luca Weiss).
 
  - Demote error log of thermal zone register to debug in the tsens QCom
    driver (Manivannan Sadhasivam).
 
  - Consolidate the the efuse values and the errata handling in the TI
    Bandgap driver (Bryan Brattlof).
 
  - Document Renesas RZ/Five as compatible with RZ/G2UL in the DT
    bindings (Lad Prabhakar).
 
  - Fix the irq handler return value in the LMh driver (Bjorn Andersson).
 
  - Delete empty platform remove callback from imx_sc_thermal (Uwe
    Kleine-König).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmObX2sSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRx7u0P/0NtwAxUICNqL1+QCdPupjbeF5c/tNFp
 c3FJGxO3QEfs+/UQ7GDaVGQqlPpao+E9jv3f2ii2+datznhOHday00o8MQ/B1pwG
 j1bAfyqmaJtruX0Q5uFGed1G6HBfcTn50iMweOOsXAm4opPtT0vgOG/Vm/TcZPbt
 4Sxo4aybZ2ZQuknbX8o9oWiUoOi43+OS3HHalC+VbBXXO+9Gp1RIcvmGPQEZtwy+
 tPq7+B0ofuCkLpVjDfWwwDQ4VsD5pSwPM5z+FcO0zu0dHpl8TROs432Y7RvvvIdk
 yhBnP7iTczvikPvlWK+6S2qHc+WD2kv5xsngF6RDDB0N8lTDTwhLJpTdYHnC/Zin
 Ho8+Lzifmj6V5ZeUe3xphQZAPqn9DAr8T9pFAOSEyXthsAqHPYBvnWuvAJg4G8uE
 8LnqwNV0xe1LEs0whVVqlXgG2QD1z42T9Wxv5y6QWCypiEudiSFRjSkvXeZMYU3K
 sn4KCYUYya2b+/ENN5xQca/eKqAo+EKXtDGMKTMQIShI8K7CdLpjpCAIFrdYptCi
 zescOMjO/trfA4RhPBFMcL03g1YARFHBCJ+HkRSlHu2vO+M0zu3HlkCNyvsVHGNZ
 2nv5+m7jLFE+N9sidxUrKVoMgsJU4qtPp/IRYS2shlzcMs6Jdxe2NEIaWK2hDC+w
 YUuIh8LhWWCq
 =MsHk
 -----END PGP SIGNATURE-----

Merge tag 'thermal-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more thermal control updates from Rafael Wysocki:
 "These are updates of assorted thermal drivers, mostly for ARM
  platforms, generally isolated and fairly straightforward, and the
  recent Intel HFI driver fix for systems without HFI support.

  Specifics:

   - Avoid clearing the HFI status bit on systems without HFI support
     which triggers unchecked MSR access errors (Srinivas Pandruvada)

   - Add sm8450 and sm8550 QCom compatible string to DT bindings (Luca
     Weiss, Neil Armstrong)

   - Use devm_platform_get_and_ioremap_resource on the ST platform to
     group two calls into a single one (Minghao Chi)

   - Use GENMASK instead of bitmaps and validate the temperature after
     reading it in the imx8mm_thermal driver (Marcus Folkesson)

   - Convert generic-adc-thermal to DT schema (Rob Herring)

   - Fix debug print message with inverted logic in the k3_j72xx_bandgap
     driver (Keerthy)

   - Fix memory leak on thermal_of_zone_register() failure (Ido
     Schimmel)

   - Add support for IPQ8074 in the tsens thermal driver along with the
     DT bindings (Robert Marko)

   - Fix and rework the debugfs code in the tsens driver (Christian
     Marangi)

   - Add calibration and DT documentation for the imx8mm driver (Marek
     Vasut)

   - Add DT bindings and compatible for the Mediatek SoCs mt7981 and
     mt7983 (Daniel Golle)

   - Don't show an error message if it happens at probe time while it
     will be deferred on the QCom SPMI ADC driver (Johan Hovold)

   - Add HWMon support for the imx8mm board (Alexander Stein)

   - Remove pointless include from the power allocator governor
     (Christophe JAILLET)

   - Add interrupt DT bindings for QCom SoCs SC8280XP, SM6350 and SM8450
     (Krzysztof Kozlowski)

   - Fix inaccurate warning message for the QCom tsens gen2 (Luca Weiss)

   - Demote error log of thermal zone register to debug in the tsens
     QCom driver (Manivannan Sadhasivam)

   - Consolidate the the efuse values and the errata handling in the TI
     Bandgap driver (Bryan Brattlof)

   - Document Renesas RZ/Five as compatible with RZ/G2UL in the DT
     bindings (Lad Prabhakar)

   - Fix the irq handler return value in the LMh driver (Bjorn
     Andersson)

   - Delete empty platform remove callback from imx_sc_thermal (Uwe
     Kleine-König)"

* tag 'thermal-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (35 commits)
  thermal/drivers/imx_sc_thermal: Drop empty platform remove function
  thermal/drivers/qcom/lmh: Fix irq handler return value
  dt-bindings: thermal: qcom-tsens: Add compatible for sm8550
  thermal/drivers/st: Use devm_platform_get_and_ioremap_resource()
  dt-bindings: thermal: rzg2l-thermal: Document RZ/Five SoC
  dt-bindings: thermal: k3-j72xx: conditionally require efuse reg range
  dt-bindings: thermal: k3-j72xx: elaborate on binding description
  thermal/drivers/k3_j72xx_bandgap: Map fuse_base only for erratum workaround
  thermal/drivers/k3_j72xx_bandgap: Remove fuse_base from structure
  thermal/drivers/k3_j72xx_bandgap: Use bool for i2128 erratum flag
  thermal/drivers/k3_j72xx_bandgap: Simplify k3_thermal_get_temp() function
  thermal/drivers/qcom: Demote error log of thermal zone register to debug
  thermal/drivers/qcom/temp-alarm: Fix inaccurate warning for gen2
  dt-bindings: thermal: qcom-tsens: narrow interrupts for SC8280XP, SM6350 and SM8450
  thermal/core/power allocator: Remove a useless include
  thermal/drivers/imx8mm: Add hwmon support
  thermal: qcom-spmi-adc-tm5: suppress probe-deferral error message
  dt-bindings: thermal: mediatek: add compatible string for MT7986 and MT7981 SoC
  thermal: ti-soc-thermal: Drop comma after SoC match table sentinel
  thermal/drivers/imx: Add support for loading calibration data from OCOTP
  ...
2022-12-15 10:16:04 -08:00
Rafael J. Wysocki
bd7bcc4f96 - Add the sm8450 QCom compatible string in the DT bindings (Luca
Weiss)
 
 - Use devm_platform_get_and_ioremap_resource on the ST platform to
   group two calls into a single one (Minghao Chi)
 
 - Add the sm8550 QCom compatible string in the DT bindings (Neil
   Armstrong)
 
 - Use GENMASK instead of bitmaps and validate the temperature after
   reading it (Marcus Folkesson)
 
 - Convert generic-adc-thermal to DT schema (Rob Herring)
 
 - Fix the debug print message where the logic is inverted (Keerthy)
 
 - Fix memory leak on thermal_of_zone_register() failure (Ido Schimmel)
 
 - Add support for IPQ8074 in the tsens driver along with the DT
   bindings (Robert Marko)
 
 - Fix and rework the debugfs code in the tsens driver (Christian
   Marangi)
 
 - Add calibration and DT documentation for the imx8mm driver (Marek
   Vasut)
 
 - Add DT bindings and compatible for the Mediatek SoCs mt7981 and
   mt7983 (Daniel Golle)
 
 - Don't show an error message if it happens at probe time while it
   will be deferred on the QCom SPMI ADC driver (Johan Hovold)
 
 - Add the HWMon support on the imx8mm board (Alexander Stein)
 
 - Remove a pointless include in the power allocator governor
   (Christophe JAILLET)
 
 - Add interrupt DT bindings for QCom SoCs SC8280XP, SM6350 and SM8450
   (Krzysztof Kozlowski)
 
 - Fix inaccurate warning message for the QCom tsens gen2 (Luca Weiss)
 
 - Demote error log of thermal zone register to debug on the tsens QCom
   driver (Manivannan Sadhasivam)
 
 - Consolidate the TI Bandgap driver regarding how is handled the efuse
   values and the errata handling (Bryan Brattlof)
 
 - Document the Renesas RZ/Five as compatible with RZ/G2UL in the DT
   bindings (Lad Prabhakar)
 
 - Fix the irq handler return value in the LMh driver (Bjorn Andersson)
 
 - Delete platform remove callback as it is empty (Uwe Kleine-König)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAmOZ4+sACgkQqDIjiipP
 6E/xWwgAoEK401wQQZSuq4wCAf7djcHRzWTKOpIq6bKtabSmJa/NFBfTQ0dXbuxy
 CaJqGcsvubyQnzdKvAEld4lbs2tnHw1hNo07exQvBqDueF2iNEdHWqupfIKE7dWH
 jMuKoCRWS5cPNkmSKIchLsN44lBHplocxERiuZp/DAZeVFNbJH0AqevmPw9IWJ1Q
 BgbtjNxygyKQvOtqjl4RcAq+/eqHxJR/sYtpFXJs+3bORK55PnjAe+uyb6BayYRd
 lGevOcas5YNMnLclu9H8s/VGVU5/ld5iA/tZKdipedOzX4AJ2wk5ev0FA4j1AVnj
 ozlRUec4SXxK9YCp3pBWAwuBWW6L/w==
 =H6vB
 -----END PGP SIGNATURE-----

Merge tag 'thermal-v6.2-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux

Pull thermal driver changes for 6.2-rc1 from Daniel Lezcano:

"- Add the sm8450 QCom compatible string in the DT bindings (Luca
   Weiss)

 - Use devm_platform_get_and_ioremap_resource on the ST platform to
   group two calls into a single one (Minghao Chi)

 - Add the sm8550 QCom compatible string in the DT bindings (Neil
   Armstrong)

 - Use GENMASK instead of bitmaps and validate the temperature after
   reading it (Marcus Folkesson)

 - Convert generic-adc-thermal to DT schema (Rob Herring)

 - Fix the debug print message where the logic is inverted (Keerthy)

 - Fix memory leak on thermal_of_zone_register() failure (Ido Schimmel)

 - Add support for IPQ8074 in the tsens driver along with the DT
   bindings (Robert Marko)

 - Fix and rework the debugfs code in the tsens driver (Christian
   Marangi)

 - Add calibration and DT documentation for the imx8mm driver (Marek
   Vasut)

 - Add DT bindings and compatible for the Mediatek SoCs mt7981 and
   mt7983 (Daniel Golle)

 - Don't show an error message if it happens at probe time while it
   will be deferred on the QCom SPMI ADC driver (Johan Hovold)

 - Add the HWMon support on the imx8mm board (Alexander Stein)

 - Remove a pointless include in the power allocator governor
   (Christophe JAILLET)

 - Add interrupt DT bindings for QCom SoCs SC8280XP, SM6350 and SM8450
   (Krzysztof Kozlowski)

 - Fix inaccurate warning message for the QCom tsens gen2 (Luca Weiss)

 - Demote error log of thermal zone register to debug on the tsens QCom
   driver (Manivannan Sadhasivam)

 - Consolidate the TI Bandgap driver regarding how is handled the efuse
   values and the errata handling (Bryan Brattlof)

 - Document the Renesas RZ/Five as compatible with RZ/G2UL in the DT
   bindings (Lad Prabhakar)

 - Fix the irq handler return value in the LMh driver (Bjorn Andersson)

 - Delete platform remove callback as it is empty (Uwe Kleine-König)"

* tag 'thermal-v6.2-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (34 commits)
  thermal/drivers/imx_sc_thermal: Drop empty platform remove function
  thermal/drivers/qcom/lmh: Fix irq handler return value
  dt-bindings: thermal: qcom-tsens: Add compatible for sm8550
  thermal/drivers/st: Use devm_platform_get_and_ioremap_resource()
  dt-bindings: thermal: rzg2l-thermal: Document RZ/Five SoC
  dt-bindings: thermal: k3-j72xx: conditionally require efuse reg range
  dt-bindings: thermal: k3-j72xx: elaborate on binding description
  thermal/drivers/k3_j72xx_bandgap: Map fuse_base only for erratum workaround
  thermal/drivers/k3_j72xx_bandgap: Remove fuse_base from structure
  thermal/drivers/k3_j72xx_bandgap: Use bool for i2128 erratum flag
  thermal/drivers/k3_j72xx_bandgap: Simplify k3_thermal_get_temp() function
  thermal/drivers/qcom: Demote error log of thermal zone register to debug
  thermal/drivers/qcom/temp-alarm: Fix inaccurate warning for gen2
  dt-bindings: thermal: qcom-tsens: narrow interrupts for SC8280XP, SM6350 and SM8450
  thermal/core/power allocator: Remove a useless include
  thermal/drivers/imx8mm: Add hwmon support
  thermal: qcom-spmi-adc-tm5: suppress probe-deferral error message
  dt-bindings: thermal: mediatek: add compatible string for MT7986 and MT7981 SoC
  thermal: ti-soc-thermal: Drop comma after SoC match table sentinel
  thermal/drivers/imx: Add support for loading calibration data from OCOTP
  ...
2022-12-14 17:05:45 +01:00
Uwe Kleine-König
5011a11029 thermal/drivers/imx_sc_thermal: Drop empty platform remove function
A remove callback just returning 0 is equivalent to no remove callback
at all. So drop the useless function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20221212220217.3777176-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:27:30 +01:00
Bjorn Andersson
46a891e45b thermal/drivers/qcom/lmh: Fix irq handler return value
After enough invocations the LMh irq is eventually reported as bad, because the
handler doesn't return IRQ_HANDLED, fix this.

Fixes: 53bca371cd ("thermal/drivers/qcom: Add support for LMh driver")
Reported-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220316180322.88132-1-bjorn.andersson@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:41 +01:00
Minghao Chi
33dc955c5a thermal/drivers/st: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202211171409524332954@zte.com.cn
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:41 +01:00
Bryan Brattlof
366444ebe7 thermal/drivers/k3_j72xx_bandgap: Map fuse_base only for erratum workaround
Some of TI's J721E SoCs require a software trimming procedure for the
temperature monitors to function properly. To determine if a particular
J721E is not affected by this erratum, both bits in the WKUP_SPARE_FUSE0
region must be set. Other SoCs, not affected by this erratum, will not
need this region.

Map the 'fuse_base' region only when the erratum fix is needed.

Signed-off-by: Bryan Brattlof <bb@ti.com>
Link: https://lore.kernel.org/r/20221031232702.10339-5-bb@ti.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:41 +01:00
Bryan Brattlof
156f0e2fda thermal/drivers/k3_j72xx_bandgap: Remove fuse_base from structure
'fuse_base' is only needed during the initial probe function to provide
data for a software trimming method for some of TI's devices affected by
the i2128 erratum. The devices not affected will not use this region

Remove fuse_base from the main k3_j72xx_bandgap structure

Signed-off-by: Bryan Brattlof <bb@ti.com>
Link: https://lore.kernel.org/r/20221031232702.10339-4-bb@ti.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Bryan Brattlof
311f328ffc thermal/drivers/k3_j72xx_bandgap: Use bool for i2128 erratum flag
Some of TI's J721E SoCs require a software trimming method to report
temperatures accurately. Currently we are using a few different data
types to indicate when we should apply the erratum.

Change the 'workaround_needed' variable's data type to a bool to align
with how we are using this variable currently.

Signed-off-by: Bryan Brattlof <bb@ti.com>
Link: https://lore.kernel.org/r/20221031232702.10339-3-bb@ti.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Bryan Brattlof
46cab93ab4 thermal/drivers/k3_j72xx_bandgap: Simplify k3_thermal_get_temp() function
The k3_thermal_get_temp() function can be simplified to return only
the result of k3_bgp_read_temp() without needing the 'ret' variable

Signed-off-by: Bryan Brattlof <bb@ti.com>
Link: https://lore.kernel.org/r/20221031232702.10339-2-bb@ti.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Manivannan Sadhasivam
2baad24963 thermal/drivers/qcom: Demote error log of thermal zone register to debug
devm_thermal_of_zone_register() can fail with -ENODEV if thermal zone for
the channel is not represented in DT. This is perfectly fine since not all
sensors needs to be used for thermal zones but only a few in real world.

So demote the error log to debug to avoid spamming users.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20221029052933.32421-1-manivannan.sadhasivam@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Luca Weiss
8763f8acbf thermal/drivers/qcom/temp-alarm: Fix inaccurate warning for gen2
On gen2 chips the stage2 threshold is not 140 degC but 125 degC.

Make the warning message clearer by using this variable and also by
including the temperature that was checked for.

Fixes: aa92b3310c ("thermal/drivers/qcom-spmi-temp-alarm: Add support for GEN2 rev 1 PMIC peripherals")
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Reviewed-by: Amit Kucheria <amitk@kernel.org>
Link: https://lore.kernel.org/r/20221020145237.942146-1-luca.weiss@fairphone.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Christophe JAILLET
de04f680b0 thermal/core/power allocator: Remove a useless include
This file does not use rcu, so there is no point in including
<linux/rculist.h>.

Remove it.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://lore.kernel.org/r/9adeec47cb5a8193016272d5c8bf936235c1711d.1669459337.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Alexander Stein
de95d1341a thermal/drivers/imx8mm: Add hwmon support
Expose thermal sensors as HWMON devices.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Link: https://lore.kernel.org/r/20220726122331.323093-1-alexander.stein@ew.tq-group.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Johan Hovold
6f89416462 thermal: qcom-spmi-adc-tm5: suppress probe-deferral error message
Drivers should not be logging errors on probe deferral. Switch to using
dev_err_probe() to log failures when parsing the devicetree to avoid
errors like:

	qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: get dt data failed: -517

when a channel is not yet available.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20221102152630.696-1-johan+linaro@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Geert Uytterhoeven
3f9cb57962 thermal: ti-soc-thermal: Drop comma after SoC match table sentinel
It does not make sense to have a comma after a sentinel, as any new
elements must be added before the sentinel.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Keerthy <j-keerthy@ti.com>
Link: https://lore.kernel.org/r/1d6de2a80b919cb11199e56ac06ad21c273ebe57.1669045586.git.geert+renesas@glider.be
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Marek Vasut
4032916488 thermal/drivers/imx: Add support for loading calibration data from OCOTP
The TMU TASR, TCALIVn, TRIM registers must be explicitly programmed with
calibration values in OCOTP. Add support for reading the OCOTP calibration
data and programming those into the TMU hardware.

The MX8MM/MX8MN TMUv1 uses only one OCOTP cell, while MX8MP TMUv2 uses 4,
the programming differs in each case.

Based on U-Boot commits:
70487ff386c ("imx8mm: Load fuse for TMU TCALIV and TASR")
ebb9aab318b ("imx: load calibration parameters from fuse for i.MX8MP")

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Christian Marangi
89992d95ed thermal/drivers/qcom/tsens: Rework debugfs file structure
The current tsens debugfs structure is composed by:
- a tsens dir in debugfs with a version file
- a directory for each tsens istance with sensors file to dump all the
  sensors value.

This works on the assumption that we have the same version for each
istance but this assumption seems fragile and with more than one tsens
istance results in the version file not tracking each of them.

A better approach is to just create a subdirectory for each tsens
istance and put there version and sensors debugfs file.

Using this new implementation results in less code since debugfs entry
are created only on successful tsens probe.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20221022125657.22530-4-ansuelsmth@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Christian Marangi
c7e077e921 thermal/drivers/qcom/tsens: Fix wrong version id dbg_version_show
For VER_0 the version was incorrectly reported as 0.1.0.

Fix that and correctly report the major version for this old tsens
revision.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20221022125657.22530-3-ansuelsmth@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Christian Marangi
de48d8766a thermal/drivers/qcom/tsens: Init debugfs only with successful probe
Calibrate and tsens_register can fail or PROBE_DEFER. This will cause a
double or a wrong init of the debugfs information. Init debugfs only
with successful probe fixing warning about directory already present.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Thara Gopinath <thara.gopinath@linaro.org>
Link: https://lore.kernel.org/r/20221022125657.22530-2-ansuelsmth@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2022-12-14 15:25:40 +01:00
Robert Marko
6840455deb thermal/drivers/tsens: Add IPQ8074 support
Qualcomm IPQ8074 uses tsens v2.3 IP, however unlike other tsens v2 IP
it only has one IRQ, that is used for up/low as well as critical.
It also does not support negative trip temperatures.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220818220245.338396-4-robimarko@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:40 +01:00
Robert Marko
f63baced38 thermal/drivers/tsens: Allow configuring min and max trips
IPQ8074 and IPQ6018 dont support negative trip temperatures and support
up to 204 degrees C as the max trip temperature.

So, instead of always setting the -40 as min and 120 degrees C as max
allow it to be configured as part of the features.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220818220245.338396-3-robimarko@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:40 +01:00
Robert Marko
4360af3527 thermal/drivers/tsens: Add support for combined interrupt
Despite using tsens v2.3 IP, IPQ8074 and IPQ6018 only have one IRQ for
signaling both up/low and critical trips.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20220818220245.338396-2-robimarko@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:40 +01:00
Ido Schimmel
7ef2f023c2 thermal/of: Fix memory leak on thermal_of_zone_register() failure
The function does not free 'of_ops' upon failure, leading to a memory
leak [1].

Fix by freeing 'of_ops' in the error path.

[1]
unreferenced object 0xffff8ee846198c80 (size 128):
  comm "swapper/0", pid 1, jiffies 4294699704 (age 70.076s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    d0 3f 6e 8c ff ff ff ff 00 00 00 00 00 00 00 00  .?n.............
  backtrace:
    [<00000000d136f562>] __kmalloc_node_track_caller+0x42/0x120
    [<0000000063f31678>] kmemdup+0x1d/0x40
    [<00000000e6d24096>] thermal_of_zone_register+0x49/0x520
    [<000000005e78c755>] devm_thermal_of_zone_register+0x54/0x90
    [<00000000ee6b209e>] pmbus_add_sensor+0x1b4/0x1d0
    [<00000000896105e3>] pmbus_add_sensor_attrs_one+0x123/0x440
    [<0000000049e990a6>] pmbus_add_sensor_attrs+0xfe/0x1d0
    [<00000000466b5440>] pmbus_do_probe+0x66b/0x14e0
    [<0000000084d42285>] i2c_device_probe+0x13b/0x2f0
    [<0000000029e2ae74>] really_probe+0xce/0x2c0
    [<00000000692df15c>] driver_probe_device+0x19/0xd0
    [<00000000547d9cce>] __device_attach_driver+0x6f/0x100
    [<0000000020abd24b>] bus_for_each_drv+0x76/0xc0
    [<00000000665d9563>] __device_attach+0xfc/0x180
    [<000000008ddd4d6a>] bus_probe_device+0x82/0xa0
    [<000000009e61132b>] device_add+0x3fe/0x920

Fixes: 3fd6d6e2b4 ("thermal/of: Rework the thermal device tree initialization")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20221020103658.802457-1-idosch@nvidia.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:39 +01:00
Keerthy
a7c42af78b thermal/drivers/k3_j72xx_bandgap: Fix the debug print message
The debug print message to check the workaround applicability is inverted.
Fix the same.

Fixes: ffcb2fc86e ("thermal: k3_j72xx_bandgap: Add the bandgap driver support")
Reported-by: Bryan Brattlof <bb@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Link: https://lore.kernel.org/r/20221010034126.3550-1-j-keerthy@ti.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:39 +01:00
Marcus Folkesson
d37edc7370 thermal/drivers/imx8mm_thermal: Validate temperature range
Check against the upper temperature limit (125 degrees C) before
consider the temperature valid.

Fixes: 5eed800a68 ("thermal: imx8mm: Add support for i.MX8MM thermal monitoring unit")
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Link: https://lore.kernel.org/r/20221014073507.1594844-1-marcus.folkesson@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:39 +01:00
Marcus Folkesson
1f455f144f thermal/drivers/imx8mm_thermal: Use GENMASK() when appropriate
GENMASK() is preferred to use for bitmasks.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20221014081620.1599511-1-marcus.folkesson@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-12-14 15:25:39 +01:00
Srinivas Pandruvada
904f309ae7 thermal: intel: Don't set HFI status bit to 1
When CPU doesn't support HFI (Hardware Feedback Interface), don't include
BIT 26 in the mask to prevent clearing. otherwise this results in:
    unchecked MSR access error: WRMSR to 0x1b1
      (tried to write 0x0000000004000aa8)
      at rIP: 0xffffffff8b8559fe (throttle_active_work+0xbe/0x1b0)

Fixes: 6fe1e64b60 ("thermal: intel: Prevent accidental clearing of HFI status")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-14 14:50:15 +01:00
Linus Torvalds
691806e977 Thermal control updates for 6.2-rc1
- Fix race conditions related to thermal device operations that are not
    protected against thermal device removal (Guenter Roeck).
 
  - Fix error code in __thermal_cooling_device_register() (Dan Carpenter).
 
  - Validate new cooling device state (coming from user space) in
    cur_state_store() and reuse the max_state value from cooling device
    structure in the sysfs interface (Viresh Kumar).
 
  - Fix some possible name leaks in error paths in the thermal control
    core code (Yang Yingliang).
 
  - Detect TCC lock bit set in the intel_tcc_cooling driver and make it
    refuse to update the TCC offset in that case (Zhang Rui).
 
  - Add TCC cooling support for RaptorLake-S (Zhang Rui).
 
  - Prevent accidental clearing of HFI status by one of the other
    drivers using the same status register (Srinivas Pandruvada).
 
  - Protect clearing of thermal status bits in Intel thermal control
    drivers (Srinivas Pandruvada).
 
  - Allow the HFI thermal control driver to ACK an HFI event for the
    previously observed timestamp (Srinivas Pandruvada).
 
  - Remove a pointless die_id check from the HFI thermal driver and
    adjust the definition a data structure used by it (Ricardo Neri).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmOXWUoSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxAhoQAI3OFLiQ/boXpTUgPFWbio+E5RZbDGTa
 Tb38JEAhREpXoce3QiT1ZDqoLUGS9tMpyfIBu8QkUXtgdyHkxFJc/AqwvFKUUmVN
 oS5GMn6s3ufQKTeiFoBd/hJ6zaGwcW4e/2QXzTZjq8oUaI0yca0HCc0QUYx6kWF6
 HqSD2KtFRVw4xe6uqZmwTVQddyIqA5FWRaZvhGolDPmVpg8NRTYVbsOzMf/StnRu
 lXyGrgk1tNIkJnGlOKnqsV9xIsH5iS8SRAgZaUc9wK/Wzor486VzH4TdVn6oYdUn
 fGCA1W982VX+mUlvVZQpyjGj8bL1JylZZSAcn8cg5cyKnTP1OinM6j/TIKc1JHK3
 ZFTvTxLuQbJD90frCKub/iIigcTX/GTk8iVRSuzmmzUiBkZ/3/15X6PVA15OEcQU
 zzHaiz0lir7LP0l2BhPDNbfTa1wJkiAtxVW7hcYUOtxL8S8vBldSEB9Kr0+e9A6i
 Lis8OOFS2nZYbGZxplX68JXp3Lo42pcF2QcdekU+iOp0eLziLc2WCB7Lj97TWJoR
 QAeyYf4eAsdKrW6vAiB4ygVxNDm4RPmesqlaNtlfhsFLUY7b5tc5vTinv6it5ktE
 CCNEi0N0NCIGifkIBnuthjToPsvhrTaYF9C1BPTi7p6mZp6VVacScA/qZ3rw2DG6
 W7FV8CJt5m5/
 =ZdzX
 -----END PGP SIGNATURE-----

Merge tag 'thermal-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control updates from Rafael Wysocki:
 "These include thermal core fixes to protect thermal device operations
  against thermal device removal, other thermal core fixes and updates
  of Intel thermal control drivers.

  Specifics:

   - Fix race conditions related to thermal device operations that are
     not protected against thermal device removal (Guenter Roeck)

   - Fix error code in __thermal_cooling_device_register() (Dan
     Carpenter)

   - Validate new cooling device state (coming from user space) in
     cur_state_store() and reuse the max_state value from cooling device
     structure in the sysfs interface (Viresh Kumar)

   - Fix some possible name leaks in error paths in the thermal control
     core code (Yang Yingliang)

   - Detect TCC lock bit set in the intel_tcc_cooling driver and make it
     refuse to update the TCC offset in that case (Zhang Rui)

   - Add TCC cooling support for RaptorLake-S (Zhang Rui)

   - Prevent accidental clearing of HFI status by one of the other
     drivers using the same status register (Srinivas Pandruvada)

   - Protect clearing of thermal status bits in Intel thermal control
     drivers (Srinivas Pandruvada)

   - Allow the HFI thermal control driver to ACK an HFI event for the
     previously observed timestamp (Srinivas Pandruvada)

   - Remove a pointless die_id check from the HFI thermal driver and
     adjust the definition a data structure used by it (Ricardo Neri)"

* tag 'thermal-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal: intel: hfi: Remove a pointless die_id check
  thermal: core: fix some possible name leaks in error paths
  thermal: intel: hfi: ACK HFI for the same timestamp
  thermal: intel: Protect clearing of thermal status bits
  thermal: intel: Prevent accidental clearing of HFI status
  thermal/core: Protect thermal device operations against thermal device removal
  thermal/core: Remove thermal_zone_set_trips()
  thermal/core: Protect sysfs accesses to thermal operations with thermal zone mutex
  thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutex
  thermal/core: Introduce locked version of thermal_zone_device_update
  thermal/core: Move parameter validation from __thermal_zone_get_temp to thermal_zone_get_temp
  thermal/core: Ensure that thermal device is registered in thermal_zone_get_temp
  thermal/core: Delete device under thermal device zone lock
  thermal/core: Destroy thermal zone device mutex in release function
  thermal: intel: intel_tcc_cooling: Add TCC cooling support for RaptorLake-S
  thermal: intel: intel_tcc_cooling: Detect TCC lock bit
  thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
  thermal/core: fix error code in __thermal_cooling_device_register()
  thermal: sysfs: Reuse cdev->max_state
  thermal: Validate new state in cur_state_store()
2022-12-12 13:45:21 -08:00
Linus Torvalds
456ed864fd ACPI updates for 6.2-rc1
- Update the ACPICA code in the kernel to the 20221020 upstream
    version and fix a couple of issues in it:
 
    * Make acpi_ex_load_op() match upstream implementation (Rafael
      Wysocki).
    * Add support for loong_arch-specific APICs in MADT (Huacai Chen).
    * Add support for fixed PCIe wake event (Huacai Chen).
    * Add EBDA pointer sanity checks (Vit Kabele).
    * Avoid accessing VGA memory when EBDA < 1KiB (Vit Kabele).
    * Add CCEL table support to both compiler/disassembler (Kuppuswamy
      Sathyanarayanan).
    * Add a couple of new UUIDs to the known UUID list (Bob Moore).
    * Add support for FFH Opregion special context data (Sudeep Holla).
    * Improve warning message for "invalid ACPI name" (Bob Moore).
    * Add support for CXL 3.0 structures (CXIMS & RDPAS) in the CEDT
      table (Alison Schofield).
    * Prepare IORT support for revision E.e (Robin Murphy).
    * Finish support for the CDAT table (Bob Moore).
    * Fix error code path in acpi_ds_call_control_method() (Rafael
      Wysocki).
    * Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage() (Li
      Zetao).
    * Update the version of the ACPICA code in the kernel (Bob Moore).
 
  - Use ZERO_PAGE(0) instead of empty_zero_page in the ACPI device
    enumeration code (Giulio Benetti).
 
  - Change the return type of the ACPI driver remove callback to void and
    update its users accordingly (Dawei Li).
 
  - Add general support for FFH address space type and implement the low-
    level part of it for ARM64 (Sudeep Holla).
 
  - Fix stale comments in the ACPI tables parsing code and make it print
    more messages related to MADT (Hanjun Guo, Huacai Chen).
 
  - Replace invocations of generic library functions with more kernel-
    specific counterparts in the ACPI sysfs interface (Christophe JAILLET,
    Xu Panda).
 
  - Print full name paths of ACPI power resource objects during
    enumeration (Kane Chen).
 
  - Eliminate a compiler warning regarding a missing function prototype
    in the ACPI power management code (Sudeep Holla).
 
  - Fix and clean up the ACPI processor driver (Rafael Wysocki, Li Zhong,
    Colin Ian King, Sudeep Holla).
 
  - Add quirk for the HP Pavilion Gaming 15-cx0041ur to the ACPI EC
    driver (Mia Kanashi).
 
  - Add some mew ACPI backlight handling quirks and update some existing
    ones (Hans de Goede).
 
  - Make the ACPI backlight driver prefer the native backlight control
    over vendor backlight control when possible (Hans de Goede).
 
  - Drop unsetting ACPI APEI driver data on remove (Uwe Kleine-König).
 
  - Use xchg_release() instead of cmpxchg() for updating new GHES cache
    slots (Ard Biesheuvel).
 
  - Clean up the ACPI APEI code (Sudeep Holla, Christophe JAILLET, Jay Lu).
 
  - Add new I2C device enumeration quirks for Medion Lifetab S10346 and
    Lenovo Yoga Tab 3 Pro (YT3-X90F) (Hans de Goede).
 
  - Make the ACPI battery driver notify user space about adding new
    battery hooks and removing the existing ones (Armin Wolf).
 
  - Modify the pfr_update and pfr_telemetry drivers to use ACPI_FREE()
    for freeing acpi_object structures to help diagnostics (Wang ShaoBo).
 
  - Make the ACPI fan driver use sysfs_emit_at() in its sysfs interface
    code (ye xingchen).
 
  - Fix the _FIF package extraction failure handling in the ACPI fan
    driver (Hanjun Guo).
 
  - Fix the PCC mailbox handling error code path (Huisong Li).
 
  - Avoid using PCC Opregions if there is no platform interrupt allocated
    for this purpose (Huisong Li).
 
  - Use sysfs_emit() instead of scnprintf() in the ACPI PAD driver and
    CPPC library (ye xingchen).
 
  - Fix some kernel-doc issues in the ACPI GSI processing code (Xiongfeng
    Wang).
 
  - Fix name memory leak in pnp_alloc_dev() (Yang Yingliang).
 
  - Do not disable PNP devices on suspend when they cannot be re-enabled
    on resume (Hans de Goede).
 
  - Clean up the ACPI thermal driver a bit (Rafael Wysocki).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmOXV10SHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxuOwP/2zew6val2Jf7I/Yxf1iQLlRyGmhFnaH
 wpltJvBjlHjAUKnPQ/kLYK9fjuUY5HVgjOE03WpwhFUpmhftYTrSkhoVkJ1Mw9Zl
 RNOAEgCG484ThHiTIVp/dMPxrtfuqpdbamhWX3Q51IfXjGW8Vc/lDxIa3k/JQxyq
 ko8GFPCoebJrSCfuwaAf2+xSQaf6dq4jpL/rlIk+nYMMB9mQmXhNEhc+l97NaCe8
 MyCIGynyNbhGsIlwdHRvTp04EIe8h0Z1+Dyns7g/TrzHj3Aezy7QVZbn8sKdZWa1
 W/Ck9QST5tfpDWyr+hUXxUJjEn4Yy+GXjM2xON0EMx5q+JD9XsOpwWOVwTR7CS5s
 FwEd6I89SC8OZM86AgMtnGxygjpK24R/kGzHjhG15IQCsypc8Rvzoxl0L0YVoon/
 UTkE57GzNWVzu0pY/oXJc2aT7lVqFXMFZ6ft/zHnBRnQmrcIi+xgDO5ni5KxctFN
 TVFwbAMCuwVx6IOcVQCZM2g4aJw426KpUn19fKnXvPwR5UIufBaCzSKWMiYrtdXr
 O5BM8ElYuyKCWGYEE0GSMjZygyDpyY6ENLH7s7P1IEmFyigBzaaGBbKm108JJq4V
 eCWJYTAx8pAptsU/vfuMvEQ1ErfhZ3TTokA5Lv0uPf53VcAnWDb7EAbW6ZGMwFSI
 IaV6cv6ILoqO
 =GVzp
 -----END PGP SIGNATURE-----

Merge tag 'acpi-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI and PNP updates from Rafael Wysocki:
 "These include new code (for instance, support for the FFH address
  space type and support for new firmware data structures in ACPICA),
  some new quirks (mostly related to backlight handling and I2C
  enumeration), a number of fixes and a fair amount of cleanups all
  over.

  Specifics:

   - Update the ACPICA code in the kernel to the 20221020 upstream
     version and fix a couple of issues in it:
      - Make acpi_ex_load_op() match upstream implementation (Rafael
        Wysocki)
      - Add support for loong_arch-specific APICs in MADT (Huacai Chen)
      - Add support for fixed PCIe wake event (Huacai Chen)
      - Add EBDA pointer sanity checks (Vit Kabele)
      - Avoid accessing VGA memory when EBDA < 1KiB (Vit Kabele)
      - Add CCEL table support to both compiler/disassembler (Kuppuswamy
        Sathyanarayanan)
      - Add a couple of new UUIDs to the known UUID list (Bob Moore)
      - Add support for FFH Opregion special context data (Sudeep
        Holla)
      - Improve warning message for "invalid ACPI name" (Bob Moore)
      - Add support for CXL 3.0 structures (CXIMS & RDPAS) in the CEDT
        table (Alison Schofield)
      - Prepare IORT support for revision E.e (Robin Murphy)
      - Finish support for the CDAT table (Bob Moore)
      - Fix error code path in acpi_ds_call_control_method() (Rafael
        Wysocki)
      - Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage() (Li
        Zetao)
      - Update the version of the ACPICA code in the kernel (Bob Moore)

   - Use ZERO_PAGE(0) instead of empty_zero_page in the ACPI device
     enumeration code (Giulio Benetti)

   - Change the return type of the ACPI driver remove callback to void
     and update its users accordingly (Dawei Li)

   - Add general support for FFH address space type and implement the
     low- level part of it for ARM64 (Sudeep Holla)

   - Fix stale comments in the ACPI tables parsing code and make it
     print more messages related to MADT (Hanjun Guo, Huacai Chen)

   - Replace invocations of generic library functions with more kernel-
     specific counterparts in the ACPI sysfs interface (Christophe
     JAILLET, Xu Panda)

   - Print full name paths of ACPI power resource objects during
     enumeration (Kane Chen)

   - Eliminate a compiler warning regarding a missing function prototype
     in the ACPI power management code (Sudeep Holla)

   - Fix and clean up the ACPI processor driver (Rafael Wysocki, Li
     Zhong, Colin Ian King, Sudeep Holla)

   - Add quirk for the HP Pavilion Gaming 15-cx0041ur to the ACPI EC
     driver (Mia Kanashi)

   - Add some mew ACPI backlight handling quirks and update some
     existing ones (Hans de Goede)

   - Make the ACPI backlight driver prefer the native backlight control
     over vendor backlight control when possible (Hans de Goede)

   - Drop unsetting ACPI APEI driver data on remove (Uwe Kleine-König)

   - Use xchg_release() instead of cmpxchg() for updating new GHES cache
     slots (Ard Biesheuvel)

   - Clean up the ACPI APEI code (Sudeep Holla, Christophe JAILLET, Jay
     Lu)

   - Add new I2C device enumeration quirks for Medion Lifetab S10346 and
     Lenovo Yoga Tab 3 Pro (YT3-X90F) (Hans de Goede)

   - Make the ACPI battery driver notify user space about adding new
     battery hooks and removing the existing ones (Armin Wolf)

   - Modify the pfr_update and pfr_telemetry drivers to use ACPI_FREE()
     for freeing acpi_object structures to help diagnostics (Wang
     ShaoBo)

   - Make the ACPI fan driver use sysfs_emit_at() in its sysfs interface
     code (ye xingchen)

   - Fix the _FIF package extraction failure handling in the ACPI fan
     driver (Hanjun Guo)

   - Fix the PCC mailbox handling error code path (Huisong Li)

   - Avoid using PCC Opregions if there is no platform interrupt
     allocated for this purpose (Huisong Li)

   - Use sysfs_emit() instead of scnprintf() in the ACPI PAD driver and
     CPPC library (ye xingchen)

   - Fix some kernel-doc issues in the ACPI GSI processing code
     (Xiongfeng Wang)

   - Fix name memory leak in pnp_alloc_dev() (Yang Yingliang)

   - Do not disable PNP devices on suspend when they cannot be
     re-enabled on resume (Hans de Goede)

   - Clean up the ACPI thermal driver a bit (Rafael Wysocki)"

* tag 'acpi-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (67 commits)
  ACPI: x86: Add skip i2c clients quirk for Medion Lifetab S10346
  ACPI: APEI: EINJ: Refactor available_error_type_show()
  ACPI: APEI: EINJ: Fix formatting errors
  ACPI: processor: perflib: Adjust acpi_processor_notify_smm() return value
  ACPI: processor: perflib: Rearrange acpi_processor_notify_smm()
  ACPI: processor: perflib: Rearrange unregistration routine
  ACPI: processor: perflib: Drop redundant parentheses
  ACPI: processor: perflib: Adjust white space
  ACPI: processor: idle: Drop unnecessary statements and parens
  ACPI: thermal: Adjust critical.flags.valid check
  ACPI: fan: Convert to use sysfs_emit_at() API
  ACPICA: Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage()
  ACPI: battery: Call power_supply_changed() when adding hooks
  ACPI: use sysfs_emit() instead of scnprintf()
  ACPI: x86: Add skip i2c clients quirk for Lenovo Yoga Tab 3 Pro (YT3-X90F)
  ACPI: APEI: Remove a useless include
  PNP: Do not disable devices on suspend when they cannot be re-enabled on resume
  ACPI: processor: Silence missing prototype warnings
  ACPI: processor_idle: Silence missing prototype warnings
  ACPI: PM: Silence missing prototype warning
  ...
2022-12-12 13:38:17 -08:00
Rafael J. Wysocki
75b15aa0d8 Merge branch 'thermal-intel'
Merge one more Intel thermal control change for 6.2-rc1:

 - Remove a pointless die_id chec from the Intel HFI thermal control
   driver (Ricardo Neri).

* thermal-intel:
  thermal: intel: hfi: Remove a pointless die_id check
2022-12-12 16:54:14 +01:00
Ricardo Neri
3a3073b69c thermal: intel: hfi: Remove a pointless die_id check
die_id is an u16 quantity. On single-die systems the default value of
die_id is 0. No need to check for negative values.

Plus, removing this check makes Coverity happy.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-12-02 20:47:52 +01:00
Rafael J. Wysocki
7d4b19ab6b Merge Intel thermal control drivers changes for v6.2
- Add Raptor Lake-S support to the intel_tcc_cooling driver (Zhang
   Rui).

 - Make the intel_tcc_cooling driver detect TCC locking (Zhang Rui).

 - Address Coverity warning in intel_hfi_process_event() (Ricardo Neri).

 - Prevent accidental clearing of HFI in the package thermal interrupt
   status (Srinivas Pandruvada).

 - Protect the clearing of status bits in MSR_IA32_PACKAGE_THERM_STATUS
   and MSR_IA32_THERM_STATUS (Srinivas Pandruvada).

 - Allow the HFI interrupt handler to ACK an event for the same
   timestamp (Srinivas Pandruvada).

* thermal-intel:
  thermal: intel: hfi: ACK HFI for the same timestamp
  thermal: intel: Protect clearing of thermal status bits
  thermal: intel: Prevent accidental clearing of HFI status
  thermal: intel: intel_tcc_cooling: Add TCC cooling support for RaptorLake-S
  thermal: intel: intel_tcc_cooling: Detect TCC lock bit
  thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
2022-12-02 19:39:07 +01:00
Yang Yingliang
4748f9687c thermal: core: fix some possible name leaks in error paths
In some error paths before device_register(), the names allocated
by dev_set_name() are not freed. Move dev_set_name() front to
device_register(), so the name can be freed while calling
put_device().

Fixes: 1dd7128b83 ("thermal/core: Fix null pointer dereference in thermal_release()")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-25 19:51:41 +01:00
Srinivas Pandruvada
c0e3acdcde thermal: intel: hfi: ACK HFI for the same timestamp
Some processors issue more than one HFI interrupt with the same
timestamp. Each interrupt must be acknowledged to let the hardware issue
new HFI interrupts. But this can't be done without some additional flow
modification in the existing interrupt handling.

For background, the HFI interrupt is a package level thermal interrupt
delivered via a LVT. This LVT is common for both the CPU and package
level interrupts. Hence, all CPUs receive the HFI interrupts. But only
one CPU should process interrupt and others simply exit by issuing EOI
to LAPIC.

The current HFI interrupt processing flow:

  1. Receive Thermal interrupt
  2. Check if there is an active HFI status in MSR_IA32_THERM_STATUS
  3. Try and get spinlock, one CPU will enter spinlock and others
     will simply return from here to issue EOI.
    (Let's assume CPU 4 is processing interrupt)
  4. Check the stored time-stamp from the HFI memory time-stamp
  5. if same
  6.      ignore interrupt, unlock and return
  7. Copy the HFI message to local buffer
  8. unlock spinlock
  9. ACK HFI interrupt
 10. Queue the message for processing in a work-queue

It is tempting to simply acknowledge all the interrupts even if they
have the same timestamp. This may cause some interrupts to not be
processed.

Let's say CPU5 is slightly late and reaches step 4 while CPU4 is
between steps 8 and 9.

Currently we simply ignore interrupts with the same timestamp. No
issue here for CPU5. When CPU4 acknowledges the interrupt, the next
HFI interrupt can be delivered.

If we acknowledge interrupts with the same timestamp (at step 6), there
is a race condition. Under the same scenario, CPU 5 will acknowledge
the HFI interrupt. This lets hardware generate another HFI interrupt,
before CPU 4 start executing step 9. Once CPU 4 complete step 9, it
will acknowledge the newly arrived HFI interrupt, without actually
processing it.

Acknowledge the interrupt when holding the spinlock. This avoids
contention of the interrupt acknowledgment.

Updated flow:

  1. Receive HFI Thermal interrupt
  2. Check if there is an active HFI status in MSR_IA32_THERM_STATUS
  3. Try and get spin-lock
     Let's assume CPU 4 is processing interrupt
  4.1 Read MSR_IA32_PACKAGE_THERM_STATUS and check HFI status bit
  4.2	If hfi status is 0
  4.3		unlock spinlock
  4.4		return
  4.5 Check the stored time-stamp from the HFI memory time-stamp
  5. if same
  6.1      ACK HFI Interrupt,
  6.2	unlock spinlock
  6.3	return
  7. Copy the HFI message to local buffer
  8. ACK HFI interrupt
  9. unlock spinlock
 10. Queue the message for processing in a work-queue

To avoid taking the lock unnecessarily, intel_hfi_process_event() checks
the status of the HFI interrupt before taking the lock. If CPU5 is late,
when it starts processing the interrupt there are two scenarios:

 a) CPU4 acknowledged the HFI interrupt before CPU5 read
    MSR_IA32_THERM_STATUS. CPU5 exits.

 b) CPU5 reads MSR_IA32_THERM_STATUS before CPU4 has acknowledged the
    interrupt. CPU5 will take the lock if CPU4 has released it. It then
    re-reads MSR_IA32_THERM_STATUS. If there is not a new interrupt,
    the HFI status bit is clear and CPU5 exits. If a new HFI interrupt
    was generated it will find that the status bit is set and it will
    continue to process the interrupt. In this case even if timestamp
    is not changed, the ACK can be issued as this is a new interrupt.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Tested-by: Arshad, Adeel<adeel.arshad@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-23 20:13:22 +01:00
Srinivas Pandruvada
930d06bf07 thermal: intel: Protect clearing of thermal status bits
The clearing of the package thermal status is done by Read-Modify-Write
operation. This may result in clearing of some new status bits which are
being or about to be processed.

For example, while clearing of HFI status, after read of thermal status
register, a new thermal status bit is set by the hardware. But during
write back, the newly generated status bit will be set to 0 or cleared.
So, it is not safe to do read-modify-write.

Since thermal status Read-Write bits can be set to only 0 not 1, it is
safe to set all other bits to 1 which are not getting cleared.

Create a common interface for clearing package thermal status bits. Use
this interface to replace existing code to clear thermal package status
bits.

It is safe to call from different CPUs without protection as there is no
read-modify-write. Also wrmsrl results in just single instruction. For
example while CPU 0 and CPU 3 are clearing bit 1 and 3 respectively. If
CPU 3 wins the race, it will write 0x4000aa2, then CPU 1 will write
0x4000aa8. The bits which are not part of clear are set to 1. The default
mask for bits, which can be written here is 0x4000aaa.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-23 20:09:06 +01:00
Srinivas Pandruvada
6fe1e64b60 thermal: intel: Prevent accidental clearing of HFI status
When there is a package thermal interrupt with PROCHOT log, it will be
processed and cleared. It is possible that there is an active HFI event
status, which is about to get processed or getting processed. While
clearing PROCHOT log bit, it will also clear HFI status bit. This means
that hardware is free to update HFI memory.

When clearing a package thermal interrupt, some processors will generate
a "general protection fault" when any of the read only bit is set to 1.

The driver maintains a mask of all read-write bits which can be set.

This mask doesn't include HFI status bit. This bit will also be cleared,
as it will be assumed read-only bit. So, add HFI status bit 26 to the
mask.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-23 20:09:06 +01:00
Dawei Li
6c0eb5ba35 ACPI: make remove callback of ACPI driver void
For bus-based driver, device removal is implemented as:
1 device_remove()->
2   bus->remove()->
3     driver->remove()

Driver core needs no inform from callee(bus driver) about the
result of remove callback. In that case, commit fc7a6209d5
("bus: Make remove callback return void") forces bus_type::remove
be void-returned.

Now we have the situation that both 1 & 2 of calling chain are
void-returned, so it does not make much sense for 3(driver->remove)
to return non-void to its caller.

So the basic idea behind this change is making remove() callback of
any bus-based driver to be void-returned.

This change, for itself, is for device drivers based on acpi-bus.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dawei Li <set_pte_at@outlook.com>
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>  # for drivers/platform/surface/*
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-23 19:11:22 +01:00
Arnd Bergmann
a6eeafba11 firmware: tegra: Changes for v6.2-rc1
This adds new BPMP ABI so that newer features can be enabled.
 Furthermore, the BPMP driver is updated to use iosys-map helpers to
 allow working with shared memory regions that are located in system
 memory.
 
 Apart from that, several minor cleanups are included.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmN7rlETHHRyZWRpbmdA
 bnZpZGlhLmNvbQAKCRDdI6zXfz6zoaT0EACUyPn96EovNyLMY9Ay/EgJbCtBB7MG
 k1ow5NoM3ZU8LXQLwtmqQcNrBxi9edQDU40vZqzoLrhWuTIQbVdu9F+rb6oYMnC4
 4POrbXKtuuFz9lr+k8xYs/M44qFQsFosvH/yr64GL9/l2yQCrKd8UP8xkxlwcE9N
 K4a8Lum+aNM6UwAoDvFiY97PkYf3SHgfpFbZ1teWARTnpOGaC3zpUPqOIREL7f08
 SezHFK5+qmMI6D+VtsG9EETjYYeHpstmEW5j2tM3HI/noAlfY7JEBffoaptWmJ02
 7A4OkWS7vbR/m69JQcpVEj5oFDUQAYMYbdEfNR/FMPPL+nAviC2yiNjWzvELgqfJ
 xyrtK0GqXIGOS8bQbb+nlXK+T+RiaRMFFHFp6DVKKx06QHLNYHefoRR94AjUGwyu
 So4POKimX0VLgMZi2votP4gQH3WKgqTsvtk+Spwq4XLH+Id5wRhg6miEInpaid/L
 mwoVqr4cW2ECeH5RzadtR0mR1bgL0uweXBXQFLw5Hp6MnGhD3LwNUNz/NlL5sO11
 q67df3K3zccatPniOQza/WV7uul0rC+EZl9zeexSGEMlUjVHv77/99e7vDfRWe12
 NNBbQxL8SmlFXriYEdWv+ZuI43tXkuk9OaSx0A1WjA4XZFwn2/3JGz9owPCDdGII
 SyUKFp9olvkMYg==
 =e9FJ
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmN9O8AACgkQmmx57+YA
 GNl+hRAAlwOn0/70DAtKWh49vg03JDm/fe4HYPBRNRz3z20+3qMMaINB2nCKLDhy
 1+uiafbkhW6Wl/NTA+RCFbHno3ztFjHxMvUyOa/PmN3FWz1hIGR/EQk8aRVY3Jsu
 y+Qf2+UhsyUVJYjU0S2Mz4kdbE2hGPAmVG05MCQ1CQhLk2nIoofLqqPfKOAHqppu
 KqCxMzsJmPjC/6FUtM6+o7AC1wnNMO9qOR152hoPe2d8yVdydta339sDxUBKH6fE
 HeodQNnvNmK3M1FQf9q7Mqa1ltyyTZZKB3MMWulZFPGnnZF8u8b2jslxNQaQ+pfb
 G61V9KvX7sLV8mw+lXPP+lquP85IwOOajhoCGF/Pa8nofjL5vfJE4lH4spuUkFTa
 nWKlVhXMnpAyzQ1K7qSeA+UycZwXGAUriwVJeSyB9jrg5bBzbtaNXQ+KoB/yV2Vn
 sQoH4Aspm52ePLggZUnDOZTuq6NUC4HZOyApPRQgPoSGiMkFwS6ic4ae0gGDXdyT
 ShHkAjF2wDOcL0fxpS5Y1lRtNI9NBFAeuETrjE1QQfT6MnTjLRpWnTsylIu01lTz
 1Eh4x8cOwOiYuYD52ozbnZ0F3roUbbvIm67/zgF/Up9h8qwCyIUZ1rkHQDMruBrx
 c91zgDxoqrEfp7Mbdu/wFWnQYhfSD6g9spBixbtflmCnMblerog=
 =yh95
 -----END PGP SIGNATURE-----

Merge tag 'tegra-for-6.2-firmware-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into soc/drivers

firmware: tegra: Changes for v6.2-rc1

This adds new BPMP ABI so that newer features can be enabled.
Furthermore, the BPMP driver is updated to use iosys-map helpers to
allow working with shared memory regions that are located in system
memory.

Apart from that, several minor cleanups are included.

* tag 'tegra-for-6.2-firmware-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux:
  firmware: tegra: Remove surplus dev_err() when using platform_get_irq_byname()
  firmware: tegra: Update BPMP ABI
  firmware: tegra: bpmp: Do not support big-endian
  firmware: tegra: bpmp: Use iosys-map helpers
  firmware: tegra: bpmp: Prefer u32 over uint32_t

Link: https://lore.kernel.org/r/20221121171239.2041835-2-thierry.reding@gmail.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-11-22 22:14:39 +01:00
Guenter Roeck
b778b4d782 thermal/core: Protect thermal device operations against thermal device removal
Thermal device operations may be called after thermal zone device removal.
After thermal zone device removal, thermal zone device operations must
no longer be called. To prevent such calls from happening, ensure that
the thermal device is registered before executing any thermal device
operations.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
91b3aafc22 thermal/core: Remove thermal_zone_set_trips()
Since no callers of thermal_zone_set_trips() are left, remove the function.
Document __thermal_zone_set_trips() instead. Explicitly state that the
thermal zone lock must be held when calling the function, and that the
pointer to the thermal zone must be valid.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
05eeee2b51 thermal/core: Protect sysfs accesses to thermal operations with thermal zone mutex
Protect access to thermal operations against thermal zone removal by
acquiring the thermal zone device mutex. After acquiring the mutex, check
if the thermal zone device is registered and abort the operation if not.

With this change, we can call __thermal_zone_device_update() instead of
thermal_zone_device_update() from trip_point_temp_store() and from
emul_temp_store(). Similar, we can call __thermal_zone_set_trips() instead
of thermal_zone_set_trips() from trip_point_hyst_store().

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
ea37bec51f thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutex
In preparation to protecting access to thermal operations against thermal
zone device removal, protect hwmon accesses to thermal zone operations
with the thermal zone mutex. After acquiring the mutex, ensure that the
thermal zone device is registered before proceeding.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
1c439dec35 thermal/core: Introduce locked version of thermal_zone_device_update
In thermal_zone_device_set_mode(), the thermal zone mutex is released only
to be reacquired in the subsequent call to thermal_zone_device_update().

Introduce __thermal_zone_device_update(), which is similar to
thermal_zone_device_update() but has to be called with the thermal device
mutex held. Call the new function from thermal_zone_device_set_mode()
to avoid the extra thermal device mutex release/acquire sequence in that
function.

With the new function in place, re-implement thermal_zone_device_update()
as wrapper around __thermal_zone_device_update() to acquire and release
the thermal device mutex.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
ed97d10a8b thermal/core: Move parameter validation from __thermal_zone_get_temp to thermal_zone_get_temp
All callers of __thermal_zone_get_temp() already validated the
thermal zone parameters. Move validation to thermal_zone_get_temp()
where it is actually needed. Also add kernel documentation for
__thermal_zone_get_temp(), listing the requirement that the
function must be called with validated parameters and with thermal
device mutex held.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
1c6b300607 thermal/core: Ensure that thermal device is registered in thermal_zone_get_temp
Calls to thermal_zone_get_temp() are not protected against thermal zone
device removal. As result, it is possible that the thermal zone operations
callbacks are no longer valid when thermal_zone_get_temp() is called.
This may result in crashes such as

BUG: unable to handle page fault for address: ffffffffc04ef420
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
PGD 5d60e067 P4D 5d60e067 PUD 5d610067 PMD 110197067 PTE 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 1 PID: 3209 Comm: cat Tainted: G        W         5.10.136-19389-g615abc6eb807 #1 02df41ac0b12f3a64f4b34245188d8875bb3bce1
Hardware name: Google Coral/Coral, BIOS Google_Coral.10068.92.0 11/27/2018
RIP: 0010:thermal_zone_get_temp+0x26/0x73
Code: 89 c3 eb d3 0f 1f 44 00 00 55 48 89 e5 41 57 41 56 53 48 85 ff 74 50 48 89 fb 48 81 ff 00 f0 ff ff 77 44 48 8b 83 98 03 00 00 <48> 83 78 10 00 74 36 49 89 f6 4c 8d bb d8 03 00 00 4c 89 ff e8 9f
RSP: 0018:ffffb3758138fd38 EFLAGS: 00010287
RAX: ffffffffc04ef410 RBX: ffff98f14d7fb000 RCX: 0000000000000000
RDX: ffff98f17cf90000 RSI: ffffb3758138fd64 RDI: ffff98f14d7fb000
RBP: ffffb3758138fd50 R08: 0000000000001000 R09: ffff98f17cf90000
R10: 0000000000000000 R11: ffffffff8dacad28 R12: 0000000000001000
R13: ffff98f1793a7d80 R14: ffff98f143231708 R15: ffff98f14d7fb018
FS:  00007ec166097800(0000) GS:ffff98f1bbd00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc04ef420 CR3: 000000010ee9a000 CR4: 00000000003506e0
Call Trace:
 temp_show+0x31/0x68
 dev_attr_show+0x1d/0x4f
 sysfs_kf_seq_show+0x92/0x107
 seq_read_iter+0xf5/0x3f2
 vfs_read+0x205/0x379
 __x64_sys_read+0x7c/0xe2
 do_syscall_64+0x43/0x55
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

if a thermal device is removed while accesses to its device attributes
are ongoing.

The problem is exposed by code in iwl_op_mode_mvm_start(), which registers
a thermal zone device only to unregister it shortly afterwards if an
unrelated failure is encountered while accessing the hardware.

Check if the thermal zone device is registered after acquiring the
thermal zone device mutex to ensure this does not happen.

The code was tested by triggering the failure in iwl_op_mode_mvm_start()
on purpose. Without this patch, the kernel crashes reliably. The crash
is no longer observed after applying this and the preceding patches.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
30b2ae07d3 thermal/core: Delete device under thermal device zone lock
Thermal device attributes may still be opened after unregistering
the thermal zone and deleting the thermal device.

Currently there is no protection against accessing thermal device
operations after unregistering a thermal zone. To enable adding
such protection, protect the device delete operation with the
thermal zone device mutex. This requires splitting the call to
device_unregister() into its components, device_del() and put_device().
Only the first call can be executed under mutex protection, since
put_device() may result in releasing the thermal zone device memory.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Guenter Roeck
d35f29ed9d thermal/core: Destroy thermal zone device mutex in release function
Accesses to thermal zones, and with it the thermal zone device mutex,
are still possible after the thermal zone device has been unregistered.
For example, thermal_zone_get_temp() can be called from temp_show()
in thermal_sysfs.c if the sysfs attribute was opened before the thermal
device was unregistered.

Move the call to mutex_destroy from thermal_zone_device_unregister()
to thermal_release() to ensure that it is only destroyed after it is
guaranteed to be no longer accessed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-14 19:04:37 +01:00
Zhang Rui
e77f069fd6 thermal: intel: intel_tcc_cooling: Add TCC cooling support for RaptorLake-S
Add RaptorLake to the list of processor models supported by the Intel
TCC cooling driver.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-09 14:58:02 +01:00
Zhang Rui
be6abd3ed6 thermal: intel: intel_tcc_cooling: Detect TCC lock bit
When MSR_IA32_TEMPERATURE_TARGET is locked, TCC Offset can not be
updated even if the PROGRAMMABE Bit is set.

Yield the driver on platforms with MSR_IA32_TEMPERATURE_TARGET locked.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-09 14:58:02 +01:00
Ricardo Neri
54d9135cf2 thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
A Coverity static code scan raised a potential overflow_before_widen
warning when hfi_features::nr_table_pages is used as an argument to
memcpy in intel_hfi_process_event().

Even though the overflow can never happen (the maximum number of pages of
the HFI table is 0x10 and 0x10 << PAGE_SHIFT = 0x10000), using size_t as
the data type of hfi_features::nr_table_pages makes Coverity happy and
matches the data type of the argument 'size' of memcpy().

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-10-28 20:11:48 +02:00
Dan Carpenter
e49a1e1ee0 thermal/core: fix error code in __thermal_cooling_device_register()
Return an error pointer if ->get_max_state() fails.  The current code
returns NULL which will cause an oops in the callers.

Fixes: c408b3d1d9 ("thermal: Validate new state in cur_state_store()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-10-28 19:59:51 +02:00
Viresh Kumar
a365105c68 thermal: sysfs: Reuse cdev->max_state
Now that the cooling device structure stores the max_state value, reuse
it and drop max_states from struct cooling_dev_stats.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-10-25 18:58:11 +02:00
Viresh Kumar
c408b3d1d9 thermal: Validate new state in cur_state_store()
In cur_state_store(), the new state of the cooling device is received
from user-space and is not validated by the thermal core but the same is
left for the individual drivers to take care of. Apart from duplicating
the code it leaves possibility for introducing bugs where a driver may
not do it right.

Lets make the thermal core check the new state itself and store the max
value in the cooling device structure.

Link: https://lore.kernel.org/all/Y0ltRJRjO7AkawvE@kili/
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-10-25 18:58:11 +02:00
Thierry Reding
4c1e0a9735 firmware: tegra: bpmp: Use iosys-map helpers
The shared memory used for inter-processor communication between the CPU
and the BPMP can reside either in system memory or in I/O memory. Use
the iosys-map helpers to abstract these differences away.

Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-10-24 15:18:11 +02:00
Rafael J. Wysocki
4bb7f6c278 thermal: intel_powerclamp: Use first online CPU as control_cpu
Commit 68b99e94a4 ("thermal: intel_powerclamp: Use get_cpu() instead
of smp_processor_id() to avoid crash") fixed an issue related to using
smp_processor_id() in preemptible context by replacing it with a pair
of get_cpu()/put_cpu(), but what is needed there really is any online
CPU and not necessarily the one currently running the code.  Arguably,
getting the one that's running the code in there is confusing.

For this reason, simply give the control CPU role to the first online
one which automatically will be CPU0 if it is online, so one check
can be dropped from the code for an added benefit.

Link: https://lore.kernel.org/linux-pm/20221011113646.GA12080@duo.ucw.cz/
Fixes: 68b99e94a4 ("thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
2022-10-15 19:33:57 +02:00
Linus Torvalds
aa512c115a More thermal control updates for 6.1-rc1
- Use platform data to get the sensor ID instead of parsing the device
    in imx_sc thermal driver and remove the dedicated OF function from
    the core code (Daniel Lezcano).
 
  - Fix Kconfig dependency for the QCom tsens thermal driver (Jonathan
    Cameron).
 
  - Add missing const annotation to the RCar ops thermal driver (Lad
    Prabhakar).
 
  - Drop duplicate parameter check from
    thermal_zone_device_register_with_trips() (Lad Prabhakar).
 
  - Fix NULL pointer dereference in trip_point_temp_store() by making it
    check if the ->set_trip_temp() operation is present (Lad Prabhakar).
 
  - Fix the MSM8939 fourth sensor hardware ID in the QCom tsens thermal
    driver (Vincent Knecht).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmNEVX4SHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxPt8P/RDbDE471D6tvCDUGG5+D17sJiUl5G87
 okcAusrYD6wlQJP+/tK6o9p0elR7TbLI2iH3VuTRCgVrAUQYqzVMOH7eYZPq4p0R
 sNZ1q+wO0AUH1TKGJjtYc72Cx8k/1sVG0jtIncjpN1zsc5dDJkDU9mMYidLw3V+u
 FYSLOYY6Pj7wfDw0SYqeefCeVTz1d2SmliNBqvoBpvrM7VmfTiWdwiAqv9yqiukg
 JfrWJ8qEbP0q7Xx9oO5x6NhglgwzZd2HNdldh+kEVTx9iVSe8Pzb8qEi+xU/WP23
 5qavneW2ccdxRLYEJAT2zhVszaswPa0vMsymYCbmeVcjpJ3WLoFyPaZuNixFBW0w
 iVr1z4OiQl6uwhiFbHbpQtTIVJi2Kh7cW8CfxRnF/mITGjnOCLz1alrtkWnhBzi3
 muzZcry0ACwGS2s/huhx1jkMhVsGuiqiVPlbsSU+75AW8NORafpZwZPb6usMPtQn
 /nNgAj+kEI7tKBXI5f39+IwUm5GYQlGLAyboJ6iAKaQhhDw6R8cwkhPsP1rtXLIR
 wj+dhBG/WFdA/HDYMKvNEg77CFbHceOGvO3nmq6V/5xDMKX+T7lMM0nEp33fkWxC
 DnuZdKp+E+iopdmAAN6jfl/frGUjdYEuz+MVWJdfxhiLpIpcD7MJDvMbUCkwZwp3
 T9dj7CWachx0
 =BrtK
 -----END PGP SIGNATURE-----

Merge tag 'thermal-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more thermal control updates from Rafael Wysocki:
 "These fix assorted issues in the thermal core and ARM thermal drivers.

  Specifics:

   - Use platform data to get the sensor ID instead of parsing the
     device in imx_sc thermal driver and remove the dedicated OF
     function from the core code (Daniel Lezcano).

   - Fix Kconfig dependency for the QCom tsens thermal driver (Jonathan
     Cameron).

   - Add missing const annotation to the RCar ops thermal driver (Lad
     Prabhakar).

   - Drop duplicate parameter check from
     thermal_zone_device_register_with_trips() (Lad Prabhakar).

   - Fix NULL pointer dereference in trip_point_temp_store() by making
     it check if the ->set_trip_temp() operation is present (Lad
     Prabhakar).

   - Fix the MSM8939 fourth sensor hardware ID in the QCom tsens thermal
     driver (Vincent Knecht)"

* tag 'thermal-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal/drivers/qcom/tsens-v0_1: Fix MSM8939 fourth sensor hw_id
  thermal/core: Add a check before calling set_trip_temp()
  thermal/core: Drop valid pointer check for type
  thermal/drivers/rcar_thermal: Constify static thermal_zone_device_ops
  thermal/drivers/qcom: Drop false build dependency of all QCOM drivers on QCOM_TSENS
  thermal/of: Remove the thermal_zone_of_get_sensor_id() function
  thermal/drivers/imx_sc: Rely on the platform data to get the resource id
2022-10-10 13:52:14 -07:00
Linus Torvalds
a09476668e Char/Misc and other driver changes for 6.1-rc1
Here is the large set of char/misc and other small driver subsystem
 changes for 6.1-rc1.  Loads of different things in here:
   - IIO driver updates, additions, and changes.  Probably the largest
     part of the diffstat
   - habanalabs driver update with support for new hardware and features,
     the second largest part of the diff.
   - fpga subsystem driver updates and additions
   - mhi subsystem updates
   - Coresight driver updates
   - gnss subsystem updates
   - extcon driver updates
   - icc subsystem updates
   - fsi subsystem updates
   - nvmem subsystem and driver updates
   - misc driver updates
   - speakup driver additions for new features
   - lots of tiny driver updates and cleanups
 
 All of these have been in the linux-next tree for a while with no
 reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCY0GQmA8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylyVQCeNJjZ3hy+Wz8WkPSY+NkehuIhyCIAnjXMOJP8
 5G/JQ+rpcclr7VOXlS66
 =zVkU
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc and other driver updates from Greg KH:
 "Here is the large set of char/misc and other small driver subsystem
  changes for 6.1-rc1. Loads of different things in here:

   - IIO driver updates, additions, and changes. Probably the largest
     part of the diffstat

   - habanalabs driver update with support for new hardware and
     features, the second largest part of the diff.

   - fpga subsystem driver updates and additions

   - mhi subsystem updates

   - Coresight driver updates

   - gnss subsystem updates

   - extcon driver updates

   - icc subsystem updates

   - fsi subsystem updates

   - nvmem subsystem and driver updates

   - misc driver updates

   - speakup driver additions for new features

   - lots of tiny driver updates and cleanups

  All of these have been in the linux-next tree for a while with no
  reported issues"

* tag 'char-misc-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (411 commits)
  w1: Split memcpy() of struct cn_msg flexible array
  spmi: pmic-arb: increase SPMI transaction timeout delay
  spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes
  spmi: pmic-arb: correct duplicate APID to PPID mapping logic
  spmi: pmic-arb: add support to dispatch interrupt based on IRQ status
  spmi: pmic-arb: check apid against limits before calling irq handler
  spmi: pmic-arb: do not ack and clear peripheral interrupts in cleanup_irq
  spmi: pmic-arb: handle spurious interrupt
  spmi: pmic-arb: add a print in cleanup_irq
  drivers: spmi: Directly use ida_alloc()/free()
  MAINTAINERS: add TI ECAP driver info
  counter: ti-ecap-capture: capture driver support for ECAP
  Documentation: ABI: sysfs-bus-counter: add frequency & num_overflows items
  dt-bindings: counter: add ti,am62-ecap-capture.yaml
  counter: Introduce the COUNTER_COMP_ARRAY component type
  counter: Consolidate Counter extension sysfs attribute creation
  counter: Introduce the Count capture component
  counter: 104-quad-8: Add Signal polarity component
  counter: Introduce the Signal polarity component
  counter: interrupt-cnt: Implement watch_validate callback
  ...
2022-10-08 08:56:37 -07:00
Linus Torvalds
0326074ff4 Networking changes for 6.1.
Core
 ----
 
  - Introduce and use a single page frag cache for allocating small skb
    heads, clawing back the 10-20% performance regression in UDP flood
    test from previous fixes.
 
  - Run packets which already went thru HW coalescing thru SW GRO.
    This significantly improves TCP segment coalescing and simplifies
    deployments as different workloads benefit from HW or SW GRO.
 
  - Shrink the size of the base zero-copy send structure.
 
  - Move TCP init under a new slow / sleepable version of DO_ONCE().
 
 BPF
 ---
 
  - Add BPF-specific, any-context-safe memory allocator.
 
  - Add helpers/kfuncs for PKCS#7 signature verification from BPF
    programs.
 
  - Define a new map type and related helpers for user space -> kernel
    communication over a ring buffer (BPF_MAP_TYPE_USER_RINGBUF).
 
  - Allow targeting BPF iterators to loop through resources of one
    task/thread.
 
  - Add ability to call selected destructive functions.
    Expose crash_kexec() to allow BPF to trigger a kernel dump.
    Use CAP_SYS_BOOT check on the loading process to judge permissions.
 
  - Enable BPF to collect custom hierarchical cgroup stats efficiently
    by integrating with the rstat framework.
 
  - Support struct arguments for trampoline based programs.
    Only structs with size <= 16B and x86 are supported.
 
  - Invoke cgroup/connect{4,6} programs for unprivileged ICMP ping
    sockets (instead of just TCP and UDP sockets).
 
  - Add a helper for accessing CLOCK_TAI for time sensitive network
    related programs.
 
  - Support accessing network tunnel metadata's flags.
 
  - Make TCP SYN ACK RTO tunable by BPF programs with TCP Fast Open.
 
  - Add support for writing to Netfilter's nf_conn:mark.
 
 Protocols
 ---------
 
  - WiFi: more Extremely High Throughput (EHT) and Multi-Link
    Operation (MLO) work (802.11be, WiFi 7).
 
  - vsock: improve support for SO_RCVLOWAT.
 
  - SMC: support SO_REUSEPORT.
 
  - Netlink: define and document how to use netlink in a "modern" way.
    Support reporting missing attributes via extended ACK.
 
  - IPSec: support collect metadata mode for xfrm interfaces.
 
  - TCPv6: send consistent autoflowlabel in SYN_RECV state
    and RST packets.
 
  - TCP: introduce optional per-netns connection hash table to allow
    better isolation between namespaces (opt-in, at the cost of memory
    and cache pressure).
 
  - MPTCP: support TCP_FASTOPEN_CONNECT.
 
  - Add NEXT-C-SID support in Segment Routing (SRv6) End behavior.
 
  - Adjust IP_UNICAST_IF sockopt behavior for connected UDP sockets.
 
  - Open vSwitch:
    - Allow specifying ifindex of new interfaces.
    - Allow conntrack and metering in non-initial user namespace.
 
  - TLS: support the Korean ARIA-GCM crypto algorithm.
 
  - Remove DECnet support.
 
 Driver API
 ----------
 
  - Allow selecting the conduit interface used by each port
    in DSA switches, at runtime.
 
  - Ethernet Power Sourcing Equipment and Power Device support.
 
  - Add tc-taprio support for queueMaxSDU parameter, i.e. setting
    per traffic class max frame size for time-based packet schedules.
 
  - Support PHY rate matching - adapting between differing host-side
    and link-side speeds.
 
  - Introduce QUSGMII PHY mode and 1000BASE-KX interface mode.
 
  - Validate OF (device tree) nodes for DSA shared ports; make
    phylink-related properties mandatory on DSA and CPU ports.
    Enforcing more uniformity should allow transitioning to phylink.
 
  - Require that flash component name used during update matches one
    of the components for which version is reported by info_get().
 
  - Remove "weight" argument from driver-facing NAPI API as much
    as possible. It's one of those magic knobs which seemed like
    a good idea at the time but is too indirect to use in practice.
 
  - Support offload of TLS connections with 256 bit keys.
 
 New hardware / drivers
 ----------------------
 
  - Ethernet:
    - Microchip KSZ9896 6-port Gigabit Ethernet Switch
    - Renesas Ethernet AVB (EtherAVB-IF) Gen4 SoCs
    - Analog Devices ADIN1110 and ADIN2111 industrial single pair
      Ethernet (10BASE-T1L) MAC+PHY.
    - Rockchip RV1126 Gigabit Ethernet (a version of stmmac IP).
 
  - Ethernet SFPs / modules:
    - RollBall / Hilink / Turris 10G copper SFPs
    - HALNy GPON module
 
  - WiFi:
    - CYW43439 SDIO chipset (brcmfmac)
    - CYW89459 PCIe chipset (brcmfmac)
    - BCM4378 on Apple platforms (brcmfmac)
 
 Drivers
 -------
 
  - CAN:
    - gs_usb: HW timestamp support
 
  - Ethernet PHYs:
    - lan8814: cable diagnostics
 
  - Ethernet NICs:
    - Intel (100G):
      - implement control of FCS/CRC stripping
      - port splitting via devlink
      - L2TPv3 filtering offload
    - nVidia/Mellanox:
      - tunnel offload for sub-functions
      - MACSec offload, w/ Extended packet number and replay
        window offload
      - significantly restructure, and optimize the AF_XDP support,
        align the behavior with other vendors
    - Huawei:
      - configuring DSCP map for traffic class selection
      - querying standard FEC statistics
      - querying SerDes lane number via ethtool
    - Marvell/Cavium:
      - egress priority flow control
      - MACSec offload
    - AMD/SolarFlare:
      - PTP over IPv6 and raw Ethernet
    - small / embedded:
      - ax88772: convert to phylink (to support SFP cages)
      - altera: tse: convert to phylink
      - ftgmac100: support fixed link
      - enetc: standard Ethtool counters
      - macb: ZynqMP SGMII dynamic configuration support
      - tsnep: support multi-queue and use page pool
      - lan743x: Rx IP & TCP checksum offload
      - igc: add xdp frags support to ndo_xdp_xmit
 
  - Ethernet high-speed switches:
    - Marvell (prestera):
      - support SPAN port features (traffic mirroring)
      - nexthop object offloading
    - Microchip (sparx5):
      - multicast forwarding offload
      - QoS queuing offload (tc-mqprio, tc-tbf, tc-ets)
 
  - Ethernet embedded switches:
    - Marvell (mv88e6xxx):
      - support RGMII cmode
    - NXP (felix):
      - standardized ethtool counters
    - Microchip (lan966x):
      - QoS queuing offload (tc-mqprio, tc-tbf, tc-cbs, tc-ets)
      - traffic policing and mirroring
      - link aggregation / bonding offload
      - QUSGMII PHY mode support
 
  - Qualcomm 802.11ax WiFi (ath11k):
    - cold boot calibration support on WCN6750
    - support to connect to a non-transmit MBSSID AP profile
    - enable remain-on-channel support on WCN6750
    - Wake-on-WLAN support for WCN6750
    - support to provide transmit power from firmware via nl80211
    - support to get power save duration for each client
    - spectral scan support for 160 MHz
 
  - MediaTek WiFi (mt76):
    - WiFi-to-Ethernet bridging offload for MT7986 chips
 
  - RealTek WiFi (rtw89):
    - P2P support
 
 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE6jPA+I1ugmIBA4hXMUZtbf5SIrsFAmM7vtkACgkQMUZtbf5S
 Irvotg//dmh53rC+UMKO3OgOqPlSMnaqzbUdDEfN6mj4Mpox7Csb8zERVURHhBHY
 fvlXWsDgxmvgTebI5fvNC5+f1iW5xcqgJV2TWnNmDOKWwvQwb6qQfgixVmunvkpe
 IIukMXYt0dAf9bXeeEfbNXcCb85cPwB76stX0tMV6BX7osp3T0TL1fvFk0NJkL0j
 TeydLad/yAQtPb4TbeWYjNDoxPVDf0cVpUrevLGmWE88UMYmgTqPze+h1W5Wri52
 bzjdLklY/4cgcIZClHQ6F9CeRWqEBxvujA5Hj/cwOcn/ptVVJWUGi7sQo3sYkoSs
 HFu+F8XsTec14kGNC0Ab40eVdqs5l/w8+E+4jvgXeKGOtVns8DwoiUIzqXpyty89
 Ib04mffrwWNjFtHvo/kIsNwP05X2PGE9HUHfwsTUfisl/ASvMmQp7D7vUoqQC/4B
 AMVzT5qpjkmfBHYQQGuw8FxJhMeAOjC6aAo6censhXJyiUhIfleQsN0syHdaNb8q
 9RZlhAgQoVb6ZgvBV8r8unQh/WtNZ3AopwifwVJld2unsE/UNfQy2KyqOWBES/zf
 LP9sfuX0JnmHn8s1BQEUMPU1jF9ZVZCft7nufJDL6JhlAL+bwZeEN4yCiAHOPZqE
 ymSLHI9s8yWZoNpuMWKrI9kFexVnQFKmA3+quAJUcYHNMSsLkL8=
 =Gsio
 -----END PGP SIGNATURE-----

Merge tag 'net-next-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next

Pull networking updates from Jakub Kicinski:
 "Core:

   - Introduce and use a single page frag cache for allocating small skb
     heads, clawing back the 10-20% performance regression in UDP flood
     test from previous fixes.

   - Run packets which already went thru HW coalescing thru SW GRO. This
     significantly improves TCP segment coalescing and simplifies
     deployments as different workloads benefit from HW or SW GRO.

   - Shrink the size of the base zero-copy send structure.

   - Move TCP init under a new slow / sleepable version of DO_ONCE().

  BPF:

   - Add BPF-specific, any-context-safe memory allocator.

   - Add helpers/kfuncs for PKCS#7 signature verification from BPF
     programs.

   - Define a new map type and related helpers for user space -> kernel
     communication over a ring buffer (BPF_MAP_TYPE_USER_RINGBUF).

   - Allow targeting BPF iterators to loop through resources of one
     task/thread.

   - Add ability to call selected destructive functions. Expose
     crash_kexec() to allow BPF to trigger a kernel dump. Use
     CAP_SYS_BOOT check on the loading process to judge permissions.

   - Enable BPF to collect custom hierarchical cgroup stats efficiently
     by integrating with the rstat framework.

   - Support struct arguments for trampoline based programs. Only
     structs with size <= 16B and x86 are supported.

   - Invoke cgroup/connect{4,6} programs for unprivileged ICMP ping
     sockets (instead of just TCP and UDP sockets).

   - Add a helper for accessing CLOCK_TAI for time sensitive network
     related programs.

   - Support accessing network tunnel metadata's flags.

   - Make TCP SYN ACK RTO tunable by BPF programs with TCP Fast Open.

   - Add support for writing to Netfilter's nf_conn:mark.

  Protocols:

   - WiFi: more Extremely High Throughput (EHT) and Multi-Link Operation
     (MLO) work (802.11be, WiFi 7).

   - vsock: improve support for SO_RCVLOWAT.

   - SMC: support SO_REUSEPORT.

   - Netlink: define and document how to use netlink in a "modern" way.
     Support reporting missing attributes via extended ACK.

   - IPSec: support collect metadata mode for xfrm interfaces.

   - TCPv6: send consistent autoflowlabel in SYN_RECV state and RST
     packets.

   - TCP: introduce optional per-netns connection hash table to allow
     better isolation between namespaces (opt-in, at the cost of memory
     and cache pressure).

   - MPTCP: support TCP_FASTOPEN_CONNECT.

   - Add NEXT-C-SID support in Segment Routing (SRv6) End behavior.

   - Adjust IP_UNICAST_IF sockopt behavior for connected UDP sockets.

   - Open vSwitch:
      - Allow specifying ifindex of new interfaces.
      - Allow conntrack and metering in non-initial user namespace.

   - TLS: support the Korean ARIA-GCM crypto algorithm.

   - Remove DECnet support.

  Driver API:

   - Allow selecting the conduit interface used by each port in DSA
     switches, at runtime.

   - Ethernet Power Sourcing Equipment and Power Device support.

   - Add tc-taprio support for queueMaxSDU parameter, i.e. setting per
     traffic class max frame size for time-based packet schedules.

   - Support PHY rate matching - adapting between differing host-side
     and link-side speeds.

   - Introduce QUSGMII PHY mode and 1000BASE-KX interface mode.

   - Validate OF (device tree) nodes for DSA shared ports; make
     phylink-related properties mandatory on DSA and CPU ports.
     Enforcing more uniformity should allow transitioning to phylink.

   - Require that flash component name used during update matches one of
     the components for which version is reported by info_get().

   - Remove "weight" argument from driver-facing NAPI API as much as
     possible. It's one of those magic knobs which seemed like a good
     idea at the time but is too indirect to use in practice.

   - Support offload of TLS connections with 256 bit keys.

  New hardware / drivers:

   - Ethernet:
      - Microchip KSZ9896 6-port Gigabit Ethernet Switch
      - Renesas Ethernet AVB (EtherAVB-IF) Gen4 SoCs
      - Analog Devices ADIN1110 and ADIN2111 industrial single pair
        Ethernet (10BASE-T1L) MAC+PHY.
      - Rockchip RV1126 Gigabit Ethernet (a version of stmmac IP).

   - Ethernet SFPs / modules:
      - RollBall / Hilink / Turris 10G copper SFPs
      - HALNy GPON module

   - WiFi:
      - CYW43439 SDIO chipset (brcmfmac)
      - CYW89459 PCIe chipset (brcmfmac)
      - BCM4378 on Apple platforms (brcmfmac)

  Drivers:

   - CAN:
      - gs_usb: HW timestamp support

   - Ethernet PHYs:
      - lan8814: cable diagnostics

   - Ethernet NICs:
      - Intel (100G):
         - implement control of FCS/CRC stripping
         - port splitting via devlink
         - L2TPv3 filtering offload
      - nVidia/Mellanox:
         - tunnel offload for sub-functions
         - MACSec offload, w/ Extended packet number and replay window
           offload
         - significantly restructure, and optimize the AF_XDP support,
           align the behavior with other vendors
      - Huawei:
         - configuring DSCP map for traffic class selection
         - querying standard FEC statistics
         - querying SerDes lane number via ethtool
      - Marvell/Cavium:
         - egress priority flow control
         - MACSec offload
      - AMD/SolarFlare:
         - PTP over IPv6 and raw Ethernet
      - small / embedded:
         - ax88772: convert to phylink (to support SFP cages)
         - altera: tse: convert to phylink
         - ftgmac100: support fixed link
         - enetc: standard Ethtool counters
         - macb: ZynqMP SGMII dynamic configuration support
         - tsnep: support multi-queue and use page pool
         - lan743x: Rx IP & TCP checksum offload
         - igc: add xdp frags support to ndo_xdp_xmit

   - Ethernet high-speed switches:
      - Marvell (prestera):
         - support SPAN port features (traffic mirroring)
         - nexthop object offloading
      - Microchip (sparx5):
         - multicast forwarding offload
         - QoS queuing offload (tc-mqprio, tc-tbf, tc-ets)

   - Ethernet embedded switches:
      - Marvell (mv88e6xxx):
         - support RGMII cmode
      - NXP (felix):
         - standardized ethtool counters
      - Microchip (lan966x):
         - QoS queuing offload (tc-mqprio, tc-tbf, tc-cbs, tc-ets)
         - traffic policing and mirroring
         - link aggregation / bonding offload
         - QUSGMII PHY mode support

   - Qualcomm 802.11ax WiFi (ath11k):
      - cold boot calibration support on WCN6750
      - support to connect to a non-transmit MBSSID AP profile
      - enable remain-on-channel support on WCN6750
      - Wake-on-WLAN support for WCN6750
      - support to provide transmit power from firmware via nl80211
      - support to get power save duration for each client
      - spectral scan support for 160 MHz

   - MediaTek WiFi (mt76):
      - WiFi-to-Ethernet bridging offload for MT7986 chips

   - RealTek WiFi (rtw89):
      - P2P support"

* tag 'net-next-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (1864 commits)
  eth: pse: add missing static inlines
  once: rename _SLOW to _SLEEPABLE
  net: pse-pd: add regulator based PSE driver
  dt-bindings: net: pse-dt: add bindings for regulator based PoDL PSE controller
  ethtool: add interface to interact with Ethernet Power Equipment
  net: mdiobus: search for PSE nodes by parsing PHY nodes.
  net: mdiobus: fwnode_mdiobus_register_phy() rework error handling
  net: add framework to support Ethernet PSE and PDs devices
  dt-bindings: net: phy: add PoDL PSE property
  net: marvell: prestera: Propagate nh state from hw to kernel
  net: marvell: prestera: Add neighbour cache accounting
  net: marvell: prestera: add stub handler neighbour events
  net: marvell: prestera: Add heplers to interact with fib_notifier_info
  net: marvell: prestera: Add length macros for prestera_ip_addr
  net: marvell: prestera: add delayed wq and flush wq on deinit
  net: marvell: prestera: Add strict cleanup of fib arbiter
  net: marvell: prestera: Add cleanup of allocated fib_nodes
  net: marvell: prestera: Add router nexthops ABI
  eth: octeon: fix build after netif_napi_add() changes
  net/mlx5: E-Switch, Return EBUSY if can't get mode lock
  ...
2022-10-04 13:38:03 -07:00
Vincent Knecht
b0c883e900 thermal/drivers/qcom/tsens-v0_1: Fix MSM8939 fourth sensor hw_id
Reading temperature from this sensor fails with 'Invalid argument'.

Looking at old vendor dts [1], its hw_id should be 3 instead of 4.
Change this hw_id accordingly.

[1] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/master/arch/arm/boot/dts/qcom/msm8939-common.dtsi#L511

Fixes: 332bc8ebab ("thermal: qcom: tsens-v0_1: Add support for MSM8939")
Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20220811105014.7194-1-vincent.knecht@mailoo.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-10-04 11:21:43 +02:00
Lad Prabhakar
597f500fde thermal/core: Add a check before calling set_trip_temp()
The thermal driver [0] for Renesas RZ/G2L SoC does not implement
set_trip_temp() callback but has trips commit 9326167058
("thermal/core: Move set_trip_temp ops to the sysfs code") changed
the behaviour which causes the below panic when trying to set the
trip temperature:

root@smarc-rzg2l:~# echo 51000 > /sys/class/thermal/thermal_zone0/trip_point_0_temp
[   92.461521] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[   92.470958] Mem abort info:
[   92.474311]   ESR = 0x0000000086000004
[   92.478546]   EC = 0x21: IABT (current EL), IL = 32 bits
[   92.484290]   SET = 0, FnV = 0
[   92.487693]   EA = 0, S1PTW = 0
[   92.491153]   FSC = 0x04: level 0 translation fault
[   92.496461] user pgtable: 4k pages, 48-bit VAs, pgdp=000000004e885000
[   92.503736] [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
[   92.510869] Internal error: Oops: 86000004 [#3] PREEMPT SMP
[   92.516556] CPU: 0 PID: 290 Comm: sh Tainted: G      D            6.0.0-rc4-next-20220906-arm64-renesas-00124-g84633c87c5f6-dirty #509
[   92.528814] Hardware name: Renesas SMARC EVK based on r9a07g044l2 (DT)
[   92.535441] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   92.542516] pc : 0x0
[   92.544764] lr : trip_point_temp_store+0x84/0x140
[   92.549582] sp : ffff80000a92bc10
[   92.552961] x29: ffff80000a92bc10 x28: ffff00000d8a45c0 x27: 0000000000000000
[   92.560249] x26: 0000000000000000 x25: ffff8000082b53e8 x24: ffff00000eaffc20
[   92.567532] x23: ffff80000a92bd68 x22: ffff00000d3e0f80 x21: 0000000000000006
[   92.574814] x20: ffff800009149000 x19: ffff00000b8ab000 x18: 0000000000000000
[   92.582097] x17: 0000000000000000 x16: 0000000000000000 x15: 0000aaab028cdee0
[   92.589378] x14: 0000000000000000 x13: 0000000000000000 x12: ffff80000a92bbd0
[   92.596659] x11: ffff00000d3e0f80 x10: ffff800009149eb8 x9 : 000000000000000a
[   92.603940] x8 : 00000000ffffffc9 x7 : 0000000000000005 x6 : 000000000000002a
[   92.611220] x5 : 000000000000c738 x4 : 00000000ffffffd3 x3 : 0000000000000000
[   92.618500] x2 : 000000000000c738 x1 : 0000000000000000 x0 : ffff00000b8ab000
[   92.625781] Call trace:
[   92.628282]  0x0
[   92.630176]  dev_attr_store+0x14/0x28
[   92.633935]  sysfs_kf_write+0x4c/0x70
[   92.637681]  kernfs_fop_write_iter+0x160/0x1e0
[   92.642213]  vfs_write+0x474/0x540
[   92.645703]  ksys_write+0x68/0xf8
[   92.649100]  __arm64_sys_write+0x18/0x20
[   92.653111]  invoke_syscall+0x40/0xf8
[   92.656866]  el0_svc_common.constprop.3+0x88/0x110
[   92.661758]  do_el0_svc+0x20/0x78
[   92.665158]  el0_svc+0x3c/0x90
[   92.668291]  el0t_64_sync_handler+0x90/0xb8
[   92.672563]  el0t_64_sync+0x148/0x14c
[   92.676322] Code: bad PC value
[   92.679453] ---[ end trace 0000000000000000 ]---
/bin/start_getty: line 40:   290 Segmentation fault      ${setsid:-} ${getty} -L $1 $2 $3

Poky (Yocto Project Reference Distro) 3.2.1 smarc-rzg2l ttySC0

smarc-rzg2l login:

This patch fixes the above issue by adding a check to see if
set_trip_temp() callback is implemented before calling it.

[0] drivers/thermal/rzg2l_thermal.c

Fixes: 9326167058 ("thermal/core: Move set_trip_temp ops to the sysfs code")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20220908174610.7837-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-10-04 11:21:36 +02:00
Lad Prabhakar
c71d8035f1 thermal/core: Drop valid pointer check for type
Drop the valid pointer check for type in
thermal_zone_device_register_with_trips() as we already have it confirmed
for != NULL from the previous if block.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20220909181322.10933-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-10-04 11:21:30 +02:00
Lad Prabhakar
c7114365e3 thermal/drivers/rcar_thermal: Constify static thermal_zone_device_ops
The only usage of rcar_thermal_zone_of_ops is to pass its address to
devm_thermal_of_zone_register(), which takes a pointer to const struct
thermal_zone_device_ops. Make it const to allow the compiler to put
it in read-only memory.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20220909182838.11154-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-10-04 11:21:18 +02:00
Jonathan Cameron
34dc523bba thermal/drivers/qcom: Drop false build dependency of all QCOM drivers on QCOM_TSENS
The SPMI QCOM drivers have no dependency in Kconfig, but the Makefile
will not be included without QCOM_TSENS. This unnecessarily reduces
build coverage.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Acked-by: Amit Kucheria <amitk@kernel.org>
Reviewed-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Link: https://lore.kernel.org/r/20220821160032.2206349-1-jic23@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-10-04 11:21:11 +02:00
Daniel Lezcano
5d10f480f7 thermal/of: Remove the thermal_zone_of_get_sensor_id() function
The function thermal_zone_of_get_sensor_id() is no longer used
anywhere, remove it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220818082316.2717095-2-daniel.lezcano@linaro.org
2022-10-04 11:21:06 +02:00
Daniel Lezcano
31fd4b9db1 thermal/drivers/imx_sc: Rely on the platform data to get the resource id
Currently the imx_sc driver is reimplementing part of the thermal zone
parsing from the thermal OF tree code to get the sensor id associated
with a thermal zone sensor.

The driver platform specific code should know what sensor is present
and not rely on the thermal zone description to do a discovery. Well
that is arguable but all the other drivers have a per platform data
telling what sensor id to use.

The imx_sc thermal driver is the only one using a different
approach. Not invalid but forcing to keep a specific function
'thermal_zone_of_get_sensor_id()' to get the sensor id for a specific
thermal zone as the self-explanatory function tells and having device
tree code inside the driver.

The thermal OF code had a rework and remains now self-encapsulated
with a register/unregister functions and their 'devm' variants, except
for the function mentioned above.

After investigating, it appears the imx_sc sensor is defined in
arch/arm64/boot/dts/freescale/imx8qxp.dtsi:

which defines the cpu-thermal zone with the id: IMX_SC_R_SYSTEM

This dtsi is included by:
 - imx8qxp-ai_ml.dts
 - imx8qxp-colibri.dtsi
 - imx8qxp-mek.dts

The two first ones do not define more thermal zones
The third one adds the pmic-thermal0 zone with id: IMX_SC_R_PMIC_0

The thermal OF code returns -ENODEV if the thermal zone registration
with a specific id fails because the description is not available in
the DT for such a sensor id. In this case we continue with the other
ids without bailing out with an error.

So we can build for the 'fsl,imx-sc-thermal' a compatible data, an
array of sensor ids containing IMX_SC_R_SYSTEM and IMX_SC_R_PMIC_0.

The latter won't be found but that will not result in an error but a
normal case where we continue the initialization with other ids.

Just to clarify, it is what the thermal framework does and what the
other drivers are expecting: when a registration fails with -ENODEV
this is not an error but a case where the description is not found in
the device tree, that be can the entire thermal zones description or a
specific thermal zone with an unknown id.

There is one small functional change but without impact. When there is
no 'thermal-zones' description the probe function was returning
'-ENODEV', now it returns zero. When a thermal zone fails to register
with an error different from '-ENODEV', the error is detected and
returned.

Change the code accordingly and remove the OF code from the driver.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220818082316.2717095-1-daniel.lezcano@linaro.org
2022-10-04 11:20:59 +02:00
Rafael J. Wysocki
2e70ea7fb9 Merge branches 'thermal-intel' and 'thermal-drivers'
Merge thermal control driver changes for 6.1-rc1:

 - Use module_pci_driver() macro in the int340x processor_thermal
   driver (Shang XiaoJing).

 - Use get_cpu() instead of smp_processor_id() in the intel_powerclamp
   thermal driver to prevent it from crashing and remove unused
   accounting for IRQ wakes from it (Srinivas Pandruvada).

 - Consolidate priv->data_vault checks in int340x_thermal (Rafael
   Wysocki).

 - Check the policy first in cpufreq_cooling_register() (Xuewen Yan).

 - Drop redundant error message from da9062-thermal (zhaoxiao).

 - Drop of_match_ptr() from thermal_mmio (Jean Delvare).

* thermal-intel:
  thermal: int340x: processor_thermal: Use module_pci_driver() macro
  thermal: intel_powerclamp: Remove accounting for IRQ wakes
  thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash
  thermal: int340x_thermal: Consolidate priv->data_vault checks

* thermal-drivers:
  thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register()
  thermal: da9062-thermal: Drop redundant error message
  thermal/drivers/thermal_mmio: Drop of_match_ptr()
2022-10-03 20:43:32 +02:00
Rafael J. Wysocki
a7ae50fc34 Merge branch 'thermal-core'
Merge core thermal control changes for 6.1-rc1:

 - Increase maximum number of trip points in the thermal core (Sumeet
   Pawnikar).

 - Replace strlcpy() with unused retval with strscpy() in the core
   thermal control code (Wolfram Sang).

 - Do not lock thermal zone mutex in the user space governor (Rafael
   Wysocki)

 - Rework the device tree initialization, convert the drivers to the
   new API and remove the old OF code (Daniel Lezcano)

 - Fix return value to -ENODEV when searching for a specific thermal
   zone which does not exist (Daniel Lezcano)

 - Fix the return value inspection in of_thermal_zone_find() (Dan
   Carpenter)

 - Fix kernel panic when KASAN is enabled as it detects use after
   free when unregistering a thermal zone (Daniel Lezcano)

 - Move the set_trip ops inside the therma sysfs code (Daniel Lezcano)

 - Remove unnecessary error message as it is already showed in the
   underlying function (Jiapeng Chong)

 - Rework the monitoring path and move the locks upper in the call
   stack to fix some potentials race windows (Daniel Lezcano)

 - Fix lockdep_assert() warning introduced by the lock rework (Daniel
   Lezcano)

 - Revert the Mellanox 'hotter thermal zone' feature because it is
   already handled in the thermal framework core code (Daniel Lezcano)

* thermal-core: (47 commits)
  thermal: core: Increase maximum number of trip points
  thermal: move from strlcpy() with unused retval to strscpy()
  thermal: gov_user_space: Do not lock thermal zone mutex
  Revert "mlxsw: core: Add the hottest thermal zone detection"
  thermal/core: Fix lockdep_assert() warning
  thermal/core: Move the mutex inside the thermal_zone_device_update() function
  thermal/core: Move the thermal zone lock out of the governors
  thermal/governors: Group the thermal zone lock inside the throttle function
  thermal/core: Rework the monitoring a bit
  thermal/core: Rearm the monitoring only one time
  thermal/drivers/qcom/spmi-adc-tm5: Remove unnecessary print function dev_err()
  thermal/of: Remove old OF code
  thermal/core: Move set_trip_temp ops to the sysfs code
  thermal/drivers/samsung: Switch to new of thermal API
  regulator/drivers/max8976: Switch to new of thermal API
  Input: sun4i-ts - switch to new of thermal API
  iio/drivers/sun4i_gpadc: Switch to new of thermal API
  hwmon/drivers/core: Switch to new of thermal API
  hwmon: pm_bus: core: Switch to new of thermal API
  ata/drivers/ahci_imx: Switch to new of thermal API
  ...
2022-10-03 20:38:43 +02:00
Sumeet Pawnikar
82b1ec794d thermal: core: Increase maximum number of trip points
On one of the Chrome system, if we define more than 12 trip points,
probe for thermal sensor fails with
"int3403 thermal: probe of INTC1046:03 failed with error -22"
and throws an error as
"thermal_sys: Error: Incorrect number of thermal trips".

The thermal_zone_device_register() interface needs maximum
number of trip points supported in a zone as an argument.
This number can't exceed THERMAL_MAX_TRIPS, which is currently
set to 12. To address this issue, THERMAL_MAX_TRIPS value
has to be increased.

This interface also has an argument to specify a mask of trips
which are writable. This mask is defined as an int.
This mask sets the ceiling for increasing maximum number of
supported trips. With the current implementation, maximum number
of trips can be supported is 31.

Also, THERMAL_MAX_TRIPS macro is used in one place only.
So, remove THERMAL_MAX_TRIPS macro and compare num_trips
directly with using a macro BITS_PER_TYPE(int)-1.

Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-30 19:50:10 +02:00
Shang XiaoJing
53e41b8593 thermal: int340x: processor_thermal: Use module_pci_driver() macro
Since PCI provides helper macro module_pci_driver(), the
module_init/exit code can be replaced with it.

Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-24 19:22:09 +02:00
Rafał Miłecki
28fc7c986f nvmem: prefix all symbols with NVMEM_
This unifies all NVMEM symbols. They follow one style now.

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220916122100.170016-8-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-09-24 14:54:38 +02:00
Srinivas Pandruvada
c4e927da89 thermal: intel_powerclamp: Remove accounting for IRQ wakes
There is a static variable "idle_wakeup_counter", which accounts for
number of wake ups because of IRQs and take actions to compensate idle
injection. This is now read and reset to 0, but never incremented.
So all the usage of this counter for idle injection has no use.

Also another static variable "reduce_irq", which depends on
"idle_wakeup_counter", so remove usage of "reduce_irq" also.

Commit feb6cd6a0f ("thermal/intel_powerclamp: stop sched tick in
forced idle") replaced the local use of "mwait_idle_with_hints" with
play_idle(). This removed possibility of updating "idle_wakeup_counter"
without change in play_idle(). This change was made in Linux 4.10.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-21 20:31:05 +02:00
Srinivas Pandruvada
68b99e94a4 thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash
When CPU 0 is offline and intel_powerclamp is used to inject
idle, it generates kernel BUG:

BUG: using smp_processor_id() in preemptible [00000000] code: bash/15687
caller is debug_smp_processor_id+0x17/0x20
CPU: 4 PID: 15687 Comm: bash Not tainted 5.19.0-rc7+ #57
Call Trace:
<TASK>
dump_stack_lvl+0x49/0x63
dump_stack+0x10/0x16
check_preemption_disabled+0xdd/0xe0
debug_smp_processor_id+0x17/0x20
powerclamp_set_cur_state+0x7f/0xf9 [intel_powerclamp]
...
...

Here CPU 0 is the control CPU by default and changed to the current CPU,
if CPU 0 offlined. This check has to be performed under cpus_read_lock(),
hence the above warning.

Use get_cpu() instead of smp_processor_id() to avoid this BUG.

Suggested-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Subject edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-21 20:27:06 +02:00
Greg Kroah-Hartman
4ba028e41b 1st set of IIO new device support, features and cleanup for 6.1
This includes Nuno Sa's work to move the IIO core over to generic firmware
 properties rather than having DT specific code paths. Combined with Andy
 Shevchenko's long term work on drivers, this leaves IIO in a good state for
 handling other firmware types.
 
 New device support
 - liteon,ltrf216a
   * New driver and dt bindings to support this Light sensor.
 - maxim,max11205
   * New driver for this 16bit single channel ADC.
 - memsensing,msa311
   * New driver for this accelerometer. Includes a string helper for read/write.
 - richtek,rtq6056
   * New driver and dt binding to support this current monitor used to measure
     power usage.
 - yamaha,yas530
   * Support the YAS537 variant (series includes several fixes for other parts
     and new driver features).
 
 Staging graduation
 - adi,ad7746 CDC. Cleanup conducted against set of roadtest tests using
   the posted RFC of that framework.
 
 Features
 - core
   * Large rework to make all the core IIO code use generic firmware properties.
     Includes switching some drivers over as well using newly provided
     generic interfaces and allowing removal of DT specific ones.
   * Support for gesture event types for single and double tap. Used in
     bosch,bma400.
 - atmel,at91-sama5d2
   * Add support for temperature sensor which uses two muxed inputs to estimate
     the temperature.
   * Handle trackx bits of EMR register to improve temp sampling accuracy.
   * Runtime PM support.
 - liteon,ltrf216a
   * Add a _raw channel output to allow working around an issue with
     differing conversions equations that breaks some user space controls.
 - mexelis,mlx90632
   * Support regulator control.
 - ti,tsc2046
   * External reference voltage support.
 
 Clean up and minor fixes
 - Tree-wide
   * devm_clk_get_enabled() replacements of opencoded equivalent.
   * Remaining IIO_DMA_MINALIGN conversions (the staging/iio drivers).
   * Various minor warning and similar cleanup such as missing static
     markings.
   * strlcpy() to strscpy() for cases where return value not checked.
   * provide units.h entries for more HZ units and use them in drivers.
 - dt-bindings cleanup
   * Drop maintainers listss where the email address is bouncing.
   * Switch spi devices over to using spi-peripheral.yaml
   * Add some missing unevaluatedProperties / additionalProperties: false
     entries.
 - ABI docs
   * Add some missing channel type specific sampling frequency entries.
   * Add parameter names for callback parameters.
 - MAINTAINERS
   * Fix wrong ADI forum links.
 - core
   * lockdep class per device, to avoid an issue with nest when one IIO
     device is the consumer of another.
   * White space tweaks.
 - asc,dlhl60d
   * Use get_unaligned_be24 to avoid some unusual data manipulation and masking.
 - atmel,at91-sama5d2
   * Fix wrong max value.
   * Improve error handling when measuring pressure and touch.
   * Add locks to remove races on updating oversampling / sampling freq.
   * Add missing calls in suspend and resume path to ensure state is correctly
     brought up if buffered capture was in use when suspend happened.
   * Error out of write_raw() callback if buffered capture enabled to avoid
     unpredictable behavior.
   * Handle different versions having different oversampling ratio support and
     drop excess error checking.
   * Cleanup magic value defines where the name is just the value and hence
     hurts readability.
   * Use read_avail() callback to provide info on possible oversampling ratios.
   * Correctly handle variable bit depth when doing oversampling on different
     supported parts. Also handle higher oversampling ratios.
 - fsl,imx8qxp
   * Don't ignore errors from regulator_get_voltage() so as to avoid some
     very surprising scaling.
 - invensense,icp10100
   * Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS. UNIVERSAL rarely made
     sense and is now deprecated. In this driver we just avoid double disabling
     in some paths.
 - maxim,max1363
   * Drop consumer channel map provision by platform data. There have been
     better ways of doing this for years and there are no in tree users.
 - microchip,mcp3911
   * Update status to maintained.
 - qcom,spmi-adc5
   * Support measurement of LDO output voltage.
 - qcom,spmi-adc
   * Add missing channel available on SM6125 SoC.
 - st,stmpe
   * Drop requirement on node name in binding now that driver correctly
     doesn't enforce it.
 - stx104
   * Move to more appropriate addac directory
 - ti,am335x
   * Document ti,am654-adc compatible already in use in tree.
 - ti,hmc5843
   * Move dev_pm_ops out of header and use new pm macros to handle export.
 - yamaha,yas530
   * Minor cleanups.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmMdsjERHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohwYA//cDu2/UcQgXRfIvWTmAAIXNk0qQ/3VQbf
 h6hjy9wESmW8728sed77bkL49WriyyXkYe3qalLph4Y+bFRwLAss/2iHlyM396+7
 3qFZz8ydkU9b2pJMt9clPr24RMoPo32s5gwRLs4LG/KJdzZNPYC+AI/ZaErtKSaD
 58p7RD9If11/jPo1q1CDJVSF6rsHPfd3terhgP/8eMNyPSwggCohVf+g8CL62Suf
 2F0m8RjNMCC+RvPIHQ4u0LtGOtRMvw5DMOcRe/xk2xVxdR2awqmgUGyTIUe61Wuz
 C9kuJlxSMovyHRyKNAhHcTDNl8vFbV/4ZaqV4PJDPT5GBiMH6TulXFX2a0oowJHB
 sjMYQP2mH7ZVssdm9P3Nv/cYs3IVHtTdQsDzMIwU9A0qiObG7tisZHm51RsgBBGa
 Zy4JnphOEjia4pz2V3Tf/sFJxNz1OmKFsUD18LdXIEv2f93++7+K8FJL3TMuSsBj
 PdWbLjhd3ZEp5re/60RIW5AaQjBxZf90GRFNIyOu4q1xGMFbHglbWjMEtiyBr+M5
 SRPnatHBLm3LXF31/Km/+VcHhIWWh3InxeORhufNVQsx600J2gpX3nvLxj2D3bWX
 QRjUj76zgH37KvKca8NTgPUrzWg10K330toLF34mIq5rFonp0dI41CzApVxQsmCH
 NO4fYKP+c1k=
 =fUm6
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-6.1a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO new device support, features and cleanup for 6.1

This includes Nuno Sa's work to move the IIO core over to generic firmware
properties rather than having DT specific code paths. Combined with Andy
Shevchenko's long term work on drivers, this leaves IIO in a good state for
handling other firmware types.

New device support
- liteon,ltrf216a
  * New driver and dt bindings to support this Light sensor.
- maxim,max11205
  * New driver for this 16bit single channel ADC.
- memsensing,msa311
  * New driver for this accelerometer. Includes a string helper for read/write.
- richtek,rtq6056
  * New driver and dt binding to support this current monitor used to measure
    power usage.
- yamaha,yas530
  * Support the YAS537 variant (series includes several fixes for other parts
    and new driver features).

Staging graduation
- adi,ad7746 CDC. Cleanup conducted against set of roadtest tests using
  the posted RFC of that framework.

Features
- core
  * Large rework to make all the core IIO code use generic firmware properties.
    Includes switching some drivers over as well using newly provided
    generic interfaces and allowing removal of DT specific ones.
  * Support for gesture event types for single and double tap. Used in
    bosch,bma400.
- atmel,at91-sama5d2
  * Add support for temperature sensor which uses two muxed inputs to estimate
    the temperature.
  * Handle trackx bits of EMR register to improve temp sampling accuracy.
  * Runtime PM support.
- liteon,ltrf216a
  * Add a _raw channel output to allow working around an issue with
    differing conversions equations that breaks some user space controls.
- mexelis,mlx90632
  * Support regulator control.
- ti,tsc2046
  * External reference voltage support.

Clean up and minor fixes
- Tree-wide
  * devm_clk_get_enabled() replacements of opencoded equivalent.
  * Remaining IIO_DMA_MINALIGN conversions (the staging/iio drivers).
  * Various minor warning and similar cleanup such as missing static
    markings.
  * strlcpy() to strscpy() for cases where return value not checked.
  * provide units.h entries for more HZ units and use them in drivers.
- dt-bindings cleanup
  * Drop maintainers listss where the email address is bouncing.
  * Switch spi devices over to using spi-peripheral.yaml
  * Add some missing unevaluatedProperties / additionalProperties: false
    entries.
- ABI docs
  * Add some missing channel type specific sampling frequency entries.
  * Add parameter names for callback parameters.
- MAINTAINERS
  * Fix wrong ADI forum links.
- core
  * lockdep class per device, to avoid an issue with nest when one IIO
    device is the consumer of another.
  * White space tweaks.
- asc,dlhl60d
  * Use get_unaligned_be24 to avoid some unusual data manipulation and masking.
- atmel,at91-sama5d2
  * Fix wrong max value.
  * Improve error handling when measuring pressure and touch.
  * Add locks to remove races on updating oversampling / sampling freq.
  * Add missing calls in suspend and resume path to ensure state is correctly
    brought up if buffered capture was in use when suspend happened.
  * Error out of write_raw() callback if buffered capture enabled to avoid
    unpredictable behavior.
  * Handle different versions having different oversampling ratio support and
    drop excess error checking.
  * Cleanup magic value defines where the name is just the value and hence
    hurts readability.
  * Use read_avail() callback to provide info on possible oversampling ratios.
  * Correctly handle variable bit depth when doing oversampling on different
    supported parts. Also handle higher oversampling ratios.
- fsl,imx8qxp
  * Don't ignore errors from regulator_get_voltage() so as to avoid some
    very surprising scaling.
- invensense,icp10100
  * Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS. UNIVERSAL rarely made
    sense and is now deprecated. In this driver we just avoid double disabling
    in some paths.
- maxim,max1363
  * Drop consumer channel map provision by platform data. There have been
    better ways of doing this for years and there are no in tree users.
- microchip,mcp3911
  * Update status to maintained.
- qcom,spmi-adc5
  * Support measurement of LDO output voltage.
- qcom,spmi-adc
  * Add missing channel available on SM6125 SoC.
- st,stmpe
  * Drop requirement on node name in binding now that driver correctly
    doesn't enforce it.
- stx104
  * Move to more appropriate addac directory
- ti,am335x
  * Document ti,am654-adc compatible already in use in tree.
- ti,hmc5843
  * Move dev_pm_ops out of header and use new pm macros to handle export.
- yamaha,yas530
  * Minor cleanups.

* tag 'iio-for-6.1a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (142 commits)
  iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS().
  iio: adc: max1363: Drop provision to provide an IIO channel map via platform data
  iio: accel: bma400: Add support for single and double tap events
  iio: Add new event type gesture and use direction for single and double tap
  iio: Use per-device lockdep class for mlock
  iio: adc: add max11205 adc driver
  dt-bindings: iio: adc: Add max11205 documentation file
  iio: magnetometer: yamaha-yas530: Use dev_err_probe()
  iio: magnetometer: yamaha-yas530: Make strings const in chip info
  iio: magnetometer: yamaha-yas530: Use pointers as driver data
  iio: adc: tsc2046: silent spi_device_id warning
  iio: adc: tsc2046: add vref support
  dt-bindings: iio: adc: ti,tsc2046: add vref-supply property
  iio: light: ltrf216a: Add raw attribute
  dt-bindings: iio: Add missing (unevaluated|additional)Properties on child nodes
  MAINTAINERS: fix Analog Devices forum links
  iio/accel: fix repeated words in comments
  dt-bindings: iio: accel: add dt-binding schema for msa311 accel driver
  iio: add MEMSensing MSA311 3-axis accelerometer driver
  dt-bindings: vendor-prefixes: add MEMSensing Microsystems Co., Ltd.
  ...
2022-09-21 16:04:24 +02:00
Rafael J. Wysocki
e9a7c526c2 thermal: int340x_thermal: Consolidate priv->data_vault checks
It is sufficient to check priv->data_vault once in the error code path
of int3400_thermal_probe(), so do that.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-03 20:23:07 +02:00
Xuewen Yan
cff895277c thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register()
Since the policy needs to be accessed first when obtaining cpu devices,
first check whether the policy is legal before this.

Fixes: 5130802ddb ("thermal: cpu_cooling: Switch to QoS requests for freq limits")
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-03 20:07:36 +02:00
Jilin Yuan
96f1c52992 thermal: Drop duplicate words from comments
Drop duplicate words from two kerneldoc comments in the thermal
subsystem.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
[ rjw: Subject edits and changelog rewrite ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-09-03 19:50:50 +02:00
Jakub Kicinski
60ad1100d5 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
tools/testing/selftests/net/.gitignore
  sort the net-next version and use it

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-09-01 12:58:02 -07:00
Wolfram Sang
1e6c8fb8b8 thermal: move from strlcpy() with unused retval to strscpy()
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-08-31 21:13:35 +02:00
zhaoxiao
1ea252ef29 thermal: da9062-thermal: Drop redundant error message
Since platform_get_irq() already prints an error message on failure, it
is not necessary to print another one for the same purpose.

Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-08-31 20:58:25 +02:00
Jean Delvare
b1a2c4ee8b thermal/drivers/thermal_mmio: Drop of_match_ptr()
Now that the driver depends on OF, we know what of_match_ptr() will
always resolve to, so we might as well save cpp some work.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-08-31 20:50:47 +02:00
Rafael J. Wysocki
72c976fc3a thermal: gov_user_space: Do not lock thermal zone mutex
Commit 670a5e356c ("thermal/core: Move the thermal zone lock out of
the governors") moved thermal zone locking away from governors, but it
forgot about the user space one which deadlocks now.

Fix this by removing the thermal zone locking from the user space
governor.

Fixes: 670a5e356c ("thermal/core: Move the thermal zone lock out of the governors")
Tested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-08-30 20:18:47 +02:00
Jakub Kicinski
9c5d03d362 genetlink: start to validate reserved header bytes
We had historically not checked that genlmsghdr.reserved
is 0 on input which prevents us from using those precious
bytes in the future.

One use case would be to extend the cmd field, which is
currently just 8 bits wide and 256 is not a lot of commands
for some core families.

To make sure that new families do the right thing by default
put the onus of opting out of validation on existing families.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Paul Moore <paul@paul-moore.com> (NetLabel)
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-08-29 12:47:15 +01:00
Rafael J. Wysocki
3bf1b15712 Merge branch 'thermal-core'
Merge thermal control core fixes for 6.0-rc3:

 - Fix missing required property for thermal zone description (Daniel
   Lezcano).

 - Add missing export symbol for
   thermal_zone_device_register_with_trips() (Daniel Lezcano).

* thermal-core:
  dt-bindings: thermal: Fix missing required property
  thermal/core: Add missing EXPORT_SYMBOL_GPL
2022-08-27 15:07:58 +02:00
Lee, Chun-Yi
7931e28098 thermal/int340x_thermal: handle data_vault when the value is ZERO_SIZE_PTR
In some case, the GDDV returns a package with a buffer which has
zero length. It causes that kmemdup() returns ZERO_SIZE_PTR (0x10).

Then the data_vault_read() got NULL point dereference problem when
accessing the 0x10 value in data_vault.

[   71.024560] BUG: kernel NULL pointer dereference, address:
0000000000000010

This patch uses ZERO_OR_NULL_PTR() for checking ZERO_SIZE_PTR or
NULL value in data_vault.

Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-08-23 19:50:43 +02:00
Daniel Lezcano
2f9d142c93 thermal/core: Fix lockdep_assert() warning
The function thermal_zone_device_is_enabled() must be called with the
thermal zone lock held. In the resume path, it is called without.

As the thermal_zone_device_is_enabled() is also checked in
thermal_zone_device_update(), do the check in resume() function is
pointless, except for saving an extra initialization which does not
hurt if it is done in all the cases.

Fixes: ca48ad71717dd ("thermal/core: Move the mutex inside the thermal_zone_device_update() function")
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
2022-08-17 14:09:39 +02:00
Daniel Lezcano
a930da9bf5 thermal/core: Move the mutex inside the thermal_zone_device_update() function
All the different calls inside the thermal_zone_device_update()
function take the mutex.

The previous changes move the mutex out of the different functions,
like the throttling ops. Now that the mutexes are all at the same
level in the call stack for the thermal_zone_device_update() function,
they can be moved inside this one.

That has the benefit of:

1. Simplify the code by not having a plethora of places where the lock is taken

2. Probably closes more race windows because releasing the lock from
one line to another can give the opportunity to the thermal zone to change
its state in the meantime. For example, the thermal zone can be
enabled right after checking it is disabled.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220805153834.2510142-5-daniel.lezcano@linaro.org
2022-08-17 14:09:39 +02:00
Daniel Lezcano
670a5e356c thermal/core: Move the thermal zone lock out of the governors
All the governors throttling ops are taking/releasing the lock at the
beginning and the end of the function.

We can move the mutex to the throttling call site instead.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220805153834.2510142-4-daniel.lezcano@linaro.org
2022-08-17 14:09:39 +02:00
Daniel Lezcano
63561fe36b thermal/governors: Group the thermal zone lock inside the throttle function
The thermal zone lock is taken in the different places in the
throttling path.

At the first glance it does not hurt to move them at the beginning and
the end of the 'throttle' function. That will allow a consolidation of
the lock in the next following changes.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220805153834.2510142-3-daniel.lezcano@linaro.org
2022-08-17 14:09:39 +02:00
Daniel Lezcano
15a73839e3 thermal/core: Rework the monitoring a bit
The should_stop_polling() function wraps the function
thermal_zone_device_is_enabled().

The monitor_thermal_zone() function checks if the thermal zone is
enabled via the should_stop_polling() function.

However, the instant after checking the thermal zone is enabled, this
one can be disabled, so even if that reduces the race window, it does
not prevent that and the monitoring can be set again with the thermal
zone disabled.

For this reason, the function should_stop_polling() is replaced by a
direct check of the thermal zone mode with the mutex locks held, that
prevents the situation described above.

As the semantic is clear with the thermal_zone_is_enabled() function,
we can remove the should_stop_polling() function and replace the check
with the former function.

While at it, reorder the checks to improve the readability of the
monitor_thermal_zone() function.

In the future, the thermal_zone_device_disable() and the
thermal_zone_device_enable() functions should unset / set the polling
timer directly instead of relying on the next
thermal_zone_device_update() call to do that. That will make a
synchronous thermal zone mode change but the locking scheme should be
double checked for that which out of the scope of this change.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220805153834.2510142-2-daniel.lezcano@linaro.org
2022-08-17 14:09:39 +02:00
Daniel Lezcano
9662756a9a thermal/core: Rearm the monitoring only one time
The current code calls monitor_thermal_zone() inside the
handle_thermal_trip() function. But this one is called in a loop for
each trip point which means the monitoring is rearmed several times
for nothing (assuming there could be several passive and active trip
points).

Move the monitor_thermal_zone() function out of the
handle_thermal_trip() function and after the thermal trip loop, so the
timer will be disabled or rearmed one time.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220805153834.2510142-1-daniel.lezcano@linaro.org
2022-08-17 14:09:39 +02:00
Jiapeng Chong
e920209847 thermal/drivers/qcom/spmi-adc-tm5: Remove unnecessary print function dev_err()
The print function dev_err() is redundant because platform_get_irq()
already prints an error.

./drivers/thermal/qcom/qcom-spmi-adc-tm5.c:1029:2-9: line 1029 is redundant because platform_get_irq() already prints an error.

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=1846
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220809034346.128607-1-jiapeng.chong@linux.alibaba.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:39 +02:00
Daniel Lezcano
f59ac19b7f thermal/of: Remove old OF code
All the drivers are converted to the new OF API, remove the old OF code.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-34-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:39 +02:00
Daniel Lezcano
9326167058 thermal/core: Move set_trip_temp ops to the sysfs code
Given the trip points can be set in the thermal zone structure, there
is no need of a specific OF function to do that. Move the code in the
place where it is generic, in the sysfs set_trip_temp storing
function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-33-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:39 +02:00
Daniel Lezcano
7ea98f70c7 thermal/drivers/samsung: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-32-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:39 +02:00
Daniel Lezcano
2cf3c72a3f thermal/drivers/ti-soc: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-25-daniel.lezcano@linexp.org
Acked-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
5ee7811e9a thermal/drivers/hisilicon: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-24-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
ae11d6a87c thermal/drivers/maxim: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-23-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
b86105ed9f thermal/drivers/banggap: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-22-daniel.lezcano@linexp.org
Reviewed-by: Bryan Brattlof <bb@ti.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
ab7e865db9 thermal/drivers/mtk: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220804224349.1926752-21-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
3e7494b41c thermal/drivers/qoriq: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-20-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
396cbbc6b7 thermal/drivers/rzg2l: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-19-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
2ebd4f2f2e thermal/drivers/rcar: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20220804224349.1926752-18-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
32fb9a8a9d thermal/drivers/imx: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-17-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
2320be6032 thermal/drivers/db8500: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-16-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
e4a1150e3e thermal/drivers/armada: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-15-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
1240fd6512 thermal/drivers/amlogic: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-14-daniel.lezcano@linexp.org
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
7e96f35408 thermal/drivers/st: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-13-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
ca1b9a9eb3 thermal/drivers/qcom: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-12-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
944441d878 thermal/drivers/broadcom: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220804224349.1926752-11-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00
Daniel Lezcano
7f689a2ef4 thermal/drivers/sprd: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-10-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2022-08-17 14:09:38 +02:00