2 * drivers/s390/s390mach.c
3 * S/390 machine check handler
6 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Ingo Adlung (adlung@de.ibm.com)
8 * Martin Schwidefsky (schwidefsky@de.ibm.com)
11 #include <linux/config.h>
12 #include <linux/init.h>
13 #include <linux/sched.h>
14 #include <linux/errno.h>
16 #include <asm/lowcore.h>
21 // #define DBG(args,...) do {} while (0);
23 static struct semaphore m_sem;
24 static struct semaphore s_sem;
26 extern int css_process_crw(int);
27 extern int chsc_process_crw(void);
28 extern int chp_process_crw(int, int);
29 extern void css_reiterate_subchannels(void);
30 extern void css_trigger_slow_path(void);
33 s390_handle_damage(char *msg)
35 printk(KERN_EMERG "%s\n", msg);
39 disabled_wait((unsigned long) __builtin_return_address(0));
43 s390_mchk_slow_path(void *param)
45 struct semaphore *sem;
47 sem = (struct semaphore *)param;
48 /* Set a nice name. */
49 daemonize("kslowcrw");
51 down_interruptible(sem);
52 css_trigger_slow_path();
58 * Retrieve CRWs and call function to handle event.
60 * Note : we currently process CRWs for io and chsc subchannels only
63 s390_collect_crw_info(void *param)
67 struct semaphore *sem;
69 sem = (struct semaphore *)param;
70 /* Set a nice name. */
73 down_interruptible(sem);
79 DBG(KERN_DEBUG "crw_info : CRW reports slct=%d, oflw=%d, "
80 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
81 crw.slct, crw.oflw, crw.chn, crw.rsc, crw.anc,
83 /* Check for overflows. */
85 pr_debug("%s: crw overflow detected!\n", __FUNCTION__);
86 css_reiterate_subchannels();
92 pr_debug("source is subchannel %04X\n", crw.rsid);
93 ret = css_process_crw (crw.rsid);
98 pr_debug("source is monitoring facility\n");
101 pr_debug("source is channel path %02X\n", crw.rsid);
103 case CRW_ERC_IPARM: /* Path has come. */
104 ret = chp_process_crw(crw.rsid, 1);
106 case CRW_ERC_PERRI: /* Path has gone. */
108 ret = chp_process_crw(crw.rsid, 0);
111 pr_debug("Don't know how to handle erc=%x\n",
119 pr_debug("source is configuration-alert facility\n");
122 pr_debug("source is channel subsystem\n");
123 ret = chsc_process_crw();
128 pr_debug("unknown source\n");
139 * machine check handler.
142 s390_do_machine_check(void)
146 mci = (struct mci *) &S390_lowcore.mcck_interruption_code;
148 if (mci->sd) /* system damage */
149 s390_handle_damage("received system damage machine check\n");
151 if (mci->pd) /* instruction processing damage */
152 s390_handle_damage("received instruction processing "
153 "damage machine check\n");
155 if (mci->se) /* storage error uncorrected */
156 s390_handle_damage("received storage error uncorrected "
159 if (mci->sc) /* storage error corrected */
161 "received storage error corrected machine check\n");
163 if (mci->ke) /* storage key-error uncorrected */
164 s390_handle_damage("received storage key-error uncorrected "
167 if (mci->ds && mci->fa) /* storage degradation */
168 s390_handle_damage("received storage degradation machine "
171 if (mci->cp) /* channel report word pending */
174 #ifdef CONFIG_MACHCHK_WARNING
176 * The warning may remain for a prolonged period on the bare iron.
177 * (actually till the machine is powered off, or until the problem is gone)
178 * So we just stop listening for the WARNING MCH and prevent continuously
179 * being interrupted. One caveat is however, that we must do this per
180 * processor and cannot use the smp version of ctl_clear_bit().
181 * On VM we only get one interrupt per virtally presented machinecheck.
182 * Though one suffices, we may get one interrupt per (virtual) processor.
184 if (mci->w) { /* WARNING pending ? */
185 static int mchchk_wng_posted = 0;
187 * Use single machine clear, as we cannot handle smp right now
189 __ctl_clear_bit(14, 24); /* Disable WARNING MCH */
190 if (xchg(&mchchk_wng_posted, 1) == 0)
191 kill_proc(1, SIGPWR, 1);
197 * s390_init_machine_check
199 * initialize machine check handling
202 machine_check_init(void)
204 init_MUTEX_LOCKED(&m_sem);
205 init_MUTEX_LOCKED( &s_sem );
206 ctl_clear_bit(14, 25); /* disable damage MCH */
207 ctl_set_bit(14, 26); /* enable degradation MCH */
208 ctl_set_bit(14, 27); /* enable system recovery MCH */
209 #ifdef CONFIG_MACHCHK_WARNING
210 ctl_set_bit(14, 24); /* enable warning MCH */
216 * Initialize the machine check handler really early to be able to
217 * catch all machine checks that happen during boot
219 arch_initcall(machine_check_init);
222 * Machine checks for the channel subsystem must be enabled
223 * after the channel subsystem is initialized
226 machine_check_crw_init (void)
228 kernel_thread(s390_collect_crw_info, &m_sem, CLONE_FS|CLONE_FILES);
229 kernel_thread(s390_mchk_slow_path, &s_sem, CLONE_FS|CLONE_FILES);
230 ctl_set_bit(14, 28); /* enable channel report MCH */
234 device_initcall (machine_check_crw_init);