From patchwork Thu Jun 6 01:32:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: li guang X-Patchwork-Id: 2676711 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 671A5DF264 for ; Thu, 6 Jun 2013 01:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756600Ab3FFBdx (ORCPT ); Wed, 5 Jun 2013 21:33:53 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:24120 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756582Ab3FFBdw (ORCPT ); Wed, 5 Jun 2013 21:33:52 -0400 X-IronPort-AV: E=Sophos;i="4.87,810,1363104000"; d="scan'208";a="7472792" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 06 Jun 2013 09:30:58 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r561Xjq7031173; Thu, 6 Jun 2013 09:33:48 +0800 Received: from liguang.fnst.cn.fujitsu.com ([10.167.233.147]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013060609320472-1877494 ; Thu, 6 Jun 2013 09:32:04 +0800 From: liguang To: Len Brown , "Rafael J. Wysocki" Cc: Matthew Garrett , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, liguang Subject: [PATCH RFC 1/3] drivers/platform/x86: add cpu physically hotplug driver Date: Thu, 6 Jun 2013 09:32:14 +0800 Message-Id: <1370482336-636-2-git-send-email-lig.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1370482336-636-1-git-send-email-lig.fnst@cn.fujitsu.com> References: <1370482336-636-1-git-send-email-lig.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/06 09:32:04, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/06 09:32:08, Serialize complete at 2013/06/06 09:32:08 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org this driver will support cpu phyical add/removal automatically after online/offline. if cpu hotpluged, cpu will not online automatically, and for cpu offline, we try to do actually eject if allowed for cpu like "echo 1 > /sys/bus/acpi/devices/LNXCPU\:0X/eject" this "echo ..." is only present for recent kernel (sorry, can't figure out since when), for a little older kernel, there's not such approach AFAICS. Signed-off-by: liguang --- drivers/platform/x86/Kconfig | 8 ++++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/cpu_physic_hotplug.c | 60 +++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 drivers/platform/x86/cpu_physic_hotplug.c diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 8577261..39b2392 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -789,4 +789,12 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config QEMU_CPU_PHYSIC_HOTPLUG + tristate "physically add/remove cpu after cpu onlined/offlined" + depends on ACPI_HOTPLUG_CPU + ---help--- + This driver will support physically remove a cpu after + it offlined for QEMU automatically. someone may require this feature + to do a physically removal for a cpu. + endif # X86_PLATFORM_DEVICES diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index ef0ec74..2e669b0 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_PVPANIC) += pvpanic.o +obj-$(CONFIG_QEMU_CPU_PHYSIC_HOTPLUG) += cpu_physic_hotplug.o diff --git a/drivers/platform/x86/cpu_physic_hotplug.c b/drivers/platform/x86/cpu_physic_hotplug.c new file mode 100644 index 0000000..a52c042 --- /dev/null +++ b/drivers/platform/x86/cpu_physic_hotplug.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include + +MODULE_AUTHOR("Li Guang"); +MODULE_DESCRIPTION("CPU physically hot-plug/unplug Driver"); +MODULE_LICENSE("GPL"); + +static int cpu_logic_hotplug_notify(struct notifier_block *nfb, + unsigned long action, void *hcpu) +{ + unsigned int cpu = (unsigned long)hcpu; + struct acpi_processor *pr = per_cpu(processors, cpu); + + if (pr) { + switch (action) { + case CPU_ONLINE: + break; + case CPU_DEAD: + break; + default: + break; + } + } + return NOTIFY_OK; +} + +static struct notifier_block cpu_logic_hotplug_notifier = +{ + .notifier_call = cpu_logic_hotplug_notify, +}; + +static int cpu_physic_hotplug_notify(struct notifier_block *nfb, + unsigned char *s) +{ +} + +static struct notifier_block cpu_physic_hotplug_notifier = +{ + .notifier_call = cpu_physic_hotplug_notify, +}; + +static int __init cpu_qemu_hotplug_init(void) +{ + register_hotcpu_notifier(&cpu_logic_hotplug_notifier); + register_ec_gpe_notifier(&cpu_physic_hotplug_notifier); + return 0; +} + +static void __exit cpu_qemu_hotplug_exit(void) +{ + unregister_hotcpu_notifier(&cpu_logic_hotplug_notifier); + unregister_ec_gpe_notifier(&cpu_physic_hotplug_notifier); +} + +module_init(cpu_qemu_hotplug_init); +module_exit(cpu_qemu_hotplug_exit);