1/* 2 * File...........: linux/drivers/s390/block/dasd_3990_erp.c 3 * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com> 4 * Holger Smolinski <Holger.Smolinski@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com> 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001 7 * 8 */ 9 10#define KMSG_COMPONENT "dasd-eckd" 11 12#include <linux/timer.h> 13#include <asm/idals.h> 14 15#define PRINTK_HEADER "dasd_erp(3990): " 16 17#include "dasd_int.h" 18#include "dasd_eckd.h" 19 20 21struct DCTL_data { 22 unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */ 23 unsigned char modifier; /* Subcommand modifier */ 24 unsigned short res; /* reserved */ 25} __attribute__ ((packed)); 26 27/* 28 ***************************************************************************** 29 * SECTION ERP HANDLING 30 ***************************************************************************** 31 */ 32/* 33 ***************************************************************************** 34 * 24 and 32 byte sense ERP functions 35 ***************************************************************************** 36 */ 37 38/* 39 * DASD_3990_ERP_CLEANUP 40 * 41 * DESCRIPTION 42 * Removes the already build but not necessary ERP request and sets 43 * the status of the original cqr / erp to the given (final) status 44 * 45 * PARAMETER 46 * erp request to be blocked 47 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED 48 * 49 * RETURN VALUES 50 * cqr original cqr 51 */ 52static struct dasd_ccw_req * 53dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status) 54{ 55 struct dasd_ccw_req *cqr = erp->refers; 56 57 dasd_free_erp_request(erp, erp->memdev); 58 cqr->status = final_status; 59 return cqr; 60 61} /* end dasd_3990_erp_cleanup */ 62 63/* 64 * DASD_3990_ERP_BLOCK_QUEUE 65 * 66 * DESCRIPTION 67 * Block the given device request queue to prevent from further 68 * processing until the started timer has expired or an related 69 * interrupt was received. 70 */ 71static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires) 72{ 73 74 struct dasd_device *device = erp->startdev; 75 unsigned long flags; 76 77 DBF_DEV_EVENT(DBF_INFO, device, 78 "blocking request queue for %is", expires/HZ); 79 80 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 81 dasd_device_set_stop_bits(device, DASD_STOPPED_PENDING); 82 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 83 erp->status = DASD_CQR_FILLED; 84 if (erp->block) 85 dasd_block_set_timer(erp->block, expires); 86 else 87 dasd_device_set_timer(device, expires); 88} 89 90/* 91 * DASD_3990_ERP_INT_REQ 92 * 93 * DESCRIPTION 94 * Handles 'Intervention Required' error. 95 * This means either device offline or not installed. 96 * 97 * PARAMETER 98 * erp current erp 99 * RETURN VALUES 100 * erp modified erp 101 */ 102static struct dasd_ccw_req * 103dasd_3990_erp_int_req(struct dasd_ccw_req * erp) 104{ 105 106 struct dasd_device *device = erp->startdev; 107 108 /* first time set initial retry counter and erp_function */ 109 /* and retry once without blocking queue */ 110 /* (this enables easier enqueing of the cqr) */ 111 if (erp->function != dasd_3990_erp_int_req) { 112 113 erp->retries = 256; 114 erp->function = dasd_3990_erp_int_req; 115 116 } else { 117 118 /* issue a message and wait for 'device ready' interrupt */ 119 dev_err(&device->cdev->dev, 120 "is offline or not installed - " 121 "INTERVENTION REQUIRED!!\n"); 122 123 dasd_3990_erp_block_queue(erp, 60*HZ); 124 } 125 126 return erp; 127 128} /* end dasd_3990_erp_int_req */ 129 130/* 131 * DASD_3990_ERP_ALTERNATE_PATH 132 * 133 * DESCRIPTION 134 * Repeat the operation on a different channel path. 135 * If all alternate paths have been tried, the request is posted with a 136 * permanent error. 137 * 138 * PARAMETER 139 * erp pointer to the current ERP 140 * 141 * RETURN VALUES 142 * erp modified pointer to the ERP 143 */ 144static void 145dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp) 146{ 147 struct dasd_device *device = erp->startdev; 148 __u8 opm; 149 unsigned long flags; 150 151 /* try alternate valid path */ 152 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 153 opm = ccw_device_get_path_mask(device->cdev); 154 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 155 if (erp->lpm == 0) 156 erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum); 157 else 158 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum); 159 160 if ((erp->lpm & opm) != 0x00) { 161 162 DBF_DEV_EVENT(DBF_WARNING, device, 163 "try alternate lpm=%x (lpum=%x / opm=%x)", 164 erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm); 165 166 /* reset status to submit the request again... */ 167 erp->status = DASD_CQR_FILLED; 168 erp->retries = 10; 169 } else { 170 dev_err(&device->cdev->dev, 171 "The DASD cannot be reached on any path (lpum=%x" 172 "/opm=%x)\n", erp->irb.esw.esw0.sublog.lpum, opm); 173 174 /* post request with permanent error */ 175 erp->status = DASD_CQR_FAILED; 176 } 177} /* end dasd_3990_erp_alternate_path */ 178 179/* 180 * DASD_3990_ERP_DCTL 181 * 182 * DESCRIPTION 183 * Setup cqr to do the Diagnostic Control (DCTL) command with an 184 * Inhibit Write subcommand (0x20) and the given modifier. 185 * 186 * PARAMETER 187 * erp pointer to the current (failed) ERP 188 * modifier subcommand modifier 189 * 190 * RETURN VALUES 191 * dctl_cqr pointer to NEW dctl_cqr 192 * 193 */ 194static struct dasd_ccw_req * 195dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier) 196{ 197 198 struct dasd_device *device = erp->startdev; 199 struct DCTL_data *DCTL_data; 200 struct ccw1 *ccw; 201 struct dasd_ccw_req *dctl_cqr; 202 203 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1, 204 sizeof(struct DCTL_data), 205 device); 206 if (IS_ERR(dctl_cqr)) { 207 dev_err(&device->cdev->dev, 208 "Unable to allocate DCTL-CQR\n"); 209 erp->status = DASD_CQR_FAILED; 210 return erp; 211 } 212 213 DCTL_data = dctl_cqr->data; 214 215 DCTL_data->subcommand = 0x02; /* Inhibit Write */ 216 DCTL_data->modifier = modifier; 217 218 ccw = dctl_cqr->cpaddr; 219 memset(ccw, 0, sizeof(struct ccw1)); 220 ccw->cmd_code = CCW_CMD_DCTL; 221 ccw->count = 4; 222 ccw->cda = (__u32)(addr_t) DCTL_data; 223 dctl_cqr->function = dasd_3990_erp_DCTL; 224 dctl_cqr->refers = erp; 225 dctl_cqr->startdev = device; 226 dctl_cqr->memdev = device; 227 dctl_cqr->magic = erp->magic; 228 dctl_cqr->expires = 5 * 60 * HZ; 229 dctl_cqr->retries = 2; 230 231 dctl_cqr->buildclk = get_clock(); 232 233 dctl_cqr->status = DASD_CQR_FILLED; 234 235 return dctl_cqr; 236 237} /* end dasd_3990_erp_DCTL */ 238 239/* 240 * DASD_3990_ERP_ACTION_1 241 * 242 * DESCRIPTION 243 * Setup ERP to do the ERP action 1 (see Reference manual). 244 * Repeat the operation on a different channel path. 245 * As deviation from the recommended recovery action, we reset the path mask 246 * after we have tried each path and go through all paths a second time. 247 * This will cover situations where only one path at a time is actually down, 248 * but all paths fail and recover just with the same sequence and timing as 249 * we try to use them (flapping links). 250 * If all alternate paths have been tried twice, the request is posted with 251 * a permanent error. 252 * 253 * PARAMETER 254 * erp pointer to the current ERP 255 * 256 * RETURN VALUES 257 * erp pointer to the ERP 258 * 259 */ 260static struct dasd_ccw_req *dasd_3990_erp_action_1_sec(struct dasd_ccw_req *erp) 261{ 262 erp->function = dasd_3990_erp_action_1_sec; 263 dasd_3990_erp_alternate_path(erp); 264 return erp; 265} 266 267static struct dasd_ccw_req *dasd_3990_erp_action_1(struct dasd_ccw_req *erp) 268{ 269 erp->function = dasd_3990_erp_action_1; 270 dasd_3990_erp_alternate_path(erp); 271 if (erp->status == DASD_CQR_FAILED) { 272 erp->status = DASD_CQR_FILLED; 273 erp->retries = 10; 274 erp->lpm = LPM_ANYPATH; 275 erp->function = dasd_3990_erp_action_1_sec; 276 } 277 return erp; 278} /* end dasd_3990_erp_action_1(b) */ 279 280/* 281 * DASD_3990_ERP_ACTION_4 282 * 283 * DESCRIPTION 284 * Setup ERP to do the ERP action 4 (see Reference manual). 285 * Set the current request to PENDING to block the CQR queue for that device 286 * until the state change interrupt appears. 287 * Use a timer (20 seconds) to retry the cqr if the interrupt is still 288 * missing. 289 * 290 * PARAMETER 291 * sense sense data of the actual error 292 * erp pointer to the current ERP 293 * 294 * RETURN VALUES 295 * erp pointer to the ERP 296 * 297 */ 298static struct dasd_ccw_req * 299dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense) 300{ 301 302 struct dasd_device *device = erp->startdev; 303 304 /* first time set initial retry counter and erp_function */ 305 /* and retry once without waiting for state change pending */ 306 /* interrupt (this enables easier enqueing of the cqr) */ 307 if (erp->function != dasd_3990_erp_action_4) { 308 309 DBF_DEV_EVENT(DBF_INFO, device, "%s", 310 "dasd_3990_erp_action_4: first time retry"); 311 312 erp->retries = 256; 313 erp->function = dasd_3990_erp_action_4; 314 315 } else { 316 if (sense && (sense[25] == 0x1D)) { /* state change pending */ 317 318 DBF_DEV_EVENT(DBF_INFO, device, 319 "waiting for state change pending " 320 "interrupt, %d retries left", 321 erp->retries); 322 323 dasd_3990_erp_block_queue(erp, 30*HZ); 324 325 } else if (sense && (sense[25] == 0x1E)) { /* busy */ 326 DBF_DEV_EVENT(DBF_INFO, device, 327 "busy - redriving request later, " 328 "%d retries left", 329 erp->retries); 330 dasd_3990_erp_block_queue(erp, HZ); 331 } else { 332 /* no state change pending - retry */ 333 DBF_DEV_EVENT(DBF_INFO, device, 334 "redriving request immediately, " 335 "%d retries left", 336 erp->retries); 337 erp->status = DASD_CQR_FILLED; 338 } 339 } 340 341 return erp; 342 343} /* end dasd_3990_erp_action_4 */ 344 345/* 346 ***************************************************************************** 347 * 24 byte sense ERP functions (only) 348 ***************************************************************************** 349 */ 350 351/* 352 * DASD_3990_ERP_ACTION_5 353 * 354 * DESCRIPTION 355 * Setup ERP to do the ERP action 5 (see Reference manual). 356 * NOTE: Further handling is done in xxx_further_erp after the retries. 357 * 358 * PARAMETER 359 * erp pointer to the current ERP 360 * 361 * RETURN VALUES 362 * erp pointer to the ERP 363 * 364 */ 365static struct dasd_ccw_req * 366dasd_3990_erp_action_5(struct dasd_ccw_req * erp) 367{ 368 369 /* first of all retry */ 370 erp->retries = 10; 371 erp->function = dasd_3990_erp_action_5; 372 373 return erp; 374 375} /* end dasd_3990_erp_action_5 */ 376 377/* 378 * DASD_3990_HANDLE_ENV_DATA 379 * 380 * DESCRIPTION 381 * Handles 24 byte 'Environmental data present'. 382 * Does a analysis of the sense data (message Format) 383 * and prints the error messages. 384 * 385 * PARAMETER 386 * sense current sense data 387 * 388 * RETURN VALUES 389 * void 390 */ 391static void 392dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense) 393{ 394 395 struct dasd_device *device = erp->startdev; 396 char msg_format = (sense[7] & 0xF0); 397 char msg_no = (sense[7] & 0x0F); 398 char errorstring[ERRORLENGTH]; 399 400 switch (msg_format) { 401 case 0x00: /* Format 0 - Program or System Checks */ 402 403 if (sense[1] & 0x10) { /* check message to operator bit */ 404 405 switch (msg_no) { 406 case 0x00: /* No Message */ 407 break; 408 case 0x01: 409 dev_warn(&device->cdev->dev, 410 "FORMAT 0 - Invalid Command\n"); 411 break; 412 case 0x02: 413 dev_warn(&device->cdev->dev, 414 "FORMAT 0 - Invalid Command " 415 "Sequence\n"); 416 break; 417 case 0x03: 418 dev_warn(&device->cdev->dev, 419 "FORMAT 0 - CCW Count less than " 420 "required\n"); 421 break; 422 case 0x04: 423 dev_warn(&device->cdev->dev, 424 "FORMAT 0 - Invalid Parameter\n"); 425 break; 426 case 0x05: 427 dev_warn(&device->cdev->dev, 428 "FORMAT 0 - Diagnostic of Special" 429 " Command Violates File Mask\n"); 430 break; 431 case 0x07: 432 dev_warn(&device->cdev->dev, 433 "FORMAT 0 - Channel Returned with " 434 "Incorrect retry CCW\n"); 435 break; 436 case 0x08: 437 dev_warn(&device->cdev->dev, 438 "FORMAT 0 - Reset Notification\n"); 439 break; 440 case 0x09: 441 dev_warn(&device->cdev->dev, 442 "FORMAT 0 - Storage Path Restart\n"); 443 break; 444 case 0x0A: 445 dev_warn(&device->cdev->dev, 446 "FORMAT 0 - Channel requested " 447 "... %02x\n", sense[8]); 448 break; 449 case 0x0B: 450 dev_warn(&device->cdev->dev, 451 "FORMAT 0 - Invalid Defective/" 452 "Alternate Track Pointer\n"); 453 break; 454 case 0x0C: 455 dev_warn(&device->cdev->dev, 456 "FORMAT 0 - DPS Installation " 457 "Check\n"); 458 break; 459 case 0x0E: 460 dev_warn(&device->cdev->dev, 461 "FORMAT 0 - Command Invalid on " 462 "Secondary Address\n"); 463 break; 464 case 0x0F: 465 dev_warn(&device->cdev->dev, 466 "FORMAT 0 - Status Not As " 467 "Required: reason %02x\n", 468 sense[8]); 469 break; 470 default: 471 dev_warn(&device->cdev->dev, 472 "FORMAT 0 - Reserved\n"); 473 } 474 } else { 475 switch (msg_no) { 476 case 0x00: /* No Message */ 477 break; 478 case 0x01: 479 dev_warn(&device->cdev->dev, 480 "FORMAT 0 - Device Error " 481 "Source\n"); 482 break; 483 case 0x02: 484 dev_warn(&device->cdev->dev, 485 "FORMAT 0 - Reserved\n"); 486 break; 487 case 0x03: 488 dev_warn(&device->cdev->dev, 489 "FORMAT 0 - Device Fenced - " 490 "device = %02x\n", sense[4]); 491 break; 492 case 0x04: 493 dev_warn(&device->cdev->dev, 494 "FORMAT 0 - Data Pinned for " 495 "Device\n"); 496 break; 497 default: 498 dev_warn(&device->cdev->dev, 499 "FORMAT 0 - Reserved\n"); 500 } 501 } 502 break; 503 504 case 0x10: /* Format 1 - Device Equipment Checks */ 505 switch (msg_no) { 506 case 0x00: /* No Message */ 507 break; 508 case 0x01: 509 dev_warn(&device->cdev->dev, 510 "FORMAT 1 - Device Status 1 not as " 511 "expected\n"); 512 break; 513 case 0x03: 514 dev_warn(&device->cdev->dev, 515 "FORMAT 1 - Index missing\n"); 516 break; 517 case 0x04: 518 dev_warn(&device->cdev->dev, 519 "FORMAT 1 - Interruption cannot be " 520 "reset\n"); 521 break; 522 case 0x05: 523 dev_warn(&device->cdev->dev, 524 "FORMAT 1 - Device did not respond to " 525 "selection\n"); 526 break; 527 case 0x06: 528 dev_warn(&device->cdev->dev, 529 "FORMAT 1 - Device check-2 error or Set " 530 "Sector is not complete\n"); 531 break; 532 case 0x07: 533 dev_warn(&device->cdev->dev, 534 "FORMAT 1 - Head address does not " 535 "compare\n"); 536 break; 537 case 0x08: 538 dev_warn(&device->cdev->dev, 539 "FORMAT 1 - Device status 1 not valid\n"); 540 break; 541 case 0x09: 542 dev_warn(&device->cdev->dev, 543 "FORMAT 1 - Device not ready\n"); 544 break; 545 case 0x0A: 546 dev_warn(&device->cdev->dev, 547 "FORMAT 1 - Track physical address did " 548 "not compare\n"); 549 break; 550 case 0x0B: 551 dev_warn(&device->cdev->dev, 552 "FORMAT 1 - Missing device address bit\n"); 553 break; 554 case 0x0C: 555 dev_warn(&device->cdev->dev, 556 "FORMAT 1 - Drive motor switch is off\n"); 557 break; 558 case 0x0D: 559 dev_warn(&device->cdev->dev, 560 "FORMAT 1 - Seek incomplete\n"); 561 break; 562 case 0x0E: 563 dev_warn(&device->cdev->dev, 564 "FORMAT 1 - Cylinder address did not " 565 "compare\n"); 566 break; 567 case 0x0F: 568 dev_warn(&device->cdev->dev, 569 "FORMAT 1 - Offset active cannot be " 570 "reset\n"); 571 break; 572 default: 573 dev_warn(&device->cdev->dev, 574 "FORMAT 1 - Reserved\n"); 575 } 576 break; 577 578 case 0x20: /* Format 2 - 3990 Equipment Checks */ 579 switch (msg_no) { 580 case 0x08: 581 dev_warn(&device->cdev->dev, 582 "FORMAT 2 - 3990 check-2 error\n"); 583 break; 584 case 0x0E: 585 dev_warn(&device->cdev->dev, 586 "FORMAT 2 - Support facility errors\n"); 587 break; 588 case 0x0F: 589 dev_warn(&device->cdev->dev, 590 "FORMAT 2 - Microcode detected error " 591 "%02x\n", 592 sense[8]); 593 break; 594 default: 595 dev_warn(&device->cdev->dev, 596 "FORMAT 2 - Reserved\n"); 597 } 598 break; 599 600 case 0x30: /* Format 3 - 3990 Control Checks */ 601 switch (msg_no) { 602 case 0x0F: 603 dev_warn(&device->cdev->dev, 604 "FORMAT 3 - Allegiance terminated\n"); 605 break; 606 default: 607 dev_warn(&device->cdev->dev, 608 "FORMAT 3 - Reserved\n"); 609 } 610 break; 611 612 case 0x40: /* Format 4 - Data Checks */ 613 switch (msg_no) { 614 case 0x00: 615 dev_warn(&device->cdev->dev, 616 "FORMAT 4 - Home address area error\n"); 617 break; 618 case 0x01: 619 dev_warn(&device->cdev->dev, 620 "FORMAT 4 - Count area error\n"); 621 break; 622 case 0x02: 623 dev_warn(&device->cdev->dev, 624 "FORMAT 4 - Key area error\n"); 625 break; 626 case 0x03: 627 dev_warn(&device->cdev->dev, 628 "FORMAT 4 - Data area error\n"); 629 break; 630 case 0x04: 631 dev_warn(&device->cdev->dev, 632 "FORMAT 4 - No sync byte in home address " 633 "area\n"); 634 break; 635 case 0x05: 636 dev_warn(&device->cdev->dev, 637 "FORMAT 4 - No sync byte in count address " 638 "area\n"); 639 break; 640 case 0x06: 641 dev_warn(&device->cdev->dev, 642 "FORMAT 4 - No sync byte in key area\n"); 643 break; 644 case 0x07: 645 dev_warn(&device->cdev->dev, 646 "FORMAT 4 - No sync byte in data area\n"); 647 break; 648 case 0x08: 649 dev_warn(&device->cdev->dev, 650 "FORMAT 4 - Home address area error; " 651 "offset active\n"); 652 break; 653 case 0x09: 654 dev_warn(&device->cdev->dev, 655 "FORMAT 4 - Count area error; offset " 656 "active\n"); 657 break; 658 case 0x0A: 659 dev_warn(&device->cdev->dev, 660 "FORMAT 4 - Key area error; offset " 661 "active\n"); 662 break; 663 case 0x0B: 664 dev_warn(&device->cdev->dev, 665 "FORMAT 4 - Data area error; " 666 "offset active\n"); 667 break; 668 case 0x0C: 669 dev_warn(&device->cdev->dev, 670 "FORMAT 4 - No sync byte in home " 671 "address area; offset active\n"); 672 break; 673 case 0x0D: 674 dev_warn(&device->cdev->dev, 675 "FORMAT 4 - No syn byte in count " 676 "address area; offset active\n"); 677 break; 678 case 0x0E: 679 dev_warn(&device->cdev->dev, 680 "FORMAT 4 - No sync byte in key area; " 681 "offset active\n"); 682 break; 683 case 0x0F: 684 dev_warn(&device->cdev->dev, 685 "FORMAT 4 - No syn byte in data area; " 686 "offset active\n"); 687 break; 688 default: 689 dev_warn(&device->cdev->dev, 690 "FORMAT 4 - Reserved\n"); 691 } 692 break; 693 694 case 0x50: /* Format 5 - Data Check with displacement information */ 695 switch (msg_no) { 696 case 0x00: 697 dev_warn(&device->cdev->dev, 698 "FORMAT 5 - Data Check in the " 699 "home address area\n"); 700 break; 701 case 0x01: 702 dev_warn(&device->cdev->dev, 703 "FORMAT 5 - Data Check in the count " 704 "area\n"); 705 break; 706 case 0x02: 707 dev_warn(&device->cdev->dev, 708 "FORMAT 5 - Data Check in the key area\n"); 709 break; 710 case 0x03: 711 dev_warn(&device->cdev->dev, 712 "FORMAT 5 - Data Check in the data " 713 "area\n"); 714 break; 715 case 0x08: 716 dev_warn(&device->cdev->dev, 717 "FORMAT 5 - Data Check in the " 718 "home address area; offset active\n"); 719 break; 720 case 0x09: 721 dev_warn(&device->cdev->dev, 722 "FORMAT 5 - Data Check in the count area; " 723 "offset active\n"); 724 break; 725 case 0x0A: 726 dev_warn(&device->cdev->dev, 727 "FORMAT 5 - Data Check in the key area; " 728 "offset active\n"); 729 break; 730 case 0x0B: 731 dev_warn(&device->cdev->dev, 732 "FORMAT 5 - Data Check in the data area; " 733 "offset active\n"); 734 break; 735 default: 736 dev_warn(&device->cdev->dev, 737 "FORMAT 5 - Reserved\n"); 738 } 739 break; 740 741 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */ 742 switch (msg_no) { 743 case 0x00: 744 dev_warn(&device->cdev->dev, 745 "FORMAT 6 - Overrun on channel A\n"); 746 break; 747 case 0x01: 748 dev_warn(&device->cdev->dev, 749 "FORMAT 6 - Overrun on channel B\n"); 750 break; 751 case 0x02: 752 dev_warn(&device->cdev->dev, 753 "FORMAT 6 - Overrun on channel C\n"); 754 break; 755 case 0x03: 756 dev_warn(&device->cdev->dev, 757 "FORMAT 6 - Overrun on channel D\n"); 758 break; 759 case 0x04: 760 dev_warn(&device->cdev->dev, 761 "FORMAT 6 - Overrun on channel E\n"); 762 break; 763 case 0x05: 764 dev_warn(&device->cdev->dev, 765 "FORMAT 6 - Overrun on channel F\n"); 766 break; 767 case 0x06: 768 dev_warn(&device->cdev->dev, 769 "FORMAT 6 - Overrun on channel G\n"); 770 break; 771 case 0x07: 772 dev_warn(&device->cdev->dev, 773 "FORMAT 6 - Overrun on channel H\n"); 774 break; 775 default: 776 dev_warn(&device->cdev->dev, 777 "FORMAT 6 - Reserved\n"); 778 } 779 break; 780 781 case 0x70: /* Format 7 - Device Connection Control Checks */ 782 switch (msg_no) { 783 case 0x00: 784 dev_warn(&device->cdev->dev, 785 "FORMAT 7 - RCC initiated by a connection " 786 "check alert\n"); 787 break; 788 case 0x01: 789 dev_warn(&device->cdev->dev, 790 "FORMAT 7 - RCC 1 sequence not " 791 "successful\n"); 792 break; 793 case 0x02: 794 dev_warn(&device->cdev->dev, 795 "FORMAT 7 - RCC 1 and RCC 2 sequences not " 796 "successful\n"); 797 break; 798 case 0x03: 799 dev_warn(&device->cdev->dev, 800 "FORMAT 7 - Invalid tag-in during " 801 "selection sequence\n"); 802 break; 803 case 0x04: 804 dev_warn(&device->cdev->dev, 805 "FORMAT 7 - extra RCC required\n"); 806 break; 807 case 0x05: 808 dev_warn(&device->cdev->dev, 809 "FORMAT 7 - Invalid DCC selection " 810 "response or timeout\n"); 811 break; 812 case 0x06: 813 dev_warn(&device->cdev->dev, 814 "FORMAT 7 - Missing end operation; device " 815 "transfer complete\n"); 816 break; 817 case 0x07: 818 dev_warn(&device->cdev->dev, 819 "FORMAT 7 - Missing end operation; device " 820 "transfer incomplete\n"); 821 break; 822 case 0x08: 823 dev_warn(&device->cdev->dev, 824 "FORMAT 7 - Invalid tag-in for an " 825 "immediate command sequence\n"); 826 break; 827 case 0x09: 828 dev_warn(&device->cdev->dev, 829 "FORMAT 7 - Invalid tag-in for an " 830 "extended command sequence\n"); 831 break; 832 case 0x0A: 833 dev_warn(&device->cdev->dev, 834 "FORMAT 7 - 3990 microcode time out when " 835 "stopping selection\n"); 836 break; 837 case 0x0B: 838 dev_warn(&device->cdev->dev, 839 "FORMAT 7 - No response to selection " 840 "after a poll interruption\n"); 841 break; 842 case 0x0C: 843 dev_warn(&device->cdev->dev, 844 "FORMAT 7 - Permanent path error (DASD " 845 "controller not available)\n"); 846 break; 847 case 0x0D: 848 dev_warn(&device->cdev->dev, 849 "FORMAT 7 - DASD controller not available" 850 " on disconnected command chain\n"); 851 break; 852 default: 853 dev_warn(&device->cdev->dev, 854 "FORMAT 7 - Reserved\n"); 855 } 856 break; 857 858 case 0x80: /* Format 8 - Additional Device Equipment Checks */ 859 switch (msg_no) { 860 case 0x00: /* No Message */ 861 case 0x01: 862 dev_warn(&device->cdev->dev, 863 "FORMAT 8 - Error correction code " 864 "hardware fault\n"); 865 break; 866 case 0x03: 867 dev_warn(&device->cdev->dev, 868 "FORMAT 8 - Unexpected end operation " 869 "response code\n"); 870 break; 871 case 0x04: 872 dev_warn(&device->cdev->dev, 873 "FORMAT 8 - End operation with transfer " 874 "count not zero\n"); 875 break; 876 case 0x05: 877 dev_warn(&device->cdev->dev, 878 "FORMAT 8 - End operation with transfer " 879 "count zero\n"); 880 break; 881 case 0x06: 882 dev_warn(&device->cdev->dev, 883 "FORMAT 8 - DPS checks after a system " 884 "reset or selective reset\n"); 885 break; 886 case 0x07: 887 dev_warn(&device->cdev->dev, 888 "FORMAT 8 - DPS cannot be filled\n"); 889 break; 890 case 0x08: 891 dev_warn(&device->cdev->dev, 892 "FORMAT 8 - Short busy time-out during " 893 "device selection\n"); 894 break; 895 case 0x09: 896 dev_warn(&device->cdev->dev, 897 "FORMAT 8 - DASD controller failed to " 898 "set or reset the long busy latch\n"); 899 break; 900 case 0x0A: 901 dev_warn(&device->cdev->dev, 902 "FORMAT 8 - No interruption from device " 903 "during a command chain\n"); 904 break; 905 default: 906 dev_warn(&device->cdev->dev, 907 "FORMAT 8 - Reserved\n"); 908 } 909 break; 910 911 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */ 912 switch (msg_no) { 913 case 0x00: 914 break; /* No Message */ 915 case 0x06: 916 dev_warn(&device->cdev->dev, 917 "FORMAT 9 - Device check-2 error\n"); 918 break; 919 case 0x07: 920 dev_warn(&device->cdev->dev, 921 "FORMAT 9 - Head address did not " 922 "compare\n"); 923 break; 924 case 0x0A: 925 dev_warn(&device->cdev->dev, 926 "FORMAT 9 - Track physical address did " 927 "not compare while oriented\n"); 928 break; 929 case 0x0E: 930 dev_warn(&device->cdev->dev, 931 "FORMAT 9 - Cylinder address did not " 932 "compare\n"); 933 break; 934 default: 935 dev_warn(&device->cdev->dev, 936 "FORMAT 9 - Reserved\n"); 937 } 938 break; 939 940 case 0xF0: /* Format F - Cache Storage Checks */ 941 switch (msg_no) { 942 case 0x00: 943 dev_warn(&device->cdev->dev, 944 "FORMAT F - Operation Terminated\n"); 945 break; 946 case 0x01: 947 dev_warn(&device->cdev->dev, 948 "FORMAT F - Subsystem Processing Error\n"); 949 break; 950 case 0x02: 951 dev_warn(&device->cdev->dev, 952 "FORMAT F - Cache or nonvolatile storage " 953 "equipment failure\n"); 954 break; 955 case 0x04: 956 dev_warn(&device->cdev->dev, 957 "FORMAT F - Caching terminated\n"); 958 break; 959 case 0x06: 960 dev_warn(&device->cdev->dev, 961 "FORMAT F - Cache fast write access not " 962 "authorized\n"); 963 break; 964 case 0x07: 965 dev_warn(&device->cdev->dev, 966 "FORMAT F - Track format incorrect\n"); 967 break; 968 case 0x09: 969 dev_warn(&device->cdev->dev, 970 "FORMAT F - Caching reinitiated\n"); 971 break; 972 case 0x0A: 973 dev_warn(&device->cdev->dev, 974 "FORMAT F - Nonvolatile storage " 975 "terminated\n"); 976 break; 977 case 0x0B: 978 dev_warn(&device->cdev->dev, 979 "FORMAT F - Volume is suspended duplex\n"); 980 /* call extended error reporting (EER) */ 981 dasd_eer_write(device, erp->refers, 982 DASD_EER_PPRCSUSPEND); 983 break; 984 case 0x0C: 985 dev_warn(&device->cdev->dev, 986 "FORMAT F - Subsystem status cannot be " 987 "determined\n"); 988 break; 989 case 0x0D: 990 dev_warn(&device->cdev->dev, 991 "FORMAT F - Caching status reset to " 992 "default\n"); 993 break; 994 case 0x0E: 995 dev_warn(&device->cdev->dev, 996 "FORMAT F - DASD Fast Write inhibited\n"); 997 break; 998 default: 999 dev_warn(&device->cdev->dev, 1000 "FORMAT D - Reserved\n"); 1001 } 1002 break; 1003 1004 default: /* unknown message format - should not happen 1005 internal error 03 - unknown message format */ 1006 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format); 1007 dev_err(&device->cdev->dev, 1008 "An error occurred in the DASD device driver, " 1009 "reason=%s\n", errorstring); 1010 break; 1011 } /* end switch message format */ 1012 1013} /* end dasd_3990_handle_env_data */ 1014 1015/* 1016 * DASD_3990_ERP_COM_REJ 1017 * 1018 * DESCRIPTION 1019 * Handles 24 byte 'Command Reject' error. 1020 * 1021 * PARAMETER 1022 * erp current erp_head 1023 * sense current sense data 1024 * 1025 * RETURN VALUES 1026 * erp 'new' erp_head - pointer to new ERP 1027 */ 1028static struct dasd_ccw_req * 1029dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense) 1030{ 1031 1032 struct dasd_device *device = erp->startdev; 1033 1034 erp->function = dasd_3990_erp_com_rej; 1035 1036 /* env data present (ACTION 10 - retry should work) */ 1037 if (sense[2] & SNS2_ENV_DATA_PRESENT) { 1038 1039 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1040 "Command Reject - environmental data present"); 1041 1042 dasd_3990_handle_env_data(erp, sense); 1043 1044 erp->retries = 5; 1045 1046 } else if (sense[1] & SNS1_WRITE_INHIBITED) { 1047 dev_err(&device->cdev->dev, "An I/O request was rejected" 1048 " because writing is inhibited\n"); 1049 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 1050 } else { 1051 /* fatal error - set status to FAILED 1052 internal error 09 - Command Reject */ 1053 dev_err(&device->cdev->dev, "An error occurred in the DASD " 1054 "device driver, reason=%s\n", "09"); 1055 1056 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 1057 } 1058 1059 return erp; 1060 1061} /* end dasd_3990_erp_com_rej */ 1062 1063/* 1064 * DASD_3990_ERP_BUS_OUT 1065 * 1066 * DESCRIPTION 1067 * Handles 24 byte 'Bus Out Parity Check' error. 1068 * 1069 * PARAMETER 1070 * erp current erp_head 1071 * RETURN VALUES 1072 * erp new erp_head - pointer to new ERP 1073 */ 1074static struct dasd_ccw_req * 1075dasd_3990_erp_bus_out(struct dasd_ccw_req * erp) 1076{ 1077 1078 struct dasd_device *device = erp->startdev; 1079 1080 /* first time set initial retry counter and erp_function */ 1081 /* and retry once without blocking queue */ 1082 /* (this enables easier enqueing of the cqr) */ 1083 if (erp->function != dasd_3990_erp_bus_out) { 1084 erp->retries = 256; 1085 erp->function = dasd_3990_erp_bus_out; 1086 1087 } else { 1088 1089 /* issue a message and wait for 'device ready' interrupt */ 1090 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1091 "bus out parity error or BOPC requested by " 1092 "channel"); 1093 1094 dasd_3990_erp_block_queue(erp, 60*HZ); 1095 1096 } 1097 1098 return erp; 1099 1100} /* end dasd_3990_erp_bus_out */ 1101 1102/* 1103 * DASD_3990_ERP_EQUIP_CHECK 1104 * 1105 * DESCRIPTION 1106 * Handles 24 byte 'Equipment Check' error. 1107 * 1108 * PARAMETER 1109 * erp current erp_head 1110 * RETURN VALUES 1111 * erp new erp_head - pointer to new ERP 1112 */ 1113static struct dasd_ccw_req * 1114dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense) 1115{ 1116 1117 struct dasd_device *device = erp->startdev; 1118 1119 erp->function = dasd_3990_erp_equip_check; 1120 1121 if (sense[1] & SNS1_WRITE_INHIBITED) { 1122 dev_info(&device->cdev->dev, 1123 "Write inhibited path encountered\n"); 1124 1125 /* vary path offline 1126 internal error 04 - Path should be varied off-line.*/ 1127 dev_err(&device->cdev->dev, "An error occurred in the DASD " 1128 "device driver, reason=%s\n", "04"); 1129 1130 erp = dasd_3990_erp_action_1(erp); 1131 1132 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) { 1133 1134 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1135 "Equipment Check - " "environmental data present"); 1136 1137 dasd_3990_handle_env_data(erp, sense); 1138 1139 erp = dasd_3990_erp_action_4(erp, sense); 1140 1141 } else if (sense[1] & SNS1_PERM_ERR) { 1142 1143 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1144 "Equipment Check - retry exhausted or " 1145 "undesirable"); 1146 1147 erp = dasd_3990_erp_action_1(erp); 1148 1149 } else { 1150 /* all other equipment checks - Action 5 */ 1151 /* rest is done when retries == 0 */ 1152 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1153 "Equipment check or processing error"); 1154 1155 erp = dasd_3990_erp_action_5(erp); 1156 } 1157 return erp; 1158 1159} /* end dasd_3990_erp_equip_check */ 1160 1161/* 1162 * DASD_3990_ERP_DATA_CHECK 1163 * 1164 * DESCRIPTION 1165 * Handles 24 byte 'Data Check' error. 1166 * 1167 * PARAMETER 1168 * erp current erp_head 1169 * RETURN VALUES 1170 * erp new erp_head - pointer to new ERP 1171 */ 1172static struct dasd_ccw_req * 1173dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense) 1174{ 1175 1176 struct dasd_device *device = erp->startdev; 1177 1178 erp->function = dasd_3990_erp_data_check; 1179 1180 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */ 1181 1182 /* issue message that the data has been corrected */ 1183 dev_emerg(&device->cdev->dev, 1184 "Data recovered during retry with PCI " 1185 "fetch mode active\n"); 1186 1187 /* not possible to handle this situation in Linux */ 1188 panic("No way to inform application about the possibly " 1189 "incorrect data"); 1190 1191 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) { 1192 1193 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1194 "Uncorrectable data check recovered secondary " 1195 "addr of duplex pair"); 1196 1197 erp = dasd_3990_erp_action_4(erp, sense); 1198 1199 } else if (sense[1] & SNS1_PERM_ERR) { 1200 1201 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1202 "Uncorrectable data check with internal " 1203 "retry exhausted"); 1204 1205 erp = dasd_3990_erp_action_1(erp); 1206 1207 } else { 1208 /* all other data checks */ 1209 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1210 "Uncorrectable data check with retry count " 1211 "exhausted..."); 1212 1213 erp = dasd_3990_erp_action_5(erp); 1214 } 1215 1216 return erp; 1217 1218} /* end dasd_3990_erp_data_check */ 1219 1220/* 1221 * DASD_3990_ERP_OVERRUN 1222 * 1223 * DESCRIPTION 1224 * Handles 24 byte 'Overrun' error. 1225 * 1226 * PARAMETER 1227 * erp current erp_head 1228 * RETURN VALUES 1229 * erp new erp_head - pointer to new ERP 1230 */ 1231static struct dasd_ccw_req * 1232dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense) 1233{ 1234 1235 struct dasd_device *device = erp->startdev; 1236 1237 erp->function = dasd_3990_erp_overrun; 1238 1239 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1240 "Overrun - service overrun or overrun" 1241 " error requested by channel"); 1242 1243 erp = dasd_3990_erp_action_5(erp); 1244 1245 return erp; 1246 1247} /* end dasd_3990_erp_overrun */ 1248 1249/* 1250 * DASD_3990_ERP_INV_FORMAT 1251 * 1252 * DESCRIPTION 1253 * Handles 24 byte 'Invalid Track Format' error. 1254 * 1255 * PARAMETER 1256 * erp current erp_head 1257 * RETURN VALUES 1258 * erp new erp_head - pointer to new ERP 1259 */ 1260static struct dasd_ccw_req * 1261dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense) 1262{ 1263 1264 struct dasd_device *device = erp->startdev; 1265 1266 erp->function = dasd_3990_erp_inv_format; 1267 1268 if (sense[2] & SNS2_ENV_DATA_PRESENT) { 1269 1270 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1271 "Track format error when destaging or " 1272 "staging data"); 1273 1274 dasd_3990_handle_env_data(erp, sense); 1275 1276 erp = dasd_3990_erp_action_4(erp, sense); 1277 1278 } else { 1279 /* internal error 06 - The track format is not valid*/ 1280 dev_err(&device->cdev->dev, 1281 "An error occurred in the DASD device driver, " 1282 "reason=%s\n", "06"); 1283 1284 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 1285 } 1286 1287 return erp; 1288 1289} /* end dasd_3990_erp_inv_format */ 1290 1291/* 1292 * DASD_3990_ERP_EOC 1293 * 1294 * DESCRIPTION 1295 * Handles 24 byte 'End-of-Cylinder' error. 1296 * 1297 * PARAMETER 1298 * erp already added default erp 1299 * RETURN VALUES 1300 * erp pointer to original (failed) cqr. 1301 */ 1302static struct dasd_ccw_req * 1303dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense) 1304{ 1305 1306 struct dasd_device *device = default_erp->startdev; 1307 1308 dev_err(&device->cdev->dev, 1309 "The cylinder data for accessing the DASD is inconsistent\n"); 1310 1311 /* implement action 7 - BUG */ 1312 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED); 1313 1314} /* end dasd_3990_erp_EOC */ 1315 1316/* 1317 * DASD_3990_ERP_ENV_DATA 1318 * 1319 * DESCRIPTION 1320 * Handles 24 byte 'Environmental-Data Present' error. 1321 * 1322 * PARAMETER 1323 * erp current erp_head 1324 * RETURN VALUES 1325 * erp new erp_head - pointer to new ERP 1326 */ 1327static struct dasd_ccw_req * 1328dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense) 1329{ 1330 1331 struct dasd_device *device = erp->startdev; 1332 1333 erp->function = dasd_3990_erp_env_data; 1334 1335 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present"); 1336 1337 dasd_3990_handle_env_data(erp, sense); 1338 1339 /* don't retry on disabled interface */ 1340 if (sense[7] != 0x0F) { 1341 erp = dasd_3990_erp_action_4(erp, sense); 1342 } else { 1343 erp->status = DASD_CQR_FILLED; 1344 } 1345 1346 return erp; 1347 1348} /* end dasd_3990_erp_env_data */ 1349 1350/* 1351 * DASD_3990_ERP_NO_REC 1352 * 1353 * DESCRIPTION 1354 * Handles 24 byte 'No Record Found' error. 1355 * 1356 * PARAMETER 1357 * erp already added default ERP 1358 * 1359 * RETURN VALUES 1360 * erp new erp_head - pointer to new ERP 1361 */ 1362static struct dasd_ccw_req * 1363dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense) 1364{ 1365 1366 struct dasd_device *device = default_erp->startdev; 1367 1368 dev_err(&device->cdev->dev, 1369 "The specified record was not found\n"); 1370 1371 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED); 1372 1373} /* end dasd_3990_erp_no_rec */ 1374 1375/* 1376 * DASD_3990_ERP_FILE_PROT 1377 * 1378 * DESCRIPTION 1379 * Handles 24 byte 'File Protected' error. 1380 * Note: Seek related recovery is not implemented because 1381 * wee don't use the seek command yet. 1382 * 1383 * PARAMETER 1384 * erp current erp_head 1385 * RETURN VALUES 1386 * erp new erp_head - pointer to new ERP 1387 */ 1388static struct dasd_ccw_req * 1389dasd_3990_erp_file_prot(struct dasd_ccw_req * erp) 1390{ 1391 1392 struct dasd_device *device = erp->startdev; 1393 1394 dev_err(&device->cdev->dev, "Accessing the DASD failed because of " 1395 "a hardware error\n"); 1396 1397 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 1398 1399} /* end dasd_3990_erp_file_prot */ 1400 1401/* 1402 * DASD_3990_ERP_INSPECT_ALIAS 1403 * 1404 * DESCRIPTION 1405 * Checks if the original request was started on an alias device. 1406 * If yes, it modifies the original and the erp request so that 1407 * the erp request can be started on a base device. 1408 * 1409 * PARAMETER 1410 * erp pointer to the currently created default ERP 1411 * 1412 * RETURN VALUES 1413 * erp pointer to the modified ERP, or NULL 1414 */ 1415 1416static struct dasd_ccw_req *dasd_3990_erp_inspect_alias( 1417 struct dasd_ccw_req *erp) 1418{ 1419 struct dasd_ccw_req *cqr = erp->refers; 1420 char *sense; 1421 1422 if (cqr->block && 1423 (cqr->block->base != cqr->startdev)) { 1424 1425 sense = dasd_get_sense(&erp->refers->irb); 1426 /* 1427 * dynamic pav may have changed base alias mapping 1428 */ 1429 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense 1430 && (sense[0] == 0x10) && (sense[7] == 0x0F) 1431 && (sense[8] == 0x67)) { 1432 /* 1433 * remove device from alias handling to prevent new 1434 * requests from being scheduled on the 1435 * wrong alias device 1436 */ 1437 dasd_alias_remove_device(cqr->startdev); 1438 1439 /* schedule worker to reload device */ 1440 dasd_reload_device(cqr->startdev); 1441 } 1442 1443 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) { 1444 DBF_DEV_EVENT(DBF_ERR, cqr->startdev, 1445 "ERP on alias device for request %p," 1446 " recover on base device %s", cqr, 1447 dev_name(&cqr->block->base->cdev->dev)); 1448 } 1449 dasd_eckd_reset_ccw_to_base_io(cqr); 1450 erp->startdev = cqr->block->base; 1451 erp->function = dasd_3990_erp_inspect_alias; 1452 return erp; 1453 } else 1454 return NULL; 1455} 1456 1457 1458/* 1459 * DASD_3990_ERP_INSPECT_24 1460 * 1461 * DESCRIPTION 1462 * Does a detailed inspection of the 24 byte sense data 1463 * and sets up a related error recovery action. 1464 * 1465 * PARAMETER 1466 * sense sense data of the actual error 1467 * erp pointer to the currently created default ERP 1468 * 1469 * RETURN VALUES 1470 * erp pointer to the (addtitional) ERP 1471 */ 1472static struct dasd_ccw_req * 1473dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense) 1474{ 1475 1476 struct dasd_ccw_req *erp_filled = NULL; 1477 1478 /* Check sense for .... */ 1479 /* 'Command Reject' */ 1480 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) { 1481 erp_filled = dasd_3990_erp_com_rej(erp, sense); 1482 } 1483 /* 'Intervention Required' */ 1484 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) { 1485 erp_filled = dasd_3990_erp_int_req(erp); 1486 } 1487 /* 'Bus Out Parity Check' */ 1488 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) { 1489 erp_filled = dasd_3990_erp_bus_out(erp); 1490 } 1491 /* 'Equipment Check' */ 1492 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) { 1493 erp_filled = dasd_3990_erp_equip_check(erp, sense); 1494 } 1495 /* 'Data Check' */ 1496 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) { 1497 erp_filled = dasd_3990_erp_data_check(erp, sense); 1498 } 1499 /* 'Overrun' */ 1500 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) { 1501 erp_filled = dasd_3990_erp_overrun(erp, sense); 1502 } 1503 /* 'Invalid Track Format' */ 1504 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) { 1505 erp_filled = dasd_3990_erp_inv_format(erp, sense); 1506 } 1507 /* 'End-of-Cylinder' */ 1508 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) { 1509 erp_filled = dasd_3990_erp_EOC(erp, sense); 1510 } 1511 /* 'Environmental Data' */ 1512 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) { 1513 erp_filled = dasd_3990_erp_env_data(erp, sense); 1514 } 1515 /* 'No Record Found' */ 1516 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) { 1517 erp_filled = dasd_3990_erp_no_rec(erp, sense); 1518 } 1519 /* 'File Protected' */ 1520 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) { 1521 erp_filled = dasd_3990_erp_file_prot(erp); 1522 } 1523 /* other (unknown) error - do default ERP */ 1524 if (erp_filled == NULL) { 1525 1526 erp_filled = erp; 1527 } 1528 1529 return erp_filled; 1530 1531} /* END dasd_3990_erp_inspect_24 */ 1532 1533/* 1534 ***************************************************************************** 1535 * 32 byte sense ERP functions (only) 1536 ***************************************************************************** 1537 */ 1538 1539/* 1540 * DASD_3990_ERPACTION_10_32 1541 * 1542 * DESCRIPTION 1543 * Handles 32 byte 'Action 10' of Single Program Action Codes. 1544 * Just retry and if retry doesn't work, return with error. 1545 * 1546 * PARAMETER 1547 * erp current erp_head 1548 * sense current sense data 1549 * RETURN VALUES 1550 * erp modified erp_head 1551 */ 1552static struct dasd_ccw_req * 1553dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense) 1554{ 1555 1556 struct dasd_device *device = erp->startdev; 1557 1558 erp->retries = 256; 1559 erp->function = dasd_3990_erp_action_10_32; 1560 1561 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested"); 1562 1563 return erp; 1564 1565} /* end dasd_3990_erp_action_10_32 */ 1566 1567/* 1568 * DASD_3990_ERP_ACTION_1B_32 1569 * 1570 * DESCRIPTION 1571 * Handles 32 byte 'Action 1B' of Single Program Action Codes. 1572 * A write operation could not be finished because of an unexpected 1573 * condition. 1574 * The already created 'default erp' is used to get the link to 1575 * the erp chain, but it can not be used for this recovery 1576 * action because it contains no DE/LO data space. 1577 * 1578 * PARAMETER 1579 * default_erp already added default erp. 1580 * sense current sense data 1581 * 1582 * RETURN VALUES 1583 * erp new erp or 1584 * default_erp in case of imprecise ending or error 1585 */ 1586static struct dasd_ccw_req * 1587dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense) 1588{ 1589 1590 struct dasd_device *device = default_erp->startdev; 1591 __u32 cpa = 0; 1592 struct dasd_ccw_req *cqr; 1593 struct dasd_ccw_req *erp; 1594 struct DE_eckd_data *DE_data; 1595 struct PFX_eckd_data *PFX_data; 1596 char *LO_data; /* LO_eckd_data_t */ 1597 struct ccw1 *ccw, *oldccw; 1598 1599 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1600 "Write not finished because of unexpected condition"); 1601 1602 default_erp->function = dasd_3990_erp_action_1B_32; 1603 1604 /* determine the original cqr */ 1605 cqr = default_erp; 1606 1607 while (cqr->refers != NULL) { 1608 cqr = cqr->refers; 1609 } 1610 1611 if (scsw_is_tm(&cqr->irb.scsw)) { 1612 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1613 "32 bit sense, action 1B is not defined" 1614 " in transport mode - just retry"); 1615 return default_erp; 1616 } 1617 1618 /* for imprecise ending just do default erp */ 1619 if (sense[1] & 0x01) { 1620 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1621 "Imprecise ending is set - just retry"); 1622 1623 return default_erp; 1624 } 1625 1626 /* determine the address of the CCW to be restarted */ 1627 /* Imprecise ending is not set -> addr from IRB-SCSW */ 1628 cpa = default_erp->refers->irb.scsw.cmd.cpa; 1629 1630 if (cpa == 0) { 1631 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1632 "Unable to determine address of the CCW " 1633 "to be restarted"); 1634 1635 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED); 1636 } 1637 1638 /* Build new ERP request including DE/LO */ 1639 erp = dasd_alloc_erp_request((char *) &cqr->magic, 1640 2 + 1,/* DE/LO + TIC */ 1641 sizeof(struct DE_eckd_data) + 1642 sizeof(struct LO_eckd_data), device); 1643 1644 if (IS_ERR(erp)) { 1645 /* internal error 01 - Unable to allocate ERP */ 1646 dev_err(&device->cdev->dev, "An error occurred in the DASD " 1647 "device driver, reason=%s\n", "01"); 1648 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED); 1649 } 1650 1651 /* use original DE */ 1652 DE_data = erp->data; 1653 oldccw = cqr->cpaddr; 1654 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) { 1655 PFX_data = cqr->data; 1656 memcpy(DE_data, &PFX_data->define_extent, 1657 sizeof(struct DE_eckd_data)); 1658 } else 1659 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data)); 1660 1661 /* create LO */ 1662 LO_data = erp->data + sizeof(struct DE_eckd_data); 1663 1664 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) { 1665 /* should not */ 1666 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED); 1667 } 1668 1669 if ((sense[7] & 0x3F) == 0x01) { 1670 /* operation code is WRITE DATA -> data area orientation */ 1671 LO_data[0] = 0x81; 1672 1673 } else if ((sense[7] & 0x3F) == 0x03) { 1674 /* operation code is FORMAT WRITE -> index orientation */ 1675 LO_data[0] = 0xC3; 1676 1677 } else { 1678 LO_data[0] = sense[7]; /* operation */ 1679 } 1680 1681 LO_data[1] = sense[8]; /* auxiliary */ 1682 LO_data[2] = sense[9]; 1683 LO_data[3] = sense[3]; /* count */ 1684 LO_data[4] = sense[29]; /* seek_addr.cyl */ 1685 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */ 1686 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */ 1687 1688 memcpy(&(LO_data[8]), &(sense[11]), 8); 1689 1690 /* create DE ccw */ 1691 ccw = erp->cpaddr; 1692 memset(ccw, 0, sizeof(struct ccw1)); 1693 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT; 1694 ccw->flags = CCW_FLAG_CC; 1695 ccw->count = 16; 1696 ccw->cda = (__u32)(addr_t) DE_data; 1697 1698 /* create LO ccw */ 1699 ccw++; 1700 memset(ccw, 0, sizeof(struct ccw1)); 1701 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD; 1702 ccw->flags = CCW_FLAG_CC; 1703 ccw->count = 16; 1704 ccw->cda = (__u32)(addr_t) LO_data; 1705 1706 /* TIC to the failed ccw */ 1707 ccw++; 1708 ccw->cmd_code = CCW_CMD_TIC; 1709 ccw->cda = cpa; 1710 1711 /* fill erp related fields */ 1712 erp->function = dasd_3990_erp_action_1B_32; 1713 erp->refers = default_erp->refers; 1714 erp->startdev = device; 1715 erp->memdev = device; 1716 erp->magic = default_erp->magic; 1717 erp->expires = 0; 1718 erp->retries = 256; 1719 erp->buildclk = get_clock(); 1720 erp->status = DASD_CQR_FILLED; 1721 1722 /* remove the default erp */ 1723 dasd_free_erp_request(default_erp, device); 1724 1725 return erp; 1726 1727} /* end dasd_3990_erp_action_1B_32 */ 1728 1729/* 1730 * DASD_3990_UPDATE_1B 1731 * 1732 * DESCRIPTION 1733 * Handles the update to the 32 byte 'Action 1B' of Single Program 1734 * Action Codes in case the first action was not successful. 1735 * The already created 'previous_erp' is the currently not successful 1736 * ERP. 1737 * 1738 * PARAMETER 1739 * previous_erp already created previous erp. 1740 * sense current sense data 1741 * RETURN VALUES 1742 * erp modified erp 1743 */ 1744static struct dasd_ccw_req * 1745dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense) 1746{ 1747 1748 struct dasd_device *device = previous_erp->startdev; 1749 __u32 cpa = 0; 1750 struct dasd_ccw_req *cqr; 1751 struct dasd_ccw_req *erp; 1752 char *LO_data; /* struct LO_eckd_data */ 1753 struct ccw1 *ccw; 1754 1755 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1756 "Write not finished because of unexpected condition" 1757 " - follow on"); 1758 1759 /* determine the original cqr */ 1760 cqr = previous_erp; 1761 1762 while (cqr->refers != NULL) { 1763 cqr = cqr->refers; 1764 } 1765 1766 if (scsw_is_tm(&cqr->irb.scsw)) { 1767 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1768 "32 bit sense, action 1B, update," 1769 " in transport mode - just retry"); 1770 return previous_erp; 1771 } 1772 1773 /* for imprecise ending just do default erp */ 1774 if (sense[1] & 0x01) { 1775 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1776 "Imprecise ending is set - just retry"); 1777 1778 previous_erp->status = DASD_CQR_FILLED; 1779 1780 return previous_erp; 1781 } 1782 1783 /* determine the address of the CCW to be restarted */ 1784 /* Imprecise ending is not set -> addr from IRB-SCSW */ 1785 cpa = previous_erp->irb.scsw.cmd.cpa; 1786 1787 if (cpa == 0) { 1788 /* internal error 02 - 1789 Unable to determine address of the CCW to be restarted */ 1790 dev_err(&device->cdev->dev, "An error occurred in the DASD " 1791 "device driver, reason=%s\n", "02"); 1792 1793 previous_erp->status = DASD_CQR_FAILED; 1794 1795 return previous_erp; 1796 } 1797 1798 erp = previous_erp; 1799 1800 /* update the LO with the new returned sense data */ 1801 LO_data = erp->data + sizeof(struct DE_eckd_data); 1802 1803 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) { 1804 /* should not happen */ 1805 previous_erp->status = DASD_CQR_FAILED; 1806 1807 return previous_erp; 1808 } 1809 1810 if ((sense[7] & 0x3F) == 0x01) { 1811 /* operation code is WRITE DATA -> data area orientation */ 1812 LO_data[0] = 0x81; 1813 1814 } else if ((sense[7] & 0x3F) == 0x03) { 1815 /* operation code is FORMAT WRITE -> index orientation */ 1816 LO_data[0] = 0xC3; 1817 1818 } else { 1819 LO_data[0] = sense[7]; /* operation */ 1820 } 1821 1822 LO_data[1] = sense[8]; /* auxiliary */ 1823 LO_data[2] = sense[9]; 1824 LO_data[3] = sense[3]; /* count */ 1825 LO_data[4] = sense[29]; /* seek_addr.cyl */ 1826 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */ 1827 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */ 1828 1829 memcpy(&(LO_data[8]), &(sense[11]), 8); 1830 1831 /* TIC to the failed ccw */ 1832 ccw = erp->cpaddr; /* addr of DE ccw */ 1833 ccw++; /* addr of LE ccw */ 1834 ccw++; /* addr of TIC ccw */ 1835 ccw->cda = cpa; 1836 1837 erp->status = DASD_CQR_FILLED; 1838 1839 return erp; 1840 1841} /* end dasd_3990_update_1B */ 1842 1843/* 1844 * DASD_3990_ERP_COMPOUND_RETRY 1845 * 1846 * DESCRIPTION 1847 * Handles the compound ERP action retry code. 1848 * NOTE: At least one retry is done even if zero is specified 1849 * by the sense data. This makes enqueueing of the request 1850 * easier. 1851 * 1852 * PARAMETER 1853 * sense sense data of the actual error 1854 * erp pointer to the currently created ERP 1855 * 1856 * RETURN VALUES 1857 * erp modified ERP pointer 1858 * 1859 */ 1860static void 1861dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense) 1862{ 1863 1864 switch (sense[25] & 0x03) { 1865 case 0x00: /* no not retry */ 1866 erp->retries = 1; 1867 break; 1868 1869 case 0x01: /* retry 2 times */ 1870 erp->retries = 2; 1871 break; 1872 1873 case 0x02: /* retry 10 times */ 1874 erp->retries = 10; 1875 break; 1876 1877 case 0x03: /* retry 256 times */ 1878 erp->retries = 256; 1879 break; 1880 1881 default: 1882 BUG(); 1883 } 1884 1885 erp->function = dasd_3990_erp_compound_retry; 1886 1887} /* end dasd_3990_erp_compound_retry */ 1888 1889/* 1890 * DASD_3990_ERP_COMPOUND_PATH 1891 * 1892 * DESCRIPTION 1893 * Handles the compound ERP action for retry on alternate 1894 * channel path. 1895 * 1896 * PARAMETER 1897 * sense sense data of the actual error 1898 * erp pointer to the currently created ERP 1899 * 1900 * RETURN VALUES 1901 * erp modified ERP pointer 1902 * 1903 */ 1904static void 1905dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense) 1906{ 1907 1908 if (sense[25] & DASD_SENSE_BIT_3) { 1909 dasd_3990_erp_alternate_path(erp); 1910 1911 if (erp->status == DASD_CQR_FAILED) { 1912 /* reset the lpm and the status to be able to 1913 * try further actions. */ 1914 1915 erp->lpm = 0; 1916 erp->status = DASD_CQR_NEED_ERP; 1917 } 1918 } 1919 1920 erp->function = dasd_3990_erp_compound_path; 1921 1922} /* end dasd_3990_erp_compound_path */ 1923 1924/* 1925 * DASD_3990_ERP_COMPOUND_CODE 1926 * 1927 * DESCRIPTION 1928 * Handles the compound ERP action for retry code. 1929 * 1930 * PARAMETER 1931 * sense sense data of the actual error 1932 * erp pointer to the currently created ERP 1933 * 1934 * RETURN VALUES 1935 * erp NEW ERP pointer 1936 * 1937 */ 1938static struct dasd_ccw_req * 1939dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense) 1940{ 1941 1942 if (sense[25] & DASD_SENSE_BIT_2) { 1943 1944 switch (sense[28]) { 1945 case 0x17: 1946 /* issue a Diagnostic Control command with an 1947 * Inhibit Write subcommand and controller modifier */ 1948 erp = dasd_3990_erp_DCTL(erp, 0x20); 1949 break; 1950 1951 case 0x25: 1952 /* wait for 5 seconds and retry again */ 1953 erp->retries = 1; 1954 1955 dasd_3990_erp_block_queue (erp, 5*HZ); 1956 break; 1957 1958 default: 1959 /* should not happen - continue */ 1960 break; 1961 } 1962 } 1963 1964 erp->function = dasd_3990_erp_compound_code; 1965 1966 return erp; 1967 1968} /* end dasd_3990_erp_compound_code */ 1969 1970/* 1971 * DASD_3990_ERP_COMPOUND_CONFIG 1972 * 1973 * DESCRIPTION 1974 * Handles the compound ERP action for configruation 1975 * dependent error. 1976 * Note: duplex handling is not implemented (yet). 1977 * 1978 * PARAMETER 1979 * sense sense data of the actual error 1980 * erp pointer to the currently created ERP 1981 * 1982 * RETURN VALUES 1983 * erp modified ERP pointer 1984 * 1985 */ 1986static void 1987dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense) 1988{ 1989 1990 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) { 1991 1992 /* set to suspended duplex state then restart 1993 internal error 05 - Set device to suspended duplex state 1994 should be done */ 1995 struct dasd_device *device = erp->startdev; 1996 dev_err(&device->cdev->dev, 1997 "An error occurred in the DASD device driver, " 1998 "reason=%s\n", "05"); 1999 2000 } 2001 2002 erp->function = dasd_3990_erp_compound_config; 2003 2004} /* end dasd_3990_erp_compound_config */ 2005 2006/* 2007 * DASD_3990_ERP_COMPOUND 2008 * 2009 * DESCRIPTION 2010 * Does the further compound program action if 2011 * compound retry was not successful. 2012 * 2013 * PARAMETER 2014 * sense sense data of the actual error 2015 * erp pointer to the current (failed) ERP 2016 * 2017 * RETURN VALUES 2018 * erp (additional) ERP pointer 2019 * 2020 */ 2021static struct dasd_ccw_req * 2022dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense) 2023{ 2024 2025 if ((erp->function == dasd_3990_erp_compound_retry) && 2026 (erp->status == DASD_CQR_NEED_ERP)) { 2027 2028 dasd_3990_erp_compound_path(erp, sense); 2029 } 2030 2031 if ((erp->function == dasd_3990_erp_compound_path) && 2032 (erp->status == DASD_CQR_NEED_ERP)) { 2033 2034 erp = dasd_3990_erp_compound_code(erp, sense); 2035 } 2036 2037 if ((erp->function == dasd_3990_erp_compound_code) && 2038 (erp->status == DASD_CQR_NEED_ERP)) { 2039 2040 dasd_3990_erp_compound_config(erp, sense); 2041 } 2042 2043 /* if no compound action ERP specified, the request failed */ 2044 if (erp->status == DASD_CQR_NEED_ERP) 2045 erp->status = DASD_CQR_FAILED; 2046 2047 return erp; 2048 2049} /* end dasd_3990_erp_compound */ 2050 2051/* 2052 *DASD_3990_ERP_HANDLE_SIM 2053 * 2054 *DESCRIPTION 2055 * inspects the SIM SENSE data and starts an appropriate action 2056 * 2057 * PARAMETER 2058 * sense sense data of the actual error 2059 * 2060 * RETURN VALUES 2061 * none 2062 */ 2063void 2064dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense) 2065{ 2066 /* print message according to log or message to operator mode */ 2067 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) { 2068 /* print SIM SRC from RefCode */ 2069 dev_err(&device->cdev->dev, "SIM - SRC: " 2070 "%02x%02x%02x%02x\n", sense[22], 2071 sense[23], sense[11], sense[12]); 2072 } else if (sense[24] & DASD_SIM_LOG) { 2073 /* print SIM SRC Refcode */ 2074 dev_warn(&device->cdev->dev, "log SIM - SRC: " 2075 "%02x%02x%02x%02x\n", sense[22], 2076 sense[23], sense[11], sense[12]); 2077 } 2078} 2079 2080/* 2081 * DASD_3990_ERP_INSPECT_32 2082 * 2083 * DESCRIPTION 2084 * Does a detailed inspection of the 32 byte sense data 2085 * and sets up a related error recovery action. 2086 * 2087 * PARAMETER 2088 * sense sense data of the actual error 2089 * erp pointer to the currently created default ERP 2090 * 2091 * RETURN VALUES 2092 * erp_filled pointer to the ERP 2093 * 2094 */ 2095static struct dasd_ccw_req * 2096dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense) 2097{ 2098 2099 struct dasd_device *device = erp->startdev; 2100 2101 erp->function = dasd_3990_erp_inspect_32; 2102 2103 /* check for SIM sense data */ 2104 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE) 2105 dasd_3990_erp_handle_sim(device, sense); 2106 2107 if (sense[25] & DASD_SENSE_BIT_0) { 2108 2109 /* compound program action codes (byte25 bit 0 == '1') */ 2110 dasd_3990_erp_compound_retry(erp, sense); 2111 2112 } else { 2113 2114 /* single program action codes (byte25 bit 0 == '0') */ 2115 switch (sense[25]) { 2116 2117 case 0x00: /* success - use default ERP for retries */ 2118 DBF_DEV_EVENT(DBF_DEBUG, device, "%s", 2119 "ERP called for successful request" 2120 " - just retry"); 2121 break; 2122 2123 case 0x01: /* fatal error */ 2124 dev_err(&device->cdev->dev, 2125 "ERP failed for the DASD\n"); 2126 2127 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 2128 break; 2129 2130 case 0x02: /* intervention required */ 2131 case 0x03: /* intervention required during dual copy */ 2132 erp = dasd_3990_erp_int_req(erp); 2133 break; 2134 2135 case 0x0F: /* length mismatch during update write command 2136 internal error 08 - update write command error*/ 2137 dev_err(&device->cdev->dev, "An error occurred in the " 2138 "DASD device driver, reason=%s\n", "08"); 2139 2140 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 2141 break; 2142 2143 case 0x10: /* logging required for other channel program */ 2144 erp = dasd_3990_erp_action_10_32(erp, sense); 2145 break; 2146 2147 case 0x15: /* next track outside defined extend 2148 internal error 07 - The next track is not 2149 within the defined storage extent */ 2150 dev_err(&device->cdev->dev, 2151 "An error occurred in the DASD device driver, " 2152 "reason=%s\n", "07"); 2153 2154 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED); 2155 break; 2156 2157 case 0x1B: /* unexpected condition during write */ 2158 2159 erp = dasd_3990_erp_action_1B_32(erp, sense); 2160 break; 2161 2162 case 0x1C: /* invalid data */ 2163 dev_emerg(&device->cdev->dev, 2164 "Data recovered during retry with PCI " 2165 "fetch mode active\n"); 2166 2167 /* not possible to handle this situation in Linux */ 2168 panic 2169 ("Invalid data - No way to inform application " 2170 "about the possibly incorrect data"); 2171 break; 2172 2173 case 0x1D: /* state-change pending */ 2174 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 2175 "A State change pending condition exists " 2176 "for the subsystem or device"); 2177 2178 erp = dasd_3990_erp_action_4(erp, sense); 2179 break; 2180 2181 case 0x1E: /* busy */ 2182 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 2183 "Busy condition exists " 2184 "for the subsystem or device"); 2185 erp = dasd_3990_erp_action_4(erp, sense); 2186 break; 2187 2188 default: /* all others errors - default erp */ 2189 break; 2190 } 2191 } 2192 2193 return erp; 2194 2195} /* end dasd_3990_erp_inspect_32 */ 2196 2197/* 2198 ***************************************************************************** 2199 * main ERP control fuctions (24 and 32 byte sense) 2200 ***************************************************************************** 2201 */ 2202 2203/* 2204 * DASD_3990_ERP_CONTROL_CHECK 2205 * 2206 * DESCRIPTION 2207 * Does a generic inspection if a control check occured and sets up 2208 * the related error recovery procedure 2209 * 2210 * PARAMETER 2211 * erp pointer to the currently created default ERP 2212 * 2213 * RETURN VALUES 2214 * erp_filled pointer to the erp 2215 */ 2216 2217static struct dasd_ccw_req * 2218dasd_3990_erp_control_check(struct dasd_ccw_req *erp) 2219{ 2220 struct dasd_device *device = erp->startdev; 2221 2222 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK 2223 | SCHN_STAT_CHN_CTRL_CHK)) { 2224 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 2225 "channel or interface control check"); 2226 erp = dasd_3990_erp_action_4(erp, NULL); 2227 } 2228 return erp; 2229} 2230 2231/* 2232 * DASD_3990_ERP_INSPECT 2233 * 2234 * DESCRIPTION 2235 * Does a detailed inspection for sense data by calling either 2236 * the 24-byte or the 32-byte inspection routine. 2237 * 2238 * PARAMETER 2239 * erp pointer to the currently created default ERP 2240 * RETURN VALUES 2241 * erp_new contens was possibly modified 2242 */ 2243static struct dasd_ccw_req * 2244dasd_3990_erp_inspect(struct dasd_ccw_req *erp) 2245{ 2246 2247 struct dasd_ccw_req *erp_new = NULL; 2248 char *sense; 2249 2250 /* if this problem occured on an alias retry on base */ 2251 erp_new = dasd_3990_erp_inspect_alias(erp); 2252 if (erp_new) 2253 return erp_new; 2254 2255 /* sense data are located in the refers record of the 2256 * already set up new ERP ! 2257 * check if concurrent sens is available 2258 */ 2259 sense = dasd_get_sense(&erp->refers->irb); 2260 if (!sense) 2261 erp_new = dasd_3990_erp_control_check(erp); 2262 /* distinguish between 24 and 32 byte sense data */ 2263 else if (sense[27] & DASD_SENSE_BIT_0) { 2264 2265 /* inspect the 24 byte sense data */ 2266 erp_new = dasd_3990_erp_inspect_24(erp, sense); 2267 2268 } else { 2269 2270 /* inspect the 32 byte sense data */ 2271 erp_new = dasd_3990_erp_inspect_32(erp, sense); 2272 2273 } /* end distinguish between 24 and 32 byte sense data */ 2274 2275 return erp_new; 2276} 2277 2278/* 2279 * DASD_3990_ERP_ADD_ERP 2280 * 2281 * DESCRIPTION 2282 * This funtion adds an additional request block (ERP) to the head of 2283 * the given cqr (or erp). 2284 * For a command mode cqr the erp is initialized as an default erp 2285 * (retry TIC). 2286 * For transport mode we make a copy of the original TCW (points to 2287 * the original TCCB, TIDALs, etc.) but give it a fresh 2288 * TSB so the original sense data will not be changed. 2289 * 2290 * PARAMETER 2291 * cqr head of the current ERP-chain (or single cqr if 2292 * first error) 2293 * RETURN VALUES 2294 * erp pointer to new ERP-chain head 2295 */ 2296static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr) 2297{ 2298 2299 struct dasd_device *device = cqr->startdev; 2300 struct ccw1 *ccw; 2301 struct dasd_ccw_req *erp; 2302 int cplength, datasize; 2303 struct tcw *tcw; 2304 struct tsb *tsb; 2305 2306 if (cqr->cpmode == 1) { 2307 cplength = 0; 2308 /* TCW needs to be 64 byte aligned, so leave enough room */ 2309 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb); 2310 } else { 2311 cplength = 2; 2312 datasize = 0; 2313 } 2314 2315 /* allocate additional request block */ 2316 erp = dasd_alloc_erp_request((char *) &cqr->magic, 2317 cplength, datasize, device); 2318 if (IS_ERR(erp)) { 2319 if (cqr->retries <= 0) { 2320 DBF_DEV_EVENT(DBF_ERR, device, "%s", 2321 "Unable to allocate ERP request"); 2322 cqr->status = DASD_CQR_FAILED; 2323 cqr->stopclk = get_clock (); 2324 } else { 2325 DBF_DEV_EVENT(DBF_ERR, device, 2326 "Unable to allocate ERP request " 2327 "(%i retries left)", 2328 cqr->retries); 2329 dasd_block_set_timer(device->block, (HZ << 3)); 2330 } 2331 return erp; 2332 } 2333 2334 ccw = cqr->cpaddr; 2335 if (cqr->cpmode == 1) { 2336 /* make a shallow copy of the original tcw but set new tsb */ 2337 erp->cpmode = 1; 2338 erp->cpaddr = PTR_ALIGN(erp->data, 64); 2339 tcw = erp->cpaddr; 2340 tsb = (struct tsb *) &tcw[1]; 2341 *tcw = *((struct tcw *)cqr->cpaddr); 2342 tcw->tsb = (long)tsb; 2343 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) { 2344 /* PSF cannot be chained from NOOP/TIC */ 2345 erp->cpaddr = cqr->cpaddr; 2346 } else { 2347 /* initialize request with default TIC to current ERP/CQR */ 2348 ccw = erp->cpaddr; 2349 ccw->cmd_code = CCW_CMD_NOOP; 2350 ccw->flags = CCW_FLAG_CC; 2351 ccw++; 2352 ccw->cmd_code = CCW_CMD_TIC; 2353 ccw->cda = (long)(cqr->cpaddr); 2354 } 2355 2356 erp->function = dasd_3990_erp_add_erp; 2357 erp->refers = cqr; 2358 erp->startdev = device; 2359 erp->memdev = device; 2360 erp->block = cqr->block; 2361 erp->magic = cqr->magic; 2362 erp->expires = 0; 2363 erp->retries = 256; 2364 erp->buildclk = get_clock(); 2365 erp->status = DASD_CQR_FILLED; 2366 2367 return erp; 2368} 2369 2370/* 2371 * DASD_3990_ERP_ADDITIONAL_ERP 2372 * 2373 * DESCRIPTION 2374 * An additional ERP is needed to handle the current error. 2375 * Add ERP to the head of the ERP-chain containing the ERP processing 2376 * determined based on the sense data. 2377 * 2378 * PARAMETER 2379 * cqr head of the current ERP-chain (or single cqr if 2380 * first error) 2381 * 2382 * RETURN VALUES 2383 * erp pointer to new ERP-chain head 2384 */ 2385static struct dasd_ccw_req * 2386dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr) 2387{ 2388 2389 struct dasd_ccw_req *erp = NULL; 2390 2391 /* add erp and initialize with default TIC */ 2392 erp = dasd_3990_erp_add_erp(cqr); 2393 2394 if (IS_ERR(erp)) 2395 return erp; 2396 2397 /* inspect sense, determine specific ERP if possible */ 2398 if (erp != cqr) { 2399 2400 erp = dasd_3990_erp_inspect(erp); 2401 } 2402 2403 return erp; 2404 2405} /* end dasd_3990_erp_additional_erp */ 2406 2407/* 2408 * DASD_3990_ERP_ERROR_MATCH 2409 * 2410 * DESCRIPTION 2411 * Check if the device status of the given cqr is the same. 2412 * This means that the failed CCW and the relevant sense data 2413 * must match. 2414 * I don't distinguish between 24 and 32 byte sense because in case of 2415 * 24 byte sense byte 25 and 27 is set as well. 2416 * 2417 * PARAMETER 2418 * cqr1 first cqr, which will be compared with the 2419 * cqr2 second cqr. 2420 * 2421 * RETURN VALUES 2422 * match 'boolean' for match found 2423 * returns 1 if match found, otherwise 0. 2424 */ 2425static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, 2426 struct dasd_ccw_req *cqr2) 2427{ 2428 char *sense1, *sense2; 2429 2430 if (cqr1->startdev != cqr2->startdev) 2431 return 0; 2432 2433 sense1 = dasd_get_sense(&cqr1->irb); 2434 sense2 = dasd_get_sense(&cqr2->irb); 2435 2436 /* one request has sense data, the other not -> no match, return 0 */ 2437 if (!sense1 != !sense2) 2438 return 0; 2439 /* no sense data in both cases -> check cstat for IFCC */ 2440 if (!sense1 && !sense2) { 2441 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK | 2442 SCHN_STAT_CHN_CTRL_CHK)) == 2443 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK | 2444 SCHN_STAT_CHN_CTRL_CHK))) 2445 return 1; /* match with ifcc*/ 2446 } 2447 /* check sense data; byte 0-2,25,27 */ 2448 if (!(sense1 && sense2 && 2449 (memcmp(sense1, sense2, 3) == 0) && 2450 (sense1[27] == sense2[27]) && 2451 (sense1[25] == sense2[25]))) { 2452 2453 return 0; /* sense doesn't match */ 2454 } 2455 2456 return 1; /* match */ 2457 2458} /* end dasd_3990_erp_error_match */ 2459 2460/* 2461 * DASD_3990_ERP_IN_ERP 2462 * 2463 * DESCRIPTION 2464 * check if the current error already happened before. 2465 * quick exit if current cqr is not an ERP (cqr->refers=NULL) 2466 * 2467 * PARAMETER 2468 * cqr failed cqr (either original cqr or already an erp) 2469 * 2470 * RETURN VALUES 2471 * erp erp-pointer to the already defined error 2472 * recovery procedure OR 2473 * NULL if a 'new' error occurred. 2474 */ 2475static struct dasd_ccw_req * 2476dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr) 2477{ 2478 2479 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */ 2480 *erp_match = NULL; /* save erp chain head */ 2481 int match = 0; /* 'boolean' for matching error found */ 2482 2483 if (cqr->refers == NULL) { /* return if not in erp */ 2484 return NULL; 2485 } 2486 2487 /* check the erp/cqr chain for current error */ 2488 do { 2489 match = dasd_3990_erp_error_match(erp_head, cqr->refers); 2490 erp_match = cqr; /* save possible matching erp */ 2491 cqr = cqr->refers; /* check next erp/cqr in queue */ 2492 2493 } while ((cqr->refers != NULL) && (!match)); 2494 2495 if (!match) { 2496 return NULL; /* no match was found */ 2497 } 2498 2499 return erp_match; /* return address of matching erp */ 2500 2501} /* END dasd_3990_erp_in_erp */ 2502 2503/* 2504 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense) 2505 * 2506 * DESCRIPTION 2507 * No retry is left for the current ERP. Check what has to be done 2508 * with the ERP. 2509 * - do further defined ERP action or 2510 * - wait for interrupt or 2511 * - exit with permanent error 2512 * 2513 * PARAMETER 2514 * erp ERP which is in progress with no retry left 2515 * 2516 * RETURN VALUES 2517 * erp modified/additional ERP 2518 */ 2519static struct dasd_ccw_req * 2520dasd_3990_erp_further_erp(struct dasd_ccw_req *erp) 2521{ 2522 2523 struct dasd_device *device = erp->startdev; 2524 char *sense = dasd_get_sense(&erp->irb); 2525 2526 /* check for 24 byte sense ERP */ 2527 if ((erp->function == dasd_3990_erp_bus_out) || 2528 (erp->function == dasd_3990_erp_action_1) || 2529 (erp->function == dasd_3990_erp_action_4)) { 2530 2531 erp = dasd_3990_erp_action_1(erp); 2532 2533 } else if (erp->function == dasd_3990_erp_action_1_sec) { 2534 erp = dasd_3990_erp_action_1_sec(erp); 2535 } else if (erp->function == dasd_3990_erp_action_5) { 2536 2537 /* retries have not been successful */ 2538 /* prepare erp for retry on different channel path */ 2539 erp = dasd_3990_erp_action_1(erp); 2540 2541 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) { 2542 2543 /* issue a Diagnostic Control command with an 2544 * Inhibit Write subcommand */ 2545 2546 switch (sense[25]) { 2547 case 0x17: 2548 case 0x57:{ /* controller */ 2549 erp = dasd_3990_erp_DCTL(erp, 0x20); 2550 break; 2551 } 2552 case 0x18: 2553 case 0x58:{ /* channel path */ 2554 erp = dasd_3990_erp_DCTL(erp, 0x40); 2555 break; 2556 } 2557 case 0x19: 2558 case 0x59:{ /* storage director */ 2559 erp = dasd_3990_erp_DCTL(erp, 0x80); 2560 break; 2561 } 2562 default: 2563 DBF_DEV_EVENT(DBF_WARNING, device, 2564 "invalid subcommand modifier 0x%x " 2565 "for Diagnostic Control Command", 2566 sense[25]); 2567 } 2568 } 2569 2570 /* check for 32 byte sense ERP */ 2571 } else if (sense && 2572 ((erp->function == dasd_3990_erp_compound_retry) || 2573 (erp->function == dasd_3990_erp_compound_path) || 2574 (erp->function == dasd_3990_erp_compound_code) || 2575 (erp->function == dasd_3990_erp_compound_config))) { 2576 2577 erp = dasd_3990_erp_compound(erp, sense); 2578 2579 } else { 2580 /* 2581 * No retry left and no additional special handling 2582 * necessary 2583 */ 2584 dev_err(&device->cdev->dev, 2585 "ERP %p has run out of retries and failed\n", erp); 2586 2587 erp->status = DASD_CQR_FAILED; 2588 } 2589 2590 return erp; 2591 2592} /* end dasd_3990_erp_further_erp */ 2593 2594/* 2595 * DASD_3990_ERP_HANDLE_MATCH_ERP 2596 * 2597 * DESCRIPTION 2598 * An error occurred again and an ERP has been detected which is already 2599 * used to handle this error (e.g. retries). 2600 * All prior ERP's are asumed to be successful and therefore removed 2601 * from queue. 2602 * If retry counter of matching erp is already 0, it is checked if further 2603 * action is needed (besides retry) or if the ERP has failed. 2604 * 2605 * PARAMETER 2606 * erp_head first ERP in ERP-chain 2607 * erp ERP that handles the actual error. 2608 * (matching erp) 2609 * 2610 * RETURN VALUES 2611 * erp modified/additional ERP 2612 */ 2613static struct dasd_ccw_req * 2614dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head, 2615 struct dasd_ccw_req *erp) 2616{ 2617 2618 struct dasd_device *device = erp_head->startdev; 2619 struct dasd_ccw_req *erp_done = erp_head; /* finished req */ 2620 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */ 2621 2622 /* loop over successful ERPs and remove them from chanq */ 2623 while (erp_done != erp) { 2624 2625 if (erp_done == NULL) /* end of chain reached */ 2626 panic(PRINTK_HEADER "Programming error in ERP! The " 2627 "original request was lost\n"); 2628 2629 /* remove the request from the device queue */ 2630 list_del(&erp_done->blocklist); 2631 2632 erp_free = erp_done; 2633 erp_done = erp_done->refers; 2634 2635 /* free the finished erp request */ 2636 dasd_free_erp_request(erp_free, erp_free->memdev); 2637 2638 } /* end while */ 2639 2640 if (erp->retries > 0) { 2641 2642 char *sense = dasd_get_sense(&erp->refers->irb); 2643 2644 /* check for special retries */ 2645 if (sense && erp->function == dasd_3990_erp_action_4) { 2646 2647 erp = dasd_3990_erp_action_4(erp, sense); 2648 2649 } else if (sense && 2650 erp->function == dasd_3990_erp_action_1B_32) { 2651 2652 erp = dasd_3990_update_1B(erp, sense); 2653 2654 } else if (sense && erp->function == dasd_3990_erp_int_req) { 2655 2656 erp = dasd_3990_erp_int_req(erp); 2657 2658 } else { 2659 /* simple retry */ 2660 DBF_DEV_EVENT(DBF_DEBUG, device, 2661 "%i retries left for erp %p", 2662 erp->retries, erp); 2663 2664 /* handle the request again... */ 2665 erp->status = DASD_CQR_FILLED; 2666 } 2667 2668 } else { 2669 /* no retry left - check for further necessary action */ 2670 /* if no further actions, handle rest as permanent error */ 2671 erp = dasd_3990_erp_further_erp(erp); 2672 } 2673 2674 return erp; 2675 2676} /* end dasd_3990_erp_handle_match_erp */ 2677 2678/* 2679 * DASD_3990_ERP_ACTION 2680 * 2681 * DESCRIPTION 2682 * control routine for 3990 erp actions. 2683 * Has to be called with the queue lock (namely the s390_irq_lock) acquired. 2684 * 2685 * PARAMETER 2686 * cqr failed cqr (either original cqr or already an erp) 2687 * 2688 * RETURN VALUES 2689 * erp erp-pointer to the head of the ERP action chain. 2690 * This means: 2691 * - either a ptr to an additional ERP cqr or 2692 * - the original given cqr (which's status might 2693 * be modified) 2694 */ 2695struct dasd_ccw_req * 2696dasd_3990_erp_action(struct dasd_ccw_req * cqr) 2697{ 2698 struct dasd_ccw_req *erp = NULL; 2699 struct dasd_device *device = cqr->startdev; 2700 struct dasd_ccw_req *temp_erp = NULL; 2701 2702 if (device->features & DASD_FEATURE_ERPLOG) { 2703 /* print current erp_chain */ 2704 dev_err(&device->cdev->dev, 2705 "ERP chain at BEGINNING of ERP-ACTION\n"); 2706 for (temp_erp = cqr; 2707 temp_erp != NULL; temp_erp = temp_erp->refers) { 2708 2709 dev_err(&device->cdev->dev, 2710 "ERP %p (%02x) refers to %p\n", 2711 temp_erp, temp_erp->status, 2712 temp_erp->refers); 2713 } 2714 } 2715 2716 /* double-check if current erp/cqr was successful */ 2717 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) && 2718 (scsw_dstat(&cqr->irb.scsw) == 2719 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) { 2720 2721 DBF_DEV_EVENT(DBF_DEBUG, device, 2722 "ERP called for successful request %p" 2723 " - NO ERP necessary", cqr); 2724 2725 cqr->status = DASD_CQR_DONE; 2726 2727 return cqr; 2728 } 2729 2730 /* check if error happened before */ 2731 erp = dasd_3990_erp_in_erp(cqr); 2732 2733 if (erp == NULL) { 2734 /* no matching erp found - set up erp */ 2735 erp = dasd_3990_erp_additional_erp(cqr); 2736 if (IS_ERR(erp)) 2737 return erp; 2738 } else { 2739 /* matching erp found - set all leading erp's to DONE */ 2740 erp = dasd_3990_erp_handle_match_erp(cqr, erp); 2741 } 2742 2743 if (device->features & DASD_FEATURE_ERPLOG) { 2744 /* print current erp_chain */ 2745 dev_err(&device->cdev->dev, 2746 "ERP chain at END of ERP-ACTION\n"); 2747 for (temp_erp = erp; 2748 temp_erp != NULL; temp_erp = temp_erp->refers) { 2749 2750 dev_err(&device->cdev->dev, 2751 "ERP %p (%02x) refers to %p\n", 2752 temp_erp, temp_erp->status, 2753 temp_erp->refers); 2754 } 2755 } 2756 2757 /* enqueue ERP request if it's a new one */ 2758 if (list_empty(&erp->blocklist)) { 2759 cqr->status = DASD_CQR_IN_ERP; 2760 /* add erp request before the cqr */ 2761 list_add_tail(&erp->blocklist, &cqr->blocklist); 2762 } 2763 2764 2765 2766 return erp; 2767 2768} /* end dasd_3990_erp_action */ 2769