mbox series

[V2,0/6] thermal/intel: Introduce intel-tcc lib and enhance tjmax handling

Message ID 20221219154620.3630-1-rui.zhang@intel.com (mailing list archive)
Headers show
Series thermal/intel: Introduce intel-tcc lib and enhance tjmax handling | expand

Message

Zhang Rui Dec. 19, 2022, 3:46 p.m. UTC
Currently, all the thermal drivers that access the Intel CPU TCC (thermal
control circuitry) MSRs have two problems,
1. they have their own implementation for the same TCC functionalities,
   including getting the tjmax/temperature, getting/setting the TCC offset.
   This introduces a lot of duplicate code.
2. they get TjMax value once and always use the cached value later.
   But Tjmax value retrieved from MSR_IA32_TEMPERATURE_TARGET can be changed
   at runtime for cases like the Intel SST-PP (Intel Speed Select Technology-
   Performance Profile) level change.

The intel-tcc library is introduced in patch 1/6 for cleaning up the duplicate
code among these drivers, and it also ensures the temperature is alway got
based on the updated tjmax value.

Patch 2 ~ 5 cleans up the drivers by using the new Intel TCC lib APIs.

Patch 6/6 enhances the x86_pkg_temp driver to handle dynamic tjmax when
progamming the thermal interrupt threshold.
Actually, the thermal interrupt threshold programming can also be part of the
TCC library, but I didn't do it in this version because x86_pkg_temp is the
only user for now.

thanks,
rui

---
Changes since V1:
 - remove unnecessary API parameters
 - avoid reading MSR on a remote CPU when possible
 - coding format improvements

Comments

Rafael J. Wysocki Dec. 30, 2022, 6:59 p.m. UTC | #1
On Mon, Dec 19, 2022 at 4:39 PM Zhang Rui <rui.zhang@intel.com> wrote:
>
> Currently, all the thermal drivers that access the Intel CPU TCC (thermal
> control circuitry) MSRs have two problems,
> 1. they have their own implementation for the same TCC functionalities,
>    including getting the tjmax/temperature, getting/setting the TCC offset.
>    This introduces a lot of duplicate code.
> 2. they get TjMax value once and always use the cached value later.
>    But Tjmax value retrieved from MSR_IA32_TEMPERATURE_TARGET can be changed
>    at runtime for cases like the Intel SST-PP (Intel Speed Select Technology-
>    Performance Profile) level change.
>
> The intel-tcc library is introduced in patch 1/6 for cleaning up the duplicate
> code among these drivers, and it also ensures the temperature is alway got
> based on the updated tjmax value.
>
> Patch 2 ~ 5 cleans up the drivers by using the new Intel TCC lib APIs.
>
> Patch 6/6 enhances the x86_pkg_temp driver to handle dynamic tjmax when
> progamming the thermal interrupt threshold.
> Actually, the thermal interrupt threshold programming can also be part of the
> TCC library, but I didn't do it in this version because x86_pkg_temp is the
> only user for now.

All patches applied as 6.3 material, thanks!