From: Andrey Drobyshev <immortalguardian1@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: gq@cs.msu.su, giometti@enneenne.com
Subject: [PATCH 3/8] hardpps: fix some pps_jitter issues.
Date: Wed, 15 Feb 2017 17:31:04 +0300 [thread overview]
Message-ID: <1487169069-15721-4-git-send-email-immortalguardian1@gmail.com> (raw)
In-Reply-To: <1487169069-15721-1-git-send-email-immortalguardian1@gmail.com>
Handle possible overflow, implementation-defined result of signed right shift
and replace unsuitable constant.
Signed-off-by: Andrey Drobyshev <immortalguardian1@gmail.com>
Signed-off-by: Alexander GQ Gerasiov <gq@cs.msu.su>
---
kernel/time/ntp.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 22f2235..9cef1b9 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -91,6 +91,7 @@ static time64_t ntp_next_leap_sec = TIME64_MAX;
*/
#define PPS_VALID 10 /* PPS signal watchdog max (s) */
#define PPS_POPCORN 4 /* popcorn spike threshold (shift) */
+#define PPS_JITUPD 2 /* pps_jitter update factor (shift) */
#define PPS_INTMIN 2 /* min freq interval (s) (shift) */
#define PPS_INTMAX 8 /* max freq interval (s) (shift) */
#define PPS_INTCOUNT 4 /* number of consecutive good intervals to
@@ -941,7 +942,7 @@ static void hardpps_update_phase(long error)
* threshold, the sample is discarded; otherwise, if so enabled,
* the time offset is updated.
*/
- if (jitter > (pps_jitter << PPS_POPCORN)) {
+ if (pps_jitter && (jitter > ((long long)pps_jitter << PPS_POPCORN))) {
printk_deferred(KERN_WARNING
"hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
jitter, (pps_jitter << PPS_POPCORN));
@@ -955,7 +956,7 @@ static void hardpps_update_phase(long error)
time_adjust = 0;
}
/* update jitter */
- pps_jitter += (jitter - pps_jitter) >> PPS_INTMIN;
+ pps_jitter += shift_right(jitter - pps_jitter, PPS_JITUPD);
}
/*
--
2.1.4
next prev parent reply other threads:[~2017-02-15 14:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 14:31 [PATCH 0/8] LinuxPPS: some minor fixes and improvements Andrey Drobyshev
2017-02-15 14:31 ` [PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro Andrey Drobyshev
2017-03-04 7:36 ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 2/8] ntp/pps: ignore pps_valid decreasing if there is no pps signal Andrey Drobyshev
2017-03-04 7:36 ` Rodolfo Giometti
2017-02-15 14:31 ` Andrey Drobyshev [this message]
2017-03-04 7:37 ` [PATCH 3/8] hardpps: fix some pps_jitter issues Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 4/8] LinuxPPS: kapi: Unlock before waking up events queue in pps_event() Andrey Drobyshev
2017-03-04 7:38 ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 5/8] LinuxPPS: pps_parport: Do not generate assert in case of lost signal Andrey Drobyshev
2017-03-04 7:39 ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 6/8] LinuxPPS: pps_parport: Ignore interrupt invoked less than 0.5sec after previous Andrey Drobyshev
2017-03-04 7:40 ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 7/8] LinuxPPS: pps_gen_parport: Add polarity parameter for inverted signal Andrey Drobyshev
2017-03-04 7:42 ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 8/8] LinuxPPS: pps_gen_parport: Add check for bad clocksource Andrey Drobyshev
2017-03-04 7:44 ` Rodolfo Giometti
2017-03-04 9:19 ` Alexander Gerasiov
2017-03-04 13:25 ` Rodolfo Giometti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1487169069-15721-4-git-send-email-immortalguardian1@gmail.com \
--to=immortalguardian1@gmail.com \
--cc=giometti@enneenne.com \
--cc=gq@cs.msu.su \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®