Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175825
b: refs/heads/master
c: b6db63d
h: refs/heads/master
i:
  175823: b1c8e5f
v: v3
  • Loading branch information
Gautham R Shenoy authored and Benjamin Herrenschmidt committed Dec 9, 2009
1 parent 76224d1 commit 2eb680e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8389b37dffdc695b4fb363ebe0ed9748bb3b48d0
refs/heads/master: b6db63d1a7f0138f348ba7a648df35ac6365988e
101 changes: 101 additions & 0 deletions trunk/arch/powerpc/platforms/pseries/dlpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
#include <linux/cpu.h>
#include "offline_states.h"

#include <asm/prom.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -287,6 +288,98 @@ int dlpar_detach_node(struct device_node *dn)
return 0;
}

int online_node_cpus(struct device_node *dn)
{
int rc = 0;
unsigned int cpu;
int len, nthreads, i;
const u32 *intserv;

intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len);
if (!intserv)
return -EINVAL;

nthreads = len / sizeof(u32);

cpu_maps_update_begin();
for (i = 0; i < nthreads; i++) {
for_each_present_cpu(cpu) {
if (get_hard_smp_processor_id(cpu) != intserv[i])
continue;
BUG_ON(get_cpu_current_state(cpu)
!= CPU_STATE_OFFLINE);
cpu_maps_update_done();
rc = cpu_up(cpu);
if (rc)
goto out;
cpu_maps_update_begin();

break;
}
if (cpu == num_possible_cpus())
printk(KERN_WARNING "Could not find cpu to online "
"with physical id 0x%x\n", intserv[i]);
}
cpu_maps_update_done();

out:
return rc;

}

int offline_node_cpus(struct device_node *dn)
{
int rc = 0;
unsigned int cpu;
int len, nthreads, i;
const u32 *intserv;

intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len);
if (!intserv)
return -EINVAL;

nthreads = len / sizeof(u32);

cpu_maps_update_begin();
for (i = 0; i < nthreads; i++) {
for_each_present_cpu(cpu) {
if (get_hard_smp_processor_id(cpu) != intserv[i])
continue;

if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE)
break;

if (get_cpu_current_state(cpu) == CPU_STATE_ONLINE) {
cpu_maps_update_done();
rc = cpu_down(cpu);
if (rc)
goto out;
cpu_maps_update_begin();
break;

}

/*
* The cpu is in CPU_STATE_INACTIVE.
* Upgrade it's state to CPU_STATE_OFFLINE.
*/
set_preferred_offline_state(cpu, CPU_STATE_OFFLINE);
BUG_ON(plpar_hcall_norets(H_PROD, intserv[i])
!= H_SUCCESS);
__cpu_die(cpu);
break;
}
if (cpu == num_possible_cpus())
printk(KERN_WARNING "Could not find cpu to offline "
"with physical id 0x%x\n", intserv[i]);
}
cpu_maps_update_done();

out:
return rc;

}

#define DR_ENTITY_SENSE 9003
#define DR_ENTITY_PRESENT 1
#define DR_ENTITY_UNUSABLE 2
Expand Down Expand Up @@ -385,6 +478,8 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
dlpar_free_cc_nodes(dn);
}

rc = online_node_cpus(dn);

return rc ? rc : count;
}

Expand All @@ -404,6 +499,12 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
return -EINVAL;
}

rc = offline_node_cpus(dn);
if (rc) {
of_node_put(dn);
return -EINVAL;
}

rc = dlpar_release_drc(*drc_index);
if (rc) {
of_node_put(dn);
Expand Down

0 comments on commit 2eb680e

Please sign in to comment.