From patchwork Wed Oct 28 20:58:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 37134 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id A51B1100C86 for ; Thu, 29 Oct 2009 08:53:29 +1100 (EST) Received: by ozlabs.org (Postfix) id EF18610082B; Thu, 29 Oct 2009 08:53:19 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e36.co.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 611B41007E9 for ; Thu, 29 Oct 2009 08:53:19 +1100 (EST) Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e36.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9SKuWg6024417 for ; Wed, 28 Oct 2009 14:56:32 -0600 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9SKwUlq149414 for ; Wed, 28 Oct 2009 14:58:35 -0600 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id n9SKwUuW002549 for ; Wed, 28 Oct 2009 14:58:30 -0600 Received: from [9.53.40.155] (mudbug-009053040155.austin.ibm.com [9.53.40.155]) by d03av05.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id n9SKwSxC002467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 Oct 2009 14:58:30 -0600 Message-ID: <4AE8B072.1070603@austin.ibm.com> Date: Wed, 28 Oct 2009 15:58:26 -0500 From: Nathan Fontenot User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6 v5] CPU probe/release files References: <4AE8ADCF.6090104@austin.ibm.com> In-Reply-To: <4AE8ADCF.6090104@austin.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Create new probe and release sysfs files to facilitate adding and removing cpus from the system. This also creates the powerpc specific stubs to handle the arch callouts from writes to the sysfs files. The creation and use of these files is regulated by the CONFIG_ARCH_CPU_PROBE_RELEASE option so that only architectures that need the capability will have the files created. Signed-off-by: Nathan Fontenot Index: powerpc/drivers/base/cpu.c =================================================================== --- powerpc.orig/drivers/base/cpu.c 2009-10-28 15:20:34.000000000 -0500 +++ powerpc/drivers/base/cpu.c 2009-10-28 15:21:53.000000000 -0500 @@ -54,6 +54,7 @@ ret = count; return ret; } + static SYSDEV_ATTR(online, 0644, show_online, store_online); static void __cpuinit register_cpu_control(struct cpu *cpu) @@ -72,6 +73,38 @@ per_cpu(cpu_sys_devices, logical_cpu) = NULL; return; } + +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE +static ssize_t cpu_probe_store(struct class *class, const char *buf, + size_t count) +{ + return arch_cpu_probe(buf, count); +} + +static ssize_t cpu_release_store(struct class *class, const char *buf, + size_t count) +{ + return arch_cpu_release(buf, count); +} + +static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); +static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); + +int __init cpu_probe_release_init(void) +{ + int rc; + + rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, + &class_attr_probe.attr); + if (!rc) + rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, + &class_attr_release.attr); + + return rc; +} +device_initcall(cpu_probe_release_init); +#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ + #else /* ... !CONFIG_HOTPLUG_CPU */ static inline void register_cpu_control(struct cpu *cpu) { Index: powerpc/arch/powerpc/include/asm/machdep.h =================================================================== --- powerpc.orig/arch/powerpc/include/asm/machdep.h 2009-10-28 15:21:47.000000000 -0500 +++ powerpc/arch/powerpc/include/asm/machdep.h 2009-10-28 15:21:53.000000000 -0500 @@ -274,6 +274,11 @@ int (*memory_probe)(u64); #endif +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE + ssize_t (*cpu_probe)(const char *, size_t); + ssize_t (*cpu_release)(const char *, size_t); +#endif + }; extern void e500_idle(void); Index: powerpc/arch/powerpc/kernel/sysfs.c =================================================================== --- powerpc.orig/arch/powerpc/kernel/sysfs.c 2009-10-28 15:20:34.000000000 -0500 +++ powerpc/arch/powerpc/kernel/sysfs.c 2009-10-28 15:21:53.000000000 -0500 @@ -461,6 +461,25 @@ cacheinfo_cpu_offline(cpu); } + +#ifdef CONFIG_ARCH_PROBE_RELEASE +ssize_t arch_cpu_probe(const char *buf, size_t count) +{ + if (ppc_md.cpu_probe) + return ppc_md.cpu_probe(buf, count); + + return -EINVAL; +} + +ssize_t arch_cpu_release(const char *buf, size_t count) +{ + if (ppc_md.cpu_release) + return ppc_md.cpu_release(buf, count); + + return -EINVAL; +} +#endif /* CONFIG_ARCH_PROBE_RELEASE */ + #endif /* CONFIG_HOTPLUG_CPU */ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self, Index: powerpc/arch/powerpc/Kconfig =================================================================== --- powerpc.orig/arch/powerpc/Kconfig 2009-10-28 15:21:47.000000000 -0500 +++ powerpc/arch/powerpc/Kconfig 2009-10-28 15:21:53.000000000 -0500 @@ -320,6 +320,10 @@ Say N if you are unsure. +config ARCH_CPU_PROBE_RELEASE + def_bool y + depends on HOTPLUG_CPU + config ARCH_ENABLE_MEMORY_HOTPLUG def_bool y Index: powerpc/include/linux/cpu.h =================================================================== --- powerpc.orig/include/linux/cpu.h 2009-10-28 15:20:34.000000000 -0500 +++ powerpc/include/linux/cpu.h 2009-10-28 15:21:53.000000000 -0500 @@ -43,6 +43,10 @@ #ifdef CONFIG_HOTPLUG_CPU extern void unregister_cpu(struct cpu *cpu); +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE +extern ssize_t arch_cpu_probe(const char *, size_t); +extern ssize_t arch_cpu_release(const char *, size_t); +#endif #endif struct notifier_block; Index: powerpc/arch/powerpc/kernel/smp.c =================================================================== --- powerpc.orig/arch/powerpc/kernel/smp.c 2009-10-28 15:20:34.000000000 -0500 +++ powerpc/arch/powerpc/kernel/smp.c 2009-10-28 15:21:53.000000000 -0500 @@ -364,7 +364,24 @@ set_cpu_online(cpu, true); local_irq_enable(); } + +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE +ssize_t arch_cpu_probe(const char *buf, size_t count) +{ + if (ppc_md.cpu_probe) + return ppc_md.cpu_probe(buf, count); + + return -EINVAL; +} +ssize_t arch_cpu_release(const char *buf, size_t count) +{ + if (ppc_md.cpu_release) + return ppc_md.cpu_release(buf, count); + + return -EINVAL; +} #endif +#endif /* CONFIG_HOTPLUG_CPU */ static int __devinit cpu_enable(unsigned int cpu) {