From patchwork Wed Mar 11 03:15:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 45614 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5EB37214C2 for ; Wed, 11 Mar 2015 03:19:34 +0000 (UTC) Received: by wivz2 with SMTP id z2sf4989576wiv.1 for ; Tue, 10 Mar 2015 20:19:33 -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=h+bE/FlI7AqYMFRVEl7lHlOYBhCJZRBEvqchuetEyPc=; b=OfWgY776FDMSXMwtrzaZQdAxM8kzlppbS3dNI2YOGMnQ2quQfr/MLLjczGC+0zQJbJ fRDpuepqAhuMlymhU8r/HeOxXasx4gNO1b10Qvuv2X89DphFRhuY6nMRXlYYC+tTi/qE NUXuLw8OKPnk3uiBSNchDmpW46EhGvV3TZKekWRH6BoY5PEqT91yhfFWRc3tHVvLkJCG eMqkTwB/kePMITOcFySnYy/tvPK7x/TMS1FkVn1IKpLbsCxsIE3+HnY2eq8c0rGJtIe4 sN2zNExX1SmSD6ZBIoZzOEAS50kEL862AY8iwx5WvNuDOqVm+whobM9KSTPjN9Man2vh QuQw== X-Gm-Message-State: ALoCoQl/dSt9vucq7NiT4Ikkz2BAia6tXtHzh4U498ScH+tkQdWa2TEu009/QhKNObiM2KVHAGu8 X-Received: by 10.180.91.76 with SMTP id cc12mr5592692wib.7.1426043973684; Tue, 10 Mar 2015 20:19:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.178 with SMTP id p18ls85467lal.68.gmail; Tue, 10 Mar 2015 20:19:33 -0700 (PDT) X-Received: by 10.152.121.33 with SMTP id lh1mr33035296lab.86.1426043973347; Tue, 10 Mar 2015 20:19:33 -0700 (PDT) Received: from mail-la0-x22d.google.com (mail-la0-x22d.google.com. [2a00:1450:4010:c03::22d]) by mx.google.com with ESMTPS id kx13si1441895lbb.152.2015.03.10.20.19.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 20:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22d as permitted sender) client-ip=2a00:1450:4010:c03::22d; Received: by labhs14 with SMTP id hs14so5522983lab.5 for ; Tue, 10 Mar 2015 20:19:33 -0700 (PDT) X-Received: by 10.112.162.167 with SMTP id yb7mr32211466lbb.76.1426043973206; Tue, 10 Mar 2015 20:19:33 -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 h5csp2512997lbj; Tue, 10 Mar 2015 20:19:32 -0700 (PDT) X-Received: by 10.70.18.36 with SMTP id t4mr74037351pdd.66.1426043971358; Tue, 10 Mar 2015 20:19:31 -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.30; Tue, 10 Mar 2015 20:19:31 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1752667AbbCKDT1 (ORCPT + 28 others); Tue, 10 Mar 2015 23:19:27 -0400 Received: from m15-112.126.com ([220.181.15.112]:48844 "EHLO m15-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbbCKDTV (ORCPT ); Tue, 10 Mar 2015 23:19:21 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp2 (Coremail) with SMTP id DMmowEAp51Z4s_9UJTpwAw--.1055S5; Wed, 11 Mar 2015 11:17:38 +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 3/8] time: Add y2038 safe update_persistent_clock64() Date: Wed, 11 Mar 2015 11:15:10 +0800 Message-Id: <1426043715-22043-4-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--.1055S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxGr4kWr4rCry8GF47uF18uFg_yoW5ArWUpa y5Cw1rKw4UJw4UurnFkanavw1agw15Xry7t34xX34ayryqqr1xJr15A39YvryDXFWfAa13 ZF40qFs8uw18Z3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jDrcfUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiJwS5v01sAr9NXAACsq Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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::22d 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 in-kernel y2038 issues, this patch adds update_persistent_clock64() and replaces all the call sites of update_persistent_clock() with this function. This is a __weak implementation, which simply calls the existing y2038 unsafe update_persistent_clock(). This allows architecture specific implementations to be converted independently, and eventually y2038-unsafe update_persistent_clock() can be removed after all its architecture specific implementations have been converted to update_persistent_clock64(). Suggested-by: Arnd Bergmann Signed-off-by: Xunlei Pang --- drivers/rtc/systohc.c | 2 +- include/linux/timekeeping.h | 1 + kernel/time/ntp.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index eb71872..ef3c07a 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -11,7 +11,7 @@ * rtc_set_ntp_time - Save NTP synchronized time to the RTC * @now: Current time of day * - * Replacement for the NTP platform function update_persistent_clock + * Replacement for the NTP platform function update_persistent_clock64 * that stores time for later retrieval by rtc_hctosys. * * Returns 0 on successful RTC update, -ENODEV if a RTC update is not diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index ff56a0f..a7fa96b 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -266,6 +266,7 @@ extern void read_persistent_clock64(struct timespec64 *ts); extern void read_boot_clock(struct timespec *ts); extern void read_boot_clock64(struct timespec64 *ts); extern int update_persistent_clock(struct timespec now); +extern int update_persistent_clock64(struct timespec64 now); #endif diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 0f60b08..42d1bc7 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -459,6 +459,16 @@ out: return leap; } +#ifdef CONFIG_GENERIC_CMOS_UPDATE +int __weak update_persistent_clock64(struct timespec64 now64) +{ + struct timespec now; + + now = timespec64_to_timespec(now64); + return update_persistent_clock(now); +} +#endif + #if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) static void sync_cmos_clock(struct work_struct *work); @@ -494,8 +504,9 @@ static void sync_cmos_clock(struct work_struct *work) if (persistent_clock_is_local) adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); #ifdef CONFIG_GENERIC_CMOS_UPDATE - fail = update_persistent_clock(timespec64_to_timespec(adjust)); + fail = update_persistent_clock64(adjust); #endif + #ifdef CONFIG_RTC_SYSTOHC if (fail == -ENODEV) fail = rtc_set_ntp_time(adjust);