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 * Use tpi to get a pending interrupt, call the interrupt handler and
109 * return a pointer to the subchannel structure.
114 struct tpi_info *tpi_info;
115 struct subchannel *sch;
118 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
121 irb = (struct irb *) __LC_IRB;
122 /* Store interrupt response block to lowcore. */
123 if (tsch (tpi_info->schid, irb) != 0)
124 /* Not status pending or not operational. */
126 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
131 spin_lock(sch->lock);
132 memcpy(&sch->schib.scsw, &irb->scsw, sizeof(union scsw));
133 if (sch->driver && sch->driver->irq)
134 sch->driver->irq(sch);
135 spin_unlock(sch->lock);
142 cio_start_handle_notoper(struct subchannel *sch, __u8 lpm)
151 stsch (sch->schid, &sch->schib);
153 CIO_MSG_EVENT(2, "cio_start: 'not oper' status for "
154 "subchannel 0.%x.%04x!\n", sch->schid.ssid,
156 sprintf(dbf_text, "no%s", sch->dev.bus_id);
157 CIO_TRACE_EVENT(0, dbf_text);
158 CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib));
160 return (sch->lpm ? -EACCES : -ENODEV);
164 cio_start_key (struct subchannel *sch, /* subchannel structure */
165 struct ccw1 * cpa, /* logical channel prog addr */
166 __u8 lpm, /* logical path mask */
167 __u8 key) /* storage key */
173 CIO_TRACE_EVENT(4, "stIO");
174 CIO_TRACE_EVENT(4, sch->dev.bus_id);
176 orb = &to_io_private(sch)->orb;
177 /* sch is always under 2G. */
178 orb->cmd.intparm = (u32)(addr_t)sch;
181 orb->cmd.pfch = sch->options.prefetch == 0;
182 orb->cmd.spnd = sch->options.suspend;
183 orb->cmd.ssic = sch->options.suspend && sch->options.inter;
184 orb->cmd.lpm = (lpm != 0) ? lpm : sch->lpm;
187 * for 64 bit we always support 64 bit IDAWs with 4k page size only
192 orb->cmd.key = key >> 4;
193 /* issue "Start Subchannel" */
194 orb->cmd.cpa = (__u32) __pa(cpa);
195 ccode = ssch(sch->schid, orb);
197 /* process condition code */
198 sprintf(dbf_txt, "ccode:%d", ccode);
199 CIO_TRACE_EVENT(4, dbf_txt);
204 * initialize device status information
206 sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
208 case 1: /* status pending */
211 case 3: /* device/path not operational */
212 return cio_start_handle_notoper(sch, lpm);
219 cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
221 return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
225 * resume suspended I/O operation
228 cio_resume (struct subchannel *sch)
233 CIO_TRACE_EVENT (4, "resIO");
234 CIO_TRACE_EVENT (4, sch->dev.bus_id);
236 ccode = rsch (sch->schid);
238 sprintf (dbf_txt, "ccode:%d", ccode);
239 CIO_TRACE_EVENT (4, dbf_txt);
243 sch->schib.scsw.cmd.actl |= SCSW_ACTL_RESUME_PEND;
251 * useless to wait for request completion
252 * as device is no longer operational !
262 cio_halt(struct subchannel *sch)
270 CIO_TRACE_EVENT (2, "haltIO");
271 CIO_TRACE_EVENT (2, sch->dev.bus_id);
274 * Issue "Halt subchannel" and process condition code
276 ccode = hsch (sch->schid);
278 sprintf (dbf_txt, "ccode:%d", ccode);
279 CIO_TRACE_EVENT (2, dbf_txt);
283 sch->schib.scsw.cmd.actl |= SCSW_ACTL_HALT_PEND;
285 case 1: /* status pending */
288 default: /* device not operational */
294 * Clear I/O operation
297 cio_clear(struct subchannel *sch)
305 CIO_TRACE_EVENT (2, "clearIO");
306 CIO_TRACE_EVENT (2, sch->dev.bus_id);
309 * Issue "Clear subchannel" and process condition code
311 ccode = csch (sch->schid);
313 sprintf (dbf_txt, "ccode:%d", ccode);
314 CIO_TRACE_EVENT (2, dbf_txt);
318 sch->schib.scsw.cmd.actl |= SCSW_ACTL_CLEAR_PEND;
320 default: /* device not operational */
326 * Function: cio_cancel
327 * Issues a "Cancel Subchannel" on the specified subchannel
328 * Note: We don't need any fancy intparms and flags here
329 * since xsch is executed synchronously.
330 * Only for common I/O internal use as for now.
333 cio_cancel (struct subchannel *sch)
341 CIO_TRACE_EVENT (2, "cancelIO");
342 CIO_TRACE_EVENT (2, sch->dev.bus_id);
344 ccode = xsch (sch->schid);
346 sprintf (dbf_txt, "ccode:%d", ccode);
347 CIO_TRACE_EVENT (2, dbf_txt);
350 case 0: /* success */
351 /* Update information in scsw. */
352 stsch (sch->schid, &sch->schib);
354 case 1: /* status pending */
356 case 2: /* not applicable */
358 default: /* not oper */
364 * Function: cio_modify
365 * Issues a "Modify Subchannel" on the specified subchannel
368 cio_modify (struct subchannel *sch)
370 int ccode, retry, ret;
373 for (retry = 0; retry < 5; retry++) {
374 ccode = msch_err (sch->schid, &sch->schib);
375 if (ccode < 0) /* -EIO if msch gets a program check. */
378 case 0: /* successfull */
380 case 1: /* status pending */
383 udelay (100); /* allow for recovery */
386 case 3: /* not operational */
394 * cio_enable_subchannel - enable a subchannel.
395 * @sch: subchannel to be enabled
396 * @intparm: interruption parameter to set
398 int cio_enable_subchannel(struct subchannel *sch, u32 intparm)
405 CIO_TRACE_EVENT (2, "ensch");
406 CIO_TRACE_EVENT (2, sch->dev.bus_id);
408 if (sch_is_pseudo_sch(sch))
410 ccode = stsch (sch->schid, &sch->schib);
414 for (retry = 5, ret = 0; retry > 0; retry--) {
415 sch->schib.pmcw.ena = 1;
416 sch->schib.pmcw.isc = sch->isc;
417 sch->schib.pmcw.intparm = intparm;
418 ret = cio_modify(sch);
423 * Got a program check in cio_modify. Try without
424 * the concurrent sense bit the next time.
426 sch->schib.pmcw.csense = 0;
428 stsch (sch->schid, &sch->schib);
429 if (sch->schib.pmcw.ena)
434 if (tsch(sch->schid, &irb) != 0)
438 sprintf (dbf_txt, "ret:%d", ret);
439 CIO_TRACE_EVENT (2, dbf_txt);
442 EXPORT_SYMBOL_GPL(cio_enable_subchannel);
445 * cio_disable_subchannel - disable a subchannel.
446 * @sch: subchannel to disable
448 int cio_disable_subchannel(struct subchannel *sch)
455 CIO_TRACE_EVENT (2, "dissch");
456 CIO_TRACE_EVENT (2, sch->dev.bus_id);
458 if (sch_is_pseudo_sch(sch))
460 ccode = stsch (sch->schid, &sch->schib);
461 if (ccode == 3) /* Not operational. */
464 if (scsw_actl(&sch->schib.scsw) != 0)
466 * the disable function must not be called while there are
467 * requests pending for completion !
471 for (retry = 5, ret = 0; retry > 0; retry--) {
472 sch->schib.pmcw.ena = 0;
473 ret = cio_modify(sch);
478 * The subchannel is busy or status pending.
479 * We'll disable when the next interrupt was delivered
480 * via the state machine.
484 stsch (sch->schid, &sch->schib);
485 if (!sch->schib.pmcw.ena)
489 sprintf (dbf_txt, "ret:%d", ret);
490 CIO_TRACE_EVENT (2, dbf_txt);
493 EXPORT_SYMBOL_GPL(cio_disable_subchannel);
495 int cio_create_sch_lock(struct subchannel *sch)
497 sch->lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
500 spin_lock_init(sch->lock);
504 static int cio_check_devno_blacklisted(struct subchannel *sch)
506 if (is_blacklisted(sch->schid.ssid, sch->schib.pmcw.dev)) {
508 * This device must not be known to Linux. So we simply
509 * say that there is no device and return ENODEV.
511 CIO_MSG_EVENT(6, "Blacklisted device detected "
512 "at devno %04X, subchannel set %x\n",
513 sch->schib.pmcw.dev, sch->schid.ssid);
519 static int cio_validate_io_subchannel(struct subchannel *sch)
521 /* Initialization for io subchannels. */
522 if (!css_sch_is_valid(&sch->schib))
525 /* Devno is valid. */
526 return cio_check_devno_blacklisted(sch);
529 static int cio_validate_msg_subchannel(struct subchannel *sch)
531 /* Initialization for message subchannels. */
532 if (!css_sch_is_valid(&sch->schib))
535 /* Devno is valid. */
536 return cio_check_devno_blacklisted(sch);
540 * cio_validate_subchannel - basic validation of subchannel
541 * @sch: subchannel structure to be filled out
542 * @schid: subchannel id
544 * Find out subchannel type and initialize struct subchannel.
547 * -ENXIO for non-defined subchannels
548 * -ENODEV for invalid subchannels or blacklisted devices
549 * -EIO for subchannels in an invalid subchannel set
551 int cio_validate_subchannel(struct subchannel *sch, struct subchannel_id schid)
557 sprintf(dbf_txt, "valsch%x", schid.sch_no);
558 CIO_TRACE_EVENT(4, dbf_txt);
560 /* Nuke all fields. */
561 memset(sch, 0, sizeof(struct subchannel));
564 if (cio_is_console(schid)) {
565 sch->lock = cio_get_console_lock();
567 err = cio_create_sch_lock(sch);
571 mutex_init(&sch->reg_mutex);
572 /* Set a name for the subchannel */
573 snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid,
577 * The first subchannel that is not-operational (ccode==3)
578 * indicates that there aren't any more devices available.
579 * If stsch gets an exception, it means the current subchannel set
582 ccode = stsch_err (schid, &sch->schib);
584 err = (ccode == 3) ? -ENXIO : ccode;
587 /* Copy subchannel type from path management control word. */
588 sch->st = sch->schib.pmcw.st;
591 case SUBCHANNEL_TYPE_IO:
592 err = cio_validate_io_subchannel(sch);
594 case SUBCHANNEL_TYPE_MSG:
595 err = cio_validate_msg_subchannel(sch);
603 CIO_MSG_EVENT(4, "Subchannel 0.%x.%04x reports subchannel type %04X\n",
604 sch->schid.ssid, sch->schid.sch_no, sch->st);
607 if (!cio_is_console(schid))
614 * do_IRQ() handles all normal I/O device IRQ's (the special
615 * SMP cross-CPU interrupts have their own specific
620 do_IRQ (struct pt_regs *regs)
622 struct tpi_info *tpi_info;
623 struct subchannel *sch;
625 struct pt_regs *old_regs;
627 old_regs = set_irq_regs(regs);
630 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator)
631 /* Serve timer interrupts first. */
632 clock_comparator_work();
634 * Get interrupt information from lowcore
636 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
637 irb = (struct irb *) __LC_IRB;
639 kstat_cpu(smp_processor_id()).irqs[IO_INTERRUPT]++;
641 * Non I/O-subchannel thin interrupts are processed differently
643 if (tpi_info->adapter_IO == 1 &&
644 tpi_info->int_type == IO_INTERRUPT_TYPE) {
645 do_adapter_IO(tpi_info->isc);
648 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
650 /* Clear pending interrupt condition. */
651 tsch(tpi_info->schid, irb);
654 spin_lock(sch->lock);
655 /* Store interrupt response block to lowcore. */
656 if (tsch(tpi_info->schid, irb) == 0) {
657 /* Keep subchannel information word up to date. */
658 memcpy (&sch->schib.scsw, &irb->scsw,
660 /* Call interrupt handler if there is one. */
661 if (sch->driver && sch->driver->irq)
662 sch->driver->irq(sch);
664 spin_unlock(sch->lock);
666 * Are more interrupts pending?
667 * If so, the tpi instruction will update the lowcore
668 * to hold the info for the next interrupt.
669 * We don't do this for VM because a tpi drops the cpu
670 * out of the sie which costs more cycles than it saves.
672 } while (!MACHINE_IS_VM && tpi (NULL) != 0);
674 set_irq_regs(old_regs);
677 #ifdef CONFIG_CCW_CONSOLE
678 static struct subchannel console_subchannel;
679 static struct io_subchannel_private console_priv;
680 static int console_subchannel_in_use;
682 void *cio_get_console_priv(void)
684 return &console_priv;
688 * busy wait for the next interrupt on the console
690 void wait_cons_dev(void)
691 __releases(console_subchannel.lock)
692 __acquires(console_subchannel.lock)
694 unsigned long cr6 __attribute__ ((aligned (8)));
695 unsigned long save_cr6 __attribute__ ((aligned (8)));
698 * before entering the spinlock we may already have
699 * processed the interrupt on a different CPU...
701 if (!console_subchannel_in_use)
704 /* disable all but the console isc */
705 __ctl_store (save_cr6, 6, 6);
706 cr6 = 1UL << (31 - CONSOLE_ISC);
707 __ctl_load (cr6, 6, 6);
710 spin_unlock(console_subchannel.lock);
713 spin_lock(console_subchannel.lock);
714 } while (console_subchannel.schib.scsw.cmd.actl != 0);
716 * restore previous isc value
718 __ctl_load (save_cr6, 6, 6);
722 cio_test_for_console(struct subchannel_id schid, void *data)
724 if (stsch_err(schid, &console_subchannel.schib) != 0)
726 if ((console_subchannel.schib.pmcw.st == SUBCHANNEL_TYPE_IO) &&
727 console_subchannel.schib.pmcw.dnv &&
728 (console_subchannel.schib.pmcw.dev == console_devno)) {
729 console_irq = schid.sch_no;
730 return 1; /* found */
737 cio_get_console_sch_no(void)
739 struct subchannel_id schid;
741 init_subchannel_id(&schid);
742 if (console_irq != -1) {
743 /* VM provided us with the irq number of the console. */
744 schid.sch_no = console_irq;
745 if (stsch(schid, &console_subchannel.schib) != 0 ||
746 (console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) ||
747 !console_subchannel.schib.pmcw.dnv)
749 console_devno = console_subchannel.schib.pmcw.dev;
750 } else if (console_devno != -1) {
751 /* At least the console device number is known. */
752 for_each_subchannel(cio_test_for_console, NULL);
753 if (console_irq == -1)
756 /* unlike in 2.4, we cannot autoprobe here, since
757 * the channel subsystem is not fully initialized.
758 * With some luck, the HWC console can take over */
765 cio_probe_console(void)
768 struct subchannel_id schid;
770 if (xchg(&console_subchannel_in_use, 1) != 0)
771 return ERR_PTR(-EBUSY);
772 sch_no = cio_get_console_sch_no();
774 console_subchannel_in_use = 0;
775 printk(KERN_WARNING "cio: No ccw console found!\n");
776 return ERR_PTR(-ENODEV);
778 memset(&console_subchannel, 0, sizeof(struct subchannel));
779 init_subchannel_id(&schid);
780 schid.sch_no = sch_no;
781 ret = cio_validate_subchannel(&console_subchannel, schid);
783 console_subchannel_in_use = 0;
784 return ERR_PTR(-ENODEV);
788 * enable console I/O-interrupt subclass
790 isc_register(CONSOLE_ISC);
791 console_subchannel.schib.pmcw.isc = CONSOLE_ISC;
792 console_subchannel.schib.pmcw.intparm =
793 (u32)(addr_t)&console_subchannel;
794 ret = cio_modify(&console_subchannel);
796 isc_unregister(CONSOLE_ISC);
797 console_subchannel_in_use = 0;
800 return &console_subchannel;
804 cio_release_console(void)
806 console_subchannel.schib.pmcw.intparm = 0;
807 cio_modify(&console_subchannel);
808 isc_unregister(CONSOLE_ISC);
809 console_subchannel_in_use = 0;
812 /* Bah... hack to catch console special sausages. */
814 cio_is_console(struct subchannel_id schid)
816 if (!console_subchannel_in_use)
818 return schid_equal(&schid, &console_subchannel.schid);
822 cio_get_console_subchannel(void)
824 if (!console_subchannel_in_use)
826 return &console_subchannel;
831 __disable_subchannel_easy(struct subchannel_id schid, struct schib *schib)
836 for (retry=0;retry<3;retry++) {
838 cc = msch(schid, schib);
840 return (cc==3?-ENODEV:-EBUSY);
842 if (!schib->pmcw.ena)
845 return -EBUSY; /* uhm... */
848 /* we can't use the normal udelay here, since it enables external interrupts */
850 static void udelay_reset(unsigned long usecs)
852 uint64_t start_cc, end_cc;
854 asm volatile ("STCK %0" : "=m" (start_cc));
857 asm volatile ("STCK %0" : "=m" (end_cc));
858 } while (((end_cc - start_cc)/4096) < usecs);
862 __clear_io_subchannel_easy(struct subchannel_id schid)
868 for (retry=0;retry<20;retry++) {
872 tsch(ti.schid, (struct irb *)__LC_IRB);
873 if (schid_equal(&ti.schid, &schid))
881 static void __clear_chsc_subchannel_easy(void)
883 /* It seems we can only wait for a bit here :/ */
887 static int pgm_check_occured;
889 static void cio_reset_pgm_check_handler(void)
891 pgm_check_occured = 1;
894 static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr)
898 pgm_check_occured = 0;
899 s390_base_pgm_handler_fn = cio_reset_pgm_check_handler;
900 rc = stsch(schid, addr);
901 s390_base_pgm_handler_fn = NULL;
903 /* The program check handler could have changed pgm_check_occured. */
906 if (pgm_check_occured)
912 static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
916 if (stsch_reset(schid, &schib))
920 switch(__disable_subchannel_easy(schid, &schib)) {
924 default: /* -EBUSY */
925 switch (schib.pmcw.st) {
926 case SUBCHANNEL_TYPE_IO:
927 if (__clear_io_subchannel_easy(schid))
928 goto out; /* give up... */
930 case SUBCHANNEL_TYPE_CHSC:
931 __clear_chsc_subchannel_easy();
934 /* No default clear strategy */
937 stsch(schid, &schib);
938 __disable_subchannel_easy(schid, &schib);
944 static atomic_t chpid_reset_count;
946 static void s390_reset_chpids_mcck_handler(void)
951 /* Check for pending channel report word. */
952 mci = (struct mci *)&S390_lowcore.mcck_interruption_code;
955 /* Process channel report words. */
956 while (stcrw(&crw) == 0) {
957 /* Check for responses to RCHP. */
958 if (crw.slct && crw.rsc == CRW_RSC_CPATH)
959 atomic_dec(&chpid_reset_count);
963 #define RCHP_TIMEOUT (30 * USEC_PER_SEC)
964 static void css_reset(void)
967 unsigned long long timeout;
970 /* Reset subchannels. */
971 for_each_subchannel(__shutdown_subchannel_easy, NULL);
972 /* Reset channel paths. */
973 s390_base_mcck_handler_fn = s390_reset_chpids_mcck_handler;
974 /* Enable channel report machine checks. */
975 __ctl_set_bit(14, 28);
976 /* Temporarily reenable machine checks. */
979 for (i = 0; i <= __MAX_CHPID; i++) {
982 if ((ret == 0) || (ret == 2))
984 * rchp either succeeded, or another rchp is already
985 * in progress. In either case, we'll get a crw.
987 atomic_inc(&chpid_reset_count);
989 /* Wait for machine check for all channel paths. */
990 timeout = get_clock() + (RCHP_TIMEOUT << 12);
991 while (atomic_read(&chpid_reset_count) != 0) {
992 if (get_clock() > timeout)
996 /* Disable machine checks again. */
997 local_mcck_disable();
998 /* Disable channel report machine checks. */
999 __ctl_clear_bit(14, 28);
1000 s390_base_mcck_handler_fn = NULL;
1003 static struct reset_call css_reset_call = {
1007 static int __init init_css_reset_call(void)
1009 atomic_set(&chpid_reset_count, 0);
1010 register_reset_call(&css_reset_call);
1014 arch_initcall(init_css_reset_call);
1016 struct sch_match_id {
1017 struct subchannel_id schid;
1018 struct ccw_dev_id devid;
1022 static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
1025 struct sch_match_id *match_id = data;
1027 if (stsch_reset(schid, &schib))
1029 if ((schib.pmcw.st == SUBCHANNEL_TYPE_IO) && schib.pmcw.dnv &&
1030 (schib.pmcw.dev == match_id->devid.devno) &&
1031 (schid.ssid == match_id->devid.ssid)) {
1032 match_id->schid = schid;
1039 static int reipl_find_schid(struct ccw_dev_id *devid,
1040 struct subchannel_id *schid)
1042 struct sch_match_id match_id;
1044 match_id.devid = *devid;
1045 match_id.rc = -ENODEV;
1046 for_each_subchannel(__reipl_subchannel_match, &match_id);
1047 if (match_id.rc == 0)
1048 *schid = match_id.schid;
1052 extern void do_reipl_asm(__u32 schid);
1054 /* Make sure all subchannels are quiet before we re-ipl an lpar. */
1055 void reipl_ccw_dev(struct ccw_dev_id *devid)
1057 struct subchannel_id schid;
1059 s390_reset_system();
1060 if (reipl_find_schid(devid, &schid) != 0)
1061 panic("IPL Device not found\n");
1062 do_reipl_asm(*((__u32*)&schid));
1065 int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo)
1067 struct subchannel_id schid;
1070 schid = *(struct subchannel_id *)__LC_SUBCHANNEL_ID;
1073 if (stsch(schid, &schib))
1075 if (schib.pmcw.st != SUBCHANNEL_TYPE_IO)
1077 if (!schib.pmcw.dnv)
1079 iplinfo->devno = schib.pmcw.dev;
1080 iplinfo->is_qdio = schib.pmcw.qf;
1085 * cio_tm_start_key - perform start function
1086 * @sch: subchannel on which to perform the start function
1087 * @tcw: transport-command word to be started
1088 * @lpm: mask of paths to use
1089 * @key: storage key to use for storage access
1091 * Start the tcw on the given subchannel. Return zero on success, non-zero
1094 int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key)
1097 union orb *orb = &to_io_private(sch)->orb;
1099 memset(orb, 0, sizeof(union orb));
1100 orb->tm.intparm = (u32) (addr_t) sch;
1101 orb->tm.key = key >> 4;
1103 orb->tm.lpm = lpm ? lpm : sch->lpm;
1104 orb->tm.tcw = (u32) (addr_t) tcw;
1105 cc = ssch(sch->schid, orb);
1113 return cio_start_handle_notoper(sch, lpm);
1118 * cio_tm_intrg - perform interrogate function
1119 * @sch - subchannel on which to perform the interrogate function
1121 * If the specified subchannel is running in transport-mode, perform the
1122 * interrogate function. Return zero on success, non-zero otherwie.
1124 int cio_tm_intrg(struct subchannel *sch)
1128 if (!to_io_private(sch)->orb.tm.b)
1130 cc = xsch(sch->schid);