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