aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char/sclp_quiesce.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/s390/char/sclp_quiesce.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/s390/char/sclp_quiesce.c')
-rw-r--r--drivers/s390/char/sclp_quiesce.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c
new file mode 100644
index 000000000000..83f75774df60
--- /dev/null
+++ b/drivers/s390/char/sclp_quiesce.c
@@ -0,0 +1,99 @@
1/*
2 * drivers/s390/char/sclp_quiesce.c
3 * signal quiesce handler
4 *
5 * (C) Copyright IBM Corp. 1999,2004
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
8 */
9
10#include <linux/config.h>
11#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/cpumask.h>
14#include <linux/smp.h>
15#include <linux/init.h>
16#include <asm/atomic.h>
17#include <asm/ptrace.h>
18#include <asm/sigp.h>
19
20#include "sclp.h"
21
22
23#ifdef CONFIG_SMP
24/* Signal completion of shutdown process. All CPUs except the first to enter
25 * this function: go to stopped state. First CPU: wait until all other
26 * CPUs are in stopped or check stop state. Afterwards, load special PSW
27 * to indicate completion. */
28static void
29do_load_quiesce_psw(void * __unused)
30{
31 static atomic_t cpuid = ATOMIC_INIT(-1);
32 psw_t quiesce_psw;
33 int cpu;
34
35 if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid))
36 signal_processor(smp_processor_id(), sigp_stop);
37 /* Wait for all other cpus to enter stopped state */
38 for_each_online_cpu(cpu) {
39 if (cpu == smp_processor_id())
40 continue;
41 while(!smp_cpu_not_running(cpu))
42 cpu_relax();
43 }
44 /* Quiesce the last cpu with the special psw */
45 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
46 quiesce_psw.addr = 0xfff;
47 __load_psw(quiesce_psw);
48}
49
50/* Shutdown handler. Perform shutdown function on all CPUs. */
51static void
52do_machine_quiesce(void)
53{
54 on_each_cpu(do_load_quiesce_psw, NULL, 0, 0);
55}
56#else
57/* Shutdown handler. Signal completion of shutdown by loading special PSW. */
58static void
59do_machine_quiesce(void)
60{
61 psw_t quiesce_psw;
62
63 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
64 quiesce_psw.addr = 0xfff;
65 __load_psw(quiesce_psw);
66}
67#endif
68
69extern void ctrl_alt_del(void);
70
71/* Handler for quiesce event. Start shutdown procedure. */
72static void
73sclp_quiesce_handler(struct evbuf_header *evbuf)
74{
75 _machine_restart = (void *) do_machine_quiesce;
76 _machine_halt = do_machine_quiesce;
77 _machine_power_off = do_machine_quiesce;
78 ctrl_alt_del();
79}
80
81static struct sclp_register sclp_quiesce_event = {
82 .receive_mask = EvTyp_SigQuiesce_Mask,
83 .receiver_fn = sclp_quiesce_handler
84};
85
86/* Initialize quiesce driver. */
87static int __init
88sclp_quiesce_init(void)
89{
90 int rc;
91
92 rc = sclp_register(&sclp_quiesce_event);
93 if (rc)
94 printk(KERN_WARNING "sclp: could not register quiesce handler "
95 "(rc=%d)\n", rc);
96 return rc;
97}
98
99module_init(sclp_quiesce_init);