From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933524Ab1KJAvw (ORCPT ); Wed, 9 Nov 2011 19:51:52 -0500 Received: from mga03.intel.com ([143.182.124.21]:32783 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933368Ab1KJAve (ORCPT ); Wed, 9 Nov 2011 19:51:34 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.69,486,1315206000"; d="scan'208";a="35103435" From: "Fenghua Yu" To: "Thomas Gleixner" , "H Peter Anvin" , "Ingo Molnar" , "Linus Torvalds" , "Andrew Morton" , "Tony Luck" , "Arjan van de Ven" , "Suresh B Siddha" , "Len Brown" , "Randy Dunlap" , "Srivatsa S. Bhat" , Peter Zijlstra Cc: "linux-kernel" , "linux-pm" , "x86" , "Fenghua Yu" Subject: [PATCH v3 7/7] x86/power/cpu.c: Don't hibernate/suspend if CPU0 is offline Date: Wed, 9 Nov 2011 16:34:17 -0800 Message-Id: <1320885257-16647-8-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 1.7.2 In-Reply-To: <1320885257-16647-1-git-send-email-fenghua.yu@intel.com> References: <1320885257-16647-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fenghua Yu Because x86 BIOS requires CPU0 to resume from sleep, suspend or hibernate can't be executed if CPU0 is detected offline. Signed-off-by: Fenghua Yu --- arch/x86/power/cpu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index f10c0af..a4ec084 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -236,3 +236,47 @@ void restore_processor_state(void) #ifdef CONFIG_X86_32 EXPORT_SYMBOL(restore_processor_state); #endif + +/* + * When bsp_check() is called in hibernate and suspend, cpu hotplug + * is disabled already. So it's unnessary to handle race condition between + * cpumask query and cpu hotplug. + */ +static int bsp_check(void) +{ + if (cpumask_first(cpu_online_mask) != 0) { + printk(KERN_WARNING "CPU0 is offline.\n"); + return -ENODEV; + } + + return 0; +} + +static int bsp_pm_callback(struct notifier_block *nb, unsigned long action, + void *ptr) +{ + int ret = 0; + + switch (action) { + case PM_SUSPEND_PREPARE: + case PM_HIBERNATION_PREPARE: + ret = bsp_check(); + break; + default: + break; + } + return notifier_from_errno(ret); +} + +static int __init bsp_pm_check_init(void) +{ + /* + * Set this bsp_pm_callback as lower priority than + * cpu_hotplug_pm_callback. So cpu_hotplug_pm_callback will be called + * earlier to disable cpu hotplug before bsp online check. + */ + pm_notifier(bsp_pm_callback, -INT_MAX); + return 0; +} + +core_initcall(bsp_pm_check_init); -- 1.6.0.3