Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3126934imm; Tue, 29 May 2018 01:16:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJSpJGIF3EmJt3lnwccdpc+z/KgWYmix6cGftVWvOH5CFIlvE6CW+YLQbCF17IP24DhhWKx X-Received: by 2002:a17:902:b683:: with SMTP id c3-v6mr7381407pls.158.1527581773890; Tue, 29 May 2018 01:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527581773; cv=none; d=google.com; s=arc-20160816; b=fUDFA8bEWJx3fUOigT1ltWQoYQvhA/CB/e1zJUG4QOLNMRRVGEZHvZHeDhjL6rqLBO 3ULhP1fEQHJvQGyomv9I8pb13n7L8o3urJ26/kNaU1aCJaYq0fP6teFCoozGNYuILRUs 3wLPZY0ZzLW1PsQvn4bC7SDoFofWVrLQmFDCx6M2WWtO0EU8ivcgTOWod708tlgre0D3 h9DGuk6N00Z7LKg+k/3TQonM9GhaXMAV8FRc/MfWWCKrquMXtdvL9wfw+vbEvyLDxJkS 5bwBUm1WoTYd1qsYu4rJbsLlPIj2lWdzWU/j/pr29lpYdrr4bhis5oGMGJRAmfpoPpoV xfxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=DtSz4qK/52Idofk1PhfpNOPtOctqYQhA1ZhtW9afpg8=; b=BDcvLhKt+kex5FYYA3RDIOzldKe3IGqbu9lMmak5klTOHrAvqoLDICjdy+3HJCePTm k8HUftQMTZk9dwErvJ9wCSDupBuhMQ97u4NE8MXzaQHQFwoakeW/3fDLFsUtX1d3mNVy Ib7bBs+4KR13wUNTBjI3E90S8TuLGp4Iqkf+VcOaIXLGqYLuJfcVXvipdRDzp5S0Y6Gr He+9zrMm37jP9O5rpGOh4rzvDeWQrTiheZcNxjv4p8gdkfqts2ovOCh7oUYv/oNQfSd/ K4l8di7eYAm0eKxCSEbEpCpHaedd975/eGyMpJZiMYkb4E8dBp5zJ9Qtm3GIAg63lLXq gMyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Q9vuMJZw; dkim=pass header.i=@codeaurora.org header.s=default header.b=Q9vuMJZw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8-v6si32037150plk.539.2018.05.29.01.15.59; Tue, 29 May 2018 01:16:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Q9vuMJZw; dkim=pass header.i=@codeaurora.org header.s=default header.b=Q9vuMJZw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932201AbeE2IPg (ORCPT + 99 others); Tue, 29 May 2018 04:15:36 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51452 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754919AbeE2IPb (ORCPT ); Tue, 29 May 2018 04:15:31 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B2E366038E; Tue, 29 May 2018 08:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527581730; bh=Y+SZv2Y5zz45rmAbkYO+Iiz2xArImVn41idg9JsDq7w=; h=From:To:Cc:Subject:Date:From; b=Q9vuMJZwhCYF/oLhY2C+vzqODDZFjoqr2RDICGSqcxBzKTgCRTK4Sq+hqjK7kFf95 M/l4XUP+GXpQAEfdqXQW0LnrReCvkvabOJBXa4N3rdofcuS9du5uhtMjDNF6YggbTQ C15nzEQ+ZRHA+3DjEx5PCByi685k6BDZzQjbHn7I= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mojha-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mojha@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B16B56028C; Tue, 29 May 2018 08:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527581730; bh=Y+SZv2Y5zz45rmAbkYO+Iiz2xArImVn41idg9JsDq7w=; h=From:To:Cc:Subject:Date:From; b=Q9vuMJZwhCYF/oLhY2C+vzqODDZFjoqr2RDICGSqcxBzKTgCRTK4Sq+hqjK7kFf95 M/l4XUP+GXpQAEfdqXQW0LnrReCvkvabOJBXa4N3rdofcuS9du5uhtMjDNF6YggbTQ C15nzEQ+ZRHA+3DjEx5PCByi685k6BDZzQjbHn7I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B16B56028C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mojha@codeaurora.org From: Mukesh Ojha To: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mukesh Ojha Subject: [PATCH] time: Fix sleeptime injection for non-stop clocksource & persistent clock Date: Tue, 29 May 2018 13:45:18 +0530 Message-Id: <1527581718-5624-1-git-send-email-mojha@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, for both non-stop clocksource and persistent clock there is a corner case, when a driver failed to go suspend mode rtc_resume injects the sleeptime as timekeeping_rtc_skipresume returned 'false' due to which we can see mismatch in time with system clock. Success case: {sleeptime_injected=true} rtc_suspend() => timekeeping_suspend() => timekeeping_resume() => rtc_resume() Failure case: {failure in sleep path} {sleeptime_injected=false} rtc_suspend() => rtc_resume() Change-Id: I98928761c98cec21a3033a55d3e10fb34138f38c Signed-off-by: Mukesh Ojha --- kernel/time/timekeeping.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 427e33d..c022d82 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1511,9 +1511,6 @@ void __weak read_boot_clock64(struct timespec64 *ts) ts->tv_nsec = 0; } -/* Flag for if timekeeping_resume() has injected sleeptime */ -static bool sleeptime_injected; - /* Flag for if there is a persistent clock on this platform */ static bool persistent_clock_exists; @@ -1611,7 +1608,14 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, */ bool timekeeping_rtc_skipresume(void) { - return sleeptime_injected; + struct timekeeper *tk = &tk_core.timekeeper; + bool skip_rtc_resume = false; + + skip_rtc_resume = ((tk->tkr_mono.clock->flags & + CLOCK_SOURCE_SUSPEND_NONSTOP) || + (persistent_clock_exists)) ? true : false; + + return skip_rtc_resume; } /** @@ -1671,8 +1675,8 @@ void timekeeping_resume(void) unsigned long flags; struct timespec64 ts_new, ts_delta; cycle_t cycle_now, cycle_delta; + bool sleeptime_injected = false; - sleeptime_injected = false; read_persistent_clock64(&ts_new); clockevents_resume(); -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project