[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / s390 / s390mach.c
blobffa996c8a9082eb1b1e49ed1fd427283e17f255c
1 /*
2 * drivers/s390/s390mach.c
3 * S/390 machine check handler
5 * S390 version
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)
9 */
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>
19 #include "s390mach.h"
21 #define DBG printk
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;
34 static void
35 s390_handle_damage(char *msg)
37 printk(KERN_EMERG "%s\n", msg);
38 #ifdef CONFIG_SMP
39 smp_send_stop();
40 #endif
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
49 static int
50 s390_collect_crw_info(void *param)
52 struct crw crw;
53 int ccode, ret, slow;
54 struct semaphore *sem;
56 sem = (struct semaphore *)param;
57 /* Set a nice name. */
58 daemonize("kmcheck");
59 repeat:
60 down_interruptible(sem);
61 slow = 0;
62 while (1) {
63 ccode = stcrw(&crw);
64 if (ccode != 0)
65 break;
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,
69 crw.erc, crw.rsid);
70 /* Check for overflows. */
71 if (crw.oflw) {
72 pr_debug("%s: crw overflow detected!\n", __FUNCTION__);
73 css_reiterate_subchannels();
74 slow = 1;
75 continue;
77 switch (crw.rsc) {
78 case CRW_RSC_SCH:
79 pr_debug("source is subchannel %04X\n", crw.rsid);
80 ret = css_process_crw (crw.rsid);
81 if (ret == -EAGAIN)
82 slow = 1;
83 break;
84 case CRW_RSC_MONITOR:
85 pr_debug("source is monitoring facility\n");
86 break;
87 case CRW_RSC_CPATH:
88 pr_debug("source is channel path %02X\n", crw.rsid);
89 switch (crw.erc) {
90 case CRW_ERC_IPARM: /* Path has come. */
91 ret = chp_process_crw(crw.rsid, 1);
92 break;
93 case CRW_ERC_PERRI: /* Path has gone. */
94 case CRW_ERC_PERRN:
95 ret = chp_process_crw(crw.rsid, 0);
96 break;
97 default:
98 pr_debug("Don't know how to handle erc=%x\n",
99 crw.erc);
100 ret = 0;
102 if (ret == -EAGAIN)
103 slow = 1;
104 break;
105 case CRW_RSC_CONFIG:
106 pr_debug("source is configuration-alert facility\n");
107 break;
108 case CRW_RSC_CSS:
109 pr_debug("source is channel subsystem\n");
110 ret = chsc_process_crw();
111 if (ret == -EAGAIN)
112 slow = 1;
113 break;
114 default:
115 pr_debug("unknown source\n");
116 break;
119 if (slow)
120 queue_work(slow_path_wq, &slow_path_work);
121 goto repeat;
122 return 0;
126 * machine check handler.
128 void
129 s390_do_machine_check(void)
131 struct mci *mci;
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 "
144 "machine check\n");
146 if (mci->sc) /* storage error corrected */
147 printk(KERN_WARNING
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 "
152 "machine check\n");
154 if (mci->ds && mci->fa) /* storage degradation */
155 s390_handle_damage("received storage degradation machine "
156 "check\n");
158 if (mci->cp) /* channel report word pending */
159 up(&m_sem);
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);
180 #endif
184 * s390_init_machine_check
186 * initialize machine check handling
188 static int
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 */
197 #endif
198 return 0;
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
211 static int __init
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 */
216 return 0;
219 device_initcall (machine_check_crw_init);