Patch "thermal: core: Fix rounding of delay jiffies" has been added to the 6.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    thermal: core: Fix rounding of delay jiffies

to the 6.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     thermal-core-fix-rounding-of-delay-jiffies.patch
and it can be found in the queue-6.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 69d02222411206ba2b0ac4c6e506ec1aa24fbf7d
Author: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Date:   Thu Aug 22 21:47:36 2024 +0200

    thermal: core: Fix rounding of delay jiffies
    
    [ Upstream commit 8144dbe68c493baa412d78f41a57e90a6461f6c3 ]
    
    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@xxxxxxxxx>
    Reviewed-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
    Link: https://patch.msgid.link/1994438.PYKUYFuaPT@xxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 99a8c06f6964d..d0e71698b3562 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -323,11 +323,15 @@ static void thermal_zone_broken_disable(struct thermal_zone_device *tz)
 static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
 					    unsigned long delay)
 {
-	if (delay)
-		mod_delayed_work(system_freezable_power_efficient_wq,
-				 &tz->poll_queue, delay);
-	else
+	if (!delay) {
 		cancel_delayed_work(&tz->poll_queue);
+		return;
+	}
+
+	if (delay > HZ)
+		delay = round_jiffies_relative(delay);
+
+	mod_delayed_work(system_freezable_power_efficient_wq, &tz->poll_queue, delay);
 }
 
 static void thermal_zone_recheck(struct thermal_zone_device *tz, int error)
@@ -1327,13 +1331,6 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
 }
 EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
 
-static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms)
-{
-	*delay_jiffies = msecs_to_jiffies(delay_ms);
-	if (delay_ms > 1000)
-		*delay_jiffies = round_jiffies(*delay_jiffies);
-}
-
 int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
 {
 	const struct thermal_trip_desc *td;
@@ -1470,8 +1467,8 @@ thermal_zone_device_register_with_trips(const char *type,
 		td->threshold = INT_MAX;
 	}
 
-	thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay);
-	thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay);
+	tz->polling_delay_jiffies = msecs_to_jiffies(polling_delay);
+	tz->passive_delay_jiffies = msecs_to_jiffies(passive_delay);
 	tz->recheck_delay_jiffies = THERMAL_RECHECK_DELAY;
 
 	/* sys I/F */




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux