From patchwork Wed Oct 28 20:59:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 37132 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 1B77F100D2C for ; Thu, 29 Oct 2009 08:52:32 +1100 (EST) Received: by ozlabs.org (Postfix) id 097C6B7B93; Thu, 29 Oct 2009 08:52:24 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e35.co.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 9FBADB7B77 for ; Thu, 29 Oct 2009 08:52:23 +1100 (EST) Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e35.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9SKmTew023540 for ; Wed, 28 Oct 2009 14:48:29 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n9SKxY0k148666 for ; Wed, 28 Oct 2009 14:59:38 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id n9SKxX0H000970 for ; Wed, 28 Oct 2009 14:59:33 -0600 Received: from [9.53.40.155] (mudbug-009053040155.austin.ibm.com [9.53.40.155]) by d03av01.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id n9SKxVNa000734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 Oct 2009 14:59:33 -0600 Message-ID: <4AE8B0B1.4020102@austin.ibm.com> Date: Wed, 28 Oct 2009 15:59:29 -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 6/6 v5] CPU DLPAR Handling 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 Register the pseries specific handler for the powerpc architecture handlers for the cpu probe and release files. This also implements the cpu DLPAR addition and removal of CPUS from the system. Signed-off-by: Nathan Fontenot Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c =================================================================== --- powerpc.orig/arch/powerpc/platforms/pseries/dlpar.c 2009-10-28 15:21:49.000000000 -0500 +++ powerpc/arch/powerpc/platforms/pseries/dlpar.c 2009-10-28 15:21:56.000000000 -0500 @@ -1,11 +1,10 @@ /* - * dlpar.c - support for dynamic reconfiguration (including PCI - * Hotplug and Dynamic Logical Partitioning on RPA platforms). + * Support for dynamic reconfiguration (including PCI, Memory, and CPU + * Hotplug and Dynamic Logical Partitioning on PAPR platforms). * * Copyright (C) 2009 Nathan Fontenot * Copyright (C) 2009 IBM Corporation * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. @@ -19,7 +18,7 @@ #include #include #include - +#include #include #include @@ -408,6 +407,80 @@ return 0; } +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE +static ssize_t cpu_probe(const char *buf, size_t count) +{ + struct device_node *dn; + unsigned long drc_index; + char *cpu_name; + int rc; + + rc = strict_strtoul(buf, 0, &drc_index); + if (rc) + return -EINVAL; + + rc = acquire_drc(drc_index); + if (rc) + return -EINVAL; + + dn = configure_connector(drc_index); + if (!dn) { + release_drc(drc_index); + return -EINVAL; + } + + /* fixup dn name */ + cpu_name = kzalloc(strlen(dn->full_name) + strlen("/cpus/") + 1, + GFP_KERNEL); + if (!cpu_name) { + free_cc_nodes(dn); + release_drc(drc_index); + return -ENOMEM; + } + + sprintf(cpu_name, "/cpus/%s", dn->full_name); + kfree(dn->full_name); + dn->full_name = cpu_name; + + rc = add_device_tree_nodes(dn); + if (rc) + release_drc(drc_index); + + return rc ? -EINVAL : count; +} + +static ssize_t cpu_release(const char *buf, size_t count) +{ + struct device_node *dn; + const u32 *drc_index; + int rc; + + dn = of_find_node_by_path(buf); + if (!dn) + return -EINVAL; + + drc_index = of_get_property(dn, "ibm,my-drc-index", NULL); + if (!drc_index) { + of_node_put(dn); + return -EINVAL; + } + + rc = release_drc(*drc_index); + if (rc) { + of_node_put(dn); + return -EINVAL; + } + + rc = remove_device_tree_nodes(dn); + if (rc) + acquire_drc(*drc_index); + + of_node_put(dn); + return rc ? -EINVAL : count; +} + +#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ + #ifdef CONFIG_MEMORY_HOTPLUG static struct property *clone_property(struct property *old_prop) @@ -591,6 +664,11 @@ ppc_md.memory_probe = memory_probe; #endif +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE + ppc_md.cpu_release = cpu_release; + ppc_md.cpu_probe = cpu_probe; +#endif + return 0; } device_initcall(pseries_dlpar_init);