1b6cba4eeSStefan Bader /* 2b6cba4eeSStefan Bader * drivers/s390/char/tape_3590.c 3b6cba4eeSStefan Bader * tape device discipline for 3590 tapes. 4b6cba4eeSStefan Bader * 5b6cba4eeSStefan Bader * Copyright (C) IBM Corp. 2001,2006 6b6cba4eeSStefan Bader * Author(s): Stefan Bader <shbader@de.ibm.com> 7b6cba4eeSStefan Bader * Michael Holzheu <holzheu@de.ibm.com> 8b6cba4eeSStefan Bader * Martin Schwidefsky <schwidefsky@de.ibm.com> 9b6cba4eeSStefan Bader */ 10b6cba4eeSStefan Bader 11b6cba4eeSStefan Bader #include <linux/config.h> 12b6cba4eeSStefan Bader #include <linux/module.h> 13b6cba4eeSStefan Bader #include <linux/init.h> 14b6cba4eeSStefan Bader #include <linux/bio.h> 15b6cba4eeSStefan Bader 16b6cba4eeSStefan Bader #define TAPE_DBF_AREA tape_3590_dbf 17b6cba4eeSStefan Bader 18b6cba4eeSStefan Bader #include "tape.h" 19b6cba4eeSStefan Bader #include "tape_std.h" 20b6cba4eeSStefan Bader #include "tape_3590.h" 21b6cba4eeSStefan Bader 22b6cba4eeSStefan Bader /* 23b6cba4eeSStefan Bader * Pointer to debug area. 24b6cba4eeSStefan Bader */ 25b6cba4eeSStefan Bader debug_info_t *TAPE_DBF_AREA = NULL; 26b6cba4eeSStefan Bader EXPORT_SYMBOL(TAPE_DBF_AREA); 27b6cba4eeSStefan Bader 28b6cba4eeSStefan Bader /******************************************************************* 29b6cba4eeSStefan Bader * Error Recovery fuctions: 30b6cba4eeSStefan Bader * - Read Opposite: implemented 31b6cba4eeSStefan Bader * - Read Device (buffered) log: BRA 32b6cba4eeSStefan Bader * - Read Library log: BRA 33b6cba4eeSStefan Bader * - Swap Devices: BRA 34b6cba4eeSStefan Bader * - Long Busy: BRA 35b6cba4eeSStefan Bader * - Special Intercept: BRA 36b6cba4eeSStefan Bader * - Read Alternate: implemented 37b6cba4eeSStefan Bader *******************************************************************/ 38b6cba4eeSStefan Bader 39b6cba4eeSStefan Bader #define PRINTK_HEADER "TAPE_3590: " 40b6cba4eeSStefan Bader 41b6cba4eeSStefan Bader static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = { 42b6cba4eeSStefan Bader [0x00] = "", 43b6cba4eeSStefan Bader [0x10] = "Lost Sense", 44b6cba4eeSStefan Bader [0x11] = "Assigned Elsewhere", 45b6cba4eeSStefan Bader [0x12] = "Allegiance Reset", 46b6cba4eeSStefan Bader [0x13] = "Shared Access Violation", 47b6cba4eeSStefan Bader [0x20] = "Command Reject", 48b6cba4eeSStefan Bader [0x21] = "Configuration Error", 49b6cba4eeSStefan Bader [0x22] = "Protection Exception", 50b6cba4eeSStefan Bader [0x23] = "Write Protect", 51b6cba4eeSStefan Bader [0x24] = "Write Length", 52b6cba4eeSStefan Bader [0x25] = "Read-Only Format", 53b6cba4eeSStefan Bader [0x31] = "Beginning of Partition", 54b6cba4eeSStefan Bader [0x33] = "End of Partition", 55b6cba4eeSStefan Bader [0x34] = "End of Data", 56b6cba4eeSStefan Bader [0x35] = "Block not found", 57b6cba4eeSStefan Bader [0x40] = "Device Intervention", 58b6cba4eeSStefan Bader [0x41] = "Loader Intervention", 59b6cba4eeSStefan Bader [0x42] = "Library Intervention", 60b6cba4eeSStefan Bader [0x50] = "Write Error", 61b6cba4eeSStefan Bader [0x51] = "Erase Error", 62b6cba4eeSStefan Bader [0x52] = "Formatting Error", 63b6cba4eeSStefan Bader [0x53] = "Read Error", 64b6cba4eeSStefan Bader [0x54] = "Unsupported Format", 65b6cba4eeSStefan Bader [0x55] = "No Formatting", 66b6cba4eeSStefan Bader [0x56] = "Positioning lost", 67b6cba4eeSStefan Bader [0x57] = "Read Length", 68b6cba4eeSStefan Bader [0x60] = "Unsupported Medium", 69b6cba4eeSStefan Bader [0x61] = "Medium Length Error", 70b6cba4eeSStefan Bader [0x62] = "Medium removed", 71b6cba4eeSStefan Bader [0x64] = "Load Check", 72b6cba4eeSStefan Bader [0x65] = "Unload Check", 73b6cba4eeSStefan Bader [0x70] = "Equipment Check", 74b6cba4eeSStefan Bader [0x71] = "Bus out Check", 75b6cba4eeSStefan Bader [0x72] = "Protocol Error", 76b6cba4eeSStefan Bader [0x73] = "Interface Error", 77b6cba4eeSStefan Bader [0x74] = "Overrun", 78b6cba4eeSStefan Bader [0x75] = "Halt Signal", 79b6cba4eeSStefan Bader [0x90] = "Device fenced", 80b6cba4eeSStefan Bader [0x91] = "Device Path fenced", 81b6cba4eeSStefan Bader [0xa0] = "Volume misplaced", 82b6cba4eeSStefan Bader [0xa1] = "Volume inaccessible", 83b6cba4eeSStefan Bader [0xa2] = "Volume in input", 84b6cba4eeSStefan Bader [0xa3] = "Volume ejected", 85b6cba4eeSStefan Bader [0xa4] = "All categories reserved", 86b6cba4eeSStefan Bader [0xa5] = "Duplicate Volume", 87b6cba4eeSStefan Bader [0xa6] = "Library Manager Offline", 88b6cba4eeSStefan Bader [0xa7] = "Library Output Station full", 89b6cba4eeSStefan Bader [0xa8] = "Vision System non-operational", 90b6cba4eeSStefan Bader [0xa9] = "Library Manager Equipment Check", 91b6cba4eeSStefan Bader [0xaa] = "Library Equipment Check", 92b6cba4eeSStefan Bader [0xab] = "All Library Cells full", 93b6cba4eeSStefan Bader [0xac] = "No Cleaner Volumes in Library", 94b6cba4eeSStefan Bader [0xad] = "I/O Station door open", 95b6cba4eeSStefan Bader [0xae] = "Subsystem environmental alert", 96b6cba4eeSStefan Bader }; 97b6cba4eeSStefan Bader 98b6cba4eeSStefan Bader /* 99b6cba4eeSStefan Bader * 3590 IOCTL Overload 100b6cba4eeSStefan Bader */ 101b6cba4eeSStefan Bader static int 102b6cba4eeSStefan Bader tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg) 103b6cba4eeSStefan Bader { 104b6cba4eeSStefan Bader switch (cmd) { 105b6cba4eeSStefan Bader case TAPE390_DISPLAY: { 106b6cba4eeSStefan Bader struct display_struct disp; 107b6cba4eeSStefan Bader 108b6cba4eeSStefan Bader if (copy_from_user(&disp, (char __user *) arg, sizeof(disp))) 109b6cba4eeSStefan Bader return -EFAULT; 110b6cba4eeSStefan Bader 111b6cba4eeSStefan Bader return tape_std_display(device, &disp); 112b6cba4eeSStefan Bader } 113b6cba4eeSStefan Bader default: 114b6cba4eeSStefan Bader return -EINVAL; /* no additional ioctls */ 115b6cba4eeSStefan Bader } 116b6cba4eeSStefan Bader } 117b6cba4eeSStefan Bader 118b6cba4eeSStefan Bader /* 119b6cba4eeSStefan Bader * SENSE Medium: Get Sense data about medium state 120b6cba4eeSStefan Bader */ 121b6cba4eeSStefan Bader static int 122b6cba4eeSStefan Bader tape_3590_sense_medium(struct tape_device *device) 123b6cba4eeSStefan Bader { 124b6cba4eeSStefan Bader struct tape_request *request; 125b6cba4eeSStefan Bader 126b6cba4eeSStefan Bader request = tape_alloc_request(1, 128); 127b6cba4eeSStefan Bader if (IS_ERR(request)) 128b6cba4eeSStefan Bader return PTR_ERR(request); 129b6cba4eeSStefan Bader request->op = TO_MSEN; 130b6cba4eeSStefan Bader tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata); 131b6cba4eeSStefan Bader return tape_do_io_free(device, request); 132b6cba4eeSStefan Bader } 133b6cba4eeSStefan Bader 134b6cba4eeSStefan Bader /* 135b6cba4eeSStefan Bader * MTTELL: Tell block. Return the number of block relative to current file. 136b6cba4eeSStefan Bader */ 137b6cba4eeSStefan Bader static int 138b6cba4eeSStefan Bader tape_3590_mttell(struct tape_device *device, int mt_count) 139b6cba4eeSStefan Bader { 140b6cba4eeSStefan Bader __u64 block_id; 141b6cba4eeSStefan Bader int rc; 142b6cba4eeSStefan Bader 143b6cba4eeSStefan Bader rc = tape_std_read_block_id(device, &block_id); 144b6cba4eeSStefan Bader if (rc) 145b6cba4eeSStefan Bader return rc; 146b6cba4eeSStefan Bader return block_id >> 32; 147b6cba4eeSStefan Bader } 148b6cba4eeSStefan Bader 149b6cba4eeSStefan Bader /* 150b6cba4eeSStefan Bader * MTSEEK: seek to the specified block. 151b6cba4eeSStefan Bader */ 152b6cba4eeSStefan Bader static int 153b6cba4eeSStefan Bader tape_3590_mtseek(struct tape_device *device, int count) 154b6cba4eeSStefan Bader { 155b6cba4eeSStefan Bader struct tape_request *request; 156b6cba4eeSStefan Bader 157b6cba4eeSStefan Bader DBF_EVENT(6, "xsee id: %x\n", count); 158b6cba4eeSStefan Bader request = tape_alloc_request(3, 4); 159b6cba4eeSStefan Bader if (IS_ERR(request)) 160b6cba4eeSStefan Bader return PTR_ERR(request); 161b6cba4eeSStefan Bader request->op = TO_LBL; 162b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); 163b6cba4eeSStefan Bader *(__u32 *) request->cpdata = count; 164b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); 165b6cba4eeSStefan Bader tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); 166b6cba4eeSStefan Bader return tape_do_io_free(device, request); 167b6cba4eeSStefan Bader } 168b6cba4eeSStefan Bader 169b6cba4eeSStefan Bader /* 170b6cba4eeSStefan Bader * Read Opposite Error Recovery Function: 171b6cba4eeSStefan Bader * Used, when Read Forward does not work 172b6cba4eeSStefan Bader */ 173b6cba4eeSStefan Bader static void 174b6cba4eeSStefan Bader tape_3590_read_opposite(struct tape_device *device, 175b6cba4eeSStefan Bader struct tape_request *request) 176b6cba4eeSStefan Bader { 177b6cba4eeSStefan Bader struct tape_3590_disc_data *data; 178b6cba4eeSStefan Bader 179b6cba4eeSStefan Bader /* 180b6cba4eeSStefan Bader * We have allocated 4 ccws in tape_std_read, so we can now 181b6cba4eeSStefan Bader * transform the request to a read backward, followed by a 182b6cba4eeSStefan Bader * forward space block. 183b6cba4eeSStefan Bader */ 184b6cba4eeSStefan Bader request->op = TO_RBA; 185b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); 186b6cba4eeSStefan Bader data = device->discdata; 187b6cba4eeSStefan Bader tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op, 188b6cba4eeSStefan Bader device->char_data.idal_buf); 189b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL); 190b6cba4eeSStefan Bader tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL); 191b6cba4eeSStefan Bader DBF_EVENT(6, "xrop ccwg\n"); 192b6cba4eeSStefan Bader } 193b6cba4eeSStefan Bader 194b6cba4eeSStefan Bader /* 195b6cba4eeSStefan Bader * Read Attention Msg 196b6cba4eeSStefan Bader * This should be done after an interrupt with attention bit (0x80) 197b6cba4eeSStefan Bader * in device state. 198b6cba4eeSStefan Bader * 199b6cba4eeSStefan Bader * After a "read attention message" request there are two possible 200b6cba4eeSStefan Bader * results: 201b6cba4eeSStefan Bader * 202b6cba4eeSStefan Bader * 1. A unit check is presented, when attention sense is present (e.g. when 203b6cba4eeSStefan Bader * a medium has been unloaded). The attention sense comes then 204b6cba4eeSStefan Bader * together with the unit check. The recovery action is either "retry" 205b6cba4eeSStefan Bader * (in case there is an attention message pending) or "permanent error". 206b6cba4eeSStefan Bader * 207b6cba4eeSStefan Bader * 2. The attention msg is written to the "read subsystem data" buffer. 208b6cba4eeSStefan Bader * In this case we probably should print it to the console. 209b6cba4eeSStefan Bader */ 210b6cba4eeSStefan Bader static int 211b6cba4eeSStefan Bader tape_3590_read_attmsg(struct tape_device *device) 212b6cba4eeSStefan Bader { 213b6cba4eeSStefan Bader struct tape_request *request; 214b6cba4eeSStefan Bader char *buf; 215b6cba4eeSStefan Bader 216b6cba4eeSStefan Bader request = tape_alloc_request(3, 4096); 217b6cba4eeSStefan Bader if (IS_ERR(request)) 218b6cba4eeSStefan Bader return PTR_ERR(request); 219b6cba4eeSStefan Bader request->op = TO_READ_ATTMSG; 220b6cba4eeSStefan Bader buf = request->cpdata; 221b6cba4eeSStefan Bader buf[0] = PREP_RD_SS_DATA; 222b6cba4eeSStefan Bader buf[6] = RD_ATTMSG; /* read att msg */ 223b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf); 224b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12); 225b6cba4eeSStefan Bader tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); 226b6cba4eeSStefan Bader return tape_do_io_free(device, request); 227b6cba4eeSStefan Bader } 228b6cba4eeSStefan Bader 229b6cba4eeSStefan Bader /* 230b6cba4eeSStefan Bader * These functions are used to schedule follow-up actions from within an 231b6cba4eeSStefan Bader * interrupt context (like unsolicited interrupts). 232b6cba4eeSStefan Bader */ 233*2cc924b8SStefan Bader struct work_handler_data { 234b6cba4eeSStefan Bader struct tape_device *device; 235b6cba4eeSStefan Bader enum tape_op op; 236b6cba4eeSStefan Bader struct work_struct work; 237*2cc924b8SStefan Bader }; 238*2cc924b8SStefan Bader 239*2cc924b8SStefan Bader static void 240*2cc924b8SStefan Bader tape_3590_work_handler(void *data) 241*2cc924b8SStefan Bader { 242*2cc924b8SStefan Bader struct work_handler_data *p = data; 243b6cba4eeSStefan Bader 244b6cba4eeSStefan Bader switch (p->op) { 245b6cba4eeSStefan Bader case TO_MSEN: 246b6cba4eeSStefan Bader tape_3590_sense_medium(p->device); 247b6cba4eeSStefan Bader break; 248b6cba4eeSStefan Bader case TO_READ_ATTMSG: 249b6cba4eeSStefan Bader tape_3590_read_attmsg(p->device); 250b6cba4eeSStefan Bader break; 251b6cba4eeSStefan Bader default: 252b6cba4eeSStefan Bader DBF_EVENT(3, "T3590: work handler undefined for " 253b6cba4eeSStefan Bader "operation 0x%02x\n", p->op); 254b6cba4eeSStefan Bader } 255b6cba4eeSStefan Bader tape_put_device(p->device); 256b6cba4eeSStefan Bader kfree(p); 257b6cba4eeSStefan Bader } 258b6cba4eeSStefan Bader 259b6cba4eeSStefan Bader static int 260b6cba4eeSStefan Bader tape_3590_schedule_work(struct tape_device *device, enum tape_op op) 261b6cba4eeSStefan Bader { 262*2cc924b8SStefan Bader struct work_handler_data *p; 263b6cba4eeSStefan Bader 264b6cba4eeSStefan Bader if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) 265b6cba4eeSStefan Bader return -ENOMEM; 266b6cba4eeSStefan Bader 267b6cba4eeSStefan Bader INIT_WORK(&p->work, tape_3590_work_handler, p); 268b6cba4eeSStefan Bader 269b6cba4eeSStefan Bader p->device = tape_get_device_reference(device); 270b6cba4eeSStefan Bader p->op = op; 271b6cba4eeSStefan Bader 272b6cba4eeSStefan Bader schedule_work(&p->work); 273b6cba4eeSStefan Bader return 0; 274b6cba4eeSStefan Bader } 275b6cba4eeSStefan Bader 276b6cba4eeSStefan Bader #ifdef CONFIG_S390_TAPE_BLOCK 277b6cba4eeSStefan Bader /* 278b6cba4eeSStefan Bader * Tape Block READ 279b6cba4eeSStefan Bader */ 280b6cba4eeSStefan Bader static struct tape_request * 281b6cba4eeSStefan Bader tape_3590_bread(struct tape_device *device, struct request *req) 282b6cba4eeSStefan Bader { 283b6cba4eeSStefan Bader struct tape_request *request; 284b6cba4eeSStefan Bader struct ccw1 *ccw; 285b6cba4eeSStefan Bader int count = 0, start_block, i; 286b6cba4eeSStefan Bader unsigned off; 287b6cba4eeSStefan Bader char *dst; 288b6cba4eeSStefan Bader struct bio_vec *bv; 289b6cba4eeSStefan Bader struct bio *bio; 290b6cba4eeSStefan Bader 291b6cba4eeSStefan Bader DBF_EVENT(6, "xBREDid:"); 292b6cba4eeSStefan Bader start_block = req->sector >> TAPEBLOCK_HSEC_S2B; 293b6cba4eeSStefan Bader DBF_EVENT(6, "start_block = %i\n", start_block); 294b6cba4eeSStefan Bader 295b6cba4eeSStefan Bader rq_for_each_bio(bio, req) { 296b6cba4eeSStefan Bader bio_for_each_segment(bv, bio, i) { 297b6cba4eeSStefan Bader count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9); 298b6cba4eeSStefan Bader } 299b6cba4eeSStefan Bader } 300b6cba4eeSStefan Bader request = tape_alloc_request(2 + count + 1, 4); 301b6cba4eeSStefan Bader if (IS_ERR(request)) 302b6cba4eeSStefan Bader return request; 303b6cba4eeSStefan Bader request->op = TO_BLOCK; 304b6cba4eeSStefan Bader *(__u32 *) request->cpdata = start_block; 305b6cba4eeSStefan Bader ccw = request->cpaddr; 306b6cba4eeSStefan Bader ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte); 307b6cba4eeSStefan Bader 308b6cba4eeSStefan Bader /* 309b6cba4eeSStefan Bader * We always setup a nop after the mode set ccw. This slot is 310b6cba4eeSStefan Bader * used in tape_std_check_locate to insert a locate ccw if the 311b6cba4eeSStefan Bader * current tape position doesn't match the start block to be read. 312b6cba4eeSStefan Bader */ 313b6cba4eeSStefan Bader ccw = tape_ccw_cc(ccw, NOP, 0, NULL); 314b6cba4eeSStefan Bader 315b6cba4eeSStefan Bader rq_for_each_bio(bio, req) { 316b6cba4eeSStefan Bader bio_for_each_segment(bv, bio, i) { 317*2cc924b8SStefan Bader dst = page_address(bv->bv_page) + bv->bv_offset; 318b6cba4eeSStefan Bader for (off = 0; off < bv->bv_len; 319b6cba4eeSStefan Bader off += TAPEBLOCK_HSEC_SIZE) { 320b6cba4eeSStefan Bader ccw->flags = CCW_FLAG_CC; 321b6cba4eeSStefan Bader ccw->cmd_code = READ_FORWARD; 322b6cba4eeSStefan Bader ccw->count = TAPEBLOCK_HSEC_SIZE; 323b6cba4eeSStefan Bader set_normalized_cda(ccw, (void *) __pa(dst)); 324b6cba4eeSStefan Bader ccw++; 325b6cba4eeSStefan Bader dst += TAPEBLOCK_HSEC_SIZE; 326b6cba4eeSStefan Bader } 327b6cba4eeSStefan Bader if (off > bv->bv_len) 328b6cba4eeSStefan Bader BUG(); 329b6cba4eeSStefan Bader } 330b6cba4eeSStefan Bader } 331b6cba4eeSStefan Bader ccw = tape_ccw_end(ccw, NOP, 0, NULL); 332b6cba4eeSStefan Bader DBF_EVENT(6, "xBREDccwg\n"); 333b6cba4eeSStefan Bader return request; 334b6cba4eeSStefan Bader } 335b6cba4eeSStefan Bader 336b6cba4eeSStefan Bader static void 337b6cba4eeSStefan Bader tape_3590_free_bread(struct tape_request *request) 338b6cba4eeSStefan Bader { 339b6cba4eeSStefan Bader struct ccw1 *ccw; 340b6cba4eeSStefan Bader 341b6cba4eeSStefan Bader /* Last ccw is a nop and doesn't need clear_normalized_cda */ 342b6cba4eeSStefan Bader for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++) 343b6cba4eeSStefan Bader if (ccw->cmd_code == READ_FORWARD) 344b6cba4eeSStefan Bader clear_normalized_cda(ccw); 345b6cba4eeSStefan Bader tape_free_request(request); 346b6cba4eeSStefan Bader } 347b6cba4eeSStefan Bader 348b6cba4eeSStefan Bader /* 349b6cba4eeSStefan Bader * check_locate is called just before the tape request is passed to 350b6cba4eeSStefan Bader * the common io layer for execution. It has to check the current 351b6cba4eeSStefan Bader * tape position and insert a locate ccw if it doesn't match the 352b6cba4eeSStefan Bader * start block for the request. 353b6cba4eeSStefan Bader */ 354b6cba4eeSStefan Bader static void 355b6cba4eeSStefan Bader tape_3590_check_locate(struct tape_device *device, struct tape_request *request) 356b6cba4eeSStefan Bader { 357b6cba4eeSStefan Bader __u32 *start_block; 358b6cba4eeSStefan Bader 359b6cba4eeSStefan Bader start_block = (__u32 *) request->cpdata; 360b6cba4eeSStefan Bader if (*start_block != device->blk_data.block_position) { 361b6cba4eeSStefan Bader /* Add the start offset of the file to get the real block. */ 362b6cba4eeSStefan Bader *start_block += device->bof; 363b6cba4eeSStefan Bader tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); 364b6cba4eeSStefan Bader } 365b6cba4eeSStefan Bader } 366b6cba4eeSStefan Bader #endif 367b6cba4eeSStefan Bader 368b6cba4eeSStefan Bader /* 369b6cba4eeSStefan Bader * The done handler is called at device/channel end and wakes up the sleeping 370b6cba4eeSStefan Bader * process 371b6cba4eeSStefan Bader */ 372b6cba4eeSStefan Bader static int 373b6cba4eeSStefan Bader tape_3590_done(struct tape_device *device, struct tape_request *request) 374b6cba4eeSStefan Bader { 375b6cba4eeSStefan Bader struct tape_3590_med_sense *sense; 376b6cba4eeSStefan Bader 377b6cba4eeSStefan Bader DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]); 378b6cba4eeSStefan Bader 379b6cba4eeSStefan Bader switch (request->op) { 380b6cba4eeSStefan Bader case TO_BSB: 381b6cba4eeSStefan Bader case TO_BSF: 382b6cba4eeSStefan Bader case TO_DSE: 383b6cba4eeSStefan Bader case TO_FSB: 384b6cba4eeSStefan Bader case TO_FSF: 385b6cba4eeSStefan Bader case TO_LBL: 386b6cba4eeSStefan Bader case TO_RFO: 387b6cba4eeSStefan Bader case TO_RBA: 388b6cba4eeSStefan Bader case TO_REW: 389b6cba4eeSStefan Bader case TO_WRI: 390b6cba4eeSStefan Bader case TO_WTM: 391b6cba4eeSStefan Bader case TO_BLOCK: 392b6cba4eeSStefan Bader case TO_LOAD: 393b6cba4eeSStefan Bader tape_med_state_set(device, MS_LOADED); 394b6cba4eeSStefan Bader break; 395b6cba4eeSStefan Bader case TO_RUN: 396b6cba4eeSStefan Bader tape_med_state_set(device, MS_UNLOADED); 397b6cba4eeSStefan Bader break; 398b6cba4eeSStefan Bader case TO_MSEN: 399b6cba4eeSStefan Bader sense = (struct tape_3590_med_sense *) request->cpdata; 400b6cba4eeSStefan Bader if (sense->masst == MSENSE_UNASSOCIATED) 401b6cba4eeSStefan Bader tape_med_state_set(device, MS_UNLOADED); 402b6cba4eeSStefan Bader if (sense->masst == MSENSE_ASSOCIATED_MOUNT) 403b6cba4eeSStefan Bader tape_med_state_set(device, MS_LOADED); 404b6cba4eeSStefan Bader break; 405b6cba4eeSStefan Bader case TO_RBI: /* RBI seems to succeed even without medium loaded. */ 406b6cba4eeSStefan Bader case TO_NOP: /* Same to NOP. */ 407b6cba4eeSStefan Bader case TO_READ_CONFIG: 408b6cba4eeSStefan Bader case TO_READ_ATTMSG: 409b6cba4eeSStefan Bader case TO_DIS: 410b6cba4eeSStefan Bader case TO_ASSIGN: 411b6cba4eeSStefan Bader case TO_UNASSIGN: 412b6cba4eeSStefan Bader break; 413b6cba4eeSStefan Bader case TO_SIZE: 414b6cba4eeSStefan Bader break; 415b6cba4eeSStefan Bader } 416b6cba4eeSStefan Bader return TAPE_IO_SUCCESS; 417b6cba4eeSStefan Bader } 418b6cba4eeSStefan Bader 419b6cba4eeSStefan Bader /* 420b6cba4eeSStefan Bader * This fuction is called, when error recovery was successfull 421b6cba4eeSStefan Bader */ 422b6cba4eeSStefan Bader static inline int 423b6cba4eeSStefan Bader tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request) 424b6cba4eeSStefan Bader { 425b6cba4eeSStefan Bader DBF_EVENT(3, "Error Recovery successfull for %s\n", 426b6cba4eeSStefan Bader tape_op_verbose[request->op]); 427b6cba4eeSStefan Bader return tape_3590_done(device, request); 428b6cba4eeSStefan Bader } 429b6cba4eeSStefan Bader 430b6cba4eeSStefan Bader /* 431b6cba4eeSStefan Bader * This fuction is called, when error recovery was not successfull 432b6cba4eeSStefan Bader */ 433b6cba4eeSStefan Bader static inline int 434b6cba4eeSStefan Bader tape_3590_erp_failed(struct tape_device *device, struct tape_request *request, 435b6cba4eeSStefan Bader struct irb *irb, int rc) 436b6cba4eeSStefan Bader { 437b6cba4eeSStefan Bader DBF_EVENT(3, "Error Recovery failed for %s\n", 438b6cba4eeSStefan Bader tape_op_verbose[request->op]); 439b6cba4eeSStefan Bader tape_dump_sense_dbf(device, request, irb); 440b6cba4eeSStefan Bader return rc; 441b6cba4eeSStefan Bader } 442b6cba4eeSStefan Bader 443b6cba4eeSStefan Bader /* 444b6cba4eeSStefan Bader * Error Recovery do retry 445b6cba4eeSStefan Bader */ 446b6cba4eeSStefan Bader static inline int 447b6cba4eeSStefan Bader tape_3590_erp_retry(struct tape_device *device, struct tape_request *request, 448b6cba4eeSStefan Bader struct irb *irb) 449b6cba4eeSStefan Bader { 450b6cba4eeSStefan Bader DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]); 451b6cba4eeSStefan Bader tape_dump_sense_dbf(device, request, irb); 452b6cba4eeSStefan Bader return TAPE_IO_RETRY; 453b6cba4eeSStefan Bader } 454b6cba4eeSStefan Bader 455b6cba4eeSStefan Bader /* 456b6cba4eeSStefan Bader * Handle unsolicited interrupts 457b6cba4eeSStefan Bader */ 458b6cba4eeSStefan Bader static int 459b6cba4eeSStefan Bader tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb) 460b6cba4eeSStefan Bader { 461b6cba4eeSStefan Bader if (irb->scsw.dstat == DEV_STAT_CHN_END) 462b6cba4eeSStefan Bader /* Probably result of halt ssch */ 463b6cba4eeSStefan Bader return TAPE_IO_PENDING; 464b6cba4eeSStefan Bader else if (irb->scsw.dstat == 0x85) 465b6cba4eeSStefan Bader /* Device Ready -> check medium state */ 466b6cba4eeSStefan Bader tape_3590_schedule_work(device, TO_MSEN); 467b6cba4eeSStefan Bader else if (irb->scsw.dstat & DEV_STAT_ATTENTION) 468b6cba4eeSStefan Bader tape_3590_schedule_work(device, TO_READ_ATTMSG); 469b6cba4eeSStefan Bader else { 470b6cba4eeSStefan Bader DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id); 471b6cba4eeSStefan Bader PRINT_WARN("Unsolicited IRQ (Device End) caught.\n"); 472b6cba4eeSStefan Bader tape_dump_sense(device, NULL, irb); 473b6cba4eeSStefan Bader } 474b6cba4eeSStefan Bader return TAPE_IO_SUCCESS; 475b6cba4eeSStefan Bader } 476b6cba4eeSStefan Bader 477b6cba4eeSStefan Bader /* 478b6cba4eeSStefan Bader * Basic Recovery routine 479b6cba4eeSStefan Bader */ 480b6cba4eeSStefan Bader static int 481b6cba4eeSStefan Bader tape_3590_erp_basic(struct tape_device *device, struct tape_request *request, 482b6cba4eeSStefan Bader struct irb *irb, int rc) 483b6cba4eeSStefan Bader { 484b6cba4eeSStefan Bader struct tape_3590_sense *sense; 485b6cba4eeSStefan Bader 486b6cba4eeSStefan Bader sense = (struct tape_3590_sense *) irb->ecw; 487b6cba4eeSStefan Bader 488b6cba4eeSStefan Bader switch (sense->bra) { 489b6cba4eeSStefan Bader case SENSE_BRA_PER: 490b6cba4eeSStefan Bader return tape_3590_erp_failed(device, request, irb, rc); 491b6cba4eeSStefan Bader case SENSE_BRA_CONT: 492b6cba4eeSStefan Bader return tape_3590_erp_succeded(device, request); 493b6cba4eeSStefan Bader case SENSE_BRA_RE: 494b6cba4eeSStefan Bader return tape_3590_erp_retry(device, request, irb); 495b6cba4eeSStefan Bader case SENSE_BRA_DRE: 496b6cba4eeSStefan Bader return tape_3590_erp_failed(device, request, irb, rc); 497b6cba4eeSStefan Bader default: 498b6cba4eeSStefan Bader PRINT_ERR("Unknown BRA %x - This should not happen!\n", 499b6cba4eeSStefan Bader sense->bra); 500b6cba4eeSStefan Bader BUG(); 501b6cba4eeSStefan Bader return TAPE_IO_STOP; 502b6cba4eeSStefan Bader } 503b6cba4eeSStefan Bader } 504b6cba4eeSStefan Bader 505b6cba4eeSStefan Bader /* 506b6cba4eeSStefan Bader * RDL: Read Device (buffered) log 507b6cba4eeSStefan Bader */ 508b6cba4eeSStefan Bader static int 509b6cba4eeSStefan Bader tape_3590_erp_read_buf_log(struct tape_device *device, 510b6cba4eeSStefan Bader struct tape_request *request, struct irb *irb) 511b6cba4eeSStefan Bader { 512b6cba4eeSStefan Bader /* 513b6cba4eeSStefan Bader * We just do the basic error recovery at the moment (retry). 514b6cba4eeSStefan Bader * Perhaps in the future, we read the log and dump it somewhere... 515b6cba4eeSStefan Bader */ 516b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EIO); 517b6cba4eeSStefan Bader } 518b6cba4eeSStefan Bader 519b6cba4eeSStefan Bader /* 520b6cba4eeSStefan Bader * SWAP: Swap Devices 521b6cba4eeSStefan Bader */ 522b6cba4eeSStefan Bader static int 523b6cba4eeSStefan Bader tape_3590_erp_swap(struct tape_device *device, struct tape_request *request, 524b6cba4eeSStefan Bader struct irb *irb) 525b6cba4eeSStefan Bader { 526b6cba4eeSStefan Bader /* 527b6cba4eeSStefan Bader * This error recovery should swap the tapes 528b6cba4eeSStefan Bader * if the original has a problem. The operation 529b6cba4eeSStefan Bader * should proceed with the new tape... this 530b6cba4eeSStefan Bader * should probably be done in user space! 531b6cba4eeSStefan Bader */ 532b6cba4eeSStefan Bader PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id); 533b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EIO); 534b6cba4eeSStefan Bader } 535b6cba4eeSStefan Bader 536b6cba4eeSStefan Bader /* 537b6cba4eeSStefan Bader * LBY: Long Busy 538b6cba4eeSStefan Bader */ 539b6cba4eeSStefan Bader static int 540b6cba4eeSStefan Bader tape_3590_erp_long_busy(struct tape_device *device, 541b6cba4eeSStefan Bader struct tape_request *request, struct irb *irb) 542b6cba4eeSStefan Bader { 543b6cba4eeSStefan Bader /* FIXME: how about WAITING for a minute ? */ 544b6cba4eeSStefan Bader PRINT_WARN("(%s): Device is busy! Please wait a minute!\n", 545b6cba4eeSStefan Bader device->cdev->dev.bus_id); 546b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EBUSY); 547b6cba4eeSStefan Bader } 548b6cba4eeSStefan Bader 549b6cba4eeSStefan Bader /* 550b6cba4eeSStefan Bader * SPI: Special Intercept 551b6cba4eeSStefan Bader */ 552b6cba4eeSStefan Bader static int 553b6cba4eeSStefan Bader tape_3590_erp_special_interrupt(struct tape_device *device, 554b6cba4eeSStefan Bader struct tape_request *request, struct irb *irb) 555b6cba4eeSStefan Bader { 556b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EIO); 557b6cba4eeSStefan Bader } 558b6cba4eeSStefan Bader 559b6cba4eeSStefan Bader /* 560b6cba4eeSStefan Bader * RDA: Read Alternate 561b6cba4eeSStefan Bader */ 562b6cba4eeSStefan Bader static int 563b6cba4eeSStefan Bader tape_3590_erp_read_alternate(struct tape_device *device, 564b6cba4eeSStefan Bader struct tape_request *request, struct irb *irb) 565b6cba4eeSStefan Bader { 566b6cba4eeSStefan Bader struct tape_3590_disc_data *data; 567b6cba4eeSStefan Bader 568b6cba4eeSStefan Bader /* 569b6cba4eeSStefan Bader * The issued Read Backward or Read Previous command is not 570b6cba4eeSStefan Bader * supported by the device 571b6cba4eeSStefan Bader * The recovery action should be to issue another command: 572b6cba4eeSStefan Bader * Read Revious: if Read Backward is not supported 573b6cba4eeSStefan Bader * Read Backward: if Read Previous is not supported 574b6cba4eeSStefan Bader */ 575b6cba4eeSStefan Bader data = device->discdata; 576b6cba4eeSStefan Bader if (data->read_back_op == READ_PREVIOUS) { 577b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n", 578b6cba4eeSStefan Bader device->cdev_id); 579b6cba4eeSStefan Bader data->read_back_op = READ_BACKWARD; 580b6cba4eeSStefan Bader } else { 581b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n", 582b6cba4eeSStefan Bader device->cdev_id); 583b6cba4eeSStefan Bader data->read_back_op = READ_PREVIOUS; 584b6cba4eeSStefan Bader } 585b6cba4eeSStefan Bader tape_3590_read_opposite(device, request); 586b6cba4eeSStefan Bader return tape_3590_erp_retry(device, request, irb); 587b6cba4eeSStefan Bader } 588b6cba4eeSStefan Bader 589b6cba4eeSStefan Bader /* 590b6cba4eeSStefan Bader * Error Recovery read opposite 591b6cba4eeSStefan Bader */ 592b6cba4eeSStefan Bader static int 593b6cba4eeSStefan Bader tape_3590_erp_read_opposite(struct tape_device *device, 594b6cba4eeSStefan Bader struct tape_request *request, struct irb *irb) 595b6cba4eeSStefan Bader { 596b6cba4eeSStefan Bader switch (request->op) { 597b6cba4eeSStefan Bader case TO_RFO: 598b6cba4eeSStefan Bader /* 599b6cba4eeSStefan Bader * We did read forward, but the data could not be read. 600b6cba4eeSStefan Bader * We will read backward and then skip forward again. 601b6cba4eeSStefan Bader */ 602b6cba4eeSStefan Bader tape_3590_read_opposite(device, request); 603b6cba4eeSStefan Bader return tape_3590_erp_retry(device, request, irb); 604b6cba4eeSStefan Bader case TO_RBA: 605b6cba4eeSStefan Bader /* We tried to read forward and backward, but hat no success */ 606b6cba4eeSStefan Bader return tape_3590_erp_failed(device, request, irb, -EIO); 607b6cba4eeSStefan Bader break; 608b6cba4eeSStefan Bader default: 609b6cba4eeSStefan Bader PRINT_WARN("read_opposite_recovery_called_with_op: %s\n", 610b6cba4eeSStefan Bader tape_op_verbose[request->op]); 611b6cba4eeSStefan Bader return tape_3590_erp_failed(device, request, irb, -EIO); 612b6cba4eeSStefan Bader } 613b6cba4eeSStefan Bader } 614b6cba4eeSStefan Bader 615b6cba4eeSStefan Bader /* 616b6cba4eeSStefan Bader * Print an MIM (Media Information Message) (message code f0) 617b6cba4eeSStefan Bader */ 618b6cba4eeSStefan Bader static void 619b6cba4eeSStefan Bader tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb) 620b6cba4eeSStefan Bader { 621b6cba4eeSStefan Bader struct tape_3590_sense *sense; 622b6cba4eeSStefan Bader 623b6cba4eeSStefan Bader sense = (struct tape_3590_sense *) irb->ecw; 624b6cba4eeSStefan Bader /* Exception Message */ 625b6cba4eeSStefan Bader switch (sense->fmt.f70.emc) { 626b6cba4eeSStefan Bader case 0x02: 627b6cba4eeSStefan Bader PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id); 628b6cba4eeSStefan Bader break; 629b6cba4eeSStefan Bader case 0x03: 630b6cba4eeSStefan Bader PRINT_WARN("(%s): Data degraded in partion %i\n", 631b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f70.mp); 632b6cba4eeSStefan Bader break; 633b6cba4eeSStefan Bader case 0x04: 634b6cba4eeSStefan Bader PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id); 635b6cba4eeSStefan Bader break; 636b6cba4eeSStefan Bader case 0x05: 637b6cba4eeSStefan Bader PRINT_WARN("(%s): Medium degraded in partition %i\n", 638b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f70.mp); 639b6cba4eeSStefan Bader break; 640b6cba4eeSStefan Bader case 0x06: 641b6cba4eeSStefan Bader PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id); 642b6cba4eeSStefan Bader break; 643b6cba4eeSStefan Bader case 0x07: 644b6cba4eeSStefan Bader PRINT_WARN("(%s): Medium Exception 0x%02x\n", 645b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f70.md); 646b6cba4eeSStefan Bader break; 647b6cba4eeSStefan Bader default: 648b6cba4eeSStefan Bader PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n", 649b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f70.emc); 650b6cba4eeSStefan Bader break; 651b6cba4eeSStefan Bader } 652b6cba4eeSStefan Bader /* Service Message */ 653b6cba4eeSStefan Bader switch (sense->fmt.f70.smc) { 654b6cba4eeSStefan Bader case 0x02: 655b6cba4eeSStefan Bader PRINT_WARN("(%s): Reference Media maintenance procedure %i\n", 656b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f70.md); 657b6cba4eeSStefan Bader break; 658b6cba4eeSStefan Bader default: 659b6cba4eeSStefan Bader PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n", 660b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f70.smc); 661b6cba4eeSStefan Bader break; 662b6cba4eeSStefan Bader } 663b6cba4eeSStefan Bader } 664b6cba4eeSStefan Bader 665b6cba4eeSStefan Bader /* 666b6cba4eeSStefan Bader * Print an I/O Subsystem Service Information Message (message code f1) 667b6cba4eeSStefan Bader */ 668b6cba4eeSStefan Bader static void 669b6cba4eeSStefan Bader tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb) 670b6cba4eeSStefan Bader { 671b6cba4eeSStefan Bader struct tape_3590_sense *sense; 672b6cba4eeSStefan Bader 673b6cba4eeSStefan Bader sense = (struct tape_3590_sense *) irb->ecw; 674b6cba4eeSStefan Bader /* Exception Message */ 675b6cba4eeSStefan Bader switch (sense->fmt.f71.emc) { 676b6cba4eeSStefan Bader case 0x01: 677b6cba4eeSStefan Bader PRINT_WARN("(%s): Effect of failure is unknown\n", 678b6cba4eeSStefan Bader device->cdev->dev.bus_id); 679b6cba4eeSStefan Bader break; 680b6cba4eeSStefan Bader case 0x02: 681b6cba4eeSStefan Bader PRINT_WARN("(%s): CU Exception - no performance impact\n", 682b6cba4eeSStefan Bader device->cdev->dev.bus_id); 683b6cba4eeSStefan Bader break; 684b6cba4eeSStefan Bader case 0x03: 685b6cba4eeSStefan Bader PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n", 686b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 687b6cba4eeSStefan Bader break; 688b6cba4eeSStefan Bader case 0x04: 689b6cba4eeSStefan Bader PRINT_WARN("(%s): CU Exception on device path 0x%02x\n", 690b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 691b6cba4eeSStefan Bader break; 692b6cba4eeSStefan Bader case 0x05: 693b6cba4eeSStefan Bader PRINT_WARN("(%s): CU Exception on library path 0x%02x\n", 694b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 695b6cba4eeSStefan Bader break; 696b6cba4eeSStefan Bader case 0x06: 697b6cba4eeSStefan Bader PRINT_WARN("(%s): CU Exception on node 0x%02x\n", 698b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 699b6cba4eeSStefan Bader break; 700b6cba4eeSStefan Bader case 0x07: 701b6cba4eeSStefan Bader PRINT_WARN("(%s): CU Exception on partition 0x%02x\n", 702b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 703b6cba4eeSStefan Bader break; 704b6cba4eeSStefan Bader default: 705b6cba4eeSStefan Bader PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n", 706b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.emc); 707b6cba4eeSStefan Bader } 708b6cba4eeSStefan Bader /* Service Message */ 709b6cba4eeSStefan Bader switch (sense->fmt.f71.smc) { 710b6cba4eeSStefan Bader case 0x01: 711b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair impact is unknown\n", 712b6cba4eeSStefan Bader device->cdev->dev.bus_id); 713b6cba4eeSStefan Bader break; 714b6cba4eeSStefan Bader case 0x02: 715b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will not impact cu performance\n", 716b6cba4eeSStefan Bader device->cdev->dev.bus_id); 717b6cba4eeSStefan Bader break; 718b6cba4eeSStefan Bader case 0x03: 719b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 720b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable node " 721b6cba4eeSStefan Bader "0x%x on CU\n", 722b6cba4eeSStefan Bader device->cdev->dev.bus_id, 723b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 724b6cba4eeSStefan Bader else 725b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable nodes " 726b6cba4eeSStefan Bader "(0x%x-0x%x) on CU\n", 727b6cba4eeSStefan Bader device->cdev->dev.bus_id, 728b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 729b6cba4eeSStefan Bader break; 730b6cba4eeSStefan Bader case 0x04: 731b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 732b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable cannel path " 733b6cba4eeSStefan Bader "0x%x on CU\n", 734b6cba4eeSStefan Bader device->cdev->dev.bus_id, 735b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 736b6cba4eeSStefan Bader else 737b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable cannel paths " 738b6cba4eeSStefan Bader "(0x%x-0x%x) on CU\n", 739b6cba4eeSStefan Bader device->cdev->dev.bus_id, 740b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 741b6cba4eeSStefan Bader break; 742b6cba4eeSStefan Bader case 0x05: 743b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 744b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable device path " 745b6cba4eeSStefan Bader "0x%x on CU\n", 746b6cba4eeSStefan Bader device->cdev->dev.bus_id, 747b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 748b6cba4eeSStefan Bader else 749b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable device paths " 750b6cba4eeSStefan Bader "(0x%x-0x%x) on CU\n", 751b6cba4eeSStefan Bader device->cdev->dev.bus_id, 752b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 753b6cba4eeSStefan Bader break; 754b6cba4eeSStefan Bader case 0x06: 755b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 756b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable library path " 757b6cba4eeSStefan Bader "0x%x on CU\n", 758b6cba4eeSStefan Bader device->cdev->dev.bus_id, 759b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 760b6cba4eeSStefan Bader else 761b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable library paths " 762b6cba4eeSStefan Bader "(0x%x-0x%x) on CU\n", 763b6cba4eeSStefan Bader device->cdev->dev.bus_id, 764b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 765b6cba4eeSStefan Bader break; 766b6cba4eeSStefan Bader case 0x07: 767b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable access to CU\n", 768b6cba4eeSStefan Bader device->cdev->dev.bus_id); 769b6cba4eeSStefan Bader break; 770b6cba4eeSStefan Bader default: 771b6cba4eeSStefan Bader PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n", 772b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.smc); 773b6cba4eeSStefan Bader } 774b6cba4eeSStefan Bader } 775b6cba4eeSStefan Bader 776b6cba4eeSStefan Bader /* 777b6cba4eeSStefan Bader * Print an Device Subsystem Service Information Message (message code f2) 778b6cba4eeSStefan Bader */ 779b6cba4eeSStefan Bader static void 780b6cba4eeSStefan Bader tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb) 781b6cba4eeSStefan Bader { 782b6cba4eeSStefan Bader struct tape_3590_sense *sense; 783b6cba4eeSStefan Bader 784b6cba4eeSStefan Bader sense = (struct tape_3590_sense *) irb->ecw; 785b6cba4eeSStefan Bader /* Exception Message */ 786b6cba4eeSStefan Bader switch (sense->fmt.f71.emc) { 787b6cba4eeSStefan Bader case 0x01: 788b6cba4eeSStefan Bader PRINT_WARN("(%s): Effect of failure is unknown\n", 789b6cba4eeSStefan Bader device->cdev->dev.bus_id); 790b6cba4eeSStefan Bader break; 791b6cba4eeSStefan Bader case 0x02: 792b6cba4eeSStefan Bader PRINT_WARN("(%s): DV Exception - no performance impact\n", 793b6cba4eeSStefan Bader device->cdev->dev.bus_id); 794b6cba4eeSStefan Bader break; 795b6cba4eeSStefan Bader case 0x03: 796b6cba4eeSStefan Bader PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n", 797b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 798b6cba4eeSStefan Bader break; 799b6cba4eeSStefan Bader case 0x04: 800b6cba4eeSStefan Bader PRINT_WARN("(%s): DV Exception on loader 0x%02x\n", 801b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 802b6cba4eeSStefan Bader break; 803b6cba4eeSStefan Bader case 0x05: 804b6cba4eeSStefan Bader PRINT_WARN("(%s): DV Exception on message display 0x%02x\n", 805b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.md[0]); 806b6cba4eeSStefan Bader break; 807b6cba4eeSStefan Bader case 0x06: 808b6cba4eeSStefan Bader PRINT_WARN("(%s): DV Exception in tape path\n", 809b6cba4eeSStefan Bader device->cdev->dev.bus_id); 810b6cba4eeSStefan Bader break; 811b6cba4eeSStefan Bader case 0x07: 812b6cba4eeSStefan Bader PRINT_WARN("(%s): DV Exception in drive\n", 813b6cba4eeSStefan Bader device->cdev->dev.bus_id); 814b6cba4eeSStefan Bader break; 815b6cba4eeSStefan Bader default: 816b6cba4eeSStefan Bader PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n", 817b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.emc); 818b6cba4eeSStefan Bader } 819b6cba4eeSStefan Bader /* Service Message */ 820b6cba4eeSStefan Bader switch (sense->fmt.f71.smc) { 821b6cba4eeSStefan Bader case 0x01: 822b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair impact is unknown\n", 823b6cba4eeSStefan Bader device->cdev->dev.bus_id); 824b6cba4eeSStefan Bader break; 825b6cba4eeSStefan Bader case 0x02: 826b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will not impact device performance\n", 827b6cba4eeSStefan Bader device->cdev->dev.bus_id); 828b6cba4eeSStefan Bader break; 829b6cba4eeSStefan Bader case 0x03: 830b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 831b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable channel path " 832b6cba4eeSStefan Bader "0x%x on DV\n", 833b6cba4eeSStefan Bader device->cdev->dev.bus_id, 834b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 835b6cba4eeSStefan Bader else 836b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable channel path " 837b6cba4eeSStefan Bader "(0x%x-0x%x) on DV\n", 838b6cba4eeSStefan Bader device->cdev->dev.bus_id, 839b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 840b6cba4eeSStefan Bader break; 841b6cba4eeSStefan Bader case 0x04: 842b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 843b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable interface 0x%x " 844b6cba4eeSStefan Bader "on DV\n", 845b6cba4eeSStefan Bader device->cdev->dev.bus_id, 846b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 847b6cba4eeSStefan Bader else 848b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable interfaces " 849b6cba4eeSStefan Bader "(0x%x-0x%x) on DV\n", 850b6cba4eeSStefan Bader device->cdev->dev.bus_id, 851b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 852b6cba4eeSStefan Bader break; 853b6cba4eeSStefan Bader case 0x05: 854b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 855b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable loader 0x%x " 856b6cba4eeSStefan Bader "on DV\n", 857b6cba4eeSStefan Bader device->cdev->dev.bus_id, 858b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 859b6cba4eeSStefan Bader else 860b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable loader " 861b6cba4eeSStefan Bader "(0x%x-0x%x) on DV\n", 862b6cba4eeSStefan Bader device->cdev->dev.bus_id, 863b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 864b6cba4eeSStefan Bader break; 865b6cba4eeSStefan Bader case 0x07: 866b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable access to DV\n", 867b6cba4eeSStefan Bader device->cdev->dev.bus_id); 868b6cba4eeSStefan Bader break; 869b6cba4eeSStefan Bader case 0x08: 870b6cba4eeSStefan Bader if (sense->fmt.f71.mdf == 0) 871b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable message " 872b6cba4eeSStefan Bader "display 0x%x on DV\n", 873b6cba4eeSStefan Bader device->cdev->dev.bus_id, 874b6cba4eeSStefan Bader sense->fmt.f71.md[1]); 875b6cba4eeSStefan Bader else 876b6cba4eeSStefan Bader PRINT_WARN("(%s): Repair will disable message " 877b6cba4eeSStefan Bader "displays (0x%x-0x%x) on DV\n", 878b6cba4eeSStefan Bader device->cdev->dev.bus_id, 879b6cba4eeSStefan Bader sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 880b6cba4eeSStefan Bader break; 881b6cba4eeSStefan Bader case 0x09: 882b6cba4eeSStefan Bader PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id); 883b6cba4eeSStefan Bader break; 884b6cba4eeSStefan Bader default: 885b6cba4eeSStefan Bader PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n", 886b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.smc); 887b6cba4eeSStefan Bader } 888b6cba4eeSStefan Bader } 889b6cba4eeSStefan Bader 890b6cba4eeSStefan Bader /* 891b6cba4eeSStefan Bader * Print standard ERA Message 892b6cba4eeSStefan Bader */ 893b6cba4eeSStefan Bader static void 894b6cba4eeSStefan Bader tape_3590_print_era_msg(struct tape_device *device, struct irb *irb) 895b6cba4eeSStefan Bader { 896b6cba4eeSStefan Bader struct tape_3590_sense *sense; 897b6cba4eeSStefan Bader 898b6cba4eeSStefan Bader sense = (struct tape_3590_sense *) irb->ecw; 899b6cba4eeSStefan Bader if (sense->mc == 0) 900b6cba4eeSStefan Bader return; 901b6cba4eeSStefan Bader if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) { 902b6cba4eeSStefan Bader if (tape_3590_msg[sense->mc] != NULL) 903b6cba4eeSStefan Bader PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id, 904b6cba4eeSStefan Bader tape_3590_msg[sense->mc]); 905b6cba4eeSStefan Bader else { 906b6cba4eeSStefan Bader PRINT_WARN("(%s): Message Code 0x%x\n", 907b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->mc); 908b6cba4eeSStefan Bader } 909b6cba4eeSStefan Bader return; 910b6cba4eeSStefan Bader } 911b6cba4eeSStefan Bader if (sense->mc == 0xf0) { 912b6cba4eeSStefan Bader /* Standard Media Information Message */ 913b6cba4eeSStefan Bader PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, " 914b6cba4eeSStefan Bader "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id, 915b6cba4eeSStefan Bader sense->fmt.f70.sev, sense->mc, 916b6cba4eeSStefan Bader sense->fmt.f70.emc, sense->fmt.f70.smc, 917b6cba4eeSStefan Bader sense->fmt.f70.refcode, sense->fmt.f70.mid, 918b6cba4eeSStefan Bader sense->fmt.f70.fid); 919b6cba4eeSStefan Bader tape_3590_print_mim_msg_f0(device, irb); 920b6cba4eeSStefan Bader return; 921b6cba4eeSStefan Bader } 922b6cba4eeSStefan Bader if (sense->mc == 0xf1) { 923b6cba4eeSStefan Bader /* Standard I/O Subsystem Service Information Message */ 924b6cba4eeSStefan Bader PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, " 925b6cba4eeSStefan Bader "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n", 926b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.sev, 927b6cba4eeSStefan Bader device->cdev->id.dev_model, 928b6cba4eeSStefan Bader sense->mc, sense->fmt.f71.emc, 929b6cba4eeSStefan Bader sense->fmt.f71.smc, sense->fmt.f71.refcode1, 930b6cba4eeSStefan Bader sense->fmt.f71.refcode2, sense->fmt.f71.refcode3); 931b6cba4eeSStefan Bader tape_3590_print_io_sim_msg_f1(device, irb); 932b6cba4eeSStefan Bader return; 933b6cba4eeSStefan Bader } 934b6cba4eeSStefan Bader if (sense->mc == 0xf2) { 935b6cba4eeSStefan Bader /* Standard Device Service Information Message */ 936b6cba4eeSStefan Bader PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, " 937b6cba4eeSStefan Bader "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n", 938b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->fmt.f71.sev, 939b6cba4eeSStefan Bader device->cdev->id.dev_model, 940b6cba4eeSStefan Bader sense->mc, sense->fmt.f71.emc, 941b6cba4eeSStefan Bader sense->fmt.f71.smc, sense->fmt.f71.refcode1, 942b6cba4eeSStefan Bader sense->fmt.f71.refcode2, sense->fmt.f71.refcode3); 943b6cba4eeSStefan Bader tape_3590_print_dev_sim_msg_f2(device, irb); 944b6cba4eeSStefan Bader return; 945b6cba4eeSStefan Bader } 946b6cba4eeSStefan Bader if (sense->mc == 0xf3) { 947b6cba4eeSStefan Bader /* Standard Library Service Information Message */ 948b6cba4eeSStefan Bader return; 949b6cba4eeSStefan Bader } 950b6cba4eeSStefan Bader PRINT_WARN("(%s): Device Message(%x)\n", 951b6cba4eeSStefan Bader device->cdev->dev.bus_id, sense->mc); 952b6cba4eeSStefan Bader } 953b6cba4eeSStefan Bader 954b6cba4eeSStefan Bader /* 955b6cba4eeSStefan Bader * 3590 error Recovery routine: 956b6cba4eeSStefan Bader * If possible, it tries to recover from the error. If this is not possible, 957b6cba4eeSStefan Bader * inform the user about the problem. 958b6cba4eeSStefan Bader */ 959b6cba4eeSStefan Bader static int 960b6cba4eeSStefan Bader tape_3590_unit_check(struct tape_device *device, struct tape_request *request, 961b6cba4eeSStefan Bader struct irb *irb) 962b6cba4eeSStefan Bader { 963b6cba4eeSStefan Bader struct tape_3590_sense *sense; 964b6cba4eeSStefan Bader int rc; 965b6cba4eeSStefan Bader 966b6cba4eeSStefan Bader #ifdef CONFIG_S390_TAPE_BLOCK 967b6cba4eeSStefan Bader if (request->op == TO_BLOCK) { 968b6cba4eeSStefan Bader /* 969b6cba4eeSStefan Bader * Recovery for block device requests. Set the block_position 970b6cba4eeSStefan Bader * to something invalid and retry. 971b6cba4eeSStefan Bader */ 972b6cba4eeSStefan Bader device->blk_data.block_position = -1; 973b6cba4eeSStefan Bader if (request->retries-- <= 0) 974b6cba4eeSStefan Bader return tape_3590_erp_failed(device, request, irb, -EIO); 975b6cba4eeSStefan Bader else 976b6cba4eeSStefan Bader return tape_3590_erp_retry(device, request, irb); 977b6cba4eeSStefan Bader } 978b6cba4eeSStefan Bader #endif 979b6cba4eeSStefan Bader 980b6cba4eeSStefan Bader sense = (struct tape_3590_sense *) irb->ecw; 981b6cba4eeSStefan Bader 982b6cba4eeSStefan Bader /* 983b6cba4eeSStefan Bader * First check all RC-QRCs where we want to do something special 984b6cba4eeSStefan Bader * - "break": basic error recovery is done 985b6cba4eeSStefan Bader * - "goto out:": just print error message if available 986b6cba4eeSStefan Bader */ 987b6cba4eeSStefan Bader rc = -EIO; 988b6cba4eeSStefan Bader switch (sense->rc_rqc) { 989b6cba4eeSStefan Bader 990b6cba4eeSStefan Bader case 0x1110: 991b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 992b6cba4eeSStefan Bader return tape_3590_erp_read_buf_log(device, request, irb); 993b6cba4eeSStefan Bader 994b6cba4eeSStefan Bader case 0x2011: 995b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 996b6cba4eeSStefan Bader return tape_3590_erp_read_alternate(device, request, irb); 997b6cba4eeSStefan Bader 998b6cba4eeSStefan Bader case 0x2230: 999b6cba4eeSStefan Bader case 0x2231: 1000b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 1001b6cba4eeSStefan Bader return tape_3590_erp_special_interrupt(device, request, irb); 1002b6cba4eeSStefan Bader 1003b6cba4eeSStefan Bader case 0x3010: 1004b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n", 1005b6cba4eeSStefan Bader device->cdev_id); 1006b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -ENOSPC); 1007b6cba4eeSStefan Bader case 0x3012: 1008b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): Forward at End of Partition\n", 1009b6cba4eeSStefan Bader device->cdev_id); 1010b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -ENOSPC); 1011b6cba4eeSStefan Bader case 0x3020: 1012b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id); 1013b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -ENOSPC); 1014b6cba4eeSStefan Bader 1015b6cba4eeSStefan Bader case 0x3122: 1016b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): Rewind Unload initiated\n", 1017b6cba4eeSStefan Bader device->cdev_id); 1018b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EIO); 1019b6cba4eeSStefan Bader case 0x3123: 1020b6cba4eeSStefan Bader DBF_EVENT(2, "(%08x): Rewind Unload complete\n", 1021b6cba4eeSStefan Bader device->cdev_id); 1022b6cba4eeSStefan Bader tape_med_state_set(device, MS_UNLOADED); 1023b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, 0); 1024b6cba4eeSStefan Bader 1025b6cba4eeSStefan Bader case 0x4010: 1026b6cba4eeSStefan Bader /* 1027b6cba4eeSStefan Bader * print additional msg since default msg 1028b6cba4eeSStefan Bader * "device intervention" is not very meaningfull 1029b6cba4eeSStefan Bader */ 1030b6cba4eeSStefan Bader PRINT_WARN("(%s): Tape operation when medium not loaded\n", 1031b6cba4eeSStefan Bader device->cdev->dev.bus_id); 1032b6cba4eeSStefan Bader tape_med_state_set(device, MS_UNLOADED); 1033b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM); 1034b6cba4eeSStefan Bader case 0x4012: /* Device Long Busy */ 1035b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 1036b6cba4eeSStefan Bader return tape_3590_erp_long_busy(device, request, irb); 1037b6cba4eeSStefan Bader 1038b6cba4eeSStefan Bader case 0x5010: 1039b6cba4eeSStefan Bader if (sense->rac == 0xd0) { 1040b6cba4eeSStefan Bader /* Swap */ 1041b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 1042b6cba4eeSStefan Bader return tape_3590_erp_swap(device, request, irb); 1043b6cba4eeSStefan Bader } 1044b6cba4eeSStefan Bader if (sense->rac == 0x26) { 1045b6cba4eeSStefan Bader /* Read Opposite */ 1046b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 1047b6cba4eeSStefan Bader return tape_3590_erp_read_opposite(device, request, 1048b6cba4eeSStefan Bader irb); 1049b6cba4eeSStefan Bader } 1050b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EIO); 1051b6cba4eeSStefan Bader case 0x5020: 1052b6cba4eeSStefan Bader case 0x5021: 1053b6cba4eeSStefan Bader case 0x5022: 1054b6cba4eeSStefan Bader case 0x5040: 1055b6cba4eeSStefan Bader case 0x5041: 1056b6cba4eeSStefan Bader case 0x5042: 1057b6cba4eeSStefan Bader tape_3590_print_era_msg(device, irb); 1058b6cba4eeSStefan Bader return tape_3590_erp_swap(device, request, irb); 1059b6cba4eeSStefan Bader 1060b6cba4eeSStefan Bader case 0x5110: 1061b6cba4eeSStefan Bader case 0x5111: 1062b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE); 1063b6cba4eeSStefan Bader 1064b6cba4eeSStefan Bader case 0x5120: 1065b6cba4eeSStefan Bader case 0x1120: 1066b6cba4eeSStefan Bader tape_med_state_set(device, MS_UNLOADED); 1067b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM); 1068b6cba4eeSStefan Bader 1069b6cba4eeSStefan Bader case 0x6020: 1070b6cba4eeSStefan Bader PRINT_WARN("(%s): Cartridge of wrong type ?\n", 1071b6cba4eeSStefan Bader device->cdev->dev.bus_id); 1072b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE); 1073b6cba4eeSStefan Bader 1074b6cba4eeSStefan Bader case 0x8011: 1075b6cba4eeSStefan Bader PRINT_WARN("(%s): Another host has reserved the tape device\n", 1076b6cba4eeSStefan Bader device->cdev->dev.bus_id); 1077b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EPERM); 1078b6cba4eeSStefan Bader case 0x8013: 1079b6cba4eeSStefan Bader PRINT_WARN("(%s): Another host has priviliged access to the " 1080b6cba4eeSStefan Bader "tape device\n", device->cdev->dev.bus_id); 1081b6cba4eeSStefan Bader PRINT_WARN("(%s): To solve the problem unload the current " 1082b6cba4eeSStefan Bader "cartridge!\n", device->cdev->dev.bus_id); 1083b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EPERM); 1084b6cba4eeSStefan Bader default: 1085b6cba4eeSStefan Bader return tape_3590_erp_basic(device, request, irb, -EIO); 1086b6cba4eeSStefan Bader } 1087b6cba4eeSStefan Bader } 1088b6cba4eeSStefan Bader 1089b6cba4eeSStefan Bader /* 1090b6cba4eeSStefan Bader * 3590 interrupt handler: 1091b6cba4eeSStefan Bader */ 1092b6cba4eeSStefan Bader static int 1093b6cba4eeSStefan Bader tape_3590_irq(struct tape_device *device, struct tape_request *request, 1094b6cba4eeSStefan Bader struct irb *irb) 1095b6cba4eeSStefan Bader { 1096b6cba4eeSStefan Bader if (request == NULL) 1097b6cba4eeSStefan Bader return tape_3590_unsolicited_irq(device, irb); 1098b6cba4eeSStefan Bader 1099b6cba4eeSStefan Bader if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) && 1100b6cba4eeSStefan Bader (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) { 1101b6cba4eeSStefan Bader /* Write at end of volume */ 1102b6cba4eeSStefan Bader DBF_EVENT(2, "End of volume\n"); 1103b6cba4eeSStefan Bader return tape_3590_erp_failed(device, request, irb, -ENOSPC); 1104b6cba4eeSStefan Bader } 1105b6cba4eeSStefan Bader 1106b6cba4eeSStefan Bader if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) 1107b6cba4eeSStefan Bader return tape_3590_unit_check(device, request, irb); 1108b6cba4eeSStefan Bader 1109b6cba4eeSStefan Bader if (irb->scsw.dstat & DEV_STAT_DEV_END) { 1110b6cba4eeSStefan Bader if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) { 1111b6cba4eeSStefan Bader if (request->op == TO_FSB || request->op == TO_BSB) 1112b6cba4eeSStefan Bader request->rescnt++; 1113b6cba4eeSStefan Bader else 1114b6cba4eeSStefan Bader DBF_EVENT(5, "Unit Exception!\n"); 1115b6cba4eeSStefan Bader } 1116b6cba4eeSStefan Bader 1117b6cba4eeSStefan Bader return tape_3590_done(device, request); 1118b6cba4eeSStefan Bader } 1119b6cba4eeSStefan Bader 1120b6cba4eeSStefan Bader if (irb->scsw.dstat & DEV_STAT_CHN_END) { 1121b6cba4eeSStefan Bader DBF_EVENT(2, "cannel end\n"); 1122b6cba4eeSStefan Bader return TAPE_IO_PENDING; 1123b6cba4eeSStefan Bader } 1124b6cba4eeSStefan Bader 1125b6cba4eeSStefan Bader if (irb->scsw.dstat & DEV_STAT_ATTENTION) { 1126b6cba4eeSStefan Bader DBF_EVENT(2, "Unit Attention when busy..\n"); 1127b6cba4eeSStefan Bader return TAPE_IO_PENDING; 1128b6cba4eeSStefan Bader } 1129b6cba4eeSStefan Bader 1130b6cba4eeSStefan Bader DBF_EVENT(6, "xunknownirq\n"); 1131b6cba4eeSStefan Bader PRINT_ERR("Unexpected interrupt.\n"); 1132b6cba4eeSStefan Bader PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]); 1133b6cba4eeSStefan Bader tape_dump_sense(device, request, irb); 1134b6cba4eeSStefan Bader return TAPE_IO_STOP; 1135b6cba4eeSStefan Bader } 1136b6cba4eeSStefan Bader 1137b6cba4eeSStefan Bader /* 1138b6cba4eeSStefan Bader * Setup device function 1139b6cba4eeSStefan Bader */ 1140b6cba4eeSStefan Bader static int 1141b6cba4eeSStefan Bader tape_3590_setup_device(struct tape_device *device) 1142b6cba4eeSStefan Bader { 1143b6cba4eeSStefan Bader int rc; 1144b6cba4eeSStefan Bader struct tape_3590_disc_data *data; 1145b6cba4eeSStefan Bader 1146b6cba4eeSStefan Bader DBF_EVENT(6, "3590 device setup\n"); 1147b6cba4eeSStefan Bader data = kmalloc(sizeof(struct tape_3590_disc_data), 1148b6cba4eeSStefan Bader GFP_KERNEL | GFP_DMA); 1149b6cba4eeSStefan Bader if (data == NULL) 1150b6cba4eeSStefan Bader return -ENOMEM; 1151b6cba4eeSStefan Bader data->read_back_op = READ_PREVIOUS; 1152b6cba4eeSStefan Bader device->discdata = data; 1153b6cba4eeSStefan Bader 1154b6cba4eeSStefan Bader if ((rc = tape_std_assign(device)) == 0) { 1155b6cba4eeSStefan Bader /* Try to find out if medium is loaded */ 1156b6cba4eeSStefan Bader if ((rc = tape_3590_sense_medium(device)) != 0) 1157b6cba4eeSStefan Bader DBF_LH(3, "3590 medium sense returned %d\n", rc); 1158b6cba4eeSStefan Bader } 1159b6cba4eeSStefan Bader 1160b6cba4eeSStefan Bader return rc; 1161b6cba4eeSStefan Bader } 1162b6cba4eeSStefan Bader 1163b6cba4eeSStefan Bader /* 1164b6cba4eeSStefan Bader * Cleanup device function 1165b6cba4eeSStefan Bader */ 1166b6cba4eeSStefan Bader static void 1167b6cba4eeSStefan Bader tape_3590_cleanup_device(struct tape_device *device) 1168b6cba4eeSStefan Bader { 1169*2cc924b8SStefan Bader flush_scheduled_work(); 1170b6cba4eeSStefan Bader tape_std_unassign(device); 1171b6cba4eeSStefan Bader 1172b6cba4eeSStefan Bader kfree(device->discdata); 1173b6cba4eeSStefan Bader device->discdata = NULL; 1174b6cba4eeSStefan Bader } 1175b6cba4eeSStefan Bader 1176b6cba4eeSStefan Bader /* 1177b6cba4eeSStefan Bader * List of 3590 magnetic tape commands. 1178b6cba4eeSStefan Bader */ 1179b6cba4eeSStefan Bader static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = { 1180b6cba4eeSStefan Bader [MTRESET] = tape_std_mtreset, 1181b6cba4eeSStefan Bader [MTFSF] = tape_std_mtfsf, 1182b6cba4eeSStefan Bader [MTBSF] = tape_std_mtbsf, 1183b6cba4eeSStefan Bader [MTFSR] = tape_std_mtfsr, 1184b6cba4eeSStefan Bader [MTBSR] = tape_std_mtbsr, 1185b6cba4eeSStefan Bader [MTWEOF] = tape_std_mtweof, 1186b6cba4eeSStefan Bader [MTREW] = tape_std_mtrew, 1187b6cba4eeSStefan Bader [MTOFFL] = tape_std_mtoffl, 1188b6cba4eeSStefan Bader [MTNOP] = tape_std_mtnop, 1189b6cba4eeSStefan Bader [MTRETEN] = tape_std_mtreten, 1190b6cba4eeSStefan Bader [MTBSFM] = tape_std_mtbsfm, 1191b6cba4eeSStefan Bader [MTFSFM] = tape_std_mtfsfm, 1192b6cba4eeSStefan Bader [MTEOM] = tape_std_mteom, 1193b6cba4eeSStefan Bader [MTERASE] = tape_std_mterase, 1194b6cba4eeSStefan Bader [MTRAS1] = NULL, 1195b6cba4eeSStefan Bader [MTRAS2] = NULL, 1196b6cba4eeSStefan Bader [MTRAS3] = NULL, 1197b6cba4eeSStefan Bader [MTSETBLK] = tape_std_mtsetblk, 1198b6cba4eeSStefan Bader [MTSETDENSITY] = NULL, 1199b6cba4eeSStefan Bader [MTSEEK] = tape_3590_mtseek, 1200b6cba4eeSStefan Bader [MTTELL] = tape_3590_mttell, 1201b6cba4eeSStefan Bader [MTSETDRVBUFFER] = NULL, 1202b6cba4eeSStefan Bader [MTFSS] = NULL, 1203b6cba4eeSStefan Bader [MTBSS] = NULL, 1204b6cba4eeSStefan Bader [MTWSM] = NULL, 1205b6cba4eeSStefan Bader [MTLOCK] = NULL, 1206b6cba4eeSStefan Bader [MTUNLOCK] = NULL, 1207b6cba4eeSStefan Bader [MTLOAD] = tape_std_mtload, 1208b6cba4eeSStefan Bader [MTUNLOAD] = tape_std_mtunload, 1209b6cba4eeSStefan Bader [MTCOMPRESSION] = tape_std_mtcompression, 1210b6cba4eeSStefan Bader [MTSETPART] = NULL, 1211b6cba4eeSStefan Bader [MTMKPART] = NULL 1212b6cba4eeSStefan Bader }; 1213b6cba4eeSStefan Bader 1214b6cba4eeSStefan Bader /* 1215b6cba4eeSStefan Bader * Tape discipline structure for 3590. 1216b6cba4eeSStefan Bader */ 1217b6cba4eeSStefan Bader static struct tape_discipline tape_discipline_3590 = { 1218b6cba4eeSStefan Bader .owner = THIS_MODULE, 1219b6cba4eeSStefan Bader .setup_device = tape_3590_setup_device, 1220b6cba4eeSStefan Bader .cleanup_device = tape_3590_cleanup_device, 1221b6cba4eeSStefan Bader .process_eov = tape_std_process_eov, 1222b6cba4eeSStefan Bader .irq = tape_3590_irq, 1223b6cba4eeSStefan Bader .read_block = tape_std_read_block, 1224b6cba4eeSStefan Bader .write_block = tape_std_write_block, 1225b6cba4eeSStefan Bader #ifdef CONFIG_S390_TAPE_BLOCK 1226b6cba4eeSStefan Bader .bread = tape_3590_bread, 1227b6cba4eeSStefan Bader .free_bread = tape_3590_free_bread, 1228b6cba4eeSStefan Bader .check_locate = tape_3590_check_locate, 1229b6cba4eeSStefan Bader #endif 1230b6cba4eeSStefan Bader .ioctl_fn = tape_3590_ioctl, 1231b6cba4eeSStefan Bader .mtop_array = tape_3590_mtop 1232b6cba4eeSStefan Bader }; 1233b6cba4eeSStefan Bader 1234b6cba4eeSStefan Bader static struct ccw_device_id tape_3590_ids[] = { 1235b6cba4eeSStefan Bader {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590}, 1236*2cc924b8SStefan Bader {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592}, 1237b6cba4eeSStefan Bader { /* end of list */ } 1238b6cba4eeSStefan Bader }; 1239b6cba4eeSStefan Bader 1240b6cba4eeSStefan Bader static int 1241b6cba4eeSStefan Bader tape_3590_online(struct ccw_device *cdev) 1242b6cba4eeSStefan Bader { 1243b6cba4eeSStefan Bader return tape_generic_online(cdev->dev.driver_data, 1244b6cba4eeSStefan Bader &tape_discipline_3590); 1245b6cba4eeSStefan Bader } 1246b6cba4eeSStefan Bader 1247b6cba4eeSStefan Bader static int 1248b6cba4eeSStefan Bader tape_3590_offline(struct ccw_device *cdev) 1249b6cba4eeSStefan Bader { 1250b6cba4eeSStefan Bader return tape_generic_offline(cdev->dev.driver_data); 1251b6cba4eeSStefan Bader } 1252b6cba4eeSStefan Bader 1253b6cba4eeSStefan Bader static struct ccw_driver tape_3590_driver = { 1254b6cba4eeSStefan Bader .name = "tape_3590", 1255b6cba4eeSStefan Bader .owner = THIS_MODULE, 1256b6cba4eeSStefan Bader .ids = tape_3590_ids, 1257b6cba4eeSStefan Bader .probe = tape_generic_probe, 1258b6cba4eeSStefan Bader .remove = tape_generic_remove, 1259b6cba4eeSStefan Bader .set_offline = tape_3590_offline, 1260b6cba4eeSStefan Bader .set_online = tape_3590_online, 1261b6cba4eeSStefan Bader }; 1262b6cba4eeSStefan Bader 1263b6cba4eeSStefan Bader /* 1264b6cba4eeSStefan Bader * Setup discipline structure. 1265b6cba4eeSStefan Bader */ 1266b6cba4eeSStefan Bader static int 1267b6cba4eeSStefan Bader tape_3590_init(void) 1268b6cba4eeSStefan Bader { 1269b6cba4eeSStefan Bader int rc; 1270b6cba4eeSStefan Bader 1271b6cba4eeSStefan Bader TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long)); 1272b6cba4eeSStefan Bader debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view); 1273b6cba4eeSStefan Bader #ifdef DBF_LIKE_HELL 1274b6cba4eeSStefan Bader debug_set_level(TAPE_DBF_AREA, 6); 1275b6cba4eeSStefan Bader #endif 1276b6cba4eeSStefan Bader 1277b6cba4eeSStefan Bader DBF_EVENT(3, "3590 init\n"); 1278b6cba4eeSStefan Bader /* Register driver for 3590 tapes. */ 1279b6cba4eeSStefan Bader rc = ccw_driver_register(&tape_3590_driver); 1280b6cba4eeSStefan Bader if (rc) 1281b6cba4eeSStefan Bader DBF_EVENT(3, "3590 init failed\n"); 1282b6cba4eeSStefan Bader else 1283b6cba4eeSStefan Bader DBF_EVENT(3, "3590 registered\n"); 1284b6cba4eeSStefan Bader return rc; 1285b6cba4eeSStefan Bader } 1286b6cba4eeSStefan Bader 1287b6cba4eeSStefan Bader static void 1288b6cba4eeSStefan Bader tape_3590_exit(void) 1289b6cba4eeSStefan Bader { 1290b6cba4eeSStefan Bader ccw_driver_unregister(&tape_3590_driver); 1291b6cba4eeSStefan Bader 1292b6cba4eeSStefan Bader debug_unregister(TAPE_DBF_AREA); 1293b6cba4eeSStefan Bader } 1294b6cba4eeSStefan Bader 1295b6cba4eeSStefan Bader MODULE_DEVICE_TABLE(ccw, tape_3590_ids); 1296b6cba4eeSStefan Bader MODULE_AUTHOR("(C) 2001,2006 IBM Corporation"); 1297b6cba4eeSStefan Bader MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver"); 1298b6cba4eeSStefan Bader MODULE_LICENSE("GPL"); 1299b6cba4eeSStefan Bader 1300b6cba4eeSStefan Bader module_init(tape_3590_init); 1301b6cba4eeSStefan Bader module_exit(tape_3590_exit); 1302