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>
15 #include <linux/workqueue.h>
17 #include <asm/lowcore.h>
22 // #define DBG(args,...) do {} while (0);
24 static struct semaphore m_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);
31 extern struct workqueue_struct
*slow_path_wq
;
32 extern struct work_struct slow_path_work
;
35 s390_handle_damage(char *msg
)
37 printk(KERN_EMERG
"%s\n", msg
);
41 disabled_wait((unsigned long) __builtin_return_address(0));
45 * Retrieve CRWs and call function to handle event.
47 * Note : we currently process CRWs for io and chsc subchannels only
50 s390_collect_crw_info(void *param
)
54 struct semaphore
*sem
;
56 sem
= (struct semaphore
*)param
;
57 /* Set a nice name. */
60 down_interruptible(sem
);
66 DBG(KERN_DEBUG
"crw_info : CRW reports slct=%d, oflw=%d, "
67 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
68 crw
.slct
, crw
.oflw
, crw
.chn
, crw
.rsc
, crw
.anc
,
70 /* Check for overflows. */
72 pr_debug("%s: crw overflow detected!\n", __FUNCTION__
);
73 css_reiterate_subchannels();
79 pr_debug("source is subchannel %04X\n", crw
.rsid
);
80 ret
= css_process_crw (crw
.rsid
);
85 pr_debug("source is monitoring facility\n");
88 pr_debug("source is channel path %02X\n", crw
.rsid
);
90 case CRW_ERC_IPARM
: /* Path has come. */
91 ret
= chp_process_crw(crw
.rsid
, 1);
93 case CRW_ERC_PERRI
: /* Path has gone. */
95 ret
= chp_process_crw(crw
.rsid
, 0);
98 pr_debug("Don't know how to handle erc=%x\n",
106 pr_debug("source is configuration-alert facility\n");
109 pr_debug("source is channel subsystem\n");
110 ret
= chsc_process_crw();
115 pr_debug("unknown source\n");
120 queue_work(slow_path_wq
, &slow_path_work
);
126 * machine check handler.
129 s390_do_machine_check(void)
133 mci
= (struct mci
*) &S390_lowcore
.mcck_interruption_code
;
135 if (mci
->sd
) /* system damage */
136 s390_handle_damage("received system damage machine check\n");
138 if (mci
->pd
) /* instruction processing damage */
139 s390_handle_damage("received instruction processing "
140 "damage machine check\n");
142 if (mci
->se
) /* storage error uncorrected */
143 s390_handle_damage("received storage error uncorrected "
146 if (mci
->sc
) /* storage error corrected */
148 "received storage error corrected machine check\n");
150 if (mci
->ke
) /* storage key-error uncorrected */
151 s390_handle_damage("received storage key-error uncorrected "
154 if (mci
->ds
&& mci
->fa
) /* storage degradation */
155 s390_handle_damage("received storage degradation machine "
158 if (mci
->cp
) /* channel report word pending */
161 #ifdef CONFIG_MACHCHK_WARNING
163 * The warning may remain for a prolonged period on the bare iron.
164 * (actually till the machine is powered off, or until the problem is gone)
165 * So we just stop listening for the WARNING MCH and prevent continuously
166 * being interrupted. One caveat is however, that we must do this per
167 * processor and cannot use the smp version of ctl_clear_bit().
168 * On VM we only get one interrupt per virtally presented machinecheck.
169 * Though one suffices, we may get one interrupt per (virtual) processor.
171 if (mci
->w
) { /* WARNING pending ? */
172 static int mchchk_wng_posted
= 0;
174 * Use single machine clear, as we cannot handle smp right now
176 __ctl_clear_bit(14, 24); /* Disable WARNING MCH */
177 if (xchg(&mchchk_wng_posted
, 1) == 0)
178 kill_proc(1, SIGPWR
, 1);
184 * s390_init_machine_check
186 * initialize machine check handling
189 machine_check_init(void)
191 init_MUTEX_LOCKED(&m_sem
);
192 ctl_clear_bit(14, 25); /* disable damage MCH */
193 ctl_set_bit(14, 26); /* enable degradation MCH */
194 ctl_set_bit(14, 27); /* enable system recovery MCH */
195 #ifdef CONFIG_MACHCHK_WARNING
196 ctl_set_bit(14, 24); /* enable warning MCH */
202 * Initialize the machine check handler really early to be able to
203 * catch all machine checks that happen during boot
205 arch_initcall(machine_check_init
);
208 * Machine checks for the channel subsystem must be enabled
209 * after the channel subsystem is initialized
212 machine_check_crw_init (void)
214 kernel_thread(s390_collect_crw_info
, &m_sem
, CLONE_FS
|CLONE_FILES
);
215 ctl_set_bit(14, 28); /* enable channel report MCH */
219 device_initcall (machine_check_crw_init
);