]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
fix up ntp patch
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Dec 2024 15:21:48 +0000 (16:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Dec 2024 15:21:48 +0000 (16:21 +0100)
33 files changed:
queue-6.1/ntp-clean-up-comments.patch [deleted file]
queue-6.1/ntp-cleanup-formatting-of-code.patch [deleted file]
queue-6.1/ntp-convert-functions-with-only-two-states-to-bool.patch [deleted file]
queue-6.1/ntp-introduce-struct-ntp_data.patch [deleted file]
queue-6.1/ntp-make-tick_usec-static.patch [deleted file]
queue-6.1/ntp-move-tick_length-into-ntp_data.patch [deleted file]
queue-6.1/ntp-move-tick_stat-into-ntp_data.patch [deleted file]
queue-6.1/ntp-read-reference-time-only-once.patch [deleted file]
queue-6.1/ntp-remove-invalid-cast-in-time-offset-math.patch
queue-6.1/ntp-remove-unused-tick_nsec.patch [deleted file]
queue-6.1/series
queue-6.12/ntp-clean-up-comments.patch [deleted file]
queue-6.12/ntp-cleanup-formatting-of-code.patch [deleted file]
queue-6.12/ntp-convert-functions-with-only-two-states-to-bool.patch [deleted file]
queue-6.12/ntp-introduce-struct-ntp_data.patch [deleted file]
queue-6.12/ntp-make-tick_usec-static.patch [deleted file]
queue-6.12/ntp-move-tick_length-into-ntp_data.patch [deleted file]
queue-6.12/ntp-move-tick_stat-into-ntp_data.patch [deleted file]
queue-6.12/ntp-read-reference-time-only-once.patch [deleted file]
queue-6.12/ntp-remove-invalid-cast-in-time-offset-math.patch
queue-6.12/ntp-remove-unused-tick_nsec.patch [deleted file]
queue-6.12/series
queue-6.6/ntp-clean-up-comments.patch [deleted file]
queue-6.6/ntp-cleanup-formatting-of-code.patch [deleted file]
queue-6.6/ntp-convert-functions-with-only-two-states-to-bool.patch [deleted file]
queue-6.6/ntp-introduce-struct-ntp_data.patch [deleted file]
queue-6.6/ntp-make-tick_usec-static.patch [deleted file]
queue-6.6/ntp-move-tick_length-into-ntp_data.patch [deleted file]
queue-6.6/ntp-move-tick_stat-into-ntp_data.patch [deleted file]
queue-6.6/ntp-read-reference-time-only-once.patch [deleted file]
queue-6.6/ntp-remove-invalid-cast-in-time-offset-math.patch
queue-6.6/ntp-remove-unused-tick_nsec.patch [deleted file]
queue-6.6/series

diff --git a/queue-6.1/ntp-clean-up-comments.patch b/queue-6.1/ntp-clean-up-comments.patch
deleted file mode 100644 (file)
index 4da4615..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-From dc1a0747f25c931ab99f216fe2e2474ed89719c9 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:39 +0200
-Subject: ntp: Clean up comments
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit a0581cdb2e5d3ad633e51a945b6f0527ce70b68a ]
-
-Usage of different comment formatting makes fast reading and parsing the
-code harder. There are several multi-line comments which do not follow the
-coding style by starting with a line only containing '/*'. There are also
-comments which do not start with capitals.
-
-Clean up all those comments to be consistent and remove comments which
-document the obvious.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-3-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 144 +++++++++++++++++++++++++---------------------
- 1 file changed, 78 insertions(+), 66 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 8e68a85996f7d..99213d931f63f 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -119,7 +119,8 @@ static long pps_stbcnt;            /* stability limit exceeded */
- static long pps_errcnt;               /* calibration errors */
--/* PPS kernel consumer compensates the whole phase error immediately.
-+/*
-+ * PPS kernel consumer compensates the whole phase error immediately.
-  * Otherwise, reduce the offset by a fixed factor times the time constant.
-  */
- static inline s64 ntp_offset_chunk(s64 offset)
-@@ -132,8 +133,7 @@ static inline s64 ntp_offset_chunk(s64 offset)
- static inline void pps_reset_freq_interval(void)
- {
--      /* the PPS calibration interval may end
--         surprisingly early */
-+      /* The PPS calibration interval may end surprisingly early */
-       pps_shift = PPS_INTMIN;
-       pps_intcnt = 0;
- }
-@@ -151,9 +151,9 @@ static inline void pps_clear(void)
-       pps_freq = 0;
- }
--/* Decrease pps_valid to indicate that another second has passed since
-- * the last PPS signal. When it reaches 0, indicate that PPS signal is
-- * missing.
-+/*
-+ * Decrease pps_valid to indicate that another second has passed since the
-+ * last PPS signal. When it reaches 0, indicate that PPS signal is missing.
-  */
- static inline void pps_dec_valid(void)
- {
-@@ -174,17 +174,21 @@ static inline void pps_set_freq(s64 freq)
- static inline int is_error_status(int status)
- {
-       return (status & (STA_UNSYNC|STA_CLOCKERR))
--              /* PPS signal lost when either PPS time or
--               * PPS frequency synchronization requested
-+              /*
-+               * PPS signal lost when either PPS time or PPS frequency
-+               * synchronization requested
-                */
-               || ((status & (STA_PPSFREQ|STA_PPSTIME))
-                       && !(status & STA_PPSSIGNAL))
--              /* PPS jitter exceeded when
--               * PPS time synchronization requested */
-+              /*
-+               * PPS jitter exceeded when PPS time synchronization
-+               * requested
-+               */
-               || ((status & (STA_PPSTIME|STA_PPSJITTER))
-                       == (STA_PPSTIME|STA_PPSJITTER))
--              /* PPS wander exceeded or calibration error when
--               * PPS frequency synchronization requested
-+              /*
-+               * PPS wander exceeded or calibration error when PPS
-+               * frequency synchronization requested
-                */
-               || ((status & STA_PPSFREQ)
-                       && (status & (STA_PPSWANDER|STA_PPSERROR)));
-@@ -270,8 +274,8 @@ static void ntp_update_frequency(void)
-       new_base                 = div_u64(second_length, NTP_INTERVAL_FREQ);
-       /*
--       * Don't wait for the next second_overflow, apply
--       * the change to the tick length immediately:
-+       * Don't wait for the next second_overflow, apply the change to the
-+       * tick length immediately:
-        */
-       tick_length             += new_base - tick_length_base;
-       tick_length_base         = new_base;
-@@ -307,10 +311,7 @@ static void ntp_update_offset(long offset)
-               offset *= NSEC_PER_USEC;
-       }
--      /*
--       * Scale the phase adjustment and
--       * clamp to the operating range.
--       */
-+      /* Scale the phase adjustment and clamp to the operating range. */
-       offset = clamp(offset, -MAXPHASE, MAXPHASE);
-       /*
-@@ -349,7 +350,8 @@ static void ntp_update_offset(long offset)
-  */
- void ntp_clear(void)
- {
--      time_adjust     = 0;            /* stop active adjtime() */
-+      /* Stop active adjtime() */
-+      time_adjust     = 0;
-       time_status     |= STA_UNSYNC;
-       time_maxerror   = NTP_PHASE_LIMIT;
-       time_esterror   = NTP_PHASE_LIMIT;
-@@ -387,7 +389,7 @@ ktime_t ntp_get_next_leap(void)
- }
- /*
-- * this routine handles the overflow of the microsecond field
-+ * This routine handles the overflow of the microsecond field
-  *
-  * The tricky bits of code to handle the accurate clock support
-  * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame.
-@@ -452,7 +454,6 @@ int second_overflow(time64_t secs)
-               break;
-       }
--
-       /* Bump the maxerror field */
-       time_maxerror += MAXFREQ / NSEC_PER_USEC;
-       if (time_maxerror > NTP_PHASE_LIMIT) {
-@@ -688,7 +689,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-               time_state = TIME_OK;
-               time_status = STA_UNSYNC;
-               ntp_next_leap_sec = TIME64_MAX;
--              /* restart PPS frequency calibration */
-+              /* Restart PPS frequency calibration */
-               pps_reset_freq_interval();
-       }
-@@ -699,7 +700,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-       if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
-               time_reftime = __ktime_get_real_seconds();
--      /* only set allowed bits */
-+      /* Only set allowed bits */
-       time_status &= STA_RONLY;
-       time_status |= txc->status & ~STA_RONLY;
- }
-@@ -721,7 +722,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-               time_freq = txc->freq * PPM_SCALE;
-               time_freq = min(time_freq, MAXFREQ_SCALED);
-               time_freq = max(time_freq, -MAXFREQ_SCALED);
--              /* update pps_freq */
-+              /* Update pps_freq */
-               pps_set_freq(time_freq);
-       }
-@@ -754,7 +755,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
- /*
-- * adjtimex mainly allows reading (and writing, if superuser) of
-+ * adjtimex() mainly allows reading (and writing, if superuser) of
-  * kernel time-keeping variables. used by xntpd.
-  */
- int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-@@ -798,8 +799,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       txc->offset = (u32)txc->offset / NSEC_PER_USEC;
-       }
--      result = time_state;    /* mostly `TIME_OK' */
--      /* check for errors */
-+      result = time_state;
-       if (is_error_status(time_status))
-               result = TIME_ERROR;
-@@ -814,7 +814,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->tick          = tick_usec;
-       txc->tai           = *time_tai;
--      /* fill PPS status fields */
-+      /* Fill PPS status fields */
-       pps_fill_timex(txc);
-       txc->time.tv_sec = ts->tv_sec;
-@@ -845,17 +845,21 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
- #ifdef        CONFIG_NTP_PPS
--/* actually struct pps_normtime is good old struct timespec, but it is
-+/*
-+ * struct pps_normtime is basically a struct timespec, but it is
-  * semantically different (and it is the reason why it was invented):
-  * pps_normtime.nsec has a range of ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ]
-- * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC) */
-+ * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC)
-+ */
- struct pps_normtime {
-       s64             sec;    /* seconds */
-       long            nsec;   /* nanoseconds */
- };
--/* normalize the timestamp so that nsec is in the
--   ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval */
-+/*
-+ * Normalize the timestamp so that nsec is in the
-+ * [ -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval
-+ */
- static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts)
- {
-       struct pps_normtime norm = {
-@@ -871,7 +875,7 @@ static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts)
-       return norm;
- }
--/* get current phase correction and jitter */
-+/* Get current phase correction and jitter */
- static inline long pps_phase_filter_get(long *jitter)
- {
-       *jitter = pps_tf[0] - pps_tf[1];
-@@ -882,7 +886,7 @@ static inline long pps_phase_filter_get(long *jitter)
-       return pps_tf[0];
- }
--/* add the sample to the phase filter */
-+/* Add the sample to the phase filter */
- static inline void pps_phase_filter_add(long err)
- {
-       pps_tf[2] = pps_tf[1];
-@@ -890,8 +894,9 @@ static inline void pps_phase_filter_add(long err)
-       pps_tf[0] = err;
- }
--/* decrease frequency calibration interval length.
-- * It is halved after four consecutive unstable intervals.
-+/*
-+ * Decrease frequency calibration interval length. It is halved after four
-+ * consecutive unstable intervals.
-  */
- static inline void pps_dec_freq_interval(void)
- {
-@@ -904,8 +909,9 @@ static inline void pps_dec_freq_interval(void)
-       }
- }
--/* increase frequency calibration interval length.
-- * It is doubled after four consecutive stable intervals.
-+/*
-+ * Increase frequency calibration interval length. It is doubled after
-+ * four consecutive stable intervals.
-  */
- static inline void pps_inc_freq_interval(void)
- {
-@@ -918,7 +924,8 @@ static inline void pps_inc_freq_interval(void)
-       }
- }
--/* update clock frequency based on MONOTONIC_RAW clock PPS signal
-+/*
-+ * Update clock frequency based on MONOTONIC_RAW clock PPS signal
-  * timestamps
-  *
-  * At the end of the calibration interval the difference between the
-@@ -932,7 +939,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       long delta, delta_mod;
-       s64 ftemp;
--      /* check if the frequency interval was too long */
-+      /* Check if the frequency interval was too long */
-       if (freq_norm.sec > (2 << pps_shift)) {
-               time_status |= STA_PPSERROR;
-               pps_errcnt++;
-@@ -943,9 +950,10 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               return 0;
-       }
--      /* here the raw frequency offset and wander (stability) is
--       * calculated. If the wander is less than the wander threshold
--       * the interval is increased; otherwise it is decreased.
-+      /*
-+       * Here the raw frequency offset and wander (stability) is
-+       * calculated. If the wander is less than the wander threshold the
-+       * interval is increased; otherwise it is decreased.
-        */
-       ftemp = div_s64(((s64)(-freq_norm.nsec)) << NTP_SCALE_SHIFT,
-                       freq_norm.sec);
-@@ -957,13 +965,14 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
--      } else {        /* good sample */
-+      } else {
-+              /* Good sample */
-               pps_inc_freq_interval();
-       }
--      /* the stability metric is calculated as the average of recent
--       * frequency changes, but is used only for performance
--       * monitoring
-+      /*
-+       * The stability metric is calculated as the average of recent
-+       * frequency changes, but is used only for performance monitoring
-        */
-       delta_mod = delta;
-       if (delta_mod < 0)
-@@ -972,7 +981,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-                               (NTP_SCALE_SHIFT - SHIFT_USEC),
-                               NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
--      /* if enabled, the system clock frequency is updated */
-+      /* If enabled, the system clock frequency is updated */
-       if ((time_status & STA_PPSFREQ) != 0 &&
-           (time_status & STA_FREQHOLD) == 0) {
-               time_freq = pps_freq;
-@@ -982,17 +991,18 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       return delta;
- }
--/* correct REALTIME clock phase error against PPS signal */
-+/* Correct REALTIME clock phase error against PPS signal */
- static void hardpps_update_phase(long error)
- {
-       long correction = -error;
-       long jitter;
--      /* add the sample to the median filter */
-+      /* Add the sample to the median filter */
-       pps_phase_filter_add(correction);
-       correction = pps_phase_filter_get(&jitter);
--      /* Nominal jitter is due to PPS signal noise. If it exceeds the
-+      /*
-+       * Nominal jitter is due to PPS signal noise. If it exceeds the
-        * threshold, the sample is discarded; otherwise, if so enabled,
-        * the time offset is updated.
-        */
-@@ -1003,13 +1013,13 @@ static void hardpps_update_phase(long error)
-               time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
-       } else if (time_status & STA_PPSTIME) {
--              /* correct the time using the phase offset */
-+              /* Correct the time using the phase offset */
-               time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT,
-                               NTP_INTERVAL_FREQ);
--              /* cancel running adjtime() */
-+              /* Cancel running adjtime() */
-               time_adjust = 0;
-       }
--      /* update jitter */
-+      /* Update jitter */
-       pps_jitter += (jitter - pps_jitter) >> PPS_INTMIN;
- }
-@@ -1031,41 +1041,43 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-       pts_norm = pps_normalize_ts(*phase_ts);
--      /* clear the error bits, they will be set again if needed */
-+      /* Clear the error bits, they will be set again if needed */
-       time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
--      /* indicate signal presence */
-+      /* Indicate signal presence */
-       time_status |= STA_PPSSIGNAL;
-       pps_valid = PPS_VALID;
--      /* when called for the first time,
--       * just start the frequency interval */
-+      /*
-+       * When called for the first time, just start the frequency
-+       * interval
-+       */
-       if (unlikely(pps_fbase.tv_sec == 0)) {
-               pps_fbase = *raw_ts;
-               return;
-       }
--      /* ok, now we have a base for frequency calculation */
-+      /* Ok, now we have a base for frequency calculation */
-       freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, pps_fbase));
--      /* check that the signal is in the range
--       * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */
-+      /*
-+       * Check that the signal is in the range
-+       * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it
-+       */
-       if ((freq_norm.sec == 0) ||
-                       (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-                       (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-               time_status |= STA_PPSJITTER;
--              /* restart the frequency calibration interval */
-+              /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n");
-               return;
-       }
--      /* signal is ok */
--
--      /* check if the current frequency interval is finished */
-+      /* Signal is ok. Check if the current frequency interval is finished */
-       if (freq_norm.sec >= (1 << pps_shift)) {
-               pps_calcnt++;
--              /* restart the frequency calibration interval */
-+              /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               hardpps_update_freq(freq_norm);
-       }
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-cleanup-formatting-of-code.patch b/queue-6.1/ntp-cleanup-formatting-of-code.patch
deleted file mode 100644 (file)
index a7e0710..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-From 22f156896bbf977e00bdc352addf5fa72e60fdb3 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:40 +0200
-Subject: ntp: Cleanup formatting of code
-
-From: Anna-Maria Behnsen <anna-maria@linutronix.de>
-
-[ Upstream commit 38007dc032bd90920463c5d2e6a27d89f7617d6d ]
-
-Code is partially formatted in a creative way which makes reading
-harder. Examples are function calls over several lines where the
-indentation does not start at the same height then the open bracket after
-the function name.
-
-Improve formatting but do not make a functional change.
-
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-4-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 37 +++++++++++++------------------------
- 1 file changed, 13 insertions(+), 24 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 99213d931f63f..eca9de85b0a76 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -428,8 +428,7 @@ int second_overflow(time64_t secs)
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = -1;
-                       time_state = TIME_OOP;
--                      printk(KERN_NOTICE
--                              "Clock: inserting leap second 23:59:60 UTC\n");
-+                      pr_notice("Clock: inserting leap second 23:59:60 UTC\n");
-               }
-               break;
-       case TIME_DEL:
-@@ -440,8 +439,7 @@ int second_overflow(time64_t secs)
-                       leap = 1;
-                       ntp_next_leap_sec = TIME64_MAX;
-                       time_state = TIME_WAIT;
--                      printk(KERN_NOTICE
--                              "Clock: deleting leap second 23:59:59 UTC\n");
-+                      pr_notice("Clock: deleting leap second 23:59:59 UTC\n");
-               }
-               break;
-       case TIME_OOP:
-@@ -834,10 +832,8 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       txc->tai--;
-                       txc->time.tv_sec++;
-               }
--              if ((time_state == TIME_OOP) &&
--                                      (ts->tv_sec == ntp_next_leap_sec)) {
-+              if ((time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-                       result = TIME_WAIT;
--              }
-       }
-       return result;
-@@ -944,9 +940,8 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               time_status |= STA_PPSERROR;
-               pps_errcnt++;
-               pps_dec_freq_interval();
--              printk_deferred(KERN_ERR
--                      "hardpps: PPSERROR: interval too long - %lld s\n",
--                      freq_norm.sec);
-+              printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n",
-+                              freq_norm.sec);
-               return 0;
-       }
-@@ -960,8 +955,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       delta = shift_right(ftemp - pps_freq, NTP_SCALE_SHIFT);
-       pps_freq = ftemp;
-       if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
--              printk_deferred(KERN_WARNING
--                              "hardpps: PPSWANDER: change=%ld\n", delta);
-+              printk_deferred(KERN_WARNING "hardpps: PPSWANDER: change=%ld\n", delta);
-               time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
-@@ -977,13 +971,11 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       delta_mod = delta;
-       if (delta_mod < 0)
-               delta_mod = -delta_mod;
--      pps_stabil += (div_s64(((s64)delta_mod) <<
--                              (NTP_SCALE_SHIFT - SHIFT_USEC),
--                              NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-+      pps_stabil += (div_s64(((s64)delta_mod) << (NTP_SCALE_SHIFT - SHIFT_USEC),
-+                             NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-       /* If enabled, the system clock frequency is updated */
--      if ((time_status & STA_PPSFREQ) != 0 &&
--          (time_status & STA_FREQHOLD) == 0) {
-+      if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
-               ntp_update_frequency();
-       }
-@@ -1007,15 +999,13 @@ static void hardpps_update_phase(long error)
-        * the time offset is updated.
-        */
-       if (jitter > (pps_jitter << PPS_POPCORN)) {
--              printk_deferred(KERN_WARNING
--                              "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-+              printk_deferred(KERN_WARNING "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-                               jitter, (pps_jitter << PPS_POPCORN));
-               time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
-       } else if (time_status & STA_PPSTIME) {
-               /* Correct the time using the phase offset */
--              time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT,
--                              NTP_INTERVAL_FREQ);
-+              time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
-               /* Cancel running adjtime() */
-               time_adjust = 0;
-       }
-@@ -1064,9 +1054,8 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-        * Check that the signal is in the range
-        * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it
-        */
--      if ((freq_norm.sec == 0) ||
--                      (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
--                      (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-+      if ((freq_norm.sec == 0) || (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-+          (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-               time_status |= STA_PPSJITTER;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-convert-functions-with-only-two-states-to-bool.patch b/queue-6.1/ntp-convert-functions-with-only-two-states-to-bool.patch
deleted file mode 100644 (file)
index 3153315..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-From 528b3e759c7b9e18f3f69e24f9095e960cec83d8 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:41 +0200
-Subject: ntp: Convert functions with only two states to bool
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 48c3c65f64b01164f1704b40b38f60837d484f13 ]
-
-is_error_status() and ntp_synced() return whether a state is set or
-not. Both functions use unsigned int for it even if it would be a perfect
-job for a bool.
-
-Use bool instead of unsigned int. And while at it, move ntp_synced()
-function to the place where it is used.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-5-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 28 +++++++++++-----------------
- 1 file changed, 11 insertions(+), 17 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index eca9de85b0a76..ef758aafdfd54 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -171,7 +171,7 @@ static inline void pps_set_freq(s64 freq)
-       pps_freq = freq;
- }
--static inline int is_error_status(int status)
-+static inline bool is_error_status(int status)
- {
-       return (status & (STA_UNSYNC|STA_CLOCKERR))
-               /*
-@@ -221,7 +221,7 @@ static inline void pps_clear(void) {}
- static inline void pps_dec_valid(void) {}
- static inline void pps_set_freq(s64 freq) {}
--static inline int is_error_status(int status)
-+static inline bool is_error_status(int status)
- {
-       return status & (STA_UNSYNC|STA_CLOCKERR);
- }
-@@ -241,21 +241,6 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
- #endif /* CONFIG_NTP_PPS */
--
--/**
-- * ntp_synced - Returns 1 if the NTP status is not UNSYNC
-- *
-- */
--static inline int ntp_synced(void)
--{
--      return !(time_status & STA_UNSYNC);
--}
--
--
--/*
-- * NTP methods:
-- */
--
- /*
-  * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-  * time_freq:
-@@ -609,6 +594,15 @@ static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_ns
- }
- #endif
-+/**
-+ * ntp_synced - Tells whether the NTP status is not UNSYNC
-+ * Returns:   true if not UNSYNC, false otherwise
-+ */
-+static inline bool ntp_synced(void)
-+{
-+      return !(time_status & STA_UNSYNC);
-+}
-+
- /*
-  * If we have an externally synchronized Linux clock, then update RTC clock
-  * accordingly every ~11 minutes. Generally RTCs can only store second
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-introduce-struct-ntp_data.patch b/queue-6.1/ntp-introduce-struct-ntp_data.patch
deleted file mode 100644 (file)
index e105af4..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-From 57103d282a874ed716f489b7b336b8d833ba43b2 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:43 +0200
-Subject: ntp: Introduce struct ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 68f66f97c5689825012877f58df65964056d4b5d ]
-
-All NTP data is held in static variables. That prevents the NTP code from
-being reuasble for non-system time timekeepers, e.g. per PTP clock
-timekeeping.
-
-Introduce struct ntp_data and move tick_usec into it for a start.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-7-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 65 ++++++++++++++++++++++++++---------------------
- 1 file changed, 36 insertions(+), 29 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 477cb08062bc5..0222f8e460810 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -22,16 +22,19 @@
- #include "ntp_internal.h"
- #include "timekeeping_internal.h"
--
--/*
-- * NTP timekeeping variables:
-+/**
-+ * struct ntp_data - Structure holding all NTP related state
-+ * @tick_usec:                USER_HZ period in microseconds
-  *
-- * Note: All of the NTP state is protected by the timekeeping locks.
-+ * Protected by the timekeeping locks.
-  */
-+struct ntp_data {
-+      unsigned long           tick_usec;
-+};
--
--/* USER_HZ period (usecs): */
--static unsigned long          tick_usec = USER_TICK_USEC;
-+static struct ntp_data tk_ntp_data = {
-+      .tick_usec              = USER_TICK_USEC,
-+};
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -245,13 +248,11 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
-  * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-  * time_freq:
-  */
--static void ntp_update_frequency(void)
-+static void ntp_update_frequency(struct ntp_data *ntpdata)
- {
--      u64 second_length;
--      u64 new_base;
-+      u64 second_length, new_base, tick_usec = (u64)ntpdata->tick_usec;
--      second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
--                                              << NTP_SCALE_SHIFT;
-+      second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) << NTP_SCALE_SHIFT;
-       second_length           += ntp_tick_adj;
-       second_length           += time_freq;
-@@ -330,10 +331,7 @@ static void ntp_update_offset(long offset)
-       time_offset = div_s64(offset64 << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
- }
--/**
-- * ntp_clear - Clears the NTP state variables
-- */
--void ntp_clear(void)
-+static void __ntp_clear(struct ntp_data *ntpdata)
- {
-       /* Stop active adjtime() */
-       time_adjust     = 0;
-@@ -341,7 +339,7 @@ void ntp_clear(void)
-       time_maxerror   = NTP_PHASE_LIMIT;
-       time_esterror   = NTP_PHASE_LIMIT;
--      ntp_update_frequency();
-+      ntp_update_frequency(ntpdata);
-       tick_length     = tick_length_base;
-       time_offset     = 0;
-@@ -351,6 +349,14 @@ void ntp_clear(void)
-       pps_clear();
- }
-+/**
-+ * ntp_clear - Clears the NTP state variables
-+ */
-+void ntp_clear(void)
-+{
-+      __ntp_clear(&tk_ntp_data);
-+}
-+
- u64 ntp_tick_length(void)
- {
-@@ -698,7 +704,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
- }
--static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-+static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct __kernel_timex *txc,
-                                         s32 *time_tai)
- {
-       if (txc->modes & ADJ_STATUS)
-@@ -739,13 +745,12 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-               ntp_update_offset(txc->offset);
-       if (txc->modes & ADJ_TICK)
--              tick_usec = txc->tick;
-+              ntpdata->tick_usec = txc->tick;
-       if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
--              ntp_update_frequency();
-+              ntp_update_frequency(ntpdata);
- }
--
- /*
-  * adjtimex() mainly allows reading (and writing, if superuser) of
-  * kernel time-keeping variables. used by xntpd.
-@@ -753,6 +758,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
- int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                 s32 *time_tai, struct audit_ntp_data *ad)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       int result;
-       if (txc->modes & ADJ_ADJTIME) {
-@@ -761,7 +767,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-               if (!(txc->modes & ADJ_OFFSET_READONLY)) {
-                       /* adjtime() is independent from ntp_adjtime() */
-                       time_adjust = txc->offset;
--                      ntp_update_frequency();
-+                      ntp_update_frequency(ntpdata);
-                       audit_ntp_set_old(ad, AUDIT_NTP_ADJUST, save_adjust);
-                       audit_ntp_set_new(ad, AUDIT_NTP_ADJUST, time_adjust);
-@@ -774,15 +780,15 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       audit_ntp_set_old(ad, AUDIT_NTP_FREQ,   time_freq);
-                       audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TAI,    *time_tai);
--                      audit_ntp_set_old(ad, AUDIT_NTP_TICK,   tick_usec);
-+                      audit_ntp_set_old(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
--                      process_adjtimex_modes(txc, time_tai);
-+                      process_adjtimex_modes(ntpdata, txc, time_tai);
-                       audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_new(ad, AUDIT_NTP_FREQ,   time_freq);
-                       audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TAI,    *time_tai);
--                      audit_ntp_set_new(ad, AUDIT_NTP_TICK,   tick_usec);
-+                      audit_ntp_set_new(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-               }
-               txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
-@@ -803,7 +809,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->constant      = time_constant;
-       txc->precision     = 1;
-       txc->tolerance     = MAXFREQ_SCALED / PPM_SCALE;
--      txc->tick          = tick_usec;
-+      txc->tick          = ntpdata->tick_usec;
-       txc->tai           = *time_tai;
-       /* Fill PPS status fields */
-@@ -924,7 +930,7 @@ static inline void pps_inc_freq_interval(void)
-  * too long, the data are discarded.
-  * Returns the difference between old and new frequency values.
-  */
--static long hardpps_update_freq(struct pps_normtime freq_norm)
-+static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime freq_norm)
- {
-       long delta, delta_mod;
-       s64 ftemp;
-@@ -971,7 +977,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       /* If enabled, the system clock frequency is updated */
-       if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
--              ntp_update_frequency();
-+              ntp_update_frequency(ntpdata);
-       }
-       return delta;
-@@ -1022,6 +1028,7 @@ static void hardpps_update_phase(long error)
- void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts)
- {
-       struct pps_normtime pts_norm, freq_norm;
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       pts_norm = pps_normalize_ts(*phase_ts);
-@@ -1062,7 +1069,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-               pps_calcnt++;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
--              hardpps_update_freq(freq_norm);
-+              hardpps_update_freq(ntpdata, freq_norm);
-       }
-       hardpps_update_phase(pts_norm.nsec);
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-make-tick_usec-static.patch b/queue-6.1/ntp-make-tick_usec-static.patch
deleted file mode 100644 (file)
index 41a192e..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-From 19e88efd3e57092a9811244c233570a4769231d6 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:38 +0200
-Subject: ntp: Make tick_usec static
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 66606a93849bfe3cbe9f0b801b40f60b87c54e11 ]
-
-There are no users of tick_usec outside of the NTP core code. Therefore
-make tick_usec static.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-2-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/timex.h | 7 -------
- kernel/time/ntp.c     | 5 ++++-
- 2 files changed, 4 insertions(+), 8 deletions(-)
-
-diff --git a/include/linux/timex.h b/include/linux/timex.h
-index 7f7a12fd8200c..4ee32eff3f221 100644
---- a/include/linux/timex.h
-+++ b/include/linux/timex.h
-@@ -139,13 +139,6 @@ unsigned long random_get_entropy_fallback(void);
- #define MAXSEC 2048           /* max interval between updates (s) */
- #define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
--/*
-- * kernel variables
-- * Note: maximum error = NTP sync distance = dispersion + delay / 2;
-- * estimated error = NTP dispersion.
-- */
--extern unsigned long tick_usec;               /* USER_HZ period (usec) */
--
- /* Required to safely shift negative values */
- #define shift_right(x, s) ({  \
-       __typeof__(x) __x = (x);        \
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 0dba1179d81d2..8e68a85996f7d 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -31,7 +31,7 @@
- /* USER_HZ period (usecs): */
--unsigned long                 tick_usec = USER_TICK_USEC;
-+static unsigned long          tick_usec = USER_TICK_USEC;
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -44,6 +44,9 @@ static u64                   tick_length_base;
- /*
-  * phase-lock loop variables
-+ *
-+ * Note: maximum error = NTP sync distance = dispersion + delay / 2;
-+ * estimated error = NTP dispersion.
-  */
- /*
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-move-tick_length-into-ntp_data.patch b/queue-6.1/ntp-move-tick_length-into-ntp_data.patch
deleted file mode 100644 (file)
index 18e29e0..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-From 322d8eef5fadffa49c0fcf8536bcb3d74d0843c1 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:44 +0200
-Subject: ntp: Move tick_length* into ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit ec93ec22aa10fb5311c0f068ee66c5b6d39788fe ]
-
-Continue the conversion from static variables to struct based data.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-8-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 34 ++++++++++++++++++----------------
- 1 file changed, 18 insertions(+), 16 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 0222f8e460810..6c5f684328c82 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -25,20 +25,21 @@
- /**
-  * struct ntp_data - Structure holding all NTP related state
-  * @tick_usec:                USER_HZ period in microseconds
-+ * @tick_length:      Adjusted tick length
-+ * @tick_length_base: Base value for @tick_length
-  *
-  * Protected by the timekeeping locks.
-  */
- struct ntp_data {
-       unsigned long           tick_usec;
-+      u64                     tick_length;
-+      u64                     tick_length_base;
- };
- static struct ntp_data tk_ntp_data = {
-       .tick_usec              = USER_TICK_USEC,
- };
--static u64                    tick_length;
--static u64                    tick_length_base;
--
- #define SECS_PER_DAY          86400
- #define MAX_TICKADJ           500LL           /* usecs */
- #define MAX_TICKADJ_SCALED \
-@@ -263,8 +264,8 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
-        * Don't wait for the next second_overflow, apply the change to the
-        * tick length immediately:
-        */
--      tick_length             += new_base - tick_length_base;
--      tick_length_base         = new_base;
-+      ntpdata->tick_length            += new_base - ntpdata->tick_length_base;
-+      ntpdata->tick_length_base        = new_base;
- }
- static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
-@@ -341,8 +342,8 @@ static void __ntp_clear(struct ntp_data *ntpdata)
-       ntp_update_frequency(ntpdata);
--      tick_length     = tick_length_base;
--      time_offset     = 0;
-+      ntpdata->tick_length    = ntpdata->tick_length_base;
-+      time_offset             = 0;
-       ntp_next_leap_sec = TIME64_MAX;
-       /* Clear PPS state variables */
-@@ -360,7 +361,7 @@ void ntp_clear(void)
- u64 ntp_tick_length(void)
- {
--      return tick_length;
-+      return tk_ntp_data.tick_length;
- }
- /**
-@@ -391,6 +392,7 @@ ktime_t ntp_get_next_leap(void)
-  */
- int second_overflow(time64_t secs)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       s64 delta;
-       int leap = 0;
-       s32 rem;
-@@ -451,11 +453,11 @@ int second_overflow(time64_t secs)
-       }
-       /* Compute the phase adjustment for the next second */
--      tick_length      = tick_length_base;
-+      ntpdata->tick_length     = ntpdata->tick_length_base;
--      delta            = ntp_offset_chunk(time_offset);
--      time_offset     -= delta;
--      tick_length     += delta;
-+      delta                    = ntp_offset_chunk(time_offset);
-+      time_offset             -= delta;
-+      ntpdata->tick_length    += delta;
-       /* Check PPS signal */
-       pps_dec_valid();
-@@ -465,18 +467,18 @@ int second_overflow(time64_t secs)
-       if (time_adjust > MAX_TICKADJ) {
-               time_adjust -= MAX_TICKADJ;
--              tick_length += MAX_TICKADJ_SCALED;
-+              ntpdata->tick_length += MAX_TICKADJ_SCALED;
-               goto out;
-       }
-       if (time_adjust < -MAX_TICKADJ) {
-               time_adjust += MAX_TICKADJ;
--              tick_length -= MAX_TICKADJ_SCALED;
-+              ntpdata->tick_length -= MAX_TICKADJ_SCALED;
-               goto out;
-       }
--      tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
--                                                       << NTP_SCALE_SHIFT;
-+      ntpdata->tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
-+                              << NTP_SCALE_SHIFT;
-       time_adjust = 0;
- out:
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-move-tick_stat-into-ntp_data.patch b/queue-6.1/ntp-move-tick_stat-into-ntp_data.patch
deleted file mode 100644 (file)
index 1095322..0000000
+++ /dev/null
@@ -1,539 +0,0 @@
-From c52eeba3eda258130c696e0bd59c71bcd3bd86d8 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:45 +0200
-Subject: ntp: Move tick_stat* into ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit bee18a2301f97465a464176767f3a3a64f900d93 ]
-
-Continue the conversion from static variables to struct based data.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-9-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 175 ++++++++++++++++++++++------------------------
- 1 file changed, 85 insertions(+), 90 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 6c5f684328c82..6d87f9889b039 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -27,6 +27,8 @@
-  * @tick_usec:                USER_HZ period in microseconds
-  * @tick_length:      Adjusted tick length
-  * @tick_length_base: Base value for @tick_length
-+ * @time_state:               State of the clock synchronization
-+ * @time_status:      Clock status bits
-  *
-  * Protected by the timekeeping locks.
-  */
-@@ -34,10 +36,14 @@ struct ntp_data {
-       unsigned long           tick_usec;
-       u64                     tick_length;
-       u64                     tick_length_base;
-+      int                     time_state;
-+      int                     time_status;
- };
- static struct ntp_data tk_ntp_data = {
-       .tick_usec              = USER_TICK_USEC,
-+      .time_state             = TIME_OK,
-+      .time_status            = STA_UNSYNC,
- };
- #define SECS_PER_DAY          86400
-@@ -53,16 +59,6 @@ static struct ntp_data tk_ntp_data = {
-  * estimated error = NTP dispersion.
-  */
--/*
-- * clock synchronization status
-- *
-- * (TIME_ERROR prevents overwriting the CMOS clock)
-- */
--static int                    time_state = TIME_OK;
--
--/* clock status bits:                                                 */
--static int                    time_status = STA_UNSYNC;
--
- /* time adjustment (nsecs):                                           */
- static s64                    time_offset;
-@@ -127,9 +123,9 @@ static long pps_errcnt;            /* calibration errors */
-  * PPS kernel consumer compensates the whole phase error immediately.
-  * Otherwise, reduce the offset by a fixed factor times the time constant.
-  */
--static inline s64 ntp_offset_chunk(s64 offset)
-+static inline s64 ntp_offset_chunk(struct ntp_data *ntpdata, s64 offset)
- {
--      if (time_status & STA_PPSTIME && time_status & STA_PPSSIGNAL)
-+      if (ntpdata->time_status & STA_PPSTIME && ntpdata->time_status & STA_PPSSIGNAL)
-               return offset;
-       else
-               return shift_right(offset, SHIFT_PLL + time_constant);
-@@ -159,13 +155,13 @@ static inline void pps_clear(void)
-  * Decrease pps_valid to indicate that another second has passed since the
-  * last PPS signal. When it reaches 0, indicate that PPS signal is missing.
-  */
--static inline void pps_dec_valid(void)
-+static inline void pps_dec_valid(struct ntp_data *ntpdata)
- {
-       if (pps_valid > 0)
-               pps_valid--;
-       else {
--              time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
--                               STA_PPSWANDER | STA_PPSERROR);
-+              ntpdata->time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
-+                                        STA_PPSWANDER | STA_PPSERROR);
-               pps_clear();
-       }
- }
-@@ -198,12 +194,12 @@ static inline bool is_error_status(int status)
-                       && (status & (STA_PPSWANDER|STA_PPSERROR)));
- }
--static inline void pps_fill_timex(struct __kernel_timex *txc)
-+static inline void pps_fill_timex(struct ntp_data *ntpdata, struct __kernel_timex *txc)
- {
-       txc->ppsfreq       = shift_right((pps_freq >> PPM_SCALE_INV_SHIFT) *
-                                        PPM_SCALE_INV, NTP_SCALE_SHIFT);
-       txc->jitter        = pps_jitter;
--      if (!(time_status & STA_NANO))
-+      if (!(ntpdata->time_status & STA_NANO))
-               txc->jitter = pps_jitter / NSEC_PER_USEC;
-       txc->shift         = pps_shift;
-       txc->stabil        = pps_stabil;
-@@ -215,14 +211,14 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
- #else /* !CONFIG_NTP_PPS */
--static inline s64 ntp_offset_chunk(s64 offset)
-+static inline s64 ntp_offset_chunk(struct ntp_data *ntp, s64 offset)
- {
-       return shift_right(offset, SHIFT_PLL + time_constant);
- }
- static inline void pps_reset_freq_interval(void) {}
- static inline void pps_clear(void) {}
--static inline void pps_dec_valid(void) {}
-+static inline void pps_dec_valid(struct ntp_data *ntpdata) {}
- static inline void pps_set_freq(s64 freq) {}
- static inline bool is_error_status(int status)
-@@ -230,7 +226,7 @@ static inline bool is_error_status(int status)
-       return status & (STA_UNSYNC|STA_CLOCKERR);
- }
--static inline void pps_fill_timex(struct __kernel_timex *txc)
-+static inline void pps_fill_timex(struct ntp_data *ntpdata, struct __kernel_timex *txc)
- {
-       /* PPS is not implemented, so these are zero */
-       txc->ppsfreq       = 0;
-@@ -268,30 +264,30 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
-       ntpdata->tick_length_base        = new_base;
- }
--static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
-+static inline s64 ntp_update_offset_fll(struct ntp_data *ntpdata, s64 offset64, long secs)
- {
--      time_status &= ~STA_MODE;
-+      ntpdata->time_status &= ~STA_MODE;
-       if (secs < MINSEC)
-               return 0;
--      if (!(time_status & STA_FLL) && (secs <= MAXSEC))
-+      if (!(ntpdata->time_status & STA_FLL) && (secs <= MAXSEC))
-               return 0;
--      time_status |= STA_MODE;
-+      ntpdata->time_status |= STA_MODE;
-       return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
- }
--static void ntp_update_offset(long offset)
-+static void ntp_update_offset(struct ntp_data *ntpdata, long offset)
- {
-       s64 freq_adj, offset64;
-       long secs, real_secs;
--      if (!(time_status & STA_PLL))
-+      if (!(ntpdata->time_status & STA_PLL))
-               return;
--      if (!(time_status & STA_NANO)) {
-+      if (!(ntpdata->time_status & STA_NANO)) {
-               /* Make sure the multiplication below won't overflow */
-               offset = clamp(offset, -USEC_PER_SEC, USEC_PER_SEC);
-               offset *= NSEC_PER_USEC;
-@@ -306,13 +302,13 @@ static void ntp_update_offset(long offset)
-        */
-       real_secs = __ktime_get_real_seconds();
-       secs = (long)(real_secs - time_reftime);
--      if (unlikely(time_status & STA_FREQHOLD))
-+      if (unlikely(ntpdata->time_status & STA_FREQHOLD))
-               secs = 0;
-       time_reftime = real_secs;
-       offset64    = offset;
--      freq_adj    = ntp_update_offset_fll(offset64, secs);
-+      freq_adj    = ntp_update_offset_fll(ntpdata, offset64, secs);
-       /*
-        * Clamp update interval to reduce PLL gain with low
-@@ -335,10 +331,10 @@ static void ntp_update_offset(long offset)
- static void __ntp_clear(struct ntp_data *ntpdata)
- {
-       /* Stop active adjtime() */
--      time_adjust     = 0;
--      time_status     |= STA_UNSYNC;
--      time_maxerror   = NTP_PHASE_LIMIT;
--      time_esterror   = NTP_PHASE_LIMIT;
-+      time_adjust             = 0;
-+      ntpdata->time_status    |= STA_UNSYNC;
-+      time_maxerror           = NTP_PHASE_LIMIT;
-+      time_esterror           = NTP_PHASE_LIMIT;
-       ntp_update_frequency(ntpdata);
-@@ -372,9 +368,10 @@ u64 ntp_tick_length(void)
-  */
- ktime_t ntp_get_next_leap(void)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       ktime_t ret;
--      if ((time_state == TIME_INS) && (time_status & STA_INS))
-+      if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS))
-               return ktime_set(ntp_next_leap_sec, 0);
-       ret = KTIME_MAX;
-       return ret;
-@@ -402,46 +399,46 @@ int second_overflow(time64_t secs)
-        * day, the system clock is set back one second; if in leap-delete
-        * state, the system clock is set ahead one second.
-        */
--      switch (time_state) {
-+      switch (ntpdata->time_state) {
-       case TIME_OK:
--              if (time_status & STA_INS) {
--                      time_state = TIME_INS;
-+              if (ntpdata->time_status & STA_INS) {
-+                      ntpdata->time_state = TIME_INS;
-                       div_s64_rem(secs, SECS_PER_DAY, &rem);
-                       ntp_next_leap_sec = secs + SECS_PER_DAY - rem;
--              } else if (time_status & STA_DEL) {
--                      time_state = TIME_DEL;
-+              } else if (ntpdata->time_status & STA_DEL) {
-+                      ntpdata->time_state = TIME_DEL;
-                       div_s64_rem(secs + 1, SECS_PER_DAY, &rem);
-                       ntp_next_leap_sec = secs + SECS_PER_DAY - rem;
-               }
-               break;
-       case TIME_INS:
--              if (!(time_status & STA_INS)) {
-+              if (!(ntpdata->time_status & STA_INS)) {
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_OK;
-+                      ntpdata->time_state = TIME_OK;
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = -1;
--                      time_state = TIME_OOP;
-+                      ntpdata->time_state = TIME_OOP;
-                       pr_notice("Clock: inserting leap second 23:59:60 UTC\n");
-               }
-               break;
-       case TIME_DEL:
--              if (!(time_status & STA_DEL)) {
-+              if (!(ntpdata->time_status & STA_DEL)) {
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_OK;
-+                      ntpdata->time_state = TIME_OK;
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = 1;
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_WAIT;
-+                      ntpdata->time_state = TIME_WAIT;
-                       pr_notice("Clock: deleting leap second 23:59:59 UTC\n");
-               }
-               break;
-       case TIME_OOP:
-               ntp_next_leap_sec = TIME64_MAX;
--              time_state = TIME_WAIT;
-+              ntpdata->time_state = TIME_WAIT;
-               break;
-       case TIME_WAIT:
--              if (!(time_status & (STA_INS | STA_DEL)))
--                      time_state = TIME_OK;
-+              if (!(ntpdata->time_status & (STA_INS | STA_DEL)))
-+                      ntpdata->time_state = TIME_OK;
-               break;
-       }
-@@ -449,18 +446,18 @@ int second_overflow(time64_t secs)
-       time_maxerror += MAXFREQ / NSEC_PER_USEC;
-       if (time_maxerror > NTP_PHASE_LIMIT) {
-               time_maxerror = NTP_PHASE_LIMIT;
--              time_status |= STA_UNSYNC;
-+              ntpdata->time_status |= STA_UNSYNC;
-       }
-       /* Compute the phase adjustment for the next second */
-       ntpdata->tick_length     = ntpdata->tick_length_base;
--      delta                    = ntp_offset_chunk(time_offset);
-+      delta                    = ntp_offset_chunk(ntpdata, time_offset);
-       time_offset             -= delta;
-       ntpdata->tick_length    += delta;
-       /* Check PPS signal */
--      pps_dec_valid();
-+      pps_dec_valid(ntpdata);
-       if (!time_adjust)
-               goto out;
-@@ -608,7 +605,7 @@ static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_ns
-  */
- static inline bool ntp_synced(void)
- {
--      return !(time_status & STA_UNSYNC);
-+      return !(tk_ntp_data.time_status & STA_UNSYNC);
- }
- /*
-@@ -683,11 +680,11 @@ static inline void __init ntp_init_cmos_sync(void) { }
- /*
-  * Propagate a new txc->status value into the NTP state:
-  */
--static inline void process_adj_status(const struct __kernel_timex *txc)
-+static inline void process_adj_status(struct ntp_data *ntpdata, const struct __kernel_timex *txc)
- {
--      if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) {
--              time_state = TIME_OK;
--              time_status = STA_UNSYNC;
-+      if ((ntpdata->time_status & STA_PLL) && !(txc->status & STA_PLL)) {
-+              ntpdata->time_state = TIME_OK;
-+              ntpdata->time_status = STA_UNSYNC;
-               ntp_next_leap_sec = TIME64_MAX;
-               /* Restart PPS frequency calibration */
-               pps_reset_freq_interval();
-@@ -697,26 +694,25 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-        * If we turn on PLL adjustments then reset the
-        * reference time to current time.
-        */
--      if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
-+      if (!(ntpdata->time_status & STA_PLL) && (txc->status & STA_PLL))
-               time_reftime = __ktime_get_real_seconds();
--      /* Only set allowed bits */
--      time_status &= STA_RONLY;
--      time_status |= txc->status & ~STA_RONLY;
-+      /* only set allowed bits */
-+      ntpdata->time_status &= STA_RONLY;
-+      ntpdata->time_status |= txc->status & ~STA_RONLY;
- }
--
- static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct __kernel_timex *txc,
-                                         s32 *time_tai)
- {
-       if (txc->modes & ADJ_STATUS)
--              process_adj_status(txc);
-+              process_adj_status(ntpdata, txc);
-       if (txc->modes & ADJ_NANO)
--              time_status |= STA_NANO;
-+              ntpdata->time_status |= STA_NANO;
-       if (txc->modes & ADJ_MICRO)
--              time_status &= ~STA_NANO;
-+              ntpdata->time_status &= ~STA_NANO;
-       if (txc->modes & ADJ_FREQUENCY) {
-               time_freq = txc->freq * PPM_SCALE;
-@@ -734,17 +730,16 @@ static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct
-       if (txc->modes & ADJ_TIMECONST) {
-               time_constant = clamp(txc->constant, 0, MAXTC);
--              if (!(time_status & STA_NANO))
-+              if (!(ntpdata->time_status & STA_NANO))
-                       time_constant += 4;
-               time_constant = clamp(time_constant, 0, MAXTC);
-       }
--      if (txc->modes & ADJ_TAI &&
--                      txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
-+      if (txc->modes & ADJ_TAI && txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
-               *time_tai = txc->constant;
-       if (txc->modes & ADJ_OFFSET)
--              ntp_update_offset(txc->offset);
-+              ntp_update_offset(ntpdata, txc->offset);
-       if (txc->modes & ADJ_TICK)
-               ntpdata->tick_usec = txc->tick;
-@@ -780,7 +775,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-               if (txc->modes) {
-                       audit_ntp_set_old(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_old(ad, AUDIT_NTP_FREQ,   time_freq);
--                      audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status);
-+                      audit_ntp_set_old(ad, AUDIT_NTP_STATUS, ntpdata->time_status);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TAI,    *time_tai);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-@@ -788,26 +783,26 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_new(ad, AUDIT_NTP_FREQ,   time_freq);
--                      audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status);
-+                      audit_ntp_set_new(ad, AUDIT_NTP_STATUS, ntpdata->time_status);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TAI,    *time_tai);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-               }
-               txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
-                                 NTP_SCALE_SHIFT);
--              if (!(time_status & STA_NANO))
-+              if (!(ntpdata->time_status & STA_NANO))
-                       txc->offset = (u32)txc->offset / NSEC_PER_USEC;
-       }
--      result = time_state;
--      if (is_error_status(time_status))
-+      result = ntpdata->time_state;
-+      if (is_error_status(ntpdata->time_status))
-               result = TIME_ERROR;
-       txc->freq          = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) *
-                                        PPM_SCALE_INV, NTP_SCALE_SHIFT);
-       txc->maxerror      = time_maxerror;
-       txc->esterror      = time_esterror;
--      txc->status        = time_status;
-+      txc->status        = ntpdata->time_status;
-       txc->constant      = time_constant;
-       txc->precision     = 1;
-       txc->tolerance     = MAXFREQ_SCALED / PPM_SCALE;
-@@ -815,26 +810,26 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->tai           = *time_tai;
-       /* Fill PPS status fields */
--      pps_fill_timex(txc);
-+      pps_fill_timex(ntpdata, txc);
-       txc->time.tv_sec = ts->tv_sec;
-       txc->time.tv_usec = ts->tv_nsec;
--      if (!(time_status & STA_NANO))
-+      if (!(ntpdata->time_status & STA_NANO))
-               txc->time.tv_usec = ts->tv_nsec / NSEC_PER_USEC;
-       /* Handle leapsec adjustments */
-       if (unlikely(ts->tv_sec >= ntp_next_leap_sec)) {
--              if ((time_state == TIME_INS) && (time_status & STA_INS)) {
-+              if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS)) {
-                       result = TIME_OOP;
-                       txc->tai++;
-                       txc->time.tv_sec--;
-               }
--              if ((time_state == TIME_DEL) && (time_status & STA_DEL)) {
-+              if ((ntpdata->time_state == TIME_DEL) && (ntpdata->time_status & STA_DEL)) {
-                       result = TIME_WAIT;
-                       txc->tai--;
-                       txc->time.tv_sec++;
-               }
--              if ((time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-+              if ((ntpdata->time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-                       result = TIME_WAIT;
-       }
-@@ -939,7 +934,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-       /* Check if the frequency interval was too long */
-       if (freq_norm.sec > (2 << pps_shift)) {
--              time_status |= STA_PPSERROR;
-+              ntpdata->time_status |= STA_PPSERROR;
-               pps_errcnt++;
-               pps_dec_freq_interval();
-               printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n",
-@@ -958,7 +953,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-       pps_freq = ftemp;
-       if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
-               printk_deferred(KERN_WARNING "hardpps: PPSWANDER: change=%ld\n", delta);
--              time_status |= STA_PPSWANDER;
-+              ntpdata->time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
-       } else {
-@@ -977,7 +972,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-                              NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-       /* If enabled, the system clock frequency is updated */
--      if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-+      if ((ntpdata->time_status & STA_PPSFREQ) && !(ntpdata->time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
-               ntp_update_frequency(ntpdata);
-       }
-@@ -986,7 +981,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
- }
- /* Correct REALTIME clock phase error against PPS signal */
--static void hardpps_update_phase(long error)
-+static void hardpps_update_phase(struct ntp_data *ntpdata, long error)
- {
-       long correction = -error;
-       long jitter;
-@@ -1003,9 +998,9 @@ static void hardpps_update_phase(long error)
-       if (jitter > (pps_jitter << PPS_POPCORN)) {
-               printk_deferred(KERN_WARNING "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-                               jitter, (pps_jitter << PPS_POPCORN));
--              time_status |= STA_PPSJITTER;
-+              ntpdata->time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
--      } else if (time_status & STA_PPSTIME) {
-+      } else if (ntpdata->time_status & STA_PPSTIME) {
-               /* Correct the time using the phase offset */
-               time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
-               /* Cancel running adjtime() */
-@@ -1035,10 +1030,10 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-       pts_norm = pps_normalize_ts(*phase_ts);
-       /* Clear the error bits, they will be set again if needed */
--      time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
-+      ntpdata->time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
--      /* Indicate signal presence */
--      time_status |= STA_PPSSIGNAL;
-+      /* indicate signal presence */
-+      ntpdata->time_status |= STA_PPSSIGNAL;
-       pps_valid = PPS_VALID;
-       /*
-@@ -1059,7 +1054,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-        */
-       if ((freq_norm.sec == 0) || (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-           (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
--              time_status |= STA_PPSJITTER;
-+              ntpdata->time_status |= STA_PPSJITTER;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n");
-@@ -1074,7 +1069,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-               hardpps_update_freq(ntpdata, freq_norm);
-       }
--      hardpps_update_phase(pts_norm.nsec);
-+      hardpps_update_phase(ntpdata, pts_norm.nsec);
- }
- #endif        /* CONFIG_NTP_PPS */
--- 
-2.43.0
-
diff --git a/queue-6.1/ntp-read-reference-time-only-once.patch b/queue-6.1/ntp-read-reference-time-only-once.patch
deleted file mode 100644 (file)
index b65bbc0..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-From 933db59179cf3c849249b1c26eef90e47f25da3e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:42 +0200
-Subject: ntp: Read reference time only once
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 136bccbc2e78d3cd0bd8831e4c5a4509c0ddd945 ]
-
-The reference time is required twice in ntp_update_offset(). It will not
-change in the meantime as the calling code holds the timekeeper lock. Read
-it only once and store it into a local variable.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-6-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index ef758aafdfd54..477cb08062bc5 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -283,9 +283,8 @@ static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
- static void ntp_update_offset(long offset)
- {
--      s64 freq_adj;
--      s64 offset64;
--      long secs;
-+      s64 freq_adj, offset64;
-+      long secs, real_secs;
-       if (!(time_status & STA_PLL))
-               return;
-@@ -303,11 +302,12 @@ static void ntp_update_offset(long offset)
-        * Select how the frequency is to be controlled
-        * and in which mode (PLL or FLL).
-        */
--      secs = (long)(__ktime_get_real_seconds() - time_reftime);
-+      real_secs = __ktime_get_real_seconds();
-+      secs = (long)(real_secs - time_reftime);
-       if (unlikely(time_status & STA_FREQHOLD))
-               secs = 0;
--      time_reftime = __ktime_get_real_seconds();
-+      time_reftime = real_secs;
-       offset64    = offset;
-       freq_adj    = ntp_update_offset_fll(offset64, secs);
--- 
-2.43.0
-
index 3d85940b599d50cf1c24b058e7a15b47f639ff9c..2a812004f1ed98f4dad12502d5a3e72470576b72 100644 (file)
@@ -1,11 +1,11 @@
-From 21e29d3ffe7a96085e3948dbc218e1730e5f8e99 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
+From f5807b0606da7ac7c1b74a386b22134ec7702d05 Mon Sep 17 00:00:00 2001
+From: Marcelo Dalmas <marcelo.dalmas@ge.com>
 Date: Mon, 25 Nov 2024 12:16:09 +0000
 Subject: ntp: Remove invalid cast in time offset math
 
 From: Marcelo Dalmas <marcelo.dalmas@ge.com>
 
-[ Upstream commit f5807b0606da7ac7c1b74a386b22134ec7702d05 ]
+commit f5807b0606da7ac7c1b74a386b22134ec7702d05 upstream.
 
 Due to an unsigned cast, adjtimex() returns the wrong offest when using
 ADJ_MICRO and the offset is negative. In this case a small negative offset
@@ -29,24 +29,19 @@ Signed-off-by: Marcelo Dalmas <marcelo.dalmas@ge.com>
 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
 Cc: stable@vger.kernel.org
 Link: https://lore.kernel.org/all/SJ0P101MB03687BF7D5A10FD3C49C51E5F42E2@SJ0P101MB0368.NAMP101.PROD.OUTLOOK.COM
-Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 ---
- kernel/time/ntp.c | 2 +-
+ kernel/time/ntp.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 6d87f9889b039..d1b7a3909de1d 100644
 --- a/kernel/time/ntp.c
 +++ b/kernel/time/ntp.c
-@@ -791,7 +791,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
+@@ -796,7 +796,7 @@ int __do_adjtimex(struct __kernel_timex
                txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
                                  NTP_SCALE_SHIFT);
-               if (!(ntpdata->time_status & STA_NANO))
+               if (!(time_status & STA_NANO))
 -                      txc->offset = (u32)txc->offset / NSEC_PER_USEC;
 +                      txc->offset = div_s64(txc->offset, NSEC_PER_USEC);
        }
  
-       result = ntpdata->time_state;
--- 
-2.43.0
-
+       result = time_state;    /* mostly `TIME_OK' */
diff --git a/queue-6.1/ntp-remove-unused-tick_nsec.patch b/queue-6.1/ntp-remove-unused-tick_nsec.patch
deleted file mode 100644 (file)
index d7eb811..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-From 4a8985fd682f4f7d3f2d93279fabcbf8addb67bb Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:37 +0200
-Subject: ntp: Remove unused tick_nsec
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit a849a0273d0f73a252d14d31c5003a8059ea51fc ]
-
-tick_nsec is only updated in the NTP core, but there are no users.
-
-Remove it.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-1-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/include/asm/timer.h | 2 --
- include/linux/timex.h        | 1 -
- kernel/time/ntp.c            | 8 ++------
- 3 files changed, 2 insertions(+), 9 deletions(-)
-
-diff --git a/arch/x86/include/asm/timer.h b/arch/x86/include/asm/timer.h
-index 7365dd4acffb6..23baf8c9b34ca 100644
---- a/arch/x86/include/asm/timer.h
-+++ b/arch/x86/include/asm/timer.h
-@@ -6,8 +6,6 @@
- #include <linux/interrupt.h>
- #include <linux/math64.h>
--#define TICK_SIZE (tick_nsec / 1000)
--
- unsigned long long native_sched_clock(void);
- extern void recalibrate_cpu_khz(void);
-diff --git a/include/linux/timex.h b/include/linux/timex.h
-index 3871b06bd302c..7f7a12fd8200c 100644
---- a/include/linux/timex.h
-+++ b/include/linux/timex.h
-@@ -145,7 +145,6 @@ unsigned long random_get_entropy_fallback(void);
-  * estimated error = NTP dispersion.
-  */
- extern unsigned long tick_usec;               /* USER_HZ period (usec) */
--extern unsigned long tick_nsec;               /* SHIFTED_HZ period (nsec) */
- /* Required to safely shift negative values */
- #define shift_right(x, s) ({  \
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 8d2dd214ec682..0dba1179d81d2 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -33,9 +33,6 @@
- /* USER_HZ period (usecs): */
- unsigned long                 tick_usec = USER_TICK_USEC;
--/* SHIFTED_HZ period (nsecs): */
--unsigned long                 tick_nsec;
--
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -253,8 +250,8 @@ static inline int ntp_synced(void)
-  */
- /*
-- * Update (tick_length, tick_length_base, tick_nsec), based
-- * on (tick_usec, ntp_tick_adj, time_freq):
-+ * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-+ * time_freq:
-  */
- static void ntp_update_frequency(void)
- {
-@@ -267,7 +264,6 @@ static void ntp_update_frequency(void)
-       second_length           += ntp_tick_adj;
-       second_length           += time_freq;
--      tick_nsec                = div_u64(second_length, HZ) >> NTP_SCALE_SHIFT;
-       new_base                 = div_u64(second_length, NTP_INTERVAL_FREQ);
-       /*
--- 
-2.43.0
-
index 4080378a6b66cbc56bdcc37610394846c4f50851..fdd75fd968930c9c8d09ce1f83b224b40fbad03d 100644 (file)
@@ -565,15 +565,6 @@ powerpc-vdso-remove-an-unsupported-flag-from-vgettim.patch
 powerpc-vdso-include-clang_flags-explicitly-in-ldfla.patch
 powerpc-vdso-refactor-cflags-for-cvdso-build.patch
 powerpc-vdso-drop-mstack-protector-guard-flags-in-32.patch
-ntp-remove-unused-tick_nsec.patch
-ntp-make-tick_usec-static.patch
-ntp-clean-up-comments.patch
-ntp-cleanup-formatting-of-code.patch
-ntp-convert-functions-with-only-two-states-to-bool.patch
-ntp-read-reference-time-only-once.patch
-ntp-introduce-struct-ntp_data.patch
-ntp-move-tick_length-into-ntp_data.patch
-ntp-move-tick_stat-into-ntp_data.patch
 ntp-remove-invalid-cast-in-time-offset-math.patch
 driver-core-fw_devlink-improve-logs-for-cycle-detect.patch
 driver-core-add-fwlink_flag_ignore-to-completely-ign.patch
diff --git a/queue-6.12/ntp-clean-up-comments.patch b/queue-6.12/ntp-clean-up-comments.patch
deleted file mode 100644 (file)
index 2c58df3..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-From a9b8629d8b0fcd0dbbb1de442cb0a47f72510704 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:39 +0200
-Subject: ntp: Clean up comments
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit a0581cdb2e5d3ad633e51a945b6f0527ce70b68a ]
-
-Usage of different comment formatting makes fast reading and parsing the
-code harder. There are several multi-line comments which do not follow the
-coding style by starting with a line only containing '/*'. There are also
-comments which do not start with capitals.
-
-Clean up all those comments to be consistent and remove comments which
-document the obvious.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-3-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 144 +++++++++++++++++++++++++---------------------
- 1 file changed, 78 insertions(+), 66 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index ed15ec993a829..e78d3cd1ec321 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -119,7 +119,8 @@ static long pps_stbcnt;            /* stability limit exceeded */
- static long pps_errcnt;               /* calibration errors */
--/* PPS kernel consumer compensates the whole phase error immediately.
-+/*
-+ * PPS kernel consumer compensates the whole phase error immediately.
-  * Otherwise, reduce the offset by a fixed factor times the time constant.
-  */
- static inline s64 ntp_offset_chunk(s64 offset)
-@@ -132,8 +133,7 @@ static inline s64 ntp_offset_chunk(s64 offset)
- static inline void pps_reset_freq_interval(void)
- {
--      /* the PPS calibration interval may end
--         surprisingly early */
-+      /* The PPS calibration interval may end surprisingly early */
-       pps_shift = PPS_INTMIN;
-       pps_intcnt = 0;
- }
-@@ -151,9 +151,9 @@ static inline void pps_clear(void)
-       pps_freq = 0;
- }
--/* Decrease pps_valid to indicate that another second has passed since
-- * the last PPS signal. When it reaches 0, indicate that PPS signal is
-- * missing.
-+/*
-+ * Decrease pps_valid to indicate that another second has passed since the
-+ * last PPS signal. When it reaches 0, indicate that PPS signal is missing.
-  */
- static inline void pps_dec_valid(void)
- {
-@@ -174,17 +174,21 @@ static inline void pps_set_freq(s64 freq)
- static inline int is_error_status(int status)
- {
-       return (status & (STA_UNSYNC|STA_CLOCKERR))
--              /* PPS signal lost when either PPS time or
--               * PPS frequency synchronization requested
-+              /*
-+               * PPS signal lost when either PPS time or PPS frequency
-+               * synchronization requested
-                */
-               || ((status & (STA_PPSFREQ|STA_PPSTIME))
-                       && !(status & STA_PPSSIGNAL))
--              /* PPS jitter exceeded when
--               * PPS time synchronization requested */
-+              /*
-+               * PPS jitter exceeded when PPS time synchronization
-+               * requested
-+               */
-               || ((status & (STA_PPSTIME|STA_PPSJITTER))
-                       == (STA_PPSTIME|STA_PPSJITTER))
--              /* PPS wander exceeded or calibration error when
--               * PPS frequency synchronization requested
-+              /*
-+               * PPS wander exceeded or calibration error when PPS
-+               * frequency synchronization requested
-                */
-               || ((status & STA_PPSFREQ)
-                       && (status & (STA_PPSWANDER|STA_PPSERROR)));
-@@ -270,8 +274,8 @@ static void ntp_update_frequency(void)
-       new_base                 = div_u64(second_length, NTP_INTERVAL_FREQ);
-       /*
--       * Don't wait for the next second_overflow, apply
--       * the change to the tick length immediately:
-+       * Don't wait for the next second_overflow, apply the change to the
-+       * tick length immediately:
-        */
-       tick_length             += new_base - tick_length_base;
-       tick_length_base         = new_base;
-@@ -307,10 +311,7 @@ static void ntp_update_offset(long offset)
-               offset *= NSEC_PER_USEC;
-       }
--      /*
--       * Scale the phase adjustment and
--       * clamp to the operating range.
--       */
-+      /* Scale the phase adjustment and clamp to the operating range. */
-       offset = clamp(offset, -MAXPHASE, MAXPHASE);
-       /*
-@@ -349,7 +350,8 @@ static void ntp_update_offset(long offset)
-  */
- void ntp_clear(void)
- {
--      time_adjust     = 0;            /* stop active adjtime() */
-+      /* Stop active adjtime() */
-+      time_adjust     = 0;
-       time_status     |= STA_UNSYNC;
-       time_maxerror   = NTP_PHASE_LIMIT;
-       time_esterror   = NTP_PHASE_LIMIT;
-@@ -387,7 +389,7 @@ ktime_t ntp_get_next_leap(void)
- }
- /*
-- * this routine handles the overflow of the microsecond field
-+ * This routine handles the overflow of the microsecond field
-  *
-  * The tricky bits of code to handle the accurate clock support
-  * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame.
-@@ -452,7 +454,6 @@ int second_overflow(time64_t secs)
-               break;
-       }
--
-       /* Bump the maxerror field */
-       time_maxerror += MAXFREQ / NSEC_PER_USEC;
-       if (time_maxerror > NTP_PHASE_LIMIT) {
-@@ -696,7 +697,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-               time_state = TIME_OK;
-               time_status = STA_UNSYNC;
-               ntp_next_leap_sec = TIME64_MAX;
--              /* restart PPS frequency calibration */
-+              /* Restart PPS frequency calibration */
-               pps_reset_freq_interval();
-       }
-@@ -707,7 +708,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-       if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
-               time_reftime = __ktime_get_real_seconds();
--      /* only set allowed bits */
-+      /* Only set allowed bits */
-       time_status &= STA_RONLY;
-       time_status |= txc->status & ~STA_RONLY;
- }
-@@ -729,7 +730,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-               time_freq = txc->freq * PPM_SCALE;
-               time_freq = min(time_freq, MAXFREQ_SCALED);
-               time_freq = max(time_freq, -MAXFREQ_SCALED);
--              /* update pps_freq */
-+              /* Update pps_freq */
-               pps_set_freq(time_freq);
-       }
-@@ -762,7 +763,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
- /*
-- * adjtimex mainly allows reading (and writing, if superuser) of
-+ * adjtimex() mainly allows reading (and writing, if superuser) of
-  * kernel time-keeping variables. used by xntpd.
-  */
- int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-@@ -806,8 +807,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       txc->offset = (u32)txc->offset / NSEC_PER_USEC;
-       }
--      result = time_state;    /* mostly `TIME_OK' */
--      /* check for errors */
-+      result = time_state;
-       if (is_error_status(time_status))
-               result = TIME_ERROR;
-@@ -822,7 +822,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->tick          = tick_usec;
-       txc->tai           = *time_tai;
--      /* fill PPS status fields */
-+      /* Fill PPS status fields */
-       pps_fill_timex(txc);
-       txc->time.tv_sec = ts->tv_sec;
-@@ -853,17 +853,21 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
- #ifdef        CONFIG_NTP_PPS
--/* actually struct pps_normtime is good old struct timespec, but it is
-+/*
-+ * struct pps_normtime is basically a struct timespec, but it is
-  * semantically different (and it is the reason why it was invented):
-  * pps_normtime.nsec has a range of ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ]
-- * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC) */
-+ * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC)
-+ */
- struct pps_normtime {
-       s64             sec;    /* seconds */
-       long            nsec;   /* nanoseconds */
- };
--/* normalize the timestamp so that nsec is in the
--   ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval */
-+/*
-+ * Normalize the timestamp so that nsec is in the
-+ * [ -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval
-+ */
- static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts)
- {
-       struct pps_normtime norm = {
-@@ -879,7 +883,7 @@ static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts)
-       return norm;
- }
--/* get current phase correction and jitter */
-+/* Get current phase correction and jitter */
- static inline long pps_phase_filter_get(long *jitter)
- {
-       *jitter = pps_tf[0] - pps_tf[1];
-@@ -890,7 +894,7 @@ static inline long pps_phase_filter_get(long *jitter)
-       return pps_tf[0];
- }
--/* add the sample to the phase filter */
-+/* Add the sample to the phase filter */
- static inline void pps_phase_filter_add(long err)
- {
-       pps_tf[2] = pps_tf[1];
-@@ -898,8 +902,9 @@ static inline void pps_phase_filter_add(long err)
-       pps_tf[0] = err;
- }
--/* decrease frequency calibration interval length.
-- * It is halved after four consecutive unstable intervals.
-+/*
-+ * Decrease frequency calibration interval length. It is halved after four
-+ * consecutive unstable intervals.
-  */
- static inline void pps_dec_freq_interval(void)
- {
-@@ -912,8 +917,9 @@ static inline void pps_dec_freq_interval(void)
-       }
- }
--/* increase frequency calibration interval length.
-- * It is doubled after four consecutive stable intervals.
-+/*
-+ * Increase frequency calibration interval length. It is doubled after
-+ * four consecutive stable intervals.
-  */
- static inline void pps_inc_freq_interval(void)
- {
-@@ -926,7 +932,8 @@ static inline void pps_inc_freq_interval(void)
-       }
- }
--/* update clock frequency based on MONOTONIC_RAW clock PPS signal
-+/*
-+ * Update clock frequency based on MONOTONIC_RAW clock PPS signal
-  * timestamps
-  *
-  * At the end of the calibration interval the difference between the
-@@ -940,7 +947,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       long delta, delta_mod;
-       s64 ftemp;
--      /* check if the frequency interval was too long */
-+      /* Check if the frequency interval was too long */
-       if (freq_norm.sec > (2 << pps_shift)) {
-               time_status |= STA_PPSERROR;
-               pps_errcnt++;
-@@ -951,9 +958,10 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               return 0;
-       }
--      /* here the raw frequency offset and wander (stability) is
--       * calculated. If the wander is less than the wander threshold
--       * the interval is increased; otherwise it is decreased.
-+      /*
-+       * Here the raw frequency offset and wander (stability) is
-+       * calculated. If the wander is less than the wander threshold the
-+       * interval is increased; otherwise it is decreased.
-        */
-       ftemp = div_s64(((s64)(-freq_norm.nsec)) << NTP_SCALE_SHIFT,
-                       freq_norm.sec);
-@@ -965,13 +973,14 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
--      } else {        /* good sample */
-+      } else {
-+              /* Good sample */
-               pps_inc_freq_interval();
-       }
--      /* the stability metric is calculated as the average of recent
--       * frequency changes, but is used only for performance
--       * monitoring
-+      /*
-+       * The stability metric is calculated as the average of recent
-+       * frequency changes, but is used only for performance monitoring
-        */
-       delta_mod = delta;
-       if (delta_mod < 0)
-@@ -980,7 +989,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-                               (NTP_SCALE_SHIFT - SHIFT_USEC),
-                               NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
--      /* if enabled, the system clock frequency is updated */
-+      /* If enabled, the system clock frequency is updated */
-       if ((time_status & STA_PPSFREQ) != 0 &&
-           (time_status & STA_FREQHOLD) == 0) {
-               time_freq = pps_freq;
-@@ -990,17 +999,18 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       return delta;
- }
--/* correct REALTIME clock phase error against PPS signal */
-+/* Correct REALTIME clock phase error against PPS signal */
- static void hardpps_update_phase(long error)
- {
-       long correction = -error;
-       long jitter;
--      /* add the sample to the median filter */
-+      /* Add the sample to the median filter */
-       pps_phase_filter_add(correction);
-       correction = pps_phase_filter_get(&jitter);
--      /* Nominal jitter is due to PPS signal noise. If it exceeds the
-+      /*
-+       * Nominal jitter is due to PPS signal noise. If it exceeds the
-        * threshold, the sample is discarded; otherwise, if so enabled,
-        * the time offset is updated.
-        */
-@@ -1011,13 +1021,13 @@ static void hardpps_update_phase(long error)
-               time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
-       } else if (time_status & STA_PPSTIME) {
--              /* correct the time using the phase offset */
-+              /* Correct the time using the phase offset */
-               time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT,
-                               NTP_INTERVAL_FREQ);
--              /* cancel running adjtime() */
-+              /* Cancel running adjtime() */
-               time_adjust = 0;
-       }
--      /* update jitter */
-+      /* Update jitter */
-       pps_jitter += (jitter - pps_jitter) >> PPS_INTMIN;
- }
-@@ -1039,41 +1049,43 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-       pts_norm = pps_normalize_ts(*phase_ts);
--      /* clear the error bits, they will be set again if needed */
-+      /* Clear the error bits, they will be set again if needed */
-       time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
--      /* indicate signal presence */
-+      /* Indicate signal presence */
-       time_status |= STA_PPSSIGNAL;
-       pps_valid = PPS_VALID;
--      /* when called for the first time,
--       * just start the frequency interval */
-+      /*
-+       * When called for the first time, just start the frequency
-+       * interval
-+       */
-       if (unlikely(pps_fbase.tv_sec == 0)) {
-               pps_fbase = *raw_ts;
-               return;
-       }
--      /* ok, now we have a base for frequency calculation */
-+      /* Ok, now we have a base for frequency calculation */
-       freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, pps_fbase));
--      /* check that the signal is in the range
--       * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */
-+      /*
-+       * Check that the signal is in the range
-+       * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it
-+       */
-       if ((freq_norm.sec == 0) ||
-                       (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-                       (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-               time_status |= STA_PPSJITTER;
--              /* restart the frequency calibration interval */
-+              /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n");
-               return;
-       }
--      /* signal is ok */
--
--      /* check if the current frequency interval is finished */
-+      /* Signal is ok. Check if the current frequency interval is finished */
-       if (freq_norm.sec >= (1 << pps_shift)) {
-               pps_calcnt++;
--              /* restart the frequency calibration interval */
-+              /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               hardpps_update_freq(freq_norm);
-       }
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-cleanup-formatting-of-code.patch b/queue-6.12/ntp-cleanup-formatting-of-code.patch
deleted file mode 100644 (file)
index 4d332de..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-From 672b574b314ea108894d168fe91d11d12fb4afc4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:40 +0200
-Subject: ntp: Cleanup formatting of code
-
-From: Anna-Maria Behnsen <anna-maria@linutronix.de>
-
-[ Upstream commit 38007dc032bd90920463c5d2e6a27d89f7617d6d ]
-
-Code is partially formatted in a creative way which makes reading
-harder. Examples are function calls over several lines where the
-indentation does not start at the same height then the open bracket after
-the function name.
-
-Improve formatting but do not make a functional change.
-
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-4-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 37 +++++++++++++------------------------
- 1 file changed, 13 insertions(+), 24 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index e78d3cd1ec321..bf2f6ee23a2ec 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -428,8 +428,7 @@ int second_overflow(time64_t secs)
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = -1;
-                       time_state = TIME_OOP;
--                      printk(KERN_NOTICE
--                              "Clock: inserting leap second 23:59:60 UTC\n");
-+                      pr_notice("Clock: inserting leap second 23:59:60 UTC\n");
-               }
-               break;
-       case TIME_DEL:
-@@ -440,8 +439,7 @@ int second_overflow(time64_t secs)
-                       leap = 1;
-                       ntp_next_leap_sec = TIME64_MAX;
-                       time_state = TIME_WAIT;
--                      printk(KERN_NOTICE
--                              "Clock: deleting leap second 23:59:59 UTC\n");
-+                      pr_notice("Clock: deleting leap second 23:59:59 UTC\n");
-               }
-               break;
-       case TIME_OOP:
-@@ -842,10 +840,8 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       txc->tai--;
-                       txc->time.tv_sec++;
-               }
--              if ((time_state == TIME_OOP) &&
--                                      (ts->tv_sec == ntp_next_leap_sec)) {
-+              if ((time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-                       result = TIME_WAIT;
--              }
-       }
-       return result;
-@@ -952,9 +948,8 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               time_status |= STA_PPSERROR;
-               pps_errcnt++;
-               pps_dec_freq_interval();
--              printk_deferred(KERN_ERR
--                      "hardpps: PPSERROR: interval too long - %lld s\n",
--                      freq_norm.sec);
-+              printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n",
-+                              freq_norm.sec);
-               return 0;
-       }
-@@ -968,8 +963,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       delta = shift_right(ftemp - pps_freq, NTP_SCALE_SHIFT);
-       pps_freq = ftemp;
-       if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
--              printk_deferred(KERN_WARNING
--                              "hardpps: PPSWANDER: change=%ld\n", delta);
-+              printk_deferred(KERN_WARNING "hardpps: PPSWANDER: change=%ld\n", delta);
-               time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
-@@ -985,13 +979,11 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       delta_mod = delta;
-       if (delta_mod < 0)
-               delta_mod = -delta_mod;
--      pps_stabil += (div_s64(((s64)delta_mod) <<
--                              (NTP_SCALE_SHIFT - SHIFT_USEC),
--                              NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-+      pps_stabil += (div_s64(((s64)delta_mod) << (NTP_SCALE_SHIFT - SHIFT_USEC),
-+                             NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-       /* If enabled, the system clock frequency is updated */
--      if ((time_status & STA_PPSFREQ) != 0 &&
--          (time_status & STA_FREQHOLD) == 0) {
-+      if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
-               ntp_update_frequency();
-       }
-@@ -1015,15 +1007,13 @@ static void hardpps_update_phase(long error)
-        * the time offset is updated.
-        */
-       if (jitter > (pps_jitter << PPS_POPCORN)) {
--              printk_deferred(KERN_WARNING
--                              "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-+              printk_deferred(KERN_WARNING "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-                               jitter, (pps_jitter << PPS_POPCORN));
-               time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
-       } else if (time_status & STA_PPSTIME) {
-               /* Correct the time using the phase offset */
--              time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT,
--                              NTP_INTERVAL_FREQ);
-+              time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
-               /* Cancel running adjtime() */
-               time_adjust = 0;
-       }
-@@ -1072,9 +1062,8 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-        * Check that the signal is in the range
-        * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it
-        */
--      if ((freq_norm.sec == 0) ||
--                      (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
--                      (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-+      if ((freq_norm.sec == 0) || (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-+          (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-               time_status |= STA_PPSJITTER;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-convert-functions-with-only-two-states-to-bool.patch b/queue-6.12/ntp-convert-functions-with-only-two-states-to-bool.patch
deleted file mode 100644 (file)
index 00de73e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-From 8c08827798816b95f2e47f8b916684f622fb0bc8 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:41 +0200
-Subject: ntp: Convert functions with only two states to bool
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 48c3c65f64b01164f1704b40b38f60837d484f13 ]
-
-is_error_status() and ntp_synced() return whether a state is set or
-not. Both functions use unsigned int for it even if it would be a perfect
-job for a bool.
-
-Use bool instead of unsigned int. And while at it, move ntp_synced()
-function to the place where it is used.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-5-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 28 +++++++++++-----------------
- 1 file changed, 11 insertions(+), 17 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index bf2f6ee23a2ec..905b0216b12dc 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -171,7 +171,7 @@ static inline void pps_set_freq(s64 freq)
-       pps_freq = freq;
- }
--static inline int is_error_status(int status)
-+static inline bool is_error_status(int status)
- {
-       return (status & (STA_UNSYNC|STA_CLOCKERR))
-               /*
-@@ -221,7 +221,7 @@ static inline void pps_clear(void) {}
- static inline void pps_dec_valid(void) {}
- static inline void pps_set_freq(s64 freq) {}
--static inline int is_error_status(int status)
-+static inline bool is_error_status(int status)
- {
-       return status & (STA_UNSYNC|STA_CLOCKERR);
- }
-@@ -241,21 +241,6 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
- #endif /* CONFIG_NTP_PPS */
--
--/**
-- * ntp_synced - Returns 1 if the NTP status is not UNSYNC
-- *
-- */
--static inline int ntp_synced(void)
--{
--      return !(time_status & STA_UNSYNC);
--}
--
--
--/*
-- * NTP methods:
-- */
--
- /*
-  * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-  * time_freq:
-@@ -609,6 +594,15 @@ static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_ns
- }
- #endif
-+/**
-+ * ntp_synced - Tells whether the NTP status is not UNSYNC
-+ * Returns:   true if not UNSYNC, false otherwise
-+ */
-+static inline bool ntp_synced(void)
-+{
-+      return !(time_status & STA_UNSYNC);
-+}
-+
- /*
-  * If we have an externally synchronized Linux clock, then update RTC clock
-  * accordingly every ~11 minutes. Generally RTCs can only store second
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-introduce-struct-ntp_data.patch b/queue-6.12/ntp-introduce-struct-ntp_data.patch
deleted file mode 100644 (file)
index df9096a..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-From 02cd24be54639c8c10474b3749b74e92b928e376 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:43 +0200
-Subject: ntp: Introduce struct ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 68f66f97c5689825012877f58df65964056d4b5d ]
-
-All NTP data is held in static variables. That prevents the NTP code from
-being reuasble for non-system time timekeepers, e.g. per PTP clock
-timekeeping.
-
-Introduce struct ntp_data and move tick_usec into it for a start.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-7-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 65 ++++++++++++++++++++++++++---------------------
- 1 file changed, 36 insertions(+), 29 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 0bfd07de202a5..f95f23385a62a 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -22,16 +22,19 @@
- #include "ntp_internal.h"
- #include "timekeeping_internal.h"
--
--/*
-- * NTP timekeeping variables:
-+/**
-+ * struct ntp_data - Structure holding all NTP related state
-+ * @tick_usec:                USER_HZ period in microseconds
-  *
-- * Note: All of the NTP state is protected by the timekeeping locks.
-+ * Protected by the timekeeping locks.
-  */
-+struct ntp_data {
-+      unsigned long           tick_usec;
-+};
--
--/* USER_HZ period (usecs): */
--static unsigned long          tick_usec = USER_TICK_USEC;
-+static struct ntp_data tk_ntp_data = {
-+      .tick_usec              = USER_TICK_USEC,
-+};
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -245,13 +248,11 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
-  * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-  * time_freq:
-  */
--static void ntp_update_frequency(void)
-+static void ntp_update_frequency(struct ntp_data *ntpdata)
- {
--      u64 second_length;
--      u64 new_base;
-+      u64 second_length, new_base, tick_usec = (u64)ntpdata->tick_usec;
--      second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
--                                              << NTP_SCALE_SHIFT;
-+      second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) << NTP_SCALE_SHIFT;
-       second_length           += ntp_tick_adj;
-       second_length           += time_freq;
-@@ -330,10 +331,7 @@ static void ntp_update_offset(long offset)
-       time_offset = div_s64(offset64 << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
- }
--/**
-- * ntp_clear - Clears the NTP state variables
-- */
--void ntp_clear(void)
-+static void __ntp_clear(struct ntp_data *ntpdata)
- {
-       /* Stop active adjtime() */
-       time_adjust     = 0;
-@@ -341,7 +339,7 @@ void ntp_clear(void)
-       time_maxerror   = NTP_PHASE_LIMIT;
-       time_esterror   = NTP_PHASE_LIMIT;
--      ntp_update_frequency();
-+      ntp_update_frequency(ntpdata);
-       tick_length     = tick_length_base;
-       time_offset     = 0;
-@@ -351,6 +349,14 @@ void ntp_clear(void)
-       pps_clear();
- }
-+/**
-+ * ntp_clear - Clears the NTP state variables
-+ */
-+void ntp_clear(void)
-+{
-+      __ntp_clear(&tk_ntp_data);
-+}
-+
- u64 ntp_tick_length(void)
- {
-@@ -706,7 +712,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
- }
--static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-+static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct __kernel_timex *txc,
-                                         s32 *time_tai)
- {
-       if (txc->modes & ADJ_STATUS)
-@@ -747,13 +753,12 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-               ntp_update_offset(txc->offset);
-       if (txc->modes & ADJ_TICK)
--              tick_usec = txc->tick;
-+              ntpdata->tick_usec = txc->tick;
-       if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
--              ntp_update_frequency();
-+              ntp_update_frequency(ntpdata);
- }
--
- /*
-  * adjtimex() mainly allows reading (and writing, if superuser) of
-  * kernel time-keeping variables. used by xntpd.
-@@ -761,6 +766,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
- int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                 s32 *time_tai, struct audit_ntp_data *ad)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       int result;
-       if (txc->modes & ADJ_ADJTIME) {
-@@ -769,7 +775,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-               if (!(txc->modes & ADJ_OFFSET_READONLY)) {
-                       /* adjtime() is independent from ntp_adjtime() */
-                       time_adjust = txc->offset;
--                      ntp_update_frequency();
-+                      ntp_update_frequency(ntpdata);
-                       audit_ntp_set_old(ad, AUDIT_NTP_ADJUST, save_adjust);
-                       audit_ntp_set_new(ad, AUDIT_NTP_ADJUST, time_adjust);
-@@ -782,15 +788,15 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       audit_ntp_set_old(ad, AUDIT_NTP_FREQ,   time_freq);
-                       audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TAI,    *time_tai);
--                      audit_ntp_set_old(ad, AUDIT_NTP_TICK,   tick_usec);
-+                      audit_ntp_set_old(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
--                      process_adjtimex_modes(txc, time_tai);
-+                      process_adjtimex_modes(ntpdata, txc, time_tai);
-                       audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_new(ad, AUDIT_NTP_FREQ,   time_freq);
-                       audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TAI,    *time_tai);
--                      audit_ntp_set_new(ad, AUDIT_NTP_TICK,   tick_usec);
-+                      audit_ntp_set_new(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-               }
-               txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
-@@ -811,7 +817,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->constant      = time_constant;
-       txc->precision     = 1;
-       txc->tolerance     = MAXFREQ_SCALED / PPM_SCALE;
--      txc->tick          = tick_usec;
-+      txc->tick          = ntpdata->tick_usec;
-       txc->tai           = *time_tai;
-       /* Fill PPS status fields */
-@@ -932,7 +938,7 @@ static inline void pps_inc_freq_interval(void)
-  * too long, the data are discarded.
-  * Returns the difference between old and new frequency values.
-  */
--static long hardpps_update_freq(struct pps_normtime freq_norm)
-+static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime freq_norm)
- {
-       long delta, delta_mod;
-       s64 ftemp;
-@@ -979,7 +985,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       /* If enabled, the system clock frequency is updated */
-       if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
--              ntp_update_frequency();
-+              ntp_update_frequency(ntpdata);
-       }
-       return delta;
-@@ -1030,6 +1036,7 @@ static void hardpps_update_phase(long error)
- void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts)
- {
-       struct pps_normtime pts_norm, freq_norm;
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       pts_norm = pps_normalize_ts(*phase_ts);
-@@ -1070,7 +1077,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-               pps_calcnt++;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
--              hardpps_update_freq(freq_norm);
-+              hardpps_update_freq(ntpdata, freq_norm);
-       }
-       hardpps_update_phase(pts_norm.nsec);
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-make-tick_usec-static.patch b/queue-6.12/ntp-make-tick_usec-static.patch
deleted file mode 100644 (file)
index c78fb2e..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-From bc82cd48fc9998b95d1e07b709738796c6ad93d9 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:38 +0200
-Subject: ntp: Make tick_usec static
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 66606a93849bfe3cbe9f0b801b40f60b87c54e11 ]
-
-There are no users of tick_usec outside of the NTP core code. Therefore
-make tick_usec static.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-2-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/timex.h | 7 -------
- kernel/time/ntp.c     | 5 ++++-
- 2 files changed, 4 insertions(+), 8 deletions(-)
-
-diff --git a/include/linux/timex.h b/include/linux/timex.h
-index 7f7a12fd8200c..4ee32eff3f221 100644
---- a/include/linux/timex.h
-+++ b/include/linux/timex.h
-@@ -139,13 +139,6 @@ unsigned long random_get_entropy_fallback(void);
- #define MAXSEC 2048           /* max interval between updates (s) */
- #define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
--/*
-- * kernel variables
-- * Note: maximum error = NTP sync distance = dispersion + delay / 2;
-- * estimated error = NTP dispersion.
-- */
--extern unsigned long tick_usec;               /* USER_HZ period (usec) */
--
- /* Required to safely shift negative values */
- #define shift_right(x, s) ({  \
-       __typeof__(x) __x = (x);        \
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index c17cc9d857bc1..ed15ec993a829 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -31,7 +31,7 @@
- /* USER_HZ period (usecs): */
--unsigned long                 tick_usec = USER_TICK_USEC;
-+static unsigned long          tick_usec = USER_TICK_USEC;
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -44,6 +44,9 @@ static u64                   tick_length_base;
- /*
-  * phase-lock loop variables
-+ *
-+ * Note: maximum error = NTP sync distance = dispersion + delay / 2;
-+ * estimated error = NTP dispersion.
-  */
- /*
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-move-tick_length-into-ntp_data.patch b/queue-6.12/ntp-move-tick_length-into-ntp_data.patch
deleted file mode 100644 (file)
index a36d804..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-From 0fe1bb3a8028f7ec5c74ee3aefa142db84098dcf Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:44 +0200
-Subject: ntp: Move tick_length* into ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit ec93ec22aa10fb5311c0f068ee66c5b6d39788fe ]
-
-Continue the conversion from static variables to struct based data.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-8-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 34 ++++++++++++++++++----------------
- 1 file changed, 18 insertions(+), 16 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index f95f23385a62a..2430e69743ee2 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -25,20 +25,21 @@
- /**
-  * struct ntp_data - Structure holding all NTP related state
-  * @tick_usec:                USER_HZ period in microseconds
-+ * @tick_length:      Adjusted tick length
-+ * @tick_length_base: Base value for @tick_length
-  *
-  * Protected by the timekeeping locks.
-  */
- struct ntp_data {
-       unsigned long           tick_usec;
-+      u64                     tick_length;
-+      u64                     tick_length_base;
- };
- static struct ntp_data tk_ntp_data = {
-       .tick_usec              = USER_TICK_USEC,
- };
--static u64                    tick_length;
--static u64                    tick_length_base;
--
- #define SECS_PER_DAY          86400
- #define MAX_TICKADJ           500LL           /* usecs */
- #define MAX_TICKADJ_SCALED \
-@@ -263,8 +264,8 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
-        * Don't wait for the next second_overflow, apply the change to the
-        * tick length immediately:
-        */
--      tick_length             += new_base - tick_length_base;
--      tick_length_base         = new_base;
-+      ntpdata->tick_length            += new_base - ntpdata->tick_length_base;
-+      ntpdata->tick_length_base        = new_base;
- }
- static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
-@@ -341,8 +342,8 @@ static void __ntp_clear(struct ntp_data *ntpdata)
-       ntp_update_frequency(ntpdata);
--      tick_length     = tick_length_base;
--      time_offset     = 0;
-+      ntpdata->tick_length    = ntpdata->tick_length_base;
-+      time_offset             = 0;
-       ntp_next_leap_sec = TIME64_MAX;
-       /* Clear PPS state variables */
-@@ -360,7 +361,7 @@ void ntp_clear(void)
- u64 ntp_tick_length(void)
- {
--      return tick_length;
-+      return tk_ntp_data.tick_length;
- }
- /**
-@@ -391,6 +392,7 @@ ktime_t ntp_get_next_leap(void)
-  */
- int second_overflow(time64_t secs)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       s64 delta;
-       int leap = 0;
-       s32 rem;
-@@ -451,11 +453,11 @@ int second_overflow(time64_t secs)
-       }
-       /* Compute the phase adjustment for the next second */
--      tick_length      = tick_length_base;
-+      ntpdata->tick_length     = ntpdata->tick_length_base;
--      delta            = ntp_offset_chunk(time_offset);
--      time_offset     -= delta;
--      tick_length     += delta;
-+      delta                    = ntp_offset_chunk(time_offset);
-+      time_offset             -= delta;
-+      ntpdata->tick_length    += delta;
-       /* Check PPS signal */
-       pps_dec_valid();
-@@ -465,18 +467,18 @@ int second_overflow(time64_t secs)
-       if (time_adjust > MAX_TICKADJ) {
-               time_adjust -= MAX_TICKADJ;
--              tick_length += MAX_TICKADJ_SCALED;
-+              ntpdata->tick_length += MAX_TICKADJ_SCALED;
-               goto out;
-       }
-       if (time_adjust < -MAX_TICKADJ) {
-               time_adjust += MAX_TICKADJ;
--              tick_length -= MAX_TICKADJ_SCALED;
-+              ntpdata->tick_length -= MAX_TICKADJ_SCALED;
-               goto out;
-       }
--      tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
--                                                       << NTP_SCALE_SHIFT;
-+      ntpdata->tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
-+                              << NTP_SCALE_SHIFT;
-       time_adjust = 0;
- out:
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-move-tick_stat-into-ntp_data.patch b/queue-6.12/ntp-move-tick_stat-into-ntp_data.patch
deleted file mode 100644 (file)
index bae6620..0000000
+++ /dev/null
@@ -1,539 +0,0 @@
-From e5cd0013fd4580d589578a01e182bf6809e45672 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:45 +0200
-Subject: ntp: Move tick_stat* into ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit bee18a2301f97465a464176767f3a3a64f900d93 ]
-
-Continue the conversion from static variables to struct based data.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-9-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 175 ++++++++++++++++++++++------------------------
- 1 file changed, 85 insertions(+), 90 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 2430e69743ee2..42c039ab8139a 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -27,6 +27,8 @@
-  * @tick_usec:                USER_HZ period in microseconds
-  * @tick_length:      Adjusted tick length
-  * @tick_length_base: Base value for @tick_length
-+ * @time_state:               State of the clock synchronization
-+ * @time_status:      Clock status bits
-  *
-  * Protected by the timekeeping locks.
-  */
-@@ -34,10 +36,14 @@ struct ntp_data {
-       unsigned long           tick_usec;
-       u64                     tick_length;
-       u64                     tick_length_base;
-+      int                     time_state;
-+      int                     time_status;
- };
- static struct ntp_data tk_ntp_data = {
-       .tick_usec              = USER_TICK_USEC,
-+      .time_state             = TIME_OK,
-+      .time_status            = STA_UNSYNC,
- };
- #define SECS_PER_DAY          86400
-@@ -53,16 +59,6 @@ static struct ntp_data tk_ntp_data = {
-  * estimated error = NTP dispersion.
-  */
--/*
-- * clock synchronization status
-- *
-- * (TIME_ERROR prevents overwriting the CMOS clock)
-- */
--static int                    time_state = TIME_OK;
--
--/* clock status bits:                                                 */
--static int                    time_status = STA_UNSYNC;
--
- /* time adjustment (nsecs):                                           */
- static s64                    time_offset;
-@@ -127,9 +123,9 @@ static long pps_errcnt;            /* calibration errors */
-  * PPS kernel consumer compensates the whole phase error immediately.
-  * Otherwise, reduce the offset by a fixed factor times the time constant.
-  */
--static inline s64 ntp_offset_chunk(s64 offset)
-+static inline s64 ntp_offset_chunk(struct ntp_data *ntpdata, s64 offset)
- {
--      if (time_status & STA_PPSTIME && time_status & STA_PPSSIGNAL)
-+      if (ntpdata->time_status & STA_PPSTIME && ntpdata->time_status & STA_PPSSIGNAL)
-               return offset;
-       else
-               return shift_right(offset, SHIFT_PLL + time_constant);
-@@ -159,13 +155,13 @@ static inline void pps_clear(void)
-  * Decrease pps_valid to indicate that another second has passed since the
-  * last PPS signal. When it reaches 0, indicate that PPS signal is missing.
-  */
--static inline void pps_dec_valid(void)
-+static inline void pps_dec_valid(struct ntp_data *ntpdata)
- {
-       if (pps_valid > 0)
-               pps_valid--;
-       else {
--              time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
--                               STA_PPSWANDER | STA_PPSERROR);
-+              ntpdata->time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
-+                                        STA_PPSWANDER | STA_PPSERROR);
-               pps_clear();
-       }
- }
-@@ -198,12 +194,12 @@ static inline bool is_error_status(int status)
-                       && (status & (STA_PPSWANDER|STA_PPSERROR)));
- }
--static inline void pps_fill_timex(struct __kernel_timex *txc)
-+static inline void pps_fill_timex(struct ntp_data *ntpdata, struct __kernel_timex *txc)
- {
-       txc->ppsfreq       = shift_right((pps_freq >> PPM_SCALE_INV_SHIFT) *
-                                        PPM_SCALE_INV, NTP_SCALE_SHIFT);
-       txc->jitter        = pps_jitter;
--      if (!(time_status & STA_NANO))
-+      if (!(ntpdata->time_status & STA_NANO))
-               txc->jitter = pps_jitter / NSEC_PER_USEC;
-       txc->shift         = pps_shift;
-       txc->stabil        = pps_stabil;
-@@ -215,14 +211,14 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
- #else /* !CONFIG_NTP_PPS */
--static inline s64 ntp_offset_chunk(s64 offset)
-+static inline s64 ntp_offset_chunk(struct ntp_data *ntp, s64 offset)
- {
-       return shift_right(offset, SHIFT_PLL + time_constant);
- }
- static inline void pps_reset_freq_interval(void) {}
- static inline void pps_clear(void) {}
--static inline void pps_dec_valid(void) {}
-+static inline void pps_dec_valid(struct ntp_data *ntpdata) {}
- static inline void pps_set_freq(s64 freq) {}
- static inline bool is_error_status(int status)
-@@ -230,7 +226,7 @@ static inline bool is_error_status(int status)
-       return status & (STA_UNSYNC|STA_CLOCKERR);
- }
--static inline void pps_fill_timex(struct __kernel_timex *txc)
-+static inline void pps_fill_timex(struct ntp_data *ntpdata, struct __kernel_timex *txc)
- {
-       /* PPS is not implemented, so these are zero */
-       txc->ppsfreq       = 0;
-@@ -268,30 +264,30 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
-       ntpdata->tick_length_base        = new_base;
- }
--static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
-+static inline s64 ntp_update_offset_fll(struct ntp_data *ntpdata, s64 offset64, long secs)
- {
--      time_status &= ~STA_MODE;
-+      ntpdata->time_status &= ~STA_MODE;
-       if (secs < MINSEC)
-               return 0;
--      if (!(time_status & STA_FLL) && (secs <= MAXSEC))
-+      if (!(ntpdata->time_status & STA_FLL) && (secs <= MAXSEC))
-               return 0;
--      time_status |= STA_MODE;
-+      ntpdata->time_status |= STA_MODE;
-       return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
- }
--static void ntp_update_offset(long offset)
-+static void ntp_update_offset(struct ntp_data *ntpdata, long offset)
- {
-       s64 freq_adj, offset64;
-       long secs, real_secs;
--      if (!(time_status & STA_PLL))
-+      if (!(ntpdata->time_status & STA_PLL))
-               return;
--      if (!(time_status & STA_NANO)) {
-+      if (!(ntpdata->time_status & STA_NANO)) {
-               /* Make sure the multiplication below won't overflow */
-               offset = clamp(offset, -USEC_PER_SEC, USEC_PER_SEC);
-               offset *= NSEC_PER_USEC;
-@@ -306,13 +302,13 @@ static void ntp_update_offset(long offset)
-        */
-       real_secs = __ktime_get_real_seconds();
-       secs = (long)(real_secs - time_reftime);
--      if (unlikely(time_status & STA_FREQHOLD))
-+      if (unlikely(ntpdata->time_status & STA_FREQHOLD))
-               secs = 0;
-       time_reftime = real_secs;
-       offset64    = offset;
--      freq_adj    = ntp_update_offset_fll(offset64, secs);
-+      freq_adj    = ntp_update_offset_fll(ntpdata, offset64, secs);
-       /*
-        * Clamp update interval to reduce PLL gain with low
-@@ -335,10 +331,10 @@ static void ntp_update_offset(long offset)
- static void __ntp_clear(struct ntp_data *ntpdata)
- {
-       /* Stop active adjtime() */
--      time_adjust     = 0;
--      time_status     |= STA_UNSYNC;
--      time_maxerror   = NTP_PHASE_LIMIT;
--      time_esterror   = NTP_PHASE_LIMIT;
-+      time_adjust             = 0;
-+      ntpdata->time_status    |= STA_UNSYNC;
-+      time_maxerror           = NTP_PHASE_LIMIT;
-+      time_esterror           = NTP_PHASE_LIMIT;
-       ntp_update_frequency(ntpdata);
-@@ -372,9 +368,10 @@ u64 ntp_tick_length(void)
-  */
- ktime_t ntp_get_next_leap(void)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       ktime_t ret;
--      if ((time_state == TIME_INS) && (time_status & STA_INS))
-+      if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS))
-               return ktime_set(ntp_next_leap_sec, 0);
-       ret = KTIME_MAX;
-       return ret;
-@@ -402,46 +399,46 @@ int second_overflow(time64_t secs)
-        * day, the system clock is set back one second; if in leap-delete
-        * state, the system clock is set ahead one second.
-        */
--      switch (time_state) {
-+      switch (ntpdata->time_state) {
-       case TIME_OK:
--              if (time_status & STA_INS) {
--                      time_state = TIME_INS;
-+              if (ntpdata->time_status & STA_INS) {
-+                      ntpdata->time_state = TIME_INS;
-                       div_s64_rem(secs, SECS_PER_DAY, &rem);
-                       ntp_next_leap_sec = secs + SECS_PER_DAY - rem;
--              } else if (time_status & STA_DEL) {
--                      time_state = TIME_DEL;
-+              } else if (ntpdata->time_status & STA_DEL) {
-+                      ntpdata->time_state = TIME_DEL;
-                       div_s64_rem(secs + 1, SECS_PER_DAY, &rem);
-                       ntp_next_leap_sec = secs + SECS_PER_DAY - rem;
-               }
-               break;
-       case TIME_INS:
--              if (!(time_status & STA_INS)) {
-+              if (!(ntpdata->time_status & STA_INS)) {
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_OK;
-+                      ntpdata->time_state = TIME_OK;
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = -1;
--                      time_state = TIME_OOP;
-+                      ntpdata->time_state = TIME_OOP;
-                       pr_notice("Clock: inserting leap second 23:59:60 UTC\n");
-               }
-               break;
-       case TIME_DEL:
--              if (!(time_status & STA_DEL)) {
-+              if (!(ntpdata->time_status & STA_DEL)) {
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_OK;
-+                      ntpdata->time_state = TIME_OK;
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = 1;
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_WAIT;
-+                      ntpdata->time_state = TIME_WAIT;
-                       pr_notice("Clock: deleting leap second 23:59:59 UTC\n");
-               }
-               break;
-       case TIME_OOP:
-               ntp_next_leap_sec = TIME64_MAX;
--              time_state = TIME_WAIT;
-+              ntpdata->time_state = TIME_WAIT;
-               break;
-       case TIME_WAIT:
--              if (!(time_status & (STA_INS | STA_DEL)))
--                      time_state = TIME_OK;
-+              if (!(ntpdata->time_status & (STA_INS | STA_DEL)))
-+                      ntpdata->time_state = TIME_OK;
-               break;
-       }
-@@ -449,18 +446,18 @@ int second_overflow(time64_t secs)
-       time_maxerror += MAXFREQ / NSEC_PER_USEC;
-       if (time_maxerror > NTP_PHASE_LIMIT) {
-               time_maxerror = NTP_PHASE_LIMIT;
--              time_status |= STA_UNSYNC;
-+              ntpdata->time_status |= STA_UNSYNC;
-       }
-       /* Compute the phase adjustment for the next second */
-       ntpdata->tick_length     = ntpdata->tick_length_base;
--      delta                    = ntp_offset_chunk(time_offset);
-+      delta                    = ntp_offset_chunk(ntpdata, time_offset);
-       time_offset             -= delta;
-       ntpdata->tick_length    += delta;
-       /* Check PPS signal */
--      pps_dec_valid();
-+      pps_dec_valid(ntpdata);
-       if (!time_adjust)
-               goto out;
-@@ -608,7 +605,7 @@ static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_ns
-  */
- static inline bool ntp_synced(void)
- {
--      return !(time_status & STA_UNSYNC);
-+      return !(tk_ntp_data.time_status & STA_UNSYNC);
- }
- /*
-@@ -691,11 +688,11 @@ static inline void __init ntp_init_cmos_sync(void) { }
- /*
-  * Propagate a new txc->status value into the NTP state:
-  */
--static inline void process_adj_status(const struct __kernel_timex *txc)
-+static inline void process_adj_status(struct ntp_data *ntpdata, const struct __kernel_timex *txc)
- {
--      if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) {
--              time_state = TIME_OK;
--              time_status = STA_UNSYNC;
-+      if ((ntpdata->time_status & STA_PLL) && !(txc->status & STA_PLL)) {
-+              ntpdata->time_state = TIME_OK;
-+              ntpdata->time_status = STA_UNSYNC;
-               ntp_next_leap_sec = TIME64_MAX;
-               /* Restart PPS frequency calibration */
-               pps_reset_freq_interval();
-@@ -705,26 +702,25 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-        * If we turn on PLL adjustments then reset the
-        * reference time to current time.
-        */
--      if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
-+      if (!(ntpdata->time_status & STA_PLL) && (txc->status & STA_PLL))
-               time_reftime = __ktime_get_real_seconds();
--      /* Only set allowed bits */
--      time_status &= STA_RONLY;
--      time_status |= txc->status & ~STA_RONLY;
-+      /* only set allowed bits */
-+      ntpdata->time_status &= STA_RONLY;
-+      ntpdata->time_status |= txc->status & ~STA_RONLY;
- }
--
- static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct __kernel_timex *txc,
-                                         s32 *time_tai)
- {
-       if (txc->modes & ADJ_STATUS)
--              process_adj_status(txc);
-+              process_adj_status(ntpdata, txc);
-       if (txc->modes & ADJ_NANO)
--              time_status |= STA_NANO;
-+              ntpdata->time_status |= STA_NANO;
-       if (txc->modes & ADJ_MICRO)
--              time_status &= ~STA_NANO;
-+              ntpdata->time_status &= ~STA_NANO;
-       if (txc->modes & ADJ_FREQUENCY) {
-               time_freq = txc->freq * PPM_SCALE;
-@@ -742,17 +738,16 @@ static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct
-       if (txc->modes & ADJ_TIMECONST) {
-               time_constant = clamp(txc->constant, 0, MAXTC);
--              if (!(time_status & STA_NANO))
-+              if (!(ntpdata->time_status & STA_NANO))
-                       time_constant += 4;
-               time_constant = clamp(time_constant, 0, MAXTC);
-       }
--      if (txc->modes & ADJ_TAI &&
--                      txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
-+      if (txc->modes & ADJ_TAI && txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
-               *time_tai = txc->constant;
-       if (txc->modes & ADJ_OFFSET)
--              ntp_update_offset(txc->offset);
-+              ntp_update_offset(ntpdata, txc->offset);
-       if (txc->modes & ADJ_TICK)
-               ntpdata->tick_usec = txc->tick;
-@@ -788,7 +783,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-               if (txc->modes) {
-                       audit_ntp_set_old(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_old(ad, AUDIT_NTP_FREQ,   time_freq);
--                      audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status);
-+                      audit_ntp_set_old(ad, AUDIT_NTP_STATUS, ntpdata->time_status);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TAI,    *time_tai);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-@@ -796,26 +791,26 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_new(ad, AUDIT_NTP_FREQ,   time_freq);
--                      audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status);
-+                      audit_ntp_set_new(ad, AUDIT_NTP_STATUS, ntpdata->time_status);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TAI,    *time_tai);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-               }
-               txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
-                                 NTP_SCALE_SHIFT);
--              if (!(time_status & STA_NANO))
-+              if (!(ntpdata->time_status & STA_NANO))
-                       txc->offset = (u32)txc->offset / NSEC_PER_USEC;
-       }
--      result = time_state;
--      if (is_error_status(time_status))
-+      result = ntpdata->time_state;
-+      if (is_error_status(ntpdata->time_status))
-               result = TIME_ERROR;
-       txc->freq          = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) *
-                                        PPM_SCALE_INV, NTP_SCALE_SHIFT);
-       txc->maxerror      = time_maxerror;
-       txc->esterror      = time_esterror;
--      txc->status        = time_status;
-+      txc->status        = ntpdata->time_status;
-       txc->constant      = time_constant;
-       txc->precision     = 1;
-       txc->tolerance     = MAXFREQ_SCALED / PPM_SCALE;
-@@ -823,26 +818,26 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->tai           = *time_tai;
-       /* Fill PPS status fields */
--      pps_fill_timex(txc);
-+      pps_fill_timex(ntpdata, txc);
-       txc->time.tv_sec = ts->tv_sec;
-       txc->time.tv_usec = ts->tv_nsec;
--      if (!(time_status & STA_NANO))
-+      if (!(ntpdata->time_status & STA_NANO))
-               txc->time.tv_usec = ts->tv_nsec / NSEC_PER_USEC;
-       /* Handle leapsec adjustments */
-       if (unlikely(ts->tv_sec >= ntp_next_leap_sec)) {
--              if ((time_state == TIME_INS) && (time_status & STA_INS)) {
-+              if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS)) {
-                       result = TIME_OOP;
-                       txc->tai++;
-                       txc->time.tv_sec--;
-               }
--              if ((time_state == TIME_DEL) && (time_status & STA_DEL)) {
-+              if ((ntpdata->time_state == TIME_DEL) && (ntpdata->time_status & STA_DEL)) {
-                       result = TIME_WAIT;
-                       txc->tai--;
-                       txc->time.tv_sec++;
-               }
--              if ((time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-+              if ((ntpdata->time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-                       result = TIME_WAIT;
-       }
-@@ -947,7 +942,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-       /* Check if the frequency interval was too long */
-       if (freq_norm.sec > (2 << pps_shift)) {
--              time_status |= STA_PPSERROR;
-+              ntpdata->time_status |= STA_PPSERROR;
-               pps_errcnt++;
-               pps_dec_freq_interval();
-               printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n",
-@@ -966,7 +961,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-       pps_freq = ftemp;
-       if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
-               printk_deferred(KERN_WARNING "hardpps: PPSWANDER: change=%ld\n", delta);
--              time_status |= STA_PPSWANDER;
-+              ntpdata->time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
-       } else {
-@@ -985,7 +980,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-                              NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-       /* If enabled, the system clock frequency is updated */
--      if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-+      if ((ntpdata->time_status & STA_PPSFREQ) && !(ntpdata->time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
-               ntp_update_frequency(ntpdata);
-       }
-@@ -994,7 +989,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
- }
- /* Correct REALTIME clock phase error against PPS signal */
--static void hardpps_update_phase(long error)
-+static void hardpps_update_phase(struct ntp_data *ntpdata, long error)
- {
-       long correction = -error;
-       long jitter;
-@@ -1011,9 +1006,9 @@ static void hardpps_update_phase(long error)
-       if (jitter > (pps_jitter << PPS_POPCORN)) {
-               printk_deferred(KERN_WARNING "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-                               jitter, (pps_jitter << PPS_POPCORN));
--              time_status |= STA_PPSJITTER;
-+              ntpdata->time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
--      } else if (time_status & STA_PPSTIME) {
-+      } else if (ntpdata->time_status & STA_PPSTIME) {
-               /* Correct the time using the phase offset */
-               time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
-               /* Cancel running adjtime() */
-@@ -1043,10 +1038,10 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-       pts_norm = pps_normalize_ts(*phase_ts);
-       /* Clear the error bits, they will be set again if needed */
--      time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
-+      ntpdata->time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
--      /* Indicate signal presence */
--      time_status |= STA_PPSSIGNAL;
-+      /* indicate signal presence */
-+      ntpdata->time_status |= STA_PPSSIGNAL;
-       pps_valid = PPS_VALID;
-       /*
-@@ -1067,7 +1062,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-        */
-       if ((freq_norm.sec == 0) || (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-           (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
--              time_status |= STA_PPSJITTER;
-+              ntpdata->time_status |= STA_PPSJITTER;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n");
-@@ -1082,7 +1077,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-               hardpps_update_freq(ntpdata, freq_norm);
-       }
--      hardpps_update_phase(pts_norm.nsec);
-+      hardpps_update_phase(ntpdata, pts_norm.nsec);
- }
- #endif        /* CONFIG_NTP_PPS */
--- 
-2.43.0
-
diff --git a/queue-6.12/ntp-read-reference-time-only-once.patch b/queue-6.12/ntp-read-reference-time-only-once.patch
deleted file mode 100644 (file)
index 385a86a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-From 615a20c1b427738e2cd85b339363d4a9a164152f Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:42 +0200
-Subject: ntp: Read reference time only once
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 136bccbc2e78d3cd0bd8831e4c5a4509c0ddd945 ]
-
-The reference time is required twice in ntp_update_offset(). It will not
-change in the meantime as the calling code holds the timekeeper lock. Read
-it only once and store it into a local variable.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-6-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 905b0216b12dc..0bfd07de202a5 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -283,9 +283,8 @@ static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
- static void ntp_update_offset(long offset)
- {
--      s64 freq_adj;
--      s64 offset64;
--      long secs;
-+      s64 freq_adj, offset64;
-+      long secs, real_secs;
-       if (!(time_status & STA_PLL))
-               return;
-@@ -303,11 +302,12 @@ static void ntp_update_offset(long offset)
-        * Select how the frequency is to be controlled
-        * and in which mode (PLL or FLL).
-        */
--      secs = (long)(__ktime_get_real_seconds() - time_reftime);
-+      real_secs = __ktime_get_real_seconds();
-+      secs = (long)(real_secs - time_reftime);
-       if (unlikely(time_status & STA_FREQHOLD))
-               secs = 0;
--      time_reftime = __ktime_get_real_seconds();
-+      time_reftime = real_secs;
-       offset64    = offset;
-       freq_adj    = ntp_update_offset_fll(offset64, secs);
--- 
-2.43.0
-
index 759b0a500b091eb25c2c847c46f057156c96e43b..44f7f9336fc3c8ab2a8b775a8090b93477662dc7 100644 (file)
@@ -1,11 +1,11 @@
-From d6835449c2cb9aff1a34a9b12ee43a4d66b80d4e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
+From f5807b0606da7ac7c1b74a386b22134ec7702d05 Mon Sep 17 00:00:00 2001
+From: Marcelo Dalmas <marcelo.dalmas@ge.com>
 Date: Mon, 25 Nov 2024 12:16:09 +0000
 Subject: ntp: Remove invalid cast in time offset math
 
 From: Marcelo Dalmas <marcelo.dalmas@ge.com>
 
-[ Upstream commit f5807b0606da7ac7c1b74a386b22134ec7702d05 ]
+commit f5807b0606da7ac7c1b74a386b22134ec7702d05 upstream.
 
 Due to an unsigned cast, adjtimex() returns the wrong offest when using
 ADJ_MICRO and the offset is negative. In this case a small negative offset
@@ -29,24 +29,19 @@ Signed-off-by: Marcelo Dalmas <marcelo.dalmas@ge.com>
 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
 Cc: stable@vger.kernel.org
 Link: https://lore.kernel.org/all/SJ0P101MB03687BF7D5A10FD3C49C51E5F42E2@SJ0P101MB0368.NAMP101.PROD.OUTLOOK.COM
-Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 ---
- kernel/time/ntp.c | 2 +-
+ kernel/time/ntp.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 42c039ab8139a..15bc5c592ebbe 100644
 --- a/kernel/time/ntp.c
 +++ b/kernel/time/ntp.c
-@@ -799,7 +799,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
+@@ -804,7 +804,7 @@ int __do_adjtimex(struct __kernel_timex
                txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
                                  NTP_SCALE_SHIFT);
-               if (!(ntpdata->time_status & STA_NANO))
+               if (!(time_status & STA_NANO))
 -                      txc->offset = (u32)txc->offset / NSEC_PER_USEC;
 +                      txc->offset = div_s64(txc->offset, NSEC_PER_USEC);
        }
  
-       result = ntpdata->time_state;
--- 
-2.43.0
-
+       result = time_state;    /* mostly `TIME_OK' */
diff --git a/queue-6.12/ntp-remove-unused-tick_nsec.patch b/queue-6.12/ntp-remove-unused-tick_nsec.patch
deleted file mode 100644 (file)
index 3b0e1db..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-From 47820bd8951cecde2a46e794efb818bf82555ccc Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:37 +0200
-Subject: ntp: Remove unused tick_nsec
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit a849a0273d0f73a252d14d31c5003a8059ea51fc ]
-
-tick_nsec is only updated in the NTP core, but there are no users.
-
-Remove it.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-1-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/include/asm/timer.h | 2 --
- include/linux/timex.h        | 1 -
- kernel/time/ntp.c            | 8 ++------
- 3 files changed, 2 insertions(+), 9 deletions(-)
-
-diff --git a/arch/x86/include/asm/timer.h b/arch/x86/include/asm/timer.h
-index 7365dd4acffb6..23baf8c9b34ca 100644
---- a/arch/x86/include/asm/timer.h
-+++ b/arch/x86/include/asm/timer.h
-@@ -6,8 +6,6 @@
- #include <linux/interrupt.h>
- #include <linux/math64.h>
--#define TICK_SIZE (tick_nsec / 1000)
--
- unsigned long long native_sched_clock(void);
- extern void recalibrate_cpu_khz(void);
-diff --git a/include/linux/timex.h b/include/linux/timex.h
-index 3871b06bd302c..7f7a12fd8200c 100644
---- a/include/linux/timex.h
-+++ b/include/linux/timex.h
-@@ -145,7 +145,6 @@ unsigned long random_get_entropy_fallback(void);
-  * estimated error = NTP dispersion.
-  */
- extern unsigned long tick_usec;               /* USER_HZ period (usec) */
--extern unsigned long tick_nsec;               /* SHIFTED_HZ period (nsec) */
- /* Required to safely shift negative values */
- #define shift_right(x, s) ({  \
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 802b336f4b8c2..c17cc9d857bc1 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -33,9 +33,6 @@
- /* USER_HZ period (usecs): */
- unsigned long                 tick_usec = USER_TICK_USEC;
--/* SHIFTED_HZ period (nsecs): */
--unsigned long                 tick_nsec;
--
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -253,8 +250,8 @@ static inline int ntp_synced(void)
-  */
- /*
-- * Update (tick_length, tick_length_base, tick_nsec), based
-- * on (tick_usec, ntp_tick_adj, time_freq):
-+ * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-+ * time_freq:
-  */
- static void ntp_update_frequency(void)
- {
-@@ -267,7 +264,6 @@ static void ntp_update_frequency(void)
-       second_length           += ntp_tick_adj;
-       second_length           += time_freq;
--      tick_nsec                = div_u64(second_length, HZ) >> NTP_SCALE_SHIFT;
-       new_base                 = div_u64(second_length, NTP_INTERVAL_FREQ);
-       /*
--- 
-2.43.0
-
index 01aefa7e9157107b0a93dccd319594cb17fc0e8d..8f8f5cc739a2e2cf3cf472676aa82631ee0d335a 100644 (file)
@@ -69,15 +69,6 @@ mmc-core-adjust-acmd22-to-sduc.patch
 mmc-core-use-gfp_noio-in-acmd22.patch
 zram-do-not-mark-idle-slots-that-cannot-be-idle.patch
 zram-clear-idle-flag-in-mark_idle.patch
-ntp-remove-unused-tick_nsec.patch
-ntp-make-tick_usec-static.patch
-ntp-clean-up-comments.patch
-ntp-cleanup-formatting-of-code.patch
-ntp-convert-functions-with-only-two-states-to-bool.patch
-ntp-read-reference-time-only-once.patch
-ntp-introduce-struct-ntp_data.patch
-ntp-move-tick_length-into-ntp_data.patch
-ntp-move-tick_stat-into-ntp_data.patch
 ntp-remove-invalid-cast-in-time-offset-math.patch
 f2fs-clean-up-w-f2fs_-blk_to_bytes-btyes_to_blk.patch
 f2fs-fix-to-adjust-appropriate-length-for-fiemap.patch
diff --git a/queue-6.6/ntp-clean-up-comments.patch b/queue-6.6/ntp-clean-up-comments.patch
deleted file mode 100644 (file)
index e0f91d4..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-From a952ef82c4ecc4b4ef6ddae4b810213d5944b945 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:39 +0200
-Subject: ntp: Clean up comments
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit a0581cdb2e5d3ad633e51a945b6f0527ce70b68a ]
-
-Usage of different comment formatting makes fast reading and parsing the
-code harder. There are several multi-line comments which do not follow the
-coding style by starting with a line only containing '/*'. There are also
-comments which do not start with capitals.
-
-Clean up all those comments to be consistent and remove comments which
-document the obvious.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-3-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 144 +++++++++++++++++++++++++---------------------
- 1 file changed, 78 insertions(+), 66 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 8e68a85996f7d..99213d931f63f 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -119,7 +119,8 @@ static long pps_stbcnt;            /* stability limit exceeded */
- static long pps_errcnt;               /* calibration errors */
--/* PPS kernel consumer compensates the whole phase error immediately.
-+/*
-+ * PPS kernel consumer compensates the whole phase error immediately.
-  * Otherwise, reduce the offset by a fixed factor times the time constant.
-  */
- static inline s64 ntp_offset_chunk(s64 offset)
-@@ -132,8 +133,7 @@ static inline s64 ntp_offset_chunk(s64 offset)
- static inline void pps_reset_freq_interval(void)
- {
--      /* the PPS calibration interval may end
--         surprisingly early */
-+      /* The PPS calibration interval may end surprisingly early */
-       pps_shift = PPS_INTMIN;
-       pps_intcnt = 0;
- }
-@@ -151,9 +151,9 @@ static inline void pps_clear(void)
-       pps_freq = 0;
- }
--/* Decrease pps_valid to indicate that another second has passed since
-- * the last PPS signal. When it reaches 0, indicate that PPS signal is
-- * missing.
-+/*
-+ * Decrease pps_valid to indicate that another second has passed since the
-+ * last PPS signal. When it reaches 0, indicate that PPS signal is missing.
-  */
- static inline void pps_dec_valid(void)
- {
-@@ -174,17 +174,21 @@ static inline void pps_set_freq(s64 freq)
- static inline int is_error_status(int status)
- {
-       return (status & (STA_UNSYNC|STA_CLOCKERR))
--              /* PPS signal lost when either PPS time or
--               * PPS frequency synchronization requested
-+              /*
-+               * PPS signal lost when either PPS time or PPS frequency
-+               * synchronization requested
-                */
-               || ((status & (STA_PPSFREQ|STA_PPSTIME))
-                       && !(status & STA_PPSSIGNAL))
--              /* PPS jitter exceeded when
--               * PPS time synchronization requested */
-+              /*
-+               * PPS jitter exceeded when PPS time synchronization
-+               * requested
-+               */
-               || ((status & (STA_PPSTIME|STA_PPSJITTER))
-                       == (STA_PPSTIME|STA_PPSJITTER))
--              /* PPS wander exceeded or calibration error when
--               * PPS frequency synchronization requested
-+              /*
-+               * PPS wander exceeded or calibration error when PPS
-+               * frequency synchronization requested
-                */
-               || ((status & STA_PPSFREQ)
-                       && (status & (STA_PPSWANDER|STA_PPSERROR)));
-@@ -270,8 +274,8 @@ static void ntp_update_frequency(void)
-       new_base                 = div_u64(second_length, NTP_INTERVAL_FREQ);
-       /*
--       * Don't wait for the next second_overflow, apply
--       * the change to the tick length immediately:
-+       * Don't wait for the next second_overflow, apply the change to the
-+       * tick length immediately:
-        */
-       tick_length             += new_base - tick_length_base;
-       tick_length_base         = new_base;
-@@ -307,10 +311,7 @@ static void ntp_update_offset(long offset)
-               offset *= NSEC_PER_USEC;
-       }
--      /*
--       * Scale the phase adjustment and
--       * clamp to the operating range.
--       */
-+      /* Scale the phase adjustment and clamp to the operating range. */
-       offset = clamp(offset, -MAXPHASE, MAXPHASE);
-       /*
-@@ -349,7 +350,8 @@ static void ntp_update_offset(long offset)
-  */
- void ntp_clear(void)
- {
--      time_adjust     = 0;            /* stop active adjtime() */
-+      /* Stop active adjtime() */
-+      time_adjust     = 0;
-       time_status     |= STA_UNSYNC;
-       time_maxerror   = NTP_PHASE_LIMIT;
-       time_esterror   = NTP_PHASE_LIMIT;
-@@ -387,7 +389,7 @@ ktime_t ntp_get_next_leap(void)
- }
- /*
-- * this routine handles the overflow of the microsecond field
-+ * This routine handles the overflow of the microsecond field
-  *
-  * The tricky bits of code to handle the accurate clock support
-  * were provided by Dave Mills (Mills@UDEL.EDU) of NTP fame.
-@@ -452,7 +454,6 @@ int second_overflow(time64_t secs)
-               break;
-       }
--
-       /* Bump the maxerror field */
-       time_maxerror += MAXFREQ / NSEC_PER_USEC;
-       if (time_maxerror > NTP_PHASE_LIMIT) {
-@@ -688,7 +689,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-               time_state = TIME_OK;
-               time_status = STA_UNSYNC;
-               ntp_next_leap_sec = TIME64_MAX;
--              /* restart PPS frequency calibration */
-+              /* Restart PPS frequency calibration */
-               pps_reset_freq_interval();
-       }
-@@ -699,7 +700,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-       if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
-               time_reftime = __ktime_get_real_seconds();
--      /* only set allowed bits */
-+      /* Only set allowed bits */
-       time_status &= STA_RONLY;
-       time_status |= txc->status & ~STA_RONLY;
- }
-@@ -721,7 +722,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-               time_freq = txc->freq * PPM_SCALE;
-               time_freq = min(time_freq, MAXFREQ_SCALED);
-               time_freq = max(time_freq, -MAXFREQ_SCALED);
--              /* update pps_freq */
-+              /* Update pps_freq */
-               pps_set_freq(time_freq);
-       }
-@@ -754,7 +755,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
- /*
-- * adjtimex mainly allows reading (and writing, if superuser) of
-+ * adjtimex() mainly allows reading (and writing, if superuser) of
-  * kernel time-keeping variables. used by xntpd.
-  */
- int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-@@ -798,8 +799,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       txc->offset = (u32)txc->offset / NSEC_PER_USEC;
-       }
--      result = time_state;    /* mostly `TIME_OK' */
--      /* check for errors */
-+      result = time_state;
-       if (is_error_status(time_status))
-               result = TIME_ERROR;
-@@ -814,7 +814,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->tick          = tick_usec;
-       txc->tai           = *time_tai;
--      /* fill PPS status fields */
-+      /* Fill PPS status fields */
-       pps_fill_timex(txc);
-       txc->time.tv_sec = ts->tv_sec;
-@@ -845,17 +845,21 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
- #ifdef        CONFIG_NTP_PPS
--/* actually struct pps_normtime is good old struct timespec, but it is
-+/*
-+ * struct pps_normtime is basically a struct timespec, but it is
-  * semantically different (and it is the reason why it was invented):
-  * pps_normtime.nsec has a range of ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ]
-- * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC) */
-+ * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC)
-+ */
- struct pps_normtime {
-       s64             sec;    /* seconds */
-       long            nsec;   /* nanoseconds */
- };
--/* normalize the timestamp so that nsec is in the
--   ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval */
-+/*
-+ * Normalize the timestamp so that nsec is in the
-+ * [ -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval
-+ */
- static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts)
- {
-       struct pps_normtime norm = {
-@@ -871,7 +875,7 @@ static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts)
-       return norm;
- }
--/* get current phase correction and jitter */
-+/* Get current phase correction and jitter */
- static inline long pps_phase_filter_get(long *jitter)
- {
-       *jitter = pps_tf[0] - pps_tf[1];
-@@ -882,7 +886,7 @@ static inline long pps_phase_filter_get(long *jitter)
-       return pps_tf[0];
- }
--/* add the sample to the phase filter */
-+/* Add the sample to the phase filter */
- static inline void pps_phase_filter_add(long err)
- {
-       pps_tf[2] = pps_tf[1];
-@@ -890,8 +894,9 @@ static inline void pps_phase_filter_add(long err)
-       pps_tf[0] = err;
- }
--/* decrease frequency calibration interval length.
-- * It is halved after four consecutive unstable intervals.
-+/*
-+ * Decrease frequency calibration interval length. It is halved after four
-+ * consecutive unstable intervals.
-  */
- static inline void pps_dec_freq_interval(void)
- {
-@@ -904,8 +909,9 @@ static inline void pps_dec_freq_interval(void)
-       }
- }
--/* increase frequency calibration interval length.
-- * It is doubled after four consecutive stable intervals.
-+/*
-+ * Increase frequency calibration interval length. It is doubled after
-+ * four consecutive stable intervals.
-  */
- static inline void pps_inc_freq_interval(void)
- {
-@@ -918,7 +924,8 @@ static inline void pps_inc_freq_interval(void)
-       }
- }
--/* update clock frequency based on MONOTONIC_RAW clock PPS signal
-+/*
-+ * Update clock frequency based on MONOTONIC_RAW clock PPS signal
-  * timestamps
-  *
-  * At the end of the calibration interval the difference between the
-@@ -932,7 +939,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       long delta, delta_mod;
-       s64 ftemp;
--      /* check if the frequency interval was too long */
-+      /* Check if the frequency interval was too long */
-       if (freq_norm.sec > (2 << pps_shift)) {
-               time_status |= STA_PPSERROR;
-               pps_errcnt++;
-@@ -943,9 +950,10 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               return 0;
-       }
--      /* here the raw frequency offset and wander (stability) is
--       * calculated. If the wander is less than the wander threshold
--       * the interval is increased; otherwise it is decreased.
-+      /*
-+       * Here the raw frequency offset and wander (stability) is
-+       * calculated. If the wander is less than the wander threshold the
-+       * interval is increased; otherwise it is decreased.
-        */
-       ftemp = div_s64(((s64)(-freq_norm.nsec)) << NTP_SCALE_SHIFT,
-                       freq_norm.sec);
-@@ -957,13 +965,14 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
--      } else {        /* good sample */
-+      } else {
-+              /* Good sample */
-               pps_inc_freq_interval();
-       }
--      /* the stability metric is calculated as the average of recent
--       * frequency changes, but is used only for performance
--       * monitoring
-+      /*
-+       * The stability metric is calculated as the average of recent
-+       * frequency changes, but is used only for performance monitoring
-        */
-       delta_mod = delta;
-       if (delta_mod < 0)
-@@ -972,7 +981,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-                               (NTP_SCALE_SHIFT - SHIFT_USEC),
-                               NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
--      /* if enabled, the system clock frequency is updated */
-+      /* If enabled, the system clock frequency is updated */
-       if ((time_status & STA_PPSFREQ) != 0 &&
-           (time_status & STA_FREQHOLD) == 0) {
-               time_freq = pps_freq;
-@@ -982,17 +991,18 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       return delta;
- }
--/* correct REALTIME clock phase error against PPS signal */
-+/* Correct REALTIME clock phase error against PPS signal */
- static void hardpps_update_phase(long error)
- {
-       long correction = -error;
-       long jitter;
--      /* add the sample to the median filter */
-+      /* Add the sample to the median filter */
-       pps_phase_filter_add(correction);
-       correction = pps_phase_filter_get(&jitter);
--      /* Nominal jitter is due to PPS signal noise. If it exceeds the
-+      /*
-+       * Nominal jitter is due to PPS signal noise. If it exceeds the
-        * threshold, the sample is discarded; otherwise, if so enabled,
-        * the time offset is updated.
-        */
-@@ -1003,13 +1013,13 @@ static void hardpps_update_phase(long error)
-               time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
-       } else if (time_status & STA_PPSTIME) {
--              /* correct the time using the phase offset */
-+              /* Correct the time using the phase offset */
-               time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT,
-                               NTP_INTERVAL_FREQ);
--              /* cancel running adjtime() */
-+              /* Cancel running adjtime() */
-               time_adjust = 0;
-       }
--      /* update jitter */
-+      /* Update jitter */
-       pps_jitter += (jitter - pps_jitter) >> PPS_INTMIN;
- }
-@@ -1031,41 +1041,43 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-       pts_norm = pps_normalize_ts(*phase_ts);
--      /* clear the error bits, they will be set again if needed */
-+      /* Clear the error bits, they will be set again if needed */
-       time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
--      /* indicate signal presence */
-+      /* Indicate signal presence */
-       time_status |= STA_PPSSIGNAL;
-       pps_valid = PPS_VALID;
--      /* when called for the first time,
--       * just start the frequency interval */
-+      /*
-+       * When called for the first time, just start the frequency
-+       * interval
-+       */
-       if (unlikely(pps_fbase.tv_sec == 0)) {
-               pps_fbase = *raw_ts;
-               return;
-       }
--      /* ok, now we have a base for frequency calculation */
-+      /* Ok, now we have a base for frequency calculation */
-       freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, pps_fbase));
--      /* check that the signal is in the range
--       * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */
-+      /*
-+       * Check that the signal is in the range
-+       * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it
-+       */
-       if ((freq_norm.sec == 0) ||
-                       (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-                       (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-               time_status |= STA_PPSJITTER;
--              /* restart the frequency calibration interval */
-+              /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n");
-               return;
-       }
--      /* signal is ok */
--
--      /* check if the current frequency interval is finished */
-+      /* Signal is ok. Check if the current frequency interval is finished */
-       if (freq_norm.sec >= (1 << pps_shift)) {
-               pps_calcnt++;
--              /* restart the frequency calibration interval */
-+              /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               hardpps_update_freq(freq_norm);
-       }
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-cleanup-formatting-of-code.patch b/queue-6.6/ntp-cleanup-formatting-of-code.patch
deleted file mode 100644 (file)
index aeb5d6b..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-From c0d8606cfcee702fb4097c32d30a2cd87d35ddf1 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:40 +0200
-Subject: ntp: Cleanup formatting of code
-
-From: Anna-Maria Behnsen <anna-maria@linutronix.de>
-
-[ Upstream commit 38007dc032bd90920463c5d2e6a27d89f7617d6d ]
-
-Code is partially formatted in a creative way which makes reading
-harder. Examples are function calls over several lines where the
-indentation does not start at the same height then the open bracket after
-the function name.
-
-Improve formatting but do not make a functional change.
-
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-4-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 37 +++++++++++++------------------------
- 1 file changed, 13 insertions(+), 24 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 99213d931f63f..eca9de85b0a76 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -428,8 +428,7 @@ int second_overflow(time64_t secs)
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = -1;
-                       time_state = TIME_OOP;
--                      printk(KERN_NOTICE
--                              "Clock: inserting leap second 23:59:60 UTC\n");
-+                      pr_notice("Clock: inserting leap second 23:59:60 UTC\n");
-               }
-               break;
-       case TIME_DEL:
-@@ -440,8 +439,7 @@ int second_overflow(time64_t secs)
-                       leap = 1;
-                       ntp_next_leap_sec = TIME64_MAX;
-                       time_state = TIME_WAIT;
--                      printk(KERN_NOTICE
--                              "Clock: deleting leap second 23:59:59 UTC\n");
-+                      pr_notice("Clock: deleting leap second 23:59:59 UTC\n");
-               }
-               break;
-       case TIME_OOP:
-@@ -834,10 +832,8 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       txc->tai--;
-                       txc->time.tv_sec++;
-               }
--              if ((time_state == TIME_OOP) &&
--                                      (ts->tv_sec == ntp_next_leap_sec)) {
-+              if ((time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-                       result = TIME_WAIT;
--              }
-       }
-       return result;
-@@ -944,9 +940,8 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-               time_status |= STA_PPSERROR;
-               pps_errcnt++;
-               pps_dec_freq_interval();
--              printk_deferred(KERN_ERR
--                      "hardpps: PPSERROR: interval too long - %lld s\n",
--                      freq_norm.sec);
-+              printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n",
-+                              freq_norm.sec);
-               return 0;
-       }
-@@ -960,8 +955,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       delta = shift_right(ftemp - pps_freq, NTP_SCALE_SHIFT);
-       pps_freq = ftemp;
-       if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
--              printk_deferred(KERN_WARNING
--                              "hardpps: PPSWANDER: change=%ld\n", delta);
-+              printk_deferred(KERN_WARNING "hardpps: PPSWANDER: change=%ld\n", delta);
-               time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
-@@ -977,13 +971,11 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       delta_mod = delta;
-       if (delta_mod < 0)
-               delta_mod = -delta_mod;
--      pps_stabil += (div_s64(((s64)delta_mod) <<
--                              (NTP_SCALE_SHIFT - SHIFT_USEC),
--                              NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-+      pps_stabil += (div_s64(((s64)delta_mod) << (NTP_SCALE_SHIFT - SHIFT_USEC),
-+                             NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-       /* If enabled, the system clock frequency is updated */
--      if ((time_status & STA_PPSFREQ) != 0 &&
--          (time_status & STA_FREQHOLD) == 0) {
-+      if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
-               ntp_update_frequency();
-       }
-@@ -1007,15 +999,13 @@ static void hardpps_update_phase(long error)
-        * the time offset is updated.
-        */
-       if (jitter > (pps_jitter << PPS_POPCORN)) {
--              printk_deferred(KERN_WARNING
--                              "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-+              printk_deferred(KERN_WARNING "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-                               jitter, (pps_jitter << PPS_POPCORN));
-               time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
-       } else if (time_status & STA_PPSTIME) {
-               /* Correct the time using the phase offset */
--              time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT,
--                              NTP_INTERVAL_FREQ);
-+              time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
-               /* Cancel running adjtime() */
-               time_adjust = 0;
-       }
-@@ -1064,9 +1054,8 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-        * Check that the signal is in the range
-        * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it
-        */
--      if ((freq_norm.sec == 0) ||
--                      (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
--                      (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-+      if ((freq_norm.sec == 0) || (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-+          (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
-               time_status |= STA_PPSJITTER;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-convert-functions-with-only-two-states-to-bool.patch b/queue-6.6/ntp-convert-functions-with-only-two-states-to-bool.patch
deleted file mode 100644 (file)
index 7e4e8f9..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-From 7066dbaf1f80ebb01a0858ac1700e39e5010bb3d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:41 +0200
-Subject: ntp: Convert functions with only two states to bool
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 48c3c65f64b01164f1704b40b38f60837d484f13 ]
-
-is_error_status() and ntp_synced() return whether a state is set or
-not. Both functions use unsigned int for it even if it would be a perfect
-job for a bool.
-
-Use bool instead of unsigned int. And while at it, move ntp_synced()
-function to the place where it is used.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-5-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 28 +++++++++++-----------------
- 1 file changed, 11 insertions(+), 17 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index eca9de85b0a76..ef758aafdfd54 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -171,7 +171,7 @@ static inline void pps_set_freq(s64 freq)
-       pps_freq = freq;
- }
--static inline int is_error_status(int status)
-+static inline bool is_error_status(int status)
- {
-       return (status & (STA_UNSYNC|STA_CLOCKERR))
-               /*
-@@ -221,7 +221,7 @@ static inline void pps_clear(void) {}
- static inline void pps_dec_valid(void) {}
- static inline void pps_set_freq(s64 freq) {}
--static inline int is_error_status(int status)
-+static inline bool is_error_status(int status)
- {
-       return status & (STA_UNSYNC|STA_CLOCKERR);
- }
-@@ -241,21 +241,6 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
- #endif /* CONFIG_NTP_PPS */
--
--/**
-- * ntp_synced - Returns 1 if the NTP status is not UNSYNC
-- *
-- */
--static inline int ntp_synced(void)
--{
--      return !(time_status & STA_UNSYNC);
--}
--
--
--/*
-- * NTP methods:
-- */
--
- /*
-  * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-  * time_freq:
-@@ -609,6 +594,15 @@ static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_ns
- }
- #endif
-+/**
-+ * ntp_synced - Tells whether the NTP status is not UNSYNC
-+ * Returns:   true if not UNSYNC, false otherwise
-+ */
-+static inline bool ntp_synced(void)
-+{
-+      return !(time_status & STA_UNSYNC);
-+}
-+
- /*
-  * If we have an externally synchronized Linux clock, then update RTC clock
-  * accordingly every ~11 minutes. Generally RTCs can only store second
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-introduce-struct-ntp_data.patch b/queue-6.6/ntp-introduce-struct-ntp_data.patch
deleted file mode 100644 (file)
index 00a66e2..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-From 6018e1b206968dd5a882e341c5582d81b808ffa5 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:43 +0200
-Subject: ntp: Introduce struct ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 68f66f97c5689825012877f58df65964056d4b5d ]
-
-All NTP data is held in static variables. That prevents the NTP code from
-being reuasble for non-system time timekeepers, e.g. per PTP clock
-timekeeping.
-
-Introduce struct ntp_data and move tick_usec into it for a start.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-7-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 65 ++++++++++++++++++++++++++---------------------
- 1 file changed, 36 insertions(+), 29 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 477cb08062bc5..0222f8e460810 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -22,16 +22,19 @@
- #include "ntp_internal.h"
- #include "timekeeping_internal.h"
--
--/*
-- * NTP timekeeping variables:
-+/**
-+ * struct ntp_data - Structure holding all NTP related state
-+ * @tick_usec:                USER_HZ period in microseconds
-  *
-- * Note: All of the NTP state is protected by the timekeeping locks.
-+ * Protected by the timekeeping locks.
-  */
-+struct ntp_data {
-+      unsigned long           tick_usec;
-+};
--
--/* USER_HZ period (usecs): */
--static unsigned long          tick_usec = USER_TICK_USEC;
-+static struct ntp_data tk_ntp_data = {
-+      .tick_usec              = USER_TICK_USEC,
-+};
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -245,13 +248,11 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
-  * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-  * time_freq:
-  */
--static void ntp_update_frequency(void)
-+static void ntp_update_frequency(struct ntp_data *ntpdata)
- {
--      u64 second_length;
--      u64 new_base;
-+      u64 second_length, new_base, tick_usec = (u64)ntpdata->tick_usec;
--      second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
--                                              << NTP_SCALE_SHIFT;
-+      second_length            = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) << NTP_SCALE_SHIFT;
-       second_length           += ntp_tick_adj;
-       second_length           += time_freq;
-@@ -330,10 +331,7 @@ static void ntp_update_offset(long offset)
-       time_offset = div_s64(offset64 << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
- }
--/**
-- * ntp_clear - Clears the NTP state variables
-- */
--void ntp_clear(void)
-+static void __ntp_clear(struct ntp_data *ntpdata)
- {
-       /* Stop active adjtime() */
-       time_adjust     = 0;
-@@ -341,7 +339,7 @@ void ntp_clear(void)
-       time_maxerror   = NTP_PHASE_LIMIT;
-       time_esterror   = NTP_PHASE_LIMIT;
--      ntp_update_frequency();
-+      ntp_update_frequency(ntpdata);
-       tick_length     = tick_length_base;
-       time_offset     = 0;
-@@ -351,6 +349,14 @@ void ntp_clear(void)
-       pps_clear();
- }
-+/**
-+ * ntp_clear - Clears the NTP state variables
-+ */
-+void ntp_clear(void)
-+{
-+      __ntp_clear(&tk_ntp_data);
-+}
-+
- u64 ntp_tick_length(void)
- {
-@@ -698,7 +704,7 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
- }
--static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-+static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct __kernel_timex *txc,
-                                         s32 *time_tai)
- {
-       if (txc->modes & ADJ_STATUS)
-@@ -739,13 +745,12 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
-               ntp_update_offset(txc->offset);
-       if (txc->modes & ADJ_TICK)
--              tick_usec = txc->tick;
-+              ntpdata->tick_usec = txc->tick;
-       if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
--              ntp_update_frequency();
-+              ntp_update_frequency(ntpdata);
- }
--
- /*
-  * adjtimex() mainly allows reading (and writing, if superuser) of
-  * kernel time-keeping variables. used by xntpd.
-@@ -753,6 +758,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
- int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                 s32 *time_tai, struct audit_ntp_data *ad)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       int result;
-       if (txc->modes & ADJ_ADJTIME) {
-@@ -761,7 +767,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-               if (!(txc->modes & ADJ_OFFSET_READONLY)) {
-                       /* adjtime() is independent from ntp_adjtime() */
-                       time_adjust = txc->offset;
--                      ntp_update_frequency();
-+                      ntp_update_frequency(ntpdata);
-                       audit_ntp_set_old(ad, AUDIT_NTP_ADJUST, save_adjust);
-                       audit_ntp_set_new(ad, AUDIT_NTP_ADJUST, time_adjust);
-@@ -774,15 +780,15 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       audit_ntp_set_old(ad, AUDIT_NTP_FREQ,   time_freq);
-                       audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TAI,    *time_tai);
--                      audit_ntp_set_old(ad, AUDIT_NTP_TICK,   tick_usec);
-+                      audit_ntp_set_old(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
--                      process_adjtimex_modes(txc, time_tai);
-+                      process_adjtimex_modes(ntpdata, txc, time_tai);
-                       audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_new(ad, AUDIT_NTP_FREQ,   time_freq);
-                       audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TAI,    *time_tai);
--                      audit_ntp_set_new(ad, AUDIT_NTP_TICK,   tick_usec);
-+                      audit_ntp_set_new(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-               }
-               txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
-@@ -803,7 +809,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->constant      = time_constant;
-       txc->precision     = 1;
-       txc->tolerance     = MAXFREQ_SCALED / PPM_SCALE;
--      txc->tick          = tick_usec;
-+      txc->tick          = ntpdata->tick_usec;
-       txc->tai           = *time_tai;
-       /* Fill PPS status fields */
-@@ -924,7 +930,7 @@ static inline void pps_inc_freq_interval(void)
-  * too long, the data are discarded.
-  * Returns the difference between old and new frequency values.
-  */
--static long hardpps_update_freq(struct pps_normtime freq_norm)
-+static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime freq_norm)
- {
-       long delta, delta_mod;
-       s64 ftemp;
-@@ -971,7 +977,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
-       /* If enabled, the system clock frequency is updated */
-       if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
--              ntp_update_frequency();
-+              ntp_update_frequency(ntpdata);
-       }
-       return delta;
-@@ -1022,6 +1028,7 @@ static void hardpps_update_phase(long error)
- void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts)
- {
-       struct pps_normtime pts_norm, freq_norm;
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       pts_norm = pps_normalize_ts(*phase_ts);
-@@ -1062,7 +1069,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-               pps_calcnt++;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
--              hardpps_update_freq(freq_norm);
-+              hardpps_update_freq(ntpdata, freq_norm);
-       }
-       hardpps_update_phase(pts_norm.nsec);
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-make-tick_usec-static.patch b/queue-6.6/ntp-make-tick_usec-static.patch
deleted file mode 100644 (file)
index 6611eec..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-From ed880bbf9b143c63503fc3517068434dee9d390f Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:38 +0200
-Subject: ntp: Make tick_usec static
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 66606a93849bfe3cbe9f0b801b40f60b87c54e11 ]
-
-There are no users of tick_usec outside of the NTP core code. Therefore
-make tick_usec static.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-2-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/timex.h | 7 -------
- kernel/time/ntp.c     | 5 ++++-
- 2 files changed, 4 insertions(+), 8 deletions(-)
-
-diff --git a/include/linux/timex.h b/include/linux/timex.h
-index 7f7a12fd8200c..4ee32eff3f221 100644
---- a/include/linux/timex.h
-+++ b/include/linux/timex.h
-@@ -139,13 +139,6 @@ unsigned long random_get_entropy_fallback(void);
- #define MAXSEC 2048           /* max interval between updates (s) */
- #define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
--/*
-- * kernel variables
-- * Note: maximum error = NTP sync distance = dispersion + delay / 2;
-- * estimated error = NTP dispersion.
-- */
--extern unsigned long tick_usec;               /* USER_HZ period (usec) */
--
- /* Required to safely shift negative values */
- #define shift_right(x, s) ({  \
-       __typeof__(x) __x = (x);        \
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 0dba1179d81d2..8e68a85996f7d 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -31,7 +31,7 @@
- /* USER_HZ period (usecs): */
--unsigned long                 tick_usec = USER_TICK_USEC;
-+static unsigned long          tick_usec = USER_TICK_USEC;
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -44,6 +44,9 @@ static u64                   tick_length_base;
- /*
-  * phase-lock loop variables
-+ *
-+ * Note: maximum error = NTP sync distance = dispersion + delay / 2;
-+ * estimated error = NTP dispersion.
-  */
- /*
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-move-tick_length-into-ntp_data.patch b/queue-6.6/ntp-move-tick_length-into-ntp_data.patch
deleted file mode 100644 (file)
index 1f0d3ac..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-From 57c1e66e29a0a5d9499dfab702f04b00251e7e6f Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:44 +0200
-Subject: ntp: Move tick_length* into ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit ec93ec22aa10fb5311c0f068ee66c5b6d39788fe ]
-
-Continue the conversion from static variables to struct based data.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-8-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 34 ++++++++++++++++++----------------
- 1 file changed, 18 insertions(+), 16 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 0222f8e460810..6c5f684328c82 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -25,20 +25,21 @@
- /**
-  * struct ntp_data - Structure holding all NTP related state
-  * @tick_usec:                USER_HZ period in microseconds
-+ * @tick_length:      Adjusted tick length
-+ * @tick_length_base: Base value for @tick_length
-  *
-  * Protected by the timekeeping locks.
-  */
- struct ntp_data {
-       unsigned long           tick_usec;
-+      u64                     tick_length;
-+      u64                     tick_length_base;
- };
- static struct ntp_data tk_ntp_data = {
-       .tick_usec              = USER_TICK_USEC,
- };
--static u64                    tick_length;
--static u64                    tick_length_base;
--
- #define SECS_PER_DAY          86400
- #define MAX_TICKADJ           500LL           /* usecs */
- #define MAX_TICKADJ_SCALED \
-@@ -263,8 +264,8 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
-        * Don't wait for the next second_overflow, apply the change to the
-        * tick length immediately:
-        */
--      tick_length             += new_base - tick_length_base;
--      tick_length_base         = new_base;
-+      ntpdata->tick_length            += new_base - ntpdata->tick_length_base;
-+      ntpdata->tick_length_base        = new_base;
- }
- static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
-@@ -341,8 +342,8 @@ static void __ntp_clear(struct ntp_data *ntpdata)
-       ntp_update_frequency(ntpdata);
--      tick_length     = tick_length_base;
--      time_offset     = 0;
-+      ntpdata->tick_length    = ntpdata->tick_length_base;
-+      time_offset             = 0;
-       ntp_next_leap_sec = TIME64_MAX;
-       /* Clear PPS state variables */
-@@ -360,7 +361,7 @@ void ntp_clear(void)
- u64 ntp_tick_length(void)
- {
--      return tick_length;
-+      return tk_ntp_data.tick_length;
- }
- /**
-@@ -391,6 +392,7 @@ ktime_t ntp_get_next_leap(void)
-  */
- int second_overflow(time64_t secs)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       s64 delta;
-       int leap = 0;
-       s32 rem;
-@@ -451,11 +453,11 @@ int second_overflow(time64_t secs)
-       }
-       /* Compute the phase adjustment for the next second */
--      tick_length      = tick_length_base;
-+      ntpdata->tick_length     = ntpdata->tick_length_base;
--      delta            = ntp_offset_chunk(time_offset);
--      time_offset     -= delta;
--      tick_length     += delta;
-+      delta                    = ntp_offset_chunk(time_offset);
-+      time_offset             -= delta;
-+      ntpdata->tick_length    += delta;
-       /* Check PPS signal */
-       pps_dec_valid();
-@@ -465,18 +467,18 @@ int second_overflow(time64_t secs)
-       if (time_adjust > MAX_TICKADJ) {
-               time_adjust -= MAX_TICKADJ;
--              tick_length += MAX_TICKADJ_SCALED;
-+              ntpdata->tick_length += MAX_TICKADJ_SCALED;
-               goto out;
-       }
-       if (time_adjust < -MAX_TICKADJ) {
-               time_adjust += MAX_TICKADJ;
--              tick_length -= MAX_TICKADJ_SCALED;
-+              ntpdata->tick_length -= MAX_TICKADJ_SCALED;
-               goto out;
-       }
--      tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
--                                                       << NTP_SCALE_SHIFT;
-+      ntpdata->tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
-+                              << NTP_SCALE_SHIFT;
-       time_adjust = 0;
- out:
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-move-tick_stat-into-ntp_data.patch b/queue-6.6/ntp-move-tick_stat-into-ntp_data.patch
deleted file mode 100644 (file)
index b09d17e..0000000
+++ /dev/null
@@ -1,539 +0,0 @@
-From 69572175a7bf6c25a1cb294df994464fe1fd3467 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:45 +0200
-Subject: ntp: Move tick_stat* into ntp_data
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit bee18a2301f97465a464176767f3a3a64f900d93 ]
-
-Continue the conversion from static variables to struct based data.
-
-No functional change.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-9-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 175 ++++++++++++++++++++++------------------------
- 1 file changed, 85 insertions(+), 90 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 6c5f684328c82..6d87f9889b039 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -27,6 +27,8 @@
-  * @tick_usec:                USER_HZ period in microseconds
-  * @tick_length:      Adjusted tick length
-  * @tick_length_base: Base value for @tick_length
-+ * @time_state:               State of the clock synchronization
-+ * @time_status:      Clock status bits
-  *
-  * Protected by the timekeeping locks.
-  */
-@@ -34,10 +36,14 @@ struct ntp_data {
-       unsigned long           tick_usec;
-       u64                     tick_length;
-       u64                     tick_length_base;
-+      int                     time_state;
-+      int                     time_status;
- };
- static struct ntp_data tk_ntp_data = {
-       .tick_usec              = USER_TICK_USEC,
-+      .time_state             = TIME_OK,
-+      .time_status            = STA_UNSYNC,
- };
- #define SECS_PER_DAY          86400
-@@ -53,16 +59,6 @@ static struct ntp_data tk_ntp_data = {
-  * estimated error = NTP dispersion.
-  */
--/*
-- * clock synchronization status
-- *
-- * (TIME_ERROR prevents overwriting the CMOS clock)
-- */
--static int                    time_state = TIME_OK;
--
--/* clock status bits:                                                 */
--static int                    time_status = STA_UNSYNC;
--
- /* time adjustment (nsecs):                                           */
- static s64                    time_offset;
-@@ -127,9 +123,9 @@ static long pps_errcnt;            /* calibration errors */
-  * PPS kernel consumer compensates the whole phase error immediately.
-  * Otherwise, reduce the offset by a fixed factor times the time constant.
-  */
--static inline s64 ntp_offset_chunk(s64 offset)
-+static inline s64 ntp_offset_chunk(struct ntp_data *ntpdata, s64 offset)
- {
--      if (time_status & STA_PPSTIME && time_status & STA_PPSSIGNAL)
-+      if (ntpdata->time_status & STA_PPSTIME && ntpdata->time_status & STA_PPSSIGNAL)
-               return offset;
-       else
-               return shift_right(offset, SHIFT_PLL + time_constant);
-@@ -159,13 +155,13 @@ static inline void pps_clear(void)
-  * Decrease pps_valid to indicate that another second has passed since the
-  * last PPS signal. When it reaches 0, indicate that PPS signal is missing.
-  */
--static inline void pps_dec_valid(void)
-+static inline void pps_dec_valid(struct ntp_data *ntpdata)
- {
-       if (pps_valid > 0)
-               pps_valid--;
-       else {
--              time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
--                               STA_PPSWANDER | STA_PPSERROR);
-+              ntpdata->time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
-+                                        STA_PPSWANDER | STA_PPSERROR);
-               pps_clear();
-       }
- }
-@@ -198,12 +194,12 @@ static inline bool is_error_status(int status)
-                       && (status & (STA_PPSWANDER|STA_PPSERROR)));
- }
--static inline void pps_fill_timex(struct __kernel_timex *txc)
-+static inline void pps_fill_timex(struct ntp_data *ntpdata, struct __kernel_timex *txc)
- {
-       txc->ppsfreq       = shift_right((pps_freq >> PPM_SCALE_INV_SHIFT) *
-                                        PPM_SCALE_INV, NTP_SCALE_SHIFT);
-       txc->jitter        = pps_jitter;
--      if (!(time_status & STA_NANO))
-+      if (!(ntpdata->time_status & STA_NANO))
-               txc->jitter = pps_jitter / NSEC_PER_USEC;
-       txc->shift         = pps_shift;
-       txc->stabil        = pps_stabil;
-@@ -215,14 +211,14 @@ static inline void pps_fill_timex(struct __kernel_timex *txc)
- #else /* !CONFIG_NTP_PPS */
--static inline s64 ntp_offset_chunk(s64 offset)
-+static inline s64 ntp_offset_chunk(struct ntp_data *ntp, s64 offset)
- {
-       return shift_right(offset, SHIFT_PLL + time_constant);
- }
- static inline void pps_reset_freq_interval(void) {}
- static inline void pps_clear(void) {}
--static inline void pps_dec_valid(void) {}
-+static inline void pps_dec_valid(struct ntp_data *ntpdata) {}
- static inline void pps_set_freq(s64 freq) {}
- static inline bool is_error_status(int status)
-@@ -230,7 +226,7 @@ static inline bool is_error_status(int status)
-       return status & (STA_UNSYNC|STA_CLOCKERR);
- }
--static inline void pps_fill_timex(struct __kernel_timex *txc)
-+static inline void pps_fill_timex(struct ntp_data *ntpdata, struct __kernel_timex *txc)
- {
-       /* PPS is not implemented, so these are zero */
-       txc->ppsfreq       = 0;
-@@ -268,30 +264,30 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
-       ntpdata->tick_length_base        = new_base;
- }
--static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
-+static inline s64 ntp_update_offset_fll(struct ntp_data *ntpdata, s64 offset64, long secs)
- {
--      time_status &= ~STA_MODE;
-+      ntpdata->time_status &= ~STA_MODE;
-       if (secs < MINSEC)
-               return 0;
--      if (!(time_status & STA_FLL) && (secs <= MAXSEC))
-+      if (!(ntpdata->time_status & STA_FLL) && (secs <= MAXSEC))
-               return 0;
--      time_status |= STA_MODE;
-+      ntpdata->time_status |= STA_MODE;
-       return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
- }
--static void ntp_update_offset(long offset)
-+static void ntp_update_offset(struct ntp_data *ntpdata, long offset)
- {
-       s64 freq_adj, offset64;
-       long secs, real_secs;
--      if (!(time_status & STA_PLL))
-+      if (!(ntpdata->time_status & STA_PLL))
-               return;
--      if (!(time_status & STA_NANO)) {
-+      if (!(ntpdata->time_status & STA_NANO)) {
-               /* Make sure the multiplication below won't overflow */
-               offset = clamp(offset, -USEC_PER_SEC, USEC_PER_SEC);
-               offset *= NSEC_PER_USEC;
-@@ -306,13 +302,13 @@ static void ntp_update_offset(long offset)
-        */
-       real_secs = __ktime_get_real_seconds();
-       secs = (long)(real_secs - time_reftime);
--      if (unlikely(time_status & STA_FREQHOLD))
-+      if (unlikely(ntpdata->time_status & STA_FREQHOLD))
-               secs = 0;
-       time_reftime = real_secs;
-       offset64    = offset;
--      freq_adj    = ntp_update_offset_fll(offset64, secs);
-+      freq_adj    = ntp_update_offset_fll(ntpdata, offset64, secs);
-       /*
-        * Clamp update interval to reduce PLL gain with low
-@@ -335,10 +331,10 @@ static void ntp_update_offset(long offset)
- static void __ntp_clear(struct ntp_data *ntpdata)
- {
-       /* Stop active adjtime() */
--      time_adjust     = 0;
--      time_status     |= STA_UNSYNC;
--      time_maxerror   = NTP_PHASE_LIMIT;
--      time_esterror   = NTP_PHASE_LIMIT;
-+      time_adjust             = 0;
-+      ntpdata->time_status    |= STA_UNSYNC;
-+      time_maxerror           = NTP_PHASE_LIMIT;
-+      time_esterror           = NTP_PHASE_LIMIT;
-       ntp_update_frequency(ntpdata);
-@@ -372,9 +368,10 @@ u64 ntp_tick_length(void)
-  */
- ktime_t ntp_get_next_leap(void)
- {
-+      struct ntp_data *ntpdata = &tk_ntp_data;
-       ktime_t ret;
--      if ((time_state == TIME_INS) && (time_status & STA_INS))
-+      if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS))
-               return ktime_set(ntp_next_leap_sec, 0);
-       ret = KTIME_MAX;
-       return ret;
-@@ -402,46 +399,46 @@ int second_overflow(time64_t secs)
-        * day, the system clock is set back one second; if in leap-delete
-        * state, the system clock is set ahead one second.
-        */
--      switch (time_state) {
-+      switch (ntpdata->time_state) {
-       case TIME_OK:
--              if (time_status & STA_INS) {
--                      time_state = TIME_INS;
-+              if (ntpdata->time_status & STA_INS) {
-+                      ntpdata->time_state = TIME_INS;
-                       div_s64_rem(secs, SECS_PER_DAY, &rem);
-                       ntp_next_leap_sec = secs + SECS_PER_DAY - rem;
--              } else if (time_status & STA_DEL) {
--                      time_state = TIME_DEL;
-+              } else if (ntpdata->time_status & STA_DEL) {
-+                      ntpdata->time_state = TIME_DEL;
-                       div_s64_rem(secs + 1, SECS_PER_DAY, &rem);
-                       ntp_next_leap_sec = secs + SECS_PER_DAY - rem;
-               }
-               break;
-       case TIME_INS:
--              if (!(time_status & STA_INS)) {
-+              if (!(ntpdata->time_status & STA_INS)) {
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_OK;
-+                      ntpdata->time_state = TIME_OK;
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = -1;
--                      time_state = TIME_OOP;
-+                      ntpdata->time_state = TIME_OOP;
-                       pr_notice("Clock: inserting leap second 23:59:60 UTC\n");
-               }
-               break;
-       case TIME_DEL:
--              if (!(time_status & STA_DEL)) {
-+              if (!(ntpdata->time_status & STA_DEL)) {
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_OK;
-+                      ntpdata->time_state = TIME_OK;
-               } else if (secs == ntp_next_leap_sec) {
-                       leap = 1;
-                       ntp_next_leap_sec = TIME64_MAX;
--                      time_state = TIME_WAIT;
-+                      ntpdata->time_state = TIME_WAIT;
-                       pr_notice("Clock: deleting leap second 23:59:59 UTC\n");
-               }
-               break;
-       case TIME_OOP:
-               ntp_next_leap_sec = TIME64_MAX;
--              time_state = TIME_WAIT;
-+              ntpdata->time_state = TIME_WAIT;
-               break;
-       case TIME_WAIT:
--              if (!(time_status & (STA_INS | STA_DEL)))
--                      time_state = TIME_OK;
-+              if (!(ntpdata->time_status & (STA_INS | STA_DEL)))
-+                      ntpdata->time_state = TIME_OK;
-               break;
-       }
-@@ -449,18 +446,18 @@ int second_overflow(time64_t secs)
-       time_maxerror += MAXFREQ / NSEC_PER_USEC;
-       if (time_maxerror > NTP_PHASE_LIMIT) {
-               time_maxerror = NTP_PHASE_LIMIT;
--              time_status |= STA_UNSYNC;
-+              ntpdata->time_status |= STA_UNSYNC;
-       }
-       /* Compute the phase adjustment for the next second */
-       ntpdata->tick_length     = ntpdata->tick_length_base;
--      delta                    = ntp_offset_chunk(time_offset);
-+      delta                    = ntp_offset_chunk(ntpdata, time_offset);
-       time_offset             -= delta;
-       ntpdata->tick_length    += delta;
-       /* Check PPS signal */
--      pps_dec_valid();
-+      pps_dec_valid(ntpdata);
-       if (!time_adjust)
-               goto out;
-@@ -608,7 +605,7 @@ static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_ns
-  */
- static inline bool ntp_synced(void)
- {
--      return !(time_status & STA_UNSYNC);
-+      return !(tk_ntp_data.time_status & STA_UNSYNC);
- }
- /*
-@@ -683,11 +680,11 @@ static inline void __init ntp_init_cmos_sync(void) { }
- /*
-  * Propagate a new txc->status value into the NTP state:
-  */
--static inline void process_adj_status(const struct __kernel_timex *txc)
-+static inline void process_adj_status(struct ntp_data *ntpdata, const struct __kernel_timex *txc)
- {
--      if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) {
--              time_state = TIME_OK;
--              time_status = STA_UNSYNC;
-+      if ((ntpdata->time_status & STA_PLL) && !(txc->status & STA_PLL)) {
-+              ntpdata->time_state = TIME_OK;
-+              ntpdata->time_status = STA_UNSYNC;
-               ntp_next_leap_sec = TIME64_MAX;
-               /* Restart PPS frequency calibration */
-               pps_reset_freq_interval();
-@@ -697,26 +694,25 @@ static inline void process_adj_status(const struct __kernel_timex *txc)
-        * If we turn on PLL adjustments then reset the
-        * reference time to current time.
-        */
--      if (!(time_status & STA_PLL) && (txc->status & STA_PLL))
-+      if (!(ntpdata->time_status & STA_PLL) && (txc->status & STA_PLL))
-               time_reftime = __ktime_get_real_seconds();
--      /* Only set allowed bits */
--      time_status &= STA_RONLY;
--      time_status |= txc->status & ~STA_RONLY;
-+      /* only set allowed bits */
-+      ntpdata->time_status &= STA_RONLY;
-+      ntpdata->time_status |= txc->status & ~STA_RONLY;
- }
--
- static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct __kernel_timex *txc,
-                                         s32 *time_tai)
- {
-       if (txc->modes & ADJ_STATUS)
--              process_adj_status(txc);
-+              process_adj_status(ntpdata, txc);
-       if (txc->modes & ADJ_NANO)
--              time_status |= STA_NANO;
-+              ntpdata->time_status |= STA_NANO;
-       if (txc->modes & ADJ_MICRO)
--              time_status &= ~STA_NANO;
-+              ntpdata->time_status &= ~STA_NANO;
-       if (txc->modes & ADJ_FREQUENCY) {
-               time_freq = txc->freq * PPM_SCALE;
-@@ -734,17 +730,16 @@ static inline void process_adjtimex_modes(struct ntp_data *ntpdata, const struct
-       if (txc->modes & ADJ_TIMECONST) {
-               time_constant = clamp(txc->constant, 0, MAXTC);
--              if (!(time_status & STA_NANO))
-+              if (!(ntpdata->time_status & STA_NANO))
-                       time_constant += 4;
-               time_constant = clamp(time_constant, 0, MAXTC);
-       }
--      if (txc->modes & ADJ_TAI &&
--                      txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
-+      if (txc->modes & ADJ_TAI && txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
-               *time_tai = txc->constant;
-       if (txc->modes & ADJ_OFFSET)
--              ntp_update_offset(txc->offset);
-+              ntp_update_offset(ntpdata, txc->offset);
-       if (txc->modes & ADJ_TICK)
-               ntpdata->tick_usec = txc->tick;
-@@ -780,7 +775,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-               if (txc->modes) {
-                       audit_ntp_set_old(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_old(ad, AUDIT_NTP_FREQ,   time_freq);
--                      audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status);
-+                      audit_ntp_set_old(ad, AUDIT_NTP_STATUS, ntpdata->time_status);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TAI,    *time_tai);
-                       audit_ntp_set_old(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-@@ -788,26 +783,26 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-                       audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset);
-                       audit_ntp_set_new(ad, AUDIT_NTP_FREQ,   time_freq);
--                      audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status);
-+                      audit_ntp_set_new(ad, AUDIT_NTP_STATUS, ntpdata->time_status);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TAI,    *time_tai);
-                       audit_ntp_set_new(ad, AUDIT_NTP_TICK,   ntpdata->tick_usec);
-               }
-               txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
-                                 NTP_SCALE_SHIFT);
--              if (!(time_status & STA_NANO))
-+              if (!(ntpdata->time_status & STA_NANO))
-                       txc->offset = (u32)txc->offset / NSEC_PER_USEC;
-       }
--      result = time_state;
--      if (is_error_status(time_status))
-+      result = ntpdata->time_state;
-+      if (is_error_status(ntpdata->time_status))
-               result = TIME_ERROR;
-       txc->freq          = shift_right((time_freq >> PPM_SCALE_INV_SHIFT) *
-                                        PPM_SCALE_INV, NTP_SCALE_SHIFT);
-       txc->maxerror      = time_maxerror;
-       txc->esterror      = time_esterror;
--      txc->status        = time_status;
-+      txc->status        = ntpdata->time_status;
-       txc->constant      = time_constant;
-       txc->precision     = 1;
-       txc->tolerance     = MAXFREQ_SCALED / PPM_SCALE;
-@@ -815,26 +810,26 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
-       txc->tai           = *time_tai;
-       /* Fill PPS status fields */
--      pps_fill_timex(txc);
-+      pps_fill_timex(ntpdata, txc);
-       txc->time.tv_sec = ts->tv_sec;
-       txc->time.tv_usec = ts->tv_nsec;
--      if (!(time_status & STA_NANO))
-+      if (!(ntpdata->time_status & STA_NANO))
-               txc->time.tv_usec = ts->tv_nsec / NSEC_PER_USEC;
-       /* Handle leapsec adjustments */
-       if (unlikely(ts->tv_sec >= ntp_next_leap_sec)) {
--              if ((time_state == TIME_INS) && (time_status & STA_INS)) {
-+              if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS)) {
-                       result = TIME_OOP;
-                       txc->tai++;
-                       txc->time.tv_sec--;
-               }
--              if ((time_state == TIME_DEL) && (time_status & STA_DEL)) {
-+              if ((ntpdata->time_state == TIME_DEL) && (ntpdata->time_status & STA_DEL)) {
-                       result = TIME_WAIT;
-                       txc->tai--;
-                       txc->time.tv_sec++;
-               }
--              if ((time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-+              if ((ntpdata->time_state == TIME_OOP) && (ts->tv_sec == ntp_next_leap_sec))
-                       result = TIME_WAIT;
-       }
-@@ -939,7 +934,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-       /* Check if the frequency interval was too long */
-       if (freq_norm.sec > (2 << pps_shift)) {
--              time_status |= STA_PPSERROR;
-+              ntpdata->time_status |= STA_PPSERROR;
-               pps_errcnt++;
-               pps_dec_freq_interval();
-               printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n",
-@@ -958,7 +953,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-       pps_freq = ftemp;
-       if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
-               printk_deferred(KERN_WARNING "hardpps: PPSWANDER: change=%ld\n", delta);
--              time_status |= STA_PPSWANDER;
-+              ntpdata->time_status |= STA_PPSWANDER;
-               pps_stbcnt++;
-               pps_dec_freq_interval();
-       } else {
-@@ -977,7 +972,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
-                              NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
-       /* If enabled, the system clock frequency is updated */
--      if ((time_status & STA_PPSFREQ) && !(time_status & STA_FREQHOLD)) {
-+      if ((ntpdata->time_status & STA_PPSFREQ) && !(ntpdata->time_status & STA_FREQHOLD)) {
-               time_freq = pps_freq;
-               ntp_update_frequency(ntpdata);
-       }
-@@ -986,7 +981,7 @@ static long hardpps_update_freq(struct ntp_data *ntpdata, struct pps_normtime fr
- }
- /* Correct REALTIME clock phase error against PPS signal */
--static void hardpps_update_phase(long error)
-+static void hardpps_update_phase(struct ntp_data *ntpdata, long error)
- {
-       long correction = -error;
-       long jitter;
-@@ -1003,9 +998,9 @@ static void hardpps_update_phase(long error)
-       if (jitter > (pps_jitter << PPS_POPCORN)) {
-               printk_deferred(KERN_WARNING "hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
-                               jitter, (pps_jitter << PPS_POPCORN));
--              time_status |= STA_PPSJITTER;
-+              ntpdata->time_status |= STA_PPSJITTER;
-               pps_jitcnt++;
--      } else if (time_status & STA_PPSTIME) {
-+      } else if (ntpdata->time_status & STA_PPSTIME) {
-               /* Correct the time using the phase offset */
-               time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ);
-               /* Cancel running adjtime() */
-@@ -1035,10 +1030,10 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-       pts_norm = pps_normalize_ts(*phase_ts);
-       /* Clear the error bits, they will be set again if needed */
--      time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
-+      ntpdata->time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR);
--      /* Indicate signal presence */
--      time_status |= STA_PPSSIGNAL;
-+      /* indicate signal presence */
-+      ntpdata->time_status |= STA_PPSSIGNAL;
-       pps_valid = PPS_VALID;
-       /*
-@@ -1059,7 +1054,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-        */
-       if ((freq_norm.sec == 0) || (freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-           (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
--              time_status |= STA_PPSJITTER;
-+              ntpdata->time_status |= STA_PPSJITTER;
-               /* Restart the frequency calibration interval */
-               pps_fbase = *raw_ts;
-               printk_deferred(KERN_ERR "hardpps: PPSJITTER: bad pulse\n");
-@@ -1074,7 +1069,7 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
-               hardpps_update_freq(ntpdata, freq_norm);
-       }
--      hardpps_update_phase(pts_norm.nsec);
-+      hardpps_update_phase(ntpdata, pts_norm.nsec);
- }
- #endif        /* CONFIG_NTP_PPS */
--- 
-2.43.0
-
diff --git a/queue-6.6/ntp-read-reference-time-only-once.patch b/queue-6.6/ntp-read-reference-time-only-once.patch
deleted file mode 100644 (file)
index 40c2214..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-From 8e4573a49f37687504fff95d8733b62bdcf3afb0 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:42 +0200
-Subject: ntp: Read reference time only once
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 136bccbc2e78d3cd0bd8831e4c5a4509c0ddd945 ]
-
-The reference time is required twice in ntp_update_offset(). It will not
-change in the meantime as the calling code holds the timekeeper lock. Read
-it only once and store it into a local variable.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-6-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- kernel/time/ntp.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index ef758aafdfd54..477cb08062bc5 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -283,9 +283,8 @@ static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
- static void ntp_update_offset(long offset)
- {
--      s64 freq_adj;
--      s64 offset64;
--      long secs;
-+      s64 freq_adj, offset64;
-+      long secs, real_secs;
-       if (!(time_status & STA_PLL))
-               return;
-@@ -303,11 +302,12 @@ static void ntp_update_offset(long offset)
-        * Select how the frequency is to be controlled
-        * and in which mode (PLL or FLL).
-        */
--      secs = (long)(__ktime_get_real_seconds() - time_reftime);
-+      real_secs = __ktime_get_real_seconds();
-+      secs = (long)(real_secs - time_reftime);
-       if (unlikely(time_status & STA_FREQHOLD))
-               secs = 0;
--      time_reftime = __ktime_get_real_seconds();
-+      time_reftime = real_secs;
-       offset64    = offset;
-       freq_adj    = ntp_update_offset_fll(offset64, secs);
--- 
-2.43.0
-
index b586571aee2570ba17d040df8519a5b4055348f2..2a812004f1ed98f4dad12502d5a3e72470576b72 100644 (file)
@@ -1,11 +1,11 @@
-From 48de567858d5dc7108ccecf728b033cf598093e5 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
+From f5807b0606da7ac7c1b74a386b22134ec7702d05 Mon Sep 17 00:00:00 2001
+From: Marcelo Dalmas <marcelo.dalmas@ge.com>
 Date: Mon, 25 Nov 2024 12:16:09 +0000
 Subject: ntp: Remove invalid cast in time offset math
 
 From: Marcelo Dalmas <marcelo.dalmas@ge.com>
 
-[ Upstream commit f5807b0606da7ac7c1b74a386b22134ec7702d05 ]
+commit f5807b0606da7ac7c1b74a386b22134ec7702d05 upstream.
 
 Due to an unsigned cast, adjtimex() returns the wrong offest when using
 ADJ_MICRO and the offset is negative. In this case a small negative offset
@@ -29,24 +29,19 @@ Signed-off-by: Marcelo Dalmas <marcelo.dalmas@ge.com>
 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
 Cc: stable@vger.kernel.org
 Link: https://lore.kernel.org/all/SJ0P101MB03687BF7D5A10FD3C49C51E5F42E2@SJ0P101MB0368.NAMP101.PROD.OUTLOOK.COM
-Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 ---
- kernel/time/ntp.c | 2 +-
+ kernel/time/ntp.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 6d87f9889b039..d1b7a3909de1d 100644
 --- a/kernel/time/ntp.c
 +++ b/kernel/time/ntp.c
-@@ -791,7 +791,7 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,
+@@ -796,7 +796,7 @@ int __do_adjtimex(struct __kernel_timex
                txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ,
                                  NTP_SCALE_SHIFT);
-               if (!(ntpdata->time_status & STA_NANO))
+               if (!(time_status & STA_NANO))
 -                      txc->offset = (u32)txc->offset / NSEC_PER_USEC;
 +                      txc->offset = div_s64(txc->offset, NSEC_PER_USEC);
        }
  
-       result = ntpdata->time_state;
--- 
-2.43.0
-
+       result = time_state;    /* mostly `TIME_OK' */
diff --git a/queue-6.6/ntp-remove-unused-tick_nsec.patch b/queue-6.6/ntp-remove-unused-tick_nsec.patch
deleted file mode 100644 (file)
index 80dab7e..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-From 06eb310a927bf861dd76379723b48d54b71b933a Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Sep 2024 15:17:37 +0200
-Subject: ntp: Remove unused tick_nsec
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit a849a0273d0f73a252d14d31c5003a8059ea51fc ]
-
-tick_nsec is only updated in the NTP core, but there are no users.
-
-Remove it.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Acked-by: John Stultz <jstultz@google.com>
-Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-1-2d52f4e13476@linutronix.de
-Stable-dep-of: f5807b0606da ("ntp: Remove invalid cast in time offset math")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/include/asm/timer.h | 2 --
- include/linux/timex.h        | 1 -
- kernel/time/ntp.c            | 8 ++------
- 3 files changed, 2 insertions(+), 9 deletions(-)
-
-diff --git a/arch/x86/include/asm/timer.h b/arch/x86/include/asm/timer.h
-index 7365dd4acffb6..23baf8c9b34ca 100644
---- a/arch/x86/include/asm/timer.h
-+++ b/arch/x86/include/asm/timer.h
-@@ -6,8 +6,6 @@
- #include <linux/interrupt.h>
- #include <linux/math64.h>
--#define TICK_SIZE (tick_nsec / 1000)
--
- unsigned long long native_sched_clock(void);
- extern void recalibrate_cpu_khz(void);
-diff --git a/include/linux/timex.h b/include/linux/timex.h
-index 3871b06bd302c..7f7a12fd8200c 100644
---- a/include/linux/timex.h
-+++ b/include/linux/timex.h
-@@ -145,7 +145,6 @@ unsigned long random_get_entropy_fallback(void);
-  * estimated error = NTP dispersion.
-  */
- extern unsigned long tick_usec;               /* USER_HZ period (usec) */
--extern unsigned long tick_nsec;               /* SHIFTED_HZ period (nsec) */
- /* Required to safely shift negative values */
- #define shift_right(x, s) ({  \
-diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
-index 8d2dd214ec682..0dba1179d81d2 100644
---- a/kernel/time/ntp.c
-+++ b/kernel/time/ntp.c
-@@ -33,9 +33,6 @@
- /* USER_HZ period (usecs): */
- unsigned long                 tick_usec = USER_TICK_USEC;
--/* SHIFTED_HZ period (nsecs): */
--unsigned long                 tick_nsec;
--
- static u64                    tick_length;
- static u64                    tick_length_base;
-@@ -253,8 +250,8 @@ static inline int ntp_synced(void)
-  */
- /*
-- * Update (tick_length, tick_length_base, tick_nsec), based
-- * on (tick_usec, ntp_tick_adj, time_freq):
-+ * Update tick_length and tick_length_base, based on tick_usec, ntp_tick_adj and
-+ * time_freq:
-  */
- static void ntp_update_frequency(void)
- {
-@@ -267,7 +264,6 @@ static void ntp_update_frequency(void)
-       second_length           += ntp_tick_adj;
-       second_length           += time_freq;
--      tick_nsec                = div_u64(second_length, HZ) >> NTP_SCALE_SHIFT;
-       new_base                 = div_u64(second_length, NTP_INTERVAL_FREQ);
-       /*
--- 
-2.43.0
-
index e496765f20483daecdbcee97432a0566dab8621e..362887328a56006d9a6676b37e0ad95cb2924d58 100644 (file)
@@ -90,15 +90,6 @@ zram-clear-idle-flag-in-mark_idle.patch
 iommu-arm-smmu-defer-probe-of-clients-after-smmu-device-bound.patch
 powerpc-vdso-refactor-cflags-for-cvdso-build.patch
 powerpc-vdso-drop-mstack-protector-guard-flags-in-32.patch
-ntp-remove-unused-tick_nsec.patch
-ntp-make-tick_usec-static.patch
-ntp-clean-up-comments.patch
-ntp-cleanup-formatting-of-code.patch
-ntp-convert-functions-with-only-two-states-to-bool.patch
-ntp-read-reference-time-only-once.patch
-ntp-introduce-struct-ntp_data.patch
-ntp-move-tick_length-into-ntp_data.patch
-ntp-move-tick_stat-into-ntp_data.patch
 ntp-remove-invalid-cast-in-time-offset-math.patch
 driver-core-fw_devlink-improve-logs-for-cycle-detect.patch
 driver-core-add-fwlink_flag_ignore-to-completely-ign.patch