]> www.infradead.org Git - users/jedix/linux-maple.git/commit
thermal: core: Fix rounding of delay jiffies
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 22 Aug 2024 19:47:36 +0000 (21:47 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 23 Aug 2024 13:53:53 +0000 (15:53 +0200)
commit8144dbe68c493baa412d78f41a57e90a6461f6c3
tree1149afbf6939d4ae85a53abef6d50ac97ff3d96e
parent18749317d12e12095c5b4cb1634c93a14585bfba
thermal: core: Fix rounding of delay jiffies

Using round_jiffies() in thermal_set_delay_jiffies() is invalid because
its argument should be time in the future in absolute jiffies and it
computes the result with respect to the current jiffies value at the
invocation time.  Fortunately, in the majority of cases it does not
make any difference due to the time_is_after_jiffies() check in
round_jiffies_common().

While using round_jiffies_relative() instead of round_jiffies() might
reflect the intent a bit better, it still would not be defensible
because that function should be called when the timer is about to be
set and it is not suitable for pre-computation of delay values.

Accordingly, drop thermal_set_delay_jiffies() altogether, simply
convert polling_delay and passive_delay to jiffies during thermal
zone initialization and make thermal_zone_device_set_polling() call
round_jiffies_relative() on the delay if it is greather than 1 second.

Fixes: 17d399cd9c89 ("thermal/core: Precompute the delays from msecs to jiffies")
Fixes: e5f2cda61d06 ("thermal/core: Move thermal_set_delay_jiffies to static")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://patch.msgid.link/1994438.PYKUYFuaPT@rjwysocki.net
drivers/thermal/thermal_core.c