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>
35 #include "blacklist.h"
36 #include "cio_debug.h"
38 #include "../s390mach.h"
40 debug_info_t *cio_debug_msg_id;
41 debug_info_t *cio_debug_trace_id;
42 debug_info_t *cio_debug_crw_id;
45 * Function: cio_debug_init
46 * Initializes three debug logs for common I/O:
47 * - cio_msg logs generic cio messages
48 * - cio_trace logs the calling of different functions
49 * - cio_crw logs machine check related cio messages
51 static int __init cio_debug_init(void)
53 cio_debug_msg_id = debug_register("cio_msg", 16, 1, 16 * sizeof(long));
54 if (!cio_debug_msg_id)
56 debug_register_view(cio_debug_msg_id, &debug_sprintf_view);
57 debug_set_level(cio_debug_msg_id, 2);
58 cio_debug_trace_id = debug_register("cio_trace", 16, 1, 16);
59 if (!cio_debug_trace_id)
61 debug_register_view(cio_debug_trace_id, &debug_hex_ascii_view);
62 debug_set_level(cio_debug_trace_id, 2);
63 cio_debug_crw_id = debug_register("cio_crw", 16, 1, 16 * sizeof(long));
64 if (!cio_debug_crw_id)
66 debug_register_view(cio_debug_crw_id, &debug_sprintf_view);
67 debug_set_level(cio_debug_crw_id, 4);
72 debug_unregister(cio_debug_msg_id);
73 if (cio_debug_trace_id)
74 debug_unregister(cio_debug_trace_id);
76 debug_unregister(cio_debug_crw_id);
80 arch_initcall (cio_debug_init);
83 cio_set_options (struct subchannel *sch, int flags)
85 sch->options.suspend = (flags & DOIO_ALLOW_SUSPEND) != 0;
86 sch->options.prefetch = (flags & DOIO_DENY_PREFETCH) != 0;
87 sch->options.inter = (flags & DOIO_SUPPRESS_INTER) != 0;
91 /* FIXME: who wants to use this? */
93 cio_get_options (struct subchannel *sch)
98 if (sch->options.suspend)
99 flags |= DOIO_ALLOW_SUSPEND;
100 if (sch->options.prefetch)
101 flags |= DOIO_DENY_PREFETCH;
102 if (sch->options.inter)
103 flags |= DOIO_SUPPRESS_INTER;
108 cio_start_handle_notoper(struct subchannel *sch, __u8 lpm)
117 CIO_MSG_EVENT(2, "cio_start: 'not oper' status for "
118 "subchannel 0.%x.%04x!\n", sch->schid.ssid,
121 if (cio_update_schib(sch))
124 sprintf(dbf_text, "no%s", dev_name(&sch->dev));
125 CIO_TRACE_EVENT(0, dbf_text);
126 CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib));
128 return (sch->lpm ? -EACCES : -ENODEV);
132 cio_start_key (struct subchannel *sch, /* subchannel structure */
133 struct ccw1 * cpa, /* logical channel prog addr */
134 __u8 lpm, /* logical path mask */
135 __u8 key) /* storage key */
141 CIO_TRACE_EVENT(4, "stIO");
142 CIO_TRACE_EVENT(4, dev_name(&sch->dev));
144 orb = &to_io_private(sch)->orb;
145 memset(orb, 0, sizeof(union orb));
146 /* sch is always under 2G. */
147 orb->cmd.intparm = (u32)(addr_t)sch;
150 orb->cmd.pfch = sch->options.prefetch == 0;
151 orb->cmd.spnd = sch->options.suspend;
152 orb->cmd.ssic = sch->options.suspend && sch->options.inter;
153 orb->cmd.lpm = (lpm != 0) ? lpm : sch->lpm;
156 * for 64 bit we always support 64 bit IDAWs with 4k page size only
161 orb->cmd.key = key >> 4;
162 /* issue "Start Subchannel" */
163 orb->cmd.cpa = (__u32) __pa(cpa);
164 ccode = ssch(sch->schid, orb);
166 /* process condition code */
167 sprintf(dbf_txt, "ccode:%d", ccode);
168 CIO_TRACE_EVENT(4, dbf_txt);
173 * initialize device status information
175 sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
177 case 1: /* status pending */
180 case 3: /* device/path not operational */
181 return cio_start_handle_notoper(sch, lpm);
188 cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
190 return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
194 * resume suspended I/O operation
197 cio_resume (struct subchannel *sch)
202 CIO_TRACE_EVENT (4, "resIO");
203 CIO_TRACE_EVENT(4, dev_name(&sch->dev));
205 ccode = rsch (sch->schid);
207 sprintf (dbf_txt, "ccode:%d", ccode);
208 CIO_TRACE_EVENT (4, dbf_txt);
212 sch->schib.scsw.cmd.actl |= SCSW_ACTL_RESUME_PEND;
220 * useless to wait for request completion
221 * as device is no longer operational !
231 cio_halt(struct subchannel *sch)
239 CIO_TRACE_EVENT (2, "haltIO");
240 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
243 * Issue "Halt subchannel" and process condition code
245 ccode = hsch (sch->schid);
247 sprintf (dbf_txt, "ccode:%d", ccode);
248 CIO_TRACE_EVENT (2, dbf_txt);
252 sch->schib.scsw.cmd.actl |= SCSW_ACTL_HALT_PEND;
254 case 1: /* status pending */
257 default: /* device not operational */
263 * Clear I/O operation
266 cio_clear(struct subchannel *sch)
274 CIO_TRACE_EVENT (2, "clearIO");
275 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
278 * Issue "Clear subchannel" and process condition code
280 ccode = csch (sch->schid);
282 sprintf (dbf_txt, "ccode:%d", ccode);
283 CIO_TRACE_EVENT (2, dbf_txt);
287 sch->schib.scsw.cmd.actl |= SCSW_ACTL_CLEAR_PEND;
289 default: /* device not operational */
295 * Function: cio_cancel
296 * Issues a "Cancel Subchannel" on the specified subchannel
297 * Note: We don't need any fancy intparms and flags here
298 * since xsch is executed synchronously.
299 * Only for common I/O internal use as for now.
302 cio_cancel (struct subchannel *sch)
310 CIO_TRACE_EVENT (2, "cancelIO");
311 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
313 ccode = xsch (sch->schid);
315 sprintf (dbf_txt, "ccode:%d", ccode);
316 CIO_TRACE_EVENT (2, dbf_txt);
319 case 0: /* success */
320 /* Update information in scsw. */
321 if (cio_update_schib(sch))
324 case 1: /* status pending */
326 case 2: /* not applicable */
328 default: /* not oper */
334 * Function: cio_modify
335 * Issues a "Modify Subchannel" on the specified subchannel
338 cio_modify (struct subchannel *sch)
340 int ccode, retry, ret;
343 for (retry = 0; retry < 5; retry++) {
344 ccode = msch_err (sch->schid, &sch->schib);
345 if (ccode < 0) /* -EIO if msch gets a program check. */
348 case 0: /* successfull */
350 case 1: /* status pending */
353 udelay (100); /* allow for recovery */
356 case 3: /* not operational */
364 * cio_update_schib - Perform stsch and update schib if subchannel is valid.
365 * @sch: subchannel on which to perform stsch
366 * Return zero on success, -ENODEV otherwise.
368 int cio_update_schib(struct subchannel *sch)
372 if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib))
375 memcpy(&sch->schib, &schib, sizeof(schib));
378 EXPORT_SYMBOL_GPL(cio_update_schib);
381 * cio_enable_subchannel - enable a subchannel.
382 * @sch: subchannel to be enabled
383 * @intparm: interruption parameter to set
385 int cio_enable_subchannel(struct subchannel *sch, u32 intparm)
391 CIO_TRACE_EVENT (2, "ensch");
392 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
394 if (sch_is_pseudo_sch(sch))
396 if (cio_update_schib(sch))
399 for (retry = 5, ret = 0; retry > 0; retry--) {
400 sch->schib.pmcw.ena = 1;
401 sch->schib.pmcw.isc = sch->isc;
402 sch->schib.pmcw.intparm = intparm;
403 ret = cio_modify(sch);
408 * Got a program check in cio_modify. Try without
409 * the concurrent sense bit the next time.
411 sch->schib.pmcw.csense = 0;
413 if (cio_update_schib(sch)) {
417 if (sch->schib.pmcw.ena)
422 if (tsch(sch->schid, &irb) != 0)
426 sprintf (dbf_txt, "ret:%d", ret);
427 CIO_TRACE_EVENT (2, dbf_txt);
430 EXPORT_SYMBOL_GPL(cio_enable_subchannel);
433 * cio_disable_subchannel - disable a subchannel.
434 * @sch: subchannel to disable
436 int cio_disable_subchannel(struct subchannel *sch)
442 CIO_TRACE_EVENT (2, "dissch");
443 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
445 if (sch_is_pseudo_sch(sch))
447 if (cio_update_schib(sch))
450 if (scsw_actl(&sch->schib.scsw) != 0)
452 * the disable function must not be called while there are
453 * requests pending for completion !
457 for (retry = 5, ret = 0; retry > 0; retry--) {
458 sch->schib.pmcw.ena = 0;
459 ret = cio_modify(sch);
464 * The subchannel is busy or status pending.
465 * We'll disable when the next interrupt was delivered
466 * via the state machine.
470 if (cio_update_schib(sch)) {
474 if (!sch->schib.pmcw.ena)
478 sprintf (dbf_txt, "ret:%d", ret);
479 CIO_TRACE_EVENT (2, dbf_txt);
482 EXPORT_SYMBOL_GPL(cio_disable_subchannel);
484 int cio_create_sch_lock(struct subchannel *sch)
486 sch->lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
489 spin_lock_init(sch->lock);
493 static int cio_check_devno_blacklisted(struct subchannel *sch)
495 if (is_blacklisted(sch->schid.ssid, sch->schib.pmcw.dev)) {
497 * This device must not be known to Linux. So we simply
498 * say that there is no device and return ENODEV.
500 CIO_MSG_EVENT(6, "Blacklisted device detected "
501 "at devno %04X, subchannel set %x\n",
502 sch->schib.pmcw.dev, sch->schid.ssid);
508 static int cio_validate_io_subchannel(struct subchannel *sch)
510 /* Initialization for io subchannels. */
511 if (!css_sch_is_valid(&sch->schib))
514 /* Devno is valid. */
515 return cio_check_devno_blacklisted(sch);
518 static int cio_validate_msg_subchannel(struct subchannel *sch)
520 /* Initialization for message subchannels. */
521 if (!css_sch_is_valid(&sch->schib))
524 /* Devno is valid. */
525 return cio_check_devno_blacklisted(sch);
529 * cio_validate_subchannel - basic validation of subchannel
530 * @sch: subchannel structure to be filled out
531 * @schid: subchannel id
533 * Find out subchannel type and initialize struct subchannel.
536 * -ENXIO for non-defined subchannels
537 * -ENODEV for invalid subchannels or blacklisted devices
538 * -EIO for subchannels in an invalid subchannel set
540 int cio_validate_subchannel(struct subchannel *sch, struct subchannel_id schid)
546 sprintf(dbf_txt, "valsch%x", schid.sch_no);
547 CIO_TRACE_EVENT(4, dbf_txt);
549 /* Nuke all fields. */
550 memset(sch, 0, sizeof(struct subchannel));
553 if (cio_is_console(schid)) {
554 sch->lock = cio_get_console_lock();
556 err = cio_create_sch_lock(sch);
560 mutex_init(&sch->reg_mutex);
561 /* Set a name for the subchannel */
562 if (cio_is_console(schid))
563 sch->dev.init_name = cio_get_console_sch_name(schid);
565 dev_set_name(&sch->dev, "0.%x.%04x", schid.ssid, schid.sch_no);
568 * The first subchannel that is not-operational (ccode==3)
569 * indicates that there aren't any more devices available.
570 * If stsch gets an exception, it means the current subchannel set
573 ccode = stsch_err (schid, &sch->schib);
575 err = (ccode == 3) ? -ENXIO : ccode;
578 /* Copy subchannel type from path management control word. */
579 sch->st = sch->schib.pmcw.st;
582 case SUBCHANNEL_TYPE_IO:
583 err = cio_validate_io_subchannel(sch);
585 case SUBCHANNEL_TYPE_MSG:
586 err = cio_validate_msg_subchannel(sch);
594 CIO_MSG_EVENT(4, "Subchannel 0.%x.%04x reports subchannel type %04X\n",
595 sch->schid.ssid, sch->schid.sch_no, sch->st);
598 if (!cio_is_console(schid))
605 * do_IRQ() handles all normal I/O device IRQ's (the special
606 * SMP cross-CPU interrupts have their own specific
611 do_IRQ (struct pt_regs *regs)
613 struct tpi_info *tpi_info;
614 struct subchannel *sch;
616 struct pt_regs *old_regs;
618 old_regs = set_irq_regs(regs);
621 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator)
622 /* Serve timer interrupts first. */
623 clock_comparator_work();
625 * Get interrupt information from lowcore
627 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
628 irb = (struct irb *) __LC_IRB;
630 kstat_cpu(smp_processor_id()).irqs[IO_INTERRUPT]++;
632 * Non I/O-subchannel thin interrupts are processed differently
634 if (tpi_info->adapter_IO == 1 &&
635 tpi_info->int_type == IO_INTERRUPT_TYPE) {
636 do_adapter_IO(tpi_info->isc);
639 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
641 /* Clear pending interrupt condition. */
642 tsch(tpi_info->schid, irb);
645 spin_lock(sch->lock);
646 /* Store interrupt response block to lowcore. */
647 if (tsch(tpi_info->schid, irb) == 0) {
648 /* Keep subchannel information word up to date. */
649 memcpy (&sch->schib.scsw, &irb->scsw,
651 /* Call interrupt handler if there is one. */
652 if (sch->driver && sch->driver->irq)
653 sch->driver->irq(sch);
655 spin_unlock(sch->lock);
657 * Are more interrupts pending?
658 * If so, the tpi instruction will update the lowcore
659 * to hold the info for the next interrupt.
660 * We don't do this for VM because a tpi drops the cpu
661 * out of the sie which costs more cycles than it saves.
663 } while (!MACHINE_IS_VM && tpi (NULL) != 0);
665 set_irq_regs(old_regs);
668 #ifdef CONFIG_CCW_CONSOLE
669 static struct subchannel console_subchannel;
670 static char console_sch_name[10] = "0.x.xxxx";
671 static struct io_subchannel_private console_priv;
672 static int console_subchannel_in_use;
675 * Use tpi to get a pending interrupt, call the interrupt handler and
676 * return a pointer to the subchannel structure.
678 static int cio_tpi(void)
680 struct tpi_info *tpi_info;
681 struct subchannel *sch;
685 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
688 irb = (struct irb *) __LC_IRB;
689 /* Store interrupt response block to lowcore. */
690 if (tsch(tpi_info->schid, irb) != 0)
691 /* Not status pending or not operational. */
693 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
696 irq_context = in_interrupt();
700 spin_lock(sch->lock);
701 memcpy(&sch->schib.scsw, &irb->scsw, sizeof(union scsw));
702 if (sch->driver && sch->driver->irq)
703 sch->driver->irq(sch);
704 spin_unlock(sch->lock);
711 void *cio_get_console_priv(void)
713 return &console_priv;
717 * busy wait for the next interrupt on the console
719 void wait_cons_dev(void)
720 __releases(console_subchannel.lock)
721 __acquires(console_subchannel.lock)
723 unsigned long cr6 __attribute__ ((aligned (8)));
724 unsigned long save_cr6 __attribute__ ((aligned (8)));
727 * before entering the spinlock we may already have
728 * processed the interrupt on a different CPU...
730 if (!console_subchannel_in_use)
733 /* disable all but the console isc */
734 __ctl_store (save_cr6, 6, 6);
735 cr6 = 1UL << (31 - CONSOLE_ISC);
736 __ctl_load (cr6, 6, 6);
739 spin_unlock(console_subchannel.lock);
742 spin_lock(console_subchannel.lock);
743 } while (console_subchannel.schib.scsw.cmd.actl != 0);
745 * restore previous isc value
747 __ctl_load (save_cr6, 6, 6);
751 cio_test_for_console(struct subchannel_id schid, void *data)
753 if (stsch_err(schid, &console_subchannel.schib) != 0)
755 if ((console_subchannel.schib.pmcw.st == SUBCHANNEL_TYPE_IO) &&
756 console_subchannel.schib.pmcw.dnv &&
757 (console_subchannel.schib.pmcw.dev == console_devno)) {
758 console_irq = schid.sch_no;
759 return 1; /* found */
766 cio_get_console_sch_no(void)
768 struct subchannel_id schid;
770 init_subchannel_id(&schid);
771 if (console_irq != -1) {
772 /* VM provided us with the irq number of the console. */
773 schid.sch_no = console_irq;
774 if (stsch(schid, &console_subchannel.schib) != 0 ||
775 (console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) ||
776 !console_subchannel.schib.pmcw.dnv)
778 console_devno = console_subchannel.schib.pmcw.dev;
779 } else if (console_devno != -1) {
780 /* At least the console device number is known. */
781 for_each_subchannel(cio_test_for_console, NULL);
782 if (console_irq == -1)
785 /* unlike in 2.4, we cannot autoprobe here, since
786 * the channel subsystem is not fully initialized.
787 * With some luck, the HWC console can take over */
794 cio_probe_console(void)
797 struct subchannel_id schid;
799 if (xchg(&console_subchannel_in_use, 1) != 0)
800 return ERR_PTR(-EBUSY);
801 sch_no = cio_get_console_sch_no();
803 console_subchannel_in_use = 0;
804 printk(KERN_WARNING "cio: No ccw console found!\n");
805 return ERR_PTR(-ENODEV);
807 memset(&console_subchannel, 0, sizeof(struct subchannel));
808 init_subchannel_id(&schid);
809 schid.sch_no = sch_no;
810 ret = cio_validate_subchannel(&console_subchannel, schid);
812 console_subchannel_in_use = 0;
813 return ERR_PTR(-ENODEV);
817 * enable console I/O-interrupt subclass
819 isc_register(CONSOLE_ISC);
820 console_subchannel.schib.pmcw.isc = CONSOLE_ISC;
821 console_subchannel.schib.pmcw.intparm =
822 (u32)(addr_t)&console_subchannel;
823 ret = cio_modify(&console_subchannel);
825 isc_unregister(CONSOLE_ISC);
826 console_subchannel_in_use = 0;
829 return &console_subchannel;
833 cio_release_console(void)
835 console_subchannel.schib.pmcw.intparm = 0;
836 cio_modify(&console_subchannel);
837 isc_unregister(CONSOLE_ISC);
838 console_subchannel_in_use = 0;
841 /* Bah... hack to catch console special sausages. */
843 cio_is_console(struct subchannel_id schid)
845 if (!console_subchannel_in_use)
847 return schid_equal(&schid, &console_subchannel.schid);
851 cio_get_console_subchannel(void)
853 if (!console_subchannel_in_use)
855 return &console_subchannel;
858 const char *cio_get_console_sch_name(struct subchannel_id schid)
860 snprintf(console_sch_name, 10, "0.%x.%04x", schid.ssid, schid.sch_no);
861 return (const char *)console_sch_name;
866 __disable_subchannel_easy(struct subchannel_id schid, struct schib *schib)
871 for (retry=0;retry<3;retry++) {
873 cc = msch(schid, schib);
875 return (cc==3?-ENODEV:-EBUSY);
876 if (stsch(schid, schib) || !css_sch_is_valid(schib))
878 if (!schib->pmcw.ena)
881 return -EBUSY; /* uhm... */
885 __clear_io_subchannel_easy(struct subchannel_id schid)
891 for (retry=0;retry<20;retry++) {
895 tsch(ti.schid, (struct irb *)__LC_IRB);
896 if (schid_equal(&ti.schid, &schid))
904 static void __clear_chsc_subchannel_easy(void)
906 /* It seems we can only wait for a bit here :/ */
910 static int pgm_check_occured;
912 static void cio_reset_pgm_check_handler(void)
914 pgm_check_occured = 1;
917 static int stsch_reset(struct subchannel_id schid, struct schib *addr)
921 pgm_check_occured = 0;
922 s390_base_pgm_handler_fn = cio_reset_pgm_check_handler;
923 rc = stsch(schid, addr);
924 s390_base_pgm_handler_fn = NULL;
926 /* The program check handler could have changed pgm_check_occured. */
929 if (pgm_check_occured)
935 static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
939 if (stsch_reset(schid, &schib))
943 switch(__disable_subchannel_easy(schid, &schib)) {
947 default: /* -EBUSY */
948 switch (schib.pmcw.st) {
949 case SUBCHANNEL_TYPE_IO:
950 if (__clear_io_subchannel_easy(schid))
951 goto out; /* give up... */
953 case SUBCHANNEL_TYPE_CHSC:
954 __clear_chsc_subchannel_easy();
957 /* No default clear strategy */
960 stsch(schid, &schib);
961 __disable_subchannel_easy(schid, &schib);
967 static atomic_t chpid_reset_count;
969 static void s390_reset_chpids_mcck_handler(void)
974 /* Check for pending channel report word. */
975 mci = (struct mci *)&S390_lowcore.mcck_interruption_code;
978 /* Process channel report words. */
979 while (stcrw(&crw) == 0) {
980 /* Check for responses to RCHP. */
981 if (crw.slct && crw.rsc == CRW_RSC_CPATH)
982 atomic_dec(&chpid_reset_count);
986 #define RCHP_TIMEOUT (30 * USEC_PER_SEC)
987 static void css_reset(void)
990 unsigned long long timeout;
993 /* Reset subchannels. */
994 for_each_subchannel(__shutdown_subchannel_easy, NULL);
995 /* Reset channel paths. */
996 s390_base_mcck_handler_fn = s390_reset_chpids_mcck_handler;
997 /* Enable channel report machine checks. */
998 __ctl_set_bit(14, 28);
999 /* Temporarily reenable machine checks. */
1000 local_mcck_enable();
1001 chp_id_init(&chpid);
1002 for (i = 0; i <= __MAX_CHPID; i++) {
1005 if ((ret == 0) || (ret == 2))
1007 * rchp either succeeded, or another rchp is already
1008 * in progress. In either case, we'll get a crw.
1010 atomic_inc(&chpid_reset_count);
1012 /* Wait for machine check for all channel paths. */
1013 timeout = get_clock() + (RCHP_TIMEOUT << 12);
1014 while (atomic_read(&chpid_reset_count) != 0) {
1015 if (get_clock() > timeout)
1019 /* Disable machine checks again. */
1020 local_mcck_disable();
1021 /* Disable channel report machine checks. */
1022 __ctl_clear_bit(14, 28);
1023 s390_base_mcck_handler_fn = NULL;
1026 static struct reset_call css_reset_call = {
1030 static int __init init_css_reset_call(void)
1032 atomic_set(&chpid_reset_count, 0);
1033 register_reset_call(&css_reset_call);
1037 arch_initcall(init_css_reset_call);
1039 struct sch_match_id {
1040 struct subchannel_id schid;
1041 struct ccw_dev_id devid;
1045 static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
1048 struct sch_match_id *match_id = data;
1050 if (stsch_reset(schid, &schib))
1052 if ((schib.pmcw.st == SUBCHANNEL_TYPE_IO) && schib.pmcw.dnv &&
1053 (schib.pmcw.dev == match_id->devid.devno) &&
1054 (schid.ssid == match_id->devid.ssid)) {
1055 match_id->schid = schid;
1062 static int reipl_find_schid(struct ccw_dev_id *devid,
1063 struct subchannel_id *schid)
1065 struct sch_match_id match_id;
1067 match_id.devid = *devid;
1068 match_id.rc = -ENODEV;
1069 for_each_subchannel(__reipl_subchannel_match, &match_id);
1070 if (match_id.rc == 0)
1071 *schid = match_id.schid;
1075 extern void do_reipl_asm(__u32 schid);
1077 /* Make sure all subchannels are quiet before we re-ipl an lpar. */
1078 void reipl_ccw_dev(struct ccw_dev_id *devid)
1080 struct subchannel_id schid;
1082 s390_reset_system();
1083 if (reipl_find_schid(devid, &schid) != 0)
1084 panic("IPL Device not found\n");
1085 do_reipl_asm(*((__u32*)&schid));
1088 int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo)
1090 struct subchannel_id schid;
1093 schid = *(struct subchannel_id *)__LC_SUBCHANNEL_ID;
1096 if (stsch(schid, &schib))
1098 if (schib.pmcw.st != SUBCHANNEL_TYPE_IO)
1100 if (!schib.pmcw.dnv)
1102 iplinfo->devno = schib.pmcw.dev;
1103 iplinfo->is_qdio = schib.pmcw.qf;
1108 * cio_tm_start_key - perform start function
1109 * @sch: subchannel on which to perform the start function
1110 * @tcw: transport-command word to be started
1111 * @lpm: mask of paths to use
1112 * @key: storage key to use for storage access
1114 * Start the tcw on the given subchannel. Return zero on success, non-zero
1117 int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key)
1120 union orb *orb = &to_io_private(sch)->orb;
1122 memset(orb, 0, sizeof(union orb));
1123 orb->tm.intparm = (u32) (addr_t) sch;
1124 orb->tm.key = key >> 4;
1126 orb->tm.lpm = lpm ? lpm : sch->lpm;
1127 orb->tm.tcw = (u32) (addr_t) tcw;
1128 cc = ssch(sch->schid, orb);
1136 return cio_start_handle_notoper(sch, lpm);
1141 * cio_tm_intrg - perform interrogate function
1142 * @sch - subchannel on which to perform the interrogate function
1144 * If the specified subchannel is running in transport-mode, perform the
1145 * interrogate function. Return zero on success, non-zero otherwie.
1147 int cio_tm_intrg(struct subchannel *sch)
1151 if (!to_io_private(sch)->orb.tm.b)
1153 cc = xsch(sch->schid);