1 /* 2 * Copyright IBM Corp. 2002, 2009 3 * 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Cornelia Huck (cornelia.huck@de.ibm.com) 6 */ 7 #include <linux/module.h> 8 #include <linux/init.h> 9 #include <linux/errno.h> 10 #include <linux/slab.h> 11 #include <linux/list.h> 12 #include <linux/device.h> 13 #include <linux/delay.h> 14 15 #include <asm/ccwdev.h> 16 #include <asm/idals.h> 17 #include <asm/chpid.h> 18 #include <asm/fcx.h> 19 20 #include "cio.h" 21 #include "cio_debug.h" 22 #include "css.h" 23 #include "chsc.h" 24 #include "device.h" 25 #include "chp.h" 26 27 /** 28 * ccw_device_set_options_mask() - set some options and unset the rest 29 * @cdev: device for which the options are to be set 30 * @flags: options to be set 31 * 32 * All flags specified in @flags are set, all flags not specified in @flags 33 * are cleared. 34 * Returns: 35 * %0 on success, -%EINVAL on an invalid flag combination. 36 */ 37 int ccw_device_set_options_mask(struct ccw_device *cdev, unsigned long flags) 38 { 39 /* 40 * The flag usage is mutal exclusive ... 41 */ 42 if ((flags & CCWDEV_EARLY_NOTIFICATION) && 43 (flags & CCWDEV_REPORT_ALL)) 44 return -EINVAL; 45 cdev->private->options.fast = (flags & CCWDEV_EARLY_NOTIFICATION) != 0; 46 cdev->private->options.repall = (flags & CCWDEV_REPORT_ALL) != 0; 47 cdev->private->options.pgroup = (flags & CCWDEV_DO_PATHGROUP) != 0; 48 cdev->private->options.force = (flags & CCWDEV_ALLOW_FORCE) != 0; 49 return 0; 50 } 51 52 /** 53 * ccw_device_set_options() - set some options 54 * @cdev: device for which the options are to be set 55 * @flags: options to be set 56 * 57 * All flags specified in @flags are set, the remainder is left untouched. 58 * Returns: 59 * %0 on success, -%EINVAL if an invalid flag combination would ensue. 60 */ 61 int ccw_device_set_options(struct ccw_device *cdev, unsigned long flags) 62 { 63 /* 64 * The flag usage is mutal exclusive ... 65 */ 66 if (((flags & CCWDEV_EARLY_NOTIFICATION) && 67 (flags & CCWDEV_REPORT_ALL)) || 68 ((flags & CCWDEV_EARLY_NOTIFICATION) && 69 cdev->private->options.repall) || 70 ((flags & CCWDEV_REPORT_ALL) && 71 cdev->private->options.fast)) 72 return -EINVAL; 73 cdev->private->options.fast |= (flags & CCWDEV_EARLY_NOTIFICATION) != 0; 74 cdev->private->options.repall |= (flags & CCWDEV_REPORT_ALL) != 0; 75 cdev->private->options.pgroup |= (flags & CCWDEV_DO_PATHGROUP) != 0; 76 cdev->private->options.force |= (flags & CCWDEV_ALLOW_FORCE) != 0; 77 return 0; 78 } 79 80 /** 81 * ccw_device_clear_options() - clear some options 82 * @cdev: device for which the options are to be cleared 83 * @flags: options to be cleared 84 * 85 * All flags specified in @flags are cleared, the remainder is left untouched. 86 */ 87 void ccw_device_clear_options(struct ccw_device *cdev, unsigned long flags) 88 { 89 cdev->private->options.fast &= (flags & CCWDEV_EARLY_NOTIFICATION) == 0; 90 cdev->private->options.repall &= (flags & CCWDEV_REPORT_ALL) == 0; 91 cdev->private->options.pgroup &= (flags & CCWDEV_DO_PATHGROUP) == 0; 92 cdev->private->options.force &= (flags & CCWDEV_ALLOW_FORCE) == 0; 93 } 94 95 /** 96 * ccw_device_clear() - terminate I/O request processing 97 * @cdev: target ccw device 98 * @intparm: interruption parameter; value is only used if no I/O is 99 * outstanding, otherwise the intparm associated with the I/O request 100 * is returned 101 * 102 * ccw_device_clear() calls csch on @cdev's subchannel. 103 * Returns: 104 * %0 on success, 105 * -%ENODEV on device not operational, 106 * -%EINVAL on invalid device state. 107 * Context: 108 * Interrupts disabled, ccw device lock held 109 */ 110 int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm) 111 { 112 struct subchannel *sch; 113 int ret; 114 115 if (!cdev || !cdev->dev.parent) 116 return -ENODEV; 117 sch = to_subchannel(cdev->dev.parent); 118 if (!sch->schib.pmcw.ena) 119 return -EINVAL; 120 if (cdev->private->state == DEV_STATE_NOT_OPER) 121 return -ENODEV; 122 if (cdev->private->state != DEV_STATE_ONLINE && 123 cdev->private->state != DEV_STATE_W4SENSE) 124 return -EINVAL; 125 126 ret = cio_clear(sch); 127 if (ret == 0) 128 cdev->private->intparm = intparm; 129 return ret; 130 } 131 132 /** 133 * ccw_device_start_key() - start a s390 channel program with key 134 * @cdev: target ccw device 135 * @cpa: logical start address of channel program 136 * @intparm: user specific interruption parameter; will be presented back to 137 * @cdev's interrupt handler. Allows a device driver to associate 138 * the interrupt with a particular I/O request. 139 * @lpm: defines the channel path to be used for a specific I/O request. A 140 * value of 0 will make cio use the opm. 141 * @key: storage key to be used for the I/O 142 * @flags: additional flags; defines the action to be performed for I/O 143 * processing. 144 * 145 * Start a S/390 channel program. When the interrupt arrives, the 146 * IRQ handler is called, either immediately, delayed (dev-end missing, 147 * or sense required) or never (no IRQ handler registered). 148 * Returns: 149 * %0, if the operation was successful; 150 * -%EBUSY, if the device is busy, or status pending; 151 * -%EACCES, if no path specified in @lpm is operational; 152 * -%ENODEV, if the device is not operational. 153 * Context: 154 * Interrupts disabled, ccw device lock held 155 */ 156 int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa, 157 unsigned long intparm, __u8 lpm, __u8 key, 158 unsigned long flags) 159 { 160 struct subchannel *sch; 161 int ret; 162 163 if (!cdev || !cdev->dev.parent) 164 return -ENODEV; 165 sch = to_subchannel(cdev->dev.parent); 166 if (!sch->schib.pmcw.ena) 167 return -EINVAL; 168 if (cdev->private->state == DEV_STATE_NOT_OPER) 169 return -ENODEV; 170 if (cdev->private->state == DEV_STATE_VERIFY || 171 cdev->private->state == DEV_STATE_CLEAR_VERIFY) { 172 /* Remember to fake irb when finished. */ 173 if (!cdev->private->flags.fake_irb) { 174 cdev->private->flags.fake_irb = 1; 175 cdev->private->intparm = intparm; 176 return 0; 177 } else 178 /* There's already a fake I/O around. */ 179 return -EBUSY; 180 } 181 if (cdev->private->state != DEV_STATE_ONLINE || 182 ((sch->schib.scsw.cmd.stctl & SCSW_STCTL_PRIM_STATUS) && 183 !(sch->schib.scsw.cmd.stctl & SCSW_STCTL_SEC_STATUS)) || 184 cdev->private->flags.doverify) 185 return -EBUSY; 186 ret = cio_set_options (sch, flags); 187 if (ret) 188 return ret; 189 /* Adjust requested path mask to excluded varied off paths. */ 190 if (lpm) { 191 lpm &= sch->opm; 192 if (lpm == 0) 193 return -EACCES; 194 } 195 ret = cio_start_key (sch, cpa, lpm, key); 196 switch (ret) { 197 case 0: 198 cdev->private->intparm = intparm; 199 break; 200 case -EACCES: 201 case -ENODEV: 202 dev_fsm_event(cdev, DEV_EVENT_VERIFY); 203 break; 204 } 205 return ret; 206 } 207 208 /** 209 * ccw_device_start_timeout_key() - start a s390 channel program with timeout and key 210 * @cdev: target ccw device 211 * @cpa: logical start address of channel program 212 * @intparm: user specific interruption parameter; will be presented back to 213 * @cdev's interrupt handler. Allows a device driver to associate 214 * the interrupt with a particular I/O request. 215 * @lpm: defines the channel path to be used for a specific I/O request. A 216 * value of 0 will make cio use the opm. 217 * @key: storage key to be used for the I/O 218 * @flags: additional flags; defines the action to be performed for I/O 219 * processing. 220 * @expires: timeout value in jiffies 221 * 222 * Start a S/390 channel program. When the interrupt arrives, the 223 * IRQ handler is called, either immediately, delayed (dev-end missing, 224 * or sense required) or never (no IRQ handler registered). 225 * This function notifies the device driver if the channel program has not 226 * completed during the time specified by @expires. If a timeout occurs, the 227 * channel program is terminated via xsch, hsch or csch, and the device's 228 * interrupt handler will be called with an irb containing ERR_PTR(-%ETIMEDOUT). 229 * Returns: 230 * %0, if the operation was successful; 231 * -%EBUSY, if the device is busy, or status pending; 232 * -%EACCES, if no path specified in @lpm is operational; 233 * -%ENODEV, if the device is not operational. 234 * Context: 235 * Interrupts disabled, ccw device lock held 236 */ 237 int ccw_device_start_timeout_key(struct ccw_device *cdev, struct ccw1 *cpa, 238 unsigned long intparm, __u8 lpm, __u8 key, 239 unsigned long flags, int expires) 240 { 241 int ret; 242 243 if (!cdev) 244 return -ENODEV; 245 ccw_device_set_timeout(cdev, expires); 246 ret = ccw_device_start_key(cdev, cpa, intparm, lpm, key, flags); 247 if (ret != 0) 248 ccw_device_set_timeout(cdev, 0); 249 return ret; 250 } 251 252 /** 253 * ccw_device_start() - start a s390 channel program 254 * @cdev: target ccw device 255 * @cpa: logical start address of channel program 256 * @intparm: user specific interruption parameter; will be presented back to 257 * @cdev's interrupt handler. Allows a device driver to associate 258 * the interrupt with a particular I/O request. 259 * @lpm: defines the channel path to be used for a specific I/O request. A 260 * value of 0 will make cio use the opm. 261 * @flags: additional flags; defines the action to be performed for I/O 262 * processing. 263 * 264 * Start a S/390 channel program. When the interrupt arrives, the 265 * IRQ handler is called, either immediately, delayed (dev-end missing, 266 * or sense required) or never (no IRQ handler registered). 267 * Returns: 268 * %0, if the operation was successful; 269 * -%EBUSY, if the device is busy, or status pending; 270 * -%EACCES, if no path specified in @lpm is operational; 271 * -%ENODEV, if the device is not operational. 272 * Context: 273 * Interrupts disabled, ccw device lock held 274 */ 275 int ccw_device_start(struct ccw_device *cdev, struct ccw1 *cpa, 276 unsigned long intparm, __u8 lpm, unsigned long flags) 277 { 278 return ccw_device_start_key(cdev, cpa, intparm, lpm, 279 PAGE_DEFAULT_KEY, flags); 280 } 281 282 /** 283 * ccw_device_start_timeout() - start a s390 channel program with timeout 284 * @cdev: target ccw device 285 * @cpa: logical start address of channel program 286 * @intparm: user specific interruption parameter; will be presented back to 287 * @cdev's interrupt handler. Allows a device driver to associate 288 * the interrupt with a particular I/O request. 289 * @lpm: defines the channel path to be used for a specific I/O request. A 290 * value of 0 will make cio use the opm. 291 * @flags: additional flags; defines the action to be performed for I/O 292 * processing. 293 * @expires: timeout value in jiffies 294 * 295 * Start a S/390 channel program. When the interrupt arrives, the 296 * IRQ handler is called, either immediately, delayed (dev-end missing, 297 * or sense required) or never (no IRQ handler registered). 298 * This function notifies the device driver if the channel program has not 299 * completed during the time specified by @expires. If a timeout occurs, the 300 * channel program is terminated via xsch, hsch or csch, and the device's 301 * interrupt handler will be called with an irb containing ERR_PTR(-%ETIMEDOUT). 302 * Returns: 303 * %0, if the operation was successful; 304 * -%EBUSY, if the device is busy, or status pending; 305 * -%EACCES, if no path specified in @lpm is operational; 306 * -%ENODEV, if the device is not operational. 307 * Context: 308 * Interrupts disabled, ccw device lock held 309 */ 310 int ccw_device_start_timeout(struct ccw_device *cdev, struct ccw1 *cpa, 311 unsigned long intparm, __u8 lpm, 312 unsigned long flags, int expires) 313 { 314 return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm, 315 PAGE_DEFAULT_KEY, flags, 316 expires); 317 } 318 319 320 /** 321 * ccw_device_halt() - halt I/O request processing 322 * @cdev: target ccw device 323 * @intparm: interruption parameter; value is only used if no I/O is 324 * outstanding, otherwise the intparm associated with the I/O request 325 * is returned 326 * 327 * ccw_device_halt() calls hsch on @cdev's subchannel. 328 * Returns: 329 * %0 on success, 330 * -%ENODEV on device not operational, 331 * -%EINVAL on invalid device state, 332 * -%EBUSY on device busy or interrupt pending. 333 * Context: 334 * Interrupts disabled, ccw device lock held 335 */ 336 int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm) 337 { 338 struct subchannel *sch; 339 int ret; 340 341 if (!cdev || !cdev->dev.parent) 342 return -ENODEV; 343 sch = to_subchannel(cdev->dev.parent); 344 if (!sch->schib.pmcw.ena) 345 return -EINVAL; 346 if (cdev->private->state == DEV_STATE_NOT_OPER) 347 return -ENODEV; 348 if (cdev->private->state != DEV_STATE_ONLINE && 349 cdev->private->state != DEV_STATE_W4SENSE) 350 return -EINVAL; 351 352 ret = cio_halt(sch); 353 if (ret == 0) 354 cdev->private->intparm = intparm; 355 return ret; 356 } 357 358 /** 359 * ccw_device_resume() - resume channel program execution 360 * @cdev: target ccw device 361 * 362 * ccw_device_resume() calls rsch on @cdev's subchannel. 363 * Returns: 364 * %0 on success, 365 * -%ENODEV on device not operational, 366 * -%EINVAL on invalid device state, 367 * -%EBUSY on device busy or interrupt pending. 368 * Context: 369 * Interrupts disabled, ccw device lock held 370 */ 371 int ccw_device_resume(struct ccw_device *cdev) 372 { 373 struct subchannel *sch; 374 375 if (!cdev || !cdev->dev.parent) 376 return -ENODEV; 377 sch = to_subchannel(cdev->dev.parent); 378 if (!sch->schib.pmcw.ena) 379 return -EINVAL; 380 if (cdev->private->state == DEV_STATE_NOT_OPER) 381 return -ENODEV; 382 if (cdev->private->state != DEV_STATE_ONLINE || 383 !(sch->schib.scsw.cmd.actl & SCSW_ACTL_SUSPENDED)) 384 return -EINVAL; 385 return cio_resume(sch); 386 } 387 388 /* 389 * Pass interrupt to device driver. 390 */ 391 int 392 ccw_device_call_handler(struct ccw_device *cdev) 393 { 394 struct subchannel *sch; 395 unsigned int stctl; 396 int ending_status; 397 398 sch = to_subchannel(cdev->dev.parent); 399 400 /* 401 * we allow for the device action handler if . 402 * - we received ending status 403 * - the action handler requested to see all interrupts 404 * - we received an intermediate status 405 * - fast notification was requested (primary status) 406 * - unsolicited interrupts 407 */ 408 stctl = scsw_stctl(&cdev->private->irb.scsw); 409 ending_status = (stctl & SCSW_STCTL_SEC_STATUS) || 410 (stctl == (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)) || 411 (stctl == SCSW_STCTL_STATUS_PEND); 412 if (!ending_status && 413 !cdev->private->options.repall && 414 !(stctl & SCSW_STCTL_INTER_STATUS) && 415 !(cdev->private->options.fast && 416 (stctl & SCSW_STCTL_PRIM_STATUS))) 417 return 0; 418 419 /* Clear pending timers for device driver initiated I/O. */ 420 if (ending_status) 421 ccw_device_set_timeout(cdev, 0); 422 /* 423 * Now we are ready to call the device driver interrupt handler. 424 */ 425 if (cdev->handler) 426 cdev->handler(cdev, cdev->private->intparm, 427 &cdev->private->irb); 428 429 /* 430 * Clear the old and now useless interrupt response block. 431 */ 432 memset(&cdev->private->irb, 0, sizeof(struct irb)); 433 434 return 1; 435 } 436 437 /** 438 * ccw_device_get_ciw() - Search for CIW command in extended sense data. 439 * @cdev: ccw device to inspect 440 * @ct: command type to look for 441 * 442 * During SenseID, command information words (CIWs) describing special 443 * commands available to the device may have been stored in the extended 444 * sense data. This function searches for CIWs of a specified command 445 * type in the extended sense data. 446 * Returns: 447 * %NULL if no extended sense data has been stored or if no CIW of the 448 * specified command type could be found, 449 * else a pointer to the CIW of the specified command type. 450 */ 451 struct ciw *ccw_device_get_ciw(struct ccw_device *cdev, __u32 ct) 452 { 453 int ciw_cnt; 454 455 if (cdev->private->flags.esid == 0) 456 return NULL; 457 for (ciw_cnt = 0; ciw_cnt < MAX_CIWS; ciw_cnt++) 458 if (cdev->private->senseid.ciw[ciw_cnt].ct == ct) 459 return cdev->private->senseid.ciw + ciw_cnt; 460 return NULL; 461 } 462 463 /** 464 * ccw_device_get_path_mask() - get currently available paths 465 * @cdev: ccw device to be queried 466 * Returns: 467 * %0 if no subchannel for the device is available, 468 * else the mask of currently available paths for the ccw device's subchannel. 469 */ 470 __u8 ccw_device_get_path_mask(struct ccw_device *cdev) 471 { 472 struct subchannel *sch; 473 474 if (!cdev->dev.parent) 475 return 0; 476 477 sch = to_subchannel(cdev->dev.parent); 478 return sch->lpm; 479 } 480 481 /* 482 * Try to break the lock on a boxed device. 483 */ 484 int 485 ccw_device_stlck(struct ccw_device *cdev) 486 { 487 void *buf, *buf2; 488 unsigned long flags; 489 struct subchannel *sch; 490 int ret; 491 492 if (!cdev) 493 return -ENODEV; 494 495 if (cdev->drv && !cdev->private->options.force) 496 return -EINVAL; 497 498 sch = to_subchannel(cdev->dev.parent); 499 500 CIO_TRACE_EVENT(2, "stl lock"); 501 CIO_TRACE_EVENT(2, dev_name(&cdev->dev)); 502 503 buf = kmalloc(32*sizeof(char), GFP_DMA|GFP_KERNEL); 504 if (!buf) 505 return -ENOMEM; 506 buf2 = kmalloc(32*sizeof(char), GFP_DMA|GFP_KERNEL); 507 if (!buf2) { 508 kfree(buf); 509 return -ENOMEM; 510 } 511 spin_lock_irqsave(sch->lock, flags); 512 ret = cio_enable_subchannel(sch, (u32)(addr_t)sch); 513 if (ret) 514 goto out_unlock; 515 /* 516 * Setup ccw. We chain an unconditional reserve and a release so we 517 * only break the lock. 518 */ 519 cdev->private->iccws[0].cmd_code = CCW_CMD_STLCK; 520 cdev->private->iccws[0].cda = (__u32) __pa(buf); 521 cdev->private->iccws[0].count = 32; 522 cdev->private->iccws[0].flags = CCW_FLAG_CC; 523 cdev->private->iccws[1].cmd_code = CCW_CMD_RELEASE; 524 cdev->private->iccws[1].cda = (__u32) __pa(buf2); 525 cdev->private->iccws[1].count = 32; 526 cdev->private->iccws[1].flags = 0; 527 ret = cio_start(sch, cdev->private->iccws, 0); 528 if (ret) { 529 cio_disable_subchannel(sch); //FIXME: return code? 530 goto out_unlock; 531 } 532 cdev->private->irb.scsw.cmd.actl |= SCSW_ACTL_START_PEND; 533 spin_unlock_irqrestore(sch->lock, flags); 534 wait_event(cdev->private->wait_q, 535 cdev->private->irb.scsw.cmd.actl == 0); 536 spin_lock_irqsave(sch->lock, flags); 537 cio_disable_subchannel(sch); //FIXME: return code? 538 if ((cdev->private->irb.scsw.cmd.dstat != 539 (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) || 540 (cdev->private->irb.scsw.cmd.cstat != 0)) 541 ret = -EIO; 542 /* Clear irb. */ 543 memset(&cdev->private->irb, 0, sizeof(struct irb)); 544 out_unlock: 545 kfree(buf); 546 kfree(buf2); 547 spin_unlock_irqrestore(sch->lock, flags); 548 return ret; 549 } 550 551 void *ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no) 552 { 553 struct subchannel *sch; 554 struct chp_id chpid; 555 556 sch = to_subchannel(cdev->dev.parent); 557 chp_id_init(&chpid); 558 chpid.id = sch->schib.pmcw.chpid[chp_no]; 559 return chp_get_chp_desc(chpid); 560 } 561 562 /** 563 * ccw_device_get_id - obtain a ccw device id 564 * @cdev: device to obtain the id for 565 * @dev_id: where to fill in the values 566 */ 567 void ccw_device_get_id(struct ccw_device *cdev, struct ccw_dev_id *dev_id) 568 { 569 *dev_id = cdev->private->dev_id; 570 } 571 EXPORT_SYMBOL(ccw_device_get_id); 572 573 /** 574 * ccw_device_tm_start_key - perform start function 575 * @cdev: ccw device on which to perform the start function 576 * @tcw: transport-command word to be started 577 * @intparm: user defined parameter to be passed to the interrupt handler 578 * @lpm: mask of paths to use 579 * @key: storage key to use for storage access 580 * 581 * Start the tcw on the given ccw device. Return zero on success, non-zero 582 * otherwise. 583 */ 584 int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw, 585 unsigned long intparm, u8 lpm, u8 key) 586 { 587 struct subchannel *sch; 588 int rc; 589 590 sch = to_subchannel(cdev->dev.parent); 591 if (!sch->schib.pmcw.ena) 592 return -EINVAL; 593 if (cdev->private->state != DEV_STATE_ONLINE) 594 return -EIO; 595 /* Adjust requested path mask to excluded varied off paths. */ 596 if (lpm) { 597 lpm &= sch->opm; 598 if (lpm == 0) 599 return -EACCES; 600 } 601 rc = cio_tm_start_key(sch, tcw, lpm, key); 602 if (rc == 0) 603 cdev->private->intparm = intparm; 604 return rc; 605 } 606 EXPORT_SYMBOL(ccw_device_tm_start_key); 607 608 /** 609 * ccw_device_tm_start_timeout_key - perform start function 610 * @cdev: ccw device on which to perform the start function 611 * @tcw: transport-command word to be started 612 * @intparm: user defined parameter to be passed to the interrupt handler 613 * @lpm: mask of paths to use 614 * @key: storage key to use for storage access 615 * @expires: time span in jiffies after which to abort request 616 * 617 * Start the tcw on the given ccw device. Return zero on success, non-zero 618 * otherwise. 619 */ 620 int ccw_device_tm_start_timeout_key(struct ccw_device *cdev, struct tcw *tcw, 621 unsigned long intparm, u8 lpm, u8 key, 622 int expires) 623 { 624 int ret; 625 626 ccw_device_set_timeout(cdev, expires); 627 ret = ccw_device_tm_start_key(cdev, tcw, intparm, lpm, key); 628 if (ret != 0) 629 ccw_device_set_timeout(cdev, 0); 630 return ret; 631 } 632 EXPORT_SYMBOL(ccw_device_tm_start_timeout_key); 633 634 /** 635 * ccw_device_tm_start - perform start function 636 * @cdev: ccw device on which to perform the start function 637 * @tcw: transport-command word to be started 638 * @intparm: user defined parameter to be passed to the interrupt handler 639 * @lpm: mask of paths to use 640 * 641 * Start the tcw on the given ccw device. Return zero on success, non-zero 642 * otherwise. 643 */ 644 int ccw_device_tm_start(struct ccw_device *cdev, struct tcw *tcw, 645 unsigned long intparm, u8 lpm) 646 { 647 return ccw_device_tm_start_key(cdev, tcw, intparm, lpm, 648 PAGE_DEFAULT_KEY); 649 } 650 EXPORT_SYMBOL(ccw_device_tm_start); 651 652 /** 653 * ccw_device_tm_start_timeout - perform start function 654 * @cdev: ccw device on which to perform the start function 655 * @tcw: transport-command word to be started 656 * @intparm: user defined parameter to be passed to the interrupt handler 657 * @lpm: mask of paths to use 658 * @expires: time span in jiffies after which to abort request 659 * 660 * Start the tcw on the given ccw device. Return zero on success, non-zero 661 * otherwise. 662 */ 663 int ccw_device_tm_start_timeout(struct ccw_device *cdev, struct tcw *tcw, 664 unsigned long intparm, u8 lpm, int expires) 665 { 666 return ccw_device_tm_start_timeout_key(cdev, tcw, intparm, lpm, 667 PAGE_DEFAULT_KEY, expires); 668 } 669 EXPORT_SYMBOL(ccw_device_tm_start_timeout); 670 671 /** 672 * ccw_device_tm_intrg - perform interrogate function 673 * @cdev: ccw device on which to perform the interrogate function 674 * 675 * Perform an interrogate function on the given ccw device. Return zero on 676 * success, non-zero otherwise. 677 */ 678 int ccw_device_tm_intrg(struct ccw_device *cdev) 679 { 680 struct subchannel *sch = to_subchannel(cdev->dev.parent); 681 682 if (!sch->schib.pmcw.ena) 683 return -EINVAL; 684 if (cdev->private->state != DEV_STATE_ONLINE) 685 return -EIO; 686 if (!scsw_is_tm(&sch->schib.scsw) || 687 !(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_START_PEND)) 688 return -EINVAL; 689 return cio_tm_intrg(sch); 690 } 691 EXPORT_SYMBOL(ccw_device_tm_intrg); 692 693 // FIXME: these have to go: 694 695 int 696 _ccw_device_get_subchannel_number(struct ccw_device *cdev) 697 { 698 return cdev->private->schid.sch_no; 699 } 700 701 702 MODULE_LICENSE("GPL"); 703 EXPORT_SYMBOL(ccw_device_set_options_mask); 704 EXPORT_SYMBOL(ccw_device_set_options); 705 EXPORT_SYMBOL(ccw_device_clear_options); 706 EXPORT_SYMBOL(ccw_device_clear); 707 EXPORT_SYMBOL(ccw_device_halt); 708 EXPORT_SYMBOL(ccw_device_resume); 709 EXPORT_SYMBOL(ccw_device_start_timeout); 710 EXPORT_SYMBOL(ccw_device_start); 711 EXPORT_SYMBOL(ccw_device_start_timeout_key); 712 EXPORT_SYMBOL(ccw_device_start_key); 713 EXPORT_SYMBOL(ccw_device_get_ciw); 714 EXPORT_SYMBOL(ccw_device_get_path_mask); 715 EXPORT_SYMBOL(_ccw_device_get_subchannel_number); 716 EXPORT_SYMBOL_GPL(ccw_device_get_chp_desc); 717