Commit Graph

3313 Commits

Author SHA1 Message Date
Linus Torvalds
a970ed1881 bitmap updates for v7.1
- new API: bitmap_weight_from() and bitmap_weighted_xor() (Yury);
  - drop unused __find_nth_andnot_bit() (Yury);
  - new tests and test improvements (Andy, Akinobu, Yury);
  - fixes for count_zeroes API (Yury);
  - cleanup bitmap_print_to_pagebuf() mess (Yury);
  - documentation updates (Andy, Kai, Kit).
 -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEi8GdvG6xMhdgpu/4sUSA/TofvsgFAmnb8vkACgkQsUSA/Tof
 vsjzKgv/RI6HDkwRgjT/jPVAZzaNFrdoL0nIQ1ZriyE70b/0HtjMzbQBO0P3Vmsa
 5k13Nus0eBi9CeEAK0NvjQXy8NRj4E7favqF3faV7l4+J6STHpOKeHZglUAj00CG
 +23WGInz+TS5RBjXnvT00wuTAVQjT6dvYng9606psVDF/nlh8ZtXmYDjLauseoUH
 a1EEKwLGXbk3/MhDgVq/R5RvZoNscL4Hky7QWMZiqLutwF8EDrZotF142tfbxkmW
 mu+2Bn1W66F+8A42HJBDRevcuvsRzMggP2kXxDk50XNL1zTN9f/4iE0r+/5x8UVF
 s3WiGnuLSkRIK4osey12Z9BAtGJTn3gTPvIPYOWvRiJHskOa1yvGSgcvmzc53x0Q
 FZgDq1JkBDsF3OZceSjGIp9QOqg+YJArlzun+mNxLbfnahEbhx21Z/ls65vLJCae
 ENIPAzet5Fxa8mZeJIyiV0zR05DcV+g64FOhcGJ7al4fRWtYVP8qa9FAyGFMV4L2
 JL4xHuRO
 =pEBo
 -----END PGP SIGNATURE-----

Merge tag 'bitmap-for-v7.1' of https://github.com/norov/linux

Pull bitmap updates from Yury Norov:

 - new API: bitmap_weight_from() and bitmap_weighted_xor() (Yury)

 - drop unused __find_nth_andnot_bit() (Yury)

 - new tests and test improvements (Andy, Akinobu, Yury)

 - fixes for count_zeroes API (Yury)

 - cleanup bitmap_print_to_pagebuf() mess (Yury)

 - documentation updates (Andy, Kai, Kit).

* tag 'bitmap-for-v7.1' of https://github.com/norov/linux: (24 commits)
  bitops: Update kernel-doc for sign_extendXX()
  powerpc/xive: simplify xive_spapr_debug_show()
  thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf()
  coresight: don't use bitmap_print_to_pagebuf()
  lib/prime_numbers: drop temporary buffer in dump_primes()
  drm/xe: switch xe_pagefault_queue_init() to using bitmap_weighted_or()
  ice: use bitmap_empty() in ice_vf_has_no_qs_ena
  ice: use bitmap_weighted_xor() in ice_find_free_recp_res_idx()
  bitmap: introduce bitmap_weighted_xor()
  bitmap: add test_zero_nbits()
  bitmap: exclude nbits == 0 cases from bitmap test
  bitmap: test bitmap_weight() for more
  asm-generic/bitops: Fix a comment typo in instrumented-atomic.h
  bitops: fix kernel-doc parameter name for parity8()
  lib: count_zeros: unify count_{leading,trailing}_zeros()
  lib: count_zeros: fix 32/64-bit inconsistency in count_trailing_zeros()
  lib: crypto: fix comments for count_leading_zeros()
  x86/topology: use bitmap_weight_from()
  bitmap: add bitmap_weight_from()
  lib/find_bit_benchmark: avoid clearing randomly filled bitmap in test_find_first_bit()
  ...
2026-04-14 08:55:18 -07:00
Linus Torvalds
fbfb6bd927 Thermal control updates for 7.1-rc1
- Fix thermal core issues related to thermal zone removal and
    registration errors that may lead to a use-after-free or a memory
    leak in some cases (Rafael Wysocki)
 
  - Drop a redundant check from thermal_zone_device_update(), adjust
    thermal workqueue allocation flags, and switch over thermal_class
    allocation to static (Rafael Wysocki)
 
  - Relocate the suspend and resume of thermal zones closer to the
    suspend and resume of devices, respectively (Rafael Wysocki)
 
  - Remove a pointless variable used in the thermal core when
    registering a cooling device (Daniel Lezcano)
 
  - Replace sprintf() in thermal_bind_cdev_to_trip() and use
    str_enabled_disabled() helper in mode_show() (Thorsten Blum)
 
  - Replace cpumask_weight() in intel_hfi_offline() with cpumask_empty()
    which is generally more efficient (Yury Norov)
 
  - Add support for reading DDR data rate from PCI config space on Nova
    Lake platforms to the int340x thermal driver (Srinivas Pandruvada)
 
  - Add an OF node address to output message to make sensor names more
    distinguishable (Alexander Stein)
 
  - Add hwmon support for the i.MX97 thermal sensor (Alexander Stein)
 
  - Clamp correctly the results when doing value/temperature conversion
    in the Spreadtrum driver (Thorsten Blum)
 
  - Add SDM670 compatible DT bindings for the Tsens and the lMH thermal
    drivers (Richard Acayan)
 
  - Add SM8750 compatible DT bindings for the Tsens thermal driver (Manaf
    Meethalavalappu Pallikunhi)
 
  - Add Eliza SoC compatible DT bindings for the Tsens driver (Krzysztof
    Kozlowski)
 
  - Fix inverted condition check on error in the Spear thermal control
    driver (Gopi Krishna Menon)
 
  - Convert DT bindings documentation into DT schema (Gopi Krishna Menon)
 
  - Use max() macro to increase readability in the Broadcom STB thermal
    sensor (Thorsten Blum)
 
  - Remove a stale @trim_offset kernel-doc entry (John Madieu)
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEcM8Aw/RY0dgsiRUR7l+9nS/U47UFAmnZBFwSHHJqd0Byand5
 c29ja2kubmV0AAoJEO5fvZ0v1OO1CIAH/jT/z4QMvfBCIlTgwTN6ArqmbEPBoufI
 yhwyH/9gYEoJ5qvBBYWRu+NbiKIcQGdQ4bIVMbrYREqUAqZtD0ICTyysWKyxN0xC
 2Y+a1uyx5Q73Ac4s2+GNhNIykpFLeODSkHX4wHmA8DSjCdSLvqtfewK09XxoFKiP
 Gdb1mhihdEQREC2nfqOpWtxeRp90AK3Ak1Obvf4+95i2KYrQgrmaxXIGFH1Q7IQu
 4Va4/7ZEdFPmBTS3vpI3wNjFb5SDHtaP8/FUc/vVohs7if4mGT2JI94oE5ic/+bc
 RpCHvii51hHIs0VUJAqkzJwNIH1/3F3UDbiJtkV0sW9tYj02I8dLYPM=
 =m1xx
 -----END PGP SIGNATURE-----

Merge tag 'thermal-7.1-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 and simplifications, driver fixes and
  new hardware support (SDM670, Eliza SoC), new driver features (hwmon
  support in imx91, DDR data rate on Nova Lake in int340x), and a
  handful of cleanups:

   - Fix thermal core issues related to thermal zone removal and
     registration errors that may lead to a use-after-free or a memory
     leak in some cases (Rafael Wysocki)

   - Drop a redundant check from thermal_zone_device_update(), adjust
     thermal workqueue allocation flags, and switch over thermal_class
     allocation to static (Rafael Wysocki)

   - Relocate the suspend and resume of thermal zones closer to the
     suspend and resume of devices, respectively (Rafael Wysocki)

   - Remove a pointless variable used in the thermal core when
     registering a cooling device (Daniel Lezcano)

   - Replace sprintf() in thermal_bind_cdev_to_trip() and use
     str_enabled_disabled() helper in mode_show() (Thorsten Blum)

   - Replace cpumask_weight() in intel_hfi_offline() with
     cpumask_empty() which is generally more efficient (Yury Norov)

   - Add support for reading DDR data rate from PCI config space on Nova
     Lake platforms to the int340x thermal driver (Srinivas Pandruvada)

   - Add an OF node address to output message to make sensor names more
     distinguishable (Alexander Stein)

   - Add hwmon support for the i.MX97 thermal sensor (Alexander Stein)

   - Clamp correctly the results when doing value/temperature conversion
     in the Spreadtrum driver (Thorsten Blum)

   - Add SDM670 compatible DT bindings for the Tsens and the lMH thermal
     drivers (Richard Acayan)

   - Add SM8750 compatible DT bindings for the Tsens thermal driver
     (Manaf Meethalavalappu Pallikunhi)

   - Add Eliza SoC compatible DT bindings for the Tsens driver
     (Krzysztof Kozlowski)

   - Fix inverted condition check on error in the Spear thermal control
     driver (Gopi Krishna Menon)

   - Convert DT bindings documentation into DT schema (Gopi Krishna
     Menon)

   - Use max() macro to increase readability in the Broadcom STB thermal
     sensor (Thorsten Blum)

   - Remove a stale @trim_offset kernel-doc entry (John Madieu)"

* tag 'thermal-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (25 commits)
  thermal: renesas: rzg3e: Remove stale @trim_offset kernel-doc entry
  thermal: core: Suspend thermal zones later and resume them earlier
  thermal: core: Allocate thermal_class statically
  thermal: core: Adjust thermal_wq allocation flags
  thermal: core: Drop redundant check from thermal_zone_device_update()
  thermal: core: Free thermal zone ID later during removal
  thermal: core: Fix thermal zone governor cleanup issues
  thermal/core: Remove pointless variable when registering a cooling device
  thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp
  dt-bindings: thermal: st,thermal-spear1340: convert to dtschema
  thermal/drivers/spear: Fix error condition for reading st,thermal-flags
  dt-bindings: thermal: qcom-tsens: Add Eliza SoC TSENS
  thermal: devfreq_cooling: avoid unnecessary kfree of freq_table
  thermal: intel: hfi: use cpumask_empty() in intel_hfi_offline()
  thermal: sysfs: Use str_enabled_disabled() helper in mode_show()
  dt-bindings: thermal: qcom-tsens: Document the SM8750 Temperature Sensor
  thermal/drivers/sprd: Use min instead of clamp in sprd_thm_temp_to_rawdata
  dt-bindings: thermal: lmh: Add SDM670 compatible
  dt-bindings: thermal: tsens: add SDM670 compatible
  thermal/drivers/sprd: Fix raw temperature clamping in sprd_thm_rawdata_to_temp
  ...
2026-04-13 20:01:50 -07:00
Rafael J. Wysocki
cd1a3b2ff0 - Added an OF node address to output message to make sensor names more
distinguishable (Alexander Stein)
 
 - Added hwmon support for the i.MX97 thermal sensor (Alexander Stein)
 
 - Clamped correctly the results when doing value/temperature conversion
   in the Spreadtrum driver (Thorsten Blum)
 
 - Added the SDM670 compatible DT bindings for the Tsens and the lMH
   drivers (Richard Acayan)
 
 - Added the SM8750 compatible DT bindings for the Tsens (Manaf
   Meethalavalappu Pallikunhi)
 
 - Added the Eliza SoC compatible DT bindings for the Tsens (Krzysztof
   Kozlowski)
 
 - Fixed inverted condition check on error in the Spear driver (Gopi
   Krishna Menon)
 
 - Converted the DT bindings documentation into DT schema (Gopi Krishna
   Menon)
 
 - Used max() macro to increase readibility in the Broadcom STB thermal
   sensor (Thorsten Blum)
 
 - Removed stale @trim_offset kernel-doc entry (John Madieu)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAmnYCGgACgkQqDIjiipP
 6E/kmggAtjYN7sQbXpebUEqT0BSEcTE+6lhRFdOF+8+MBC3cWuXTMN9ruO5MoliG
 XxkiF9wg81oH55QQ3HEugFf9wIwqFJKwDsc0zDGv+5C2k8qcAWn6CmH5DDYGjR2K
 PW6xVAeFcvsZi8MBL9+Jf+db7WjAKfh+zokbsV0oo0jByf/cxPuSAdaCPlpkrWNq
 0Fv+LaqGJPYS7It7VQMjPD3vjInbUnl/CEngoggwXZQYzL/wjPdcUpwgTSP3xY40
 mRmEdY+ykrLOF+CL10L93ZeeJDEYaeZiecYBGRqCvPuW8VusYM5c8AI0orQZpz2W
 7i4X18HSInK0cZ9nddXG4IFbNUKIcA==
 =mVCt
 -----END PGP SIGNATURE-----

Merge tag 'thermal-v7.1-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux

Merge updates of assorted thermal drivers for 7.1-rc1 from Daniel
Lezcano:

"- Added an OF node address to output message to make sensor names more
   distinguishable (Alexander Stein)

 - Added hwmon support for the i.MX97 thermal sensor (Alexander Stein)

 - Clamped correctly the results when doing value/temperature conversion
   in the Spreadtrum driver (Thorsten Blum)

 - Added the SDM670 compatible DT bindings for the Tsens and the lMH
   drivers (Richard Acayan)

 - Added the SM8750 compatible DT bindings for the Tsens (Manaf
   Meethalavalappu Pallikunhi)

 - Added the Eliza SoC compatible DT bindings for the Tsens (Krzysztof
   Kozlowski)

 - Fixed inverted condition check on error in the Spear driver (Gopi
   Krishna Menon)

 - Converted the DT bindings documentation into DT schema (Gopi Krishna
   Menon)

 - Used max() macro to increase readibility in the Broadcom STB thermal
   sensor (Thorsten Blum)

 - Removed stale @trim_offset kernel-doc entry (John Madieu)"

* tag 'thermal-v7.1-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
  thermal: renesas: rzg3e: Remove stale @trim_offset kernel-doc entry
  thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp
  dt-bindings: thermal: st,thermal-spear1340: convert to dtschema
  thermal/drivers/spear: Fix error condition for reading st,thermal-flags
  dt-bindings: thermal: qcom-tsens: Add Eliza SoC TSENS
  dt-bindings: thermal: qcom-tsens: Document the SM8750 Temperature Sensor
  thermal/drivers/sprd: Use min instead of clamp in sprd_thm_temp_to_rawdata
  dt-bindings: thermal: lmh: Add SDM670 compatible
  dt-bindings: thermal: tsens: add SDM670 compatible
  thermal/drivers/sprd: Fix raw temperature clamping in sprd_thm_rawdata_to_temp
  thermal/drivers/sprd: Fix temperature clamping in sprd_thm_temp_to_rawdata
  thermal/drivers/imx91: Add hwmon support
  thermal/of: Add OF node address to output message
2026-04-10 13:00:36 +02:00
Rafael J. Wysocki
2bd33eb507 Merge branch 'pm-powercap'
Merge power capping updates for 7.1-rc1:

 - Clean up and rearrange the intel_rapl power capping driver to make
   the respective interface drivers (TPMI, MSR, and MMOI) hold their
   own settings and primitives and consolidate PL4 and PMU support
   flags into rapl_defaults (Kuppuswamy Sathyanarayanan)

 - Correct kernel-doc function parameter names in the power capping core
   code (Randy Dunlap)

* pm-powercap:
  powercap: intel_rapl: Consolidate PL4 and PMU support flags into rapl_defaults
  powercap: intel_rapl: Move MSR primitives to MSR driver
  thermal: intel: int340x: processor: Move MMIO primitives to MMIO driver
  powercap: intel_rapl: Move TPMI primitives to TPMI driver
  powercap: intel_rapl: Move primitive info to header for interface drivers
  powercap: intel_rapl: Remove unused macro definitions
  powercap: intel_rapl: Move MSR default settings into MSR interface driver
  powercap: intel_rapl: Remove unused AVERAGE_POWER primitive
  powercap: correct kernel-doc function parameter names
  thermal: intel: int340x: processor: Move RAPL defaults to MMIO driver
  powercap: intel_rapl: Move TPMI default settings into TPMI interface driver
  powercap: intel_rapl: Allow interface drivers to configure rapl_defaults
  powercap: intel_rapl: Use unit conversion macros from units.h
  powercap: intel_rapl: Use GENMASK() and BIT() macros
  powercap: intel_rapl: Use shifts for power-of-2 operations
  powercap: intel_rapl: Simplify rapl_compute_time_window_atom()
  powercap: intel_rapl: Remove unused TIME_WINDOW macros
  powercap: intel_rapl: Cleanup coding style
  powercap: intel_rapl: Add a symbol namespace for intel_rapl exports
2026-04-10 12:43:10 +02:00
John Madieu
bf746e2a41 thermal: renesas: rzg3e: Remove stale @trim_offset kernel-doc entry
The trim_offset field was removed from struct rzg3e_thermal_priv but
its kernel-doc entry was left behind. Remove it to fix the mismatch.

Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Link: https://patch.msgid.link/20260409125916.2244241-1-john.madieu.xa@bp.renesas.com
2026-04-09 21:47:15 +02:00
Yury Norov
f3d8bb9425 thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf()
The function opencodes cpumask_print_to_pagebuf() with more generic
bitmap_print_to_pagebuf(). Switch to using the proper API.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
2026-04-09 13:28:05 -04:00
Rafael J. Wysocki
ecc26ba41c Merge branch 'thermal-intel'
Merge updates of Intel thermal drivers for 7.1:

 - Replace cpumask_weight() in intel_hfi_offline() with cpumask_empty()
   which is generally more efficient (Yury Norov)

 - Add support for reading DDR data rate from PCI config space on Nova
   Lake platforms to the int340x thermal driver (Srinivas Pandruvada)

* thermal-intel:
  thermal: intel: hfi: use cpumask_empty() in intel_hfi_offline()
  thermal: intel: int340x: Read DDR data rate for Nova Lake
2026-04-08 12:31:06 +02:00
Rafael J. Wysocki
d33e89d122 thermal: core: Suspend thermal zones later and resume them earlier
To avoid some undesirable interactions between thermal zone suspend
and resume with user space that is running when those operations are
carried out, move them closer to the suspend and resume of devices,
respectively, by updating dpm_prepare() to carry out thermal zone
suspend and dpm_complete() to start thermal zone resume (that will
continue asynchronously).

This also makes the code easier to follow by removing one, arguably
redundant, level of indirection represented by the thermal PM notifier.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/2036875.PYKUYFuaPT@rafael.j.wysocki
2026-04-08 12:30:31 +02:00
Rafael J. Wysocki
c4c6a86463 thermal: core: Allocate thermal_class statically
Define thermal_class as a static structure to simplify thermal_init()
and to simplify thermal class availability checks that will need to
be carried out during the suspend and resume of thermal zones after
subsequent changes.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/10831981.nUPlyArG6x@rafael.j.wysocki
2026-04-08 12:30:31 +02:00
Rafael J. Wysocki
26fd03effa thermal: core: Adjust thermal_wq allocation flags
The thermal workqueue doesn't need to be freezable or per-CPU, so drop
WQ_FREEZABLE and WQ_PERCPU from the flags when allocating it.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ rjw: Subject rewrite ]
Link: https://patch.msgid.link/3413335.44csPzL39Z@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-04-08 12:30:31 +02:00
Rafael J. Wysocki
323803ac63 thermal: core: Drop redundant check from thermal_zone_device_update()
Since __thermal_zone_device_update() checks if tz->state is
TZ_STATE_READY and bails out immediately otherwise, it is not
necessary to check the thermal_zone_is_present() return value in
thermal_zone_device_update().  Namely, tz->state is equal to
TZ_STATE_FLAG_INIT initially and that flag is only cleared in
thermal_zone_init_complete() after adding tz to the list of thermal
zones, and thermal_zone_exit() sets TZ_STATE_FLAG_EXIT in tz->state
while removing tz from that list.  Thus tz->state is not TZ_STATE_READY
when tz is not in the list and the check mentioned above is redundant.

Accordingly, drop the redundant thermal_zone_is_present() check from
thermal_zone_device_update() and drop the former altogether because it
has no more users.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/3406806.aeNJFYEL58@rafael.j.wysocki
2026-04-08 12:30:31 +02:00
Rafael J. Wysocki
daae9c18fe thermal: core: Free thermal zone ID later during removal
The thermal zone removal ordering is different from the thermal zone
registration rollback path ordering and the former is arguably
problematic because freeing a thermal zone ID prematurely may cause
it to be used during the registration of another thermal zone which
may fail as a result.

Prevent that from occurring by changing the thermal zone removal
ordering to reflect the thermal zone registration rollback path
ordering.

Also more the ida_destroy() call from thermal_zone_device_unregister()
to thermal_release() for consistency.

Fixes: b31ef8285b ("thermal core: convert ID allocation to IDA")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5063934.GXAFRqVoOG@rafael.j.wysocki
2026-04-08 12:30:30 +02:00
Rafael J. Wysocki
41ff66baf8 thermal: core: Fix thermal zone governor cleanup issues
If thermal_zone_device_register_with_trips() fails after adding
a thermal governor to the thermal zone being registered, the
governor is not removed from it as appropriate which may lead to
a memory leak.

In turn, thermal_zone_device_unregister() calls thermal_set_governor()
without acquiring the thermal zone lock beforehand which may race with
a governor update via sysfs and may lead to a use-after-free in that
case.

Address these issues by adding two thermal_set_governor() calls, one to
thermal_release() to remove the governor from the given thermal zone,
and one to the thermal zone registration error path to cover failures
preceding the thermal zone device registration.

Fixes: e33df1d2f3 ("thermal: let governors have private data for each thermal zone")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5092923.31r3eYUQgx@rafael.j.wysocki
2026-04-08 12:30:30 +02:00
Daniel Lezcano
761fdf4c8c thermal/core: Remove pointless variable when registering a cooling device
The 'id' variable is set to store the ida_alloc() value which is
already stored into cdev->id. It is pointless to use it because
cdev->id can be used instead.

Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20260402084426.1360086-1-daniel.lezcano@kernel.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-04-04 15:05:18 +02:00
Rafael J. Wysocki
49c7db1f0b Merge back earlier thermal core updates for 7.1 2026-04-04 14:59:43 +02:00
Thorsten Blum
29cbf826d5 thermal/drivers/brcmstb_thermal: Use max to simplify brcmstb_get_temp
Use max() to simplify brcmstb_get_temp() and improve its readability.
Since avs_tmon_code_to_temp() returns an int, change the data type of
the local variable 't' from long to int.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20260402165616.895305-3-thorsten.blum@linux.dev
2026-04-02 19:23:54 +02:00
Rafael J. Wysocki
9e07e3b818 thermal: core: Fix thermal zone device registration error path
If thermal_zone_device_register_with_trips() fails after registering
a thermal zone device, it needs to wait for the tz->removal completion
like thermal_zone_device_unregister(), in case user space has managed
to take a reference to the thermal zone device's kobject, in which case
thermal_release() may not be called by the error path itself and tz may
be freed prematurely.

Add the missing wait_for_completion() call to the thermal zone device
registration error path.

Fixes: 04e6ccfc93 ("thermal: core: Fix NULL pointer dereference in zone registration error path")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/2849815.mvXUDI8C0e@rafael.j.wysocki
2026-04-02 11:37:35 +02:00
Kuppuswamy Sathyanarayanan
d7a718fff3 thermal: intel: int340x: processor: Move MMIO primitives to MMIO driver
MMIO-specific primitives differ from those used by the TPMI interface.
The MSR and MMIO interfaces shared the same primitives in the common
driver, but MMIO does not require many MSR-specific entries (like PSYS).
Keeping these in the common driver does not add any value and requires
interface-specific handling logic that makes the common layer
unnecessarily complex.

Move the MMIO primitive definitions and associated bitmasks into the
MMIO interface driver. This change includes:

 1. Add MMIO-local struct rapl_primitive_info instance without
    MSR-specific entries and assign it to priv->rpi during MMIO
    initialization.
 2. Remove the RAPL MMIO case from rapl_config() in the common driver.

No functional changes are intended.

Co-developed-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/20260331211950.3329932-6-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-04-01 16:03:05 +02:00
Rafael J. Wysocki
45b859b072 thermal: core: Address thermal zone removal races with resume
Since thermal_zone_pm_complete() and thermal_zone_device_resume()
re-initialize the poll_queue delayed work for the given thermal zone,
the cancel_delayed_work_sync() in thermal_zone_device_unregister()
may miss some already running work items and the thermal zone may
be freed prematurely [1].

There are two failing scenarios that both start with
running thermal_pm_notify_complete() right before invoking
thermal_zone_device_unregister() for one of the thermal zones.

In the first scenario, there is a work item already running for
the given thermal zone when thermal_pm_notify_complete() calls
thermal_zone_pm_complete() for that thermal zone and it continues to
run when thermal_zone_device_unregister() starts.  Since the poll_queue
delayed work has been re-initialized by thermal_pm_notify_complete(), the
running work item will be missed by the cancel_delayed_work_sync() in
thermal_zone_device_unregister() and if it continues to run past the
freeing of the thermal zone object, a use-after-free will occur.

In the second scenario, thermal_zone_device_resume() queued up by
thermal_pm_notify_complete() runs right after the thermal_zone_exit()
called by thermal_zone_device_unregister() has returned.  The poll_queue
delayed work is re-initialized by it before cancel_delayed_work_sync() is
called by thermal_zone_device_unregister(), so it may continue to run
after the freeing of the thermal zone object, which also leads to a
use-after-free.

Address the first failing scenario by ensuring that no thermal work
items will be running when thermal_pm_notify_complete() is called.
For this purpose, first move the cancel_delayed_work() call from
thermal_zone_pm_complete() to thermal_zone_pm_prepare() to prevent
new work from entering the workqueue going forward.  Next, switch
over to using a dedicated workqueue for thermal events and update
the code in thermal_pm_notify() to flush that workqueue after
thermal_pm_notify_prepare() has returned which will take care of
all leftover thermal work already on the workqueue (that leftover
work would do nothing useful anyway because all of the thermal zones
have been flagged as suspended).

The second failing scenario is addressed by adding a tz->state check
to thermal_zone_device_resume() to prevent it from re-initializing
the poll_queue delayed work if the thermal zone is going away.

Note that the above changes will also facilitate relocating the suspend
and resume of thermal zones closer to the suspend and resume of devices,
respectively.

Fixes: 5a5efdaffd ("thermal: core: Resume thermal zones asynchronously")
Reported-by: syzbot+3b3852c6031d0f30dfaf@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=3b3852c6031d0f30dfaf
Reported-by: Mauricio Faria de Oliveira <mfo@igalia.com>
Closes: https://lore.kernel.org/linux-pm/20260324-thermal-core-uaf-init_delayed_work-v1-1-6611ae76a8a1@igalia.com/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mauricio Faria de Oliveira <mfo@igalia.com>
Tested-by: Mauricio Faria de Oliveira <mfo@igalia.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Cc: All applicable <stable@vger.kernel.org>
Link: https://patch.msgid.link/6267615.lOV4Wx5bFT@rafael.j.wysocki
2026-03-31 13:54:03 +02:00
Rafael J. Wysocki
d8d3e49b38 Merge back earlier Intel thermal drivers updates for 7.1 2026-03-27 18:15:53 +01:00
Gopi Krishna Menon
da2c4f332a thermal/drivers/spear: Fix error condition for reading st,thermal-flags
of_property_read_u32 returns 0 on success. The current check returns
-EINVAL if the property is read successfully.

Fix the check by removing ! from of_property_read_u32

Fixes: b9c7aff481 ("drivers/thermal/spear_thermal.c: add Device Tree probing capability")
Signed-off-by: Gopi Krishna Menon <krishnagopi487@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Suggested-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20260327090526.59330-1-krishnagopi487@gmail.com
2026-03-27 11:26:43 +01:00
Srinivas Pandruvada
7dfe984601 thermal: intel: int340x: soc_slider: Set offset only for balanced mode
The slider offset can be set via debugfs for balanced mode. The offset
should be only applicable in balanced mode. For other modes, it should
be 0 when writing to MMIO offset,

Fixes: 8306bcaba0 ("thermal: intel: int340x: Add module parameter to change slider offset")
Tested-by: Erin Park <erin.park@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 6.18+ <stable@vger.kernel.org> # 6.18+
[ rjw: Subject and changelog tweaks ]
Link: https://patch.msgid.link/20260324172346.3317145-1-srinivas.pandruvada@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-24 19:00:12 +01:00
Anas Iqbal
945471425a thermal: devfreq_cooling: avoid unnecessary kfree of freq_table
dfc->freq_table is only allocated in the non-EM path via
devfreq_cooling_gen_tables(). In the EM path, it remains NULL.

Avoid calling kfree() unnecessarily when freq_table was never allocated.

This resolves a Smatch warning:
calling kfree() when 'dfc->freq_table' is always NULL.

Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20260323094018.2264-1-mohd.abd.6602@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-23 14:51:06 +01:00
Yury Norov
40927abf2f thermal: intel: hfi: use cpumask_empty() in intel_hfi_offline()
cpumask_empty() is more efficient as it may return earlier.

Switch to using it.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
Link: https://patch.msgid.link/20260314191016.603067-1-ynorov@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-19 19:17:46 +01:00
Thorsten Blum
2dc1b0dd4b thermal: sysfs: Use str_enabled_disabled() helper in mode_show()
Replace hard-coded strings with the str_enabled_disabled() helper.

This unifies the output and helps the linker with deduplication, which
may result in a smaller binary.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
[ rjw: Subject and changelog tweaks ]
Link: https://patch.msgid.link/20260311164212.405981-3-thorsten.blum@linux.dev
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-14 12:15:56 +01:00
Thorsten Blum
94ff50f414 thermal/drivers/sprd: Use min instead of clamp in sprd_thm_temp_to_rawdata
Clamping 'val' to itself is unnecessary and the expression can be
simplified by using min() instead. Casting SPRD_THM_RAW_DATA_HIGH to u32
is also redundant and can be removed.

Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260310102523.201722-3-thorsten.blum@linux.dev
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2026-03-10 11:54:12 +01:00
Thorsten Blum
b3414148bb thermal/drivers/sprd: Fix raw temperature clamping in sprd_thm_rawdata_to_temp
The raw temperature data was never clamped to SPRD_THM_RAW_DATA_LOW or
SPRD_THM_RAW_DATA_HIGH because the return value of clamp() was not used.
Fix this by assigning the clamped value to 'rawdata'.

Casting SPRD_THM_RAW_DATA_LOW and SPRD_THM_RAW_DATA_HIGH to u32 is also
redundant and can be removed.

Fixes: 554fdbaf19 ("thermal: sprd: Add Spreadtrum thermal driver support")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260307102422.306055-2-thorsten.blum@linux.dev
2026-03-10 00:12:46 +01:00
Thorsten Blum
83c0f9a5d6 thermal/drivers/sprd: Fix temperature clamping in sprd_thm_temp_to_rawdata
The temperature was never clamped to SPRD_THM_TEMP_LOW or
SPRD_THM_TEMP_HIGH because the return value of clamp() was not used. Fix
this by assigning the clamped value to 'temp'.

Casting SPRD_THM_TEMP_LOW and SPRD_THM_TEMP_HIGH to int is also
redundant and can be removed.

Fixes: 554fdbaf19 ("thermal: sprd: Add Spreadtrum thermal driver support")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260307102422.306055-1-thorsten.blum@linux.dev
2026-03-10 00:12:19 +01:00
Alexander Stein
a3618f3ca6 thermal/drivers/imx91: Add hwmon support
Expose thermal readings as a HWMON device, so that it could be
accessed using lm-sensors.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Link: https://patch.msgid.link/20260306133017.3189979-1-alexander.stein@ew.tq-group.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2026-03-10 00:12:19 +01:00
Alexander Stein
d161cbd685 thermal/of: Add OF node address to output message
Temperature sensors are supposed to have the DT node name
temperature-sensors. Having multiple ones the node name alone isn't very
helpful. Add the node address to make them more distinguishable.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20260305163508.2643106-1-alexander.stein@ew.tq-group.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
2026-03-10 00:12:19 +01:00
Thorsten Blum
5ddd020b8b thermal: core: Replace sprintf() in thermal_bind_cdev_to_trip()
Replace unbounded sprintf() with the safer snprintf(). While the
current code works correctly, snprintf() is safer and follows secure
coding best practices.

No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
[ rjw: Subject tweaks ]
Link: https://patch.msgid.link/20260223073245.321298-2-thorsten.blum@linux.dev
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-06 17:57:58 +01:00
Kuppuswamy Sathyanarayanan
f82fabe18c thermal: intel: int340x: processor: Move RAPL defaults to MMIO driver
Previously, the MMIO and MSR RAPL interfaces shared the same set of
RAPL defaults provided by common code. However, unlike the MSR
interface, the MMIO RAPL interface does not require CPU-specific
variations in its default handling. Keeping the RAPL defaults in
the RAPL common driver therefore provides no additional benefit.

Move the MMIO defaults into the MMIO interface driver. This change
includes the following updates:

  * Introduce a MMIO-local rapl_defaults instance with the appropriate
    default callbacks.
  * Assign the MMIO-specific rapl_defaults to priv->defaults during
    MMIO driver initialization.

No functional changes are expected.

Co-developed-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20260212233044.329790-11-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-05 15:52:39 +01:00
Kuppuswamy Sathyanarayanan
13060743a4 powercap: intel_rapl: Add a symbol namespace for intel_rapl exports
Cleanup of the intel_rapl common driver requires introducing additional
exported helper and lifecycle functions. Before adding new exports,
create a dedicated symbol namespace for intel_rapl and update the
relevant interface drivers to explicitly import it.

This makes the intended usage of these symbols explicit, avoids
polluting the global namespace, and prepares the codebase for the
ongoing RAPL refactoring.

No functional changes are intended.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20260212233044.329790-2-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-05 15:52:38 +01:00
Srinivas Pandruvada
6d3e2ce6f1 thermal: intel: int340x: Read DDR data rate for Nova Lake
Add support for reading DDR data rate from PCI config offset.

The register details are:

 CFG Offset : 0xE0
 Bits	   : 11:2

DDR Data rate is in 33.33 MTPS units.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Rearrange code to avoid using goto and make declarations consistent ]
Link: https://patch.msgid.link/20260223190420.874853-1-srinivas.pandruvada@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-03-05 15:37:55 +01:00
Kees Cook
189f164e57 Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses
Conversion performed via this Coccinelle script:

  // SPDX-License-Identifier: GPL-2.0-only
  // Options: --include-headers-for-types --all-includes --include-headers --keep-comments
  virtual patch

  @gfp depends on patch && !(file in "tools") && !(file in "samples")@
  identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,
 		    kzalloc_obj,kzalloc_objs,kzalloc_flex,
		    kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,
		    kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};
  @@

  	ALLOC(...
  -		, GFP_KERNEL
  	)

  $ make coccicheck MODE=patch COCCI=gfp.cocci

Build and boot tested x86_64 with Fedora 42's GCC and Clang:

Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01
Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01

Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-22 08:26:33 -08:00
Linus Torvalds
32a92f8c89 Convert more 'alloc_obj' cases to default GFP_KERNEL arguments
This converts some of the visually simpler cases that have been split
over multiple lines.  I only did the ones that are easy to verify the
resulting diff by having just that final GFP_KERNEL argument on the next
line.

Somebody should probably do a proper coccinelle script for this, but for
me the trivial script actually resulted in an assertion failure in the
middle of the script.  I probably had made it a bit _too_ trivial.

So after fighting that far a while I decided to just do some of the
syntactically simpler cases with variations of the previous 'sed'
scripts.

The more syntactically complex multi-line cases would mostly really want
whitespace cleanup anyway.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 20:03:00 -08:00
Linus Torvalds
323bbfcf1e Convert 'alloc_flex' family to use the new default GFP_KERNEL argument
This is the exact same thing as the 'alloc_obj()' version, only much
smaller because there are a lot fewer users of the *alloc_flex()
interface.

As with alloc_obj() version, this was done entirely with mindless brute
force, using the same script, except using 'flex' in the pattern rather
than 'objs*'.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 17:09:51 -08:00
Linus Torvalds
bf4afc53b7 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
This was done entirely with mindless brute force, using

    git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' |
        xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/'

to convert the new alloc_obj() users that had a simple GFP_KERNEL
argument to just drop that argument.

Note that due to the extreme simplicity of the scripting, any slightly
more complex cases spread over multiple lines would not be triggered:
they definitely exist, but this covers the vast bulk of the cases, and
the resulting diff is also then easier to check automatically.

For the same reason the 'flex' versions will be done as a separate
conversion.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 17:09:51 -08:00
Kees Cook
69050f8d6d treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:

Single allocations:	kmalloc(sizeof(TYPE), ...)
are replaced with:	kmalloc_obj(TYPE, ...)

Array allocations:	kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with:	kmalloc_objs(TYPE, COUNT, ...)

Flex array allocations:	kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with:	kmalloc_flex(*PTR, FAM, COUNT, ...)

(where TYPE may also be *VAR)

The resulting allocations no longer return "void *", instead returning
"TYPE *".

Signed-off-by: Kees Cook <kees@kernel.org>
2026-02-21 01:02:28 -08:00
Linus Torvalds
fa2827e72c Additional thermal control update for 7.0-rc1
Fix sysfs group leak on DLVR registration failure in the Intel
 int340x thermal driver (Kaushlendra Kumar)
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEcM8Aw/RY0dgsiRUR7l+9nS/U47UFAmmWFiASHHJqd0Byand5
 c29ja2kubmV0AAoJEO5fvZ0v1OO1hOwH/3d74wJiY8QI8maslzarIFbI9lcq5axu
 LdFIuwf9FScw27oCktHsqmZuMQ2ETfCDnNy7qJXTJmznpVHsmK72EQmco1CU4f+M
 4Wyk6WNKDMZyndKMqAQqevdNcJBSmJHRq7eLdOtaRLexRPZZXhfLb6nWlBeMzQeB
 aACtb1Zzgp1Nwmr/kwJXbi4UZXa3w+nLl9qEqKIuNh4y8DinJP93zWt3QlaByDH3
 fRovEiVOAp1+pNdm32mfkfBN+DxM0lzqIW2j9lvBFHrq7pINo1eBQ+kIb4uvk9Cl
 7nKdCF98Yf3b3aDhWvepmOgY4i479seGgMPOMpje3R7T3Tvn4S+QD+0=
 =R1jm
 -----END PGP SIGNATURE-----

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

Pull thermal control fix from Rafael Wysocki:
 "This fixes a sysfs group leak on DLVR registration failure in the
  Intel int340x thermal driver (Kaushlendra Kumar)"

* tag 'thermal-7.0-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal: int340x: Fix sysfs group leak on DLVR registration failure
2026-02-18 14:33:18 -08:00
Kaushlendra Kumar
15176b818e thermal: int340x: Fix sysfs group leak on DLVR registration failure
When DLVR sysfs group creation fails in proc_thermal_rfim_add(),
the function returns immediately without cleaning up the FIVR group
that may have been created earlier.

Add proper error unwinding to remove the FIVR group before returning
failure.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/LV3PR11MB876881B77D32A2854AD2908EF563A@LV3PR11MB8768.namprd11.prod.outlook.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-02-11 20:56:01 +01:00
Linus Torvalds
4e21e585b6 A series of treewide cleanups to ensure interrupt request consistency.
- Add the missing IRQF_COND_ONESHOT flag to devm_request_irq()
 
     This is inconsistent vs. request_irq() and causes the same issues which
     where addressed with the introduction of this flag
 
   - Cleanup IRQF_ONESHOT and IRQF_NO_THREAD usage
 
     Quite some drivers have inconsistent interrupt request flags related to
     interrupt threading namely IRQF_ONESHOT and IRQF_NO_THREAD. This leads to
     warnings and/or malfunction when forced interrupt threading is enabled.
 
   - Remove stub primary (hard interrupt) handlers
 
     A bunch of drivers implement a stub primary (hard interrupt) handler which
     just returns IRQ_WAKE_THREAD. The same functionality is provided by the
     core code when the primary handler argument of request_thread_irq() is set
     to NULL.
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEQp8+kY+LLUocC4bMphj1TA10mKEFAmmJs8MQHHRnbHhAa2Vy
 bmVsLm9yZwAKCRCmGPVMDXSYoTbvEACH4OegGofKri7aecUPNcpRdQDHBoueikni
 Rio/vydFJ/H2hto4xlSPC4C84onxuFqY9lJgo/tCQTCrO0t+ZQ4ZGqnlQKzLJzmv
 vcVzNgGsxDZ0p1wJO0rBpTRxJN8yTXi8VVv5e6OPuihjLhdXGesyYtk1zosR3nOS
 CF/w8r9jVMzsSMPvtEMr5AwXD9ZTziUqyhQv94fYlpsbyD4TPXnUxhVkdUFFHHo3
 ROzWPFw1Ykh6wpdRPEpupcCf1d2Pq0TIAU86y3Sbf2msuXiTouHf+lH1uTd3EsLN
 6qUIqRYjwWE8HTieh+3YcH415wrIsUsWJb8YDi0DpqhPbja3IXP5ACHqEWaaNHRA
 MaBE2Gc02se4ChXMWncYR3cdzyAAwAeKLUahpLNc+7U4cHOm1w2g60yy4I0v2krh
 V0vfEN88WQ8DgrM0VvDLST6ZinSz4ia+R0qYWywl6eIW4RVNtuBi6wrN5PtzSEtz
 jZ3LqnRLGmNfKwS/taHBCAme7NIJSNa1L0ao/icnW5XVQz/d2EHVcUsLHecHZSMx
 l9tr/g3t85tsFW1eIKfF8T1a5DrbCEP4afceQk9KexAfAkP7el53M1E1yQDk/kW8
 so0CwZtbDJ136RQdBIQqx49QrUEOvtrgNDRQxPFBUrWEHcvjqbUuFclp9hpLheOj
 8YnzkVe0Rg==
 =vrmm
 -----END PGP SIGNATURE-----

Merge tag 'irq-cleanups-2026-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull irq cleanups from Thomas Gleixner:
 "A series of treewide cleanups to ensure interrupt request consistency.

   - Add the missing IRQF_COND_ONESHOT flag to devm_request_irq()

     This is inconsistent vs request_irq() and causes the same issues
     which where addressed with the introduction of this flag

   - Cleanup IRQF_ONESHOT and IRQF_NO_THREAD usage

     Quite some drivers have inconsistent interrupt request flags
     related to interrupt threading namely IRQF_ONESHOT and
     IRQF_NO_THREAD. This leads to warnings and/or malfunction when
     forced interrupt threading is enabled.

   - Remove stub primary (hard interrupt) handlers

     A bunch of drivers implement a stub primary (hard interrupt)
     handler which just returns IRQ_WAKE_THREAD. The same functionality
     is provided by the core code when the primary handler argument of
     request_thread_irq() is set to NULL"

* tag 'irq-cleanups-2026-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  media: pci: mg4b: Use IRQF_NO_THREAD
  mfd: wm8350-core: Use IRQF_ONESHOT
  thermal/qcom/lmh: Replace IRQF_ONESHOT with IRQF_NO_THREAD
  rtc: amlogic-a4: Remove IRQF_ONESHOT
  usb: typec: fusb302: Remove IRQF_ONESHOT
  EDAC/altera: Remove IRQF_ONESHOT
  char: tpm: cr50: Remove IRQF_ONESHOT
  ARM: versatile: Remove IRQF_ONESHOT
  scsi: efct: Use IRQF_ONESHOT and default primary handler
  Bluetooth: btintel_pcie: Use IRQF_ONESHOT and default primary handler
  bus: fsl-mc: Use default primary handler
  mailbox: bcm-ferxrm-mailbox: Use default primary handler
  iommu/amd: Use core's primary handler and set IRQF_ONESHOT
  platform/x86: int0002: Remove IRQF_ONESHOT from request_irq()
  genirq: Set IRQF_COND_ONESHOT in devm_request_irq().
2026-02-10 13:22:50 -08:00
Rafael J. Wysocki
8035d70cf8 Merge branch 'thermal-intel'
Merge updates of Intel thermal drivers for 6.20/7.0:

 - Add Panther Lake, Wildcat Lake and Nova Lake processor IDs to the
   list of supported processors in the intel_tcc_cooling thermal
   driver (Srinivas Pandruvada)

 - Drop unnecessary explicit driver data clearing on removal from the
   intel_pch_thermal driver (Kaushlendra Kumar)

 - Add support for "slow" workload type hints to the int340x
   processor_thermal driver and enable it on the Panther Lake
   platform (Srinivas Pandruvada)

 - Use sysfs_emit{_at}() in sysfs show functions in Intel thermal
   drivers (Thorsten Blum)

 - Update the x86_pkg_temp_thermal driver to handle THERMAL_TEMP_INVALID
   that can be passed to it via sysfs as expected (Rafael Wysocki)

 - Drop a redundant local variable from the intel_tcc_cooling thermal
   driver and fix a kerneldoc comment typo in the TCC library (Sumeet
   Pawnikar)

* thermal-intel:
  drivers: thermal: intel: tcc_cooling: Drop redundant local variable
  thermal: intel: x86_pkg_temp_thermal: Handle invalid temperature
  thermal: intel: Use sysfs_emit() in a sysfs show function
  thermal: intel: fix typo "nagative" in comment for cpu argument
  thermal: intel: int340x: Use sysfs_emit{_at}() in sysfs show functions
  thermal: intel: selftests: workload_hint: Support slow workload hints
  thermal: int340x: processor_thermal: Enable slow workload type hints
  thermal: intel: intel_pch_thermal: Drop explicit driver data clearing
  thermal: intel: intel_tcc_cooling: Add CPU models in the support list
2026-02-04 19:34:57 +01:00
Sebastian Andrzej Siewior
781b391557 thermal/qcom/lmh: Replace IRQF_ONESHOT with IRQF_NO_THREAD
Passing IRQF_ONESHOT ensures that the interrupt source is masked until
the secondary (threaded) handler is done. If only a primary handler is
used then the flag makes no sense because the interrupt can not fire
(again) while its handler is running.

The flag also prevents force-threading of the primary handler and the
irq-core will warn about this.

The intention here was probably to not allow forced-threading.

Replace IRQF_ONESHOT with IRQF_NO_THREAD.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260128095540.863589-14-bigeasy@linutronix.de
2026-02-01 17:37:16 +01:00
Sumeet Pawnikar
9eb9c350bc drivers: thermal: intel: tcc_cooling: Drop redundant local variable
Simplify the error path by directly returning PTR_ERR(tcc_cdev)
instead of storing it in an intermediate variable ret which can be
dropped then because it is only used for that.

Also remove an uneeded empty line before the declaration of local
variable err.

Signed-off-by: Sumeet Pawnikar <sumeet4linux@gmail.com>
[ rjw: Dropped unneeded changes, rewrote changelog, adjusted subject ]
Link: https://patch.msgid.link/20260131151615.6230-1-sumeet4linux@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-02-01 14:00:19 +01:00
Rafael J. Wysocki
74dd4d1f4c - Fix CFLAGS and LDFLAGS in the pkg-config template fir the libthermal
(Romain Gantois)
 
 - Support multiple temp to raw conversion functions for the Mediatek
   LVTS thermal driver and add the MT8196 and MT6991 support (Laura
   Nao)
 
 - Add support for the Mediatek LVTS driver for MT7987 (Frank
   Wunderlich)
 
 - Use the existing HZ_PER_MHZ macro on STM32 (Andy Shevchenko)
 
 - Use the existing clamp() macro in BCM2835 (Thorsten Blum)
 
 - Make the reset line optional in order to support new Renesas Soc
   where it is not available. Add the RZ/T2H and RZ/N2H suppport
   (Cosmin Tanislav)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAml6Q0MACgkQqDIjiipP
 6E9P4QgAg1AHwxBaULff9SOxYKwfyWo2FE/nwlpiOAjY2eZjNwWjGkaAzi5cNiF1
 HUH8YBWXIb910LWDer6ieG5nBNjBOqmb0qF7Vx5dU+VV6cdV/Zg/0u8dManbMxLD
 lhJJnG/jZuJ1XRIZosJMyuIQRs4xgt1YwkUwSf/q51x8dk7+M+HUgzPNxb4iFTCE
 UZY1FLfveadMdAnl92o2HsJQ447LW2gyj6iIaOT9FnxBKdVgwItu8Qcuz6n5WSbv
 ALSiieyKRHrhsp3w7VSZ+Lzh457vrXEKdw8LMXsFbd0GBstvFX5B/Zqd9mRz8Ydf
 6axZI+yhj0OEkWnAHom6DttUE5dxIg==
 =RJtp
 -----END PGP SIGNATURE-----

Merge tag 'thermal-v7.0' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux

Pull thermal control updates for 6.20/7.0 from Daniel Lezcano:

"- Fix CFLAGS and LDFLAGS in the pkg-config template fir the libthermal
   (Romain Gantois)

 - Support multiple temp to raw conversion functions for the Mediatek
   LVTS thermal driver and add the MT8196 and MT6991 support (Laura
   Nao)

 - Add support for the Mediatek LVTS driver for MT7987 (Frank
   Wunderlich)

 - Use the existing HZ_PER_MHZ macro on STM32 (Andy Shevchenko)

 - Use the existing clamp() macro in BCM2835 (Thorsten Blum)

 - Make the reset line optional in order to support new Renesas Soc
   where it is not available. Add the RZ/T2H and RZ/N2H suppport
   (Cosmin Tanislav)"

* tag 'thermal-v7.0' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
  thermal: renesas: rzg3e: add support for RZ/T2H and RZ/N2H
  dt-bindings: thermal: r9a09g047-tsu: document RZ/T2H and RZ/N2H
  thermal: renesas: rzg3e: make calibration value retrieval per-chip
  thermal: renesas: rzg3e: make min and max temperature per-chip
  thermal: renesas: rzg3e: make reset optional
  dt-bindings: thermal: r9a09g047-tsu: Document RZ/V2N TSU
  thermal/drivers/broadcom: Use clamp to simplify bcm2835_thermal_temp2adc
  thermal/drivers/stm32: Use predefined HZ_PER_MHZ instead of a custom one
  thermal/drivers/mediatek/lvts_thermal: Add mt7987 support
  dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT7987
  dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
  thermal/drivers/mediatek/lvts_thermal: Add MT8196 support
  thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data
  thermal/drivers/mediatek/lvts: Add support for ATP mode
  thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
  thermal/drivers/mediatek/lvts: Add platform ops to support alternative conversion logic
  thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable
  dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196
  tools: lib: thermal: Correct CFLAGS and LDFLAGS in pkg-config template
2026-01-29 15:30:03 +01:00
Felix Gu
a1fe789a96 thermal/of: Fix reference leak in thermal_of_cm_lookup()
In thermal_of_cm_lookup(), tr_np is obtained via of_parse_phandle(), but
never released.

Use the __free(device_node) cleanup attribute to automatically release
the node and fix the leak.

Fixes: 423de5b5bc ("thermal/of: Fix cdev lookup in thermal_of_should_bind()")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
[ rjw: Changelog edits ]
Link: https://patch.msgid.link/20260124-thermal_of-v1-1-54d3416948cf@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-01-28 22:10:34 +01:00
Randy Dunlap
1e461784c3 thermal: core: thermal_core.h: fix all kernel-doc warnings
Resolve all kernel-doc warnings in thermal_core.h:

Warning: drivers/thermal/thermal_core.h:99 bad line: trip point.
Warning: drivers/thermal/thermal_core.h:101 bad line: passive trip point.
Warning: drivers/thermal/thermal_core.h:152 struct member 'trips_attribute_group' not described in 'thermal_zone_device'
Warning: drivers/thermal/thermal_core.h:152 struct member 'debugfs' not described in 'thermal_zone_device'
Warning: drivers/thermal/thermal_core.h:152 struct member 'user_thresholds' not described in 'thermal_zone_device'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20260128062446.402175-1-rdunlap@infradead.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-01-28 22:07:27 +01:00
Rafael J. Wysocki
9635c586a5 thermal: intel: x86_pkg_temp_thermal: Handle invalid temperature
After commit be0a3600aa ("thermal: sysfs: Rework the handling of trip
point updates"), THERMAL_TEMP_INVALID can be passed to sys_set_trip_temp()
and it is treated as a regular temperature value there, so the sysfs
write fails even though it is expected to succeed and disable the given
trip point.

Address this by making sys_set_trip_temp() clear its temp variable when
it is equal to THERMAL_TEMP_INVALID.

Fixes: be0a3600aa ("thermal: sysfs: Rework the handling of trip point updates")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2815400.mvXUDI8C0e@rafael.j.wysocki
2026-01-23 21:52:12 +01:00
Cosmin Tanislav
0061030929 thermal: renesas: rzg3e: add support for RZ/T2H and RZ/N2H
The Renesas RZ/T2H (R9A09G077) and RZ/N2H (R9A09G087) SoCs expose the
temperature calibration via SMC SIP and do not have a reset for the
TSU peripheral, and use different minimum and maximum temperature values
compared to the already supported RZ/G3E.

Although the calibration data is stored in an OTP memory, the OTP itself
is not memory-mapped, access to it is done through an OTP controller.

The OTP controller is only accessible from the secure world,
but the temperature calibration data stored in the OTP is exposed via
SMC.

Add support for retrieving the calibration data using arm_smcc_smc().

Add a compatible for RZ/T2H, RZ/N2H can use it as a fallback.

Reviewed-by: John Madieu <john.madieu.xa@bp.renesas.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://patch.msgid.link/20260108195223.193531-6-cosmin-gabriel.tanislav.xa@renesas.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2026-01-21 19:06:57 +01:00