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