From patchwork Mon Mar 25 20:08:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15630 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 EA82C23E66 for ; Mon, 25 Mar 2013 20:08:33 +0000 (UTC) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by fiordland.canonical.com (Postfix) with ESMTP id A5E78A1954C for ; Mon, 25 Mar 2013 20:08:33 +0000 (UTC) Received: by mail-vb0-f49.google.com with SMTP id s24so4062842vbi.22 for ; Mon, 25 Mar 2013 13:08:33 -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=w4KM2tjfi3snSzFO5ykCSyduDjFpcO/ERZPjlJ0dv9E=; b=ecmfHiMzF9kelLGWNTl6mEde6anz7QFJrEByqGzqxl89Lntn5ws7l9gm3cCj24WGaD 0zeXyQwr/bpQnFZp+AAvO5A8NWi06ODrRYrTcLK8BDA0I6bcVGvJx5NeVIH9C7GXofr0 EY1K0LPB6hV87G98QtlBwDA6SfKCw6S7KTwmJDOmfCn7WLfQiwBqeHlCUimw0FGnnD8M znl6bITh8m97liAWxeIzm1G6W+NP6u6VUgz9qCoGqLNA8+opGGWZeiyRAqFPybv6qiMG SaWQjQSc5379tL78Jr387viWQfX/aAWh2EbGijomJXXHhFbSAjlW787l9uTHc/URAd7c CteA== X-Received: by 10.220.150.74 with SMTP id x10mr17480263vcv.68.1364242113142; Mon, 25 Mar 2013 13:08:33 -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 cg12csp41759ved; Mon, 25 Mar 2013 13:08:32 -0700 (PDT) X-Received: by 10.68.163.133 with SMTP id yi5mr18620306pbb.201.1364242112214; Mon, 25 Mar 2013 13:08:32 -0700 (PDT) Received: from mail-da0-x22e.google.com (mail-da0-x22e.google.com [2607:f8b0:400e:c00::22e]) by mx.google.com with ESMTPS id xr1si14548539pbc.279.2013.03.25.13.08.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::22e is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=2607:f8b0:400e:c00::22e; Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400e:c00::22e 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-f46.google.com with SMTP id y19so3363702dan.19 for ; Mon, 25 Mar 2013 13:08:31 -0700 (PDT) X-Received: by 10.68.138.135 with SMTP id qq7mr19252537pbb.42.1364242111624; Mon, 25 Mar 2013 13:08:31 -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.30 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:30 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Richard Cochran , Prarit Bhargava Subject: [PATCH 5/8] timekeeping: Move ADJ_SETOFFSET to top level do_adjtimex() Date: Mon, 25 Mar 2013 13:08:15 -0700 Message-Id: <1364242098-5977-6-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: ALoCoQlzbpEpPnPgUptfzZZ1vXKHuuZ8afmt1f0J4zwUVHf4A1JtAJcbxOG7DA2xlx703qzRUlc0 Since ADJ_SETOFFSET adjusts the timekeeping state, process it as part of the top level do_adjtimex() function in timekeeping.c. This avoids deadlocks that could occur once we change the ntp locking rules. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- kernel/time/ntp.c | 11 ----------- kernel/time/timekeeping.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index d17e13c..a331ebc 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -666,17 +666,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) { int result; - if (txc->modes & ADJ_SETOFFSET) { - struct timespec delta; - delta.tv_sec = txc->time.tv_sec; - delta.tv_nsec = txc->time.tv_usec; - if (!(txc->modes & ADJ_NANO)) - delta.tv_nsec *= 1000; - result = timekeeping_inject_offset(&delta); - if (result) - return result; - } - raw_spin_lock_irq(&ntp_lock); if (txc->modes & ADJ_ADJTIME) { diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 5f7a233..e44915c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1627,6 +1627,17 @@ int do_adjtimex(struct timex *txc) if (ret) return ret; + if (txc->modes & ADJ_SETOFFSET) { + struct timespec delta; + delta.tv_sec = txc->time.tv_sec; + delta.tv_nsec = txc->time.tv_usec; + if (!(txc->modes & ADJ_NANO)) + delta.tv_nsec *= 1000; + ret = timekeeping_inject_offset(&delta); + if (ret) + return ret; + } + getnstimeofday(&ts); orig_tai = tai = timekeeping_get_tai_offset();