Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2764682imm; Mon, 16 Jul 2018 13:51:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFV890uVd4zSCrrOsoJDXBL1/PgUx3Ebf+Jp+fi1sURzmPZZfV3vFJKK86NPwa0P6r1tcV X-Received: by 2002:a62:1219:: with SMTP id a25-v6mr19528045pfj.104.1531774291094; Mon, 16 Jul 2018 13:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531774291; cv=none; d=google.com; s=arc-20160816; b=hxqWfUi3HRvC9F08H+2ATdMaXW8oDMIGxgk5lB+Fh7S8JirDlhLn5QT8UJ5kIawCUn rZkcgdS42Lwg2hhu2IvDupqbX5YcrLWhcQj1Nw7Dm0cmHdc7PDNFoXpJKuotdfCxU9dZ 8ilFD97n5Pe1jFEzkmPiPdY27REzKPA9See6KWpxI9rMF/FmShx5wqLdwkO+/amZlqGA YPBEI8OXmueiYRGipCOGDDk/VyGlzJzI7ldYUykdbscHK+z+vRcFhjUbYR0VUPs5ftyf t73+Br9xMXPQZ/lNxhTPl+3VOJGYrAy+Ym3r6BzFs8O1R2fo62vsClGRrrRwP1jEkI4/ DMfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=Gj4tQSjs1cblqdCn8jWCRpTSDL56BXx36HSdocBIyhQ=; b=whddoblziudvztsGFxUfze1J1F770yDy1wld0Ae/m3Y4Ath9jKVrjTZyseTfxe4bTP o9zLaaGfRroz34gWIWmnm54BUZqnfv3UutFGEu8cFdtuDItdNSTTf8uGtcBTuOUDsZnP FL3IbeE/cJu9uDBoIuyBGsX0EHVEQX4a7aT0MNp+2H13cWT9r/GiYoGpIkYF88MxHb6k wvXWeU9s+RiQTfAFZkPQxI7F7yI6nJj9a+N22XMMlVGN4LZFMDqDBy2PPEO5m37vlNI+ XDmYoVQQk7Iow0LPRuoT+6u2pFrrlNPQ6U9/tkQC+cG0fWe3QGdVH+7m0gV/TMnvXfPC Qugw== ARC-Authentication-Results: i=1; mx.google.com; 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 z28-v6si30867765pfa.161.2018.07.16.13.51.16; Mon, 16 Jul 2018 13:51:31 -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; 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 S1728787AbeGPVTt (ORCPT + 99 others); Mon, 16 Jul 2018 17:19:49 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:53275 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728123AbeGPVTt (ORCPT ); Mon, 16 Jul 2018 17:19:49 -0400 Received: from p4fea5a5a.dip0.t-ipconnect.de ([79.234.90.90] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ffAS7-0004AM-3T; Mon, 16 Jul 2018 22:50:39 +0200 Date: Mon, 16 Jul 2018 22:50:38 +0200 (CEST) From: Thomas Gleixner To: Mukesh Ojha cc: john.stultz@linaro.org, linux-kernel@vger.kernel.org, gkohli@codeaurora.org, cpandya@codeaurora.org, neeraju@codeaurora.org Subject: Re: [PATCH v4] time: Fix extra sleeptime injection when suspend fails In-Reply-To: <1531773650-30424-1-git-send-email-mojha@codeaurora.org> Message-ID: References: <1531773650-30424-1-git-send-email-mojha@codeaurora.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Jul 2018, Mukesh Ojha wrote: > @@ -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()) > return 0; That does not make any sense at all, really. > /* Flag for if there is a persistent clock on this platform */ > static bool persistent_clock_exists; > @@ -1610,7 +1622,7 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, > */ > bool timekeeping_rtc_skipresume(void) > { > - return sleeptime_injected; > + return suspend_timing_needed; Just make this !suspend_timing_needed and the function name and its return value still makes sense. > @@ -1701,13 +1714,13 @@ void timekeeping_resume(void) > tk->tkr_mono.mask); > nsec = mul_u64_u32_shr(cyc_delta, clock->mult, clock->shift); > ts_delta = ns_to_timespec64(nsec); > - sleeptime_injected = true; > + suspend_timing_needed = false; > } else if (timespec64_compare(&ts_new, &timekeeping_suspend_time) > 0) { > ts_delta = timespec64_sub(ts_new, timekeeping_suspend_time); > - sleeptime_injected = true; > + suspend_timing_needed = false; > } > > - if (sleeptime_injected) > + if (!suspend_timing_needed) > __timekeeping_inject_sleeptime(tk, &ts_delta); This reads odd as well. I'd rather keep a local variable inject_sleeptime or such and set that in the code pathes above. if (...) { ... inject_sleeptime = true; } else if (...) { ... inject_sleeptime = true; } if (inject_sleeptime) { suspend_timing_needed = false; __timekeeping_inject_sleeptime(); } Hmm? Just blindly converting everything results in functional, but nonsensical code. Think about what happens when you look at that stuff 6 month from now... Thanks, tglx