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 #define KMSG_COMPONENT "cio"
13 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15 #include <linux/ftrace.h>
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/slab.h>
19 #include <linux/device.h>
20 #include <linux/kernel_stat.h>
21 #include <linux/interrupt.h>
23 #include <asm/delay.h>
25 #include <asm/irq_regs.h>
26 #include <asm/setup.h>
27 #include <asm/reset.h>
29 #include <asm/chpid.h>
32 #include <asm/cputime.h>
41 #include "blacklist.h"
42 #include "cio_debug.h"
45 debug_info_t *cio_debug_msg_id;
46 debug_info_t *cio_debug_trace_id;
47 debug_info_t *cio_debug_crw_id;
50 * Function: cio_debug_init
51 * Initializes three debug logs for common I/O:
52 * - cio_msg logs generic cio messages
53 * - cio_trace logs the calling of different functions
54 * - cio_crw logs machine check related cio messages
56 static int __init cio_debug_init(void)
58 cio_debug_msg_id = debug_register("cio_msg", 16, 1, 16 * sizeof(long));
59 if (!cio_debug_msg_id)
61 debug_register_view(cio_debug_msg_id, &debug_sprintf_view);
62 debug_set_level(cio_debug_msg_id, 2);
63 cio_debug_trace_id = debug_register("cio_trace", 16, 1, 16);
64 if (!cio_debug_trace_id)
66 debug_register_view(cio_debug_trace_id, &debug_hex_ascii_view);
67 debug_set_level(cio_debug_trace_id, 2);
68 cio_debug_crw_id = debug_register("cio_crw", 16, 1, 16 * sizeof(long));
69 if (!cio_debug_crw_id)
71 debug_register_view(cio_debug_crw_id, &debug_sprintf_view);
72 debug_set_level(cio_debug_crw_id, 4);
77 debug_unregister(cio_debug_msg_id);
78 if (cio_debug_trace_id)
79 debug_unregister(cio_debug_trace_id);
81 debug_unregister(cio_debug_crw_id);
85 arch_initcall (cio_debug_init);
88 cio_set_options (struct subchannel *sch, int flags)
90 sch->options.suspend = (flags & DOIO_ALLOW_SUSPEND) != 0;
91 sch->options.prefetch = (flags & DOIO_DENY_PREFETCH) != 0;
92 sch->options.inter = (flags & DOIO_SUPPRESS_INTER) != 0;
96 /* FIXME: who wants to use this? */
98 cio_get_options (struct subchannel *sch)
103 if (sch->options.suspend)
104 flags |= DOIO_ALLOW_SUSPEND;
105 if (sch->options.prefetch)
106 flags |= DOIO_DENY_PREFETCH;
107 if (sch->options.inter)
108 flags |= DOIO_SUPPRESS_INTER;
113 cio_start_handle_notoper(struct subchannel *sch, __u8 lpm)
122 CIO_MSG_EVENT(2, "cio_start: 'not oper' status for "
123 "subchannel 0.%x.%04x!\n", sch->schid.ssid,
126 if (cio_update_schib(sch))
129 sprintf(dbf_text, "no%s", dev_name(&sch->dev));
130 CIO_TRACE_EVENT(0, dbf_text);
131 CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib));
133 return (sch->lpm ? -EACCES : -ENODEV);
137 cio_start_key (struct subchannel *sch, /* subchannel structure */
138 struct ccw1 * cpa, /* logical channel prog addr */
139 __u8 lpm, /* logical path mask */
140 __u8 key) /* storage key */
145 CIO_TRACE_EVENT(5, "stIO");
146 CIO_TRACE_EVENT(5, dev_name(&sch->dev));
148 orb = &to_io_private(sch)->orb;
149 memset(orb, 0, sizeof(union orb));
150 /* sch is always under 2G. */
151 orb->cmd.intparm = (u32)(addr_t)sch;
154 orb->cmd.pfch = sch->options.prefetch == 0;
155 orb->cmd.spnd = sch->options.suspend;
156 orb->cmd.ssic = sch->options.suspend && sch->options.inter;
157 orb->cmd.lpm = (lpm != 0) ? lpm : sch->lpm;
160 * for 64 bit we always support 64 bit IDAWs with 4k page size only
165 orb->cmd.key = key >> 4;
166 /* issue "Start Subchannel" */
167 orb->cmd.cpa = (__u32) __pa(cpa);
168 ccode = ssch(sch->schid, orb);
170 /* process condition code */
171 CIO_HEX_EVENT(5, &ccode, sizeof(ccode));
176 * initialize device status information
178 sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
180 case 1: /* status pending */
183 case 3: /* device/path not operational */
184 return cio_start_handle_notoper(sch, lpm);
191 cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
193 return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
197 * resume suspended I/O operation
200 cio_resume (struct subchannel *sch)
204 CIO_TRACE_EVENT(4, "resIO");
205 CIO_TRACE_EVENT(4, dev_name(&sch->dev));
207 ccode = rsch (sch->schid);
209 CIO_HEX_EVENT(4, &ccode, sizeof(ccode));
213 sch->schib.scsw.cmd.actl |= SCSW_ACTL_RESUME_PEND;
221 * useless to wait for request completion
222 * as device is no longer operational !
232 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 CIO_HEX_EVENT(2, &ccode, sizeof(ccode));
251 sch->schib.scsw.cmd.actl |= SCSW_ACTL_HALT_PEND;
253 case 1: /* status pending */
256 default: /* device not operational */
262 * Clear I/O operation
265 cio_clear(struct subchannel *sch)
272 CIO_TRACE_EVENT(2, "clearIO");
273 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
276 * Issue "Clear subchannel" and process condition code
278 ccode = csch (sch->schid);
280 CIO_HEX_EVENT(2, &ccode, sizeof(ccode));
284 sch->schib.scsw.cmd.actl |= SCSW_ACTL_CLEAR_PEND;
286 default: /* device not operational */
292 * Function: cio_cancel
293 * Issues a "Cancel Subchannel" on the specified subchannel
294 * Note: We don't need any fancy intparms and flags here
295 * since xsch is executed synchronously.
296 * Only for common I/O internal use as for now.
299 cio_cancel (struct subchannel *sch)
306 CIO_TRACE_EVENT(2, "cancelIO");
307 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
309 ccode = xsch (sch->schid);
311 CIO_HEX_EVENT(2, &ccode, sizeof(ccode));
314 case 0: /* success */
315 /* Update information in scsw. */
316 if (cio_update_schib(sch))
319 case 1: /* status pending */
321 case 2: /* not applicable */
323 default: /* not oper */
329 static void cio_apply_config(struct subchannel *sch, struct schib *schib)
331 schib->pmcw.intparm = sch->config.intparm;
332 schib->pmcw.mbi = sch->config.mbi;
333 schib->pmcw.isc = sch->config.isc;
334 schib->pmcw.ena = sch->config.ena;
335 schib->pmcw.mme = sch->config.mme;
336 schib->pmcw.mp = sch->config.mp;
337 schib->pmcw.csense = sch->config.csense;
338 schib->pmcw.mbfc = sch->config.mbfc;
339 if (sch->config.mbfc)
340 schib->mba = sch->config.mba;
343 static int cio_check_config(struct subchannel *sch, struct schib *schib)
345 return (schib->pmcw.intparm == sch->config.intparm) &&
346 (schib->pmcw.mbi == sch->config.mbi) &&
347 (schib->pmcw.isc == sch->config.isc) &&
348 (schib->pmcw.ena == sch->config.ena) &&
349 (schib->pmcw.mme == sch->config.mme) &&
350 (schib->pmcw.mp == sch->config.mp) &&
351 (schib->pmcw.csense == sch->config.csense) &&
352 (schib->pmcw.mbfc == sch->config.mbfc) &&
353 (!sch->config.mbfc || (schib->mba == sch->config.mba));
357 * cio_commit_config - apply configuration to the subchannel
359 int cio_commit_config(struct subchannel *sch)
362 int ccode, retry, ret = 0;
364 if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib))
367 for (retry = 0; retry < 5; retry++) {
368 /* copy desired changes to local schib */
369 cio_apply_config(sch, &schib);
370 ccode = msch_err(sch->schid, &schib);
371 if (ccode < 0) /* -EIO if msch gets a program check. */
374 case 0: /* successful */
375 if (stsch(sch->schid, &schib) ||
376 !css_sch_is_valid(&schib))
378 if (cio_check_config(sch, &schib)) {
379 /* commit changes from local schib */
380 memcpy(&sch->schib, &schib, sizeof(schib));
385 case 1: /* status pending */
388 udelay(100); /* allow for recovery */
391 case 3: /* not operational */
399 * cio_update_schib - Perform stsch and update schib if subchannel is valid.
400 * @sch: subchannel on which to perform stsch
401 * Return zero on success, -ENODEV otherwise.
403 int cio_update_schib(struct subchannel *sch)
407 if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib))
410 memcpy(&sch->schib, &schib, sizeof(schib));
413 EXPORT_SYMBOL_GPL(cio_update_schib);
416 * cio_enable_subchannel - enable a subchannel.
417 * @sch: subchannel to be enabled
418 * @intparm: interruption parameter to set
420 int cio_enable_subchannel(struct subchannel *sch, u32 intparm)
425 CIO_TRACE_EVENT(2, "ensch");
426 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
428 if (sch_is_pseudo_sch(sch))
430 if (cio_update_schib(sch))
434 sch->config.isc = sch->isc;
435 sch->config.intparm = intparm;
437 for (retry = 0; retry < 3; retry++) {
438 ret = cio_commit_config(sch);
441 * Got a program check in msch. Try without
442 * the concurrent sense bit the next time.
444 sch->config.csense = 0;
445 } else if (ret == -EBUSY) {
447 if (tsch(sch->schid, &irb) != 0)
452 CIO_HEX_EVENT(2, &ret, sizeof(ret));
455 EXPORT_SYMBOL_GPL(cio_enable_subchannel);
458 * cio_disable_subchannel - disable a subchannel.
459 * @sch: subchannel to disable
461 int cio_disable_subchannel(struct subchannel *sch)
466 CIO_TRACE_EVENT(2, "dissch");
467 CIO_TRACE_EVENT(2, dev_name(&sch->dev));
469 if (sch_is_pseudo_sch(sch))
471 if (cio_update_schib(sch))
476 for (retry = 0; retry < 3; retry++) {
477 ret = cio_commit_config(sch);
480 if (tsch(sch->schid, &irb) != 0)
485 CIO_HEX_EVENT(2, &ret, sizeof(ret));
488 EXPORT_SYMBOL_GPL(cio_disable_subchannel);
490 int cio_create_sch_lock(struct subchannel *sch)
492 sch->lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
495 spin_lock_init(sch->lock);
499 static int cio_check_devno_blacklisted(struct subchannel *sch)
501 if (is_blacklisted(sch->schid.ssid, sch->schib.pmcw.dev)) {
503 * This device must not be known to Linux. So we simply
504 * say that there is no device and return ENODEV.
506 CIO_MSG_EVENT(6, "Blacklisted device detected "
507 "at devno %04X, subchannel set %x\n",
508 sch->schib.pmcw.dev, sch->schid.ssid);
514 static int cio_validate_io_subchannel(struct subchannel *sch)
516 /* Initialization for io subchannels. */
517 if (!css_sch_is_valid(&sch->schib))
520 /* Devno is valid. */
521 return cio_check_devno_blacklisted(sch);
524 static int cio_validate_msg_subchannel(struct subchannel *sch)
526 /* Initialization for message subchannels. */
527 if (!css_sch_is_valid(&sch->schib))
530 /* Devno is valid. */
531 return cio_check_devno_blacklisted(sch);
535 * cio_validate_subchannel - basic validation of subchannel
536 * @sch: subchannel structure to be filled out
537 * @schid: subchannel id
539 * Find out subchannel type and initialize struct subchannel.
542 * -ENXIO for non-defined subchannels
543 * -ENODEV for invalid subchannels or blacklisted devices
544 * -EIO for subchannels in an invalid subchannel set
546 int cio_validate_subchannel(struct subchannel *sch, struct subchannel_id schid)
552 sprintf(dbf_txt, "valsch%x", schid.sch_no);
553 CIO_TRACE_EVENT(4, dbf_txt);
555 /* Nuke all fields. */
556 memset(sch, 0, sizeof(struct subchannel));
559 if (cio_is_console(schid)) {
560 sch->lock = cio_get_console_lock();
562 err = cio_create_sch_lock(sch);
566 mutex_init(&sch->reg_mutex);
567 /* Set a name for the subchannel */
568 if (cio_is_console(schid))
569 sch->dev.init_name = cio_get_console_sch_name(schid);
571 dev_set_name(&sch->dev, "0.%x.%04x", schid.ssid, schid.sch_no);
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
616 void __irq_entry do_IRQ(struct pt_regs *regs)
618 struct tpi_info *tpi_info;
619 struct subchannel *sch;
621 struct pt_regs *old_regs;
623 old_regs = set_irq_regs(regs);
626 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator)
627 /* Serve timer interrupts first. */
628 clock_comparator_work();
630 * Get interrupt information from lowcore
632 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
633 irb = (struct irb *) __LC_IRB;
635 kstat_cpu(smp_processor_id()).irqs[IO_INTERRUPT]++;
637 * Non I/O-subchannel thin interrupts are processed differently
639 if (tpi_info->adapter_IO == 1 &&
640 tpi_info->int_type == IO_INTERRUPT_TYPE) {
641 do_adapter_IO(tpi_info->isc);
644 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
646 /* Clear pending interrupt condition. */
647 tsch(tpi_info->schid, irb);
650 spin_lock(sch->lock);
651 /* Store interrupt response block to lowcore. */
652 if (tsch(tpi_info->schid, irb) == 0) {
653 /* Keep subchannel information word up to date. */
654 memcpy (&sch->schib.scsw, &irb->scsw,
656 /* Call interrupt handler if there is one. */
657 if (sch->driver && sch->driver->irq)
658 sch->driver->irq(sch);
660 spin_unlock(sch->lock);
662 * Are more interrupts pending?
663 * If so, the tpi instruction will update the lowcore
664 * to hold the info for the next interrupt.
665 * We don't do this for VM because a tpi drops the cpu
666 * out of the sie which costs more cycles than it saves.
668 } while (!MACHINE_IS_VM && tpi (NULL) != 0);
670 set_irq_regs(old_regs);
673 #ifdef CONFIG_CCW_CONSOLE
674 static struct subchannel console_subchannel;
675 static char console_sch_name[10] = "0.x.xxxx";
676 static struct io_subchannel_private console_priv;
677 static int console_subchannel_in_use;
680 * Use tpi to get a pending interrupt, call the interrupt handler and
681 * return a pointer to the subchannel structure.
683 static int cio_tpi(void)
685 struct tpi_info *tpi_info;
686 struct subchannel *sch;
690 tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID;
693 irb = (struct irb *) __LC_IRB;
694 /* Store interrupt response block to lowcore. */
695 if (tsch(tpi_info->schid, irb) != 0)
696 /* Not status pending or not operational. */
698 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
701 irq_context = in_interrupt();
705 spin_lock(sch->lock);
706 memcpy(&sch->schib.scsw, &irb->scsw, sizeof(union scsw));
707 if (sch->driver && sch->driver->irq)
708 sch->driver->irq(sch);
709 spin_unlock(sch->lock);
716 void *cio_get_console_priv(void)
718 return &console_priv;
722 * busy wait for the next interrupt on the console
724 void wait_cons_dev(void)
725 __releases(console_subchannel.lock)
726 __acquires(console_subchannel.lock)
728 unsigned long cr6 __attribute__ ((aligned (8)));
729 unsigned long save_cr6 __attribute__ ((aligned (8)));
732 * before entering the spinlock we may already have
733 * processed the interrupt on a different CPU...
735 if (!console_subchannel_in_use)
738 /* disable all but the console isc */
739 __ctl_store (save_cr6, 6, 6);
740 cr6 = 1UL << (31 - CONSOLE_ISC);
741 __ctl_load (cr6, 6, 6);
744 spin_unlock(console_subchannel.lock);
747 spin_lock(console_subchannel.lock);
748 } while (console_subchannel.schib.scsw.cmd.actl != 0);
750 * restore previous isc value
752 __ctl_load (save_cr6, 6, 6);
756 cio_test_for_console(struct subchannel_id schid, void *data)
758 if (stsch_err(schid, &console_subchannel.schib) != 0)
760 if ((console_subchannel.schib.pmcw.st == SUBCHANNEL_TYPE_IO) &&
761 console_subchannel.schib.pmcw.dnv &&
762 (console_subchannel.schib.pmcw.dev == console_devno)) {
763 console_irq = schid.sch_no;
764 return 1; /* found */
771 cio_get_console_sch_no(void)
773 struct subchannel_id schid;
775 init_subchannel_id(&schid);
776 if (console_irq != -1) {
777 /* VM provided us with the irq number of the console. */
778 schid.sch_no = console_irq;
779 if (stsch(schid, &console_subchannel.schib) != 0 ||
780 (console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) ||
781 !console_subchannel.schib.pmcw.dnv)
783 console_devno = console_subchannel.schib.pmcw.dev;
784 } else if (console_devno != -1) {
785 /* At least the console device number is known. */
786 for_each_subchannel(cio_test_for_console, NULL);
787 if (console_irq == -1)
790 /* unlike in 2.4, we cannot autoprobe here, since
791 * the channel subsystem is not fully initialized.
792 * With some luck, the HWC console can take over */
799 cio_probe_console(void)
802 struct subchannel_id schid;
804 if (xchg(&console_subchannel_in_use, 1) != 0)
805 return ERR_PTR(-EBUSY);
806 sch_no = cio_get_console_sch_no();
808 console_subchannel_in_use = 0;
809 pr_warning("No CCW console was found\n");
810 return ERR_PTR(-ENODEV);
812 memset(&console_subchannel, 0, sizeof(struct subchannel));
813 init_subchannel_id(&schid);
814 schid.sch_no = sch_no;
815 ret = cio_validate_subchannel(&console_subchannel, schid);
817 console_subchannel_in_use = 0;
818 return ERR_PTR(-ENODEV);
822 * enable console I/O-interrupt subclass
824 isc_register(CONSOLE_ISC);
825 console_subchannel.config.isc = CONSOLE_ISC;
826 console_subchannel.config.intparm = (u32)(addr_t)&console_subchannel;
827 ret = cio_commit_config(&console_subchannel);
829 isc_unregister(CONSOLE_ISC);
830 console_subchannel_in_use = 0;
833 return &console_subchannel;
837 cio_release_console(void)
839 console_subchannel.config.intparm = 0;
840 cio_commit_config(&console_subchannel);
841 isc_unregister(CONSOLE_ISC);
842 console_subchannel_in_use = 0;
845 /* Bah... hack to catch console special sausages. */
847 cio_is_console(struct subchannel_id schid)
849 if (!console_subchannel_in_use)
851 return schid_equal(&schid, &console_subchannel.schid);
855 cio_get_console_subchannel(void)
857 if (!console_subchannel_in_use)
859 return &console_subchannel;
862 const char *cio_get_console_sch_name(struct subchannel_id schid)
864 snprintf(console_sch_name, 10, "0.%x.%04x", schid.ssid, schid.sch_no);
865 return (const char *)console_sch_name;
870 __disable_subchannel_easy(struct subchannel_id schid, struct schib *schib)
875 for (retry=0;retry<3;retry++) {
877 cc = msch(schid, schib);
879 return (cc==3?-ENODEV:-EBUSY);
880 if (stsch(schid, schib) || !css_sch_is_valid(schib))
882 if (!schib->pmcw.ena)
885 return -EBUSY; /* uhm... */
889 __clear_io_subchannel_easy(struct subchannel_id schid)
895 for (retry=0;retry<20;retry++) {
899 tsch(ti.schid, (struct irb *)__LC_IRB);
900 if (schid_equal(&ti.schid, &schid))
908 static void __clear_chsc_subchannel_easy(void)
910 /* It seems we can only wait for a bit here :/ */
914 static int pgm_check_occured;
916 static void cio_reset_pgm_check_handler(void)
918 pgm_check_occured = 1;
921 static int stsch_reset(struct subchannel_id schid, struct schib *addr)
925 pgm_check_occured = 0;
926 s390_base_pgm_handler_fn = cio_reset_pgm_check_handler;
927 rc = stsch(schid, addr);
928 s390_base_pgm_handler_fn = NULL;
930 /* The program check handler could have changed pgm_check_occured. */
933 if (pgm_check_occured)
939 static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
943 if (stsch_reset(schid, &schib))
947 switch(__disable_subchannel_easy(schid, &schib)) {
951 default: /* -EBUSY */
952 switch (schib.pmcw.st) {
953 case SUBCHANNEL_TYPE_IO:
954 if (__clear_io_subchannel_easy(schid))
955 goto out; /* give up... */
957 case SUBCHANNEL_TYPE_CHSC:
958 __clear_chsc_subchannel_easy();
961 /* No default clear strategy */
964 stsch(schid, &schib);
965 __disable_subchannel_easy(schid, &schib);
971 static atomic_t chpid_reset_count;
973 static void s390_reset_chpids_mcck_handler(void)
978 /* Check for pending channel report word. */
979 mci = (struct mci *)&S390_lowcore.mcck_interruption_code;
982 /* Process channel report words. */
983 while (stcrw(&crw) == 0) {
984 /* Check for responses to RCHP. */
985 if (crw.slct && crw.rsc == CRW_RSC_CPATH)
986 atomic_dec(&chpid_reset_count);
990 #define RCHP_TIMEOUT (30 * USEC_PER_SEC)
991 static void css_reset(void)
994 unsigned long long timeout;
997 /* Reset subchannels. */
998 for_each_subchannel(__shutdown_subchannel_easy, NULL);
999 /* Reset channel paths. */
1000 s390_base_mcck_handler_fn = s390_reset_chpids_mcck_handler;
1001 /* Enable channel report machine checks. */
1002 __ctl_set_bit(14, 28);
1003 /* Temporarily reenable machine checks. */
1004 local_mcck_enable();
1005 chp_id_init(&chpid);
1006 for (i = 0; i <= __MAX_CHPID; i++) {
1009 if ((ret == 0) || (ret == 2))
1011 * rchp either succeeded, or another rchp is already
1012 * in progress. In either case, we'll get a crw.
1014 atomic_inc(&chpid_reset_count);
1016 /* Wait for machine check for all channel paths. */
1017 timeout = get_clock() + (RCHP_TIMEOUT << 12);
1018 while (atomic_read(&chpid_reset_count) != 0) {
1019 if (get_clock() > timeout)
1023 /* Disable machine checks again. */
1024 local_mcck_disable();
1025 /* Disable channel report machine checks. */
1026 __ctl_clear_bit(14, 28);
1027 s390_base_mcck_handler_fn = NULL;
1030 static struct reset_call css_reset_call = {
1034 static int __init init_css_reset_call(void)
1036 atomic_set(&chpid_reset_count, 0);
1037 register_reset_call(&css_reset_call);
1041 arch_initcall(init_css_reset_call);
1043 struct sch_match_id {
1044 struct subchannel_id schid;
1045 struct ccw_dev_id devid;
1049 static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
1052 struct sch_match_id *match_id = data;
1054 if (stsch_reset(schid, &schib))
1056 if ((schib.pmcw.st == SUBCHANNEL_TYPE_IO) && schib.pmcw.dnv &&
1057 (schib.pmcw.dev == match_id->devid.devno) &&
1058 (schid.ssid == match_id->devid.ssid)) {
1059 match_id->schid = schid;
1066 static int reipl_find_schid(struct ccw_dev_id *devid,
1067 struct subchannel_id *schid)
1069 struct sch_match_id match_id;
1071 match_id.devid = *devid;
1072 match_id.rc = -ENODEV;
1073 for_each_subchannel(__reipl_subchannel_match, &match_id);
1074 if (match_id.rc == 0)
1075 *schid = match_id.schid;
1079 extern void do_reipl_asm(__u32 schid);
1081 /* Make sure all subchannels are quiet before we re-ipl an lpar. */
1082 void reipl_ccw_dev(struct ccw_dev_id *devid)
1084 struct subchannel_id schid;
1086 s390_reset_system();
1087 if (reipl_find_schid(devid, &schid) != 0)
1088 panic("IPL Device not found\n");
1089 do_reipl_asm(*((__u32*)&schid));
1092 int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo)
1094 struct subchannel_id schid;
1097 schid = *(struct subchannel_id *)__LC_SUBCHANNEL_ID;
1100 if (stsch(schid, &schib))
1102 if (schib.pmcw.st != SUBCHANNEL_TYPE_IO)
1104 if (!schib.pmcw.dnv)
1106 iplinfo->devno = schib.pmcw.dev;
1107 iplinfo->is_qdio = schib.pmcw.qf;
1112 * cio_tm_start_key - perform start function
1113 * @sch: subchannel on which to perform the start function
1114 * @tcw: transport-command word to be started
1115 * @lpm: mask of paths to use
1116 * @key: storage key to use for storage access
1118 * Start the tcw on the given subchannel. Return zero on success, non-zero
1121 int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key)
1124 union orb *orb = &to_io_private(sch)->orb;
1126 memset(orb, 0, sizeof(union orb));
1127 orb->tm.intparm = (u32) (addr_t) sch;
1128 orb->tm.key = key >> 4;
1130 orb->tm.lpm = lpm ? lpm : sch->lpm;
1131 orb->tm.tcw = (u32) (addr_t) tcw;
1132 cc = ssch(sch->schid, orb);
1140 return cio_start_handle_notoper(sch, lpm);
1145 * cio_tm_intrg - perform interrogate function
1146 * @sch - subchannel on which to perform the interrogate function
1148 * If the specified subchannel is running in transport-mode, perform the
1149 * interrogate function. Return zero on success, non-zero otherwie.
1151 int cio_tm_intrg(struct subchannel *sch)
1155 if (!to_io_private(sch)->orb.tm.b)
1157 cc = xsch(sch->schid);