11 #define KMSG_COMPONENT "cio"
12 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15 #include <linux/module.h>
17 #include <linux/slab.h>
18 #include <linux/device.h>
22 #include <asm/delay.h>
24 #include <asm/irq_regs.h>
25 #include <asm/setup.h>
28 #include <asm/chpid.h>
31 #include <asm/cputime.h>
55 static int __init cio_debug_init(
void)
57 cio_debug_msg_id =
debug_register(
"cio_msg", 16, 1, 16 *
sizeof(
long));
58 if (!cio_debug_msg_id)
63 if (!cio_debug_trace_id)
67 cio_debug_crw_id =
debug_register(
"cio_crw", 16, 1, 16 *
sizeof(
long));
68 if (!cio_debug_crw_id)
77 if (cio_debug_trace_id)
107 "subchannel 0.%x.%04x!\n", sch->
schid.ssid,
113 sprintf(dbf_text,
"no%s", dev_name(&sch->
dev));
133 memset(orb, 0,
sizeof(
union orb));
141 orb->
cmd.lpm = (lpm != 0) ? lpm : sch->
lpm;
149 orb->
cmd.key = key >> 4;
152 ccode = ssch(sch->
schid, orb);
155 CIO_HEX_EVENT(5, &ccode,
sizeof(ccode));
168 return cio_start_handle_notoper(sch, lpm);
191 ccode = rsch (sch->
schid);
193 CIO_HEX_EVENT(4, &ccode,
sizeof(ccode));
229 ccode = hsch (sch->
schid);
231 CIO_HEX_EVENT(2, &ccode,
sizeof(ccode));
262 ccode = csch (sch->
schid);
264 CIO_HEX_EVENT(2, &ccode,
sizeof(ccode));
293 ccode = xsch (sch->
schid);
295 CIO_HEX_EVENT(2, &ccode,
sizeof(ccode));
327 static int cio_check_config(
struct subchannel *sch,
struct schib *schib)
329 return (schib->
pmcw.intparm == sch->
config.intparm) &&
351 for (retry = 0; retry < 5; retry++) {
353 cio_apply_config(sch, &schib);
354 ccode = msch_err(sch->
schid, &schib);
359 if (stsch_err(sch->
schid, &schib) ||
362 if (cio_check_config(sch, &schib)) {
421 for (retry = 0; retry < 3; retry++) {
429 }
else if (ret == -
EBUSY) {
431 if (tsch(sch->
schid, &irb) != 0)
436 CIO_HEX_EVENT(2, &ret,
sizeof(ret));
460 for (retry = 0; retry < 3; retry++) {
464 if (tsch(sch->
schid, &irb) != 0)
469 CIO_HEX_EVENT(2, &ret,
sizeof(ret));
483 static int cio_check_devno_blacklisted(
struct subchannel *sch)
491 "at devno %04X, subchannel set %x\n",
498 static int cio_validate_io_subchannel(
struct subchannel *sch)
505 return cio_check_devno_blacklisted(sch);
508 static int cio_validate_msg_subchannel(
struct subchannel *sch)
515 return cio_check_devno_blacklisted(sch);
558 ccode = stsch_err (schid, &sch->
schib);
560 err = (ccode == 3) ? -
ENXIO : ccode;
568 err = cio_validate_io_subchannel(sch);
571 err = cio_validate_msg_subchannel(sch);
579 CIO_MSG_EVENT(4,
"Subchannel 0.%x.%04x reports subchannel type %04X\n",
602 old_regs = set_irq_regs(regs);
611 tpi_info = (
struct tpi_info *)&
S390_lowcore.subchannel_id;
623 tsch(tpi_info->
schid, irb);
626 spin_lock(sch->
lock);
628 if (tsch(tpi_info->
schid, irb) == 0) {
639 spin_unlock(sch->
lock);
649 set_irq_regs(old_regs);
652 #ifdef CONFIG_CCW_CONSOLE
655 static int console_subchannel_in_use;
668 if (tsch(sch->
schid, irb) != 0)
690 return &console_priv;
698 if (!console_subchannel_in_use)
702 cio_tsch(&console_subchannel);
703 if (console_subchannel.schib.scsw.cmd.actl == 0)
712 if (stsch_err(schid, &console_subchannel.schib) != 0)
715 console_subchannel.schib.pmcw.dnv &&
725 cio_get_console_sch_no(
void)
729 init_subchannel_id(&schid);
733 if (stsch_err(schid, &console_subchannel.schib) != 0 ||
735 !console_subchannel.schib.pmcw.dnv)
753 cio_probe_console(
void)
758 if (
xchg(&console_subchannel_in_use, 1) != 0)
759 return ERR_PTR(-
EBUSY);
760 sch_no = cio_get_console_sch_no();
762 console_subchannel_in_use = 0;
767 init_subchannel_id(&schid);
771 console_subchannel_in_use = 0;
780 console_subchannel.config.intparm = (
u32)(
addr_t)&console_subchannel;
784 console_subchannel_in_use = 0;
787 return &console_subchannel;
791 cio_release_console(
void)
793 console_subchannel.config.intparm = 0;
796 console_subchannel_in_use = 0;
803 if (!console_subchannel_in_use)
805 return schid_equal(&schid, &console_subchannel.schid);
811 if (!console_subchannel_in_use)
813 return &console_subchannel;
818 __disable_subchannel_easy(
struct subchannel_id schid,
struct schib *schib)
823 for (retry=0;retry<3;retry++) {
825 cc = msch_err(schid, schib);
830 if (!schib->
pmcw.ena)
843 for (retry=0;retry<20;retry++) {
848 if (schid_equal(&ti.schid, &schid))
856 static void __clear_chsc_subchannel_easy(
void)
862 static int pgm_check_occured;
864 static void cio_reset_pgm_check_handler(
void)
866 pgm_check_occured = 1;
873 pgm_check_occured = 0;
875 rc = stsch_err(schid, addr);
881 if (pgm_check_occured)
887 static int __shutdown_subchannel_easy(
struct subchannel_id schid,
void *data)
891 if (stsch_reset(schid, &schib))
895 switch(__disable_subchannel_easy(schid, &schib)) {
900 switch (schib.
pmcw.st) {
902 if (__clear_io_subchannel_easy(schid))
906 __clear_chsc_subchannel_easy();
912 stsch_err(schid, &schib);
913 __disable_subchannel_easy(schid, &schib);
921 static void s390_reset_chpids_mcck_handler(
void)
927 mci = (
struct mci *)&
S390_lowcore.mcck_interruption_code;
931 while (stcrw(&
crw) == 0) {
938 #define RCHP_TIMEOUT (30 * USEC_PER_SEC)
939 static void css_reset(
void)
957 if ((ret == 0) || (ret == 2))
982 static int __init init_css_reset_call(
void)
997 static int __reipl_subchannel_match(
struct subchannel_id schid,
void *data)
1002 if (stsch_reset(schid, &schib))
1005 (schib.
pmcw.dev == match_id->
devid.devno) &&
1022 if (match_id.rc == 0)
1023 *schid = match_id.schid;
1035 if (reipl_find_schid(devid, &schid) != 0)
1036 panic(
"IPL Device not found\n");
1048 if (stsch_err(schid, &schib))
1052 if (!schib.
pmcw.dnv)
1074 memset(orb, 0,
sizeof(
union orb));
1076 orb->
tm.key = key >> 4;
1078 orb->
tm.lpm = lpm ? lpm : sch->
lpm;
1080 cc = ssch(sch->
schid, orb);
1088 return cio_start_handle_notoper(sch, lpm);
1105 cc = xsch(sch->
schid);