2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls
5 * Copyright IBM Corp. 1999,2008
6 * Author(s): Ingo Adlung (adlung@de.ibm.com)
7 * Cornelia Huck (cornelia.huck@de.ibm.com)
8 * Arnd Bergmann (arndb@de.ibm.com)
9 * Martin Schwidefsky (schwidefsky@de.ibm.com)
12 #include <linux/module.h>
13 #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>
19 #include <asm/delay.h>
21 #include <asm/irq_regs.h>
22 #include <asm/setup.h>
23 #include <asm/reset.h>
25 #include <asm/chpid.h>
33 #include "blacklist.h"
34 #include "cio_debug.h"
36 #include "../s390mach.h"
38 debug_info_t
*cio_debug_msg_id
;
39 debug_info_t
*cio_debug_trace_id
;
40 debug_info_t
*cio_debug_crw_id
;
43 * Function: cio_debug_init
44 * Initializes three debug logs for common I/O:
45 * - cio_msg logs generic cio messages
46 * - cio_trace logs the calling of different functions
47 * - cio_crw logs machine check related cio messages
49 static int __init
cio_debug_init(void)
51 cio_debug_msg_id
= debug_register("cio_msg", 16, 1, 16 * sizeof(long));
52 if (!cio_debug_msg_id
)
54 debug_register_view(cio_debug_msg_id
, &debug_sprintf_view
);
55 debug_set_level(cio_debug_msg_id
, 2);
56 cio_debug_trace_id
= debug_register("cio_trace", 16, 1, 16);
57 if (!cio_debug_trace_id
)
59 debug_register_view(cio_debug_trace_id
, &debug_hex_ascii_view
);
60 debug_set_level(cio_debug_trace_id
, 2);
61 cio_debug_crw_id
= debug_register("cio_crw", 16, 1, 16 * sizeof(long));
62 if (!cio_debug_crw_id
)
64 debug_register_view(cio_debug_crw_id
, &debug_sprintf_view
);
65 debug_set_level(cio_debug_crw_id
, 4);
70 debug_unregister(cio_debug_msg_id
);
71 if (cio_debug_trace_id
)
72 debug_unregister(cio_debug_trace_id
);
74 debug_unregister(cio_debug_crw_id
);
75 printk(KERN_WARNING
"cio: could not initialize debugging\n");
79 arch_initcall (cio_debug_init
);
82 cio_set_options (struct subchannel
*sch
, int flags
)
84 sch
->options
.suspend
= (flags
& DOIO_ALLOW_SUSPEND
) != 0;
85 sch
->options
.prefetch
= (flags
& DOIO_DENY_PREFETCH
) != 0;
86 sch
->options
.inter
= (flags
& DOIO_SUPPRESS_INTER
) != 0;
90 /* FIXME: who wants to use this? */
92 cio_get_options (struct subchannel
*sch
)
97 if (sch
->options
.suspend
)
98 flags
|= DOIO_ALLOW_SUSPEND
;
99 if (sch
->options
.prefetch
)
100 flags
|= DOIO_DENY_PREFETCH
;
101 if (sch
->options
.inter
)
102 flags
|= DOIO_SUPPRESS_INTER
;
107 * Use tpi to get a pending interrupt, call the interrupt handler and
108 * return a pointer to the subchannel structure.
113 struct tpi_info
*tpi_info
;
114 struct subchannel
*sch
;
117 tpi_info
= (struct tpi_info
*) __LC_SUBCHANNEL_ID
;
120 irb
= (struct irb
*) __LC_IRB
;
121 /* Store interrupt response block to lowcore. */
122 if (tsch (tpi_info
->schid
, irb
) != 0)
123 /* Not status pending or not operational. */
125 sch
= (struct subchannel
*)(unsigned long)tpi_info
->intparm
;
130 spin_lock(sch
->lock
);
131 memcpy(&sch
->schib
.scsw
, &irb
->scsw
, sizeof(union scsw
));
132 if (sch
->driver
&& sch
->driver
->irq
)
133 sch
->driver
->irq(sch
);
134 spin_unlock(sch
->lock
);
141 cio_start_handle_notoper(struct subchannel
*sch
, __u8 lpm
)
150 stsch (sch
->schid
, &sch
->schib
);
152 CIO_MSG_EVENT(2, "cio_start: 'not oper' status for "
153 "subchannel 0.%x.%04x!\n", sch
->schid
.ssid
,
155 sprintf(dbf_text
, "no%s", sch
->dev
.bus_id
);
156 CIO_TRACE_EVENT(0, dbf_text
);
157 CIO_HEX_EVENT(0, &sch
->schib
, sizeof (struct schib
));
159 return (sch
->lpm
? -EACCES
: -ENODEV
);
163 cio_start_key (struct subchannel
*sch
, /* subchannel structure */
164 struct ccw1
* cpa
, /* logical channel prog addr */
165 __u8 lpm
, /* logical path mask */
166 __u8 key
) /* storage key */
172 CIO_TRACE_EVENT(4, "stIO");
173 CIO_TRACE_EVENT(4, sch
->dev
.bus_id
);
175 orb
= &to_io_private(sch
)->orb
;
176 /* sch is always under 2G. */
177 orb
->intparm
= (u32
)(addr_t
)sch
;
180 orb
->pfch
= sch
->options
.prefetch
== 0;
181 orb
->spnd
= sch
->options
.suspend
;
182 orb
->ssic
= sch
->options
.suspend
&& sch
->options
.inter
;
183 orb
->lpm
= (lpm
!= 0) ? lpm
: sch
->lpm
;
186 * for 64 bit we always support 64 bit IDAWs with 4k page size only
192 /* issue "Start Subchannel" */
193 orb
->cpa
= (__u32
) __pa(cpa
);
194 ccode
= ssch(sch
->schid
, orb
);
196 /* process condition code */
197 sprintf(dbf_txt
, "ccode:%d", ccode
);
198 CIO_TRACE_EVENT(4, dbf_txt
);
203 * initialize device status information
205 sch
->schib
.scsw
.cmd
.actl
|= SCSW_ACTL_START_PEND
;
207 case 1: /* status pending */
210 default: /* device/path not operational */
211 return cio_start_handle_notoper(sch
, lpm
);
216 cio_start (struct subchannel
*sch
, struct ccw1
*cpa
, __u8 lpm
)
218 return cio_start_key(sch
, cpa
, lpm
, PAGE_DEFAULT_KEY
);
222 * resume suspended I/O operation
225 cio_resume (struct subchannel
*sch
)
230 CIO_TRACE_EVENT (4, "resIO");
231 CIO_TRACE_EVENT (4, sch
->dev
.bus_id
);
233 ccode
= rsch (sch
->schid
);
235 sprintf (dbf_txt
, "ccode:%d", ccode
);
236 CIO_TRACE_EVENT (4, dbf_txt
);
240 sch
->schib
.scsw
.cmd
.actl
|= SCSW_ACTL_RESUME_PEND
;
248 * useless to wait for request completion
249 * as device is no longer operational !
259 cio_halt(struct subchannel
*sch
)
267 CIO_TRACE_EVENT (2, "haltIO");
268 CIO_TRACE_EVENT (2, sch
->dev
.bus_id
);
271 * Issue "Halt subchannel" and process condition code
273 ccode
= hsch (sch
->schid
);
275 sprintf (dbf_txt
, "ccode:%d", ccode
);
276 CIO_TRACE_EVENT (2, dbf_txt
);
280 sch
->schib
.scsw
.cmd
.actl
|= SCSW_ACTL_HALT_PEND
;
282 case 1: /* status pending */
285 default: /* device not operational */
291 * Clear I/O operation
294 cio_clear(struct subchannel
*sch
)
302 CIO_TRACE_EVENT (2, "clearIO");
303 CIO_TRACE_EVENT (2, sch
->dev
.bus_id
);
306 * Issue "Clear subchannel" and process condition code
308 ccode
= csch (sch
->schid
);
310 sprintf (dbf_txt
, "ccode:%d", ccode
);
311 CIO_TRACE_EVENT (2, dbf_txt
);
315 sch
->schib
.scsw
.cmd
.actl
|= SCSW_ACTL_CLEAR_PEND
;
317 default: /* device not operational */
323 * Function: cio_cancel
324 * Issues a "Cancel Subchannel" on the specified subchannel
325 * Note: We don't need any fancy intparms and flags here
326 * since xsch is executed synchronously.
327 * Only for common I/O internal use as for now.
330 cio_cancel (struct subchannel
*sch
)
338 CIO_TRACE_EVENT (2, "cancelIO");
339 CIO_TRACE_EVENT (2, sch
->dev
.bus_id
);
341 ccode
= xsch (sch
->schid
);
343 sprintf (dbf_txt
, "ccode:%d", ccode
);
344 CIO_TRACE_EVENT (2, dbf_txt
);
347 case 0: /* success */
348 /* Update information in scsw. */
349 stsch (sch
->schid
, &sch
->schib
);
351 case 1: /* status pending */
353 case 2: /* not applicable */
355 default: /* not oper */
361 * Function: cio_modify
362 * Issues a "Modify Subchannel" on the specified subchannel
365 cio_modify (struct subchannel
*sch
)
367 int ccode
, retry
, ret
;
370 for (retry
= 0; retry
< 5; retry
++) {
371 ccode
= msch_err (sch
->schid
, &sch
->schib
);
372 if (ccode
< 0) /* -EIO if msch gets a program check. */
375 case 0: /* successfull */
377 case 1: /* status pending */
380 udelay (100); /* allow for recovery */
383 case 3: /* not operational */
391 * cio_enable_subchannel - enable a subchannel.
392 * @sch: subchannel to be enabled
393 * @intparm: interruption parameter to set
395 int cio_enable_subchannel(struct subchannel
*sch
, u32 intparm
)
402 CIO_TRACE_EVENT (2, "ensch");
403 CIO_TRACE_EVENT (2, sch
->dev
.bus_id
);
405 if (sch_is_pseudo_sch(sch
))
407 ccode
= stsch (sch
->schid
, &sch
->schib
);
411 for (retry
= 5, ret
= 0; retry
> 0; retry
--) {
412 sch
->schib
.pmcw
.ena
= 1;
413 sch
->schib
.pmcw
.isc
= sch
->isc
;
414 sch
->schib
.pmcw
.intparm
= intparm
;
415 ret
= cio_modify(sch
);
420 * Got a program check in cio_modify. Try without
421 * the concurrent sense bit the next time.
423 sch
->schib
.pmcw
.csense
= 0;
425 stsch (sch
->schid
, &sch
->schib
);
426 if (sch
->schib
.pmcw
.ena
)
431 if (tsch(sch
->schid
, &irb
) != 0)
435 sprintf (dbf_txt
, "ret:%d", ret
);
436 CIO_TRACE_EVENT (2, dbf_txt
);
439 EXPORT_SYMBOL_GPL(cio_enable_subchannel
);
442 * cio_disable_subchannel - disable a subchannel.
443 * @sch: subchannel to disable
445 int cio_disable_subchannel(struct subchannel
*sch
)
452 CIO_TRACE_EVENT (2, "dissch");
453 CIO_TRACE_EVENT (2, sch
->dev
.bus_id
);
455 if (sch_is_pseudo_sch(sch
))
457 ccode
= stsch (sch
->schid
, &sch
->schib
);
458 if (ccode
== 3) /* Not operational. */
461 if (scsw_actl(&sch
->schib
.scsw
) != 0)
463 * the disable function must not be called while there are
464 * requests pending for completion !
468 for (retry
= 5, ret
= 0; retry
> 0; retry
--) {
469 sch
->schib
.pmcw
.ena
= 0;
470 ret
= cio_modify(sch
);
475 * The subchannel is busy or status pending.
476 * We'll disable when the next interrupt was delivered
477 * via the state machine.
481 stsch (sch
->schid
, &sch
->schib
);
482 if (!sch
->schib
.pmcw
.ena
)
486 sprintf (dbf_txt
, "ret:%d", ret
);
487 CIO_TRACE_EVENT (2, dbf_txt
);
490 EXPORT_SYMBOL_GPL(cio_disable_subchannel
);
492 int cio_create_sch_lock(struct subchannel
*sch
)
494 sch
->lock
= kmalloc(sizeof(spinlock_t
), GFP_KERNEL
);
497 spin_lock_init(sch
->lock
);
501 static int cio_check_devno_blacklisted(struct subchannel
*sch
)
503 if (is_blacklisted(sch
->schid
.ssid
, sch
->schib
.pmcw
.dev
)) {
505 * This device must not be known to Linux. So we simply
506 * say that there is no device and return ENODEV.
508 CIO_MSG_EVENT(6, "Blacklisted device detected "
509 "at devno %04X, subchannel set %x\n",
510 sch
->schib
.pmcw
.dev
, sch
->schid
.ssid
);
516 static int cio_validate_io_subchannel(struct subchannel
*sch
)
518 /* Initialization for io subchannels. */
519 if (!css_sch_is_valid(&sch
->schib
))
522 /* Devno is valid. */
523 return cio_check_devno_blacklisted(sch
);
526 static int cio_validate_msg_subchannel(struct subchannel
*sch
)
528 /* Initialization for message subchannels. */
529 if (!css_sch_is_valid(&sch
->schib
))
532 /* Devno is valid. */
533 return cio_check_devno_blacklisted(sch
);
537 * cio_validate_subchannel - basic validation of subchannel
538 * @sch: subchannel structure to be filled out
539 * @schid: subchannel id
541 * Find out subchannel type and initialize struct subchannel.
544 * -ENXIO for non-defined subchannels
545 * -ENODEV for invalid subchannels or blacklisted devices
546 * -EIO for subchannels in an invalid subchannel set
548 int cio_validate_subchannel(struct subchannel
*sch
, struct subchannel_id schid
)
554 sprintf(dbf_txt
, "valsch%x", schid
.sch_no
);
555 CIO_TRACE_EVENT(4, dbf_txt
);
557 /* Nuke all fields. */
558 memset(sch
, 0, sizeof(struct subchannel
));
561 if (cio_is_console(schid
)) {
562 sch
->lock
= cio_get_console_lock();
564 err
= cio_create_sch_lock(sch
);
568 mutex_init(&sch
->reg_mutex
);
569 /* Set a name for the subchannel */
570 snprintf (sch
->dev
.bus_id
, BUS_ID_SIZE
, "0.%x.%04x", schid
.ssid
,
574 * The first subchannel that is not-operational (ccode==3)
575 * indicates that there aren't any more devices available.
576 * If stsch gets an exception, it means the current subchannel set
579 ccode
= stsch_err (schid
, &sch
->schib
);
581 err
= (ccode
== 3) ? -ENXIO
: ccode
;
584 /* Copy subchannel type from path management control word. */
585 sch
->st
= sch
->schib
.pmcw
.st
;
588 case SUBCHANNEL_TYPE_IO
:
589 err
= cio_validate_io_subchannel(sch
);
591 case SUBCHANNEL_TYPE_MSG
:
592 err
= cio_validate_msg_subchannel(sch
);
600 CIO_MSG_EVENT(4, "Subchannel 0.%x.%04x reports subchannel type %04X\n",
601 sch
->schid
.ssid
, sch
->schid
.sch_no
, sch
->st
);
604 if (!cio_is_console(schid
))
611 * do_IRQ() handles all normal I/O device IRQ's (the special
612 * SMP cross-CPU interrupts have their own specific
617 do_IRQ (struct pt_regs
*regs
)
619 struct tpi_info
*tpi_info
;
620 struct subchannel
*sch
;
622 struct pt_regs
*old_regs
;
624 old_regs
= set_irq_regs(regs
);
627 if (S390_lowcore
.int_clock
>= S390_lowcore
.clock_comparator
)
628 /* Serve timer interrupts first. */
629 clock_comparator_work();
631 * Get interrupt information from lowcore
633 tpi_info
= (struct tpi_info
*) __LC_SUBCHANNEL_ID
;
634 irb
= (struct irb
*) __LC_IRB
;
636 kstat_cpu(smp_processor_id()).irqs
[IO_INTERRUPT
]++;
638 * Non I/O-subchannel thin interrupts are processed differently
640 if (tpi_info
->adapter_IO
== 1 &&
641 tpi_info
->int_type
== IO_INTERRUPT_TYPE
) {
645 sch
= (struct subchannel
*)(unsigned long)tpi_info
->intparm
;
647 /* Clear pending interrupt condition. */
648 tsch(tpi_info
->schid
, irb
);
651 spin_lock(sch
->lock
);
652 /* Store interrupt response block to lowcore. */
653 if (tsch(tpi_info
->schid
, irb
) == 0) {
654 /* Keep subchannel information word up to date. */
655 memcpy (&sch
->schib
.scsw
, &irb
->scsw
,
657 /* Call interrupt handler if there is one. */
658 if (sch
->driver
&& sch
->driver
->irq
)
659 sch
->driver
->irq(sch
);
661 spin_unlock(sch
->lock
);
663 * Are more interrupts pending?
664 * If so, the tpi instruction will update the lowcore
665 * to hold the info for the next interrupt.
666 * We don't do this for VM because a tpi drops the cpu
667 * out of the sie which costs more cycles than it saves.
669 } while (!MACHINE_IS_VM
&& tpi (NULL
) != 0);
671 set_irq_regs(old_regs
);
674 #ifdef CONFIG_CCW_CONSOLE
675 static struct subchannel console_subchannel
;
676 static struct io_subchannel_private console_priv
;
677 static int console_subchannel_in_use
;
679 void *cio_get_console_priv(void)
681 return &console_priv
;
685 * busy wait for the next interrupt on the console
687 void wait_cons_dev(void)
688 __releases(console_subchannel
.lock
)
689 __acquires(console_subchannel
.lock
)
691 unsigned long cr6
__attribute__ ((aligned (8)));
692 unsigned long save_cr6
__attribute__ ((aligned (8)));
695 * before entering the spinlock we may already have
696 * processed the interrupt on a different CPU...
698 if (!console_subchannel_in_use
)
701 /* disable all but isc 1 (console device) */
702 __ctl_store (save_cr6
, 6, 6);
704 __ctl_load (cr6
, 6, 6);
707 spin_unlock(console_subchannel
.lock
);
710 spin_lock(console_subchannel
.lock
);
711 } while (console_subchannel
.schib
.scsw
.cmd
.actl
!= 0);
713 * restore previous isc value
715 __ctl_load (save_cr6
, 6, 6);
719 cio_test_for_console(struct subchannel_id schid
, void *data
)
721 if (stsch_err(schid
, &console_subchannel
.schib
) != 0)
723 if ((console_subchannel
.schib
.pmcw
.st
== SUBCHANNEL_TYPE_IO
) &&
724 console_subchannel
.schib
.pmcw
.dnv
&&
725 (console_subchannel
.schib
.pmcw
.dev
== console_devno
)) {
726 console_irq
= schid
.sch_no
;
727 return 1; /* found */
734 cio_get_console_sch_no(void)
736 struct subchannel_id schid
;
738 init_subchannel_id(&schid
);
739 if (console_irq
!= -1) {
740 /* VM provided us with the irq number of the console. */
741 schid
.sch_no
= console_irq
;
742 if (stsch(schid
, &console_subchannel
.schib
) != 0 ||
743 (console_subchannel
.schib
.pmcw
.st
!= SUBCHANNEL_TYPE_IO
) ||
744 !console_subchannel
.schib
.pmcw
.dnv
)
746 console_devno
= console_subchannel
.schib
.pmcw
.dev
;
747 } else if (console_devno
!= -1) {
748 /* At least the console device number is known. */
749 for_each_subchannel(cio_test_for_console
, NULL
);
750 if (console_irq
== -1)
753 /* unlike in 2.4, we cannot autoprobe here, since
754 * the channel subsystem is not fully initialized.
755 * With some luck, the HWC console can take over */
756 printk(KERN_WARNING
"cio: No ccw console found!\n");
763 cio_probe_console(void)
766 struct subchannel_id schid
;
768 if (xchg(&console_subchannel_in_use
, 1) != 0)
769 return ERR_PTR(-EBUSY
);
770 sch_no
= cio_get_console_sch_no();
772 console_subchannel_in_use
= 0;
773 return ERR_PTR(-ENODEV
);
775 memset(&console_subchannel
, 0, sizeof(struct subchannel
));
776 init_subchannel_id(&schid
);
777 schid
.sch_no
= sch_no
;
778 ret
= cio_validate_subchannel(&console_subchannel
, schid
);
780 console_subchannel_in_use
= 0;
781 return ERR_PTR(-ENODEV
);
785 * enable console I/O-interrupt subclass 1
788 console_subchannel
.schib
.pmcw
.isc
= 1;
789 console_subchannel
.schib
.pmcw
.intparm
=
790 (u32
)(addr_t
)&console_subchannel
;
791 ret
= cio_modify(&console_subchannel
);
793 console_subchannel_in_use
= 0;
796 return &console_subchannel
;
800 cio_release_console(void)
802 console_subchannel
.schib
.pmcw
.intparm
= 0;
803 cio_modify(&console_subchannel
);
804 ctl_clear_bit(6, 30);
805 console_subchannel_in_use
= 0;
808 /* Bah... hack to catch console special sausages. */
810 cio_is_console(struct subchannel_id schid
)
812 if (!console_subchannel_in_use
)
814 return schid_equal(&schid
, &console_subchannel
.schid
);
818 cio_get_console_subchannel(void)
820 if (!console_subchannel_in_use
)
822 return &console_subchannel
;
827 __disable_subchannel_easy(struct subchannel_id schid
, struct schib
*schib
)
832 for (retry
=0;retry
<3;retry
++) {
834 cc
= msch(schid
, schib
);
836 return (cc
==3?-ENODEV
:-EBUSY
);
838 if (!schib
->pmcw
.ena
)
841 return -EBUSY
; /* uhm... */
844 /* we can't use the normal udelay here, since it enables external interrupts */
846 static void udelay_reset(unsigned long usecs
)
848 uint64_t start_cc
, end_cc
;
850 asm volatile ("STCK %0" : "=m" (start_cc
));
853 asm volatile ("STCK %0" : "=m" (end_cc
));
854 } while (((end_cc
- start_cc
)/4096) < usecs
);
858 __clear_io_subchannel_easy(struct subchannel_id schid
)
864 for (retry
=0;retry
<20;retry
++) {
868 tsch(ti
.schid
, (struct irb
*)__LC_IRB
);
869 if (schid_equal(&ti
.schid
, &schid
))
877 static int pgm_check_occured
;
879 static void cio_reset_pgm_check_handler(void)
881 pgm_check_occured
= 1;
884 static int stsch_reset(struct subchannel_id schid
, volatile struct schib
*addr
)
888 pgm_check_occured
= 0;
889 s390_base_pgm_handler_fn
= cio_reset_pgm_check_handler
;
890 rc
= stsch(schid
, addr
);
891 s390_base_pgm_handler_fn
= NULL
;
893 /* The program check handler could have changed pgm_check_occured. */
896 if (pgm_check_occured
)
902 static int __shutdown_subchannel_easy(struct subchannel_id schid
, void *data
)
906 if (stsch_reset(schid
, &schib
))
910 switch(__disable_subchannel_easy(schid
, &schib
)) {
914 default: /* -EBUSY */
915 switch (schib
.pmcw
.st
) {
916 case SUBCHANNEL_TYPE_IO
:
917 if (__clear_io_subchannel_easy(schid
))
918 goto out
; /* give up... */
921 /* No default clear strategy */
924 stsch(schid
, &schib
);
925 __disable_subchannel_easy(schid
, &schib
);
931 static atomic_t chpid_reset_count
;
933 static void s390_reset_chpids_mcck_handler(void)
938 /* Check for pending channel report word. */
939 mci
= (struct mci
*)&S390_lowcore
.mcck_interruption_code
;
942 /* Process channel report words. */
943 while (stcrw(&crw
) == 0) {
944 /* Check for responses to RCHP. */
945 if (crw
.slct
&& crw
.rsc
== CRW_RSC_CPATH
)
946 atomic_dec(&chpid_reset_count
);
950 #define RCHP_TIMEOUT (30 * USEC_PER_SEC)
951 static void css_reset(void)
954 unsigned long long timeout
;
957 /* Reset subchannels. */
958 for_each_subchannel(__shutdown_subchannel_easy
, NULL
);
959 /* Reset channel paths. */
960 s390_base_mcck_handler_fn
= s390_reset_chpids_mcck_handler
;
961 /* Enable channel report machine checks. */
962 __ctl_set_bit(14, 28);
963 /* Temporarily reenable machine checks. */
966 for (i
= 0; i
<= __MAX_CHPID
; i
++) {
969 if ((ret
== 0) || (ret
== 2))
971 * rchp either succeeded, or another rchp is already
972 * in progress. In either case, we'll get a crw.
974 atomic_inc(&chpid_reset_count
);
976 /* Wait for machine check for all channel paths. */
977 timeout
= get_clock() + (RCHP_TIMEOUT
<< 12);
978 while (atomic_read(&chpid_reset_count
) != 0) {
979 if (get_clock() > timeout
)
983 /* Disable machine checks again. */
984 local_mcck_disable();
985 /* Disable channel report machine checks. */
986 __ctl_clear_bit(14, 28);
987 s390_base_mcck_handler_fn
= NULL
;
990 static struct reset_call css_reset_call
= {
994 static int __init
init_css_reset_call(void)
996 atomic_set(&chpid_reset_count
, 0);
997 register_reset_call(&css_reset_call
);
1001 arch_initcall(init_css_reset_call
);
1003 struct sch_match_id
{
1004 struct subchannel_id schid
;
1005 struct ccw_dev_id devid
;
1009 static int __reipl_subchannel_match(struct subchannel_id schid
, void *data
)
1012 struct sch_match_id
*match_id
= data
;
1014 if (stsch_reset(schid
, &schib
))
1016 if ((schib
.pmcw
.st
== SUBCHANNEL_TYPE_IO
) && schib
.pmcw
.dnv
&&
1017 (schib
.pmcw
.dev
== match_id
->devid
.devno
) &&
1018 (schid
.ssid
== match_id
->devid
.ssid
)) {
1019 match_id
->schid
= schid
;
1026 static int reipl_find_schid(struct ccw_dev_id
*devid
,
1027 struct subchannel_id
*schid
)
1029 struct sch_match_id match_id
;
1031 match_id
.devid
= *devid
;
1032 match_id
.rc
= -ENODEV
;
1033 for_each_subchannel(__reipl_subchannel_match
, &match_id
);
1034 if (match_id
.rc
== 0)
1035 *schid
= match_id
.schid
;
1039 extern void do_reipl_asm(__u32 schid
);
1041 /* Make sure all subchannels are quiet before we re-ipl an lpar. */
1042 void reipl_ccw_dev(struct ccw_dev_id
*devid
)
1044 struct subchannel_id schid
;
1046 s390_reset_system();
1047 if (reipl_find_schid(devid
, &schid
) != 0)
1048 panic("IPL Device not found\n");
1049 do_reipl_asm(*((__u32
*)&schid
));
1052 int __init
cio_get_iplinfo(struct cio_iplinfo
*iplinfo
)
1054 struct subchannel_id schid
;
1057 schid
= *(struct subchannel_id
*)__LC_SUBCHANNEL_ID
;
1060 if (stsch(schid
, &schib
))
1062 if (schib
.pmcw
.st
!= SUBCHANNEL_TYPE_IO
)
1064 if (!schib
.pmcw
.dnv
)
1066 iplinfo
->devno
= schib
.pmcw
.dev
;
1067 iplinfo
->is_qdio
= schib
.pmcw
.qf
;