Patch "timekeeping: Fix cross-timestamp interpolation for non-x86" has been added to the 5.15-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

    timekeeping: Fix cross-timestamp interpolation for non-x86

to the 5.15-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:
     timekeeping-fix-cross-timestamp-interpolation-for-no.patch
and it can be found in the queue-5.15 subdirectory.

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



commit 67fcb0b09ba9225a452a8a68de6873528bd65830
Author: Peter Hilber <peter.hilber@xxxxxxxxxxxxxxx>
Date:   Mon Dec 18 08:38:41 2023 +0100

    timekeeping: Fix cross-timestamp interpolation for non-x86
    
    [ Upstream commit 14274d0bd31b4debf28284604589f596ad2e99f2 ]
    
    So far, get_device_system_crosststamp() unconditionally passes
    system_counterval.cycles to timekeeping_cycles_to_ns(). But when
    interpolating system time (do_interp == true), system_counterval.cycles is
    before tkr_mono.cycle_last, contrary to the timekeeping_cycles_to_ns()
    expectations.
    
    On x86, CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE will mitigate on
    interpolating, setting delta to 0. With delta == 0, xtstamp->sys_monoraw
    and xtstamp->sys_realtime are then set to the last update time, as
    implicitly expected by adjust_historical_crosststamp(). On other
    architectures, the resulting nonsense xtstamp->sys_monoraw and
    xtstamp->sys_realtime corrupt the xtstamp (ts) adjustment in
    adjust_historical_crosststamp().
    
    Fix this by deriving xtstamp->sys_monoraw and xtstamp->sys_realtime from
    the last update time when interpolating, by using the local variable
    "cycles". The local variable already has the right value when
    interpolating, unlike system_counterval.cycles.
    
    Fixes: 2c756feb18d9 ("time: Add history to cross timestamp interface supporting slower devices")
    Signed-off-by: Peter Hilber <peter.hilber@xxxxxxxxxxxxxxx>
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Acked-by: John Stultz <jstultz@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231218073849.35294-4-peter.hilber@xxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index d21280b3b2ea7..dfa6649c490de 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1244,10 +1244,8 @@ int get_device_system_crosststamp(int (*get_time_fn)
 				      tk_core.timekeeper.offs_real);
 		base_raw = tk->tkr_raw.base;
 
-		nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono,
-						     system_counterval.cycles);
-		nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw,
-						    system_counterval.cycles);
+		nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, cycles);
+		nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, cycles);
 	} while (read_seqcount_retry(&tk_core.seq, seq));
 
 	xtstamp->sys_realtime = ktime_add_ns(base_real, nsec_real);




[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