From patchwork Thu Apr 2 03:34:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46681 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3724216D1 for ; Thu, 2 Apr 2015 03:35:06 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf7173101lbc.1 for ; Wed, 01 Apr 2015 20:35:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=gS4KSgYLk8/L0x87+fjlpHd8V8Ar8CKYEP8NL7ibgVI=; b=iW6o98wyNJ+gf2Q4/XY8vvDrP+DUhmHIzpkgcFAcdYbAbJfNhmOc7crhjlZ/2wthFy KBaLsSi1ItzJvVlFRnw5ttNvFOg5MAG0Cb77QqPl0aCr0+r2AgH6gF3zJjAxegtowDkN ETf0PLYMs6SkrK7RX/mdHqI+meE303+ZiG+/475tWiIUufLnw2gEf5hLroZz1CqbdShB H2ISW1p09unJFurfJuA7EEdPn8I1yrQn2snn1DjIdrfsb50glUp3eNyI2LeWTPO0t7r+ PA5taZiIxAv9/deO99YqHh8sZJtZZlb6xo37UURvws2ObXaDOyiX/4x8U2AXPPAUf8CK lhKQ== X-Gm-Message-State: ALoCoQnBgx6NiOifm2d2w1BXDZdmnveWNemRZmTBI2TG9z7QToU1mxs7G0epiaNqzXOiHjhYjED3 X-Received: by 10.152.184.73 with SMTP id es9mr707816lac.4.1427945705821; Wed, 01 Apr 2015 20:35:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.194 with SMTP id a2ls141437lak.88.gmail; Wed, 01 Apr 2015 20:35:05 -0700 (PDT) X-Received: by 10.113.11.12 with SMTP id ee12mr38293094lbd.5.1427945705680; Wed, 01 Apr 2015 20:35:05 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id ms7si3137729lbb.51.2015.04.01.20.35.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:35:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbzk7 with SMTP id zk7so34215698lbb.0 for ; Wed, 01 Apr 2015 20:35:05 -0700 (PDT) X-Received: by 10.112.201.231 with SMTP id kd7mr39386818lbc.35.1427945705265; Wed, 01 Apr 2015 20:35:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1063167lbq; Wed, 1 Apr 2015 20:35:04 -0700 (PDT) X-Received: by 10.66.231.204 with SMTP id ti12mr82915898pac.135.1427945693534; Wed, 01 Apr 2015 20:34:53 -0700 (PDT) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com. [209.85.220.51]) by mx.google.com with ESMTPS id h2si5584987pdk.22.2015.04.01.20.34.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:53 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.51 as permitted sender) client-ip=209.85.220.51; Received: by pactp5 with SMTP id tp5so71152748pac.1 for ; Wed, 01 Apr 2015 20:34:52 -0700 (PDT) X-Received: by 10.70.35.72 with SMTP id f8mr83127936pdj.88.1427945692655; Wed, 01 Apr 2015 20:34:52 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id da10sm3572603pac.42.2015.04.01.20.34.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:34:51 -0700 (PDT) From: John Stultz To: lkml Cc: Xunlei Pang , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 05/21] ARM: tegra: clock: Provide y2038-safe tegra_read_persistent_clock() replacement Date: Wed, 1 Apr 2015 20:34:25 -0700 Message-Id: <1427945681-29972-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> References: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang As part of addressing "y2038 problem" for in-kernel uses, this patch adds the y2038-safe tegra_read_persistent_clock64() using timespec64. Because we rely on some subsequent changes to convert arm multiarch support, tegra_read_persistent_clock() will be removed then. Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Acked-by: Thierry Reding Signed-off-by: Xunlei Pang Signed-off-by: John Stultz --- drivers/clocksource/tegra20_timer.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/tegra20_timer.c b/drivers/clocksource/tegra20_timer.c index d8a3a4e..4a0a603 100644 --- a/drivers/clocksource/tegra20_timer.c +++ b/drivers/clocksource/tegra20_timer.c @@ -51,7 +51,7 @@ static void __iomem *timer_reg_base; static void __iomem *rtc_base; -static struct timespec persistent_ts; +static struct timespec64 persistent_ts; static u64 persistent_ms, last_persistent_ms; static struct delay_timer tegra_delay_timer; @@ -120,26 +120,33 @@ static u64 tegra_rtc_read_ms(void) } /* - * tegra_read_persistent_clock - Return time from a persistent clock. + * tegra_read_persistent_clock64 - Return time from a persistent clock. * * Reads the time from a source which isn't disabled during PM, the * 32k sync timer. Convert the cycles elapsed since last read into - * nsecs and adds to a monotonically increasing timespec. + * nsecs and adds to a monotonically increasing timespec64. * Care must be taken that this funciton is not called while the * tegra_rtc driver could be executing to avoid race conditions * on the RTC shadow register */ -static void tegra_read_persistent_clock(struct timespec *ts) +static void tegra_read_persistent_clock64(struct timespec64 *ts) { u64 delta; - struct timespec *tsp = &persistent_ts; last_persistent_ms = persistent_ms; persistent_ms = tegra_rtc_read_ms(); delta = persistent_ms - last_persistent_ms; - timespec_add_ns(tsp, delta * NSEC_PER_MSEC); - *ts = *tsp; + timespec64_add_ns(&persistent_ts, delta * NSEC_PER_MSEC); + *ts = persistent_ts; +} + +static void tegra_read_persistent_clock(struct timespec *ts) +{ + struct timespec ts64; + + tegra_read_persistent_clock64(&ts64); + *ts = timespec64_to_timespec(ts64); } static unsigned long tegra_delay_timer_read_counter_long(void)