Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2775295imm; Mon, 16 Jul 2018 14:03:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpekJsd/O8ajqXXKWj1zIwqfNqUfBgx3PEiIufUm8+Qj2ae1ClqIzsT1YKIeRgkFwruVr6m9 X-Received: by 2002:a63:842:: with SMTP id 63-v6mr17295451pgi.406.1531775005769; Mon, 16 Jul 2018 14:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531775005; cv=none; d=google.com; s=arc-20160816; b=V1v22OzMnLppDT/pNFF+03w1NqZOeJbCUmvowYDOH8YKgU00nIj8LnBQjz1OFdzqWi yKwXs2XlQVqeLJ8Gr2p1Kr2e2z/wkZccwOTK21SQ5PQq9t66LWSf0/Col6Vb2Jd9ysdu fBmt8k5HYAvTpoAnopkStvNvBKalFvkXExJDCrH9JoDiYxHvLwX84E5VnmwhHFQckAM1 +E23T/e6VLDLwk35tKqzeRSZ/GM1TQalemsRemddyTSBdAZrfQDMPE9pk0H42BtCbhTs xiuVS12kkT2gFZxL3IPujq10KY3LBFevwiI86jFbiMh/Q34y503dxkt+qDnkVSpJuM/Y 539A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=EZNJr0eTyWX+0EudR48uBYNiRNF51MCqerQkoqYyZ9E=; b=VwVZVNktJ+M76Q5YdCAnXCbgEwVQ64gUg/1Kur2TU4jQTiiZbWeWyd9Lgd38Z2bJyA D7jo9yhBtvm/5JMCAIqyF5VTP1JJfSlFAa41tYrJDQX1sGwIMM24CcKmNuHWWaCulJgK w6LE4bTNsR8uyV/zty2U3nPUYdQv64usXInXsObtXUhnr5uxm74pe42GsSYfgKbkbuyY 8ax0RqsbwlmghK6p+KOBoupxeCo2EgFp38NzH0E9CKNaPG8rdaP3jnKCVkGWvr4lYgWQ X9tIRsAtv3bJo1Ghut55pgeRb0Dw+/KxKcOatvnJA5NS32Px2v6PnDH0gk8uAwDfbcX/ DpYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Az0VIVQZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si13047841pgb.107.2018.07.16.14.03.10; Mon, 16 Jul 2018 14:03:25 -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=@linaro.org header.s=google header.b=Az0VIVQZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbeGPVaz (ORCPT + 99 others); Mon, 16 Jul 2018 17:30:55 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39182 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728415AbeGPVay (ORCPT ); Mon, 16 Jul 2018 17:30:54 -0400 Received: by mail-wr1-f65.google.com with SMTP id h10-v6so33257554wre.6 for ; Mon, 16 Jul 2018 14:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=EZNJr0eTyWX+0EudR48uBYNiRNF51MCqerQkoqYyZ9E=; b=Az0VIVQZfEq0jkiaBA1HAotzCTuvNYQ0nrDN9rLp+TJ+fw0+XtwJJB95tOICtWEwu/ rQoEy00IDem9WBMYJCPLcrNEQ69sKoeSXg3oSuSXSqOmgFHKzFMUCAhRZxa9/YeQA7UR +VfW9tJ4uwtJKMPx3fE0etl0NbAyGaWzCrjr8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EZNJr0eTyWX+0EudR48uBYNiRNF51MCqerQkoqYyZ9E=; b=cOPk/PT1vVrj2Nq+TBOvN3djQICOW32r+RUhiGJ0g5lq4U3vZ+0sF8jlVlQHHwKsI/ OESrBWlmPe28IB97womqFt8A2oxyAl7FdB/ZLIynMGPpnLvmGo5ZUYMgLeJgxTNkedid BWnJrEAyN256cZHbJHQ/VcyKyZq+2OPCComzZ4FFl0H5OuIptChxLvtkZr5Lsgf+G8uY 6kNmyDPKbJO5uWCGbS5tXhiumlDGBfr8fAqJbnO9mqg1IEx75L/abon6INhY3mokbROd d/xHBGKD5MewHmXzJFrS/38P61UN5ngWiOMeE0Gi7ZQowdc0jj1Pv6CNyiAy9jD3ITFy bcfA== X-Gm-Message-State: AOUpUlFsa6PyPjo7E3tRz/vXcjJzbHPxnJd955GyENppDWTEHvX58hmp zqSHOBzqPpYzI5ENqo9ot18L0U3n6fhGKHo3dACwVg== X-Received: by 2002:a5d:4b50:: with SMTP id w16-v6mr13034087wrs.87.1531774902106; Mon, 16 Jul 2018 14:01:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:c243:0:0:0:0:0 with HTTP; Mon, 16 Jul 2018 14:01:41 -0700 (PDT) In-Reply-To: <1531773650-30424-1-git-send-email-mojha@codeaurora.org> References: <1531773650-30424-1-git-send-email-mojha@codeaurora.org> From: John Stultz Date: Mon, 16 Jul 2018 14:01:41 -0700 Message-ID: Subject: Re: [PATCH v4] time: Fix extra sleeptime injection when suspend fails To: Mukesh Ojha Cc: Thomas Gleixner , lkml , gkohli@codeaurora.org, cpandya@codeaurora.org, neeraju@codeaurora.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 16, 2018 at 1:40 PM, Mukesh Ojha wrote: > Currently, there exists a corner case assuming when there is > only one clocksource e.g RTC, and system failed to go to > suspend mode. While resume rtc_resume() injects the sleeptime > as timekeeping_rtc_skipresume() returned 'false' (default value > of sleeptime_injected) due to which we can see mismatch in > timestamps. > > This issue can also come in a system where more than one > clocksource are present and very first suspend fails. > > Fix this by handling the sleeptime_injected flag properly. > > Success case: > ------------ > {sleeptime_injected=false} > rtc_suspend() => timekeeping_suspend() => timekeeping_resume() => > > (sleeptime injected) > rtc_resume() > > Failure case: > ------------ > {failure in sleep path} {sleeptime_injected=false} > rtc_suspend() => rtc_resume() > > sleeptime injected again which was not required as the suspend failed) > > Originally-by: Thomas Gleixner > Signed-off-by: Mukesh Ojha > --- > Changes in V4: > * Changes as suggested by John > - Changed the variable name from sleeptime_injected to suspend_timing_needed > - Changed the boolean logic. Thanks so much for reworking and resending this again! > diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c > index d37588f..ee455cc 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 (timekeeping_rtc_skipresume()) > + if (!timekeeping_rtc_skipresume()) Hrm... So I'd have instead inverted the logic *in* timekeeping_rtc_skipresume(), rather then here, but this looks to be close enough and I can fix that bit up. Can you confirm you've validated this version of the patch resolves the issue you reported? thanks -john