Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * signal quiesce handler |
| 4 | * |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 5 | * Copyright IBM Corp. 1999, 2004 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> |
| 7 | * Peter Oberparleiter <peter.oberparleiter@de.ibm.com> |
| 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/types.h> |
| 11 | #include <linux/cpumask.h> |
| 12 | #include <linux/smp.h> |
| 13 | #include <linux/init.h> |
Adrian Bunk | 83cc5ed | 2006-06-25 05:47:41 -0700 | [diff] [blame] | 14 | #include <linux/reboot.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 15 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/ptrace.h> |
Jan Glauber | 188596f | 2007-02-21 10:55:03 +0100 | [diff] [blame] | 17 | #include <asm/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | #include "sclp.h" |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | /* Shutdown handler. Signal completion of shutdown by loading special PSW. */ |
Martin Schwidefsky | 8b94c1e | 2009-11-13 15:43:53 +0100 | [diff] [blame] | 22 | static void do_machine_quiesce(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
| 24 | psw_t quiesce_psw; |
| 25 | |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 26 | smp_send_stop(); |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 27 | quiesce_psw.mask = |
| 28 | PSW_MASK_BASE | PSW_MASK_EA | PSW_MASK_BA | PSW_MASK_WAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | quiesce_psw.addr = 0xfff; |
| 30 | __load_psw(quiesce_psw); |
| 31 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | /* Handler for quiesce event. Start shutdown procedure. */ |
Martin Schwidefsky | 8b94c1e | 2009-11-13 15:43:53 +0100 | [diff] [blame] | 34 | static void sclp_quiesce_handler(struct evbuf_header *evbuf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
Peter Oberparleiter | 9b357cc | 2021-06-11 11:13:40 +0200 | [diff] [blame] | 36 | _machine_restart = (void *) do_machine_quiesce; |
| 37 | _machine_halt = do_machine_quiesce; |
| 38 | _machine_power_off = do_machine_quiesce; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | ctrl_alt_del(); |
| 40 | } |
| 41 | |
| 42 | static struct sclp_register sclp_quiesce_event = { |
Stefan Haberland | 6d4740c | 2007-04-27 16:01:53 +0200 | [diff] [blame] | 43 | .receive_mask = EVTYP_SIGQUIESCE_MASK, |
Martin Schwidefsky | 8b94c1e | 2009-11-13 15:43:53 +0100 | [diff] [blame] | 44 | .receiver_fn = sclp_quiesce_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | /* Initialize quiesce driver. */ |
Martin Schwidefsky | 8b94c1e | 2009-11-13 15:43:53 +0100 | [diff] [blame] | 48 | static int __init sclp_quiesce_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | { |
Martin Schwidefsky | a12c53f | 2008-07-14 09:59:28 +0200 | [diff] [blame] | 50 | return sclp_register(&sclp_quiesce_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
Paul Gortmaker | aae175d | 2016-10-30 16:37:28 -0400 | [diff] [blame] | 52 | device_initcall(sclp_quiesce_init); |