Merge with Linux 2.5.74.
[linux-2.6/linux-mips.git] / drivers / s390 / block / dasd_3990_erp.c
blobbecb1e8c495cd95192df6e9a4b74c603ec104b41
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
8 * $Revision: 1.25 $
9 */
11 #include <linux/timer.h>
12 #include <linux/slab.h>
13 #include <asm/idals.h>
14 #include <asm/todclk.h>
16 #define PRINTK_HEADER "dasd_erp(3990): "
18 #include "dasd_int.h"
19 #include "dasd_eckd.h"
22 struct DCTL_data {
23 unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
24 unsigned char modifier; /* Subcommand modifier */
25 unsigned short res; /* reserved */
26 } __attribute__ ((packed));
29 *****************************************************************************
30 * SECTION ERP EXAMINATION
31 *****************************************************************************
35 * DASD_3990_ERP_EXAMINE_24
37 * DESCRIPTION
38 * Checks only for fatal (unrecoverable) error.
39 * A detailed examination of the sense data is done later outside
40 * the interrupt handler.
42 * Each bit configuration leading to an action code 2 (Exit with
43 * programming error or unusual condition indication)
44 * are handled as fatal errorĀ“s.
46 * All other configurations are handled as recoverable errors.
48 * RETURN VALUES
49 * dasd_era_fatal for all fatal (unrecoverable errors)
50 * dasd_era_recover for all others.
52 static dasd_era_t
53 dasd_3990_erp_examine_24(struct dasd_ccw_req * cqr, char *sense)
56 struct dasd_device *device = cqr->device;
58 /* check for 'Command Reject' */
59 if ((sense[0] & SNS0_CMD_REJECT) &&
60 (!(sense[2] & SNS2_ENV_DATA_PRESENT))) {
62 DEV_MESSAGE(KERN_ERR, device, "%s",
63 "EXAMINE 24: Command Reject detected - "
64 "fatal error");
66 return dasd_era_fatal;
69 /* check for 'Invalid Track Format' */
70 if ((sense[1] & SNS1_INV_TRACK_FORMAT) &&
71 (!(sense[2] & SNS2_ENV_DATA_PRESENT))) {
73 DEV_MESSAGE(KERN_ERR, device, "%s",
74 "EXAMINE 24: Invalid Track Format detected "
75 "- fatal error");
77 return dasd_era_fatal;
80 /* check for 'No Record Found' */
81 if (sense[1] & SNS1_NO_REC_FOUND) {
83 /* FIXME: fatal error ?!? */
84 DEV_MESSAGE(KERN_ERR, device,
85 "EXAMINE 24: No Record Found detected %s",
86 device->state <= DASD_STATE_BASIC ?
87 " " : "- fatal error");
89 return dasd_era_fatal;
92 /* return recoverable for all others */
93 return dasd_era_recover;
94 } /* END dasd_3990_erp_examine_24 */
97 * DASD_3990_ERP_EXAMINE_32
99 * DESCRIPTION
100 * Checks only for fatal/no/recoverable error.
101 * A detailed examination of the sense data is done later outside
102 * the interrupt handler.
104 * RETURN VALUES
105 * dasd_era_none no error
106 * dasd_era_fatal for all fatal (unrecoverable errors)
107 * dasd_era_recover for recoverable others.
109 static dasd_era_t
110 dasd_3990_erp_examine_32(struct dasd_ccw_req * cqr, char *sense)
113 struct dasd_device *device = cqr->device;
115 switch (sense[25]) {
116 case 0x00:
117 return dasd_era_none;
119 case 0x01:
120 DEV_MESSAGE(KERN_ERR, device, "%s", "EXAMINE 32: fatal error");
122 return dasd_era_fatal;
124 default:
126 return dasd_era_recover;
129 } /* end dasd_3990_erp_examine_32 */
132 * DASD_3990_ERP_EXAMINE
134 * DESCRIPTION
135 * Checks only for fatal/no/recover error.
136 * A detailed examination of the sense data is done later outside
137 * the interrupt handler.
139 * The logic is based on the 'IBM 3990 Storage Control Reference' manual
140 * 'Chapter 7. Error Recovery Procedures'.
142 * RETURN VALUES
143 * dasd_era_none no error
144 * dasd_era_fatal for all fatal (unrecoverable errors)
145 * dasd_era_recover for all others.
147 dasd_era_t
148 dasd_3990_erp_examine(struct dasd_ccw_req * cqr, struct irb * irb)
151 char *sense = irb->ecw;
152 dasd_era_t era = dasd_era_recover;
153 struct dasd_device *device = cqr->device;
155 /* check for successful execution first */
156 if (irb->scsw.cstat == 0x00 &&
157 irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END))
158 return dasd_era_none;
160 /* distinguish between 24 and 32 byte sense data */
161 if (sense[27] & DASD_SENSE_BIT_0) {
163 era = dasd_3990_erp_examine_24(cqr, sense);
165 } else {
167 era = dasd_3990_erp_examine_32(cqr, sense);
171 /* log the erp chain if fatal error occurred */
172 if ((era == dasd_era_fatal) && (device->state >= DASD_STATE_READY)) {
173 dasd_log_sense(cqr, irb);
174 dasd_log_ccw(cqr, 0, irb->scsw.cpa);
177 return era;
179 } /* END dasd_3990_erp_examine */
182 *****************************************************************************
183 * SECTION ERP HANDLING
184 *****************************************************************************
187 *****************************************************************************
188 * 24 and 32 byte sense ERP functions
189 *****************************************************************************
193 * DASD_3990_ERP_CLEANUP
195 * DESCRIPTION
196 * Removes the already build but not necessary ERP request and sets
197 * the status of the original cqr / erp to the given (final) status
199 * PARAMETER
200 * erp request to be blocked
201 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
203 * RETURN VALUES
204 * cqr original cqr
206 static struct dasd_ccw_req *
207 dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
209 struct dasd_ccw_req *cqr = erp->refers;
211 dasd_free_erp_request(erp, erp->device);
212 cqr->status = final_status;
213 return cqr;
215 } /* end dasd_3990_erp_cleanup */
218 * DASD_3990_ERP_BLOCK_QUEUE
220 * DESCRIPTION
221 * Block the given device request queue to prevent from further
222 * processing until the started timer has expired or an related
223 * interrupt was received.
225 static void
226 dasd_3990_erp_block_queue(struct dasd_ccw_req * erp, int expires)
229 struct dasd_device *device = erp->device;
231 DEV_MESSAGE(KERN_INFO, device,
232 "blocking request queue for %is", expires);
234 device->stopped |= DASD_STOPPED_PENDING;
235 erp->status = DASD_CQR_QUEUED;
237 dasd_set_timer(device, expires);
241 * DASD_3990_ERP_INT_REQ
243 * DESCRIPTION
244 * Handles 'Intervention Required' error.
245 * This means either device offline or not installed.
247 * PARAMETER
248 * erp current erp
249 * RETURN VALUES
250 * erp modified erp
252 static struct dasd_ccw_req *
253 dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
256 struct dasd_device *device = erp->device;
258 /* first time set initial retry counter and erp_function */
259 /* and retry once without blocking queue */
260 /* (this enables easier enqueing of the cqr) */
261 if (erp->function != dasd_3990_erp_int_req) {
263 erp->retries = 256;
264 erp->function = dasd_3990_erp_int_req;
266 } else {
268 /* issue a message and wait for 'device ready' interrupt */
269 DEV_MESSAGE(KERN_ERR, device, "%s",
270 "is offline or not installed - "
271 "INTERVENTION REQUIRED!!");
273 dasd_3990_erp_block_queue(erp, 60*HZ);
276 return erp;
278 } /* end dasd_3990_erp_int_req */
281 * DASD_3990_ERP_ALTERNATE_PATH
283 * DESCRIPTION
284 * Repeat the operation on a different channel path.
285 * If all alternate paths have been tried, the request is posted with a
286 * permanent error.
288 * PARAMETER
289 * erp pointer to the current ERP
291 * RETURN VALUES
292 * erp modified pointer to the ERP
294 static void
295 dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
297 struct dasd_device *device = erp->device;
298 __u8 opm;
300 /* try alternate valid path */
301 opm = ccw_device_get_path_mask(device->cdev);
302 //FIXME: start with get_opm ?
303 if (erp->lpm == 0)
304 erp->lpm = LPM_ANYPATH & ~(erp->dstat->esw.esw0.sublog.lpum);
305 else
306 erp->lpm &= ~(erp->dstat->esw.esw0.sublog.lpum);
308 if ((erp->lpm & opm) != 0x00) {
310 DEV_MESSAGE(KERN_DEBUG, device,
311 "try alternate lpm=%x (lpum=%x / opm=%x)",
312 erp->lpm, erp->dstat->esw.esw0.sublog.lpum, opm);
314 /* reset status to queued to handle the request again... */
315 erp->status = DASD_CQR_QUEUED;
316 erp->retries = 1;
317 } else {
318 DEV_MESSAGE(KERN_ERR, device,
319 "No alternate channel path left (lpum=%x / "
320 "opm=%x) -> permanent error",
321 erp->dstat->esw.esw0.sublog.lpum, opm);
323 /* post request with permanent error */
324 erp->status = DASD_CQR_FAILED;
326 } /* end dasd_3990_erp_alternate_path */
329 * DASD_3990_ERP_DCTL
331 * DESCRIPTION
332 * Setup cqr to do the Diagnostic Control (DCTL) command with an
333 * Inhibit Write subcommand (0x20) and the given modifier.
335 * PARAMETER
336 * erp pointer to the current (failed) ERP
337 * modifier subcommand modifier
339 * RETURN VALUES
340 * dctl_cqr pointer to NEW dctl_cqr
343 static struct dasd_ccw_req *
344 dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
347 struct dasd_device *device = erp->device;
348 struct DCTL_data *DCTL_data;
349 struct ccw1 *ccw;
350 struct dasd_ccw_req *dctl_cqr;
352 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
353 sizeof (struct DCTL_data),
354 erp->device);
355 if (IS_ERR(dctl_cqr)) {
356 DEV_MESSAGE(KERN_ERR, device, "%s",
357 "Unable to allocate DCTL-CQR");
358 erp->status = DASD_CQR_FAILED;
359 return erp;
362 DCTL_data = dctl_cqr->data;
364 DCTL_data->subcommand = 0x02; /* Inhibit Write */
365 DCTL_data->modifier = modifier;
367 ccw = dctl_cqr->cpaddr;
368 memset(ccw, 0, sizeof (struct ccw1));
369 ccw->cmd_code = CCW_CMD_DCTL;
370 ccw->count = 4;
371 ccw->cda = (__u32)(addr_t) DCTL_data;
372 dctl_cqr->function = dasd_3990_erp_DCTL;
373 dctl_cqr->refers = erp;
374 dctl_cqr->device = erp->device;
375 dctl_cqr->magic = erp->magic;
376 dctl_cqr->expires = 5 * 60 * HZ;
377 dctl_cqr->retries = 2;
379 dctl_cqr->buildclk = get_clock();
381 dctl_cqr->status = DASD_CQR_FILLED;
383 return dctl_cqr;
385 } /* end dasd_3990_erp_DCTL */
388 * DASD_3990_ERP_ACTION_1
390 * DESCRIPTION
391 * Setup ERP to do the ERP action 1 (see Reference manual).
392 * Repeat the operation on a different channel path.
393 * If all alternate paths have been tried, the request is posted with a
394 * permanent error.
395 * Note: duplex handling is not implemented (yet).
397 * PARAMETER
398 * erp pointer to the current ERP
400 * RETURN VALUES
401 * erp pointer to the ERP
404 static struct dasd_ccw_req *
405 dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
408 erp->function = dasd_3990_erp_action_1;
410 dasd_3990_erp_alternate_path(erp);
412 return erp;
414 } /* end dasd_3990_erp_action_1 */
417 * DASD_3990_ERP_ACTION_4
419 * DESCRIPTION
420 * Setup ERP to do the ERP action 4 (see Reference manual).
421 * Set the current request to PENDING to block the CQR queue for that device
422 * until the state change interrupt appears.
423 * Use a timer (20 seconds) to retry the cqr if the interrupt is still missing.
425 * PARAMETER
426 * sense sense data of the actual error
427 * erp pointer to the current ERP
429 * RETURN VALUES
430 * erp pointer to the ERP
433 static struct dasd_ccw_req *
434 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
437 struct dasd_device *device = erp->device;
439 /* first time set initial retry counter and erp_function */
440 /* and retry once without waiting for state change pending */
441 /* interrupt (this enables easier enqueing of the cqr) */
442 if (erp->function != dasd_3990_erp_action_4) {
444 erp->retries = 256;
445 erp->function = dasd_3990_erp_action_4;
447 } else {
449 if (sense[25] == 0x1D) { /* state change pending */
451 DEV_MESSAGE(KERN_INFO, device,
452 "waiting for state change pending "
453 "interrupt, %d retries left",
454 erp->retries);
456 dasd_3990_erp_block_queue(erp, 30*HZ);
458 } else {
460 /* no state change pending - retry */
461 DEV_MESSAGE (KERN_INFO, device,
462 "redriving request immediately, "
463 "%d retries left",
464 erp->retries);
465 erp->status = DASD_CQR_QUEUED;
469 return erp;
471 } /* end dasd_3990_erp_action_4 */
474 *****************************************************************************
475 * 24 byte sense ERP functions (only)
476 *****************************************************************************
480 * DASD_3990_ERP_ACTION_5
482 * DESCRIPTION
483 * Setup ERP to do the ERP action 5 (see Reference manual).
484 * NOTE: Further handling is done in xxx_further_erp after the retries.
486 * PARAMETER
487 * erp pointer to the current ERP
489 * RETURN VALUES
490 * erp pointer to the ERP
493 static struct dasd_ccw_req *
494 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
497 /* first of all retry */
498 erp->retries = 10;
499 erp->function = dasd_3990_erp_action_5;
501 return erp;
503 } /* end dasd_3990_erp_action_5 */
506 * DASD_3990_HANDLE_ENV_DATA
508 * DESCRIPTION
509 * Handles 24 byte 'Environmental data present'.
510 * Does a analysis of the sense data (message Format)
511 * and prints the error messages.
513 * PARAMETER
514 * sense current sense data
516 * RETURN VALUES
517 * void
519 static void
520 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
523 struct dasd_device *device = erp->device;
524 char msg_format = (sense[7] & 0xF0);
525 char msg_no = (sense[7] & 0x0F);
527 switch (msg_format) {
528 case 0x00: /* Format 0 - Program or System Checks */
530 if (sense[1] & 0x10) { /* check message to operator bit */
532 switch (msg_no) {
533 case 0x00: /* No Message */
534 break;
535 case 0x01:
536 DEV_MESSAGE(KERN_WARNING, device, "%s",
537 "FORMAT 0 - Invalid Command");
538 break;
539 case 0x02:
540 DEV_MESSAGE(KERN_WARNING, device, "%s",
541 "FORMAT 0 - Invalid Command "
542 "Sequence");
543 break;
544 case 0x03:
545 DEV_MESSAGE(KERN_WARNING, device, "%s",
546 "FORMAT 0 - CCW Count less than "
547 "required");
548 break;
549 case 0x04:
550 DEV_MESSAGE(KERN_WARNING, device, "%s",
551 "FORMAT 0 - Invalid Parameter");
552 break;
553 case 0x05:
554 DEV_MESSAGE(KERN_WARNING, device, "%s",
555 "FORMAT 0 - Diagnostic of Sepecial"
556 " Command Violates File Mask");
557 break;
558 case 0x07:
559 DEV_MESSAGE(KERN_WARNING, device, "%s",
560 "FORMAT 0 - Channel Returned with "
561 "Incorrect retry CCW");
562 break;
563 case 0x08:
564 DEV_MESSAGE(KERN_WARNING, device, "%s",
565 "FORMAT 0 - Reset Notification");
566 break;
567 case 0x09:
568 DEV_MESSAGE(KERN_WARNING, device, "%s",
569 "FORMAT 0 - Storage Path Restart");
570 break;
571 case 0x0A:
572 DEV_MESSAGE(KERN_WARNING, device,
573 "FORMAT 0 - Channel requested "
574 "... %02x", sense[8]);
575 break;
576 case 0x0B:
577 DEV_MESSAGE(KERN_WARNING, device, "%s",
578 "FORMAT 0 - Invalid Defective/"
579 "Alternate Track Pointer");
580 break;
581 case 0x0C:
582 DEV_MESSAGE(KERN_WARNING, device, "%s",
583 "FORMAT 0 - DPS Installation "
584 "Check");
585 break;
586 case 0x0E:
587 DEV_MESSAGE(KERN_WARNING, device, "%s",
588 "FORMAT 0 - Command Invalid on "
589 "Secondary Address");
590 break;
591 case 0x0F:
592 DEV_MESSAGE(KERN_WARNING, device,
593 "FORMAT 0 - Status Not As "
594 "Required: reason %02x", sense[8]);
595 break;
596 default:
597 DEV_MESSAGE(KERN_WARNING, device, "%s",
598 "FORMAT 0 - Reseved");
600 } else {
601 switch (msg_no) {
602 case 0x00: /* No Message */
603 break;
604 case 0x01:
605 DEV_MESSAGE(KERN_WARNING, device, "%s",
606 "FORMAT 0 - Device Error Source");
607 break;
608 case 0x02:
609 DEV_MESSAGE(KERN_WARNING, device, "%s",
610 "FORMAT 0 - Reserved");
611 break;
612 case 0x03:
613 DEV_MESSAGE(KERN_WARNING, device,
614 "FORMAT 0 - Device Fenced - "
615 "device = %02x", sense[4]);
616 break;
617 case 0x04:
618 DEV_MESSAGE(KERN_WARNING, device, "%s",
619 "FORMAT 0 - Data Pinned for "
620 "Device");
621 break;
622 default:
623 DEV_MESSAGE(KERN_WARNING, device, "%s",
624 "FORMAT 0 - Reserved");
627 break;
629 case 0x10: /* Format 1 - Device Equipment Checks */
630 switch (msg_no) {
631 case 0x00: /* No Message */
632 break;
633 case 0x01:
634 DEV_MESSAGE(KERN_WARNING, device, "%s",
635 "FORMAT 1 - Device Status 1 not as "
636 "expected");
637 break;
638 case 0x03:
639 DEV_MESSAGE(KERN_WARNING, device, "%s",
640 "FORMAT 1 - Index missing");
641 break;
642 case 0x04:
643 DEV_MESSAGE(KERN_WARNING, device, "%s",
644 "FORMAT 1 - Interruption cannot be reset");
645 break;
646 case 0x05:
647 DEV_MESSAGE(KERN_WARNING, device, "%s",
648 "FORMAT 1 - Device did not respond to "
649 "selection");
650 break;
651 case 0x06:
652 DEV_MESSAGE(KERN_WARNING, device, "%s",
653 "FORMAT 1 - Device check-2 error or Set "
654 "Sector is not complete");
655 break;
656 case 0x07:
657 DEV_MESSAGE(KERN_WARNING, device, "%s",
658 "FORMAT 1 - Head address does not "
659 "compare");
660 break;
661 case 0x08:
662 DEV_MESSAGE(KERN_WARNING, device, "%s",
663 "FORMAT 1 - Device status 1 not valid");
664 break;
665 case 0x09:
666 DEV_MESSAGE(KERN_WARNING, device, "%s",
667 "FORMAT 1 - Device not ready");
668 break;
669 case 0x0A:
670 DEV_MESSAGE(KERN_WARNING, device, "%s",
671 "FORMAT 1 - Track physical address did "
672 "not compare");
673 break;
674 case 0x0B:
675 DEV_MESSAGE(KERN_WARNING, device, "%s",
676 "FORMAT 1 - Missing device address bit");
677 break;
678 case 0x0C:
679 DEV_MESSAGE(KERN_WARNING, device, "%s",
680 "FORMAT 1 - Drive motor switch is off");
681 break;
682 case 0x0D:
683 DEV_MESSAGE(KERN_WARNING, device, "%s",
684 "FORMAT 1 - Seek incomplete");
685 break;
686 case 0x0E:
687 DEV_MESSAGE(KERN_WARNING, device, "%s",
688 "FORMAT 1 - Cylinder address did not "
689 "compare");
690 break;
691 case 0x0F:
692 DEV_MESSAGE(KERN_WARNING, device, "%s",
693 "FORMAT 1 - Offset active cannot be "
694 "reset");
695 break;
696 default:
697 DEV_MESSAGE(KERN_WARNING, device, "%s",
698 "FORMAT 1 - Reserved");
700 break;
702 case 0x20: /* Format 2 - 3990 Equipment Checks */
703 switch (msg_no) {
704 case 0x08:
705 DEV_MESSAGE(KERN_WARNING, device, "%s",
706 "FORMAT 2 - 3990 check-2 error");
707 break;
708 case 0x0E:
709 DEV_MESSAGE(KERN_WARNING, device, "%s",
710 "FORMAT 2 - Support facility errors");
711 break;
712 case 0x0F:
713 DEV_MESSAGE(KERN_WARNING, device,
714 "FORMAT 2 - Microcode detected error %02x",
715 sense[8]);
716 break;
717 default:
718 DEV_MESSAGE(KERN_WARNING, device, "%s",
719 "FORMAT 2 - Reserved");
721 break;
723 case 0x30: /* Format 3 - 3990 Control Checks */
724 switch (msg_no) {
725 case 0x0F:
726 DEV_MESSAGE(KERN_WARNING, device, "%s",
727 "FORMAT 3 - Allegiance terminated");
728 break;
729 default:
730 DEV_MESSAGE(KERN_WARNING, device, "%s",
731 "FORMAT 3 - Reserved");
733 break;
735 case 0x40: /* Format 4 - Data Checks */
736 switch (msg_no) {
737 case 0x00:
738 DEV_MESSAGE(KERN_WARNING, device, "%s",
739 "FORMAT 4 - Home address area error");
740 break;
741 case 0x01:
742 DEV_MESSAGE(KERN_WARNING, device, "%s",
743 "FORMAT 4 - Count area error");
744 break;
745 case 0x02:
746 DEV_MESSAGE(KERN_WARNING, device, "%s",
747 "FORMAT 4 - Key area error");
748 break;
749 case 0x03:
750 DEV_MESSAGE(KERN_WARNING, device, "%s",
751 "FORMAT 4 - Data area error");
752 break;
753 case 0x04:
754 DEV_MESSAGE(KERN_WARNING, device, "%s",
755 "FORMAT 4 - No sync byte in home address "
756 "area");
757 break;
758 case 0x05:
759 DEV_MESSAGE(KERN_WARNING, device, "%s",
760 "FORMAT 4 - No sync byte in count address "
761 "area");
762 break;
763 case 0x06:
764 DEV_MESSAGE(KERN_WARNING, device, "%s",
765 "FORMAT 4 - No sync byte in key area");
766 break;
767 case 0x07:
768 DEV_MESSAGE(KERN_WARNING, device, "%s",
769 "FORMAT 4 - No sync byte in data area");
770 break;
771 case 0x08:
772 DEV_MESSAGE(KERN_WARNING, device, "%s",
773 "FORMAT 4 - Home address area error; "
774 "offset active");
775 break;
776 case 0x09:
777 DEV_MESSAGE(KERN_WARNING, device, "%s",
778 "FORMAT 4 - Count area error; offset "
779 "active");
780 break;
781 case 0x0A:
782 DEV_MESSAGE(KERN_WARNING, device, "%s",
783 "FORMAT 4 - Key area error; offset "
784 "active");
785 break;
786 case 0x0B:
787 DEV_MESSAGE(KERN_WARNING, device, "%s",
788 "FORMAT 4 - Data area error; "
789 "offset active");
790 break;
791 case 0x0C:
792 DEV_MESSAGE(KERN_WARNING, device, "%s",
793 "FORMAT 4 - No sync byte in home "
794 "address area; offset active");
795 break;
796 case 0x0D:
797 DEV_MESSAGE(KERN_WARNING, device, "%s",
798 "FORMAT 4 - No syn byte in count "
799 "address area; offset active");
800 break;
801 case 0x0E:
802 DEV_MESSAGE(KERN_WARNING, device, "%s",
803 "FORMAT 4 - No sync byte in key area; "
804 "offset active");
805 break;
806 case 0x0F:
807 DEV_MESSAGE(KERN_WARNING, device, "%s",
808 "FORMAT 4 - No syn byte in data area; "
809 "offset active");
810 break;
811 default:
812 DEV_MESSAGE(KERN_WARNING, device, "%s",
813 "FORMAT 4 - Reserved");
815 break;
817 case 0x50: /* Format 5 - Data Check with displacement information */
818 switch (msg_no) {
819 case 0x00:
820 DEV_MESSAGE(KERN_WARNING, device, "%s",
821 "FORMAT 5 - Data Check in the "
822 "home address area");
823 break;
824 case 0x01:
825 DEV_MESSAGE(KERN_WARNING, device, "%s",
826 "FORMAT 5 - Data Check in the count area");
827 break;
828 case 0x02:
829 DEV_MESSAGE(KERN_WARNING, device, "%s",
830 "FORMAT 5 - Data Check in the key area");
831 break;
832 case 0x03:
833 DEV_MESSAGE(KERN_WARNING, device, "%s",
834 "FORMAT 5 - Data Check in the data area");
835 break;
836 case 0x08:
837 DEV_MESSAGE(KERN_WARNING, device, "%s",
838 "FORMAT 5 - Data Check in the "
839 "home address area; offset active");
840 break;
841 case 0x09:
842 DEV_MESSAGE(KERN_WARNING, device, "%s",
843 "FORMAT 5 - Data Check in the count area; "
844 "offset active");
845 break;
846 case 0x0A:
847 DEV_MESSAGE(KERN_WARNING, device, "%s",
848 "FORMAT 5 - Data Check in the key area; "
849 "offset active");
850 break;
851 case 0x0B:
852 DEV_MESSAGE(KERN_WARNING, device, "%s",
853 "FORMAT 5 - Data Check in the data area; "
854 "offset active");
855 break;
856 default:
857 DEV_MESSAGE(KERN_WARNING, device, "%s",
858 "FORMAT 5 - Reserved");
860 break;
862 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
863 switch (msg_no) {
864 case 0x00:
865 DEV_MESSAGE(KERN_WARNING, device, "%s",
866 "FORMAT 6 - Overrun on channel A");
867 break;
868 case 0x01:
869 DEV_MESSAGE(KERN_WARNING, device, "%s",
870 "FORMAT 6 - Overrun on channel B");
871 break;
872 case 0x02:
873 DEV_MESSAGE(KERN_WARNING, device, "%s",
874 "FORMAT 6 - Overrun on channel C");
875 break;
876 case 0x03:
877 DEV_MESSAGE(KERN_WARNING, device, "%s",
878 "FORMAT 6 - Overrun on channel D");
879 break;
880 case 0x04:
881 DEV_MESSAGE(KERN_WARNING, device, "%s",
882 "FORMAT 6 - Overrun on channel E");
883 break;
884 case 0x05:
885 DEV_MESSAGE(KERN_WARNING, device, "%s",
886 "FORMAT 6 - Overrun on channel F");
887 break;
888 case 0x06:
889 DEV_MESSAGE(KERN_WARNING, device, "%s",
890 "FORMAT 6 - Overrun on channel G");
891 break;
892 case 0x07:
893 DEV_MESSAGE(KERN_WARNING, device, "%s",
894 "FORMAT 6 - Overrun on channel H");
895 break;
896 default:
897 DEV_MESSAGE(KERN_WARNING, device, "%s",
898 "FORMAT 6 - Reserved");
900 break;
902 case 0x70: /* Format 7 - Device Connection Control Checks */
903 switch (msg_no) {
904 case 0x00:
905 DEV_MESSAGE(KERN_WARNING, device, "%s",
906 "FORMAT 7 - RCC initiated by a connection "
907 "check alert");
908 break;
909 case 0x01:
910 DEV_MESSAGE(KERN_WARNING, device, "%s",
911 "FORMAT 7 - RCC 1 sequence not "
912 "successful");
913 break;
914 case 0x02:
915 DEV_MESSAGE(KERN_WARNING, device, "%s",
916 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
917 "successful");
918 break;
919 case 0x03:
920 DEV_MESSAGE(KERN_WARNING, device, "%s",
921 "FORMAT 7 - Invalid tag-in during "
922 "selection sequence");
923 break;
924 case 0x04:
925 DEV_MESSAGE(KERN_WARNING, device, "%s",
926 "FORMAT 7 - extra RCC required");
927 break;
928 case 0x05:
929 DEV_MESSAGE(KERN_WARNING, device, "%s",
930 "FORMAT 7 - Invalid DCC selection "
931 "response or timeout");
932 break;
933 case 0x06:
934 DEV_MESSAGE(KERN_WARNING, device, "%s",
935 "FORMAT 7 - Missing end operation; device "
936 "transfer complete");
937 break;
938 case 0x07:
939 DEV_MESSAGE(KERN_WARNING, device, "%s",
940 "FORMAT 7 - Missing end operation; device "
941 "transfer incomplete");
942 break;
943 case 0x08:
944 DEV_MESSAGE(KERN_WARNING, device, "%s",
945 "FORMAT 7 - Invalid tag-in for an "
946 "immediate command sequence");
947 break;
948 case 0x09:
949 DEV_MESSAGE(KERN_WARNING, device, "%s",
950 "FORMAT 7 - Invalid tag-in for an "
951 "extended command sequence");
952 break;
953 case 0x0A:
954 DEV_MESSAGE(KERN_WARNING, device, "%s",
955 "FORMAT 7 - 3990 microcode time out when "
956 "stopping selection");
957 break;
958 case 0x0B:
959 DEV_MESSAGE(KERN_WARNING, device, "%s",
960 "FORMAT 7 - No response to selection "
961 "after a poll interruption");
962 break;
963 case 0x0C:
964 DEV_MESSAGE(KERN_WARNING, device, "%s",
965 "FORMAT 7 - Permanent path error (DASD "
966 "controller not available)");
967 break;
968 case 0x0D:
969 DEV_MESSAGE(KERN_WARNING, device, "%s",
970 "FORMAT 7 - DASD controller not available"
971 " on disconnected command chain");
972 break;
973 default:
974 DEV_MESSAGE(KERN_WARNING, device, "%s",
975 "FORMAT 7 - Reserved");
977 break;
979 case 0x80: /* Format 8 - Additional Device Equipment Checks */
980 switch (msg_no) {
981 case 0x00: /* No Message */
982 case 0x01:
983 DEV_MESSAGE(KERN_WARNING, device, "%s",
984 "FORMAT 8 - Error correction code "
985 "hardware fault");
986 break;
987 case 0x03:
988 DEV_MESSAGE(KERN_WARNING, device, "%s",
989 "FORMAT 8 - Unexpected end operation "
990 "response code");
991 break;
992 case 0x04:
993 DEV_MESSAGE(KERN_WARNING, device, "%s",
994 "FORMAT 8 - End operation with transfer "
995 "count not zero");
996 break;
997 case 0x05:
998 DEV_MESSAGE(KERN_WARNING, device, "%s",
999 "FORMAT 8 - End operation with transfer "
1000 "count zero");
1001 break;
1002 case 0x06:
1003 DEV_MESSAGE(KERN_WARNING, device, "%s",
1004 "FORMAT 8 - DPS checks after a system "
1005 "reset or selective reset");
1006 break;
1007 case 0x07:
1008 DEV_MESSAGE(KERN_WARNING, device, "%s",
1009 "FORMAT 8 - DPS cannot be filled");
1010 break;
1011 case 0x08:
1012 DEV_MESSAGE(KERN_WARNING, device, "%s",
1013 "FORMAT 8 - Short busy time-out during "
1014 "device selection");
1015 break;
1016 case 0x09:
1017 DEV_MESSAGE(KERN_WARNING, device, "%s",
1018 "FORMAT 8 - DASD controller failed to "
1019 "set or reset the long busy latch");
1020 break;
1021 case 0x0A:
1022 DEV_MESSAGE(KERN_WARNING, device, "%s",
1023 "FORMAT 8 - No interruption from device "
1024 "during a command chain");
1025 break;
1026 default:
1027 DEV_MESSAGE(KERN_WARNING, device, "%s",
1028 "FORMAT 8 - Reserved");
1030 break;
1032 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
1033 switch (msg_no) {
1034 case 0x00:
1035 break; /* No Message */
1036 case 0x06:
1037 DEV_MESSAGE(KERN_WARNING, device, "%s",
1038 "FORMAT 9 - Device check-2 error");
1039 break;
1040 case 0x07:
1041 DEV_MESSAGE(KERN_WARNING, device, "%s",
1042 "FORMAT 9 - Head address did not compare");
1043 break;
1044 case 0x0A:
1045 DEV_MESSAGE(KERN_WARNING, device, "%s",
1046 "FORMAT 9 - Track physical address did "
1047 "not compare while oriented");
1048 break;
1049 case 0x0E:
1050 DEV_MESSAGE(KERN_WARNING, device, "%s",
1051 "FORMAT 9 - Cylinder address did not "
1052 "compare");
1053 break;
1054 default:
1055 DEV_MESSAGE(KERN_WARNING, device, "%s",
1056 "FORMAT 9 - Reserved");
1058 break;
1060 case 0xF0: /* Format F - Cache Storage Checks */
1061 switch (msg_no) {
1062 case 0x00:
1063 DEV_MESSAGE(KERN_WARNING, device, "%s",
1064 "FORMAT F - Operation Terminated");
1065 break;
1066 case 0x01:
1067 DEV_MESSAGE(KERN_WARNING, device, "%s",
1068 "FORMAT F - Subsystem Processing Error");
1069 break;
1070 case 0x02:
1071 DEV_MESSAGE(KERN_WARNING, device, "%s",
1072 "FORMAT F - Cache or nonvolatile storage "
1073 "equipment failure");
1074 break;
1075 case 0x04:
1076 DEV_MESSAGE(KERN_WARNING, device, "%s",
1077 "FORMAT F - Caching terminated");
1078 break;
1079 case 0x06:
1080 DEV_MESSAGE(KERN_WARNING, device, "%s",
1081 "FORMAT F - Cache fast write access not "
1082 "authorized");
1083 break;
1084 case 0x07:
1085 DEV_MESSAGE(KERN_WARNING, device, "%s",
1086 "FORMAT F - Track format incorrect");
1087 break;
1088 case 0x09:
1089 DEV_MESSAGE(KERN_WARNING, device, "%s",
1090 "FORMAT F - Caching reinitiated");
1091 break;
1092 case 0x0A:
1093 DEV_MESSAGE(KERN_WARNING, device, "%s",
1094 "FORMAT F - Nonvolatile storage "
1095 "terminated");
1096 break;
1097 case 0x0B:
1098 DEV_MESSAGE(KERN_WARNING, device, "%s",
1099 "FORMAT F - Volume is suspended duplex");
1100 break;
1101 case 0x0C:
1102 DEV_MESSAGE(KERN_WARNING, device, "%s",
1103 "FORMAT F - Subsystem status connot be "
1104 "determined");
1105 break;
1106 case 0x0D:
1107 DEV_MESSAGE(KERN_WARNING, device, "%s",
1108 "FORMAT F - Caching status reset to "
1109 "default");
1110 break;
1111 case 0x0E:
1112 DEV_MESSAGE(KERN_WARNING, device, "%s",
1113 "FORMAT F - DASD Fast Write inhibited");
1114 break;
1115 default:
1116 DEV_MESSAGE(KERN_WARNING, device, "%s",
1117 "FORMAT D - Reserved");
1119 break;
1121 default: /* unknown message format - should not happen */
1122 DEV_MESSAGE (KERN_WARNING, device,
1123 "unknown message format %02x",
1124 msg_format);
1125 break;
1126 } /* end switch message format */
1128 } /* end dasd_3990_handle_env_data */
1131 * DASD_3990_ERP_COM_REJ
1133 * DESCRIPTION
1134 * Handles 24 byte 'Command Reject' error.
1136 * PARAMETER
1137 * erp current erp_head
1138 * sense current sense data
1140 * RETURN VALUES
1141 * erp 'new' erp_head - pointer to new ERP
1143 static struct dasd_ccw_req *
1144 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1147 struct dasd_device *device = erp->device;
1149 erp->function = dasd_3990_erp_com_rej;
1151 /* env data present (ACTION 10 - retry should work) */
1152 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1154 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1155 "Command Reject - environmental data present");
1157 dasd_3990_handle_env_data(erp, sense);
1159 erp->retries = 5;
1161 } else {
1162 /* fatal error - set status to FAILED */
1163 DEV_MESSAGE(KERN_ERR, device, "%s",
1164 "Command Reject - Fatal error");
1166 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1169 return erp;
1171 } /* end dasd_3990_erp_com_rej */
1174 * DASD_3990_ERP_BUS_OUT
1176 * DESCRIPTION
1177 * Handles 24 byte 'Bus Out Parity Check' error.
1179 * PARAMETER
1180 * erp current erp_head
1181 * RETURN VALUES
1182 * erp new erp_head - pointer to new ERP
1184 static struct dasd_ccw_req *
1185 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1188 struct dasd_device *device = erp->device;
1190 /* first time set initial retry counter and erp_function */
1191 /* and retry once without blocking queue */
1192 /* (this enables easier enqueing of the cqr) */
1193 if (erp->function != dasd_3990_erp_bus_out) {
1194 erp->retries = 256;
1195 erp->function = dasd_3990_erp_bus_out;
1197 } else {
1199 /* issue a message and wait for 'device ready' interrupt */
1200 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1201 "bus out parity error or BOPC requested by "
1202 "channel");
1204 dasd_3990_erp_block_queue(erp, 60*HZ);
1208 return erp;
1210 } /* end dasd_3990_erp_bus_out */
1213 * DASD_3990_ERP_EQUIP_CHECK
1215 * DESCRIPTION
1216 * Handles 24 byte 'Equipment Check' error.
1218 * PARAMETER
1219 * erp current erp_head
1220 * RETURN VALUES
1221 * erp new erp_head - pointer to new ERP
1223 static struct dasd_ccw_req *
1224 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1227 struct dasd_device *device = erp->device;
1229 erp->function = dasd_3990_erp_equip_check;
1231 if (sense[1] & SNS1_WRITE_INHIBITED) {
1233 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1234 "Write inhibited path encountered");
1236 /* vary path offline */
1237 DEV_MESSAGE(KERN_ERR, device, "%s",
1238 "Path should be varied off-line. "
1239 "This is not implemented yet \n - please report "
1240 "to linux390@de.ibm.com");
1242 erp = dasd_3990_erp_action_1(erp);
1244 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1246 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1247 "Equipment Check - " "environmental data present");
1249 dasd_3990_handle_env_data(erp, sense);
1251 erp = dasd_3990_erp_action_4(erp, sense);
1253 } else if (sense[1] & SNS1_PERM_ERR) {
1255 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1256 "Equipment Check - retry exhausted or "
1257 "undesirable");
1259 erp = dasd_3990_erp_action_1(erp);
1261 } else {
1262 /* all other equipment checks - Action 5 */
1263 /* rest is done when retries == 0 */
1264 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1265 "Equipment check or processing error");
1267 erp = dasd_3990_erp_action_5(erp);
1270 return erp;
1272 } /* end dasd_3990_erp_equip_check */
1275 * DASD_3990_ERP_DATA_CHECK
1277 * DESCRIPTION
1278 * Handles 24 byte 'Data Check' error.
1280 * PARAMETER
1281 * erp current erp_head
1282 * RETURN VALUES
1283 * erp new erp_head - pointer to new ERP
1285 static struct dasd_ccw_req *
1286 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1289 struct dasd_device *device = erp->device;
1291 erp->function = dasd_3990_erp_data_check;
1293 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1295 /* issue message that the data has been corrected */
1296 DEV_MESSAGE(KERN_EMERG, device, "%s",
1297 "Data recovered during retry with PCI "
1298 "fetch mode active");
1300 /* not possible to handle this situation in Linux */
1301 panic("No way to inform appliction about the possibly "
1302 "incorret data");
1304 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1306 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1307 "Uncorrectable data check recovered secondary "
1308 "addr of duplex pair");
1310 erp = dasd_3990_erp_action_4(erp, sense);
1312 } else if (sense[1] & SNS1_PERM_ERR) {
1314 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1315 "Uncorrectable data check with internal "
1316 "retry exhausted");
1318 erp = dasd_3990_erp_action_1(erp);
1320 } else {
1321 /* all other data checks */
1322 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1323 "Uncorrectable data check with retry count "
1324 "exhausted...");
1326 erp = dasd_3990_erp_action_5(erp);
1329 return erp;
1331 } /* end dasd_3990_erp_data_check */
1334 * DASD_3990_ERP_OVERRUN
1336 * DESCRIPTION
1337 * Handles 24 byte 'Overrun' error.
1339 * PARAMETER
1340 * erp current erp_head
1341 * RETURN VALUES
1342 * erp new erp_head - pointer to new ERP
1344 static struct dasd_ccw_req *
1345 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1348 struct dasd_device *device = erp->device;
1350 erp->function = dasd_3990_erp_overrun;
1352 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1353 "Overrun - service overrun or overrun"
1354 " error requested by channel");
1356 erp = dasd_3990_erp_action_5(erp);
1358 return erp;
1360 } /* end dasd_3990_erp_overrun */
1363 * DASD_3990_ERP_INV_FORMAT
1365 * DESCRIPTION
1366 * Handles 24 byte 'Invalid Track Format' error.
1368 * PARAMETER
1369 * erp current erp_head
1370 * RETURN VALUES
1371 * erp new erp_head - pointer to new ERP
1373 static struct dasd_ccw_req *
1374 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1377 struct dasd_device *device = erp->device;
1379 erp->function = dasd_3990_erp_inv_format;
1381 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1383 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1384 "Track format error when destaging or "
1385 "staging data");
1387 dasd_3990_handle_env_data(erp, sense);
1389 erp = dasd_3990_erp_action_4(erp, sense);
1391 } else {
1392 DEV_MESSAGE(KERN_ERR, device, "%s",
1393 "Invalid Track Format - Fatal error should have "
1394 "been handled within the interrupt handler");
1396 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1399 return erp;
1401 } /* end dasd_3990_erp_inv_format */
1404 * DASD_3990_ERP_EOC
1406 * DESCRIPTION
1407 * Handles 24 byte 'End-of-Cylinder' error.
1409 * PARAMETER
1410 * erp already added default erp
1411 * RETURN VALUES
1412 * erp pointer to original (failed) cqr.
1414 static struct dasd_ccw_req *
1415 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1418 struct dasd_device *device = default_erp->device;
1420 DEV_MESSAGE(KERN_ERR, device, "%s",
1421 "End-of-Cylinder - must never happen");
1423 /* implement action 7 - BUG */
1424 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1426 } /* end dasd_3990_erp_EOC */
1429 * DASD_3990_ERP_ENV_DATA
1431 * DESCRIPTION
1432 * Handles 24 byte 'Environmental-Data Present' error.
1434 * PARAMETER
1435 * erp current erp_head
1436 * RETURN VALUES
1437 * erp new erp_head - pointer to new ERP
1439 static struct dasd_ccw_req *
1440 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1443 struct dasd_device *device = erp->device;
1445 erp->function = dasd_3990_erp_env_data;
1447 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Environmental data present");
1449 dasd_3990_handle_env_data(erp, sense);
1451 /* don't retry on disabled interface */
1452 if (sense[7] != 0x0F) {
1454 erp = dasd_3990_erp_action_4(erp, sense);
1455 } else {
1457 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_IN_IO);
1460 return erp;
1462 } /* end dasd_3990_erp_env_data */
1465 * DASD_3990_ERP_NO_REC
1467 * DESCRIPTION
1468 * Handles 24 byte 'No Record Found' error.
1470 * PARAMETER
1471 * erp already added default ERP
1473 * RETURN VALUES
1474 * erp new erp_head - pointer to new ERP
1476 static struct dasd_ccw_req *
1477 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1480 struct dasd_device *device = default_erp->device;
1482 DEV_MESSAGE(KERN_ERR, device, "%s",
1483 "No Record Found - Fatal error should "
1484 "have been handled within the interrupt handler");
1486 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1488 } /* end dasd_3990_erp_no_rec */
1491 * DASD_3990_ERP_FILE_PROT
1493 * DESCRIPTION
1494 * Handles 24 byte 'File Protected' error.
1495 * Note: Seek related recovery is not implemented because
1496 * wee don't use the seek command yet.
1498 * PARAMETER
1499 * erp current erp_head
1500 * RETURN VALUES
1501 * erp new erp_head - pointer to new ERP
1503 static struct dasd_ccw_req *
1504 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1507 struct dasd_device *device = erp->device;
1509 DEV_MESSAGE(KERN_ERR, device, "%s", "File Protected");
1511 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1513 } /* end dasd_3990_erp_file_prot */
1516 * DASD_3990_ERP_INSPECT_24
1518 * DESCRIPTION
1519 * Does a detailed inspection of the 24 byte sense data
1520 * and sets up a related error recovery action.
1522 * PARAMETER
1523 * sense sense data of the actual error
1524 * erp pointer to the currently created default ERP
1526 * RETURN VALUES
1527 * erp pointer to the (addtitional) ERP
1529 static struct dasd_ccw_req *
1530 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1533 struct dasd_ccw_req *erp_filled = NULL;
1535 /* Check sense for .... */
1536 /* 'Command Reject' */
1537 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1538 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1540 /* 'Intervention Required' */
1541 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1542 erp_filled = dasd_3990_erp_int_req(erp);
1544 /* 'Bus Out Parity Check' */
1545 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1546 erp_filled = dasd_3990_erp_bus_out(erp);
1548 /* 'Equipment Check' */
1549 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1550 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1552 /* 'Data Check' */
1553 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1554 erp_filled = dasd_3990_erp_data_check(erp, sense);
1556 /* 'Overrun' */
1557 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1558 erp_filled = dasd_3990_erp_overrun(erp, sense);
1560 /* 'Invalid Track Format' */
1561 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1562 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1564 /* 'End-of-Cylinder' */
1565 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1566 erp_filled = dasd_3990_erp_EOC(erp, sense);
1568 /* 'Environmental Data' */
1569 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1570 erp_filled = dasd_3990_erp_env_data(erp, sense);
1572 /* 'No Record Found' */
1573 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1574 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1576 /* 'File Protected' */
1577 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1578 erp_filled = dasd_3990_erp_file_prot(erp);
1580 /* other (unknown) error - do default ERP */
1581 if (erp_filled == NULL) {
1583 erp_filled = erp;
1586 return erp_filled;
1588 } /* END dasd_3990_erp_inspect_24 */
1591 *****************************************************************************
1592 * 32 byte sense ERP functions (only)
1593 *****************************************************************************
1597 * DASD_3990_ERPACTION_10_32
1599 * DESCRIPTION
1600 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1601 * Just retry and if retry doesn't work, return with error.
1603 * PARAMETER
1604 * erp current erp_head
1605 * sense current sense data
1606 * RETURN VALUES
1607 * erp modified erp_head
1609 static struct dasd_ccw_req *
1610 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1613 struct dasd_device *device = erp->device;
1615 erp->retries = 256;
1616 erp->function = dasd_3990_erp_action_10_32;
1618 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Perform logging requested");
1620 return erp;
1622 } /* end dasd_3990_erp_action_10_32 */
1625 * DASD_3990_ERP_ACTION_1B_32
1627 * DESCRIPTION
1628 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1629 * A write operation could not be finished because of an unexpected
1630 * condition.
1631 * The already created 'default erp' is used to get the link to
1632 * the erp chain, but it can not be used for this recovery
1633 * action because it contains no DE/LO data space.
1635 * PARAMETER
1636 * default_erp already added default erp.
1637 * sense current sense data
1639 * RETURN VALUES
1640 * erp new erp or
1641 * default_erp in case of imprecise ending or error
1643 static struct dasd_ccw_req *
1644 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1647 struct dasd_device *device = default_erp->device;
1648 __u32 cpa = 0;
1649 struct dasd_ccw_req *cqr;
1650 struct dasd_ccw_req *erp;
1651 struct DE_eckd_data *DE_data;
1652 char *LO_data; /* LO_eckd_data_t */
1653 struct ccw1 *ccw;
1655 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1656 "Write not finished because of unexpected condition");
1658 default_erp->function = dasd_3990_erp_action_1B_32;
1660 /* determine the original cqr */
1661 cqr = default_erp;
1663 while (cqr->refers != NULL) {
1664 cqr = cqr->refers;
1667 /* for imprecise ending just do default erp */
1668 if (sense[1] & 0x01) {
1670 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1671 "Imprecise ending is set - just retry");
1673 return default_erp;
1676 /* determine the address of the CCW to be restarted */
1677 /* Imprecise ending is not set -> addr from IRB-SCSW */
1678 cpa = default_erp->refers->dstat->scsw.cpa;
1680 if (cpa == 0) {
1682 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1683 "Unable to determine address of the CCW "
1684 "to be restarted");
1686 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1689 /* Build new ERP request including DE/LO */
1690 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1691 2 + 1,/* DE/LO + TIC */
1692 sizeof (struct DE_eckd_data) +
1693 sizeof (struct LO_eckd_data), device);
1695 if (IS_ERR(erp)) {
1696 DEV_MESSAGE(KERN_ERR, device, "%s", "Unable to allocate ERP");
1697 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1700 /* use original DE */
1701 DE_data = erp->data;
1702 memcpy(DE_data, cqr->data, sizeof (struct DE_eckd_data));
1704 /* create LO */
1705 LO_data = erp->data + sizeof (struct DE_eckd_data);
1707 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1709 DEV_MESSAGE(KERN_ERR, device, "%s",
1710 "BUG - this should not happen");
1712 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1715 if ((sense[7] & 0x3F) == 0x01) {
1716 /* operation code is WRITE DATA -> data area orientation */
1717 LO_data[0] = 0x81;
1719 } else if ((sense[7] & 0x3F) == 0x03) {
1720 /* operation code is FORMAT WRITE -> index orientation */
1721 LO_data[0] = 0xC3;
1723 } else {
1724 LO_data[0] = sense[7]; /* operation */
1727 LO_data[1] = sense[8]; /* auxiliary */
1728 LO_data[2] = sense[9];
1729 LO_data[3] = sense[3]; /* count */
1730 LO_data[4] = sense[29]; /* seek_addr.cyl */
1731 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1732 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1734 memcpy(&(LO_data[8]), &(sense[11]), 8);
1736 /* create DE ccw */
1737 ccw = erp->cpaddr;
1738 memset(ccw, 0, sizeof (struct ccw1));
1739 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1740 ccw->flags = CCW_FLAG_CC;
1741 ccw->count = 16;
1742 ccw->cda = (__u32)(addr_t) DE_data;
1744 /* create LO ccw */
1745 ccw++;
1746 memset(ccw, 0, sizeof (struct ccw1));
1747 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1748 ccw->flags = CCW_FLAG_CC;
1749 ccw->count = 16;
1750 ccw->cda = (__u32)(addr_t) LO_data;
1752 /* TIC to the failed ccw */
1753 ccw++;
1754 ccw->cmd_code = CCW_CMD_TIC;
1755 ccw->cda = cpa;
1757 /* fill erp related fields */
1758 erp->function = dasd_3990_erp_action_1B_32;
1759 erp->refers = default_erp->refers;
1760 erp->device = device;
1761 erp->magic = default_erp->magic;
1762 erp->expires = 0;
1763 erp->retries = 256;
1764 erp->status = DASD_CQR_FILLED;
1766 /* remove the default erp */
1767 dasd_free_erp_request(default_erp, device);
1769 return erp;
1771 } /* end dasd_3990_erp_action_1B_32 */
1774 * DASD_3990_UPDATE_1B
1776 * DESCRIPTION
1777 * Handles the update to the 32 byte 'Action 1B' of Single Program
1778 * Action Codes in case the first action was not successful.
1779 * The already created 'previous_erp' is the currently not successful
1780 * ERP.
1782 * PARAMETER
1783 * previous_erp already created previous erp.
1784 * sense current sense data
1785 * RETURN VALUES
1786 * erp modified erp
1788 static struct dasd_ccw_req *
1789 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1792 struct dasd_device *device = previous_erp->device;
1793 __u32 cpa = 0;
1794 struct dasd_ccw_req *cqr;
1795 struct dasd_ccw_req *erp;
1796 char *LO_data; /* struct LO_eckd_data */
1797 struct ccw1 *ccw;
1799 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1800 "Write not finished because of unexpected condition"
1801 " - follow on");
1803 /* determine the original cqr */
1804 cqr = previous_erp;
1806 while (cqr->refers != NULL) {
1807 cqr = cqr->refers;
1810 /* for imprecise ending just do default erp */
1811 if (sense[1] & 0x01) {
1813 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1814 "Imprecise ending is set - just retry");
1816 previous_erp->status = DASD_CQR_QUEUED;
1818 return previous_erp;
1821 /* determine the address of the CCW to be restarted */
1822 /* Imprecise ending is not set -> addr from IRB-SCSW */
1823 cpa = previous_erp->dstat->scsw.cpa;
1825 if (cpa == 0) {
1827 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1828 "Unable to determine address of the CCW "
1829 "to be restarted");
1831 previous_erp->status = DASD_CQR_FAILED;
1833 return previous_erp;
1836 erp = previous_erp;
1838 /* update the LO with the new returned sense data */
1839 LO_data = erp->data + sizeof (struct DE_eckd_data);
1841 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1843 DEV_MESSAGE(KERN_ERR, device, "%s",
1844 "BUG - this should not happen");
1846 previous_erp->status = DASD_CQR_FAILED;
1848 return previous_erp;
1851 if ((sense[7] & 0x3F) == 0x01) {
1852 /* operation code is WRITE DATA -> data area orientation */
1853 LO_data[0] = 0x81;
1855 } else if ((sense[7] & 0x3F) == 0x03) {
1856 /* operation code is FORMAT WRITE -> index orientation */
1857 LO_data[0] = 0xC3;
1859 } else {
1860 LO_data[0] = sense[7]; /* operation */
1863 LO_data[1] = sense[8]; /* auxiliary */
1864 LO_data[2] = sense[9];
1865 LO_data[3] = sense[3]; /* count */
1866 LO_data[4] = sense[29]; /* seek_addr.cyl */
1867 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1868 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1870 memcpy(&(LO_data[8]), &(sense[11]), 8);
1872 /* TIC to the failed ccw */
1873 ccw = erp->cpaddr; /* addr of DE ccw */
1874 ccw++; /* addr of LE ccw */
1875 ccw++; /* addr of TIC ccw */
1876 ccw->cda = cpa;
1878 erp->status = DASD_CQR_QUEUED;
1880 return erp;
1882 } /* end dasd_3990_update_1B */
1885 * DASD_3990_ERP_COMPOUND_RETRY
1887 * DESCRIPTION
1888 * Handles the compound ERP action retry code.
1889 * NOTE: At least one retry is done even if zero is specified
1890 * by the sense data. This makes enqueueing of the request
1891 * easier.
1893 * PARAMETER
1894 * sense sense data of the actual error
1895 * erp pointer to the currently created ERP
1897 * RETURN VALUES
1898 * erp modified ERP pointer
1901 static void
1902 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1905 switch (sense[25] & 0x03) {
1906 case 0x00: /* no not retry */
1907 erp->retries = 1;
1908 break;
1910 case 0x01: /* retry 2 times */
1911 erp->retries = 2;
1912 break;
1914 case 0x02: /* retry 10 times */
1915 erp->retries = 10;
1916 break;
1918 case 0x03: /* retry 256 times */
1919 erp->retries = 256;
1920 break;
1922 default:
1923 BUG();
1926 erp->function = dasd_3990_erp_compound_retry;
1928 } /* end dasd_3990_erp_compound_retry */
1931 * DASD_3990_ERP_COMPOUND_PATH
1933 * DESCRIPTION
1934 * Handles the compound ERP action for retry on alternate
1935 * channel path.
1937 * PARAMETER
1938 * sense sense data of the actual error
1939 * erp pointer to the currently created ERP
1941 * RETURN VALUES
1942 * erp modified ERP pointer
1945 static void
1946 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1949 if (sense[25] & DASD_SENSE_BIT_3) {
1950 dasd_3990_erp_alternate_path(erp);
1952 if (erp->status == DASD_CQR_FAILED) {
1953 /* reset the lpm and the status to be able to
1954 * try further actions. */
1956 erp->lpm = 0;
1958 erp->status = DASD_CQR_ERROR;
1963 erp->function = dasd_3990_erp_compound_path;
1965 } /* end dasd_3990_erp_compound_path */
1968 * DASD_3990_ERP_COMPOUND_CODE
1970 * DESCRIPTION
1971 * Handles the compound ERP action for retry code.
1973 * PARAMETER
1974 * sense sense data of the actual error
1975 * erp pointer to the currently created ERP
1977 * RETURN VALUES
1978 * erp NEW ERP pointer
1981 static struct dasd_ccw_req *
1982 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1985 if (sense[25] & DASD_SENSE_BIT_2) {
1987 switch (sense[28]) {
1988 case 0x17:
1989 /* issue a Diagnostic Control command with an
1990 * Inhibit Write subcommand and controler modifier */
1991 erp = dasd_3990_erp_DCTL(erp, 0x20);
1992 break;
1994 case 0x25:
1995 /* wait for 5 seconds and retry again */
1996 erp->retries = 1;
1998 dasd_3990_erp_block_queue (erp, 5*HZ);
1999 break;
2001 default:
2002 /* should not happen - continue */
2003 break;
2007 erp->function = dasd_3990_erp_compound_code;
2009 return erp;
2011 } /* end dasd_3990_erp_compound_code */
2014 * DASD_3990_ERP_COMPOUND_CONFIG
2016 * DESCRIPTION
2017 * Handles the compound ERP action for configruation
2018 * dependent error.
2019 * Note: duplex handling is not implemented (yet).
2021 * PARAMETER
2022 * sense sense data of the actual error
2023 * erp pointer to the currently created ERP
2025 * RETURN VALUES
2026 * erp modified ERP pointer
2029 static void
2030 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2033 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2035 /* set to suspended duplex state then restart */
2036 struct dasd_device *device = erp->device;
2038 DEV_MESSAGE(KERN_ERR, device, "%s",
2039 "Set device to suspended duplex state should be "
2040 "done!\n"
2041 "This is not implemented yet (for compound ERP)"
2042 " - please report to linux390@de.ibm.com");
2046 erp->function = dasd_3990_erp_compound_config;
2048 } /* end dasd_3990_erp_compound_config */
2051 * DASD_3990_ERP_COMPOUND
2053 * DESCRIPTION
2054 * Does the further compound program action if
2055 * compound retry was not successful.
2057 * PARAMETER
2058 * sense sense data of the actual error
2059 * erp pointer to the current (failed) ERP
2061 * RETURN VALUES
2062 * erp (additional) ERP pointer
2065 static struct dasd_ccw_req *
2066 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2069 if ((erp->function == dasd_3990_erp_compound_retry) &&
2070 (erp->status == DASD_CQR_ERROR)) {
2072 dasd_3990_erp_compound_path(erp, sense);
2075 if ((erp->function == dasd_3990_erp_compound_path) &&
2076 (erp->status == DASD_CQR_ERROR)) {
2078 erp = dasd_3990_erp_compound_code(erp, sense);
2081 if ((erp->function == dasd_3990_erp_compound_code) &&
2082 (erp->status == DASD_CQR_ERROR)) {
2084 dasd_3990_erp_compound_config(erp, sense);
2087 /* if no compound action ERP specified, the request failed */
2088 if (erp->status == DASD_CQR_ERROR) {
2090 erp->status = DASD_CQR_FAILED;
2093 return erp;
2095 } /* end dasd_3990_erp_compound */
2098 * DASD_3990_ERP_INSPECT_32
2100 * DESCRIPTION
2101 * Does a detailed inspection of the 32 byte sense data
2102 * and sets up a related error recovery action.
2104 * PARAMETER
2105 * sense sense data of the actual error
2106 * erp pointer to the currently created default ERP
2108 * RETURN VALUES
2109 * erp_filled pointer to the ERP
2112 static struct dasd_ccw_req *
2113 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2116 struct dasd_device *device = erp->device;
2118 erp->function = dasd_3990_erp_inspect_32;
2120 if (sense[25] & DASD_SENSE_BIT_0) {
2122 /* compound program action codes (byte25 bit 0 == '1') */
2123 dasd_3990_erp_compound_retry(erp, sense);
2125 } else {
2127 /* single program action codes (byte25 bit 0 == '0') */
2128 switch (sense[25]) {
2130 case 0x00: /* success */
2131 DEV_MESSAGE(KERN_DEBUG, device,
2132 "ERP called for successful request %p"
2133 " - NO ERP necessary", erp);
2135 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_DONE);
2137 break;
2139 case 0x01: /* fatal error */
2140 DEV_MESSAGE(KERN_ERR, device, "%s",
2141 "Fatal error should have been "
2142 "handled within the interrupt handler");
2144 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2145 break;
2147 case 0x02: /* intervention required */
2148 case 0x03: /* intervention required during dual copy */
2149 erp = dasd_3990_erp_int_req(erp);
2150 break;
2152 case 0x0F: /* length mismatch during update write command */
2153 DEV_MESSAGE(KERN_ERR, device, "%s",
2154 "update write command error - should not "
2155 "happen;\n"
2156 "Please send this message together with "
2157 "the above sense data to linux390@de."
2158 "ibm.com");
2160 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2161 break;
2163 case 0x10: /* logging required for other channel program */
2164 erp = dasd_3990_erp_action_10_32(erp, sense);
2165 break;
2167 case 0x15: /* next track outside defined extend */
2168 DEV_MESSAGE(KERN_ERR, device, "%s",
2169 "next track outside defined extend - "
2170 "should not happen;\n"
2171 "Please send this message together with "
2172 "the above sense data to linux390@de."
2173 "ibm.com");
2175 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2176 break;
2178 case 0x1B: /* unexpected condition during write */
2180 erp = dasd_3990_erp_action_1B_32(erp, sense);
2181 break;
2183 case 0x1C: /* invalid data */
2184 DEV_MESSAGE(KERN_EMERG, device, "%s",
2185 "Data recovered during retry with PCI "
2186 "fetch mode active");
2188 /* not possible to handle this situation in Linux */
2189 panic
2190 ("Invalid data - No way to inform appliction about "
2191 "the possibly incorret data");
2192 break;
2194 case 0x1D: /* state-change pending */
2195 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2196 "A State change pending condition exists "
2197 "for the subsystem or device");
2199 erp = dasd_3990_erp_action_4(erp, sense);
2200 break;
2202 default: /* all others errors - default erp */
2203 break;
2207 return erp;
2209 } /* end dasd_3990_erp_inspect_32 */
2212 *****************************************************************************
2213 * main ERP control fuctions (24 and 32 byte sense)
2214 *****************************************************************************
2218 * DASD_3990_ERP_INSPECT
2220 * DESCRIPTION
2221 * Does a detailed inspection for sense data by calling either
2222 * the 24-byte or the 32-byte inspection routine.
2224 * PARAMETER
2225 * erp pointer to the currently created default ERP
2226 * RETURN VALUES
2227 * erp_new contens was possibly modified
2229 static struct dasd_ccw_req *
2230 dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
2233 struct dasd_ccw_req *erp_new = NULL;
2234 /* sense data are located in the refers record of the */
2235 /* already set up new ERP ! */
2236 char *sense = erp->refers->dstat->ecw;
2238 /* distinguish between 24 and 32 byte sense data */
2239 if (sense[27] & DASD_SENSE_BIT_0) {
2241 /* inspect the 24 byte sense data */
2242 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2244 } else {
2246 /* inspect the 32 byte sense data */
2247 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2249 } /* end distinguish between 24 and 32 byte sense data */
2251 return erp_new;
2253 } /* END dasd_3990_erp_inspect */
2256 * DASD_3990_ERP_ADD_ERP
2258 * DESCRIPTION
2259 * This funtion adds an additional request block (ERP) to the head of
2260 * the given cqr (or erp).
2261 * This erp is initialized as an default erp (retry TIC)
2263 * PARAMETER
2264 * cqr head of the current ERP-chain (or single cqr if
2265 * first error)
2266 * RETURN VALUES
2267 * erp pointer to new ERP-chain head
2269 static struct dasd_ccw_req *
2270 dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)
2273 struct dasd_device *device = cqr->device;
2274 struct ccw1 *ccw;
2276 /* allocate additional request block */
2277 struct dasd_ccw_req *erp;
2279 erp = dasd_alloc_erp_request((char *) &cqr->magic, 2, 0, cqr->device);
2280 if (IS_ERR(erp)) {
2281 if (cqr->retries <= 0) {
2282 DEV_MESSAGE(KERN_ERR, device, "%s",
2283 "Unable to allocate ERP request");
2284 cqr->status = DASD_CQR_FAILED;
2285 cqr->stopclk = get_clock ();
2286 } else {
2287 DEV_MESSAGE (KERN_ERR, device,
2288 "Unable to allocate ERP request "
2289 "(%i retries left)",
2290 cqr->retries);
2291 dasd_set_timer(device, (HZ << 3));
2293 return cqr;
2296 /* initialize request with default TIC to current ERP/CQR */
2297 ccw = erp->cpaddr;
2298 ccw->cmd_code = CCW_CMD_NOOP;
2299 ccw->flags = CCW_FLAG_CC;
2300 ccw++;
2301 ccw->cmd_code = CCW_CMD_TIC;
2302 ccw->cda = (long)(cqr->cpaddr);
2303 erp->function = dasd_3990_erp_add_erp;
2304 erp->refers = cqr;
2305 erp->device = cqr->device;
2306 erp->magic = cqr->magic;
2307 erp->expires = 0;
2308 erp->retries = 256;
2310 erp->status = DASD_CQR_FILLED;
2312 return erp;
2316 * DASD_3990_ERP_ADDITIONAL_ERP
2318 * DESCRIPTION
2319 * An additional ERP is needed to handle the current error.
2320 * Add ERP to the head of the ERP-chain containing the ERP processing
2321 * determined based on the sense data.
2323 * PARAMETER
2324 * cqr head of the current ERP-chain (or single cqr if
2325 * first error)
2327 * RETURN VALUES
2328 * erp pointer to new ERP-chain head
2330 static struct dasd_ccw_req *
2331 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2334 struct dasd_ccw_req *erp = NULL;
2336 /* add erp and initialize with default TIC */
2337 erp = dasd_3990_erp_add_erp(cqr);
2339 /* inspect sense, determine specific ERP if possible */
2340 if (erp != cqr) {
2342 erp = dasd_3990_erp_inspect(erp);
2345 return erp;
2347 } /* end dasd_3990_erp_additional_erp */
2350 * DASD_3990_ERP_ERROR_MATCH
2352 * DESCRIPTION
2353 * Check if the device status of the given cqr is the same.
2354 * This means that the failed CCW and the relevant sense data
2355 * must match.
2356 * I don't distinguish between 24 and 32 byte sense because in case of
2357 * 24 byte sense byte 25 and 27 is set as well.
2359 * PARAMETER
2360 * cqr1 first cqr, which will be compared with the
2361 * cqr2 second cqr.
2363 * RETURN VALUES
2364 * match 'boolean' for match found
2365 * returns 1 if match found, otherwise 0.
2367 static int
2368 dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, struct dasd_ccw_req *cqr2)
2371 /* check failed CCW */
2372 if (cqr1->dstat->scsw.cpa != cqr2->dstat->scsw.cpa) {
2373 // return 0; /* CCW doesn't match */
2376 /* check sense data; byte 0-2,25,27 */
2377 if (!((memcmp (cqr1->dstat->ecw, cqr2->dstat->ecw, 3) == 0) &&
2378 (cqr1->dstat->ecw[27] == cqr2->dstat->ecw[27]) &&
2379 (cqr1->dstat->ecw[25] == cqr2->dstat->ecw[25]))) {
2381 return 0; /* sense doesn't match */
2384 return 1; /* match */
2386 } /* end dasd_3990_erp_error_match */
2389 * DASD_3990_ERP_IN_ERP
2391 * DESCRIPTION
2392 * check if the current error already happened before.
2393 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2395 * PARAMETER
2396 * cqr failed cqr (either original cqr or already an erp)
2398 * RETURN VALUES
2399 * erp erp-pointer to the already defined error
2400 * recovery procedure OR
2401 * NULL if a 'new' error occurred.
2403 static struct dasd_ccw_req *
2404 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2407 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2408 *erp_match = NULL; /* save erp chain head */
2409 int match = 0; /* 'boolean' for matching error found */
2411 if (cqr->refers == NULL) { /* return if not in erp */
2412 return NULL;
2415 /* check the erp/cqr chain for current error */
2416 do {
2417 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2418 erp_match = cqr; /* save possible matching erp */
2419 cqr = cqr->refers; /* check next erp/cqr in queue */
2421 } while ((cqr->refers != NULL) && (!match));
2423 if (!match) {
2424 return NULL; /* no match was found */
2427 return erp_match; /* return address of matching erp */
2429 } /* END dasd_3990_erp_in_erp */
2432 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2434 * DESCRIPTION
2435 * No retry is left for the current ERP. Check what has to be done
2436 * with the ERP.
2437 * - do further defined ERP action or
2438 * - wait for interrupt or
2439 * - exit with permanent error
2441 * PARAMETER
2442 * erp ERP which is in progress with no retry left
2444 * RETURN VALUES
2445 * erp modified/additional ERP
2447 static struct dasd_ccw_req *
2448 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2451 struct dasd_device *device = erp->device;
2452 char *sense = erp->dstat->ecw;
2454 /* check for 24 byte sense ERP */
2455 if ((erp->function == dasd_3990_erp_bus_out) ||
2456 (erp->function == dasd_3990_erp_action_1) ||
2457 (erp->function == dasd_3990_erp_action_4)) {
2459 erp = dasd_3990_erp_action_1(erp);
2461 } else if (erp->function == dasd_3990_erp_action_5) {
2463 /* retries have not been successful */
2464 /* prepare erp for retry on different channel path */
2465 erp = dasd_3990_erp_action_1(erp);
2467 if (!(sense[2] & DASD_SENSE_BIT_0)) {
2469 /* issue a Diagnostic Control command with an
2470 * Inhibit Write subcommand */
2472 switch (sense[25]) {
2473 case 0x17:
2474 case 0x57:{ /* controller */
2475 erp = dasd_3990_erp_DCTL(erp, 0x20);
2476 break;
2478 case 0x18:
2479 case 0x58:{ /* channel path */
2480 erp = dasd_3990_erp_DCTL(erp, 0x40);
2481 break;
2483 case 0x19:
2484 case 0x59:{ /* storage director */
2485 erp = dasd_3990_erp_DCTL(erp, 0x80);
2486 break;
2488 default:
2489 DEV_MESSAGE(KERN_DEBUG, device,
2490 "invalid subcommand modifier 0x%x "
2491 "for Diagnostic Control Command",
2492 sense[25]);
2496 /* check for 32 byte sense ERP */
2497 } else if ((erp->function == dasd_3990_erp_compound_retry) ||
2498 (erp->function == dasd_3990_erp_compound_path) ||
2499 (erp->function == dasd_3990_erp_compound_code) ||
2500 (erp->function == dasd_3990_erp_compound_config)) {
2502 erp = dasd_3990_erp_compound(erp, sense);
2504 } else {
2505 /* no retry left and no additional special handling necessary */
2506 DEV_MESSAGE(KERN_ERR, device,
2507 "no retries left for erp %p - "
2508 "set status to FAILED", erp);
2510 erp->status = DASD_CQR_FAILED;
2513 return erp;
2515 } /* end dasd_3990_erp_further_erp */
2518 * DASD_3990_ERP_HANDLE_MATCH_ERP
2520 * DESCRIPTION
2521 * An error occurred again and an ERP has been detected which is already
2522 * used to handle this error (e.g. retries).
2523 * All prior ERP's are asumed to be successful and therefore removed
2524 * from queue.
2525 * If retry counter of matching erp is already 0, it is checked if further
2526 * action is needed (besides retry) or if the ERP has failed.
2528 * PARAMETER
2529 * erp_head first ERP in ERP-chain
2530 * erp ERP that handles the actual error.
2531 * (matching erp)
2533 * RETURN VALUES
2534 * erp modified/additional ERP
2536 static struct dasd_ccw_req *
2537 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2538 struct dasd_ccw_req *erp)
2541 struct dasd_device *device = erp_head->device;
2542 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2543 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2545 /* loop over successful ERPs and remove them from chanq */
2546 while (erp_done != erp) {
2548 if (erp_done == NULL) /* end of chain reached */
2549 panic(PRINTK_HEADER "Programming error in ERP! The "
2550 "original request was lost\n");
2552 /* remove the request from the device queue */
2553 list_del(&erp_done->list);
2555 erp_free = erp_done;
2556 erp_done = erp_done->refers;
2558 /* free the finished erp request */
2559 dasd_free_erp_request(erp_free, erp_free->device);
2561 } /* end while */
2563 if (erp->retries > 0) {
2565 char *sense = erp->refers->dstat->ecw;
2567 /* check for special retries */
2568 if (erp->function == dasd_3990_erp_action_4) {
2570 erp = dasd_3990_erp_action_4(erp, sense);
2572 } else if (erp->function == dasd_3990_erp_action_1B_32) {
2574 erp = dasd_3990_update_1B(erp, sense);
2576 } else if (erp->function == dasd_3990_erp_int_req) {
2578 erp = dasd_3990_erp_int_req(erp);
2580 } else {
2581 /* simple retry */
2582 DEV_MESSAGE(KERN_DEBUG, device,
2583 "%i retries left for erp %p",
2584 erp->retries, erp);
2586 /* handle the request again... */
2587 erp->status = DASD_CQR_QUEUED;
2590 } else {
2591 /* no retry left - check for further necessary action */
2592 /* if no further actions, handle rest as permanent error */
2593 erp = dasd_3990_erp_further_erp(erp);
2596 return erp;
2598 } /* end dasd_3990_erp_handle_match_erp */
2601 * DASD_3990_ERP_ACTION
2603 * DESCRIPTION
2604 * controll routine for 3990 erp actions.
2605 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2607 * PARAMETER
2608 * cqr failed cqr (either original cqr or already an erp)
2610 * RETURN VALUES
2611 * erp erp-pointer to the head of the ERP action chain.
2612 * This means:
2613 * - either a ptr to an additional ERP cqr or
2614 * - the original given cqr (which's status might
2615 * be modified)
2617 struct dasd_ccw_req *
2618 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2621 struct dasd_ccw_req *erp = NULL;
2622 struct dasd_device *device = cqr->device;
2623 __u32 cpa = cqr->dstat->scsw.cpa;
2625 #ifdef ERP_DEBUG
2626 /* print current erp_chain */
2627 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2628 "ERP chain at BEGINNING of ERP-ACTION");
2630 struct dasd_ccw_req *temp_erp = NULL;
2632 for (temp_erp = cqr;
2633 temp_erp != NULL; temp_erp = temp_erp->refers) {
2635 DEV_MESSAGE(KERN_DEBUG, device,
2636 " erp %p refers to %p",
2637 temp_erp, temp_erp->refers);
2640 #endif /* ERP_DEBUG */
2642 /* double-check if current erp/cqr was successfull */
2643 if ((cqr->dstat->scsw.cstat == 0x00) &&
2644 (cqr->dstat->scsw.dstat == (DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2646 DEV_MESSAGE(KERN_DEBUG, device,
2647 "ERP called for successful request %p"
2648 " - NO ERP necessary", cqr);
2650 cqr->status = DASD_CQR_DONE;
2652 return cqr;
2654 /* check if sense data are available */
2655 if (!cqr->dstat->ecw) {
2656 DEV_MESSAGE(KERN_DEBUG, device,
2657 "ERP called witout sense data avail ..."
2658 "request %p - NO ERP possible", cqr);
2660 cqr->status = DASD_CQR_FAILED;
2662 return cqr;
2666 /* check if error happened before */
2667 erp = dasd_3990_erp_in_erp(cqr);
2669 if (erp == NULL) {
2670 /* no matching erp found - set up erp */
2671 erp = dasd_3990_erp_additional_erp(cqr);
2672 } else {
2673 /* matching erp found - set all leading erp's to DONE */
2674 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2677 #ifdef ERP_DEBUG
2678 /* print current erp_chain */
2679 DEV_MESSAGE(KERN_DEBUG, device, "%s", "ERP chain at END of ERP-ACTION");
2681 struct dasd_ccw_req *temp_erp = NULL;
2682 for (temp_erp = erp;
2683 temp_erp != NULL; temp_erp = temp_erp->refers) {
2685 DEV_MESSAGE(KERN_DEBUG, device,
2686 " erp %p refers to %p",
2687 temp_erp, temp_erp->refers);
2690 #endif /* ERP_DEBUG */
2692 if (erp->status == DASD_CQR_FAILED)
2693 dasd_log_ccw(erp, 1, cpa);
2695 /* enqueue added ERP request */
2696 if (erp->status == DASD_CQR_FILLED) {
2697 erp->status = DASD_CQR_QUEUED;
2698 list_add(&erp->list, &device->ccw_queue);
2701 return erp;
2703 } /* end dasd_3990_erp_action */
2706 * Overrides for Emacs so that we follow Linus's tabbing style.
2707 * Emacs will notice this stuff at the end of the file and automatically
2708 * adjust the settings for this buffer only. This must remain at the end
2709 * of the file.
2710 * ---------------------------------------------------------------------------
2711 * Local variables:
2712 * c-indent-level: 4
2713 * c-brace-imaginary-offset: 0
2714 * c-brace-offset: -4
2715 * c-argdecl-indent: 4
2716 * c-label-offset: -4
2717 * c-continued-statement-offset: 4
2718 * c-continued-brace-offset: 0
2719 * indent-tabs-mode: 1
2720 * tab-width: 8
2721 * End: