Commit graph

2658 commits

Author SHA1 Message Date
Linus Torvalds 4ac4677fdb Thermal control updates for 6.7-rc1
- Untangle the initialization and updates of passive and active trip
    points in the ACPI thermal driver (Rafael Wysocki).
 
  - Reduce code duplication related to the initialization and updates
    of trip points in the ACPI thermal driver (Rafael Wysocki).
 
  - Use trip pointers for cooling device binding in the ACPI thermal
    driver (Rafael Wysocki).
 
  - Simplify critical and hot trips representation in the ACPI thermal
    driver (Rafael Wysocki).
 
  - Use trip pointers in thermal governors and in the related part of
    the thermal core (Rafael Wysocki).
 
  - Drop the trips_disabled bitmask that has become redundant from the
    thermal core (Rafael Wysocki).
 
  - Avoid updating trip points when the thermal zone temperature falls
    into a trip point's hysteresis range (ícolas F. R. A. Prado).
 
  - Add power floor notifications support to the int340x thermal control
    driver (Srinivas Pandruvada).
 
  - Rework updating trip points in the int340x thermal driver so that it
    does not access thermal zone internals directly (Rafael Wysocki).
 
  - Use param_get_byte() instead of param_get_int() as the max_idle module
    parameter .get() callback in the Intel powerclamp thermal driver to
    avoid possible out-of-bounds access (David Arcari).
 
  - Add workload hints support to the int340x thermal driver (Srinivas
    Pandruvada).
 
  - Add support for Mediatek LVTS MT8192 along with suspend/resume
    routines (Balsam Chihi).
 
  - Fix probe for THERMAL_V2 in the Mediatek LVTS driver (Markus
    Schneider-Pargmann).
 
  - Remove duplicate error message from the max76620 driver when
    thermal_of_zone_register() fails (Thierry Reding).
 
  - Add i.MX7D compatible bindings to fix a warning from dtbs_check for
    the imx6ul platform (Alexander Stein).
 
  - Add sa8775p compatible to the QCom tsens driver (Priyansh Jain).
 
  - Fix error check in lvts_debugfs_init() to be against PTR_ERR() in the
    LVTS Mediatek driver (Minjie Du).
 
  - Remove unused variable in thermal/tools (Kuan-Wei Chiu).
 
  - Document the imx8dl thermal sensor (Fabio Estevam).
 
  - Add variable names in callback prototypes to prevent warning from
    checkpatch.pl in the imx8mm driver (Bragatheswaran Manickavel).
 
  - Add missing unevaluatedProperties on child node schemas for tegra124
    (Rob Herring)
 
  - Add mt7988 support to the Mediatek LVTS driver (Frank Wunderlich).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmU6a+sSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRx9s8P/A/u3d8jn5Dj7B4N3Y4uTL1IG3aleGnZ
 EDxoiW6ju723s9ZMGsJg6qzXoksJDjleUTGtdyGYgbPyFz44/6/bcYqI6H0GsHlH
 lah5jAgXEaJdbc9CwwhjBoVEN6wO5ATyDIJ1H+iU0x/6svZpXN+tlQp2dAFacAxD
 CyZkFrBrSrEercO59NxCTyA9n9hfAfHdX7hBd5e686SXtcR+wdLyLfrPiEoE4oYq
 vW9QkzTSK+nILrLTSGnrmtYvsOzbyRKqoIPrRhqSwgobvDHvYgkokdESYGzu/d3F
 k922eHV8C4RyFZmVT9o+dVaK27gZ3KQI3d8BfpitMYD/Tb0N4axmwkZ44rrA8OOy
 kpTFENvlICyUpfcTqwLYIZT9WK7rXKpxqjLeKMZvzrUWBoNm8tFsuJy3Hxd0IP6V
 F2X62UH/sA4QAtJHD0VP5mc7FRbuFBdpyQ6Tq9ZNUQGoOeFT6VxQaqzRzqWwV6Na
 lxxvX3FST4lRguNRg9NW3RrOxQOyLaQP1TIN3CaZ0rOs2dlGz8v2UN252uM/K1Y0
 JO0rXS2HoXdUqWWaIMnVvNqOsaYeMGhVfCNySEn1DoChpInAZF50Z0/fL5Vpb51L
 cl0VrNxReHwDHeuRtKcFgH1S8YrsehrRAZp3bDArmD/XszJQR+Rv5N6BSdURDLSU
 1mkfn37l8fKc
 =PSaG
 -----END PGP SIGNATURE-----

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

Pull thermal control updates from Rafael Wysocki:
 "These further rework the ACPI thermal driver, after the changes made
  to it in the previous cycle, to make it easier to grasp, get rid of
  redundant pieces of internal data structures and eliminate its
  reliance on a specific ordering of trip point objects in the thermal
  core, make thermal core adjustments needed for the ACPI thermal driver
  rework, modify the thermal governor interface so as to use trip
  pointers for representing trip points in it, switch over multiple
  thermal drivers to using void platform driver remove callbacks, add
  support for 2 hardware features to the Intel int340x thermal driver,
  add support for new hardware on ARM platforms, update documentation,
  fix problems, clean up code and update the MAINTAINERS record for
  thermal control.

  Specifics:

   - Untangle the initialization and updates of passive and active trip
     points in the ACPI thermal driver (Rafael Wysocki)

   - Reduce code duplication related to the initialization and updates
     of trip points in the ACPI thermal driver (Rafael Wysocki)

   - Use trip pointers for cooling device binding in the ACPI thermal
     driver (Rafael Wysocki)

   - Simplify critical and hot trips representation in the ACPI thermal
     driver (Rafael Wysocki)

   - Use trip pointers in thermal governors and in the related part of
     the thermal core (Rafael Wysocki)

   - Drop the trips_disabled bitmask that has become redundant from the
     thermal core (Rafael Wysocki)

   - Avoid updating trip points when the thermal zone temperature falls
     into a trip point's hysteresis range (ícolas F. R. A. Prado)

   - Add power floor notifications support to the int340x thermal
     control driver (Srinivas Pandruvada)

   - Rework updating trip points in the int340x thermal driver so that
     it does not access thermal zone internals directly (Rafael
     Wysocki)

   - Use param_get_byte() instead of param_get_int() as the max_idle
     module parameter .get() callback in the Intel powerclamp thermal
     driver to avoid possible out-of-bounds access (David Arcari)

   - Add workload hints support to the int340x thermal driver (Srinivas
     Pandruvada)

   - Add support for Mediatek LVTS MT8192 along with suspend/resume
     routines (Balsam Chihi)

   - Fix probe for THERMAL_V2 in the Mediatek LVTS driver (Markus
     Schneider-Pargmann)

   - Remove duplicate error message from the max76620 driver when
     thermal_of_zone_register() fails (Thierry Reding)

   - Add i.MX7D compatible bindings to fix a warning from dtbs_check for
     the imx6ul platform (Alexander Stein)

   - Add sa8775p compatible to the QCom tsens driver (Priyansh Jain)

   - Fix error check in lvts_debugfs_init() to be against PTR_ERR() in
     the LVTS Mediatek driver (Minjie Du)

   - Remove unused variable in thermal/tools (Kuan-Wei Chiu)

   - Document the imx8dl thermal sensor (Fabio Estevam)

   - Add variable names in callback prototypes to prevent warning from
     checkpatch.pl in the imx8mm driver (Bragatheswaran Manickavel)

   - Add missing unevaluatedProperties on child node schemas for
     tegra124 (Rob Herring)

   - Add mt7988 support to the Mediatek LVTS driver (Frank Wunderlich)"

* tag 'thermal-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (111 commits)
  thermal: ACPI: Include the right header file
  thermal: core: Don't update trip points inside the hysteresis range
  thermal: core: Pass trip pointer to governor throttle callback
  thermal: gov_step_wise: Fold update_passive_instance() into its caller
  thermal: gov_power_allocator: Use trip pointers instead of trip indices
  thermal: gov_fair_share: Rearrange get_trip_level()
  thermal: trip: Define for_each_trip() macro
  thermal: trip: Simplify computing trip indices
  thermal/qcom/tsens: Drop ops_v0_1
  thermal/drivers/mediatek/lvts_thermal: Update calibration data documentation
  thermal/drivers/mediatek/lvts_thermal: Add mt8192 support
  thermal/drivers/mediatek/lvts_thermal: Add suspend and resume
  dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for mt8192
  thermal/drivers/mediatek: Fix probe for THERMAL_V2
  thermal/drivers/max77620: Remove duplicate error message
  dt-bindings: timer: add imx7d compatible
  dt-bindings: net: microchip: Allow nvmem-cell usage
  dt-bindings: imx-thermal: Add #thermal-sensor-cells property
  dt-bindings: thermal: tsens: Add sa8775p compatible
  thermal/drivers/mediatek/lvts_thermal: Fix error check in lvts_debugfs_init()
  ...
2023-10-31 15:28:37 -10:00
Linus Torvalds befaa609f4 hardening updates for v6.7-rc1
- Add LKDTM test for stuck CPUs (Mark Rutland)
 
 - Improve LKDTM selftest behavior under UBSan (Ricardo Cañuelo)
 
 - Refactor more 1-element arrays into flexible arrays (Gustavo A. R. Silva)
 
 - Analyze and replace strlcpy and strncpy uses (Justin Stitt, Azeem Shaikh)
 
 - Convert group_info.usage to refcount_t (Elena Reshetova)
 
 - Add __counted_by annotations (Kees Cook, Gustavo A. R. Silva)
 
 - Add Kconfig fragment for basic hardening options (Kees Cook, Lukas Bulwahn)
 
 - Fix randstruct GCC plugin performance mode to stay in groups (Kees Cook)
 
 - Fix strtomem() compile-time check for small sources (Kees Cook)
 -----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAmU/3cUWHGtlZXNjb29r
 QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJsEoEACBGPSiOmfSWdH3TOnIG270PD24
 jGjg8KFv7RC/JTOdYmpLl0okdlGT9LvjN/ToSSDEw3PIayxoXUdhkbYy0MYtiV3m
 yz2ozDTzJuplQX/W2fPE+nXSzIwHao2zjPPFjHnT7lt8IIjhgjiOtLfZ2gGUkW99
 Mdu2aWh3u0r4tC8OS23++yN5ibRc5l72efsjDWjZ0aPXnxE1bjmLMiIPiizpndIf
 beasPuDBs98sJVYouemCwnsPXuXOPz3Q1Cpo/fTd+TMTJCLSemCQZCTuOBU0acI/
 ZjLCgCaJU1yIYKBMtrIN4G9kITZniXX3/Nm4o6NQMVlcCqMeNaHuflomqWoqWfhE
 UPbRo2eghZOaMNiCKLLvZDIqPrh1IcsiEl6Ef3W4hICc42GTK96IuGisIvDXwQ4N
 /SzTOupJuN42noh3z1M3XuZy5RoXJ99IYDNY5CTKf9IdqvA0bbGkU3nb1gZH/xw9
 BjTqKzR/7K1kTXuSgagDZ1Wceej9pZxhX7E3IHYsP8ZOvKug3EeL4yybVwQ3HRfq
 Qnzcp/qPB9cOkLSQXveRTFTsj2mX28Gixct/iDuc1jIYwGQlY1gI6dcUcqby6ptM
 BrQti7eR2NH2+T3aE2UVCIWsZVhx7NaSF+z8JxfAuu56jicc4xJVsi8zrNveWX5M
 m2VXyBl3121BVtKi4w==
 =0iVF
 -----END PGP SIGNATURE-----

Merge tag 'hardening-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull hardening updates from Kees Cook:
 "One of the more voluminous set of changes is for adding the new
  __counted_by annotation[1] to gain run-time bounds checking of
  dynamically sized arrays with UBSan.

   - Add LKDTM test for stuck CPUs (Mark Rutland)

   - Improve LKDTM selftest behavior under UBSan (Ricardo Cañuelo)

   - Refactor more 1-element arrays into flexible arrays (Gustavo A. R.
     Silva)

   - Analyze and replace strlcpy and strncpy uses (Justin Stitt, Azeem
     Shaikh)

   - Convert group_info.usage to refcount_t (Elena Reshetova)

   - Add __counted_by annotations (Kees Cook, Gustavo A. R. Silva)

   - Add Kconfig fragment for basic hardening options (Kees Cook, Lukas
     Bulwahn)

   - Fix randstruct GCC plugin performance mode to stay in groups (Kees
     Cook)

   - Fix strtomem() compile-time check for small sources (Kees Cook)"

* tag 'hardening-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (56 commits)
  hwmon: (acpi_power_meter) replace open-coded kmemdup_nul
  reset: Annotate struct reset_control_array with __counted_by
  kexec: Annotate struct crash_mem with __counted_by
  virtio_console: Annotate struct port_buffer with __counted_by
  ima: Add __counted_by for struct modsig and use struct_size()
  MAINTAINERS: Include stackleak paths in hardening entry
  string: Adjust strtomem() logic to allow for smaller sources
  hardening: x86: drop reference to removed config AMD_IOMMU_V2
  randstruct: Fix gcc-plugin performance mode to stay in group
  mailbox: zynqmp: Annotate struct zynqmp_ipi_pdata with __counted_by
  drivers: thermal: tsens: Annotate struct tsens_priv with __counted_by
  irqchip/imx-intmux: Annotate struct intmux_data with __counted_by
  KVM: Annotate struct kvm_irq_routing_table with __counted_by
  virt: acrn: Annotate struct vm_memory_region_batch with __counted_by
  hwmon: Annotate struct gsc_hwmon_platform_data with __counted_by
  sparc: Annotate struct cpuinfo_tree with __counted_by
  isdn: kcapi: replace deprecated strncpy with strscpy_pad
  isdn: replace deprecated strncpy with strscpy
  NFS/flexfiles: Annotate struct nfs4_ff_layout_segment with __counted_by
  nfs41: Annotate struct nfs4_file_layout_dsaddr with __counted_by
  ...
2023-10-30 19:09:55 -10:00
Rafael J. Wysocki 607218deac - Add support for Mediatek LVTS MT8192 driver along with the
suspend/resume routines (Balsam Chihi)
 
 - Fix probe for THERMAL_V2 for the Mediatek LVTS driver (Markus
   Schneider-Pargmann)
 
 - Remove duplicate error message in the max76620 driver when
   thermal_of_zone_register() fails as the sub routine already show one
   (Thierry Reding)
 
 - Add i.MX7D compatible bindings to fix a warning from dtbs_check for
   the imx6ul platform (Alexander Stein)
 
 - Add sa8775p compatible for the QCom tsens driver (Priyansh Jain)
 
 - Fix error check in lvts_debugfs_init() which is checking against
   NULL instead of PTR_ERR() on the LVTS Mediatek driver (Minjie Du)
 
 - Remove unused variable in the thermal/tools (Kuan-Wei Chiu)
 
 - Document the imx8dl thermal sensor (Fabio Estevam)
 
 - Add variable names in callback prototypes to prevent warning from
   checkpatch.pl for the imx8mm driver (Bragatheswaran Manickavel)
 
 - Add missing unevaluatedProperties on child node schemas for tegra124
   (Rob Herring)
 
 - Add mt7988 support for the Mediatek LVTS driver (Frank Wunderlich)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAmU35s8ACgkQqDIjiipP
 6E8nggf/VQei7x/fRTFRYJVyP6SdwzpZPcyMYEcwL50wpp/d/R5xapFzM7nofV6n
 SYFXkpuejGH5d5JbJjpkv1S56Q/Bf6yy7cGciKiBmxaU2cWY636KmhlUPe2kfmX5
 ipiNi/ZU0zAjZM7FRpBVPgp0HTvnGehDzIaSi6Y/vKVAw5TPTzjLz8oNoeHGP4/6
 xNRgJuTwAvqL1lqZoo9YV7tVdkcuQamf3dkDkHqvSSL9UilHZEqrtLyh1Iz12+py
 LESjlePz1jzK169oG5QiA4thIMV7CPTwkrkAJXwT2H2zWccg7JzZ7K1S3aJq2vHL
 5UMcsUE2wCczfdnlhxD6wkJ3CDyirA==
 =i0K9
 -----END PGP SIGNATURE-----

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

Merge thermal control (ARM drivers mostly) updates for 6.7-rc1 from
Daniel Lezcano:

"- Add support for Mediatek LVTS MT8192 driver along with the
   suspend/resume routines (Balsam Chihi)

 - Fix probe for THERMAL_V2 for the Mediatek LVTS driver (Markus
   Schneider-Pargmann)

 - Remove duplicate error message in the max76620 driver when
   thermal_of_zone_register() fails as the sub routine already show one
   (Thierry Reding)

 - Add i.MX7D compatible bindings to fix a warning from dtbs_check for
   the imx6ul platform (Alexander Stein)

 - Add sa8775p compatible for the QCom tsens driver (Priyansh Jain)

 - Fix error check in lvts_debugfs_init() which is checking against
   NULL instead of PTR_ERR() on the LVTS Mediatek driver (Minjie Du)

 - Remove unused variable in the thermal/tools (Kuan-Wei Chiu)

 - Document the imx8dl thermal sensor (Fabio Estevam)

 - Add variable names in callback prototypes to prevent warning from
   checkpatch.pl for the imx8mm driver (Bragatheswaran Manickavel)

 - Add missing unevaluatedProperties on child node schemas for tegra124
  (Rob Herring)

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

* tag 'thermal-v6.7-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
  thermal/qcom/tsens: Drop ops_v0_1
  thermal/drivers/mediatek/lvts_thermal: Update calibration data documentation
  thermal/drivers/mediatek/lvts_thermal: Add mt8192 support
  thermal/drivers/mediatek/lvts_thermal: Add suspend and resume
  dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for mt8192
  thermal/drivers/mediatek: Fix probe for THERMAL_V2
  thermal/drivers/max77620: Remove duplicate error message
  dt-bindings: timer: add imx7d compatible
  dt-bindings: net: microchip: Allow nvmem-cell usage
  dt-bindings: imx-thermal: Add #thermal-sensor-cells property
  dt-bindings: thermal: tsens: Add sa8775p compatible
  thermal/drivers/mediatek/lvts_thermal: Fix error check in lvts_debugfs_init()
  tools/thermal: Remove unused 'mds' and 'nrhandler' variables
  dt-bindings: thermal: fsl,scu-thermal: Document imx8dl
  thermal/drivers/imx8mm_thermal: Fix function pointer declaration by adding identifier name
  dt-bindings: thermal: nvidia,tegra124-soctherm: Add missing unevaluatedProperties on child node schemas
  thermal/drivers/mediatek/lvts_thermal: Add mt7988 support
  thermal/drivers/mediatek/lvts_thermal: Make coeff configurable
  dt-bindings: thermal: mediatek: Add LVTS thermal sensors for mt7988
  dt-bindings: thermal: mediatek: Add mt7988 lvts compatible
2023-10-25 14:41:10 +02:00
Rafael J. Wysocki 8aa49284f3 Merge branch 'thermal-intel'
Merge changes in Intel thermal control drivers for 6.7-rc1:

 - Add power floor notifications support to the int340x thermal control
   driver (Srinivas Pandruvada).

 - Rework updating trip points in the int340x thermal driver so that it
   does not access thermal zone internals directly (Rafael Wysocki).

 - Use param_get_byte() instead of param_get_int() as the max_idle module
   parameter .get() callback in the Intel powerclamp thermal driver to
   avoid possible out-of-bounds access (David Arcari).

 - Add workload hints support to the the int340x thermal driver (Srinivas
   Pandruvada).

* thermal-intel:
  selftests/thermel/intel: Add test to read power floor status
  thermal: int340x: processor_thermal: Enable power floor support
  thermal: int340x: processor_thermal: Handle power floor interrupts
  thermal: int340x: processor_thermal: Support power floor notifications
  thermal: int340x: processor_thermal: Set feature mask before proc_thermal_add
  thermal: int340x: processor_thermal: Common function to clear SOC interrupt
  thermal: int340x: processor_thermal: Move interrupt status MMIO offset to common header
  thermal: intel: powerclamp: fix mismatch in get function for max_idle
  thermal: int340x: Use thermal_zone_for_each_trip()
  thermal: int340x: processor_thermal: Ack all PCI interrupts
  thermal: int340x: Add ArrowLake-S PCI ID
  selftests/thermel/intel: Add test to read workload hint
  thermal: int340x: Handle workload hint interrupts
  thermal: int340x: processor_thermal: Add workload type hint interface
  thermal: int340x: Remove PROC_THERMAL_FEATURE_WLT_REQ for Meteor Lake
  thermal: int340x: processor_thermal: Use non MSI interrupts by default
  thermal: int340x: processor_thermal: Add interrupt configuration function
  thermal: int340x: processor_thermal: Move mailbox code to common module
2023-10-23 20:06:58 +02:00
Rafael J. Wysocki 598c20f964 Merge branch 'thermal-core'
Merge thermal core changes for 6.7-rc1:

 - Use trip pointers in thermal governors and in the related part of
   the thermal core (Rafael Wysocki).

 - Avoid updating trip points when the thermal zone temperature falls
   into a trip point's hysteresis range (ícolas F. R. A. Prado).

* thermal-core:
  thermal: ACPI: Include the right header file
  thermal: core: Don't update trip points inside the hysteresis range
  thermal: core: Pass trip pointer to governor throttle callback
  thermal: gov_step_wise: Fold update_passive_instance() into its caller
  thermal: gov_power_allocator: Use trip pointers instead of trip indices
  thermal: gov_fair_share: Rearrange get_trip_level()
  thermal: trip: Define for_each_trip() macro
  thermal: trip: Simplify computing trip indices
2023-10-23 20:00:51 +02:00
Rafael J. Wysocki 27fa2b6043 Merge branch 'acpi-thermal'
Merge ACPI thermal driver changes are related thermal core changes for
v6.7-rc1:

 - Untangle the initialization and updates of passive and active trip
   points in the ACPI thermal driver (Rafael Wysocki).

 - Reduce code duplication related to the initialization and updates
   of trip points in the ACPI thermal driver (Rafael Wysocki).

 - Use trip pointers for cooling device binding in the ACPI thermal
   driver (Rafael Wysocki).

 - Simplify critical and hot trips representation in the ACPI thermal
   driver (Rafael Wysocki).

* acpi-thermal: (26 commits)
  thermal: trip: Drop lockdep assertion from thermal_zone_trip_id()
  thermal: trip: Remove lockdep assertion from for_each_thermal_trip()
  thermal: core: Drop thermal_zone_device_exec()
  ACPI: thermal: Use thermal_zone_for_each_trip() for updating trips
  ACPI: thermal: Combine passive and active trip update functions
  ACPI: thermal: Move get_active_temp()
  ACPI: thermal: Fix up function header formatting in two places
  ACPI: thermal: Drop list of device ACPI handles from struct acpi_thermal
  ACPI: thermal: Rename structure fields holding temperature in deci-Kelvin
  ACPI: thermal: Drop critical_valid and hot_valid trip flags
  ACPI: thermal: Do not use trip indices for cooling device binding
  ACPI: thermal: Mark uninitialized active trips as invalid
  ACPI: thermal: Merge trip initialization functions
  ACPI: thermal: Collapse trip devices update function wrappers
  ACPI: thermal: Collapse trip devices update functions
  ACPI: thermal: Add device list to struct acpi_thermal_trip
  ACPI: thermal: Fix a small leak in acpi_thermal_add()
  ACPI: thermal: Drop valid flag from struct acpi_thermal_trip
  ACPI: thermal: Drop redundant trip point flags
  ACPI: thermal: Untangle initialization and updates of active trips
  ...
2023-10-23 19:51:26 +02:00
Rafael J. Wysocki c27d08f786 thermal: ACPI: Include the right header file
It is not necessary to include thermal_core.h into thermal_acpi.c,
because none of the code in there depends on anything in the former,
except for the linux/thermal.h, but it is better to include that one
directly instead of including the entire thermal_core.h, so make that
change.

No functional impact.

Fixes: 7a0e397488 ("thermal: ACPI: Add ACPI trip point routines")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-10-20 19:26:37 +02:00
Nícolas F. R. A. Prado cf3986f8c0 thermal: core: Don't update trip points inside the hysteresis range
When searching for the trip points that need to be set, the nearest
higher trip point's temperature is used for the high trip, while the
nearest lower trip point's temperature minus the hysteresis is used for
the low trip. The issue with this logic is that when the current
temperature is inside a trip point's hysteresis range, both high and low
trips will come from the same trip point. As a consequence instability
can still occur like this:
* the temperature rises slightly and enters the hysteresis range of a
  trip point
* polling happens and updates the trip points to the hysteresis range
* the temperature falls slightly, exiting the hysteresis range, crossing
  the trip point and triggering an IRQ, the trip points are updated
* repeat

So even though the current hysteresis implementation prevents
instability from happening due to IRQs triggering on the same
temperature value, both ways, it doesn't prevent it from happening due
to an IRQ on one way and polling on the other.

To properly implement a hysteresis behavior, when inside the hysteresis
range, don't update the trip points. This way, the previously set trip
points will stay in effect, which will in a way remember the previous
state (if the temperature signal came from above or below the range) and
therefore have the right trip point already set.

The exception is if there was no previous trip point set, in which case
a previous state doesn't exist, and so it's sensible to allow the
hysteresis range as trip points.

The following logs show the current behavior when running on a real
machine:

[  202.524658] thermal thermal_zone0: new temperature boundaries: -2147483647 < x < 40000
   203.562817: thermal_temperature: thermal_zone=vpu0-thermal id=0 temp_prev=36986 temp=37979
[  203.562845] thermal thermal_zone0: new temperature boundaries: 37000 < x < 40000
   204.176059: thermal_temperature: thermal_zone=vpu0-thermal id=0 temp_prev=37979 temp=40028
[  204.176089] thermal thermal_zone0: new temperature boundaries: 37000 < x < 100000
   205.226813: thermal_temperature: thermal_zone=vpu0-thermal id=0 temp_prev=40028 temp=38652
[  205.226842] thermal thermal_zone0: new temperature boundaries: 37000 < x < 40000

And with this patch applied:

[  184.933415] thermal thermal_zone0: new temperature boundaries: -2147483647 < x < 40000
   185.981182: thermal_temperature: thermal_zone=vpu0-thermal id=0 temp_prev=36986 temp=37872
   186.744685: thermal_temperature: thermal_zone=vpu0-thermal id=0 temp_prev=37872 temp=40058
[  186.744716] thermal thermal_zone0: new temperature boundaries: 37000 < x < 100000
   187.773284: thermal_temperature: thermal_zone=vpu0-thermal id=0 temp_prev=40058 temp=38698

Fixes: 060c034a97 ("thermal: Add support for hardware-tracked trip points")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Co-developed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-20 19:26:37 +02:00
Rafael J. Wysocki 8c35b1f472 thermal: core: Pass trip pointer to governor throttle callback
Modify the governor .throttle() callback definition so that it takes a
trip pointer instead of a trip index as its second argument, adjust the
governors accordingly and update the core code invoking .throttle().

This causes the governors to become independent of the representation
of the list of trips in the thermal zone structure.

This change is not expected to alter the general functionality.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-10-20 19:26:37 +02:00
Rafael J. Wysocki fdcf70ed4e thermal: gov_step_wise: Fold update_passive_instance() into its caller
Fold update_passive_instance() into thermal_zone_trip_update() that is
its only caller so as to make the code in question 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>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
2023-10-20 19:26:37 +02:00
Rafael J. Wysocki 94be1d27aa thermal: gov_power_allocator: Use trip pointers instead of trip indices
Modify the power allocator thermal governor to use trip pointers instead
of trip indices everywhere except for the power_allocator_throttle()
second argument that will be changed subsequently along with the
definition of the .throttle() governor callback.

The general functionality is not expected to be changed.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>
2023-10-20 19:26:37 +02:00
Rafael J. Wysocki 276f1ede95 thermal: gov_fair_share: Rearrange get_trip_level()
Make get_trip_level() use for_each_trip() to iterate over trip points
and make it call thermal_zone_trip_id() to obtain the integer ID of a
given trip point so as to avoid relying on the knowledge of struct
thermal_zone_device internals.

The general functionality is not expected to be changed.

This change causes the governor to use trip pointers instead of trip
indices everywhere except for the fair_share_throttle() second argument
that will be modified subsequently along with the definition of the
governor .throttle() callback.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-10-20 19:26:37 +02:00
Rafael J. Wysocki 234ed6f5fb thermal: trip: Define for_each_trip() macro
Define a new macro for_each_trip() to be used by the thermal core code
and thermal governors for walking trips in a given thermal zone.

Modify for_each_thermal_trip() to use this macro instead of an open-
coded loop over trips.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
2023-10-20 19:26:01 +02:00
Rafael J. Wysocki 78869767f2 thermal: trip: Simplify computing trip indices
A trip index can be computed right away as a difference between the
value of a trip pointer pointing to the given trip object and the
start of the trips[] table in the given thermal zone, so change
thermal_zone_trip_id() accordingly.

No intentional functional impact (except for some speedup).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>
2023-10-20 19:25:22 +02:00
Dmitry Baryshkov 9618efe343 thermal/qcom/tsens: Drop ops_v0_1
Since the commit 6812d1dfbc ("thermal/drivers/qcom/tsens-v0_1: Fix
mdm9607 slope values") the default v0.1 implementation of tsens
options is unused by the driver. Drop it now to stop compiler
complaining about the unused static const. If it appears there is the
need for the default v0.1 ops struct, this commit can be easily
reverted without further considerations.

Fixes: 6812d1dfbc ("thermal/drivers/qcom/tsens-v0_1: Fix mdm9607 slope values")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231019144311.1035181-1-dmitry.baryshkov@linaro.org
2023-10-19 17:13:12 +02:00
Balsam CHIHI 5437d14d94 thermal/drivers/mediatek/lvts_thermal: Update calibration data documentation
Update LVTS calibration data documentation for mt8192 and mt8195.

Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
[bero@baylibre.com: Fix issues pointed out by Nícolas F. R. A. Prado <nfraprado@collabora.com>]
Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231017190545.157282-6-bero@baylibre.com
2023-10-19 02:43:32 +02:00
Balsam CHIHI 288732242d thermal/drivers/mediatek/lvts_thermal: Add mt8192 support
Add LVTS Driver support for MT8192.

Co-developed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
[bero@baylibre.com: cosmetic changes, rebase]
Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231017190545.157282-4-bero@baylibre.com
2023-10-19 02:43:06 +02:00
Balsam CHIHI 8137bb9060 thermal/drivers/mediatek/lvts_thermal: Add suspend and resume
Add suspend and resume support to LVTS driver.

Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
[bero@baylibre.com: suspend/resume in noirq phase]
Co-developed-by: Bernhard Rosenkränzer <bero@baylibre.com>
Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231017190545.157282-3-bero@baylibre.com
2023-10-19 02:41:17 +02:00
Markus Schneider-Pargmann 5055fadfa7 thermal/drivers/mediatek: Fix probe for THERMAL_V2
Fix the probe function to call mtk_thermal_release_periodic_ts for
everything != MTK_THERMAL_V1. This was accidentally changed from V1
to V2 in the original patch.

Reported-by: Frank Wunderlich <frank-w@public-files.de>
Closes: https://lore.kernel.org/lkml/B0B3775B-B8D1-4284-814F-4F41EC22F532@public-files.de/
Reported-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Closes: https://lore.kernel.org/lkml/07a569b9-e691-64ea-dd65-3b49842af33d@linaro.org/
Fixes: 33140e668b ("thermal/drivers/mediatek: Control buffer enablement tweaks")
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230918100706.1229239-1-msp@baylibre.com
2023-10-17 11:16:01 +02:00
Thierry Reding 5368084c39 thermal/drivers/max77620: Remove duplicate error message
The thermal_of_zone_register() function already prints an error message
when appropriate, so remove the extra one from the MAX77620 thermal
driver.

This fixes a spurious error message when no thermal zone was defined
for the MAX77620 in device tree.

Reported-by: Nicolas Chauvet <kwizart@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20231013155104.1781197-1-thierry.reding@gmail.com
2023-10-15 23:40:10 +02:00
Minjie Du 2ffa39c83b thermal/drivers/mediatek/lvts_thermal: Fix error check in lvts_debugfs_init()
debugfs_create_dir() function returns an error value embedded in
the pointer (PTR_ERR). Evaluate the return value using IS_ERR
rather than checking for NULL.

Signed-off-by: Minjie Du <duminjie@vivo.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230921091057.3812-1-duminjie@vivo.com
2023-10-15 23:40:10 +02:00
Bragatheswaran Manickavel f84f6e0f45 thermal/drivers/imx8mm_thermal: Fix function pointer declaration by adding identifier name
Added identifier names to respective definitions for fix
warnings reported by checkpatch.pl

WARNING: function definition argument 'void *' should also have an identifier name
WARNING: function definition argument 'int *' should also have an identifier name
Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230917083443.3220-1-bragathemanick0908@gmail.com
2023-10-15 23:40:09 +02:00
Frank Wunderlich 585e92e6a7 thermal/drivers/mediatek/lvts_thermal: Add mt7988 support
Add Support for Mediatek Filogic 880/MT7988 LVTS.

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Tested-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230922055020.6436-5-linux@fw-web.de
2023-10-15 23:40:09 +02:00
Frank Wunderlich 6725a29321 thermal/drivers/mediatek/lvts_thermal: Make coeff configurable
The upcoming mt7988 has different temperature coefficients so we
cannot use constants in the functions lvts_golden_temp_init,
lvts_golden_temp_init and lvts_raw_to_temp anymore.

Add a field in the lvts_ctrl pointing to the lvts_data which now
contains the soc-specific temperature coefficents.

To make the code better readable, rename static int coeff_b to
golden_temp_offset, COEFF_A to temp_factor and COEFF_B to temp_offset.

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Tested-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230922055020.6436-4-linux@fw-web.de
2023-10-15 23:40:09 +02:00
Srinivas Pandruvada 0e50925392 thermal: int340x: processor_thermal: Enable power floor support
Enable power floor feature support for Meteor Lake processors.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-12 21:09:48 +02:00
Srinivas Pandruvada 8cd5ad18dd thermal: int340x: processor_thermal: Handle power floor interrupts
On thermal device interrupt, if the interrupt is generated for passing
power floor status, call the callback to pass notification to the user
space.

First call proc_thermal_check_power_floor_intr() to check interrupt, if
this callback returns true, wake the IRQ thread to call
proc_thermal_power_floor_intr_callback() to notify user space.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-12 21:09:48 +02:00
Srinivas Pandruvada b473d6a9d6 thermal: int340x: processor_thermal: Support power floor notifications
When the hardware reduces the power to the minimum possible, the power
floor is notified via an interrupt.

This can happen when user space requests a power limit via powercap RAPL
interface, which forces the system to enter to the lowest power. This
power floor indication can be used as a hint to resort to other methods
of reducing power than via RAPL power limit.

Before power floor status can be read or the firmware can trigger
notifications regarding it, it needs to be configured via a mailbox
command. The actual power floor status is read via bit 39 of MMIO
offset 0x5B18 of the processor thermal PCI device.

To show the current power floor status and get notification
on a sysfs attribute, add 2 new attributes to
/sys/bus/pci/devices/0000\:00\:04.0/power_limits/

power_floor_enable : This attribute is present when power floor
 notifications are supported. This attribute allows to enable/disable
 power floor notifications.

power_floor_status : This attribute is present when power floor
 notifications are supported. When enabled via power_floor_enable, this
 attribute shows the current power floor status.

The power floor implementation provides interfaces which are called
from the sysfs callbacks to enable/disable and read power floor
status. It also provides two additional interfaces to check if the
current processor thermal device interrupt is for power floor status
and to send notifications to user space.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Changelog and documentation changes edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-12 21:09:48 +02:00
Srinivas Pandruvada 6ebc25d8b0 thermal: int340x: processor_thermal: Set feature mask before proc_thermal_add
The function proc_thermal_add() adds sysfs entries for power limits.

The feature mask of available features is not present at that time, so
it cannot be used by proc_thermal_add() to selectively create sysfs
attributes.

The feature mask is set by proc_thermal_mmio_add(), so modify the code
to call it before proc_thermal_add() so as to allow the latter to use
the feature mask.

There is no functional impact with this change.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-12 21:09:48 +02:00
Srinivas Pandruvada 088f16f352 thermal: int340x: processor_thermal: Common function to clear SOC interrupt
The SOC interrupt status register contains multiple interrupt sources
(workload hint interrupt and power floor interrupt). It is not possible
to clear individual interrupt source with read-modify-write, as it may
clear the new interrupt from the firmware after a read operation. It is
also not possible to set the interrupt status bit to 1 for the other
interrupt source, which is not part of clearing.

Hence, create a common function, to clear all status bits at once.

Call this function after processing all interrupt sources.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-12 21:09:48 +02:00
Srinivas Pandruvada 24e4c26202 thermal: int340x: processor_thermal: Move interrupt status MMIO offset to common header
Move define SOC_WT_RES_INT_STATUS_OFFSET to processor_thermal_device.h.

This way it can be reused in other modules.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-12 21:09:48 +02:00
Rafael J. Wysocki d3bff62770 Merge branch 'thermal-misc'
Merge thermal control changes related to switching over platform drivers
to using void remove callbacks.

* thermal-misc: (31 commits)
  thermal: amlogic: Convert to platform remove callback returning void
  thermal: uniphier: Convert to platform remove callback returning void
  thermal: ti-bandgap: Convert to platform remove callback returning void
  thermal: tegra-bpmp: Convert to platform remove callback returning void
  thermal: soctherm: Convert to platform remove callback returning void
  thermal: stm: Convert to platform remove callback returning void
  thermal: sprd: Convert to platform remove callback returning void
  thermal: spear: Convert to platform remove callback returning void
  thermal: exynos_tmu: Convert to platform remove callback returning void
  thermal: rzg2l: Convert to platform remove callback returning void
  thermal: rockchip: Convert to platform remove callback returning void
  thermal: rcar: Convert to platform remove callback returning void
  thermal: rcar_gen3: Convert to platform remove callback returning void
  thermal: tsens: Convert to platform remove callback returning void
  thermal: lvts: Convert to platform remove callback returning void
  thermal: kirkwood: Convert to platform remove callback returning void
  thermal: k3_j72xx_bandgap: Convert to platform remove callback returning void
  thermal: k3_bandgap: Convert to platform remove callback returning void
  thermal: int3406: Convert to platform remove callback returning void
  thermal: int3403: Convert to platform remove callback returning void
  ...
2023-10-12 20:08:28 +02:00
Rafael J. Wysocki a26b452e83 Merge branch 'acpi-thermal'
The ACPI thermal driver changes include some thermal core modifications
that are depended on by subsequent thermal core changes, so merge them.

* acpi-thermal: (26 commits)
  thermal: trip: Drop lockdep assertion from thermal_zone_trip_id()
  thermal: trip: Remove lockdep assertion from for_each_thermal_trip()
  thermal: core: Drop thermal_zone_device_exec()
  ACPI: thermal: Use thermal_zone_for_each_trip() for updating trips
  ACPI: thermal: Combine passive and active trip update functions
  ACPI: thermal: Move get_active_temp()
  ACPI: thermal: Fix up function header formatting in two places
  ACPI: thermal: Drop list of device ACPI handles from struct acpi_thermal
  ACPI: thermal: Rename structure fields holding temperature in deci-Kelvin
  ACPI: thermal: Drop critical_valid and hot_valid trip flags
  ACPI: thermal: Do not use trip indices for cooling device binding
  ACPI: thermal: Mark uninitialized active trips as invalid
  ACPI: thermal: Merge trip initialization functions
  ACPI: thermal: Collapse trip devices update function wrappers
  ACPI: thermal: Collapse trip devices update functions
  ACPI: thermal: Add device list to struct acpi_thermal_trip
  ACPI: thermal: Fix a small leak in acpi_thermal_add()
  ACPI: thermal: Drop valid flag from struct acpi_thermal_trip
  ACPI: thermal: Drop redundant trip point flags
  ACPI: thermal: Untangle initialization and updates of active trips
  ...
2023-10-11 17:56:51 +02:00
Rafael J. Wysocki 108ffd12be thermal: trip: Drop lockdep assertion from thermal_zone_trip_id()
The lockdep assertion in thermal_zone_trip_id() triggers when the
trip point sysfs attribute of a thermal instance is read, because
there is no thermal zone locking in that code path.

This is not verly useful, though, because there is no mechanism by which
the location of the trips[] table in a thermal zone or its size can
change after binding cooling devices to the trips in that thermal
zone and before those cooling devices are unbound from them.  Thus
it is not in fact necessary to hold the thermal zone lock when
thermal_zone_trip_id() is called from trip_point_show() and so the
lockdep asserion in the former is invalid.

Accordingly, drop that lockdep assertion.

Fixes: 2c7b4bfade ("thermal: core: Store trip pointer in struct thermal_instance")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-11 17:45:42 +02:00
Dan Carpenter c99626092e thermal: core: prevent potential string overflow
The dev->id value comes from ida_alloc() so it's a number between zero
and INT_MAX.  If it's too high then these sprintf()s will overflow.

Fixes: 203d3d4aa4 ("the generic thermal sysfs driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-11 16:15:09 +02:00
Kees Cook 86748637bf drivers: thermal: tsens: Annotate struct tsens_priv with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct tsens_priv.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Thara Gopinath <thara.gopinath@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Reviewed-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20230922175341.work.919-kees@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
2023-10-08 22:46:05 -07:00
Rafael J. Wysocki b44444027c thermal: trip: Remove lockdep assertion from for_each_thermal_trip()
The lockdep assertion in for_each_thermal_trip() was added to possibly
catch incorrect usage of that function without the thermal zone lock.
However, it turns out that the ACPI thermal driver has a legitimate
reason to call for_each_thermal_trip() without locking.

Namely, it is called by acpi_thermal_bind_unbind_cdev() in the thermal
zone registration and unregistration paths.  That function cannot acquire
the thermal zone lock by itself, because it calls functions that acquire
it, thermal_bind_cdev_to_trip() or thermal_unbind_cdev_from_trip().
However, it is invoked when the ACPI notify handler for the thermal
zone in question has not been registered yet (in the registration path)
or after that handler has been unregistered (in the unregistration
path).  Therefore, when for_each_thermal_trip() is called by
acpi_thermal_bind_unbind_cdev(), thermal trip changes induced by the
platform firmware cannot take place and so the thermal zone's trips[]
table is effectively immutable.  Hence, it is valid to call
for_each_thermal_trip() from acpi_thermal_bind_unbind_cdev() without
locking and the lockdep assertion in the former is in fact incorrect, so
remove it.

Fixes: d5ea889246 ("ACPI: thermal: Do not use trip indices for cooling device binding")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-07 13:29:22 +02:00
David Arcari fae633cfb7 thermal: intel: powerclamp: fix mismatch in get function for max_idle
KASAN reported this

      [ 444.853098] BUG: KASAN: global-out-of-bounds in param_get_int+0x77/0x90
      [ 444.853111] Read of size 4 at addr ffffffffc16c9220 by task cat/2105
      ...
      [ 444.853442] The buggy address belongs to the variable:
      [ 444.853443] max_idle+0x0/0xffffffffffffcde0 [intel_powerclamp]

There is a mismatch between the param_get_int and the definition of
max_idle.  Replacing param_get_int with param_get_byte resolves this
issue.

Fixes: ebf5197102 ("thermal: intel: powerclamp: Add two module parameters")
Cc: 6.3+ <stable@vger.kernel.org> # 6.3+
Signed-off-by: David Arcari <darcari@redhat.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-05 20:18:03 +02:00
Rafael J. Wysocki 4963e34ce7 thermal: core: Drop thermal_zone_device_exec()
Because thermal_zone_device_exec() has no users any more and there are
no plans to use it anywhere, revert commit 9a99a996d1 ("thermal: core:
Introduce thermal_zone_device_exec()") that introduced it.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-10-05 13:32:55 +02:00
Rafael J. Wysocki cd3c00e776 thermal: int340x: Use thermal_zone_for_each_trip()
Modify int340x_thermal_update_trips() to use thermal_zone_for_each_trip()
for walking trips instead of using the trips[] table passed to the
thermal zone registration function.

For this purpose, store active trip point indices in the priv fieids of
the corresponding thermal_trip structures.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-10-05 13:31:15 +02:00
Rafael J. Wysocki 2cbe1a3331 Merge earlier changes in Intel thermal drivers for v6.7. 2023-10-05 13:24:25 +02:00
Rafael J. Wysocki a56cc0a833 thermal: core: Add function to walk trips under zone lock
Add a wrapper around for_each_thermal_trip(), called
thermal_zone_for_each_trip(), that will invoke the former under the
thermal zone lock and pass its return value to the caller.

Two drivers will be modified subsequently to use this new function.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2023-10-05 13:13:40 +02:00
Uwe Kleine-König eea6c26207 thermal: amlogic: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

amlogic_thermal_disable() always returned zero. Change it to return no
value and then trivially convert the driver to .remove_new() and fix a
whitespace inconsitency en passant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:19 +02:00
Uwe Kleine-König 439f0bb3a7 thermal: uniphier: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:17 +02:00
Uwe Kleine-König f3e38da002 thermal: ti-bandgap: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:15 +02:00
Uwe Kleine-König f021f05262 thermal: tegra-bpmp: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:13 +02:00
Uwe Kleine-König f1afede9e2 thermal: soctherm: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:11 +02:00
Uwe Kleine-König ca92bdec59 thermal: stm: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:09 +02:00
Uwe Kleine-König 295b117645 thermal: sprd: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:08 +02:00
Uwe Kleine-König 7c2714a1e6 thermal: spear: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:06 +02:00
Uwe Kleine-König 0b478d7b86 thermal: exynos_tmu: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-10-02 14:24:02 +02:00