blob: cd5475b82420d375e7e557027190530bd7a1a749 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Michael Holzheuaa770152006-12-28 00:35:36 +01005 * Copyright (C) IBM Corp. 1999,2006
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Author(s): Ingo Adlung (adlung@de.ibm.com)
Cornelia Huck4ce3b302006-01-14 13:21:04 -08007 * Cornelia Huck (cornelia.huck@de.ibm.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Arnd Bergmann (arndb@de.ibm.com)
9 * Martin Schwidefsky (schwidefsky@de.ibm.com)
10 */
11
12#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/init.h>
14#include <linux/slab.h>
15#include <linux/device.h>
16#include <linux/kernel_stat.h>
17#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/cio.h>
19#include <asm/delay.h>
20#include <asm/irq.h>
Heiko Carstens5a489b982006-10-06 16:38:35 +020021#include <asm/irq_regs.h>
Heiko Carstense87bfe52006-09-20 15:59:15 +020022#include <asm/setup.h>
Heiko Carstens15e9b582006-12-04 15:40:26 +010023#include <asm/reset.h>
Michael Holzheu46b05d22007-02-21 10:55:21 +010024#include <asm/ipl.h>
Peter Oberparleitere5854a52007-04-27 16:01:31 +020025#include <asm/chpid.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include "airq.h"
27#include "cio.h"
28#include "css.h"
29#include "chsc.h"
30#include "ioasm.h"
31#include "blacklist.h"
32#include "cio_debug.h"
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020033#include "chp.h"
Heiko Carstens15e9b582006-12-04 15:40:26 +010034#include "../s390mach.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36debug_info_t *cio_debug_msg_id;
37debug_info_t *cio_debug_trace_id;
38debug_info_t *cio_debug_crw_id;
39
40int cio_show_msg;
41
42static int __init
43cio_setup (char *parm)
44{
45 if (!strcmp (parm, "yes"))
46 cio_show_msg = 1;
47 else if (!strcmp (parm, "no"))
48 cio_show_msg = 0;
49 else
Cornelia Hucke556bbb2007-07-27 12:29:19 +020050 printk(KERN_ERR "cio: cio_setup: "
51 "invalid cio_msg parameter '%s'", parm);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 return 1;
53}
54
55__setup ("cio_msg=", cio_setup);
56
57/*
58 * Function: cio_debug_init
Cornelia Huckbc698bc2008-01-26 14:10:42 +010059 * Initializes three debug logs for common I/O:
60 * - cio_msg logs generic cio messages
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 * - cio_trace logs the calling of different functions
Cornelia Huckbc698bc2008-01-26 14:10:42 +010062 * - cio_crw logs machine check related cio messages
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 */
Cornelia Huckbc698bc2008-01-26 14:10:42 +010064static int __init cio_debug_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
Cornelia Huckbc698bc2008-01-26 14:10:42 +010066 cio_debug_msg_id = debug_register("cio_msg", 16, 4, 16 * sizeof(long));
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 if (!cio_debug_msg_id)
68 goto out_unregister;
Cornelia Huckbc698bc2008-01-26 14:10:42 +010069 debug_register_view(cio_debug_msg_id, &debug_sprintf_view);
70 debug_set_level(cio_debug_msg_id, 2);
71 cio_debug_trace_id = debug_register("cio_trace", 16, 4, 16);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 if (!cio_debug_trace_id)
73 goto out_unregister;
Cornelia Huckbc698bc2008-01-26 14:10:42 +010074 debug_register_view(cio_debug_trace_id, &debug_hex_ascii_view);
75 debug_set_level(cio_debug_trace_id, 2);
76 cio_debug_crw_id = debug_register("cio_crw", 16, 4, 16 * sizeof(long));
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 if (!cio_debug_crw_id)
78 goto out_unregister;
Cornelia Huckbc698bc2008-01-26 14:10:42 +010079 debug_register_view(cio_debug_crw_id, &debug_sprintf_view);
80 debug_set_level(cio_debug_crw_id, 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 return 0;
82
83out_unregister:
84 if (cio_debug_msg_id)
Cornelia Huckbc698bc2008-01-26 14:10:42 +010085 debug_unregister(cio_debug_msg_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 if (cio_debug_trace_id)
Cornelia Huckbc698bc2008-01-26 14:10:42 +010087 debug_unregister(cio_debug_trace_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 if (cio_debug_crw_id)
Cornelia Huckbc698bc2008-01-26 14:10:42 +010089 debug_unregister(cio_debug_crw_id);
Cornelia Hucke556bbb2007-07-27 12:29:19 +020090 printk(KERN_WARNING"cio: could not initialize debugging\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 return -1;
92}
93
94arch_initcall (cio_debug_init);
95
96int
97cio_set_options (struct subchannel *sch, int flags)
98{
99 sch->options.suspend = (flags & DOIO_ALLOW_SUSPEND) != 0;
100 sch->options.prefetch = (flags & DOIO_DENY_PREFETCH) != 0;
101 sch->options.inter = (flags & DOIO_SUPPRESS_INTER) != 0;
102 return 0;
103}
104
105/* FIXME: who wants to use this? */
106int
107cio_get_options (struct subchannel *sch)
108{
109 int flags;
110
111 flags = 0;
112 if (sch->options.suspend)
113 flags |= DOIO_ALLOW_SUSPEND;
114 if (sch->options.prefetch)
115 flags |= DOIO_DENY_PREFETCH;
116 if (sch->options.inter)
117 flags |= DOIO_SUPPRESS_INTER;
118 return flags;
119}
120
121/*
122 * Use tpi to get a pending interrupt, call the interrupt handler and
123 * return a pointer to the subchannel structure.
124 */
Heiko Carstens4d284ca2007-02-05 21:18:53 +0100125static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126cio_tpi(void)
127{
128 struct tpi_info *tpi_info;
129 struct subchannel *sch;
130 struct irb *irb;
131
132 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
133 if (tpi (NULL) != 1)
134 return 0;
135 irb = (struct irb *) __LC_IRB;
136 /* Store interrupt response block to lowcore. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800137 if (tsch (tpi_info->schid, irb) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 /* Not status pending or not operational. */
139 return 1;
140 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
141 if (!sch)
142 return 1;
143 local_bh_disable();
144 irq_enter ();
Cornelia Huck2ec22982006-12-08 15:54:26 +0100145 spin_lock(sch->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 memcpy (&sch->schib.scsw, &irb->scsw, sizeof (struct scsw));
147 if (sch->driver && sch->driver->irq)
Cornelia Huck602b20f2008-01-26 14:10:39 +0100148 sch->driver->irq(sch);
Cornelia Huck2ec22982006-12-08 15:54:26 +0100149 spin_unlock(sch->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 irq_exit ();
Heiko Carstens1f194a42006-07-03 00:24:46 -0700151 _local_bh_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 return 1;
153}
154
Heiko Carstens4d284ca2007-02-05 21:18:53 +0100155static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156cio_start_handle_notoper(struct subchannel *sch, __u8 lpm)
157{
158 char dbf_text[15];
159
160 if (lpm != 0)
161 sch->lpm &= ~lpm;
162 else
163 sch->lpm = 0;
164
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800165 stsch (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167 CIO_MSG_EVENT(0, "cio_start: 'not oper' status for "
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800168 "subchannel 0.%x.%04x!\n", sch->schid.ssid,
169 sch->schid.sch_no);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 sprintf(dbf_text, "no%s", sch->dev.bus_id);
171 CIO_TRACE_EVENT(0, dbf_text);
172 CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib));
173
174 return (sch->lpm ? -EACCES : -ENODEV);
175}
176
177int
178cio_start_key (struct subchannel *sch, /* subchannel structure */
179 struct ccw1 * cpa, /* logical channel prog addr */
180 __u8 lpm, /* logical path mask */
181 __u8 key) /* storage key */
182{
183 char dbf_txt[15];
184 int ccode;
185
186 CIO_TRACE_EVENT (4, "stIO");
187 CIO_TRACE_EVENT (4, sch->dev.bus_id);
188
189 /* sch is always under 2G. */
190 sch->orb.intparm = (__u32)(unsigned long)sch;
191 sch->orb.fmt = 1;
192
193 sch->orb.pfch = sch->options.prefetch == 0;
194 sch->orb.spnd = sch->options.suspend;
195 sch->orb.ssic = sch->options.suspend && sch->options.inter;
Peter Oberparleitere0e32c82006-09-20 15:59:57 +0200196 sch->orb.lpm = (lpm != 0) ? lpm : sch->lpm;
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800197#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 /*
199 * for 64 bit we always support 64 bit IDAWs with 4k page size only
200 */
201 sch->orb.c64 = 1;
202 sch->orb.i2k = 0;
203#endif
204 sch->orb.key = key >> 4;
205 /* issue "Start Subchannel" */
206 sch->orb.cpa = (__u32) __pa (cpa);
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800207 ccode = ssch (sch->schid, &sch->orb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
209 /* process condition code */
210 sprintf (dbf_txt, "ccode:%d", ccode);
211 CIO_TRACE_EVENT (4, dbf_txt);
212
213 switch (ccode) {
214 case 0:
215 /*
216 * initialize device status information
217 */
218 sch->schib.scsw.actl |= SCSW_ACTL_START_PEND;
219 return 0;
220 case 1: /* status pending */
221 case 2: /* busy */
222 return -EBUSY;
223 default: /* device/path not operational */
224 return cio_start_handle_notoper(sch, lpm);
225 }
226}
227
228int
229cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
230{
Peter Oberparleiter0b642ed2005-05-01 08:58:58 -0700231 return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232}
233
234/*
235 * resume suspended I/O operation
236 */
237int
238cio_resume (struct subchannel *sch)
239{
240 char dbf_txt[15];
241 int ccode;
242
243 CIO_TRACE_EVENT (4, "resIO");
244 CIO_TRACE_EVENT (4, sch->dev.bus_id);
245
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800246 ccode = rsch (sch->schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
248 sprintf (dbf_txt, "ccode:%d", ccode);
249 CIO_TRACE_EVENT (4, dbf_txt);
250
251 switch (ccode) {
252 case 0:
253 sch->schib.scsw.actl |= SCSW_ACTL_RESUME_PEND;
254 return 0;
255 case 1:
256 return -EBUSY;
257 case 2:
258 return -EINVAL;
259 default:
260 /*
261 * useless to wait for request completion
262 * as device is no longer operational !
263 */
264 return -ENODEV;
265 }
266}
267
268/*
269 * halt I/O operation
270 */
271int
272cio_halt(struct subchannel *sch)
273{
274 char dbf_txt[15];
275 int ccode;
276
277 if (!sch)
278 return -ENODEV;
279
280 CIO_TRACE_EVENT (2, "haltIO");
281 CIO_TRACE_EVENT (2, sch->dev.bus_id);
282
283 /*
284 * Issue "Halt subchannel" and process condition code
285 */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800286 ccode = hsch (sch->schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288 sprintf (dbf_txt, "ccode:%d", ccode);
289 CIO_TRACE_EVENT (2, dbf_txt);
290
291 switch (ccode) {
292 case 0:
293 sch->schib.scsw.actl |= SCSW_ACTL_HALT_PEND;
294 return 0;
295 case 1: /* status pending */
296 case 2: /* busy */
297 return -EBUSY;
298 default: /* device not operational */
299 return -ENODEV;
300 }
301}
302
303/*
304 * Clear I/O operation
305 */
306int
307cio_clear(struct subchannel *sch)
308{
309 char dbf_txt[15];
310 int ccode;
311
312 if (!sch)
313 return -ENODEV;
314
315 CIO_TRACE_EVENT (2, "clearIO");
316 CIO_TRACE_EVENT (2, sch->dev.bus_id);
317
318 /*
319 * Issue "Clear subchannel" and process condition code
320 */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800321 ccode = csch (sch->schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 sprintf (dbf_txt, "ccode:%d", ccode);
324 CIO_TRACE_EVENT (2, dbf_txt);
325
326 switch (ccode) {
327 case 0:
328 sch->schib.scsw.actl |= SCSW_ACTL_CLEAR_PEND;
329 return 0;
330 default: /* device not operational */
331 return -ENODEV;
332 }
333}
334
335/*
336 * Function: cio_cancel
337 * Issues a "Cancel Subchannel" on the specified subchannel
338 * Note: We don't need any fancy intparms and flags here
339 * since xsch is executed synchronously.
340 * Only for common I/O internal use as for now.
341 */
342int
343cio_cancel (struct subchannel *sch)
344{
345 char dbf_txt[15];
346 int ccode;
347
348 if (!sch)
349 return -ENODEV;
350
351 CIO_TRACE_EVENT (2, "cancelIO");
352 CIO_TRACE_EVENT (2, sch->dev.bus_id);
353
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800354 ccode = xsch (sch->schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356 sprintf (dbf_txt, "ccode:%d", ccode);
357 CIO_TRACE_EVENT (2, dbf_txt);
358
359 switch (ccode) {
360 case 0: /* success */
361 /* Update information in scsw. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800362 stsch (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 return 0;
364 case 1: /* status pending */
365 return -EBUSY;
366 case 2: /* not applicable */
367 return -EINVAL;
368 default: /* not oper */
369 return -ENODEV;
370 }
371}
372
373/*
374 * Function: cio_modify
375 * Issues a "Modify Subchannel" on the specified subchannel
376 */
377int
378cio_modify (struct subchannel *sch)
379{
380 int ccode, retry, ret;
381
382 ret = 0;
383 for (retry = 0; retry < 5; retry++) {
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800384 ccode = msch_err (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 if (ccode < 0) /* -EIO if msch gets a program check. */
386 return ccode;
387 switch (ccode) {
388 case 0: /* successfull */
389 return 0;
390 case 1: /* status pending */
391 return -EBUSY;
392 case 2: /* busy */
393 udelay (100); /* allow for recovery */
394 ret = -EBUSY;
395 break;
396 case 3: /* not operational */
397 return -ENODEV;
398 }
399 }
400 return ret;
401}
402
403/*
404 * Enable subchannel.
405 */
406int
407cio_enable_subchannel (struct subchannel *sch, unsigned int isc)
408{
409 char dbf_txt[15];
410 int ccode;
411 int retry;
412 int ret;
413
414 CIO_TRACE_EVENT (2, "ensch");
415 CIO_TRACE_EVENT (2, sch->dev.bus_id);
416
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100417 if (sch_is_pseudo_sch(sch))
418 return -EINVAL;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800419 ccode = stsch (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 if (ccode)
421 return -ENODEV;
422
423 for (retry = 5, ret = 0; retry > 0; retry--) {
424 sch->schib.pmcw.ena = 1;
425 sch->schib.pmcw.isc = isc;
426 sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
427 ret = cio_modify(sch);
428 if (ret == -ENODEV)
429 break;
430 if (ret == -EIO)
431 /*
432 * Got a program check in cio_modify. Try without
433 * the concurrent sense bit the next time.
434 */
435 sch->schib.pmcw.csense = 0;
436 if (ret == 0) {
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800437 stsch (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 if (sch->schib.pmcw.ena)
439 break;
440 }
441 if (ret == -EBUSY) {
442 struct irb irb;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800443 if (tsch(sch->schid, &irb) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 break;
445 }
446 }
447 sprintf (dbf_txt, "ret:%d", ret);
448 CIO_TRACE_EVENT (2, dbf_txt);
449 return ret;
450}
451
452/*
453 * Disable subchannel.
454 */
455int
456cio_disable_subchannel (struct subchannel *sch)
457{
458 char dbf_txt[15];
459 int ccode;
460 int retry;
461 int ret;
462
463 CIO_TRACE_EVENT (2, "dissch");
464 CIO_TRACE_EVENT (2, sch->dev.bus_id);
465
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100466 if (sch_is_pseudo_sch(sch))
467 return 0;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800468 ccode = stsch (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 if (ccode == 3) /* Not operational. */
470 return -ENODEV;
471
472 if (sch->schib.scsw.actl != 0)
473 /*
474 * the disable function must not be called while there are
475 * requests pending for completion !
476 */
477 return -EBUSY;
478
479 for (retry = 5, ret = 0; retry > 0; retry--) {
480 sch->schib.pmcw.ena = 0;
481 ret = cio_modify(sch);
482 if (ret == -ENODEV)
483 break;
484 if (ret == -EBUSY)
485 /*
486 * The subchannel is busy or status pending.
487 * We'll disable when the next interrupt was delivered
488 * via the state machine.
489 */
490 break;
491 if (ret == 0) {
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800492 stsch (sch->schid, &sch->schib);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 if (!sch->schib.pmcw.ena)
494 break;
495 }
496 }
497 sprintf (dbf_txt, "ret:%d", ret);
498 CIO_TRACE_EVENT (2, dbf_txt);
499 return ret;
500}
501
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100502int cio_create_sch_lock(struct subchannel *sch)
Cornelia Huck2ec22982006-12-08 15:54:26 +0100503{
504 sch->lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
505 if (!sch->lock)
506 return -ENOMEM;
507 spin_lock_init(sch->lock);
508 return 0;
509}
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
512 * cio_validate_subchannel()
513 *
514 * Find out subchannel type and initialize struct subchannel.
515 * Return codes:
516 * SUBCHANNEL_TYPE_IO for a normal io subchannel
517 * SUBCHANNEL_TYPE_CHSC for a chsc subchannel
518 * SUBCHANNEL_TYPE_MESSAGE for a messaging subchannel
519 * SUBCHANNEL_TYPE_ADM for a adm(?) subchannel
520 * -ENXIO for non-defined subchannels
521 * -ENODEV for subchannels with invalid device number or blacklisted devices
522 */
523int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800524cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 char dbf_txt[15];
527 int ccode;
Cornelia Huck2ec22982006-12-08 15:54:26 +0100528 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800530 sprintf (dbf_txt, "valsch%x", schid.sch_no);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 CIO_TRACE_EVENT (4, dbf_txt);
532
533 /* Nuke all fields. */
534 memset(sch, 0, sizeof(struct subchannel));
535
Cornelia Huck2ec22982006-12-08 15:54:26 +0100536 sch->schid = schid;
537 if (cio_is_console(schid)) {
538 sch->lock = cio_get_console_lock();
539 } else {
540 err = cio_create_sch_lock(sch);
541 if (err)
542 goto out;
543 }
Cornelia Huck6ab48792006-07-12 16:39:50 +0200544 mutex_init(&sch->reg_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 /* Set a name for the subchannel */
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800546 snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid,
547 schid.sch_no);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
549 /*
550 * The first subchannel that is not-operational (ccode==3)
551 * indicates that there aren't any more devices available.
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800552 * If stsch gets an exception, it means the current subchannel set
553 * is not valid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 */
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800555 ccode = stsch_err (schid, &sch->schib);
Cornelia Huck2ec22982006-12-08 15:54:26 +0100556 if (ccode) {
557 err = (ccode == 3) ? -ENXIO : ccode;
558 goto out;
559 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 /* Copy subchannel type from path management control word. */
561 sch->st = sch->schib.pmcw.st;
562
563 /*
564 * ... just being curious we check for non I/O subchannels
565 */
566 if (sch->st != 0) {
567 CIO_DEBUG(KERN_INFO, 0,
Cornelia Huckbc698bc2008-01-26 14:10:42 +0100568 "Subchannel 0.%x.%04x reports "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 "non-I/O subchannel type %04X\n",
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800570 sch->schid.ssid, sch->schid.sch_no, sch->st);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 /* We stop here for non-io subchannels. */
Cornelia Huck2ec22982006-12-08 15:54:26 +0100572 err = sch->st;
573 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 }
575
576 /* Initialization for io subchannels. */
Cornelia Huck2ec22982006-12-08 15:54:26 +0100577 if (!sch->schib.pmcw.dnv) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 /* io subchannel but device number is invalid. */
Cornelia Huck2ec22982006-12-08 15:54:26 +0100579 err = -ENODEV;
580 goto out;
581 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 /* Devno is valid. */
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800583 if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 /*
585 * This device must not be known to Linux. So we simply
586 * say that there is no device and return ENODEV.
587 */
Cornelia Huck347d59d2007-02-05 21:17:56 +0100588 CIO_MSG_EVENT(4, "Blacklisted device detected "
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800589 "at devno %04X, subchannel set %x\n",
590 sch->schib.pmcw.dev, sch->schid.ssid);
Cornelia Huck2ec22982006-12-08 15:54:26 +0100591 err = -ENODEV;
592 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 }
Peter Oberparleitere6b6e102007-04-27 16:01:28 +0200594 if (cio_is_console(sch->schid))
595 sch->opm = 0xff;
596 else
597 sch->opm = chp_get_sch_opm(sch);
Peter Oberparleiter28bdc6f2006-09-20 15:59:59 +0200598 sch->lpm = sch->schib.pmcw.pam & sch->opm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599
600 CIO_DEBUG(KERN_INFO, 0,
Cornelia Huckbc698bc2008-01-26 14:10:42 +0100601 "Detected device %04x on subchannel 0.%x.%04X"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 " - PIM = %02X, PAM = %02X, POM = %02X\n",
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800603 sch->schib.pmcw.dev, sch->schid.ssid,
604 sch->schid.sch_no, sch->schib.pmcw.pim,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 sch->schib.pmcw.pam, sch->schib.pmcw.pom);
606
607 /*
608 * We now have to initially ...
609 * ... set "interruption subclass"
610 * ... enable "concurrent sense"
611 * ... enable "multipath mode" if more than one
612 * CHPID is available. This is done regardless
613 * whether multiple paths are available for us.
614 */
615 sch->schib.pmcw.isc = 3; /* could be smth. else */
616 sch->schib.pmcw.csense = 1; /* concurrent sense */
617 sch->schib.pmcw.ena = 0;
618 if ((sch->lpm & (sch->lpm - 1)) != 0)
619 sch->schib.pmcw.mp = 1; /* multipath mode */
Cornelia Huck1842f2b2007-10-12 16:11:22 +0200620 /* clean up possible residual cmf stuff */
621 sch->schib.pmcw.mme = 0;
622 sch->schib.pmcw.mbfc = 0;
623 sch->schib.pmcw.mbi = 0;
624 sch->schib.mba = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 return 0;
Cornelia Huck2ec22982006-12-08 15:54:26 +0100626out:
627 if (!cio_is_console(schid))
628 kfree(sch->lock);
629 sch->lock = NULL;
630 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631}
632
633/*
634 * do_IRQ() handles all normal I/O device IRQ's (the special
635 * SMP cross-CPU interrupts have their own specific
636 * handlers).
637 *
638 */
639void
640do_IRQ (struct pt_regs *regs)
641{
642 struct tpi_info *tpi_info;
643 struct subchannel *sch;
644 struct irb *irb;
Heiko Carstens5a489b982006-10-06 16:38:35 +0200645 struct pt_regs *old_regs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646
Heiko Carstens5a489b982006-10-06 16:38:35 +0200647 old_regs = set_irq_regs(regs);
Heiko Carstens9d0a57c2006-10-11 15:31:26 +0200648 irq_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 asm volatile ("mc 0,0");
650 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer)
651 /**
652 * Make sure that the i/o interrupt did not "overtake"
653 * the last HZ timer interrupt.
654 */
Martin Schwidefskyd54853e2007-02-05 21:18:19 +0100655 account_ticks(S390_lowcore.int_clock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 /*
657 * Get interrupt information from lowcore
658 */
659 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
660 irb = (struct irb *) __LC_IRB;
661 do {
662 kstat_cpu(smp_processor_id()).irqs[IO_INTERRUPT]++;
663 /*
664 * Non I/O-subchannel thin interrupts are processed differently
665 */
666 if (tpi_info->adapter_IO == 1 &&
667 tpi_info->int_type == IO_INTERRUPT_TYPE) {
668 do_adapter_IO();
669 continue;
670 }
671 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
672 if (sch)
Cornelia Huck2ec22982006-12-08 15:54:26 +0100673 spin_lock(sch->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 /* Store interrupt response block to lowcore. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800675 if (tsch (tpi_info->schid, irb) == 0 && sch) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 /* Keep subchannel information word up to date. */
677 memcpy (&sch->schib.scsw, &irb->scsw,
678 sizeof (irb->scsw));
679 /* Call interrupt handler if there is one. */
680 if (sch->driver && sch->driver->irq)
Cornelia Huck602b20f2008-01-26 14:10:39 +0100681 sch->driver->irq(sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 }
683 if (sch)
Cornelia Huck2ec22982006-12-08 15:54:26 +0100684 spin_unlock(sch->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 /*
686 * Are more interrupts pending?
687 * If so, the tpi instruction will update the lowcore
688 * to hold the info for the next interrupt.
689 * We don't do this for VM because a tpi drops the cpu
690 * out of the sie which costs more cycles than it saves.
691 */
692 } while (!MACHINE_IS_VM && tpi (NULL) != 0);
Heiko Carstens9d0a57c2006-10-11 15:31:26 +0200693 irq_exit();
Heiko Carstens5a489b982006-10-06 16:38:35 +0200694 set_irq_regs(old_regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695}
696
697#ifdef CONFIG_CCW_CONSOLE
698static struct subchannel console_subchannel;
699static int console_subchannel_in_use;
700
701/*
702 * busy wait for the next interrupt on the console
703 */
704void
705wait_cons_dev (void)
706{
707 unsigned long cr6 __attribute__ ((aligned (8)));
708 unsigned long save_cr6 __attribute__ ((aligned (8)));
709
710 /*
711 * before entering the spinlock we may already have
712 * processed the interrupt on a different CPU...
713 */
714 if (!console_subchannel_in_use)
715 return;
716
717 /* disable all but isc 7 (console device) */
718 __ctl_store (save_cr6, 6, 6);
719 cr6 = 0x01000000;
720 __ctl_load (cr6, 6, 6);
721
722 do {
Cornelia Huck2ec22982006-12-08 15:54:26 +0100723 spin_unlock(console_subchannel.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 if (!cio_tpi())
725 cpu_relax();
Cornelia Huck2ec22982006-12-08 15:54:26 +0100726 spin_lock(console_subchannel.lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 } while (console_subchannel.schib.scsw.actl != 0);
728 /*
729 * restore previous isc value
730 */
731 __ctl_load (save_cr6, 6, 6);
732}
733
734static int
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800735cio_test_for_console(struct subchannel_id schid, void *data)
736{
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800737 if (stsch_err(schid, &console_subchannel.schib) != 0)
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800738 return -ENXIO;
739 if (console_subchannel.schib.pmcw.dnv &&
740 console_subchannel.schib.pmcw.dev ==
741 console_devno) {
742 console_irq = schid.sch_no;
743 return 1; /* found */
744 }
745 return 0;
746}
747
748
749static int
750cio_get_console_sch_no(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800752 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800754 init_subchannel_id(&schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 if (console_irq != -1) {
756 /* VM provided us with the irq number of the console. */
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800757 schid.sch_no = console_irq;
758 if (stsch(schid, &console_subchannel.schib) != 0 ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 !console_subchannel.schib.pmcw.dnv)
760 return -1;
761 console_devno = console_subchannel.schib.pmcw.dev;
762 } else if (console_devno != -1) {
763 /* At least the console device number is known. */
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800764 for_each_subchannel(cio_test_for_console, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 if (console_irq == -1)
766 return -1;
767 } else {
768 /* unlike in 2.4, we cannot autoprobe here, since
769 * the channel subsystem is not fully initialized.
770 * With some luck, the HWC console can take over */
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200771 printk(KERN_WARNING "cio: No ccw console found!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 return -1;
773 }
774 return console_irq;
775}
776
777struct subchannel *
778cio_probe_console(void)
779{
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800780 int sch_no, ret;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800781 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
783 if (xchg(&console_subchannel_in_use, 1) != 0)
784 return ERR_PTR(-EBUSY);
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800785 sch_no = cio_get_console_sch_no();
786 if (sch_no == -1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 console_subchannel_in_use = 0;
788 return ERR_PTR(-ENODEV);
789 }
790 memset(&console_subchannel, 0, sizeof(struct subchannel));
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800791 init_subchannel_id(&schid);
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800792 schid.sch_no = sch_no;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800793 ret = cio_validate_subchannel(&console_subchannel, schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 if (ret) {
795 console_subchannel_in_use = 0;
796 return ERR_PTR(-ENODEV);
797 }
798
799 /*
800 * enable console I/O-interrupt subclass 7
801 */
802 ctl_set_bit(6, 24);
803 console_subchannel.schib.pmcw.isc = 7;
804 console_subchannel.schib.pmcw.intparm =
805 (__u32)(unsigned long)&console_subchannel;
806 ret = cio_modify(&console_subchannel);
807 if (ret) {
808 console_subchannel_in_use = 0;
809 return ERR_PTR(ret);
810 }
811 return &console_subchannel;
812}
813
814void
815cio_release_console(void)
816{
817 console_subchannel.schib.pmcw.intparm = 0;
818 cio_modify(&console_subchannel);
819 ctl_clear_bit(6, 24);
820 console_subchannel_in_use = 0;
821}
822
823/* Bah... hack to catch console special sausages. */
824int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800825cio_is_console(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826{
827 if (!console_subchannel_in_use)
828 return 0;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800829 return schid_equal(&schid, &console_subchannel.schid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830}
831
832struct subchannel *
833cio_get_console_subchannel(void)
834{
835 if (!console_subchannel_in_use)
Heiko Carstensd2c993d2006-07-12 16:41:55 +0200836 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 return &console_subchannel;
838}
839
840#endif
Heiko Carstens4d284ca2007-02-05 21:18:53 +0100841static int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800842__disable_subchannel_easy(struct subchannel_id schid, struct schib *schib)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843{
844 int retry, cc;
845
846 cc = 0;
847 for (retry=0;retry<3;retry++) {
848 schib->pmcw.ena = 0;
849 cc = msch(schid, schib);
850 if (cc)
851 return (cc==3?-ENODEV:-EBUSY);
852 stsch(schid, schib);
853 if (!schib->pmcw.ena)
854 return 0;
855 }
856 return -EBUSY; /* uhm... */
857}
858
Martin Schwidefskyd54853e2007-02-05 21:18:19 +0100859/* we can't use the normal udelay here, since it enables external interrupts */
860
861static void udelay_reset(unsigned long usecs)
862{
863 uint64_t start_cc, end_cc;
864
865 asm volatile ("STCK %0" : "=m" (start_cc));
866 do {
867 cpu_relax();
868 asm volatile ("STCK %0" : "=m" (end_cc));
869 } while (((end_cc - start_cc)/4096) < usecs);
870}
871
Heiko Carstens4d284ca2007-02-05 21:18:53 +0100872static int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800873__clear_subchannel_easy(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874{
875 int retry;
876
877 if (csch(schid))
878 return -ENODEV;
879 for (retry=0;retry<20;retry++) {
880 struct tpi_info ti;
881
882 if (tpi(&ti)) {
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800883 tsch(ti.schid, (struct irb *)__LC_IRB);
884 if (schid_equal(&ti.schid, &schid))
Cornelia Huck4c24da72005-09-03 15:58:01 -0700885 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 }
Martin Schwidefskyd54853e2007-02-05 21:18:19 +0100887 udelay_reset(100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 }
889 return -EBUSY;
890}
891
Michael Holzheua45e1412006-12-15 17:18:22 +0100892static int pgm_check_occured;
893
894static void cio_reset_pgm_check_handler(void)
895{
896 pgm_check_occured = 1;
897}
898
899static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr)
900{
901 int rc;
902
903 pgm_check_occured = 0;
Heiko Carstensab14de62007-02-05 21:18:37 +0100904 s390_base_pgm_handler_fn = cio_reset_pgm_check_handler;
Heiko Carstens6faf4442007-01-09 10:18:41 +0100905 rc = stsch(schid, addr);
Heiko Carstensab14de62007-02-05 21:18:37 +0100906 s390_base_pgm_handler_fn = NULL;
Heiko Carstens6faf4442007-01-09 10:18:41 +0100907
Heiko Carstensab14de62007-02-05 21:18:37 +0100908 /* The program check handler could have changed pgm_check_occured. */
Heiko Carstens6faf4442007-01-09 10:18:41 +0100909 barrier();
910
Michael Holzheua45e1412006-12-15 17:18:22 +0100911 if (pgm_check_occured)
912 return -EIO;
913 else
914 return rc;
915}
916
Heiko Carstens15e9b582006-12-04 15:40:26 +0100917static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800918{
919 struct schib schib;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920
Michael Holzheua45e1412006-12-15 17:18:22 +0100921 if (stsch_reset(schid, &schib))
Cornelia Huckf97a56f2006-01-06 00:19:22 -0800922 return -ENXIO;
923 if (!schib.pmcw.ena)
924 return 0;
925 switch(__disable_subchannel_easy(schid, &schib)) {
926 case 0:
927 case -ENODEV:
928 break;
929 default: /* -EBUSY */
930 if (__clear_subchannel_easy(schid))
931 break; /* give up... */
932 stsch(schid, &schib);
933 __disable_subchannel_easy(schid, &schib);
934 }
935 return 0;
936}
937
Heiko Carstens15e9b582006-12-04 15:40:26 +0100938static atomic_t chpid_reset_count;
939
940static void s390_reset_chpids_mcck_handler(void)
941{
942 struct crw crw;
943 struct mci *mci;
944
945 /* Check for pending channel report word. */
946 mci = (struct mci *)&S390_lowcore.mcck_interruption_code;
947 if (!mci->cp)
948 return;
949 /* Process channel report words. */
950 while (stcrw(&crw) == 0) {
951 /* Check for responses to RCHP. */
952 if (crw.slct && crw.rsc == CRW_RSC_CPATH)
953 atomic_dec(&chpid_reset_count);
954 }
955}
956
957#define RCHP_TIMEOUT (30 * USEC_PER_SEC)
958static void css_reset(void)
959{
960 int i, ret;
961 unsigned long long timeout;
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200962 struct chp_id chpid;
Heiko Carstens15e9b582006-12-04 15:40:26 +0100963
964 /* Reset subchannels. */
965 for_each_subchannel(__shutdown_subchannel_easy, NULL);
966 /* Reset channel paths. */
Heiko Carstensab14de62007-02-05 21:18:37 +0100967 s390_base_mcck_handler_fn = s390_reset_chpids_mcck_handler;
Heiko Carstens15e9b582006-12-04 15:40:26 +0100968 /* Enable channel report machine checks. */
969 __ctl_set_bit(14, 28);
970 /* Temporarily reenable machine checks. */
971 local_mcck_enable();
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200972 chp_id_init(&chpid);
Heiko Carstens15e9b582006-12-04 15:40:26 +0100973 for (i = 0; i <= __MAX_CHPID; i++) {
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200974 chpid.id = i;
975 ret = rchp(chpid);
Heiko Carstens15e9b582006-12-04 15:40:26 +0100976 if ((ret == 0) || (ret == 2))
977 /*
978 * rchp either succeeded, or another rchp is already
979 * in progress. In either case, we'll get a crw.
980 */
981 atomic_inc(&chpid_reset_count);
982 }
983 /* Wait for machine check for all channel paths. */
984 timeout = get_clock() + (RCHP_TIMEOUT << 12);
985 while (atomic_read(&chpid_reset_count) != 0) {
986 if (get_clock() > timeout)
987 break;
988 cpu_relax();
989 }
990 /* Disable machine checks again. */
991 local_mcck_disable();
992 /* Disable channel report machine checks. */
993 __ctl_clear_bit(14, 28);
Heiko Carstensab14de62007-02-05 21:18:37 +0100994 s390_base_mcck_handler_fn = NULL;
Heiko Carstens15e9b582006-12-04 15:40:26 +0100995}
996
997static struct reset_call css_reset_call = {
998 .fn = css_reset,
999};
1000
1001static int __init init_css_reset_call(void)
1002{
1003 atomic_set(&chpid_reset_count, 0);
1004 register_reset_call(&css_reset_call);
1005 return 0;
1006}
1007
1008arch_initcall(init_css_reset_call);
1009
1010struct sch_match_id {
1011 struct subchannel_id schid;
1012 struct ccw_dev_id devid;
1013 int rc;
1014};
1015
1016static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
1017{
1018 struct schib schib;
1019 struct sch_match_id *match_id = data;
1020
Michael Holzheua45e1412006-12-15 17:18:22 +01001021 if (stsch_reset(schid, &schib))
Heiko Carstens15e9b582006-12-04 15:40:26 +01001022 return -ENXIO;
1023 if (schib.pmcw.dnv &&
1024 (schib.pmcw.dev == match_id->devid.devno) &&
1025 (schid.ssid == match_id->devid.ssid)) {
1026 match_id->schid = schid;
1027 match_id->rc = 0;
1028 return 1;
1029 }
1030 return 0;
1031}
1032
1033static int reipl_find_schid(struct ccw_dev_id *devid,
1034 struct subchannel_id *schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035{
Michael Holzheuff6b8ea2006-09-20 15:58:49 +02001036 struct sch_match_id match_id;
1037
1038 match_id.devid = *devid;
1039 match_id.rc = -ENODEV;
Heiko Carstens15e9b582006-12-04 15:40:26 +01001040 for_each_subchannel(__reipl_subchannel_match, &match_id);
Michael Holzheuff6b8ea2006-09-20 15:58:49 +02001041 if (match_id.rc == 0)
1042 *schid = match_id.schid;
1043 return match_id.rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044}
1045
Michael Holzheuff6b8ea2006-09-20 15:58:49 +02001046extern void do_reipl_asm(__u32 schid);
1047
1048/* Make sure all subchannels are quiet before we re-ipl an lpar. */
1049void reipl_ccw_dev(struct ccw_dev_id *devid)
1050{
1051 struct subchannel_id schid;
1052
Heiko Carstens15e9b582006-12-04 15:40:26 +01001053 s390_reset_system();
1054 if (reipl_find_schid(devid, &schid) != 0)
Michael Holzheuff6b8ea2006-09-20 15:58:49 +02001055 panic("IPL Device not found\n");
Michael Holzheuff6b8ea2006-09-20 15:58:49 +02001056 do_reipl_asm(*((__u32*)&schid));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057}
Heiko Carstense87bfe52006-09-20 15:59:15 +02001058
Heiko Carstens6fc321f2007-04-27 16:01:25 +02001059int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo)
Heiko Carstense87bfe52006-09-20 15:59:15 +02001060{
1061 struct subchannel_id schid;
Heiko Carstens6fc321f2007-04-27 16:01:25 +02001062 struct schib schib;
Heiko Carstense87bfe52006-09-20 15:59:15 +02001063
1064 schid = *(struct subchannel_id *)__LC_SUBCHANNEL_ID;
1065 if (!schid.one)
Heiko Carstens6fc321f2007-04-27 16:01:25 +02001066 return -ENODEV;
1067 if (stsch(schid, &schib))
1068 return -ENODEV;
1069 if (!schib.pmcw.dnv)
1070 return -ENODEV;
1071 iplinfo->devno = schib.pmcw.dev;
1072 iplinfo->is_qdio = schib.pmcw.qf;
1073 return 0;
Heiko Carstense87bfe52006-09-20 15:59:15 +02001074}