Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/s390/cio/cio.c |
| 3 | * S/390 common I/O routines -- low level i/o calls |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Michael Holzheu | aa77015 | 2006-12-28 00:35:36 +0100 | [diff] [blame] | 5 | * Copyright (C) IBM Corp. 1999,2006 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Author(s): Ingo Adlung (adlung@de.ibm.com) |
Cornelia Huck | 4ce3b30 | 2006-01-14 13:21:04 -0800 | [diff] [blame] | 7 | * Cornelia Huck (cornelia.huck@de.ibm.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Arnd Bergmann (arndb@de.ibm.com) |
| 9 | * Martin Schwidefsky (schwidefsky@de.ibm.com) |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/cio.h> |
| 19 | #include <asm/delay.h> |
| 20 | #include <asm/irq.h> |
Heiko Carstens | 5a489b9 | 2006-10-06 16:38:35 +0200 | [diff] [blame] | 21 | #include <asm/irq_regs.h> |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 22 | #include <asm/setup.h> |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 23 | #include <asm/reset.h> |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 24 | #include <asm/ipl.h> |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 25 | #include <asm/chpid.h> |
Peter Oberparleiter | 4e8e56c | 2008-01-26 14:10:44 +0100 | [diff] [blame] | 26 | #include <asm/airq.h> |
Heiko Carstens | 43ca5c3 | 2008-04-17 07:46:23 +0200 | [diff] [blame] | 27 | #include <asm/cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include "cio.h" |
| 29 | #include "css.h" |
| 30 | #include "chsc.h" |
| 31 | #include "ioasm.h" |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 32 | #include "io_sch.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "blacklist.h" |
| 34 | #include "cio_debug.h" |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 35 | #include "chp.h" |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 36 | #include "../s390mach.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | debug_info_t *cio_debug_msg_id; |
| 39 | debug_info_t *cio_debug_trace_id; |
| 40 | debug_info_t *cio_debug_crw_id; |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | /* |
| 43 | * Function: cio_debug_init |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 44 | * Initializes three debug logs for common I/O: |
| 45 | * - cio_msg logs generic cio messages |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | * - cio_trace logs the calling of different functions |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 47 | * - cio_crw logs machine check related cio messages |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | */ |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 49 | static int __init cio_debug_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Peter Tiedemann | 361f494 | 2008-01-26 14:11:30 +0100 | [diff] [blame] | 51 | cio_debug_msg_id = debug_register("cio_msg", 16, 1, 16 * sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | if (!cio_debug_msg_id) |
| 53 | goto out_unregister; |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 54 | debug_register_view(cio_debug_msg_id, &debug_sprintf_view); |
| 55 | debug_set_level(cio_debug_msg_id, 2); |
Peter Tiedemann | 361f494 | 2008-01-26 14:11:30 +0100 | [diff] [blame] | 56 | cio_debug_trace_id = debug_register("cio_trace", 16, 1, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | if (!cio_debug_trace_id) |
| 58 | goto out_unregister; |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 59 | debug_register_view(cio_debug_trace_id, &debug_hex_ascii_view); |
| 60 | debug_set_level(cio_debug_trace_id, 2); |
Peter Tiedemann | 361f494 | 2008-01-26 14:11:30 +0100 | [diff] [blame] | 61 | cio_debug_crw_id = debug_register("cio_crw", 16, 1, 16 * sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | if (!cio_debug_crw_id) |
| 63 | goto out_unregister; |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 64 | debug_register_view(cio_debug_crw_id, &debug_sprintf_view); |
| 65 | debug_set_level(cio_debug_crw_id, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | return 0; |
| 67 | |
| 68 | out_unregister: |
| 69 | if (cio_debug_msg_id) |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 70 | debug_unregister(cio_debug_msg_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | if (cio_debug_trace_id) |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 72 | debug_unregister(cio_debug_trace_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | if (cio_debug_crw_id) |
Cornelia Huck | bc698bc | 2008-01-26 14:10:42 +0100 | [diff] [blame] | 74 | debug_unregister(cio_debug_crw_id); |
Cornelia Huck | e556bbb | 2007-07-27 12:29:19 +0200 | [diff] [blame] | 75 | printk(KERN_WARNING"cio: could not initialize debugging\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | return -1; |
| 77 | } |
| 78 | |
| 79 | arch_initcall (cio_debug_init); |
| 80 | |
| 81 | int |
| 82 | cio_set_options (struct subchannel *sch, int flags) |
| 83 | { |
| 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; |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | /* FIXME: who wants to use this? */ |
| 91 | int |
| 92 | cio_get_options (struct subchannel *sch) |
| 93 | { |
| 94 | int flags; |
| 95 | |
| 96 | flags = 0; |
| 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; |
| 103 | return flags; |
| 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Use tpi to get a pending interrupt, call the interrupt handler and |
| 108 | * return a pointer to the subchannel structure. |
| 109 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 110 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | cio_tpi(void) |
| 112 | { |
| 113 | struct tpi_info *tpi_info; |
| 114 | struct subchannel *sch; |
| 115 | struct irb *irb; |
| 116 | |
| 117 | tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID; |
| 118 | if (tpi (NULL) != 1) |
| 119 | return 0; |
| 120 | irb = (struct irb *) __LC_IRB; |
| 121 | /* Store interrupt response block to lowcore. */ |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 122 | if (tsch (tpi_info->schid, irb) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | /* Not status pending or not operational. */ |
| 124 | return 1; |
| 125 | sch = (struct subchannel *)(unsigned long)tpi_info->intparm; |
| 126 | if (!sch) |
| 127 | return 1; |
| 128 | local_bh_disable(); |
| 129 | irq_enter (); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 130 | spin_lock(sch->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | memcpy (&sch->schib.scsw, &irb->scsw, sizeof (struct scsw)); |
| 132 | if (sch->driver && sch->driver->irq) |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 133 | sch->driver->irq(sch); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 134 | spin_unlock(sch->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | irq_exit (); |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 136 | _local_bh_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | return 1; |
| 138 | } |
| 139 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 140 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | cio_start_handle_notoper(struct subchannel *sch, __u8 lpm) |
| 142 | { |
| 143 | char dbf_text[15]; |
| 144 | |
| 145 | if (lpm != 0) |
| 146 | sch->lpm &= ~lpm; |
| 147 | else |
| 148 | sch->lpm = 0; |
| 149 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 150 | stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
Michael Ernst | 139b83d | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 152 | CIO_MSG_EVENT(2, "cio_start: 'not oper' status for " |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 153 | "subchannel 0.%x.%04x!\n", sch->schid.ssid, |
| 154 | sch->schid.sch_no); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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)); |
| 158 | |
| 159 | return (sch->lpm ? -EACCES : -ENODEV); |
| 160 | } |
| 161 | |
| 162 | int |
| 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 */ |
| 167 | { |
| 168 | char dbf_txt[15]; |
| 169 | int ccode; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 170 | struct orb *orb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 172 | CIO_TRACE_EVENT(4, "stIO"); |
| 173 | CIO_TRACE_EVENT(4, sch->dev.bus_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 175 | orb = &to_io_private(sch)->orb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | /* sch is always under 2G. */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 177 | orb->intparm = (u32)(addr_t)sch; |
| 178 | orb->fmt = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 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; |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 184 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | /* |
| 186 | * for 64 bit we always support 64 bit IDAWs with 4k page size only |
| 187 | */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 188 | orb->c64 = 1; |
| 189 | orb->i2k = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | #endif |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 191 | orb->key = key >> 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | /* issue "Start Subchannel" */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 193 | orb->cpa = (__u32) __pa(cpa); |
| 194 | ccode = ssch(sch->schid, orb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
| 196 | /* process condition code */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 197 | sprintf(dbf_txt, "ccode:%d", ccode); |
| 198 | CIO_TRACE_EVENT(4, dbf_txt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | switch (ccode) { |
| 201 | case 0: |
| 202 | /* |
| 203 | * initialize device status information |
| 204 | */ |
| 205 | sch->schib.scsw.actl |= SCSW_ACTL_START_PEND; |
| 206 | return 0; |
| 207 | case 1: /* status pending */ |
| 208 | case 2: /* busy */ |
| 209 | return -EBUSY; |
| 210 | default: /* device/path not operational */ |
| 211 | return cio_start_handle_notoper(sch, lpm); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | int |
| 216 | cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm) |
| 217 | { |
Peter Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 218 | return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /* |
| 222 | * resume suspended I/O operation |
| 223 | */ |
| 224 | int |
| 225 | cio_resume (struct subchannel *sch) |
| 226 | { |
| 227 | char dbf_txt[15]; |
| 228 | int ccode; |
| 229 | |
| 230 | CIO_TRACE_EVENT (4, "resIO"); |
| 231 | CIO_TRACE_EVENT (4, sch->dev.bus_id); |
| 232 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 233 | ccode = rsch (sch->schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
| 235 | sprintf (dbf_txt, "ccode:%d", ccode); |
| 236 | CIO_TRACE_EVENT (4, dbf_txt); |
| 237 | |
| 238 | switch (ccode) { |
| 239 | case 0: |
| 240 | sch->schib.scsw.actl |= SCSW_ACTL_RESUME_PEND; |
| 241 | return 0; |
| 242 | case 1: |
| 243 | return -EBUSY; |
| 244 | case 2: |
| 245 | return -EINVAL; |
| 246 | default: |
| 247 | /* |
| 248 | * useless to wait for request completion |
| 249 | * as device is no longer operational ! |
| 250 | */ |
| 251 | return -ENODEV; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * halt I/O operation |
| 257 | */ |
| 258 | int |
| 259 | cio_halt(struct subchannel *sch) |
| 260 | { |
| 261 | char dbf_txt[15]; |
| 262 | int ccode; |
| 263 | |
| 264 | if (!sch) |
| 265 | return -ENODEV; |
| 266 | |
| 267 | CIO_TRACE_EVENT (2, "haltIO"); |
| 268 | CIO_TRACE_EVENT (2, sch->dev.bus_id); |
| 269 | |
| 270 | /* |
| 271 | * Issue "Halt subchannel" and process condition code |
| 272 | */ |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 273 | ccode = hsch (sch->schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | |
| 275 | sprintf (dbf_txt, "ccode:%d", ccode); |
| 276 | CIO_TRACE_EVENT (2, dbf_txt); |
| 277 | |
| 278 | switch (ccode) { |
| 279 | case 0: |
| 280 | sch->schib.scsw.actl |= SCSW_ACTL_HALT_PEND; |
| 281 | return 0; |
| 282 | case 1: /* status pending */ |
| 283 | case 2: /* busy */ |
| 284 | return -EBUSY; |
| 285 | default: /* device not operational */ |
| 286 | return -ENODEV; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | /* |
| 291 | * Clear I/O operation |
| 292 | */ |
| 293 | int |
| 294 | cio_clear(struct subchannel *sch) |
| 295 | { |
| 296 | char dbf_txt[15]; |
| 297 | int ccode; |
| 298 | |
| 299 | if (!sch) |
| 300 | return -ENODEV; |
| 301 | |
| 302 | CIO_TRACE_EVENT (2, "clearIO"); |
| 303 | CIO_TRACE_EVENT (2, sch->dev.bus_id); |
| 304 | |
| 305 | /* |
| 306 | * Issue "Clear subchannel" and process condition code |
| 307 | */ |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 308 | ccode = csch (sch->schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
| 310 | sprintf (dbf_txt, "ccode:%d", ccode); |
| 311 | CIO_TRACE_EVENT (2, dbf_txt); |
| 312 | |
| 313 | switch (ccode) { |
| 314 | case 0: |
| 315 | sch->schib.scsw.actl |= SCSW_ACTL_CLEAR_PEND; |
| 316 | return 0; |
| 317 | default: /* device not operational */ |
| 318 | return -ENODEV; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | /* |
| 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. |
| 328 | */ |
| 329 | int |
| 330 | cio_cancel (struct subchannel *sch) |
| 331 | { |
| 332 | char dbf_txt[15]; |
| 333 | int ccode; |
| 334 | |
| 335 | if (!sch) |
| 336 | return -ENODEV; |
| 337 | |
| 338 | CIO_TRACE_EVENT (2, "cancelIO"); |
| 339 | CIO_TRACE_EVENT (2, sch->dev.bus_id); |
| 340 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 341 | ccode = xsch (sch->schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | sprintf (dbf_txt, "ccode:%d", ccode); |
| 344 | CIO_TRACE_EVENT (2, dbf_txt); |
| 345 | |
| 346 | switch (ccode) { |
| 347 | case 0: /* success */ |
| 348 | /* Update information in scsw. */ |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 349 | stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | return 0; |
| 351 | case 1: /* status pending */ |
| 352 | return -EBUSY; |
| 353 | case 2: /* not applicable */ |
| 354 | return -EINVAL; |
| 355 | default: /* not oper */ |
| 356 | return -ENODEV; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | /* |
| 361 | * Function: cio_modify |
| 362 | * Issues a "Modify Subchannel" on the specified subchannel |
| 363 | */ |
| 364 | int |
| 365 | cio_modify (struct subchannel *sch) |
| 366 | { |
| 367 | int ccode, retry, ret; |
| 368 | |
| 369 | ret = 0; |
| 370 | for (retry = 0; retry < 5; retry++) { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 371 | ccode = msch_err (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | if (ccode < 0) /* -EIO if msch gets a program check. */ |
| 373 | return ccode; |
| 374 | switch (ccode) { |
| 375 | case 0: /* successfull */ |
| 376 | return 0; |
| 377 | case 1: /* status pending */ |
| 378 | return -EBUSY; |
| 379 | case 2: /* busy */ |
| 380 | udelay (100); /* allow for recovery */ |
| 381 | ret = -EBUSY; |
| 382 | break; |
| 383 | case 3: /* not operational */ |
| 384 | return -ENODEV; |
| 385 | } |
| 386 | } |
| 387 | return ret; |
| 388 | } |
| 389 | |
| 390 | /* |
| 391 | * Enable subchannel. |
| 392 | */ |
Cornelia Huck | edf2209 | 2008-04-30 13:38:39 +0200 | [diff] [blame] | 393 | int cio_enable_subchannel(struct subchannel *sch, u32 intparm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | { |
| 395 | char dbf_txt[15]; |
| 396 | int ccode; |
| 397 | int retry; |
| 398 | int ret; |
| 399 | |
| 400 | CIO_TRACE_EVENT (2, "ensch"); |
| 401 | CIO_TRACE_EVENT (2, sch->dev.bus_id); |
| 402 | |
Cornelia Huck | d7b5a4c | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 403 | if (sch_is_pseudo_sch(sch)) |
| 404 | return -EINVAL; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 405 | ccode = stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | if (ccode) |
| 407 | return -ENODEV; |
| 408 | |
| 409 | for (retry = 5, ret = 0; retry > 0; retry--) { |
| 410 | sch->schib.pmcw.ena = 1; |
Cornelia Huck | edf2209 | 2008-04-30 13:38:39 +0200 | [diff] [blame] | 411 | sch->schib.pmcw.isc = sch->isc; |
Cornelia Huck | b279a4f | 2008-01-26 14:10:45 +0100 | [diff] [blame] | 412 | sch->schib.pmcw.intparm = intparm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | ret = cio_modify(sch); |
| 414 | if (ret == -ENODEV) |
| 415 | break; |
| 416 | if (ret == -EIO) |
| 417 | /* |
| 418 | * Got a program check in cio_modify. Try without |
| 419 | * the concurrent sense bit the next time. |
| 420 | */ |
| 421 | sch->schib.pmcw.csense = 0; |
| 422 | if (ret == 0) { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 423 | stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | if (sch->schib.pmcw.ena) |
| 425 | break; |
| 426 | } |
| 427 | if (ret == -EBUSY) { |
| 428 | struct irb irb; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 429 | if (tsch(sch->schid, &irb) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | break; |
| 431 | } |
| 432 | } |
| 433 | sprintf (dbf_txt, "ret:%d", ret); |
| 434 | CIO_TRACE_EVENT (2, dbf_txt); |
| 435 | return ret; |
| 436 | } |
| 437 | |
| 438 | /* |
| 439 | * Disable subchannel. |
| 440 | */ |
| 441 | int |
| 442 | cio_disable_subchannel (struct subchannel *sch) |
| 443 | { |
| 444 | char dbf_txt[15]; |
| 445 | int ccode; |
| 446 | int retry; |
| 447 | int ret; |
| 448 | |
| 449 | CIO_TRACE_EVENT (2, "dissch"); |
| 450 | CIO_TRACE_EVENT (2, sch->dev.bus_id); |
| 451 | |
Cornelia Huck | d7b5a4c | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 452 | if (sch_is_pseudo_sch(sch)) |
| 453 | return 0; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 454 | ccode = stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | if (ccode == 3) /* Not operational. */ |
| 456 | return -ENODEV; |
| 457 | |
| 458 | if (sch->schib.scsw.actl != 0) |
| 459 | /* |
| 460 | * the disable function must not be called while there are |
| 461 | * requests pending for completion ! |
| 462 | */ |
| 463 | return -EBUSY; |
| 464 | |
| 465 | for (retry = 5, ret = 0; retry > 0; retry--) { |
| 466 | sch->schib.pmcw.ena = 0; |
| 467 | ret = cio_modify(sch); |
| 468 | if (ret == -ENODEV) |
| 469 | break; |
| 470 | if (ret == -EBUSY) |
| 471 | /* |
| 472 | * The subchannel is busy or status pending. |
| 473 | * We'll disable when the next interrupt was delivered |
| 474 | * via the state machine. |
| 475 | */ |
| 476 | break; |
| 477 | if (ret == 0) { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 478 | stsch (sch->schid, &sch->schib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | if (!sch->schib.pmcw.ena) |
| 480 | break; |
| 481 | } |
| 482 | } |
| 483 | sprintf (dbf_txt, "ret:%d", ret); |
| 484 | CIO_TRACE_EVENT (2, dbf_txt); |
| 485 | return ret; |
| 486 | } |
| 487 | |
Cornelia Huck | d7b5a4c | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 488 | int cio_create_sch_lock(struct subchannel *sch) |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 489 | { |
| 490 | sch->lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL); |
| 491 | if (!sch->lock) |
| 492 | return -ENOMEM; |
| 493 | spin_lock_init(sch->lock); |
| 494 | return 0; |
| 495 | } |
| 496 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | /* |
| 498 | * cio_validate_subchannel() |
| 499 | * |
| 500 | * Find out subchannel type and initialize struct subchannel. |
| 501 | * Return codes: |
| 502 | * SUBCHANNEL_TYPE_IO for a normal io subchannel |
| 503 | * SUBCHANNEL_TYPE_CHSC for a chsc subchannel |
| 504 | * SUBCHANNEL_TYPE_MESSAGE for a messaging subchannel |
| 505 | * SUBCHANNEL_TYPE_ADM for a adm(?) subchannel |
| 506 | * -ENXIO for non-defined subchannels |
| 507 | * -ENODEV for subchannels with invalid device number or blacklisted devices |
| 508 | */ |
| 509 | int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 510 | cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | { |
| 512 | char dbf_txt[15]; |
| 513 | int ccode; |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 514 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 516 | sprintf (dbf_txt, "valsch%x", schid.sch_no); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | CIO_TRACE_EVENT (4, dbf_txt); |
| 518 | |
| 519 | /* Nuke all fields. */ |
| 520 | memset(sch, 0, sizeof(struct subchannel)); |
| 521 | |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 522 | sch->schid = schid; |
| 523 | if (cio_is_console(schid)) { |
| 524 | sch->lock = cio_get_console_lock(); |
| 525 | } else { |
| 526 | err = cio_create_sch_lock(sch); |
| 527 | if (err) |
| 528 | goto out; |
| 529 | } |
Cornelia Huck | 6ab4879 | 2006-07-12 16:39:50 +0200 | [diff] [blame] | 530 | mutex_init(&sch->reg_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | /* Set a name for the subchannel */ |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 532 | snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid, |
| 533 | schid.sch_no); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
| 535 | /* |
| 536 | * The first subchannel that is not-operational (ccode==3) |
| 537 | * indicates that there aren't any more devices available. |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 538 | * If stsch gets an exception, it means the current subchannel set |
| 539 | * is not valid. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | */ |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 541 | ccode = stsch_err (schid, &sch->schib); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 542 | if (ccode) { |
| 543 | err = (ccode == 3) ? -ENXIO : ccode; |
| 544 | goto out; |
| 545 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | /* Copy subchannel type from path management control word. */ |
| 547 | sch->st = sch->schib.pmcw.st; |
| 548 | |
| 549 | /* |
| 550 | * ... just being curious we check for non I/O subchannels |
| 551 | */ |
| 552 | if (sch->st != 0) { |
Michael Ernst | 139b83d | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 553 | CIO_MSG_EVENT(4, "Subchannel 0.%x.%04x reports " |
| 554 | "non-I/O subchannel type %04X\n", |
| 555 | sch->schid.ssid, sch->schid.sch_no, sch->st); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | /* We stop here for non-io subchannels. */ |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 557 | err = sch->st; |
| 558 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | /* Initialization for io subchannels. */ |
Michael Ernst | 808e488 | 2008-01-26 14:10:51 +0100 | [diff] [blame] | 562 | if (!css_sch_is_valid(&sch->schib)) { |
| 563 | err = -ENODEV; |
| 564 | goto out; |
| 565 | } |
| 566 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | /* Devno is valid. */ |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 568 | if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | /* |
| 570 | * This device must not be known to Linux. So we simply |
| 571 | * say that there is no device and return ENODEV. |
| 572 | */ |
Michael Ernst | 139b83d | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 573 | CIO_MSG_EVENT(6, "Blacklisted device detected " |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 574 | "at devno %04X, subchannel set %x\n", |
| 575 | sch->schib.pmcw.dev, sch->schid.ssid); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 576 | err = -ENODEV; |
| 577 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 579 | if (cio_is_console(sch->schid)) { |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 580 | sch->opm = 0xff; |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 581 | sch->isc = 1; |
| 582 | } else { |
Peter Oberparleiter | e6b6e10 | 2007-04-27 16:01:28 +0200 | [diff] [blame] | 583 | sch->opm = chp_get_sch_opm(sch); |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 584 | sch->isc = 3; |
| 585 | } |
Peter Oberparleiter | 28bdc6f | 2006-09-20 15:59:59 +0200 | [diff] [blame] | 586 | sch->lpm = sch->schib.pmcw.pam & sch->opm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
Michael Ernst | 139b83d | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 588 | CIO_MSG_EVENT(6, "Detected device %04x on subchannel 0.%x.%04X " |
| 589 | "- PIM = %02X, PAM = %02X, POM = %02X\n", |
| 590 | sch->schib.pmcw.dev, sch->schid.ssid, |
| 591 | sch->schid.sch_no, sch->schib.pmcw.pim, |
| 592 | sch->schib.pmcw.pam, sch->schib.pmcw.pom); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
| 594 | /* |
| 595 | * We now have to initially ... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | * ... enable "concurrent sense" |
| 597 | * ... enable "multipath mode" if more than one |
| 598 | * CHPID is available. This is done regardless |
| 599 | * whether multiple paths are available for us. |
| 600 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | sch->schib.pmcw.csense = 1; /* concurrent sense */ |
| 602 | sch->schib.pmcw.ena = 0; |
| 603 | if ((sch->lpm & (sch->lpm - 1)) != 0) |
| 604 | sch->schib.pmcw.mp = 1; /* multipath mode */ |
Cornelia Huck | 1842f2b | 2007-10-12 16:11:22 +0200 | [diff] [blame] | 605 | /* clean up possible residual cmf stuff */ |
| 606 | sch->schib.pmcw.mme = 0; |
| 607 | sch->schib.pmcw.mbfc = 0; |
| 608 | sch->schib.pmcw.mbi = 0; |
| 609 | sch->schib.mba = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | return 0; |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 611 | out: |
| 612 | if (!cio_is_console(schid)) |
| 613 | kfree(sch->lock); |
| 614 | sch->lock = NULL; |
| 615 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | /* |
| 619 | * do_IRQ() handles all normal I/O device IRQ's (the special |
| 620 | * SMP cross-CPU interrupts have their own specific |
| 621 | * handlers). |
| 622 | * |
| 623 | */ |
| 624 | void |
| 625 | do_IRQ (struct pt_regs *regs) |
| 626 | { |
| 627 | struct tpi_info *tpi_info; |
| 628 | struct subchannel *sch; |
| 629 | struct irb *irb; |
Heiko Carstens | 5a489b9 | 2006-10-06 16:38:35 +0200 | [diff] [blame] | 630 | struct pt_regs *old_regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
Heiko Carstens | 5a489b9 | 2006-10-06 16:38:35 +0200 | [diff] [blame] | 632 | old_regs = set_irq_regs(regs); |
Heiko Carstens | 9d0a57c | 2006-10-11 15:31:26 +0200 | [diff] [blame] | 633 | irq_enter(); |
Heiko Carstens | 43ca5c3 | 2008-04-17 07:46:23 +0200 | [diff] [blame] | 634 | s390_idle_check(); |
Heiko Carstens | 5a62b19 | 2008-04-17 07:46:25 +0200 | [diff] [blame] | 635 | if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator) |
| 636 | /* Serve timer interrupts first. */ |
| 637 | clock_comparator_work(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | /* |
| 639 | * Get interrupt information from lowcore |
| 640 | */ |
| 641 | tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID; |
| 642 | irb = (struct irb *) __LC_IRB; |
| 643 | do { |
| 644 | kstat_cpu(smp_processor_id()).irqs[IO_INTERRUPT]++; |
| 645 | /* |
| 646 | * Non I/O-subchannel thin interrupts are processed differently |
| 647 | */ |
| 648 | if (tpi_info->adapter_IO == 1 && |
| 649 | tpi_info->int_type == IO_INTERRUPT_TYPE) { |
| 650 | do_adapter_IO(); |
| 651 | continue; |
| 652 | } |
| 653 | sch = (struct subchannel *)(unsigned long)tpi_info->intparm; |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 654 | if (!sch) { |
| 655 | /* Clear pending interrupt condition. */ |
| 656 | tsch(tpi_info->schid, irb); |
| 657 | continue; |
| 658 | } |
| 659 | spin_lock(sch->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | /* Store interrupt response block to lowcore. */ |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 661 | if (tsch(tpi_info->schid, irb) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | /* Keep subchannel information word up to date. */ |
| 663 | memcpy (&sch->schib.scsw, &irb->scsw, |
| 664 | sizeof (irb->scsw)); |
| 665 | /* Call interrupt handler if there is one. */ |
| 666 | if (sch->driver && sch->driver->irq) |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 667 | sch->driver->irq(sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | } |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 669 | spin_unlock(sch->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | /* |
| 671 | * Are more interrupts pending? |
| 672 | * If so, the tpi instruction will update the lowcore |
| 673 | * to hold the info for the next interrupt. |
| 674 | * We don't do this for VM because a tpi drops the cpu |
| 675 | * out of the sie which costs more cycles than it saves. |
| 676 | */ |
| 677 | } while (!MACHINE_IS_VM && tpi (NULL) != 0); |
Heiko Carstens | 9d0a57c | 2006-10-11 15:31:26 +0200 | [diff] [blame] | 678 | irq_exit(); |
Heiko Carstens | 5a489b9 | 2006-10-06 16:38:35 +0200 | [diff] [blame] | 679 | set_irq_regs(old_regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | #ifdef CONFIG_CCW_CONSOLE |
| 683 | static struct subchannel console_subchannel; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 684 | static struct io_subchannel_private console_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | static int console_subchannel_in_use; |
| 686 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 687 | void *cio_get_console_priv(void) |
| 688 | { |
| 689 | return &console_priv; |
| 690 | } |
| 691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | /* |
| 693 | * busy wait for the next interrupt on the console |
| 694 | */ |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 695 | void wait_cons_dev(void) |
| 696 | __releases(console_subchannel.lock) |
| 697 | __acquires(console_subchannel.lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | { |
| 699 | unsigned long cr6 __attribute__ ((aligned (8))); |
| 700 | unsigned long save_cr6 __attribute__ ((aligned (8))); |
| 701 | |
| 702 | /* |
| 703 | * before entering the spinlock we may already have |
| 704 | * processed the interrupt on a different CPU... |
| 705 | */ |
| 706 | if (!console_subchannel_in_use) |
| 707 | return; |
| 708 | |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 709 | /* disable all but isc 1 (console device) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | __ctl_store (save_cr6, 6, 6); |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 711 | cr6 = 0x40000000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | __ctl_load (cr6, 6, 6); |
| 713 | |
| 714 | do { |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 715 | spin_unlock(console_subchannel.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | if (!cio_tpi()) |
| 717 | cpu_relax(); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 718 | spin_lock(console_subchannel.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | } while (console_subchannel.schib.scsw.actl != 0); |
| 720 | /* |
| 721 | * restore previous isc value |
| 722 | */ |
| 723 | __ctl_load (save_cr6, 6, 6); |
| 724 | } |
| 725 | |
| 726 | static int |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 727 | cio_test_for_console(struct subchannel_id schid, void *data) |
| 728 | { |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 729 | if (stsch_err(schid, &console_subchannel.schib) != 0) |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 730 | return -ENXIO; |
Cornelia Huck | b279a4f | 2008-01-26 14:10:45 +0100 | [diff] [blame] | 731 | if ((console_subchannel.schib.pmcw.st == SUBCHANNEL_TYPE_IO) && |
| 732 | console_subchannel.schib.pmcw.dnv && |
| 733 | (console_subchannel.schib.pmcw.dev == console_devno)) { |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 734 | console_irq = schid.sch_no; |
| 735 | return 1; /* found */ |
| 736 | } |
| 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | |
| 741 | static int |
| 742 | cio_get_console_sch_no(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 744 | struct subchannel_id schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 746 | init_subchannel_id(&schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | if (console_irq != -1) { |
| 748 | /* VM provided us with the irq number of the console. */ |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 749 | schid.sch_no = console_irq; |
| 750 | if (stsch(schid, &console_subchannel.schib) != 0 || |
Cornelia Huck | b279a4f | 2008-01-26 14:10:45 +0100 | [diff] [blame] | 751 | (console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | !console_subchannel.schib.pmcw.dnv) |
| 753 | return -1; |
| 754 | console_devno = console_subchannel.schib.pmcw.dev; |
| 755 | } else if (console_devno != -1) { |
| 756 | /* At least the console device number is known. */ |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 757 | for_each_subchannel(cio_test_for_console, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | if (console_irq == -1) |
| 759 | return -1; |
| 760 | } else { |
| 761 | /* unlike in 2.4, we cannot autoprobe here, since |
| 762 | * the channel subsystem is not fully initialized. |
| 763 | * With some luck, the HWC console can take over */ |
Cornelia Huck | e556bbb | 2007-07-27 12:29:19 +0200 | [diff] [blame] | 764 | printk(KERN_WARNING "cio: No ccw console found!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | return -1; |
| 766 | } |
| 767 | return console_irq; |
| 768 | } |
| 769 | |
| 770 | struct subchannel * |
| 771 | cio_probe_console(void) |
| 772 | { |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 773 | int sch_no, ret; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 774 | struct subchannel_id schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
| 776 | if (xchg(&console_subchannel_in_use, 1) != 0) |
| 777 | return ERR_PTR(-EBUSY); |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 778 | sch_no = cio_get_console_sch_no(); |
| 779 | if (sch_no == -1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | console_subchannel_in_use = 0; |
| 781 | return ERR_PTR(-ENODEV); |
| 782 | } |
| 783 | memset(&console_subchannel, 0, sizeof(struct subchannel)); |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 784 | init_subchannel_id(&schid); |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 785 | schid.sch_no = sch_no; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 786 | ret = cio_validate_subchannel(&console_subchannel, schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | if (ret) { |
| 788 | console_subchannel_in_use = 0; |
| 789 | return ERR_PTR(-ENODEV); |
| 790 | } |
| 791 | |
| 792 | /* |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 793 | * enable console I/O-interrupt subclass 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | */ |
Cornelia Huck | 85b0d7c | 2008-06-10 10:03:21 +0200 | [diff] [blame] | 795 | ctl_set_bit(6, 30); |
| 796 | console_subchannel.isc = 1; |
| 797 | console_subchannel.schib.pmcw.isc = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | console_subchannel.schib.pmcw.intparm = |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 799 | (u32)(addr_t)&console_subchannel; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | ret = cio_modify(&console_subchannel); |
| 801 | if (ret) { |
| 802 | console_subchannel_in_use = 0; |
| 803 | return ERR_PTR(ret); |
| 804 | } |
| 805 | return &console_subchannel; |
| 806 | } |
| 807 | |
| 808 | void |
| 809 | cio_release_console(void) |
| 810 | { |
| 811 | console_subchannel.schib.pmcw.intparm = 0; |
| 812 | cio_modify(&console_subchannel); |
| 813 | ctl_clear_bit(6, 24); |
| 814 | console_subchannel_in_use = 0; |
| 815 | } |
| 816 | |
| 817 | /* Bah... hack to catch console special sausages. */ |
| 818 | int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 819 | cio_is_console(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | { |
| 821 | if (!console_subchannel_in_use) |
| 822 | return 0; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 823 | return schid_equal(&schid, &console_subchannel.schid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | struct subchannel * |
| 827 | cio_get_console_subchannel(void) |
| 828 | { |
| 829 | if (!console_subchannel_in_use) |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 830 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | return &console_subchannel; |
| 832 | } |
| 833 | |
| 834 | #endif |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 835 | static int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 836 | __disable_subchannel_easy(struct subchannel_id schid, struct schib *schib) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | { |
| 838 | int retry, cc; |
| 839 | |
| 840 | cc = 0; |
| 841 | for (retry=0;retry<3;retry++) { |
| 842 | schib->pmcw.ena = 0; |
| 843 | cc = msch(schid, schib); |
| 844 | if (cc) |
| 845 | return (cc==3?-ENODEV:-EBUSY); |
| 846 | stsch(schid, schib); |
| 847 | if (!schib->pmcw.ena) |
| 848 | return 0; |
| 849 | } |
| 850 | return -EBUSY; /* uhm... */ |
| 851 | } |
| 852 | |
Martin Schwidefsky | d54853e | 2007-02-05 21:18:19 +0100 | [diff] [blame] | 853 | /* we can't use the normal udelay here, since it enables external interrupts */ |
| 854 | |
| 855 | static void udelay_reset(unsigned long usecs) |
| 856 | { |
| 857 | uint64_t start_cc, end_cc; |
| 858 | |
| 859 | asm volatile ("STCK %0" : "=m" (start_cc)); |
| 860 | do { |
| 861 | cpu_relax(); |
| 862 | asm volatile ("STCK %0" : "=m" (end_cc)); |
| 863 | } while (((end_cc - start_cc)/4096) < usecs); |
| 864 | } |
| 865 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 866 | static int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 867 | __clear_subchannel_easy(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | { |
| 869 | int retry; |
| 870 | |
| 871 | if (csch(schid)) |
| 872 | return -ENODEV; |
| 873 | for (retry=0;retry<20;retry++) { |
| 874 | struct tpi_info ti; |
| 875 | |
| 876 | if (tpi(&ti)) { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 877 | tsch(ti.schid, (struct irb *)__LC_IRB); |
| 878 | if (schid_equal(&ti.schid, &schid)) |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 879 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | } |
Martin Schwidefsky | d54853e | 2007-02-05 21:18:19 +0100 | [diff] [blame] | 881 | udelay_reset(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | } |
| 883 | return -EBUSY; |
| 884 | } |
| 885 | |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 886 | static int pgm_check_occured; |
| 887 | |
| 888 | static void cio_reset_pgm_check_handler(void) |
| 889 | { |
| 890 | pgm_check_occured = 1; |
| 891 | } |
| 892 | |
| 893 | static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr) |
| 894 | { |
| 895 | int rc; |
| 896 | |
| 897 | pgm_check_occured = 0; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 898 | s390_base_pgm_handler_fn = cio_reset_pgm_check_handler; |
Heiko Carstens | 6faf444 | 2007-01-09 10:18:41 +0100 | [diff] [blame] | 899 | rc = stsch(schid, addr); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 900 | s390_base_pgm_handler_fn = NULL; |
Heiko Carstens | 6faf444 | 2007-01-09 10:18:41 +0100 | [diff] [blame] | 901 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 902 | /* The program check handler could have changed pgm_check_occured. */ |
Heiko Carstens | 6faf444 | 2007-01-09 10:18:41 +0100 | [diff] [blame] | 903 | barrier(); |
| 904 | |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 905 | if (pgm_check_occured) |
| 906 | return -EIO; |
| 907 | else |
| 908 | return rc; |
| 909 | } |
| 910 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 911 | static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data) |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 912 | { |
| 913 | struct schib schib; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 915 | if (stsch_reset(schid, &schib)) |
Cornelia Huck | f97a56f | 2006-01-06 00:19:22 -0800 | [diff] [blame] | 916 | return -ENXIO; |
| 917 | if (!schib.pmcw.ena) |
| 918 | return 0; |
| 919 | switch(__disable_subchannel_easy(schid, &schib)) { |
| 920 | case 0: |
| 921 | case -ENODEV: |
| 922 | break; |
| 923 | default: /* -EBUSY */ |
| 924 | if (__clear_subchannel_easy(schid)) |
| 925 | break; /* give up... */ |
| 926 | stsch(schid, &schib); |
| 927 | __disable_subchannel_easy(schid, &schib); |
| 928 | } |
| 929 | return 0; |
| 930 | } |
| 931 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 932 | static atomic_t chpid_reset_count; |
| 933 | |
| 934 | static void s390_reset_chpids_mcck_handler(void) |
| 935 | { |
| 936 | struct crw crw; |
| 937 | struct mci *mci; |
| 938 | |
| 939 | /* Check for pending channel report word. */ |
| 940 | mci = (struct mci *)&S390_lowcore.mcck_interruption_code; |
| 941 | if (!mci->cp) |
| 942 | return; |
| 943 | /* Process channel report words. */ |
| 944 | while (stcrw(&crw) == 0) { |
| 945 | /* Check for responses to RCHP. */ |
| 946 | if (crw.slct && crw.rsc == CRW_RSC_CPATH) |
| 947 | atomic_dec(&chpid_reset_count); |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | #define RCHP_TIMEOUT (30 * USEC_PER_SEC) |
| 952 | static void css_reset(void) |
| 953 | { |
| 954 | int i, ret; |
| 955 | unsigned long long timeout; |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 956 | struct chp_id chpid; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 957 | |
| 958 | /* Reset subchannels. */ |
| 959 | for_each_subchannel(__shutdown_subchannel_easy, NULL); |
| 960 | /* Reset channel paths. */ |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 961 | s390_base_mcck_handler_fn = s390_reset_chpids_mcck_handler; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 962 | /* Enable channel report machine checks. */ |
| 963 | __ctl_set_bit(14, 28); |
| 964 | /* Temporarily reenable machine checks. */ |
| 965 | local_mcck_enable(); |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 966 | chp_id_init(&chpid); |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 967 | for (i = 0; i <= __MAX_CHPID; i++) { |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 968 | chpid.id = i; |
| 969 | ret = rchp(chpid); |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 970 | if ((ret == 0) || (ret == 2)) |
| 971 | /* |
| 972 | * rchp either succeeded, or another rchp is already |
| 973 | * in progress. In either case, we'll get a crw. |
| 974 | */ |
| 975 | atomic_inc(&chpid_reset_count); |
| 976 | } |
| 977 | /* Wait for machine check for all channel paths. */ |
| 978 | timeout = get_clock() + (RCHP_TIMEOUT << 12); |
| 979 | while (atomic_read(&chpid_reset_count) != 0) { |
| 980 | if (get_clock() > timeout) |
| 981 | break; |
| 982 | cpu_relax(); |
| 983 | } |
| 984 | /* Disable machine checks again. */ |
| 985 | local_mcck_disable(); |
| 986 | /* Disable channel report machine checks. */ |
| 987 | __ctl_clear_bit(14, 28); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 988 | s390_base_mcck_handler_fn = NULL; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | static struct reset_call css_reset_call = { |
| 992 | .fn = css_reset, |
| 993 | }; |
| 994 | |
| 995 | static int __init init_css_reset_call(void) |
| 996 | { |
| 997 | atomic_set(&chpid_reset_count, 0); |
| 998 | register_reset_call(&css_reset_call); |
| 999 | return 0; |
| 1000 | } |
| 1001 | |
| 1002 | arch_initcall(init_css_reset_call); |
| 1003 | |
| 1004 | struct sch_match_id { |
| 1005 | struct subchannel_id schid; |
| 1006 | struct ccw_dev_id devid; |
| 1007 | int rc; |
| 1008 | }; |
| 1009 | |
| 1010 | static int __reipl_subchannel_match(struct subchannel_id schid, void *data) |
| 1011 | { |
| 1012 | struct schib schib; |
| 1013 | struct sch_match_id *match_id = data; |
| 1014 | |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1015 | if (stsch_reset(schid, &schib)) |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1016 | return -ENXIO; |
Cornelia Huck | b279a4f | 2008-01-26 14:10:45 +0100 | [diff] [blame] | 1017 | if ((schib.pmcw.st == SUBCHANNEL_TYPE_IO) && schib.pmcw.dnv && |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1018 | (schib.pmcw.dev == match_id->devid.devno) && |
| 1019 | (schid.ssid == match_id->devid.ssid)) { |
| 1020 | match_id->schid = schid; |
| 1021 | match_id->rc = 0; |
| 1022 | return 1; |
| 1023 | } |
| 1024 | return 0; |
| 1025 | } |
| 1026 | |
| 1027 | static int reipl_find_schid(struct ccw_dev_id *devid, |
| 1028 | struct subchannel_id *schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1030 | struct sch_match_id match_id; |
| 1031 | |
| 1032 | match_id.devid = *devid; |
| 1033 | match_id.rc = -ENODEV; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1034 | for_each_subchannel(__reipl_subchannel_match, &match_id); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1035 | if (match_id.rc == 0) |
| 1036 | *schid = match_id.schid; |
| 1037 | return match_id.rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | } |
| 1039 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1040 | extern void do_reipl_asm(__u32 schid); |
| 1041 | |
| 1042 | /* Make sure all subchannels are quiet before we re-ipl an lpar. */ |
| 1043 | void reipl_ccw_dev(struct ccw_dev_id *devid) |
| 1044 | { |
| 1045 | struct subchannel_id schid; |
| 1046 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1047 | s390_reset_system(); |
| 1048 | if (reipl_find_schid(devid, &schid) != 0) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1049 | panic("IPL Device not found\n"); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1050 | do_reipl_asm(*((__u32*)&schid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | } |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 1052 | |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1053 | int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo) |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 1054 | { |
| 1055 | struct subchannel_id schid; |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1056 | struct schib schib; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 1057 | |
| 1058 | schid = *(struct subchannel_id *)__LC_SUBCHANNEL_ID; |
| 1059 | if (!schid.one) |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1060 | return -ENODEV; |
| 1061 | if (stsch(schid, &schib)) |
| 1062 | return -ENODEV; |
Cornelia Huck | b279a4f | 2008-01-26 14:10:45 +0100 | [diff] [blame] | 1063 | if (schib.pmcw.st != SUBCHANNEL_TYPE_IO) |
| 1064 | return -ENODEV; |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1065 | if (!schib.pmcw.dnv) |
| 1066 | return -ENODEV; |
| 1067 | iplinfo->devno = schib.pmcw.dev; |
| 1068 | iplinfo->is_qdio = schib.pmcw.qf; |
| 1069 | return 0; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 1070 | } |