From patchwork Thu Apr 2 03:34:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46679 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 61457216D1 for ; Thu, 2 Apr 2015 03:35:01 +0000 (UTC) Received: by wibgr10 with SMTP id gr10sf15745299wib.2 for ; Wed, 01 Apr 2015 20:35:00 -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=m5OJq0XCD5d+er2lrShcjW5KAagcSFrALfPCoeVFETo=; b=WBhqf8226ymJUae6NvOjXWtSrwYbwynVX5JC0vFjxhJh73OASll/kj+RqXpPY7Oh/p ws/PLWO1Wg7izb66UOe/qie8/RVfl7BmQtQnpzSEdlloOJEXzkISnJDtpYKpYqdsMGsg hV0Kq6WJ0zOXg+3b4IJpc8tqZTDHcuKuOcf9q+spYcsz++SU9NH7Eh6ednBgRgu54VO8 U3AN3/EFuzDkj1uVCaeSiprZrTyvJwtIdsJNcC9CurfB9OvSfhnCk4KCDz9dC79Ulx+H gTObrcl3YVbMx+40v/a+YoKdFXEeXV9Y1YLBuESkA8WtZy3Ezyxv6mHYEhCv6iihnYgw 8+oQ== X-Gm-Message-State: ALoCoQk42Vpxm9jXKbrqeSH8w9WJcIro9dlj1zf1NDKB4OMp2dMqL0uJk3k2zJfoNV9cFA/P5J1I X-Received: by 10.180.73.137 with SMTP id l9mr551876wiv.5.1427945700652; Wed, 01 Apr 2015 20:35:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.97 with SMTP id it1ls162331lac.1.gmail; Wed, 01 Apr 2015 20:35:00 -0700 (PDT) X-Received: by 10.112.72.36 with SMTP id a4mr22069498lbv.58.1427945700277; Wed, 01 Apr 2015 20:35:00 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id kw12si3153032lac.3.2015.04.01.20.34.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbug6 with SMTP id ug6so50486878lbb.3 for ; Wed, 01 Apr 2015 20:34:59 -0700 (PDT) X-Received: by 10.112.141.202 with SMTP id rq10mr38776825lbb.88.1427945699438; Wed, 01 Apr 2015 20:34:59 -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 k9csp1063137lbq; Wed, 1 Apr 2015 20:34:58 -0700 (PDT) X-Received: by 10.66.137.98 with SMTP id qh2mr82784312pab.76.1427945691110; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com. [209.85.192.169]) by mx.google.com with ESMTPS id lx6si5528522pdb.209.2015.04.01.20.34.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.169 as permitted sender) client-ip=209.85.192.169; Received: by pddn5 with SMTP id n5so75626807pdd.2 for ; Wed, 01 Apr 2015 20:34:50 -0700 (PDT) X-Received: by 10.68.204.199 with SMTP id la7mr30025423pbc.147.1427945690137; Wed, 01 Apr 2015 20:34:50 -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.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:34:49 -0700 (PDT) From: John Stultz To: lkml Cc: Xunlei Pang , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 03/21] time: Add y2038 safe update_persistent_clock64() Date: Wed, 1 Apr 2015 20:34:23 -0700 Message-Id: <1427945681-29972-4-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.181 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 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(). Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Suggested-by: Arnd Bergmann Signed-off-by: Xunlei Pang Signed-off-by: John Stultz --- 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 4c0f76f..7a2369d 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -272,6 +272,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);