From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933121AbcKHMew (ORCPT ); Tue, 8 Nov 2016 07:34:52 -0500 Received: from mga02.intel.com ([134.134.136.20]:32966 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933337AbcKHMeu (ORCPT ); Tue, 8 Nov 2016 07:34:50 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,462,1473145200"; d="scan'208";a="28948030" Date: Tue, 8 Nov 2016 20:43:12 +0800 From: Chen Yu To: x86@kernel.org Cc: Pavel Machek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Thomas Gleixner , Len Brown , John Stultz , Xunlei Pang Subject: Re: [PATCH 2/2][RFC v6] PM / sleep: save/restore RTC time after resumed if pm_trace enabled Message-ID: <20161108124312.GC7191@yu-desktop-1.sh.intel.com> References: <3bf82cf55c4f5ce3286f6c3fc0b2b7e4b2e5ded3.1478589736.git.yu.c.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3bf82cf55c4f5ce3286f6c3fc0b2b7e4b2e5ded3.1478589736.git.yu.c.chen@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, On Tue, Nov 08, 2016 at 05:02:14PM +0800, Chen Yu wrote: > Previously the bogus CMOS RTC sleep time has been ignored if pm_trace > is enabled, however once the system successfully resumed back, > any further read to CMOS RTC would return an error. Actually it is > more user-friendly to bring the system back to normal after resumed. > > This patch has registered an pm notifier to restore the RTC to the > value before been overwitten by pm_trace. > > Cc: "Rafael J. Wysocki" > Cc: Thomas Gleixner > Cc: Len Brown > Cc: John Stultz > Cc: Xunlei Pang > Signed-off-by: Chen Yu > --- Please ignore this version for now, the atomic variable below is unnecessary since pm_trace has disabled the async suspend. And in order to allow the users to adjust rtc after resume, we can clear the pm_trace_rtc_abused directly and warn users of the broken rtc. (Without save/restore). > drivers/base/power/trace.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c > index aa9109a..1e6c611 100644 > --- a/drivers/base/power/trace.c > +++ b/drivers/base/power/trace.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > > #include > > @@ -76,6 +77,11 @@ > > bool pm_trace_rtc_abused __read_mostly; > static unsigned int dev_hash_value; > +struct rtc_time_save { > + struct rtc_time time; > + atomic_t saved; > +}; >