From patchwork Wed Mar 11 03:15:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 45615 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6380D214C2 for ; Wed, 11 Mar 2015 03:19:39 +0000 (UTC) Received: by wghl18 with SMTP id l18sf4393281wgh.1 for ; Tue, 10 Mar 2015 20:19:38 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=CfLMWmHgMI9/2h25n7ubwFlDa0kiuCQHyfM58kHby0g=; b=AalMjUZNAPVunpirwN9/OpMjVMMKhX2nBy4NCOSBUdGqRbjvA3KQq3IXBCjC0cRdNt 97pMxL0DooGXTIs6pGJK07FoWkDJlLEXQ5QFF6TmgmAfkHgPQXov4ExRnS14PafOXaFA v/yPF8IYw4H3CDrQTxU4rxG0rhEWxD1rT8jg0rmvZYyRxykee3jnRuP0alKQkaO5B7l4 RUJFh1nRGzDlhKsmV3L2odPXg73SgBWlTKBT0A6UHMUeUg8a+VTcENy1EHnSqLfzP/j6 6kjuViarQjvJjleWz4FpYXVdN4EYFDcdms+AzmIs67Qf1feDDy9aGNHOShSwbobGxPU8 r3xw== X-Gm-Message-State: ALoCoQlCh+xcYwq3NoGOmX3fqmy+TUwN56M2CE3V0YOoV8a5LDD4DRgEMkUlAWSslyh/jLc1h23O X-Received: by 10.152.19.67 with SMTP id c3mr3838060lae.7.1426043978639; Tue, 10 Mar 2015 20:19:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.9 with SMTP id js9ls104164lab.69.gmail; Tue, 10 Mar 2015 20:19:38 -0700 (PDT) X-Received: by 10.112.167.231 with SMTP id zr7mr33111920lbb.123.1426043978493; Tue, 10 Mar 2015 20:19:38 -0700 (PDT) Received: from mail-la0-x234.google.com (mail-la0-x234.google.com. [2a00:1450:4010:c03::234]) by mx.google.com with ESMTPS id ut6si1498452lbc.85.2015.03.10.20.19.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 20:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::234 as permitted sender) client-ip=2a00:1450:4010:c03::234; Received: by lams18 with SMTP id s18so6041131lam.2 for ; Tue, 10 Mar 2015 20:19:38 -0700 (PDT) X-Received: by 10.112.172.229 with SMTP id bf5mr32468614lbc.72.1426043978369; Tue, 10 Mar 2015 20:19:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2513026lbj; Tue, 10 Mar 2015 20:19:37 -0700 (PDT) X-Received: by 10.66.189.105 with SMTP id gh9mr72159873pac.41.1426043972253; Tue, 10 Mar 2015 20:19:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id va1si4487475pac.83.2015.03.10.20.19.31; Tue, 10 Mar 2015 20:19:32 -0700 (PDT) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752765AbbCKDTa (ORCPT + 5 others); Tue, 10 Mar 2015 23:19:30 -0400 Received: from m15-112.126.com ([220.181.15.112]:48968 "EHLO m15-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752277AbbCKDT1 (ORCPT ); Tue, 10 Mar 2015 23:19:27 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp2 (Coremail) with SMTP id DMmowEAp51Z4s_9UJTpwAw--.1055S6; Wed, 11 Mar 2015 11:17:42 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , John Stultz , Arnd Bergmann , linux-omap@vger.kernel.org, Tony Lindgren , linux-tegra@vger.kernel.org, Stephen Warren , linux390@de.ibm.com, Martin Schwidefsky , Ralf Baechle , Arnd Bergmann , Xunlei Pang Subject: [PATCH 4/8] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement Date: Wed, 11 Mar 2015 11:15:11 +0800 Message-Id: <1426043715-22043-5-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426043715-22043-1-git-send-email-xlpang@126.com> References: <1426043715-22043-1-git-send-email-xlpang@126.com> X-CM-TRANSID: DMmowEAp51Z4s_9UJTpwAw--.1055S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7trWxWryfCry3ZF1DJFy8AFb_yoW5JF4Dpr 10y3Z8Ww4UXa4v9wsrta4DXw15K3s8Cay7t34rK34Syr1UtwnxC3WrCayYyr9xXrWrZayU uF40y3WDWF4DA3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jIE__UUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbipAy5v1Gofq45RQAAs7 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::234 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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. Signed-off-by: Xunlei Pang --- 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 61b4d70..d422e36 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); } /**