From patchwork Mon Mar 25 20:08:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15631 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 4D99D23E66 for ; Mon, 25 Mar 2013 20:08:35 +0000 (UTC) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by fiordland.canonical.com (Postfix) with ESMTP id 0AA0FA1954C for ; Mon, 25 Mar 2013 20:08:34 +0000 (UTC) Received: by mail-vc0-f178.google.com with SMTP id hz11so5041074vcb.9 for ; Mon, 25 Mar 2013 13:08:34 -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=17fksefeWD7pNYyAwLjh/5UpazYPNhnbF6IUjX1PQk8=; b=bg2b2iwlEpY36NIkcd4nlbcg6WcOwCmjk88iFarQqER+4x994zTtRM/kJacKSzUgeQ DtLFNT1LHZyreu2yRFwoRgxGGWlqi5M2qS7WvJpRLToqzZqBRjvlBb9by3z5ZyTMCR9y mlG4wnZvjpqrV+UL3OeqUxJkXXa103gCtu8apNhHc2MJ0YmMI1VNaiKAV1FgqiEKGSBx BiULZ2SxTdPz0DbaTy80FnkEpms5R4n4bgTPB9SG6+dc+X87vSS40Sl8XIIRIF0UMTeB 85FPG0CtUVWwYuDyOGN8Ua++xIFd+pm7boO4fea7Dsc6cz3bTVpAraGX0pniD2FgA9zP MXpw== X-Received: by 10.52.31.103 with SMTP id z7mr14748822vdh.56.1364242114495; Mon, 25 Mar 2013 13:08:34 -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 cg12csp41761ved; Mon, 25 Mar 2013 13:08:34 -0700 (PDT) X-Received: by 10.68.253.68 with SMTP id zy4mr840041pbc.38.1364242113664; Mon, 25 Mar 2013 13:08:33 -0700 (PDT) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id xp9si14596881pbc.100.2013.03.25.13.08.33 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.46 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-pa0-f46.google.com with SMTP id wp1so1213332pac.33 for ; Mon, 25 Mar 2013 13:08:33 -0700 (PDT) X-Received: by 10.66.120.137 with SMTP id lc9mr19748379pab.128.1364242113282; Mon, 25 Mar 2013 13:08:33 -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.31 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:32 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Richard Cochran , Prarit Bhargava Subject: [PATCH 6/8] timekeeping: Hold timekeepering locks in do_adjtimex and hardpps Date: Mon, 25 Mar 2013 13:08:16 -0700 Message-Id: <1364242098-5977-7-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: ALoCoQmg3/nvddf+0DKp3PUsyIlNcEhR38mHYk35mo0GO2igE8VZKyOLOdYdbULB7pKzyuOfjzA5 In moving the NTP state to be protected by the timekeeping locks, be sure to acquire the timekeeping locks prior to calling ntp functions. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index e44915c..d10bd73 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -787,10 +787,10 @@ void __init timekeeping_init(void) boot.tv_nsec = 0; } - ntp_init(); - raw_spin_lock_irqsave(&timekeeper_lock, flags); write_seqcount_begin(&timekeeper_seq); + ntp_init(); + clock = clocksource_default_clock(); if (clock->enable) clock->enable(clock); @@ -1618,6 +1618,7 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); */ int do_adjtimex(struct timex *txc) { + unsigned long flags; struct timespec ts; s32 tai, orig_tai; int ret; @@ -1641,8 +1642,14 @@ int do_adjtimex(struct timex *txc) getnstimeofday(&ts); orig_tai = tai = timekeeping_get_tai_offset(); + raw_spin_lock_irqsave(&timekeeper_lock, flags); + write_seqcount_begin(&timekeeper_seq); + ret = __do_adjtimex(txc, &ts, &tai); + write_seqcount_end(&timekeeper_seq); + raw_spin_unlock_irqrestore(&timekeeper_lock, flags); + if (tai != orig_tai) timekeeping_set_tai_offset(tai); @@ -1655,7 +1662,15 @@ int do_adjtimex(struct timex *txc) */ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) { + unsigned long flags; + + raw_spin_lock_irqsave(&timekeeper_lock, flags); + write_seqcount_begin(&timekeeper_seq); + __hardpps(phase_ts, raw_ts); + + write_seqcount_end(&timekeeper_seq); + raw_spin_unlock_irqrestore(&timekeeper_lock, flags); } EXPORT_SYMBOL(hardpps); #endif