Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp646519imm; Tue, 15 May 2018 07:09:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoqNsy9NN8W7YxW7xvcjpHWTUBDzfzGnAABhiEBvq+/770TDbjCT/XrdYaO1zPYkFP03QQK X-Received: by 2002:a17:902:4603:: with SMTP id o3-v6mr15142310pld.49.1526393341285; Tue, 15 May 2018 07:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526393340; cv=none; d=google.com; s=arc-20160816; b=LBPYbJ53EyW8WA30xrsiY2JnOVz1k6CPBdrTCybc/eUZgpdizUzgyr1HYo0sqcBG6r tP6Jnr8z5e4x4AyuRn/pLl7KaoC5Ny73dbZSvjAaBw83fN3yvCGkdZU2G0ZoEq/NV+HJ f6tUV0zvKOhM7tGONCNT2lCOg27bO5eobwnST/za2ebtqDpaBryYsQjtflmx5UGwNi6W pZnvmFvFJtxV1jlcFuqWbK9uRzbtYSF1Z9Z+WAmxGHM4tWJZkkQTvL6vmz18eumL5aZb hhIQWQtmgBreOtGXN1KhMmyF+emYenXhF70U2m5HZIOD01mzC5x7nJVphmGpUcVbrTT9 2MpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=ueg7auepDmlUY3OPmWquc+zeC96SSuDdbuoWriLwMYU=; b=sRNA7qJ1yVq9XYFzfHE58QqaWJnxeHYWRBroqUIpAW+e5QuwQ8BZ1C9q0ttopb11BX DQ1gRV5GmjjfpHorFpnmSjMRgRuEAY+Avz+UjWnKAsC7uOxiCD0Uygf3+lI5780Q2X6I tGjcs/VNvayuTA/t5Bh0DyAjQA68AbCKuFKfC+5NEkt3yD6FW5/5ihsnSuao/BIvpaWl u6UQVPvYTgOTmi5WbpZMbS2nHyJS9/Hkpws1GD86P3a3I9n+m7InurGzbRY9LtZ9tINi TCWA35QnBD/f/kmqloRjGI/gkcK+yUSfaFgB9jvEgbS9jDa0EsdqtR0LQaxAJ4WpUL9t B4xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UcP0/aQC; 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 u11-v6si87956pgp.480.2018.05.15.07.08.40; Tue, 15 May 2018 07:09:00 -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=UcP0/aQC; 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 S1753955AbeEON4U (ORCPT + 99 others); Tue, 15 May 2018 09:56:20 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40586 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbeEON4S (ORCPT ); Tue, 15 May 2018 09:56:18 -0400 Received: by mail-wm0-f68.google.com with SMTP id j5-v6so1282736wme.5 for ; Tue, 15 May 2018 06:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ueg7auepDmlUY3OPmWquc+zeC96SSuDdbuoWriLwMYU=; b=UcP0/aQCDQYUeVi2fBPwdCKTBiNcm0VS+IBojh6EBfaglmTjrtVeVEIqn4hpqJPRvk Uza5Srv3uGvz7XrGlDGt41zci5o8Uwt4kojdEYrw9qsKg2yWlMibFaQ/Ce8pLwWlbmy8 +DdR5x+ddLMMBOvYt1hJbKH0nTz6svH2noix4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ueg7auepDmlUY3OPmWquc+zeC96SSuDdbuoWriLwMYU=; b=cb57Fgl/tE6Nli+u8DxHKKpZ3MhezpTNf90GSP6R08OklV7dimz3g/GxszdGdG9au8 NoCypYUJhZmhuS4xO5+Hzh9KezYahmmRIIXeXTFru4D2SNcqzJgn+tYes+6YOk20JILB R6o3/T8bUiuemYZcPtcRg88HQwl48ErHhc1L2HCQ0W2bga0wLPzWeHO5cpypBE+VaMrm eITCIbDZePMHlG/OX6QNWGcdJK3vBWu9zG/dC/sndfnnjy2eAUBWz/wW6AWqb1vAsp4C 3Zrtcusmch2xOGPyFnc5Afl7S/R7mHpDPeGYzrOvgjmf1Kk6RPHZtbZ+nFt3v52HbB+/ OZ+Q== X-Gm-Message-State: ALKqPweU/wwEBp/vW05SaDH9PurCzuvNKJcZ1PIN9tUqqQy2SgA8Y/Jg 2RHiQyF3WqjalWQsZTzHT8jd+g== X-Received: by 2002:a1c:bf52:: with SMTP id p79-v6mr7928319wmf.43.1526392576566; Tue, 15 May 2018 06:56:16 -0700 (PDT) Received: from mai (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.gmail.com with ESMTPSA id 4-v6sm677429wmg.40.2018.05.15.06.56.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 06:56:15 -0700 (PDT) Date: Tue, 15 May 2018 15:56:12 +0200 From: Daniel Lezcano To: Baolin Wang Cc: tglx@linutronix.de, john.stultz@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: Re: [RFC PATCH 00/10] Add persistent clock support Message-ID: <20180515135612.GQ29062@mai> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 14, 2018 at 04:55:26PM +0800, Baolin Wang wrote: > Hi, > > We will meet below issues when compensating the suspend time for the timekeeping. > > 1. We have too many different ways of dealing with persistent timekeeping > across architectures, so it is hard for one driver to compatable with different > architectures. > > 2. On some platforms (such as Spreadtrum platform), we registered the high > resolution timer as one clocksource to update the OS time, but the high > resolution timer will be stopped in suspend state. So we use another one > always-on timer (but low resolution) to calculate the suspend time to > compensate the OS time. Though we can register the always-on timer as one > clocksource, we need re-calculate the mult/shift with one larger conversion > range to calculate the suspend time and need update the clock in case of > running over the always-on timer. > > More duplicate code will be added if other platforms meet this case. > > 3. Now we have 3 sources that could be used to compensate the OS time: > Nonstop clocksource during suspend, persistent clock and rtc device, > which is complicated. Another hand is that the nonstop clocksource can > risk wrapping if the suspend time is too long, so we need one mechanism > to wake up the system before the nonstop clocksource wrapping. > > According to above issues, we can introduce one common persistent clock > framework to compatable with different architectures, in future we will > remove the persistent clock implementation for each architecture. Also > this framework will implement common code to help drivers to register easily. > Moreover if we converted all SUSPEND_NONSTOP clocksource to register to > be one persistent clock, we can remove the SUSPEND_NONSTOP clocksource > accounting in timekeeping, which means we can only compensate the OS time > from persistent clock and RTC. > > Will be appreciated for any comments. Thank you all. Why do we need another API ? Why not remove the present persistent API and rely on the SUSPEND_NONSTOP flag to do the right action at suspend and resume? We register different clocksources, the rating does the selection. When entering 'suspend', we check against the SUSPEND_NONSTOP flag and switch to the first clocksource with the best rating and the flag set. When resuming, we switch back to the highest rating. Having a clocksource out of the always-on domain must be notified with a trace in the log because this is not a normal situation. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog