From patchwork Tue Jan 20 16:41:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 43417 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DBB622034D for ; Tue, 20 Jan 2015 16:49:31 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id hs14sf20978913lab.1 for ; Tue, 20 Jan 2015 08:49:30 -0800 (PST) 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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=blhcW+aN3SCuBiksE++LszOj+/Yv90OBEWX566Q8aQY=; b=C3KleWZu8JWN+/uZPL1guWNGZ38KV96/SJcX9i0mPvGxWWJbqsrbNF+Qqf5hEcrv70 1/Tvfrgh3uMUjyPWv1zFKp4qGwt8n6jrb2+j/IzV/xjncFf1rcSx2mB/J161KDzKqgPt P0uWdhYBlm/WBqJGecCGPbE5lLgfSfQCBDpKWzZ6jN1ko5LQ1aEzBQYSk0GsMdMc0icN pggbDuRuQBquRZ5oHj+AHxfTfWuJC+63blftxu9SXcym4ct0qbJ40rpt5SIezNQa9WIk zf1VQy9X9mtqNgEOmKyhUOV1D9ZthYJlisvfPIjdcZZz2G5ehME2xG+0dYk6Lkov6iFV EFww== X-Gm-Message-State: ALoCoQlGoYKo/Q2ZijsME8m34UMvDwj8CQud4Nuw0753gt19wHaJHoVHpRrcAwUGooxLFVJHW8ox X-Received: by 10.180.228.38 with SMTP id sf6mr2969956wic.5.1421772570719; Tue, 20 Jan 2015 08:49:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.232 with SMTP id m8ls694532laa.45.gmail; Tue, 20 Jan 2015 08:49:30 -0800 (PST) X-Received: by 10.152.43.77 with SMTP id u13mr39142929lal.93.1421772570462; Tue, 20 Jan 2015 08:49:30 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id xo9si14212409lac.57.2015.01.20.08.49.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 08:49:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id z11so34715390lbi.6 for ; Tue, 20 Jan 2015 08:49:30 -0800 (PST) X-Received: by 10.112.170.36 with SMTP id aj4mr39324208lbc.3.1421772570346; Tue, 20 Jan 2015 08:49:30 -0800 (PST) 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.9.200 with SMTP id c8csp1481806lbb; Tue, 20 Jan 2015 08:49:29 -0800 (PST) X-Received: by 10.66.254.232 with SMTP id al8mr54757630pad.76.1421772568584; Tue, 20 Jan 2015 08:49:28 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ki8si4919441pbc.210.2015.01.20.08.49.27; Tue, 20 Jan 2015 08:49:28 -0800 (PST) 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 S1754798AbbATQlr (ORCPT + 28 others); Tue, 20 Jan 2015 11:41:47 -0500 Received: from mail-ie0-f180.google.com ([209.85.223.180]:56734 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752380AbbATQlo (ORCPT ); Tue, 20 Jan 2015 11:41:44 -0500 Received: by mail-ie0-f180.google.com with SMTP id rl12so3524321iec.11 for ; Tue, 20 Jan 2015 08:41:44 -0800 (PST) X-Received: by 10.50.18.49 with SMTP id t17mr27754805igd.3.1421772103962; Tue, 20 Jan 2015 08:41:43 -0800 (PST) Received: from ip-10-181-65-231.ec2.internal ([54.235.93.228]) by mx.google.com with ESMTPSA id q7sm3117924igx.9.2015.01.20.08.41.42 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 08:41:43 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , Feng Tang , John Stultz , Arnd Bergmann , Xunlei Pang Subject: [PATCH 1/3] time: Don't bother to run rtc_resume() for nonstop clocksource Date: Tue, 20 Jan 2015 16:41:28 +0000 Message-Id: <1421772090-13113-1-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.2.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@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.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: , If a system does not provide a persistent_clock(), the time will be updated on resume by rtc_resume(). With the addition of the non-stop clocksources for suspend timing, those systems set the time on resume in timekeeping_resume(), but may not provide a valid persistent_clock(). This results in the rtc_resume() logic thinking no one has set the time and it then will over-write the suspend time again, which is not necessary and only increases clock error. So, fix this for rtc_resume(). Signed-off-by: Xunlei Pang --- drivers/rtc/class.c | 2 +- include/linux/timekeeping.h | 11 +++++++++++ kernel/time/timekeeping.c | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 472a5ad..c8f35a5 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -102,7 +102,7 @@ static int rtc_resume(struct device *dev) struct timespec64 sleep_time; int err; - if (has_persistent_clock()) + if (rtc_resume_skip()) return 0; rtc_hctosys_ret = -ENODEV; diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 9b63d13..6f3283b 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -238,6 +238,17 @@ extern void getnstime_raw_and_real(struct timespec *ts_raw, */ extern bool persistent_clock_exist; extern int persistent_clock_is_local; +extern bool suspendtime_found; + +#ifdef CONFIG_RTC_LIB +/* Used by rtc_resume() */ +static inline bool rtc_resume_skip(void) +{ + return suspendtime_found; +} +#else +static inline void rtc_resume_skip(void) { } +#endif static inline bool has_persistent_clock(void) { diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6a93185..586bb5c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -65,6 +65,7 @@ int __read_mostly timekeeping_suspended; /* Flag for if there is a persistent clock on this platform */ bool __read_mostly persistent_clock_exist = false; +bool suspendtime_found; static inline void tk_normalize_xtime(struct timekeeper *tk) { @@ -1178,8 +1179,8 @@ static void timekeeping_resume(void) struct timespec64 ts_new, ts_delta; struct timespec tmp; cycle_t cycle_now, cycle_delta; - bool suspendtime_found = false; + suspendtime_found = false; read_persistent_clock(&tmp); ts_new = timespec_to_timespec64(tmp);