From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751830AbcFYQxH (ORCPT ); Sat, 25 Jun 2016 12:53:07 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:45524 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbcFYQxE (ORCPT ); Sat, 25 Jun 2016 12:53:04 -0400 Date: Sat, 25 Jun 2016 18:53:02 +0200 From: Pavel Machek To: Chen Yu Cc: linux-pm@vger.kernel.org, x86@kernel.org, "Rafael J. Wysocki" , Len Brown , Peter Zijlstra , "H. Peter Anvin" , Borislav Petkov , Brian Gerst , Thomas Gleixner , Ingo Molnar , Varun Koyyalagunta , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/4][RFC v2] PM / hibernate: introduce a flag to indicate resuming from hibernation Message-ID: <20160625165302.GC4362@amd> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 2016-06-26 00:18:52, Chen Yu wrote: > Sometime we need to do some operations before resuming from > hibernation, so introduce a flag to indicate this stage. > > Signed-off-by: Chen Yu > --- > include/linux/suspend.h | 7 +++++++ > kernel/power/hibernate.c | 3 +++ > 2 files changed, 10 insertions(+) > > diff --git a/include/linux/suspend.h b/include/linux/suspend.h > index 8b6ec7e..422e87a 100644 > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -384,6 +384,12 @@ extern bool system_entering_hibernation(void); > extern bool hibernation_available(void); > asmlinkage int swsusp_save(void); > extern struct pbe *restore_pblist; > +extern bool in_resume_hibernate; in_resume_hibernation? But it is pretty sad if we need another such state function... Pavel > +static inline bool hibernation_in_resume(void) > +{ > + return in_resume_hibernate; > +} > #else /* CONFIG_HIBERNATION */ > static inline void register_nosave_region(unsigned long b, unsigned long e) {} > static inline void register_nosave_region_late(unsigned long b, unsigned long e) {} > @@ -395,6 +401,7 @@ static inline void hibernation_set_ops(const struct platform_hibernation_ops *op > static inline int hibernate(void) { return -ENOSYS; } > static inline bool system_entering_hibernation(void) { return false; } > static inline bool hibernation_available(void) { return false; } > +static inline bool hibernation_in_resume(void) { return false; } > #endif /* CONFIG_HIBERNATION */ > > /* Hibernation and suspend events */ > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index fca9254..41be909 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -43,6 +43,7 @@ static char resume_file[256] = CONFIG_PM_STD_PARTITION; > dev_t swsusp_resume_device; > sector_t swsusp_resume_block; > __visible int in_suspend __nosavedata; > +bool in_resume_hibernate; > > enum { > HIBERNATION_INVALID, > @@ -433,6 +434,7 @@ static int resume_target_kernel(bool platform_mode) > if (error) > goto Cleanup; > > + in_resume_hibernate = true; > error = disable_nonboot_cpus(); > if (error) > goto Enable_cpus; > @@ -474,6 +476,7 @@ static int resume_target_kernel(bool platform_mode) > local_irq_enable(); > > Enable_cpus: > + in_resume_hibernate = false; > enable_nonboot_cpus(); > > Cleanup: -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html