Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/s390/char/tape_34xx.c |
| 3 | * tape device discipline for 3480/3490 tapes. |
| 4 | * |
Frank Munzert | 3ef32e62 | 2009-06-16 10:30:39 +0200 | [diff] [blame] | 5 | * Copyright IBM Corp. 2001, 2009 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Author(s): Carsten Otte <cotte@de.ibm.com> |
| 7 | * Tuan Ngo-Anh <ngoanh@de.ibm.com> |
| 8 | * Martin Schwidefsky <schwidefsky@de.ibm.com> |
| 9 | */ |
| 10 | |
Michael Holzheu | 59e3692 | 2009-09-11 10:29:07 +0200 | [diff] [blame] | 11 | #define KMSG_COMPONENT "tape_34xx" |
Michael Holzheu | bb50991 | 2009-12-18 17:43:21 +0100 | [diff] [blame] | 12 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/bio.h> |
| 17 | #include <linux/workqueue.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 18 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #define TAPE_DBF_AREA tape_34xx_dbf |
| 21 | |
| 22 | #include "tape.h" |
| 23 | #include "tape_std.h" |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | /* |
| 26 | * Pointer to debug area. |
| 27 | */ |
| 28 | debug_info_t *TAPE_DBF_AREA = NULL; |
| 29 | EXPORT_SYMBOL(TAPE_DBF_AREA); |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #define TAPE34XX_FMT_3480 0 |
| 32 | #define TAPE34XX_FMT_3480_2_XF 1 |
| 33 | #define TAPE34XX_FMT_3480_XF 2 |
| 34 | |
| 35 | struct tape_34xx_block_id { |
| 36 | unsigned int wrap : 1; |
| 37 | unsigned int segment : 7; |
| 38 | unsigned int format : 2; |
| 39 | unsigned int block : 22; |
| 40 | }; |
| 41 | |
| 42 | /* |
| 43 | * A list of block ID's is used to faster seek blocks. |
| 44 | */ |
| 45 | struct tape_34xx_sbid { |
| 46 | struct list_head list; |
| 47 | struct tape_34xx_block_id bid; |
| 48 | }; |
| 49 | |
| 50 | static void tape_34xx_delete_sbid_from(struct tape_device *, int); |
| 51 | |
| 52 | /* |
| 53 | * Medium sense for 34xx tapes. There is no 'real' medium sense call. |
| 54 | * So we just do a normal sense. |
| 55 | */ |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 56 | static void __tape_34xx_medium_sense(struct tape_request *request) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 58 | struct tape_device *device = request->device; |
| 59 | unsigned char *sense; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | if (request->rc == 0) { |
| 62 | sense = request->cpdata; |
| 63 | |
| 64 | /* |
| 65 | * This isn't quite correct. But since INTERVENTION_REQUIRED |
| 66 | * means that the drive is 'neither ready nor on-line' it is |
| 67 | * only slightly inaccurate to say there is no tape loaded if |
| 68 | * the drive isn't online... |
| 69 | */ |
| 70 | if (sense[0] & SENSE_INTERVENTION_REQUIRED) |
| 71 | tape_med_state_set(device, MS_UNLOADED); |
| 72 | else |
| 73 | tape_med_state_set(device, MS_LOADED); |
| 74 | |
| 75 | if (sense[1] & SENSE_WRITE_PROTECT) |
| 76 | device->tape_generic_status |= GMT_WR_PROT(~0); |
| 77 | else |
| 78 | device->tape_generic_status &= ~GMT_WR_PROT(~0); |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 79 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n", |
| 81 | request->rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | tape_free_request(request); |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 83 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 85 | static int tape_34xx_medium_sense(struct tape_device *device) |
| 86 | { |
| 87 | struct tape_request *request; |
| 88 | int rc; |
| 89 | |
| 90 | request = tape_alloc_request(1, 32); |
| 91 | if (IS_ERR(request)) { |
| 92 | DBF_EXCEPTION(6, "MSEN fail\n"); |
| 93 | return PTR_ERR(request); |
| 94 | } |
| 95 | |
| 96 | request->op = TO_MSEN; |
| 97 | tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); |
| 98 | rc = tape_do_io_interruptible(device, request); |
| 99 | __tape_34xx_medium_sense(request); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | return rc; |
| 101 | } |
| 102 | |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 103 | static void tape_34xx_medium_sense_async(struct tape_device *device) |
| 104 | { |
| 105 | struct tape_request *request; |
| 106 | |
| 107 | request = tape_alloc_request(1, 32); |
| 108 | if (IS_ERR(request)) { |
| 109 | DBF_EXCEPTION(6, "MSEN fail\n"); |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | request->op = TO_MSEN; |
| 114 | tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); |
| 115 | request->callback = (void *) __tape_34xx_medium_sense; |
| 116 | request->callback_data = NULL; |
| 117 | tape_do_io_async(device, request); |
| 118 | } |
| 119 | |
Martin Schwidefsky | c163753 | 2006-12-08 15:53:57 +0100 | [diff] [blame] | 120 | struct tape_34xx_work { |
| 121 | struct tape_device *device; |
| 122 | enum tape_op op; |
| 123 | struct work_struct work; |
| 124 | }; |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /* |
| 127 | * These functions are currently used only to schedule a medium_sense for |
| 128 | * later execution. This is because we get an interrupt whenever a medium |
| 129 | * is inserted but cannot call tape_do_io* from an interrupt context. |
| 130 | * Maybe that's useful for other actions we want to start from the |
| 131 | * interrupt handler. |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 132 | * Note: the work handler is called by the system work queue. The tape |
| 133 | * commands started by the handler need to be asynchrounous, otherwise |
| 134 | * a deadlock can occur e.g. in case of a deferred cc=1 (see __tape_do_irq). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | */ |
| 136 | static void |
Martin Schwidefsky | c163753 | 2006-12-08 15:53:57 +0100 | [diff] [blame] | 137 | tape_34xx_work_handler(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | { |
Martin Schwidefsky | c163753 | 2006-12-08 15:53:57 +0100 | [diff] [blame] | 139 | struct tape_34xx_work *p = |
| 140 | container_of(work, struct tape_34xx_work, work); |
Martin Schwidefsky | 8fd138c | 2009-12-07 12:52:03 +0100 | [diff] [blame] | 141 | struct tape_device *device = p->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | switch(p->op) { |
| 144 | case TO_MSEN: |
Martin Schwidefsky | 0c2bd9b | 2011-03-03 17:56:07 +0100 | [diff] [blame] | 145 | tape_34xx_medium_sense_async(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | break; |
| 147 | default: |
| 148 | DBF_EVENT(3, "T34XX: internal error: unknown work\n"); |
| 149 | } |
Martin Schwidefsky | 8fd138c | 2009-12-07 12:52:03 +0100 | [diff] [blame] | 150 | tape_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | kfree(p); |
| 152 | } |
| 153 | |
| 154 | static int |
| 155 | tape_34xx_schedule_work(struct tape_device *device, enum tape_op op) |
| 156 | { |
Martin Schwidefsky | c163753 | 2006-12-08 15:53:57 +0100 | [diff] [blame] | 157 | struct tape_34xx_work *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Yoann Padioleau | dd00cc4 | 2007-07-19 01:49:03 -0700 | [diff] [blame] | 159 | if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | return -ENOMEM; |
| 161 | |
Martin Schwidefsky | c163753 | 2006-12-08 15:53:57 +0100 | [diff] [blame] | 162 | INIT_WORK(&p->work, tape_34xx_work_handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
Martin Schwidefsky | 8fd138c | 2009-12-07 12:52:03 +0100 | [diff] [blame] | 164 | p->device = tape_get_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | p->op = op; |
| 166 | |
| 167 | schedule_work(&p->work); |
| 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | /* |
| 172 | * Done Handler is called when dev stat = DEVICE-END (successful operation) |
| 173 | */ |
| 174 | static inline int |
| 175 | tape_34xx_done(struct tape_request *request) |
| 176 | { |
| 177 | DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]); |
| 178 | |
| 179 | switch (request->op) { |
| 180 | case TO_DSE: |
| 181 | case TO_RUN: |
| 182 | case TO_WRI: |
| 183 | case TO_WTM: |
| 184 | case TO_ASSIGN: |
| 185 | case TO_UNASSIGN: |
| 186 | tape_34xx_delete_sbid_from(request->device, 0); |
| 187 | break; |
| 188 | default: |
| 189 | ; |
| 190 | } |
| 191 | return TAPE_IO_SUCCESS; |
| 192 | } |
| 193 | |
| 194 | static inline int |
| 195 | tape_34xx_erp_failed(struct tape_request *request, int rc) |
| 196 | { |
| 197 | DBF_EVENT(3, "Error recovery failed for %s (RC=%d)\n", |
| 198 | tape_op_verbose[request->op], rc); |
| 199 | return rc; |
| 200 | } |
| 201 | |
| 202 | static inline int |
| 203 | tape_34xx_erp_succeeded(struct tape_request *request) |
| 204 | { |
| 205 | DBF_EVENT(3, "Error Recovery successful for %s\n", |
| 206 | tape_op_verbose[request->op]); |
| 207 | return tape_34xx_done(request); |
| 208 | } |
| 209 | |
| 210 | static inline int |
| 211 | tape_34xx_erp_retry(struct tape_request *request) |
| 212 | { |
| 213 | DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]); |
| 214 | return TAPE_IO_RETRY; |
| 215 | } |
| 216 | |
| 217 | /* |
| 218 | * This function is called, when no request is outstanding and we get an |
| 219 | * interrupt |
| 220 | */ |
| 221 | static int |
| 222 | tape_34xx_unsolicited_irq(struct tape_device *device, struct irb *irb) |
| 223 | { |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 224 | if (irb->scsw.cmd.dstat == 0x85) { /* READY */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | /* A medium was inserted in the drive. */ |
| 226 | DBF_EVENT(6, "xuud med\n"); |
| 227 | tape_34xx_delete_sbid_from(device, 0); |
| 228 | tape_34xx_schedule_work(device, TO_MSEN); |
| 229 | } else { |
| 230 | DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id); |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 231 | tape_dump_sense_dbf(device, NULL, irb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
| 233 | return TAPE_IO_SUCCESS; |
| 234 | } |
| 235 | |
| 236 | /* |
| 237 | * Read Opposite Error Recovery Function: |
| 238 | * Used, when Read Forward does not work |
| 239 | */ |
| 240 | static int |
| 241 | tape_34xx_erp_read_opposite(struct tape_device *device, |
| 242 | struct tape_request *request) |
| 243 | { |
| 244 | if (request->op == TO_RFO) { |
| 245 | /* |
| 246 | * We did read forward, but the data could not be read |
| 247 | * *correctly*. We transform the request to a read backward |
| 248 | * and try again. |
| 249 | */ |
| 250 | tape_std_read_backward(device, request); |
| 251 | return tape_34xx_erp_retry(request); |
| 252 | } |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 253 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | /* |
| 255 | * We tried to read forward and backward, but hat no |
| 256 | * success -> failed. |
| 257 | */ |
| 258 | return tape_34xx_erp_failed(request, -EIO); |
| 259 | } |
| 260 | |
| 261 | static int |
| 262 | tape_34xx_erp_bug(struct tape_device *device, struct tape_request *request, |
| 263 | struct irb *irb, int no) |
| 264 | { |
| 265 | if (request->op != TO_ASSIGN) { |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 266 | dev_err(&device->cdev->dev, "An unexpected condition %d " |
| 267 | "occurred in tape error recovery\n", no); |
| 268 | tape_dump_sense_dbf(device, request, irb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | return tape_34xx_erp_failed(request, -EIO); |
| 271 | } |
| 272 | |
| 273 | /* |
| 274 | * Handle data overrun between cu and drive. The channel speed might |
| 275 | * be too slow. |
| 276 | */ |
| 277 | static int |
| 278 | tape_34xx_erp_overrun(struct tape_device *device, struct tape_request *request, |
| 279 | struct irb *irb) |
| 280 | { |
| 281 | if (irb->ecw[3] == 0x40) { |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 282 | dev_warn (&device->cdev->dev, "A data overrun occurred between" |
| 283 | " the control unit and tape unit\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | return tape_34xx_erp_failed(request, -EIO); |
| 285 | } |
| 286 | return tape_34xx_erp_bug(device, request, irb, -1); |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | * Handle record sequence error. |
| 291 | */ |
| 292 | static int |
| 293 | tape_34xx_erp_sequence(struct tape_device *device, |
| 294 | struct tape_request *request, struct irb *irb) |
| 295 | { |
| 296 | if (irb->ecw[3] == 0x41) { |
| 297 | /* |
| 298 | * cu detected incorrect block-id sequence on tape. |
| 299 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 300 | dev_warn (&device->cdev->dev, "The block ID sequence on the " |
| 301 | "tape is incorrect\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | return tape_34xx_erp_failed(request, -EIO); |
| 303 | } |
| 304 | /* |
| 305 | * Record sequence error bit is set, but erpa does not |
| 306 | * show record sequence error. |
| 307 | */ |
| 308 | return tape_34xx_erp_bug(device, request, irb, -2); |
| 309 | } |
| 310 | |
| 311 | /* |
| 312 | * This function analyses the tape's sense-data in case of a unit-check. |
| 313 | * If possible, it tries to recover from the error. Else the user is |
| 314 | * informed about the problem. |
| 315 | */ |
| 316 | static int |
| 317 | tape_34xx_unit_check(struct tape_device *device, struct tape_request *request, |
| 318 | struct irb *irb) |
| 319 | { |
| 320 | int inhibit_cu_recovery; |
| 321 | __u8* sense; |
| 322 | |
| 323 | inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0; |
| 324 | sense = irb->ecw; |
| 325 | |
| 326 | #ifdef CONFIG_S390_TAPE_BLOCK |
| 327 | if (request->op == TO_BLOCK) { |
| 328 | /* |
| 329 | * Recovery for block device requests. Set the block_position |
| 330 | * to something invalid and retry. |
| 331 | */ |
| 332 | device->blk_data.block_position = -1; |
| 333 | if (request->retries-- <= 0) |
| 334 | return tape_34xx_erp_failed(request, -EIO); |
| 335 | else |
| 336 | return tape_34xx_erp_retry(request); |
| 337 | } |
| 338 | #endif |
| 339 | |
| 340 | if ( |
| 341 | sense[0] & SENSE_COMMAND_REJECT && |
| 342 | sense[1] & SENSE_WRITE_PROTECT |
| 343 | ) { |
| 344 | if ( |
| 345 | request->op == TO_DSE || |
| 346 | request->op == TO_WRI || |
| 347 | request->op == TO_WTM |
| 348 | ) { |
| 349 | /* medium is write protected */ |
| 350 | return tape_34xx_erp_failed(request, -EACCES); |
| 351 | } else { |
| 352 | return tape_34xx_erp_bug(device, request, irb, -3); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * Special cases for various tape-states when reaching |
| 358 | * end of recorded area |
| 359 | * |
| 360 | * FIXME: Maybe a special case of the special case: |
| 361 | * sense[0] == SENSE_EQUIPMENT_CHECK && |
| 362 | * sense[1] == SENSE_DRIVE_ONLINE && |
| 363 | * sense[3] == 0x47 (Volume Fenced) |
| 364 | * |
| 365 | * This was caused by continued FSF or FSR after an |
| 366 | * 'End Of Data'. |
| 367 | */ |
| 368 | if (( |
| 369 | sense[0] == SENSE_DATA_CHECK || |
| 370 | sense[0] == SENSE_EQUIPMENT_CHECK || |
| 371 | sense[0] == SENSE_EQUIPMENT_CHECK + SENSE_DEFERRED_UNIT_CHECK |
| 372 | ) && ( |
| 373 | sense[1] == SENSE_DRIVE_ONLINE || |
| 374 | sense[1] == SENSE_BEGINNING_OF_TAPE + SENSE_WRITE_MODE |
| 375 | )) { |
| 376 | switch (request->op) { |
| 377 | /* |
| 378 | * sense[0] == SENSE_DATA_CHECK && |
| 379 | * sense[1] == SENSE_DRIVE_ONLINE |
| 380 | * sense[3] == 0x36 (End Of Data) |
| 381 | * |
| 382 | * Further seeks might return a 'Volume Fenced'. |
| 383 | */ |
| 384 | case TO_FSF: |
| 385 | case TO_FSB: |
| 386 | /* Trying to seek beyond end of recorded area */ |
| 387 | return tape_34xx_erp_failed(request, -ENOSPC); |
| 388 | case TO_BSB: |
| 389 | return tape_34xx_erp_retry(request); |
| 390 | |
| 391 | /* |
| 392 | * sense[0] == SENSE_DATA_CHECK && |
| 393 | * sense[1] == SENSE_DRIVE_ONLINE && |
| 394 | * sense[3] == 0x36 (End Of Data) |
| 395 | */ |
| 396 | case TO_LBL: |
| 397 | /* Block could not be located. */ |
| 398 | tape_34xx_delete_sbid_from(device, 0); |
| 399 | return tape_34xx_erp_failed(request, -EIO); |
| 400 | |
| 401 | case TO_RFO: |
| 402 | /* Read beyond end of recorded area -> 0 bytes read */ |
| 403 | return tape_34xx_erp_failed(request, 0); |
| 404 | |
| 405 | /* |
| 406 | * sense[0] == SENSE_EQUIPMENT_CHECK && |
| 407 | * sense[1] == SENSE_DRIVE_ONLINE && |
| 408 | * sense[3] == 0x38 (Physical End Of Volume) |
| 409 | */ |
| 410 | case TO_WRI: |
| 411 | /* Writing at physical end of volume */ |
| 412 | return tape_34xx_erp_failed(request, -ENOSPC); |
| 413 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | return tape_34xx_erp_failed(request, 0); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | /* Sensing special bits */ |
| 419 | if (sense[0] & SENSE_BUS_OUT_CHECK) |
| 420 | return tape_34xx_erp_retry(request); |
| 421 | |
| 422 | if (sense[0] & SENSE_DATA_CHECK) { |
| 423 | /* |
| 424 | * hardware failure, damaged tape or improper |
| 425 | * operating conditions |
| 426 | */ |
| 427 | switch (sense[3]) { |
| 428 | case 0x23: |
| 429 | /* a read data check occurred */ |
| 430 | if ((sense[2] & SENSE_TAPE_SYNC_MODE) || |
| 431 | inhibit_cu_recovery) |
| 432 | // data check is not permanent, may be |
| 433 | // recovered. We always use async-mode with |
| 434 | // cu-recovery, so this should *never* happen. |
| 435 | return tape_34xx_erp_bug(device, request, |
| 436 | irb, -4); |
| 437 | |
| 438 | /* data check is permanent, CU recovery has failed */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 439 | dev_warn (&device->cdev->dev, "A read error occurred " |
| 440 | "that cannot be recovered\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | return tape_34xx_erp_failed(request, -EIO); |
| 442 | case 0x25: |
| 443 | // a write data check occurred |
| 444 | if ((sense[2] & SENSE_TAPE_SYNC_MODE) || |
| 445 | inhibit_cu_recovery) |
| 446 | // data check is not permanent, may be |
| 447 | // recovered. We always use async-mode with |
| 448 | // cu-recovery, so this should *never* happen. |
| 449 | return tape_34xx_erp_bug(device, request, |
| 450 | irb, -5); |
| 451 | |
| 452 | // data check is permanent, cu-recovery has failed |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 453 | dev_warn (&device->cdev->dev, "A write error on the " |
| 454 | "tape cannot be recovered\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | return tape_34xx_erp_failed(request, -EIO); |
| 456 | case 0x26: |
| 457 | /* Data Check (read opposite) occurred. */ |
| 458 | return tape_34xx_erp_read_opposite(device, request); |
| 459 | case 0x28: |
| 460 | /* ID-Mark at tape start couldn't be written */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 461 | dev_warn (&device->cdev->dev, "Writing the ID-mark " |
| 462 | "failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | return tape_34xx_erp_failed(request, -EIO); |
| 464 | case 0x31: |
| 465 | /* Tape void. Tried to read beyond end of device. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 466 | dev_warn (&device->cdev->dev, "Reading the tape beyond" |
| 467 | " the end of the recorded area failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | return tape_34xx_erp_failed(request, -ENOSPC); |
| 469 | case 0x41: |
| 470 | /* Record sequence error. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 471 | dev_warn (&device->cdev->dev, "The tape contains an " |
| 472 | "incorrect block ID sequence\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | return tape_34xx_erp_failed(request, -EIO); |
| 474 | default: |
| 475 | /* all data checks for 3480 should result in one of |
| 476 | * the above erpa-codes. For 3490, other data-check |
| 477 | * conditions do exist. */ |
| 478 | if (device->cdev->id.driver_info == tape_3480) |
| 479 | return tape_34xx_erp_bug(device, request, |
| 480 | irb, -6); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | if (sense[0] & SENSE_OVERRUN) |
| 485 | return tape_34xx_erp_overrun(device, request, irb); |
| 486 | |
| 487 | if (sense[1] & SENSE_RECORD_SEQUENCE_ERR) |
| 488 | return tape_34xx_erp_sequence(device, request, irb); |
| 489 | |
| 490 | /* Sensing erpa codes */ |
| 491 | switch (sense[3]) { |
| 492 | case 0x00: |
| 493 | /* Unit check with erpa code 0. Report and ignore. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | return TAPE_IO_SUCCESS; |
| 495 | case 0x21: |
| 496 | /* |
| 497 | * Data streaming not operational. CU will switch to |
| 498 | * interlock mode. Reissue the command. |
| 499 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | return tape_34xx_erp_retry(request); |
| 501 | case 0x22: |
| 502 | /* |
| 503 | * Path equipment check. Might be drive adapter error, buffer |
| 504 | * error on the lower interface, internal path not usable, |
| 505 | * or error during cartridge load. |
| 506 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 507 | dev_warn (&device->cdev->dev, "A path equipment check occurred" |
| 508 | " for the tape device\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | return tape_34xx_erp_failed(request, -EIO); |
| 510 | case 0x24: |
| 511 | /* |
| 512 | * Load display check. Load display was command was issued, |
| 513 | * but the drive is displaying a drive check message. Can |
| 514 | * be threated as "device end". |
| 515 | */ |
| 516 | return tape_34xx_erp_succeeded(request); |
| 517 | case 0x27: |
| 518 | /* |
| 519 | * Command reject. May indicate illegal channel program or |
| 520 | * buffer over/underrun. Since all channel programs are |
| 521 | * issued by this driver and ought be correct, we assume a |
| 522 | * over/underrun situation and retry the channel program. |
| 523 | */ |
| 524 | return tape_34xx_erp_retry(request); |
| 525 | case 0x29: |
| 526 | /* |
| 527 | * Function incompatible. Either the tape is idrc compressed |
| 528 | * but the hardware isn't capable to do idrc, or a perform |
| 529 | * subsystem func is issued and the CU is not on-line. |
| 530 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | return tape_34xx_erp_failed(request, -EIO); |
| 532 | case 0x2a: |
| 533 | /* |
| 534 | * Unsolicited environmental data. An internal counter |
| 535 | * overflows, we can ignore this and reissue the cmd. |
| 536 | */ |
| 537 | return tape_34xx_erp_retry(request); |
| 538 | case 0x2b: |
| 539 | /* |
| 540 | * Environmental data present. Indicates either unload |
| 541 | * completed ok or read buffered log command completed ok. |
| 542 | */ |
| 543 | if (request->op == TO_RUN) { |
| 544 | /* Rewind unload completed ok. */ |
| 545 | tape_med_state_set(device, MS_UNLOADED); |
| 546 | return tape_34xx_erp_succeeded(request); |
| 547 | } |
| 548 | /* tape_34xx doesn't use read buffered log commands. */ |
| 549 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 550 | case 0x2c: |
| 551 | /* |
| 552 | * Permanent equipment check. CU has tried recovery, but |
| 553 | * did not succeed. |
| 554 | */ |
| 555 | return tape_34xx_erp_failed(request, -EIO); |
| 556 | case 0x2d: |
| 557 | /* Data security erase failure. */ |
| 558 | if (request->op == TO_DSE) |
| 559 | return tape_34xx_erp_failed(request, -EIO); |
| 560 | /* Data security erase failure, but no such command issued. */ |
| 561 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 562 | case 0x2e: |
| 563 | /* |
| 564 | * Not capable. This indicates either that the drive fails |
| 565 | * reading the format id mark or that that format specified |
| 566 | * is not supported by the drive. |
| 567 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 568 | dev_warn (&device->cdev->dev, "The tape unit cannot process " |
| 569 | "the tape format\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | return tape_34xx_erp_failed(request, -EMEDIUMTYPE); |
| 571 | case 0x30: |
| 572 | /* The medium is write protected. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 573 | dev_warn (&device->cdev->dev, "The tape medium is write-" |
| 574 | "protected\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | return tape_34xx_erp_failed(request, -EACCES); |
| 576 | case 0x32: |
| 577 | // Tension loss. We cannot recover this, it's an I/O error. |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 578 | dev_warn (&device->cdev->dev, "The tape does not have the " |
| 579 | "required tape tension\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | return tape_34xx_erp_failed(request, -EIO); |
| 581 | case 0x33: |
| 582 | /* |
| 583 | * Load Failure. The cartridge was not inserted correctly or |
| 584 | * the tape is not threaded correctly. |
| 585 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 586 | dev_warn (&device->cdev->dev, "The tape unit failed to load" |
| 587 | " the cartridge\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | tape_34xx_delete_sbid_from(device, 0); |
| 589 | return tape_34xx_erp_failed(request, -EIO); |
| 590 | case 0x34: |
| 591 | /* |
| 592 | * Unload failure. The drive cannot maintain tape tension |
| 593 | * and control tape movement during an unload operation. |
| 594 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 595 | dev_warn (&device->cdev->dev, "Automatic unloading of the tape" |
| 596 | " cartridge failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | if (request->op == TO_RUN) |
| 598 | return tape_34xx_erp_failed(request, -EIO); |
| 599 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 600 | case 0x35: |
| 601 | /* |
| 602 | * Drive equipment check. One of the following: |
| 603 | * - cu cannot recover from a drive detected error |
| 604 | * - a check code message is shown on drive display |
| 605 | * - the cartridge loader does not respond correctly |
| 606 | * - a failure occurs during an index, load, or unload cycle |
| 607 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 608 | dev_warn (&device->cdev->dev, "An equipment check has occurred" |
| 609 | " on the tape unit\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | return tape_34xx_erp_failed(request, -EIO); |
| 611 | case 0x36: |
| 612 | if (device->cdev->id.driver_info == tape_3490) |
| 613 | /* End of data. */ |
| 614 | return tape_34xx_erp_failed(request, -EIO); |
| 615 | /* This erpa is reserved for 3480 */ |
| 616 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 617 | case 0x37: |
| 618 | /* |
| 619 | * Tape length error. The tape is shorter than reported in |
| 620 | * the beginning-of-tape data. |
| 621 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 622 | dev_warn (&device->cdev->dev, "The tape information states an" |
| 623 | " incorrect length\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | return tape_34xx_erp_failed(request, -EIO); |
| 625 | case 0x38: |
| 626 | /* |
| 627 | * Physical end of tape. A read/write operation reached |
| 628 | * the physical end of tape. |
| 629 | */ |
| 630 | if (request->op==TO_WRI || |
| 631 | request->op==TO_DSE || |
| 632 | request->op==TO_WTM) |
| 633 | return tape_34xx_erp_failed(request, -ENOSPC); |
| 634 | return tape_34xx_erp_failed(request, -EIO); |
| 635 | case 0x39: |
| 636 | /* Backward at Beginning of tape. */ |
| 637 | return tape_34xx_erp_failed(request, -EIO); |
| 638 | case 0x3a: |
| 639 | /* Drive switched to not ready. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 640 | dev_warn (&device->cdev->dev, "The tape unit is not ready\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | return tape_34xx_erp_failed(request, -EIO); |
| 642 | case 0x3b: |
| 643 | /* Manual rewind or unload. This causes an I/O error. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 644 | dev_warn (&device->cdev->dev, "The tape medium has been " |
| 645 | "rewound or unloaded manually\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | tape_34xx_delete_sbid_from(device, 0); |
| 647 | return tape_34xx_erp_failed(request, -EIO); |
| 648 | case 0x42: |
| 649 | /* |
| 650 | * Degraded mode. A condition that can cause degraded |
| 651 | * performance is detected. |
| 652 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 653 | dev_warn (&device->cdev->dev, "The tape subsystem is running " |
| 654 | "in degraded mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | return tape_34xx_erp_retry(request); |
| 656 | case 0x43: |
| 657 | /* Drive not ready. */ |
| 658 | tape_34xx_delete_sbid_from(device, 0); |
| 659 | tape_med_state_set(device, MS_UNLOADED); |
| 660 | /* Some commands commands are successful even in this case */ |
| 661 | if (sense[1] & SENSE_DRIVE_ONLINE) { |
| 662 | switch(request->op) { |
| 663 | case TO_ASSIGN: |
| 664 | case TO_UNASSIGN: |
| 665 | case TO_DIS: |
| 666 | case TO_NOP: |
| 667 | return tape_34xx_done(request); |
| 668 | break; |
| 669 | default: |
| 670 | break; |
| 671 | } |
| 672 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | return tape_34xx_erp_failed(request, -ENOMEDIUM); |
| 674 | case 0x44: |
| 675 | /* Locate Block unsuccessful. */ |
| 676 | if (request->op != TO_BLOCK && request->op != TO_LBL) |
| 677 | /* No locate block was issued. */ |
| 678 | return tape_34xx_erp_bug(device, request, |
| 679 | irb, sense[3]); |
| 680 | return tape_34xx_erp_failed(request, -EIO); |
| 681 | case 0x45: |
| 682 | /* The drive is assigned to a different channel path. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 683 | dev_warn (&device->cdev->dev, "The tape unit is already " |
| 684 | "assigned\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | return tape_34xx_erp_failed(request, -EIO); |
| 686 | case 0x46: |
| 687 | /* |
| 688 | * Drive not on-line. Drive may be switched offline, |
| 689 | * the power supply may be switched off or |
| 690 | * the drive address may not be set correctly. |
| 691 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 692 | dev_warn (&device->cdev->dev, "The tape unit is not online\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | return tape_34xx_erp_failed(request, -EIO); |
| 694 | case 0x47: |
| 695 | /* Volume fenced. CU reports volume integrity is lost. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 696 | dev_warn (&device->cdev->dev, "The control unit has fenced " |
| 697 | "access to the tape volume\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | tape_34xx_delete_sbid_from(device, 0); |
| 699 | return tape_34xx_erp_failed(request, -EIO); |
| 700 | case 0x48: |
| 701 | /* Log sense data and retry request. */ |
| 702 | return tape_34xx_erp_retry(request); |
| 703 | case 0x49: |
| 704 | /* Bus out check. A parity check error on the bus was found. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 705 | dev_warn (&device->cdev->dev, "A parity error occurred on the " |
| 706 | "tape bus\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | return tape_34xx_erp_failed(request, -EIO); |
| 708 | case 0x4a: |
| 709 | /* Control unit erp failed. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 710 | dev_warn (&device->cdev->dev, "I/O error recovery failed on " |
| 711 | "the tape control unit\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | return tape_34xx_erp_failed(request, -EIO); |
| 713 | case 0x4b: |
| 714 | /* |
| 715 | * CU and drive incompatible. The drive requests micro-program |
| 716 | * patches, which are not available on the CU. |
| 717 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 718 | dev_warn (&device->cdev->dev, "The tape unit requires a " |
| 719 | "firmware update\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | return tape_34xx_erp_failed(request, -EIO); |
| 721 | case 0x4c: |
| 722 | /* |
| 723 | * Recovered Check-One failure. Cu develops a hardware error, |
| 724 | * but is able to recover. |
| 725 | */ |
| 726 | return tape_34xx_erp_retry(request); |
| 727 | case 0x4d: |
| 728 | if (device->cdev->id.driver_info == tape_3490) |
| 729 | /* |
| 730 | * Resetting event received. Since the driver does |
| 731 | * not support resetting event recovery (which has to |
| 732 | * be handled by the I/O Layer), retry our command. |
| 733 | */ |
| 734 | return tape_34xx_erp_retry(request); |
| 735 | /* This erpa is reserved for 3480. */ |
| 736 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 737 | case 0x4e: |
| 738 | if (device->cdev->id.driver_info == tape_3490) { |
| 739 | /* |
| 740 | * Maximum block size exceeded. This indicates, that |
| 741 | * the block to be written is larger than allowed for |
| 742 | * buffered mode. |
| 743 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 744 | dev_warn (&device->cdev->dev, "The maximum block size" |
| 745 | " for buffered mode is exceeded\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | return tape_34xx_erp_failed(request, -ENOBUFS); |
| 747 | } |
| 748 | /* This erpa is reserved for 3480. */ |
| 749 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 750 | case 0x50: |
| 751 | /* |
| 752 | * Read buffered log (Overflow). CU is running in extended |
| 753 | * buffered log mode, and a counter overflows. This should |
| 754 | * never happen, since we're never running in extended |
| 755 | * buffered log mode. |
| 756 | */ |
| 757 | return tape_34xx_erp_retry(request); |
| 758 | case 0x51: |
| 759 | /* |
| 760 | * Read buffered log (EOV). EOF processing occurs while the |
| 761 | * CU is in extended buffered log mode. This should never |
| 762 | * happen, since we're never running in extended buffered |
| 763 | * log mode. |
| 764 | */ |
| 765 | return tape_34xx_erp_retry(request); |
| 766 | case 0x52: |
| 767 | /* End of Volume complete. Rewind unload completed ok. */ |
| 768 | if (request->op == TO_RUN) { |
| 769 | tape_med_state_set(device, MS_UNLOADED); |
| 770 | tape_34xx_delete_sbid_from(device, 0); |
| 771 | return tape_34xx_erp_succeeded(request); |
| 772 | } |
| 773 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 774 | case 0x53: |
| 775 | /* Global command intercept. */ |
| 776 | return tape_34xx_erp_retry(request); |
| 777 | case 0x54: |
| 778 | /* Channel interface recovery (temporary). */ |
| 779 | return tape_34xx_erp_retry(request); |
| 780 | case 0x55: |
| 781 | /* Channel interface recovery (permanent). */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 782 | dev_warn (&device->cdev->dev, "A channel interface error cannot be" |
| 783 | " recovered\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | return tape_34xx_erp_failed(request, -EIO); |
| 785 | case 0x56: |
| 786 | /* Channel protocol error. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 787 | dev_warn (&device->cdev->dev, "A channel protocol error " |
| 788 | "occurred\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | return tape_34xx_erp_failed(request, -EIO); |
| 790 | case 0x57: |
| 791 | if (device->cdev->id.driver_info == tape_3480) { |
| 792 | /* Attention intercept. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | return tape_34xx_erp_retry(request); |
| 794 | } else { |
| 795 | /* Global status intercept. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | return tape_34xx_erp_retry(request); |
| 797 | } |
| 798 | case 0x5a: |
| 799 | /* |
| 800 | * Tape length incompatible. The tape inserted is too long, |
| 801 | * which could cause damage to the tape or the drive. |
| 802 | */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 803 | dev_warn (&device->cdev->dev, "The tape unit does not support " |
| 804 | "the tape length\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | return tape_34xx_erp_failed(request, -EIO); |
| 806 | case 0x5b: |
| 807 | /* Format 3480 XF incompatible */ |
| 808 | if (sense[1] & SENSE_BEGINNING_OF_TAPE) |
| 809 | /* The tape will get overwritten. */ |
| 810 | return tape_34xx_erp_retry(request); |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 811 | dev_warn (&device->cdev->dev, "The tape unit does not support" |
| 812 | " format 3480 XF\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | return tape_34xx_erp_failed(request, -EIO); |
| 814 | case 0x5c: |
| 815 | /* Format 3480-2 XF incompatible */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 816 | dev_warn (&device->cdev->dev, "The tape unit does not support tape " |
| 817 | "format 3480-2 XF\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | return tape_34xx_erp_failed(request, -EIO); |
| 819 | case 0x5d: |
| 820 | /* Tape length violation. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 821 | dev_warn (&device->cdev->dev, "The tape unit does not support" |
| 822 | " the current tape length\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | return tape_34xx_erp_failed(request, -EMEDIUMTYPE); |
| 824 | case 0x5e: |
| 825 | /* Compaction algorithm incompatible. */ |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 826 | dev_warn (&device->cdev->dev, "The tape unit does not support" |
| 827 | " the compaction algorithm\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | return tape_34xx_erp_failed(request, -EMEDIUMTYPE); |
| 829 | |
| 830 | /* The following erpas should have been covered earlier. */ |
| 831 | case 0x23: /* Read data check. */ |
| 832 | case 0x25: /* Write data check. */ |
| 833 | case 0x26: /* Data check (read opposite). */ |
| 834 | case 0x28: /* Write id mark check. */ |
| 835 | case 0x31: /* Tape void. */ |
| 836 | case 0x40: /* Overrun error. */ |
| 837 | case 0x41: /* Record sequence error. */ |
| 838 | /* All other erpas are reserved for future use. */ |
| 839 | default: |
| 840 | return tape_34xx_erp_bug(device, request, irb, sense[3]); |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | /* |
| 845 | * 3480/3490 interrupt handler |
| 846 | */ |
| 847 | static int |
| 848 | tape_34xx_irq(struct tape_device *device, struct tape_request *request, |
| 849 | struct irb *irb) |
| 850 | { |
| 851 | if (request == NULL) |
| 852 | return tape_34xx_unsolicited_irq(device, irb); |
| 853 | |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 854 | if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) && |
| 855 | (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | (request->op == TO_WRI)) { |
| 857 | /* Write at end of volume */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | return tape_34xx_erp_failed(request, -ENOSPC); |
| 859 | } |
| 860 | |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 861 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | return tape_34xx_unit_check(device, request, irb); |
| 863 | |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 864 | if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | /* |
| 866 | * A unit exception occurs on skipping over a tapemark block. |
| 867 | */ |
Peter Oberparleiter | 23d805b | 2008-07-14 09:58:50 +0200 | [diff] [blame] | 868 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | if (request->op == TO_BSB || request->op == TO_FSB) |
| 870 | request->rescnt++; |
| 871 | else |
| 872 | DBF_EVENT(5, "Unit Exception!\n"); |
| 873 | } |
| 874 | return tape_34xx_done(request); |
| 875 | } |
| 876 | |
| 877 | DBF_EVENT(6, "xunknownirq\n"); |
Carsten Otte | ab640db | 2009-03-26 15:24:38 +0100 | [diff] [blame] | 878 | tape_dump_sense_dbf(device, request, irb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | return TAPE_IO_STOP; |
| 880 | } |
| 881 | |
| 882 | /* |
| 883 | * ioctl_overload |
| 884 | */ |
| 885 | static int |
| 886 | tape_34xx_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg) |
| 887 | { |
| 888 | if (cmd == TAPE390_DISPLAY) { |
| 889 | struct display_struct disp; |
| 890 | |
| 891 | if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)) != 0) |
| 892 | return -EFAULT; |
| 893 | |
| 894 | return tape_std_display(device, &disp); |
| 895 | } else |
| 896 | return -EINVAL; |
| 897 | } |
| 898 | |
| 899 | static inline void |
| 900 | tape_34xx_append_new_sbid(struct tape_34xx_block_id bid, struct list_head *l) |
| 901 | { |
| 902 | struct tape_34xx_sbid * new_sbid; |
| 903 | |
| 904 | new_sbid = kmalloc(sizeof(*new_sbid), GFP_ATOMIC); |
| 905 | if (!new_sbid) |
| 906 | return; |
| 907 | |
| 908 | new_sbid->bid = bid; |
| 909 | list_add(&new_sbid->list, l); |
| 910 | } |
| 911 | |
| 912 | /* |
| 913 | * Build up the search block ID list. The block ID consists of a logical |
| 914 | * block number and a hardware specific part. The hardware specific part |
| 915 | * helps the tape drive to speed up searching for a specific block. |
| 916 | */ |
| 917 | static void |
| 918 | tape_34xx_add_sbid(struct tape_device *device, struct tape_34xx_block_id bid) |
| 919 | { |
| 920 | struct list_head * sbid_list; |
| 921 | struct tape_34xx_sbid * sbid; |
| 922 | struct list_head * l; |
| 923 | |
| 924 | /* |
| 925 | * immediately return if there is no list at all or the block to add |
| 926 | * is located in segment 1 of wrap 0 because this position is used |
| 927 | * if no hardware position data is supplied. |
| 928 | */ |
| 929 | sbid_list = (struct list_head *) device->discdata; |
| 930 | if (!sbid_list || (bid.segment < 2 && bid.wrap == 0)) |
| 931 | return; |
| 932 | |
| 933 | /* |
| 934 | * Search the position where to insert the new entry. Hardware |
| 935 | * acceleration uses only the segment and wrap number. So we |
| 936 | * need only one entry for a specific wrap/segment combination. |
| 937 | * If there is a block with a lower number but the same hard- |
| 938 | * ware position data we just update the block number in the |
| 939 | * existing entry. |
| 940 | */ |
| 941 | list_for_each(l, sbid_list) { |
| 942 | sbid = list_entry(l, struct tape_34xx_sbid, list); |
| 943 | |
| 944 | if ( |
| 945 | (sbid->bid.segment == bid.segment) && |
| 946 | (sbid->bid.wrap == bid.wrap) |
| 947 | ) { |
| 948 | if (bid.block < sbid->bid.block) |
| 949 | sbid->bid = bid; |
| 950 | else return; |
| 951 | break; |
| 952 | } |
| 953 | |
| 954 | /* Sort in according to logical block number. */ |
| 955 | if (bid.block < sbid->bid.block) { |
| 956 | tape_34xx_append_new_sbid(bid, l->prev); |
| 957 | break; |
| 958 | } |
| 959 | } |
| 960 | /* List empty or new block bigger than last entry. */ |
| 961 | if (l == sbid_list) |
| 962 | tape_34xx_append_new_sbid(bid, l->prev); |
| 963 | |
| 964 | DBF_LH(4, "Current list is:\n"); |
| 965 | list_for_each(l, sbid_list) { |
| 966 | sbid = list_entry(l, struct tape_34xx_sbid, list); |
| 967 | DBF_LH(4, "%d:%03d@%05d\n", |
| 968 | sbid->bid.wrap, |
| 969 | sbid->bid.segment, |
| 970 | sbid->bid.block |
| 971 | ); |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | /* |
| 976 | * Delete all entries from the search block ID list that belong to tape blocks |
| 977 | * equal or higher than the given number. |
| 978 | */ |
| 979 | static void |
| 980 | tape_34xx_delete_sbid_from(struct tape_device *device, int from) |
| 981 | { |
| 982 | struct list_head * sbid_list; |
| 983 | struct tape_34xx_sbid * sbid; |
| 984 | struct list_head * l; |
| 985 | struct list_head * n; |
| 986 | |
| 987 | sbid_list = (struct list_head *) device->discdata; |
| 988 | if (!sbid_list) |
| 989 | return; |
| 990 | |
| 991 | list_for_each_safe(l, n, sbid_list) { |
| 992 | sbid = list_entry(l, struct tape_34xx_sbid, list); |
| 993 | if (sbid->bid.block >= from) { |
| 994 | DBF_LH(4, "Delete sbid %d:%03d@%05d\n", |
| 995 | sbid->bid.wrap, |
| 996 | sbid->bid.segment, |
| 997 | sbid->bid.block |
| 998 | ); |
| 999 | list_del(l); |
| 1000 | kfree(sbid); |
| 1001 | } |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | /* |
| 1006 | * Merge hardware position data into a block id. |
| 1007 | */ |
| 1008 | static void |
| 1009 | tape_34xx_merge_sbid( |
| 1010 | struct tape_device * device, |
| 1011 | struct tape_34xx_block_id * bid |
| 1012 | ) { |
| 1013 | struct tape_34xx_sbid * sbid; |
| 1014 | struct tape_34xx_sbid * sbid_to_use; |
| 1015 | struct list_head * sbid_list; |
| 1016 | struct list_head * l; |
| 1017 | |
| 1018 | sbid_list = (struct list_head *) device->discdata; |
| 1019 | bid->wrap = 0; |
| 1020 | bid->segment = 1; |
| 1021 | |
| 1022 | if (!sbid_list || list_empty(sbid_list)) |
| 1023 | return; |
| 1024 | |
| 1025 | sbid_to_use = NULL; |
| 1026 | list_for_each(l, sbid_list) { |
| 1027 | sbid = list_entry(l, struct tape_34xx_sbid, list); |
| 1028 | |
| 1029 | if (sbid->bid.block >= bid->block) |
| 1030 | break; |
| 1031 | sbid_to_use = sbid; |
| 1032 | } |
| 1033 | if (sbid_to_use) { |
| 1034 | bid->wrap = sbid_to_use->bid.wrap; |
| 1035 | bid->segment = sbid_to_use->bid.segment; |
| 1036 | DBF_LH(4, "Use %d:%03d@%05d for %05d\n", |
| 1037 | sbid_to_use->bid.wrap, |
| 1038 | sbid_to_use->bid.segment, |
| 1039 | sbid_to_use->bid.block, |
| 1040 | bid->block |
| 1041 | ); |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | static int |
| 1046 | tape_34xx_setup_device(struct tape_device * device) |
| 1047 | { |
| 1048 | int rc; |
| 1049 | struct list_head * discdata; |
| 1050 | |
| 1051 | DBF_EVENT(6, "34xx device setup\n"); |
| 1052 | if ((rc = tape_std_assign(device)) == 0) { |
| 1053 | if ((rc = tape_34xx_medium_sense(device)) != 0) { |
| 1054 | DBF_LH(3, "34xx medium sense returned %d\n", rc); |
| 1055 | } |
| 1056 | } |
| 1057 | discdata = kmalloc(sizeof(struct list_head), GFP_KERNEL); |
| 1058 | if (discdata) { |
| 1059 | INIT_LIST_HEAD(discdata); |
| 1060 | device->discdata = discdata; |
| 1061 | } |
| 1062 | |
| 1063 | return rc; |
| 1064 | } |
| 1065 | |
| 1066 | static void |
| 1067 | tape_34xx_cleanup_device(struct tape_device *device) |
| 1068 | { |
| 1069 | tape_std_unassign(device); |
| 1070 | |
| 1071 | if (device->discdata) { |
| 1072 | tape_34xx_delete_sbid_from(device, 0); |
| 1073 | kfree(device->discdata); |
| 1074 | device->discdata = NULL; |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | /* |
| 1080 | * MTTELL: Tell block. Return the number of block relative to current file. |
| 1081 | */ |
| 1082 | static int |
| 1083 | tape_34xx_mttell(struct tape_device *device, int mt_count) |
| 1084 | { |
| 1085 | struct { |
| 1086 | struct tape_34xx_block_id cbid; |
| 1087 | struct tape_34xx_block_id dbid; |
| 1088 | } __attribute__ ((packed)) block_id; |
| 1089 | int rc; |
| 1090 | |
| 1091 | rc = tape_std_read_block_id(device, (__u64 *) &block_id); |
| 1092 | if (rc) |
| 1093 | return rc; |
| 1094 | |
| 1095 | tape_34xx_add_sbid(device, block_id.cbid); |
| 1096 | return block_id.cbid.block; |
| 1097 | } |
| 1098 | |
| 1099 | /* |
| 1100 | * MTSEEK: seek to the specified block. |
| 1101 | */ |
| 1102 | static int |
| 1103 | tape_34xx_mtseek(struct tape_device *device, int mt_count) |
| 1104 | { |
| 1105 | struct tape_request *request; |
| 1106 | struct tape_34xx_block_id * bid; |
| 1107 | |
| 1108 | if (mt_count > 0x3fffff) { |
| 1109 | DBF_EXCEPTION(6, "xsee parm\n"); |
| 1110 | return -EINVAL; |
| 1111 | } |
| 1112 | request = tape_alloc_request(3, 4); |
| 1113 | if (IS_ERR(request)) |
| 1114 | return PTR_ERR(request); |
| 1115 | |
| 1116 | /* setup ccws */ |
| 1117 | request->op = TO_LBL; |
| 1118 | bid = (struct tape_34xx_block_id *) request->cpdata; |
| 1119 | bid->format = (*device->modeset_byte & 0x08) ? |
| 1120 | TAPE34XX_FMT_3480_XF : TAPE34XX_FMT_3480; |
| 1121 | bid->block = mt_count; |
| 1122 | tape_34xx_merge_sbid(device, bid); |
| 1123 | |
| 1124 | tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); |
| 1125 | tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); |
| 1126 | tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); |
| 1127 | |
| 1128 | /* execute it */ |
| 1129 | return tape_do_io_free(device, request); |
| 1130 | } |
| 1131 | |
| 1132 | #ifdef CONFIG_S390_TAPE_BLOCK |
| 1133 | /* |
| 1134 | * Tape block read for 34xx. |
| 1135 | */ |
| 1136 | static struct tape_request * |
| 1137 | tape_34xx_bread(struct tape_device *device, struct request *req) |
| 1138 | { |
| 1139 | struct tape_request *request; |
| 1140 | struct ccw1 *ccw; |
NeilBrown | 5705f70 | 2007-09-25 12:35:59 +0200 | [diff] [blame] | 1141 | int count = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | unsigned off; |
| 1143 | char *dst; |
| 1144 | struct bio_vec *bv; |
NeilBrown | 5705f70 | 2007-09-25 12:35:59 +0200 | [diff] [blame] | 1145 | struct req_iterator iter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | struct tape_34xx_block_id * start_block; |
| 1147 | |
| 1148 | DBF_EVENT(6, "xBREDid:"); |
| 1149 | |
| 1150 | /* Count the number of blocks for the request. */ |
NeilBrown | 5705f70 | 2007-09-25 12:35:59 +0200 | [diff] [blame] | 1151 | rq_for_each_segment(bv, req, iter) |
| 1152 | count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | |
| 1154 | /* Allocate the ccw request. */ |
| 1155 | request = tape_alloc_request(3+count+1, 8); |
| 1156 | if (IS_ERR(request)) |
| 1157 | return request; |
| 1158 | |
| 1159 | /* Setup ccws. */ |
| 1160 | request->op = TO_BLOCK; |
| 1161 | start_block = (struct tape_34xx_block_id *) request->cpdata; |
Tejun Heo | 83096eb | 2009-05-07 22:24:39 +0900 | [diff] [blame] | 1162 | start_block->block = blk_rq_pos(req) >> TAPEBLOCK_HSEC_S2B; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | DBF_EVENT(6, "start_block = %i\n", start_block->block); |
| 1164 | |
| 1165 | ccw = request->cpaddr; |
| 1166 | ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte); |
| 1167 | |
| 1168 | /* |
| 1169 | * We always setup a nop after the mode set ccw. This slot is |
| 1170 | * used in tape_std_check_locate to insert a locate ccw if the |
| 1171 | * current tape position doesn't match the start block to be read. |
| 1172 | * The second nop will be filled with a read block id which is in |
| 1173 | * turn used by tape_34xx_free_bread to populate the segment bid |
| 1174 | * table. |
| 1175 | */ |
| 1176 | ccw = tape_ccw_cc(ccw, NOP, 0, NULL); |
| 1177 | ccw = tape_ccw_cc(ccw, NOP, 0, NULL); |
| 1178 | |
NeilBrown | 5705f70 | 2007-09-25 12:35:59 +0200 | [diff] [blame] | 1179 | rq_for_each_segment(bv, req, iter) { |
Jens Axboe | 6c92e69 | 2007-08-16 13:43:12 +0200 | [diff] [blame] | 1180 | dst = kmap(bv->bv_page) + bv->bv_offset; |
| 1181 | for (off = 0; off < bv->bv_len; off += TAPEBLOCK_HSEC_SIZE) { |
| 1182 | ccw->flags = CCW_FLAG_CC; |
| 1183 | ccw->cmd_code = READ_FORWARD; |
| 1184 | ccw->count = TAPEBLOCK_HSEC_SIZE; |
| 1185 | set_normalized_cda(ccw, (void*) __pa(dst)); |
| 1186 | ccw++; |
| 1187 | dst += TAPEBLOCK_HSEC_SIZE; |
| 1188 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | } |
| 1190 | |
| 1191 | ccw = tape_ccw_end(ccw, NOP, 0, NULL); |
| 1192 | DBF_EVENT(6, "xBREDccwg\n"); |
| 1193 | return request; |
| 1194 | } |
| 1195 | |
| 1196 | static void |
| 1197 | tape_34xx_free_bread (struct tape_request *request) |
| 1198 | { |
| 1199 | struct ccw1* ccw; |
| 1200 | |
| 1201 | ccw = request->cpaddr; |
| 1202 | if ((ccw + 2)->cmd_code == READ_BLOCK_ID) { |
| 1203 | struct { |
| 1204 | struct tape_34xx_block_id cbid; |
| 1205 | struct tape_34xx_block_id dbid; |
| 1206 | } __attribute__ ((packed)) *rbi_data; |
| 1207 | |
| 1208 | rbi_data = request->cpdata; |
| 1209 | |
| 1210 | if (request->device) |
| 1211 | tape_34xx_add_sbid(request->device, rbi_data->cbid); |
| 1212 | } |
| 1213 | |
| 1214 | /* Last ccw is a nop and doesn't need clear_normalized_cda */ |
| 1215 | for (; ccw->flags & CCW_FLAG_CC; ccw++) |
| 1216 | if (ccw->cmd_code == READ_FORWARD) |
| 1217 | clear_normalized_cda(ccw); |
| 1218 | tape_free_request(request); |
| 1219 | } |
| 1220 | |
| 1221 | /* |
| 1222 | * check_locate is called just before the tape request is passed to |
| 1223 | * the common io layer for execution. It has to check the current |
| 1224 | * tape position and insert a locate ccw if it doesn't match the |
| 1225 | * start block for the request. |
| 1226 | */ |
| 1227 | static void |
| 1228 | tape_34xx_check_locate(struct tape_device *device, struct tape_request *request) |
| 1229 | { |
| 1230 | struct tape_34xx_block_id * start_block; |
| 1231 | |
| 1232 | start_block = (struct tape_34xx_block_id *) request->cpdata; |
| 1233 | if (start_block->block == device->blk_data.block_position) |
| 1234 | return; |
| 1235 | |
| 1236 | DBF_LH(4, "Block seek(%06d+%06d)\n", start_block->block, device->bof); |
| 1237 | start_block->wrap = 0; |
| 1238 | start_block->segment = 1; |
| 1239 | start_block->format = (*device->modeset_byte & 0x08) ? |
| 1240 | TAPE34XX_FMT_3480_XF : |
| 1241 | TAPE34XX_FMT_3480; |
| 1242 | start_block->block = start_block->block + device->bof; |
| 1243 | tape_34xx_merge_sbid(device, start_block); |
| 1244 | tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); |
| 1245 | tape_ccw_cc(request->cpaddr + 2, READ_BLOCK_ID, 8, request->cpdata); |
| 1246 | } |
| 1247 | #endif |
| 1248 | |
| 1249 | /* |
| 1250 | * List of 3480/3490 magnetic tape commands. |
| 1251 | */ |
| 1252 | static tape_mtop_fn tape_34xx_mtop[TAPE_NR_MTOPS] = { |
| 1253 | [MTRESET] = tape_std_mtreset, |
| 1254 | [MTFSF] = tape_std_mtfsf, |
| 1255 | [MTBSF] = tape_std_mtbsf, |
| 1256 | [MTFSR] = tape_std_mtfsr, |
| 1257 | [MTBSR] = tape_std_mtbsr, |
| 1258 | [MTWEOF] = tape_std_mtweof, |
| 1259 | [MTREW] = tape_std_mtrew, |
| 1260 | [MTOFFL] = tape_std_mtoffl, |
| 1261 | [MTNOP] = tape_std_mtnop, |
| 1262 | [MTRETEN] = tape_std_mtreten, |
| 1263 | [MTBSFM] = tape_std_mtbsfm, |
| 1264 | [MTFSFM] = tape_std_mtfsfm, |
| 1265 | [MTEOM] = tape_std_mteom, |
| 1266 | [MTERASE] = tape_std_mterase, |
| 1267 | [MTRAS1] = NULL, |
| 1268 | [MTRAS2] = NULL, |
| 1269 | [MTRAS3] = NULL, |
| 1270 | [MTSETBLK] = tape_std_mtsetblk, |
| 1271 | [MTSETDENSITY] = NULL, |
| 1272 | [MTSEEK] = tape_34xx_mtseek, |
| 1273 | [MTTELL] = tape_34xx_mttell, |
| 1274 | [MTSETDRVBUFFER] = NULL, |
| 1275 | [MTFSS] = NULL, |
| 1276 | [MTBSS] = NULL, |
| 1277 | [MTWSM] = NULL, |
| 1278 | [MTLOCK] = NULL, |
| 1279 | [MTUNLOCK] = NULL, |
| 1280 | [MTLOAD] = tape_std_mtload, |
| 1281 | [MTUNLOAD] = tape_std_mtunload, |
| 1282 | [MTCOMPRESSION] = tape_std_mtcompression, |
| 1283 | [MTSETPART] = NULL, |
| 1284 | [MTMKPART] = NULL |
| 1285 | }; |
| 1286 | |
| 1287 | /* |
| 1288 | * Tape discipline structure for 3480 and 3490. |
| 1289 | */ |
| 1290 | static struct tape_discipline tape_discipline_34xx = { |
| 1291 | .owner = THIS_MODULE, |
| 1292 | .setup_device = tape_34xx_setup_device, |
| 1293 | .cleanup_device = tape_34xx_cleanup_device, |
| 1294 | .process_eov = tape_std_process_eov, |
| 1295 | .irq = tape_34xx_irq, |
| 1296 | .read_block = tape_std_read_block, |
| 1297 | .write_block = tape_std_write_block, |
| 1298 | #ifdef CONFIG_S390_TAPE_BLOCK |
| 1299 | .bread = tape_34xx_bread, |
| 1300 | .free_bread = tape_34xx_free_bread, |
| 1301 | .check_locate = tape_34xx_check_locate, |
| 1302 | #endif |
| 1303 | .ioctl_fn = tape_34xx_ioctl, |
| 1304 | .mtop_array = tape_34xx_mtop |
| 1305 | }; |
| 1306 | |
| 1307 | static struct ccw_device_id tape_34xx_ids[] = { |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 1308 | { CCW_DEVICE_DEVTYPE(0x3480, 0, 0x3480, 0), .driver_info = tape_3480}, |
| 1309 | { CCW_DEVICE_DEVTYPE(0x3490, 0, 0x3490, 0), .driver_info = tape_3490}, |
| 1310 | { /* end of list */ }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | }; |
| 1312 | |
| 1313 | static int |
| 1314 | tape_34xx_online(struct ccw_device *cdev) |
| 1315 | { |
| 1316 | return tape_generic_online( |
Greg Kroah-Hartman | dff59b6 | 2009-05-04 12:40:54 -0700 | [diff] [blame] | 1317 | dev_get_drvdata(&cdev->dev), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1318 | &tape_discipline_34xx |
| 1319 | ); |
| 1320 | } |
| 1321 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | static struct ccw_driver tape_34xx_driver = { |
Sebastian Ott | 3bda058 | 2011-03-23 10:16:02 +0100 | [diff] [blame] | 1323 | .driver = { |
| 1324 | .name = "tape_34xx", |
| 1325 | .owner = THIS_MODULE, |
| 1326 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | .ids = tape_34xx_ids, |
| 1328 | .probe = tape_generic_probe, |
| 1329 | .remove = tape_generic_remove, |
| 1330 | .set_online = tape_34xx_online, |
Frank Munzert | 4d7a3cd | 2009-04-23 13:58:09 +0200 | [diff] [blame] | 1331 | .set_offline = tape_generic_offline, |
Frank Munzert | 3ef32e62 | 2009-06-16 10:30:39 +0200 | [diff] [blame] | 1332 | .freeze = tape_generic_pm_suspend, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | }; |
| 1334 | |
| 1335 | static int |
| 1336 | tape_34xx_init (void) |
| 1337 | { |
| 1338 | int rc; |
| 1339 | |
Michael Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 1340 | TAPE_DBF_AREA = debug_register ( "tape_34xx", 2, 2, 4*sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view); |
| 1342 | #ifdef DBF_LIKE_HELL |
| 1343 | debug_set_level(TAPE_DBF_AREA, 6); |
| 1344 | #endif |
| 1345 | |
Heiko Carstens | e018ba1 | 2006-02-01 03:06:31 -0800 | [diff] [blame] | 1346 | DBF_EVENT(3, "34xx init\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | /* Register driver for 3480/3490 tapes. */ |
| 1348 | rc = ccw_driver_register(&tape_34xx_driver); |
| 1349 | if (rc) |
| 1350 | DBF_EVENT(3, "34xx init failed\n"); |
| 1351 | else |
| 1352 | DBF_EVENT(3, "34xx registered\n"); |
| 1353 | return rc; |
| 1354 | } |
| 1355 | |
| 1356 | static void |
| 1357 | tape_34xx_exit(void) |
| 1358 | { |
| 1359 | ccw_driver_unregister(&tape_34xx_driver); |
| 1360 | |
| 1361 | debug_unregister(TAPE_DBF_AREA); |
| 1362 | } |
| 1363 | |
| 1364 | MODULE_DEVICE_TABLE(ccw, tape_34xx_ids); |
| 1365 | MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH"); |
Heiko Carstens | e018ba1 | 2006-02-01 03:06:31 -0800 | [diff] [blame] | 1366 | MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape device driver"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | MODULE_LICENSE("GPL"); |
| 1368 | |
| 1369 | module_init(tape_34xx_init); |
| 1370 | module_exit(tape_34xx_exit); |