From patchwork Mon Mar 25 20:08:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15629 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 76D9623E66 for ; Mon, 25 Mar 2013 20:08:32 +0000 (UTC) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by fiordland.canonical.com (Postfix) with ESMTP id 1C109A19564 for ; Mon, 25 Mar 2013 20:08:32 +0000 (UTC) Received: by mail-vc0-f175.google.com with SMTP id hf12so4975228vcb.20 for ; Mon, 25 Mar 2013 13:08:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=5H6/4xU80YtoXUJbbivxphay5+Rqr7xJPMlqzTNU+M8=; b=XTp/8kJuPBEJ8uleSSQq1F3anDA0GywzW8N4jxdde6W19IzV60TfVeoUfibeBmO8DY ru8MlRLuvPMqNMKbqB0452sCdFWsRUSb246rGADdc7NczWIp4XzgHAoDW+tSb+jIx9gp TtYsl+8mk9npxbgoNoP1dVmhsnqMhUYnH3BmHEtC3BjNEaMCH9yjKu+iF1AQYvbu3JAF 00f8uK234heUrq0IUlUGJB5VplauaN2mA6bToafqTjA9y0w82l9vG0zW2L0c1eMfvBDt OdAFqE+5GSQvG8qqvLJNANXZrfCq0ak9LANoa12m6R9oJQuDeo7Xae81Rr7lDNiZwLd1 olfw== X-Received: by 10.52.76.103 with SMTP id j7mr15033570vdw.90.1364242111631; Mon, 25 Mar 2013 13:08:31 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp41757ved; Mon, 25 Mar 2013 13:08:31 -0700 (PDT) X-Received: by 10.68.14.233 with SMTP id s9mr19209394pbc.154.1364242110773; Mon, 25 Mar 2013 13:08:30 -0700 (PDT) Received: from mail-da0-x22c.google.com (mail-da0-x22c.google.com [2607:f8b0:400e:c00::22c]) by mx.google.com with ESMTPS id pg7si2539127pbb.67.2013.03.25.13.08.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:30 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::22c is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=2607:f8b0:400e:c00::22c; Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400e:c00::22c is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: by mail-da0-f44.google.com with SMTP id z20so3370780dae.3 for ; Mon, 25 Mar 2013 13:08:30 -0700 (PDT) X-Received: by 10.68.42.9 with SMTP id j9mr19438121pbl.142.1364242110293; Mon, 25 Mar 2013 13:08:30 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPS id gn2sm14529074pbb.22.2013.03.25.13.08.28 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:29 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Richard Cochran , Prarit Bhargava Subject: [PATCH 4/8] ntp: Rework do_adjtimex to take timespec and tai arguments Date: Mon, 25 Mar 2013 13:08:14 -0700 Message-Id: <1364242098-5977-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> References: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQluG9Iu8V4+Od4Y1tlibuppb+fDm/kxYR5ifBLNK4UwAKaAnLMY12iyJJi350rC5v9XcPN9 In order to change the locking rules, we need to provide the timespec and tai values rather then having the ntp logic acquire these values itself. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- kernel/time/ntp.c | 18 +++++------------- kernel/time/ntp_internal.h | 2 +- kernel/time/timekeeping.c | 13 +++++++++++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 2dc60c6..d17e13c 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -662,10 +662,8 @@ int ntp_validate_timex(struct timex *txc) * adjtimex mainly allows reading (and writing, if superuser) of * kernel time-keeping variables. used by xntpd. */ -int __do_adjtimex(struct timex *txc) +int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) { - struct timespec ts; - u32 time_tai, orig_tai; int result; if (txc->modes & ADJ_SETOFFSET) { @@ -679,9 +677,6 @@ int __do_adjtimex(struct timex *txc) return result; } - getnstimeofday(&ts); - orig_tai = time_tai = timekeeping_get_tai_offset(); - raw_spin_lock_irq(&ntp_lock); if (txc->modes & ADJ_ADJTIME) { @@ -697,7 +692,7 @@ int __do_adjtimex(struct timex *txc) /* If there are input parameters, then process them: */ if (txc->modes) - process_adjtimex_modes(txc, &ts, &time_tai); + process_adjtimex_modes(txc, ts, time_tai); txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, NTP_SCALE_SHIFT); @@ -719,18 +714,15 @@ int __do_adjtimex(struct timex *txc) txc->precision = 1; txc->tolerance = MAXFREQ_SCALED / PPM_SCALE; txc->tick = tick_usec; - txc->tai = time_tai; + txc->tai = *time_tai; /* fill PPS status fields */ pps_fill_timex(txc); raw_spin_unlock_irq(&ntp_lock); - if (time_tai != orig_tai) - timekeeping_set_tai_offset(time_tai); - - txc->time.tv_sec = ts.tv_sec; - txc->time.tv_usec = ts.tv_nsec; + txc->time.tv_sec = ts->tv_sec; + txc->time.tv_usec = ts->tv_nsec; if (!(time_status & STA_NANO)) txc->time.tv_usec /= NSEC_PER_USEC; diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h index a2a3976..1950cb4 100644 --- a/kernel/time/ntp_internal.h +++ b/kernel/time/ntp_internal.h @@ -7,6 +7,6 @@ extern void ntp_clear(void); extern u64 ntp_tick_length(void); extern int second_overflow(unsigned long secs); extern int ntp_validate_timex(struct timex *); -extern int __do_adjtimex(struct timex *); +extern int __do_adjtimex(struct timex *, struct timespec *, s32 *); extern void __hardpps(const struct timespec *, const struct timespec *); #endif /* _LINUX_NTP_INTERNAL_H */ diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f6c8a72..5f7a233 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1618,6 +1618,8 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); */ int do_adjtimex(struct timex *txc) { + struct timespec ts; + s32 tai, orig_tai; int ret; /* Validate the data before disabling interrupts */ @@ -1625,9 +1627,16 @@ int do_adjtimex(struct timex *txc) if (ret) return ret; - return __do_adjtimex(txc); -} + getnstimeofday(&ts); + orig_tai = tai = timekeeping_get_tai_offset(); + + ret = __do_adjtimex(txc, &ts, &tai); + if (tai != orig_tai) + timekeeping_set_tai_offset(tai); + + return ret; +} #ifdef CONFIG_NTP_PPS /**