thermal: intel: hfi: Enable HFI only when required
authorStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Fri, 23 Feb 2024 15:59:42 +0000 (16:59 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 27 Mar 2024 13:50:26 +0000 (14:50 +0100)
commitb33f3d2677b8ddd7a3aba2b02497422a1d2c2a01
tree503f477b6391852b4911f9c21ce15ba92c0353eb
parentafdaff3706918b7414e0741c4c5c20a12726a207
thermal: intel: hfi: Enable HFI only when required

Enable and disable hardware feedback interface (HFI) when user space
handler is present. For example, enable HFI, when intel-speed-select or
Intel Low Power daemon is running and subscribing to thermal netlink
events. When user space handlers exit or remove subscription for
thermal netlink events, disable HFI.

Summary of changes:

 - Register a thermal genetlink notifier

 - In the notifier, process THERMAL_NOTIFY_BIND and THERMAL_NOTIFY_UNBIND
   reason codes to count number of thermal event group netlink multicast
   clients. If thermal netlink group has any listener enable HFI on all
   packages. If there are no listener disable HFI on all packages.

- When CPU is online, instead of blindly enabling HFI, check if
  the thermal netlink group has any listener. This will make sure that
  HFI is not enabled by default during boot time.

- Actual processing to enable/disable matches what is done in
  suspend/resume callbacks. Create two functions hfi_enable_instance()
  and hfi_disable_instance(), which can be called from the netlink
  notifier callback and suspend/resume callbacks.

Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/intel/intel_hfi.c