From patchwork Thu Apr 2 03:34:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46680 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D4F8F216D1 for ; Thu, 2 Apr 2015 03:35:03 +0000 (UTC) Received: by wgua4 with SMTP id a4sf14107170wgu.2 for ; Wed, 01 Apr 2015 20:35:03 -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=OQIdsYf2F0e5ABEOt6F6mqvvd1mg7aFL3RSjpD/N4cg=; b=EwwKlZ5oxS2EMgftxhcJroFT8kgf511r8JwEKDTumU1yycnbi4pHE9/v6C1vc23WI2 KhuJeIVQCluFtJs+CXIRbXjCW/19GXk3ZgbOLleYMkSuUXSY6PybQj1tUZczIPXzO4SH jzjy+lOqm5sM5SIKZg/FzHOfNo0Awpl2ILJO6VTP2WLAqD/e4hv8z+4t1IyLxZq//J9D GonfS24rRTFZ63qeNt6gbr/LNIL7cbpadxP7t819JKVfC2aqSwJt6yWUncVRlcdF2kJg enWezrdsDba0P/E6iser47G5jtxE/Z76nsdxOSn890132dgmmZhcpb1eTKsbRLZH9fyi WRKQ== X-Gm-Message-State: ALoCoQmFEfYgIr7c6/tYM8Cix01M0xHDF+z/WfHcamzUA5oOTTXc/rIlrdygggu9l6JO0aZqWboa X-Received: by 10.152.23.7 with SMTP id i7mr3430521laf.1.1427945703145; Wed, 01 Apr 2015 20:35:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.68 with SMTP id la4ls148262lab.25.gmail; Wed, 01 Apr 2015 20:35:02 -0700 (PDT) X-Received: by 10.152.8.69 with SMTP id p5mr34497942laa.113.1427945702870; Wed, 01 Apr 2015 20:35:02 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id n1si3127695lae.91.2015.04.01.20.35.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:35:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lajy8 with SMTP id y8so50903007laj.0 for ; Wed, 01 Apr 2015 20:35:02 -0700 (PDT) X-Received: by 10.112.8.76 with SMTP id p12mr34978146lba.29.1427945702632; Wed, 01 Apr 2015 20:35:02 -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 k9csp1063153lbq; Wed, 1 Apr 2015 20:35:01 -0700 (PDT) X-Received: by 10.66.185.230 with SMTP id ff6mr84172896pac.102.1427945692329; Wed, 01 Apr 2015 20:34:52 -0700 (PDT) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com. [209.85.220.49]) by mx.google.com with ESMTPS id wh9si5493511pbc.121.2015.04.01.20.34.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:52 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.49 as permitted sender) client-ip=209.85.220.49; Received: by pacgg7 with SMTP id gg7so71300613pac.0 for ; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) X-Received: by 10.70.46.65 with SMTP id t1mr82169929pdm.128.1427945691438; Wed, 01 Apr 2015 20:34:51 -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.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:34:50 -0700 (PDT) From: John Stultz To: lkml Cc: Xunlei Pang , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 04/21] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement Date: Wed, 1 Apr 2015 20:34:24 -0700 Message-Id: <1427945681-29972-5-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.215.47 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 omap_read_persistent_clock64() using timespec64. Because we rely on some subsequent changes to convert arm multiarch support, omap_read_persistent_clock() will be removed then. Also remove the needless spinlock, because read_persistent_clock() doesn't run simultaneously. Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Acked-by: Tony Lindgren Signed-off-by: Xunlei Pang Signed-off-by: John Stultz --- arch/arm/plat-omap/counter_32k.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c index 43cf745..b7b7b07 100644 --- a/arch/arm/plat-omap/counter_32k.c +++ b/arch/arm/plat-omap/counter_32k.c @@ -44,24 +44,20 @@ static u64 notrace omap_32k_read_sched_clock(void) } /** - * omap_read_persistent_clock - Return time from a persistent clock. + * omap_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. */ -static struct timespec persistent_ts; +static struct timespec64 persistent_ts; static cycles_t cycles; static unsigned int persistent_mult, persistent_shift; -static DEFINE_SPINLOCK(read_persistent_clock_lock); -static void omap_read_persistent_clock(struct timespec *ts) +static void omap_read_persistent_clock64(struct timespec64 *ts) { unsigned long long nsecs; cycles_t last_cycles; - unsigned long flags; - - spin_lock_irqsave(&read_persistent_clock_lock, flags); last_cycles = cycles; cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0; @@ -69,11 +65,17 @@ static void omap_read_persistent_clock(struct timespec *ts) nsecs = clocksource_cyc2ns(cycles - last_cycles, persistent_mult, persistent_shift); - timespec_add_ns(&persistent_ts, nsecs); + timespec64_add_ns(&persistent_ts, nsecs); *ts = persistent_ts; +} + +static void omap_read_persistent_clock(struct timespec *ts) +{ + struct timespec64 ts64; - spin_unlock_irqrestore(&read_persistent_clock_lock, flags); + omap_read_persistent_clock64(&ts64); + *ts = timespec64_to_timespec(ts64); } /**