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
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): "
19 #include "dasd_eckd.h"
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
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.
49 * dasd_era_fatal for all fatal (unrecoverable errors)
50 * dasd_era_recover for all others.
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 - "
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 "
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
100 * Checks only for fatal/no/recoverable error.
101 * A detailed examination of the sense data is done later outside
102 * the interrupt handler.
105 * dasd_era_none no error
106 * dasd_era_fatal for all fatal (unrecoverable errors)
107 * dasd_era_recover for recoverable others.
110 dasd_3990_erp_examine_32(struct dasd_ccw_req * cqr, char *sense)
113 struct dasd_device *device = cqr->device;
117 return dasd_era_none;
120 DEV_MESSAGE(KERN_ERR, device, "%s", "EXAMINE 32: fatal error");
122 return dasd_era_fatal;
126 return dasd_era_recover;
129 } /* end dasd_3990_erp_examine_32 */
132 * DASD_3990_ERP_EXAMINE
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'.
143 * dasd_era_none no error
144 * dasd_era_fatal for all fatal (unrecoverable errors)
145 * dasd_era_recover for all others.
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);
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);
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
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
200 * erp request to be blocked
201 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
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;
215 } /* end dasd_3990_erp_cleanup */
218 * DASD_3990_ERP_BLOCK_QUEUE
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.
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/HZ);
234 device->stopped |= DASD_STOPPED_PENDING;
235 erp->status = DASD_CQR_QUEUED;
237 dasd_set_timer(device, expires);
241 * DASD_3990_ERP_INT_REQ
244 * Handles 'Intervention Required' error.
245 * This means either device offline or not installed.
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) {
264 erp->function = dasd_3990_erp_int_req;
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);
278 } /* end dasd_3990_erp_int_req */
281 * DASD_3990_ERP_ALTERNATE_PATH
284 * Repeat the operation on a different channel path.
285 * If all alternate paths have been tried, the request is posted with a
289 * erp pointer to the current ERP
292 * erp modified pointer to the ERP
295 dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
297 struct dasd_device *device = erp->device;
300 /* try alternate valid path */
301 opm = ccw_device_get_path_mask(device->cdev);
302 //FIXME: start with get_opm ?
304 erp->lpm = LPM_ANYPATH & ~(erp->dstat->esw.esw0.sublog.lpum);
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 if (erp->status > DASD_CQR_QUEUED)
316 erp->status = DASD_CQR_QUEUED;
319 DEV_MESSAGE(KERN_ERR, device,
320 "No alternate channel path left (lpum=%x / "
321 "opm=%x) -> permanent error",
322 erp->dstat->esw.esw0.sublog.lpum, opm);
324 /* post request with permanent error */
325 if (erp->status > DASD_CQR_QUEUED)
326 erp->status = DASD_CQR_FAILED;
328 } /* end dasd_3990_erp_alternate_path */
334 * Setup cqr to do the Diagnostic Control (DCTL) command with an
335 * Inhibit Write subcommand (0x20) and the given modifier.
338 * erp pointer to the current (failed) ERP
339 * modifier subcommand modifier
342 * dctl_cqr pointer to NEW dctl_cqr
345 static struct dasd_ccw_req *
346 dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
349 struct dasd_device *device = erp->device;
350 struct DCTL_data *DCTL_data;
352 struct dasd_ccw_req *dctl_cqr;
354 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
355 sizeof (struct DCTL_data),
357 if (IS_ERR(dctl_cqr)) {
358 DEV_MESSAGE(KERN_ERR, device, "%s",
359 "Unable to allocate DCTL-CQR");
360 erp->status = DASD_CQR_FAILED;
364 DCTL_data = dctl_cqr->data;
366 DCTL_data->subcommand = 0x02; /* Inhibit Write */
367 DCTL_data->modifier = modifier;
369 ccw = dctl_cqr->cpaddr;
370 memset(ccw, 0, sizeof (struct ccw1));
371 ccw->cmd_code = CCW_CMD_DCTL;
373 ccw->cda = (__u32)(addr_t) DCTL_data;
374 dctl_cqr->function = dasd_3990_erp_DCTL;
375 dctl_cqr->refers = erp;
376 dctl_cqr->device = erp->device;
377 dctl_cqr->magic = erp->magic;
378 dctl_cqr->expires = 5 * 60 * HZ;
379 dctl_cqr->retries = 2;
381 dctl_cqr->buildclk = get_clock();
383 dctl_cqr->status = DASD_CQR_FILLED;
387 } /* end dasd_3990_erp_DCTL */
390 * DASD_3990_ERP_ACTION_1
393 * Setup ERP to do the ERP action 1 (see Reference manual).
394 * Repeat the operation on a different channel path.
395 * If all alternate paths have been tried, the request is posted with a
397 * Note: duplex handling is not implemented (yet).
400 * erp pointer to the current ERP
403 * erp pointer to the ERP
406 static struct dasd_ccw_req *
407 dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
410 erp->function = dasd_3990_erp_action_1;
412 dasd_3990_erp_alternate_path(erp);
416 } /* end dasd_3990_erp_action_1 */
419 * DASD_3990_ERP_ACTION_4
422 * Setup ERP to do the ERP action 4 (see Reference manual).
423 * Set the current request to PENDING to block the CQR queue for that device
424 * until the state change interrupt appears.
425 * Use a timer (20 seconds) to retry the cqr if the interrupt is still missing.
428 * sense sense data of the actual error
429 * erp pointer to the current ERP
432 * erp pointer to the ERP
435 static struct dasd_ccw_req *
436 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
439 struct dasd_device *device = erp->device;
441 /* first time set initial retry counter and erp_function */
442 /* and retry once without waiting for state change pending */
443 /* interrupt (this enables easier enqueing of the cqr) */
444 if (erp->function != dasd_3990_erp_action_4) {
447 erp->function = dasd_3990_erp_action_4;
451 if (sense[25] == 0x1D) { /* state change pending */
453 DEV_MESSAGE(KERN_INFO, device,
454 "waiting for state change pending "
455 "interrupt, %d retries left",
458 dasd_3990_erp_block_queue(erp, 30*HZ);
462 /* no state change pending - retry */
463 DEV_MESSAGE (KERN_INFO, device,
464 "redriving request immediately, "
467 erp->status = DASD_CQR_QUEUED;
473 } /* end dasd_3990_erp_action_4 */
476 *****************************************************************************
477 * 24 byte sense ERP functions (only)
478 *****************************************************************************
482 * DASD_3990_ERP_ACTION_5
485 * Setup ERP to do the ERP action 5 (see Reference manual).
486 * NOTE: Further handling is done in xxx_further_erp after the retries.
489 * erp pointer to the current ERP
492 * erp pointer to the ERP
495 static struct dasd_ccw_req *
496 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
499 /* first of all retry */
501 erp->function = dasd_3990_erp_action_5;
505 } /* end dasd_3990_erp_action_5 */
508 * DASD_3990_HANDLE_ENV_DATA
511 * Handles 24 byte 'Environmental data present'.
512 * Does a analysis of the sense data (message Format)
513 * and prints the error messages.
516 * sense current sense data
522 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
525 struct dasd_device *device = erp->device;
526 char msg_format = (sense[7] & 0xF0);
527 char msg_no = (sense[7] & 0x0F);
529 switch (msg_format) {
530 case 0x00: /* Format 0 - Program or System Checks */
532 if (sense[1] & 0x10) { /* check message to operator bit */
535 case 0x00: /* No Message */
538 DEV_MESSAGE(KERN_WARNING, device, "%s",
539 "FORMAT 0 - Invalid Command");
542 DEV_MESSAGE(KERN_WARNING, device, "%s",
543 "FORMAT 0 - Invalid Command "
547 DEV_MESSAGE(KERN_WARNING, device, "%s",
548 "FORMAT 0 - CCW Count less than "
552 DEV_MESSAGE(KERN_WARNING, device, "%s",
553 "FORMAT 0 - Invalid Parameter");
556 DEV_MESSAGE(KERN_WARNING, device, "%s",
557 "FORMAT 0 - Diagnostic of Sepecial"
558 " Command Violates File Mask");
561 DEV_MESSAGE(KERN_WARNING, device, "%s",
562 "FORMAT 0 - Channel Returned with "
563 "Incorrect retry CCW");
566 DEV_MESSAGE(KERN_WARNING, device, "%s",
567 "FORMAT 0 - Reset Notification");
570 DEV_MESSAGE(KERN_WARNING, device, "%s",
571 "FORMAT 0 - Storage Path Restart");
574 DEV_MESSAGE(KERN_WARNING, device,
575 "FORMAT 0 - Channel requested "
576 "... %02x", sense[8]);
579 DEV_MESSAGE(KERN_WARNING, device, "%s",
580 "FORMAT 0 - Invalid Defective/"
581 "Alternate Track Pointer");
584 DEV_MESSAGE(KERN_WARNING, device, "%s",
585 "FORMAT 0 - DPS Installation "
589 DEV_MESSAGE(KERN_WARNING, device, "%s",
590 "FORMAT 0 - Command Invalid on "
591 "Secondary Address");
594 DEV_MESSAGE(KERN_WARNING, device,
595 "FORMAT 0 - Status Not As "
596 "Required: reason %02x", sense[8]);
599 DEV_MESSAGE(KERN_WARNING, device, "%s",
600 "FORMAT 0 - Reseved");
604 case 0x00: /* No Message */
607 DEV_MESSAGE(KERN_WARNING, device, "%s",
608 "FORMAT 0 - Device Error Source");
611 DEV_MESSAGE(KERN_WARNING, device, "%s",
612 "FORMAT 0 - Reserved");
615 DEV_MESSAGE(KERN_WARNING, device,
616 "FORMAT 0 - Device Fenced - "
617 "device = %02x", sense[4]);
620 DEV_MESSAGE(KERN_WARNING, device, "%s",
621 "FORMAT 0 - Data Pinned for "
625 DEV_MESSAGE(KERN_WARNING, device, "%s",
626 "FORMAT 0 - Reserved");
631 case 0x10: /* Format 1 - Device Equipment Checks */
633 case 0x00: /* No Message */
636 DEV_MESSAGE(KERN_WARNING, device, "%s",
637 "FORMAT 1 - Device Status 1 not as "
641 DEV_MESSAGE(KERN_WARNING, device, "%s",
642 "FORMAT 1 - Index missing");
645 DEV_MESSAGE(KERN_WARNING, device, "%s",
646 "FORMAT 1 - Interruption cannot be reset");
649 DEV_MESSAGE(KERN_WARNING, device, "%s",
650 "FORMAT 1 - Device did not respond to "
654 DEV_MESSAGE(KERN_WARNING, device, "%s",
655 "FORMAT 1 - Device check-2 error or Set "
656 "Sector is not complete");
659 DEV_MESSAGE(KERN_WARNING, device, "%s",
660 "FORMAT 1 - Head address does not "
664 DEV_MESSAGE(KERN_WARNING, device, "%s",
665 "FORMAT 1 - Device status 1 not valid");
668 DEV_MESSAGE(KERN_WARNING, device, "%s",
669 "FORMAT 1 - Device not ready");
672 DEV_MESSAGE(KERN_WARNING, device, "%s",
673 "FORMAT 1 - Track physical address did "
677 DEV_MESSAGE(KERN_WARNING, device, "%s",
678 "FORMAT 1 - Missing device address bit");
681 DEV_MESSAGE(KERN_WARNING, device, "%s",
682 "FORMAT 1 - Drive motor switch is off");
685 DEV_MESSAGE(KERN_WARNING, device, "%s",
686 "FORMAT 1 - Seek incomplete");
689 DEV_MESSAGE(KERN_WARNING, device, "%s",
690 "FORMAT 1 - Cylinder address did not "
694 DEV_MESSAGE(KERN_WARNING, device, "%s",
695 "FORMAT 1 - Offset active cannot be "
699 DEV_MESSAGE(KERN_WARNING, device, "%s",
700 "FORMAT 1 - Reserved");
704 case 0x20: /* Format 2 - 3990 Equipment Checks */
707 DEV_MESSAGE(KERN_WARNING, device, "%s",
708 "FORMAT 2 - 3990 check-2 error");
711 DEV_MESSAGE(KERN_WARNING, device, "%s",
712 "FORMAT 2 - Support facility errors");
715 DEV_MESSAGE(KERN_WARNING, device,
716 "FORMAT 2 - Microcode detected error %02x",
720 DEV_MESSAGE(KERN_WARNING, device, "%s",
721 "FORMAT 2 - Reserved");
725 case 0x30: /* Format 3 - 3990 Control Checks */
728 DEV_MESSAGE(KERN_WARNING, device, "%s",
729 "FORMAT 3 - Allegiance terminated");
732 DEV_MESSAGE(KERN_WARNING, device, "%s",
733 "FORMAT 3 - Reserved");
737 case 0x40: /* Format 4 - Data Checks */
740 DEV_MESSAGE(KERN_WARNING, device, "%s",
741 "FORMAT 4 - Home address area error");
744 DEV_MESSAGE(KERN_WARNING, device, "%s",
745 "FORMAT 4 - Count area error");
748 DEV_MESSAGE(KERN_WARNING, device, "%s",
749 "FORMAT 4 - Key area error");
752 DEV_MESSAGE(KERN_WARNING, device, "%s",
753 "FORMAT 4 - Data area error");
756 DEV_MESSAGE(KERN_WARNING, device, "%s",
757 "FORMAT 4 - No sync byte in home address "
761 DEV_MESSAGE(KERN_WARNING, device, "%s",
762 "FORMAT 4 - No sync byte in count address "
766 DEV_MESSAGE(KERN_WARNING, device, "%s",
767 "FORMAT 4 - No sync byte in key area");
770 DEV_MESSAGE(KERN_WARNING, device, "%s",
771 "FORMAT 4 - No sync byte in data area");
774 DEV_MESSAGE(KERN_WARNING, device, "%s",
775 "FORMAT 4 - Home address area error; "
779 DEV_MESSAGE(KERN_WARNING, device, "%s",
780 "FORMAT 4 - Count area error; offset "
784 DEV_MESSAGE(KERN_WARNING, device, "%s",
785 "FORMAT 4 - Key area error; offset "
789 DEV_MESSAGE(KERN_WARNING, device, "%s",
790 "FORMAT 4 - Data area error; "
794 DEV_MESSAGE(KERN_WARNING, device, "%s",
795 "FORMAT 4 - No sync byte in home "
796 "address area; offset active");
799 DEV_MESSAGE(KERN_WARNING, device, "%s",
800 "FORMAT 4 - No syn byte in count "
801 "address area; offset active");
804 DEV_MESSAGE(KERN_WARNING, device, "%s",
805 "FORMAT 4 - No sync byte in key area; "
809 DEV_MESSAGE(KERN_WARNING, device, "%s",
810 "FORMAT 4 - No syn byte in data area; "
814 DEV_MESSAGE(KERN_WARNING, device, "%s",
815 "FORMAT 4 - Reserved");
819 case 0x50: /* Format 5 - Data Check with displacement information */
822 DEV_MESSAGE(KERN_WARNING, device, "%s",
823 "FORMAT 5 - Data Check in the "
824 "home address area");
827 DEV_MESSAGE(KERN_WARNING, device, "%s",
828 "FORMAT 5 - Data Check in the count area");
831 DEV_MESSAGE(KERN_WARNING, device, "%s",
832 "FORMAT 5 - Data Check in the key area");
835 DEV_MESSAGE(KERN_WARNING, device, "%s",
836 "FORMAT 5 - Data Check in the data area");
839 DEV_MESSAGE(KERN_WARNING, device, "%s",
840 "FORMAT 5 - Data Check in the "
841 "home address area; offset active");
844 DEV_MESSAGE(KERN_WARNING, device, "%s",
845 "FORMAT 5 - Data Check in the count area; "
849 DEV_MESSAGE(KERN_WARNING, device, "%s",
850 "FORMAT 5 - Data Check in the key area; "
854 DEV_MESSAGE(KERN_WARNING, device, "%s",
855 "FORMAT 5 - Data Check in the data area; "
859 DEV_MESSAGE(KERN_WARNING, device, "%s",
860 "FORMAT 5 - Reserved");
864 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
867 DEV_MESSAGE(KERN_WARNING, device, "%s",
868 "FORMAT 6 - Overrun on channel A");
871 DEV_MESSAGE(KERN_WARNING, device, "%s",
872 "FORMAT 6 - Overrun on channel B");
875 DEV_MESSAGE(KERN_WARNING, device, "%s",
876 "FORMAT 6 - Overrun on channel C");
879 DEV_MESSAGE(KERN_WARNING, device, "%s",
880 "FORMAT 6 - Overrun on channel D");
883 DEV_MESSAGE(KERN_WARNING, device, "%s",
884 "FORMAT 6 - Overrun on channel E");
887 DEV_MESSAGE(KERN_WARNING, device, "%s",
888 "FORMAT 6 - Overrun on channel F");
891 DEV_MESSAGE(KERN_WARNING, device, "%s",
892 "FORMAT 6 - Overrun on channel G");
895 DEV_MESSAGE(KERN_WARNING, device, "%s",
896 "FORMAT 6 - Overrun on channel H");
899 DEV_MESSAGE(KERN_WARNING, device, "%s",
900 "FORMAT 6 - Reserved");
904 case 0x70: /* Format 7 - Device Connection Control Checks */
907 DEV_MESSAGE(KERN_WARNING, device, "%s",
908 "FORMAT 7 - RCC initiated by a connection "
912 DEV_MESSAGE(KERN_WARNING, device, "%s",
913 "FORMAT 7 - RCC 1 sequence not "
917 DEV_MESSAGE(KERN_WARNING, device, "%s",
918 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
922 DEV_MESSAGE(KERN_WARNING, device, "%s",
923 "FORMAT 7 - Invalid tag-in during "
924 "selection sequence");
927 DEV_MESSAGE(KERN_WARNING, device, "%s",
928 "FORMAT 7 - extra RCC required");
931 DEV_MESSAGE(KERN_WARNING, device, "%s",
932 "FORMAT 7 - Invalid DCC selection "
933 "response or timeout");
936 DEV_MESSAGE(KERN_WARNING, device, "%s",
937 "FORMAT 7 - Missing end operation; device "
938 "transfer complete");
941 DEV_MESSAGE(KERN_WARNING, device, "%s",
942 "FORMAT 7 - Missing end operation; device "
943 "transfer incomplete");
946 DEV_MESSAGE(KERN_WARNING, device, "%s",
947 "FORMAT 7 - Invalid tag-in for an "
948 "immediate command sequence");
951 DEV_MESSAGE(KERN_WARNING, device, "%s",
952 "FORMAT 7 - Invalid tag-in for an "
953 "extended command sequence");
956 DEV_MESSAGE(KERN_WARNING, device, "%s",
957 "FORMAT 7 - 3990 microcode time out when "
958 "stopping selection");
961 DEV_MESSAGE(KERN_WARNING, device, "%s",
962 "FORMAT 7 - No response to selection "
963 "after a poll interruption");
966 DEV_MESSAGE(KERN_WARNING, device, "%s",
967 "FORMAT 7 - Permanent path error (DASD "
968 "controller not available)");
971 DEV_MESSAGE(KERN_WARNING, device, "%s",
972 "FORMAT 7 - DASD controller not available"
973 " on disconnected command chain");
976 DEV_MESSAGE(KERN_WARNING, device, "%s",
977 "FORMAT 7 - Reserved");
981 case 0x80: /* Format 8 - Additional Device Equipment Checks */
983 case 0x00: /* No Message */
985 DEV_MESSAGE(KERN_WARNING, device, "%s",
986 "FORMAT 8 - Error correction code "
990 DEV_MESSAGE(KERN_WARNING, device, "%s",
991 "FORMAT 8 - Unexpected end operation "
995 DEV_MESSAGE(KERN_WARNING, device, "%s",
996 "FORMAT 8 - End operation with transfer "
1000 DEV_MESSAGE(KERN_WARNING, device, "%s",
1001 "FORMAT 8 - End operation with transfer "
1005 DEV_MESSAGE(KERN_WARNING, device, "%s",
1006 "FORMAT 8 - DPS checks after a system "
1007 "reset or selective reset");
1010 DEV_MESSAGE(KERN_WARNING, device, "%s",
1011 "FORMAT 8 - DPS cannot be filled");
1014 DEV_MESSAGE(KERN_WARNING, device, "%s",
1015 "FORMAT 8 - Short busy time-out during "
1016 "device selection");
1019 DEV_MESSAGE(KERN_WARNING, device, "%s",
1020 "FORMAT 8 - DASD controller failed to "
1021 "set or reset the long busy latch");
1024 DEV_MESSAGE(KERN_WARNING, device, "%s",
1025 "FORMAT 8 - No interruption from device "
1026 "during a command chain");
1029 DEV_MESSAGE(KERN_WARNING, device, "%s",
1030 "FORMAT 8 - Reserved");
1034 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
1037 break; /* No Message */
1039 DEV_MESSAGE(KERN_WARNING, device, "%s",
1040 "FORMAT 9 - Device check-2 error");
1043 DEV_MESSAGE(KERN_WARNING, device, "%s",
1044 "FORMAT 9 - Head address did not compare");
1047 DEV_MESSAGE(KERN_WARNING, device, "%s",
1048 "FORMAT 9 - Track physical address did "
1049 "not compare while oriented");
1052 DEV_MESSAGE(KERN_WARNING, device, "%s",
1053 "FORMAT 9 - Cylinder address did not "
1057 DEV_MESSAGE(KERN_WARNING, device, "%s",
1058 "FORMAT 9 - Reserved");
1062 case 0xF0: /* Format F - Cache Storage Checks */
1065 DEV_MESSAGE(KERN_WARNING, device, "%s",
1066 "FORMAT F - Operation Terminated");
1069 DEV_MESSAGE(KERN_WARNING, device, "%s",
1070 "FORMAT F - Subsystem Processing Error");
1073 DEV_MESSAGE(KERN_WARNING, device, "%s",
1074 "FORMAT F - Cache or nonvolatile storage "
1075 "equipment failure");
1078 DEV_MESSAGE(KERN_WARNING, device, "%s",
1079 "FORMAT F - Caching terminated");
1082 DEV_MESSAGE(KERN_WARNING, device, "%s",
1083 "FORMAT F - Cache fast write access not "
1087 DEV_MESSAGE(KERN_WARNING, device, "%s",
1088 "FORMAT F - Track format incorrect");
1091 DEV_MESSAGE(KERN_WARNING, device, "%s",
1092 "FORMAT F - Caching reinitiated");
1095 DEV_MESSAGE(KERN_WARNING, device, "%s",
1096 "FORMAT F - Nonvolatile storage "
1100 DEV_MESSAGE(KERN_WARNING, device, "%s",
1101 "FORMAT F - Volume is suspended duplex");
1104 DEV_MESSAGE(KERN_WARNING, device, "%s",
1105 "FORMAT F - Subsystem status connot be "
1109 DEV_MESSAGE(KERN_WARNING, device, "%s",
1110 "FORMAT F - Caching status reset to "
1114 DEV_MESSAGE(KERN_WARNING, device, "%s",
1115 "FORMAT F - DASD Fast Write inhibited");
1118 DEV_MESSAGE(KERN_WARNING, device, "%s",
1119 "FORMAT D - Reserved");
1123 default: /* unknown message format - should not happen */
1124 DEV_MESSAGE (KERN_WARNING, device,
1125 "unknown message format %02x",
1128 } /* end switch message format */
1130 } /* end dasd_3990_handle_env_data */
1133 * DASD_3990_ERP_COM_REJ
1136 * Handles 24 byte 'Command Reject' error.
1139 * erp current erp_head
1140 * sense current sense data
1143 * erp 'new' erp_head - pointer to new ERP
1145 static struct dasd_ccw_req *
1146 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1149 struct dasd_device *device = erp->device;
1151 erp->function = dasd_3990_erp_com_rej;
1153 /* env data present (ACTION 10 - retry should work) */
1154 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1156 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1157 "Command Reject - environmental data present");
1159 dasd_3990_handle_env_data(erp, sense);
1164 /* fatal error - set status to FAILED */
1165 DEV_MESSAGE(KERN_ERR, device, "%s",
1166 "Command Reject - Fatal error");
1168 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1173 } /* end dasd_3990_erp_com_rej */
1176 * DASD_3990_ERP_BUS_OUT
1179 * Handles 24 byte 'Bus Out Parity Check' error.
1182 * erp current erp_head
1184 * erp new erp_head - pointer to new ERP
1186 static struct dasd_ccw_req *
1187 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1190 struct dasd_device *device = erp->device;
1192 /* first time set initial retry counter and erp_function */
1193 /* and retry once without blocking queue */
1194 /* (this enables easier enqueing of the cqr) */
1195 if (erp->function != dasd_3990_erp_bus_out) {
1197 erp->function = dasd_3990_erp_bus_out;
1201 /* issue a message and wait for 'device ready' interrupt */
1202 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1203 "bus out parity error or BOPC requested by "
1206 dasd_3990_erp_block_queue(erp, 60*HZ);
1212 } /* end dasd_3990_erp_bus_out */
1215 * DASD_3990_ERP_EQUIP_CHECK
1218 * Handles 24 byte 'Equipment Check' error.
1221 * erp current erp_head
1223 * erp new erp_head - pointer to new ERP
1225 static struct dasd_ccw_req *
1226 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1229 struct dasd_device *device = erp->device;
1231 erp->function = dasd_3990_erp_equip_check;
1233 if (sense[1] & SNS1_WRITE_INHIBITED) {
1235 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1236 "Write inhibited path encountered");
1238 /* vary path offline */
1239 DEV_MESSAGE(KERN_ERR, device, "%s",
1240 "Path should be varied off-line. "
1241 "This is not implemented yet \n - please report "
1242 "to linux390@de.ibm.com");
1244 erp = dasd_3990_erp_action_1(erp);
1246 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1248 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1249 "Equipment Check - " "environmental data present");
1251 dasd_3990_handle_env_data(erp, sense);
1253 erp = dasd_3990_erp_action_4(erp, sense);
1255 } else if (sense[1] & SNS1_PERM_ERR) {
1257 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1258 "Equipment Check - retry exhausted or "
1261 erp = dasd_3990_erp_action_1(erp);
1264 /* all other equipment checks - Action 5 */
1265 /* rest is done when retries == 0 */
1266 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1267 "Equipment check or processing error");
1269 erp = dasd_3990_erp_action_5(erp);
1274 } /* end dasd_3990_erp_equip_check */
1277 * DASD_3990_ERP_DATA_CHECK
1280 * Handles 24 byte 'Data Check' error.
1283 * erp current erp_head
1285 * erp new erp_head - pointer to new ERP
1287 static struct dasd_ccw_req *
1288 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1291 struct dasd_device *device = erp->device;
1293 erp->function = dasd_3990_erp_data_check;
1295 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1297 /* issue message that the data has been corrected */
1298 DEV_MESSAGE(KERN_EMERG, device, "%s",
1299 "Data recovered during retry with PCI "
1300 "fetch mode active");
1302 /* not possible to handle this situation in Linux */
1303 panic("No way to inform appliction about the possibly "
1306 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1308 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1309 "Uncorrectable data check recovered secondary "
1310 "addr of duplex pair");
1312 erp = dasd_3990_erp_action_4(erp, sense);
1314 } else if (sense[1] & SNS1_PERM_ERR) {
1316 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1317 "Uncorrectable data check with internal "
1320 erp = dasd_3990_erp_action_1(erp);
1323 /* all other data checks */
1324 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1325 "Uncorrectable data check with retry count "
1328 erp = dasd_3990_erp_action_5(erp);
1333 } /* end dasd_3990_erp_data_check */
1336 * DASD_3990_ERP_OVERRUN
1339 * Handles 24 byte 'Overrun' error.
1342 * erp current erp_head
1344 * erp new erp_head - pointer to new ERP
1346 static struct dasd_ccw_req *
1347 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1350 struct dasd_device *device = erp->device;
1352 erp->function = dasd_3990_erp_overrun;
1354 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1355 "Overrun - service overrun or overrun"
1356 " error requested by channel");
1358 erp = dasd_3990_erp_action_5(erp);
1362 } /* end dasd_3990_erp_overrun */
1365 * DASD_3990_ERP_INV_FORMAT
1368 * Handles 24 byte 'Invalid Track Format' error.
1371 * erp current erp_head
1373 * erp new erp_head - pointer to new ERP
1375 static struct dasd_ccw_req *
1376 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1379 struct dasd_device *device = erp->device;
1381 erp->function = dasd_3990_erp_inv_format;
1383 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1385 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1386 "Track format error when destaging or "
1389 dasd_3990_handle_env_data(erp, sense);
1391 erp = dasd_3990_erp_action_4(erp, sense);
1394 DEV_MESSAGE(KERN_ERR, device, "%s",
1395 "Invalid Track Format - Fatal error should have "
1396 "been handled within the interrupt handler");
1398 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1403 } /* end dasd_3990_erp_inv_format */
1409 * Handles 24 byte 'End-of-Cylinder' error.
1412 * erp already added default erp
1414 * erp pointer to original (failed) cqr.
1416 static struct dasd_ccw_req *
1417 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1420 struct dasd_device *device = default_erp->device;
1422 DEV_MESSAGE(KERN_ERR, device, "%s",
1423 "End-of-Cylinder - must never happen");
1425 /* implement action 7 - BUG */
1426 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1428 } /* end dasd_3990_erp_EOC */
1431 * DASD_3990_ERP_ENV_DATA
1434 * Handles 24 byte 'Environmental-Data Present' error.
1437 * erp current erp_head
1439 * erp new erp_head - pointer to new ERP
1441 static struct dasd_ccw_req *
1442 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1445 struct dasd_device *device = erp->device;
1447 erp->function = dasd_3990_erp_env_data;
1449 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Environmental data present");
1451 dasd_3990_handle_env_data(erp, sense);
1453 /* don't retry on disabled interface */
1454 if (sense[7] != 0x0F) {
1456 erp = dasd_3990_erp_action_4(erp, sense);
1459 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_IN_IO);
1464 } /* end dasd_3990_erp_env_data */
1467 * DASD_3990_ERP_NO_REC
1470 * Handles 24 byte 'No Record Found' error.
1473 * erp already added default ERP
1476 * erp new erp_head - pointer to new ERP
1478 static struct dasd_ccw_req *
1479 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1482 struct dasd_device *device = default_erp->device;
1484 DEV_MESSAGE(KERN_ERR, device, "%s",
1485 "No Record Found - Fatal error should "
1486 "have been handled within the interrupt handler");
1488 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1490 } /* end dasd_3990_erp_no_rec */
1493 * DASD_3990_ERP_FILE_PROT
1496 * Handles 24 byte 'File Protected' error.
1497 * Note: Seek related recovery is not implemented because
1498 * wee don't use the seek command yet.
1501 * erp current erp_head
1503 * erp new erp_head - pointer to new ERP
1505 static struct dasd_ccw_req *
1506 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1509 struct dasd_device *device = erp->device;
1511 DEV_MESSAGE(KERN_ERR, device, "%s", "File Protected");
1513 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1515 } /* end dasd_3990_erp_file_prot */
1518 * DASD_3990_ERP_INSPECT_24
1521 * Does a detailed inspection of the 24 byte sense data
1522 * and sets up a related error recovery action.
1525 * sense sense data of the actual error
1526 * erp pointer to the currently created default ERP
1529 * erp pointer to the (addtitional) ERP
1531 static struct dasd_ccw_req *
1532 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1535 struct dasd_ccw_req *erp_filled = NULL;
1537 /* Check sense for .... */
1538 /* 'Command Reject' */
1539 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1540 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1542 /* 'Intervention Required' */
1543 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1544 erp_filled = dasd_3990_erp_int_req(erp);
1546 /* 'Bus Out Parity Check' */
1547 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1548 erp_filled = dasd_3990_erp_bus_out(erp);
1550 /* 'Equipment Check' */
1551 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1552 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1555 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1556 erp_filled = dasd_3990_erp_data_check(erp, sense);
1559 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1560 erp_filled = dasd_3990_erp_overrun(erp, sense);
1562 /* 'Invalid Track Format' */
1563 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1564 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1566 /* 'End-of-Cylinder' */
1567 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1568 erp_filled = dasd_3990_erp_EOC(erp, sense);
1570 /* 'Environmental Data' */
1571 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1572 erp_filled = dasd_3990_erp_env_data(erp, sense);
1574 /* 'No Record Found' */
1575 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1576 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1578 /* 'File Protected' */
1579 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1580 erp_filled = dasd_3990_erp_file_prot(erp);
1582 /* other (unknown) error - do default ERP */
1583 if (erp_filled == NULL) {
1590 } /* END dasd_3990_erp_inspect_24 */
1593 *****************************************************************************
1594 * 32 byte sense ERP functions (only)
1595 *****************************************************************************
1599 * DASD_3990_ERPACTION_10_32
1602 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1603 * Just retry and if retry doesn't work, return with error.
1606 * erp current erp_head
1607 * sense current sense data
1609 * erp modified erp_head
1611 static struct dasd_ccw_req *
1612 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1615 struct dasd_device *device = erp->device;
1618 erp->function = dasd_3990_erp_action_10_32;
1620 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Perform logging requested");
1624 } /* end dasd_3990_erp_action_10_32 */
1627 * DASD_3990_ERP_ACTION_1B_32
1630 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1631 * A write operation could not be finished because of an unexpected
1633 * The already created 'default erp' is used to get the link to
1634 * the erp chain, but it can not be used for this recovery
1635 * action because it contains no DE/LO data space.
1638 * default_erp already added default erp.
1639 * sense current sense data
1643 * default_erp in case of imprecise ending or error
1645 static struct dasd_ccw_req *
1646 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1649 struct dasd_device *device = default_erp->device;
1651 struct dasd_ccw_req *cqr;
1652 struct dasd_ccw_req *erp;
1653 struct DE_eckd_data *DE_data;
1654 char *LO_data; /* LO_eckd_data_t */
1657 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1658 "Write not finished because of unexpected condition");
1660 default_erp->function = dasd_3990_erp_action_1B_32;
1662 /* determine the original cqr */
1665 while (cqr->refers != NULL) {
1669 /* for imprecise ending just do default erp */
1670 if (sense[1] & 0x01) {
1672 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1673 "Imprecise ending is set - just retry");
1678 /* determine the address of the CCW to be restarted */
1679 /* Imprecise ending is not set -> addr from IRB-SCSW */
1680 cpa = default_erp->refers->dstat->scsw.cpa;
1684 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1685 "Unable to determine address of the CCW "
1688 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1691 /* Build new ERP request including DE/LO */
1692 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1693 2 + 1,/* DE/LO + TIC */
1694 sizeof (struct DE_eckd_data) +
1695 sizeof (struct LO_eckd_data), device);
1698 DEV_MESSAGE(KERN_ERR, device, "%s", "Unable to allocate ERP");
1699 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1702 /* use original DE */
1703 DE_data = erp->data;
1704 memcpy(DE_data, cqr->data, sizeof (struct DE_eckd_data));
1707 LO_data = erp->data + sizeof (struct DE_eckd_data);
1709 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1711 DEV_MESSAGE(KERN_ERR, device, "%s",
1712 "BUG - this should not happen");
1714 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1717 if ((sense[7] & 0x3F) == 0x01) {
1718 /* operation code is WRITE DATA -> data area orientation */
1721 } else if ((sense[7] & 0x3F) == 0x03) {
1722 /* operation code is FORMAT WRITE -> index orientation */
1726 LO_data[0] = sense[7]; /* operation */
1729 LO_data[1] = sense[8]; /* auxiliary */
1730 LO_data[2] = sense[9];
1731 LO_data[3] = sense[3]; /* count */
1732 LO_data[4] = sense[29]; /* seek_addr.cyl */
1733 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1734 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1736 memcpy(&(LO_data[8]), &(sense[11]), 8);
1740 memset(ccw, 0, sizeof (struct ccw1));
1741 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1742 ccw->flags = CCW_FLAG_CC;
1744 ccw->cda = (__u32)(addr_t) DE_data;
1748 memset(ccw, 0, sizeof (struct ccw1));
1749 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1750 ccw->flags = CCW_FLAG_CC;
1752 ccw->cda = (__u32)(addr_t) LO_data;
1754 /* TIC to the failed ccw */
1756 ccw->cmd_code = CCW_CMD_TIC;
1759 /* fill erp related fields */
1760 erp->function = dasd_3990_erp_action_1B_32;
1761 erp->refers = default_erp->refers;
1762 erp->device = device;
1763 erp->magic = default_erp->magic;
1766 cqr->buildclk = get_clock();
1767 erp->status = DASD_CQR_FILLED;
1769 /* remove the default erp */
1770 dasd_free_erp_request(default_erp, device);
1774 } /* end dasd_3990_erp_action_1B_32 */
1777 * DASD_3990_UPDATE_1B
1780 * Handles the update to the 32 byte 'Action 1B' of Single Program
1781 * Action Codes in case the first action was not successful.
1782 * The already created 'previous_erp' is the currently not successful
1786 * previous_erp already created previous erp.
1787 * sense current sense data
1791 static struct dasd_ccw_req *
1792 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1795 struct dasd_device *device = previous_erp->device;
1797 struct dasd_ccw_req *cqr;
1798 struct dasd_ccw_req *erp;
1799 char *LO_data; /* struct LO_eckd_data */
1802 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1803 "Write not finished because of unexpected condition"
1806 /* determine the original cqr */
1809 while (cqr->refers != NULL) {
1813 /* for imprecise ending just do default erp */
1814 if (sense[1] & 0x01) {
1816 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1817 "Imprecise ending is set - just retry");
1819 previous_erp->status = DASD_CQR_QUEUED;
1821 return previous_erp;
1824 /* determine the address of the CCW to be restarted */
1825 /* Imprecise ending is not set -> addr from IRB-SCSW */
1826 cpa = previous_erp->dstat->scsw.cpa;
1830 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1831 "Unable to determine address of the CCW "
1834 previous_erp->status = DASD_CQR_FAILED;
1836 return previous_erp;
1841 /* update the LO with the new returned sense data */
1842 LO_data = erp->data + sizeof (struct DE_eckd_data);
1844 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1846 DEV_MESSAGE(KERN_ERR, device, "%s",
1847 "BUG - this should not happen");
1849 previous_erp->status = DASD_CQR_FAILED;
1851 return previous_erp;
1854 if ((sense[7] & 0x3F) == 0x01) {
1855 /* operation code is WRITE DATA -> data area orientation */
1858 } else if ((sense[7] & 0x3F) == 0x03) {
1859 /* operation code is FORMAT WRITE -> index orientation */
1863 LO_data[0] = sense[7]; /* operation */
1866 LO_data[1] = sense[8]; /* auxiliary */
1867 LO_data[2] = sense[9];
1868 LO_data[3] = sense[3]; /* count */
1869 LO_data[4] = sense[29]; /* seek_addr.cyl */
1870 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1871 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1873 memcpy(&(LO_data[8]), &(sense[11]), 8);
1875 /* TIC to the failed ccw */
1876 ccw = erp->cpaddr; /* addr of DE ccw */
1877 ccw++; /* addr of LE ccw */
1878 ccw++; /* addr of TIC ccw */
1881 erp->status = DASD_CQR_QUEUED;
1885 } /* end dasd_3990_update_1B */
1888 * DASD_3990_ERP_COMPOUND_RETRY
1891 * Handles the compound ERP action retry code.
1892 * NOTE: At least one retry is done even if zero is specified
1893 * by the sense data. This makes enqueueing of the request
1897 * sense sense data of the actual error
1898 * erp pointer to the currently created ERP
1901 * erp modified ERP pointer
1905 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1908 switch (sense[25] & 0x03) {
1909 case 0x00: /* no not retry */
1913 case 0x01: /* retry 2 times */
1917 case 0x02: /* retry 10 times */
1921 case 0x03: /* retry 256 times */
1929 erp->function = dasd_3990_erp_compound_retry;
1931 } /* end dasd_3990_erp_compound_retry */
1934 * DASD_3990_ERP_COMPOUND_PATH
1937 * Handles the compound ERP action for retry on alternate
1941 * sense sense data of the actual error
1942 * erp pointer to the currently created ERP
1945 * erp modified ERP pointer
1949 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1952 if (sense[25] & DASD_SENSE_BIT_3) {
1953 dasd_3990_erp_alternate_path(erp);
1955 if (erp->status == DASD_CQR_FAILED) {
1956 /* reset the lpm and the status to be able to
1957 * try further actions. */
1961 erp->status = DASD_CQR_ERROR;
1966 erp->function = dasd_3990_erp_compound_path;
1968 } /* end dasd_3990_erp_compound_path */
1971 * DASD_3990_ERP_COMPOUND_CODE
1974 * Handles the compound ERP action for retry code.
1977 * sense sense data of the actual error
1978 * erp pointer to the currently created ERP
1981 * erp NEW ERP pointer
1984 static struct dasd_ccw_req *
1985 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1988 if (sense[25] & DASD_SENSE_BIT_2) {
1990 switch (sense[28]) {
1992 /* issue a Diagnostic Control command with an
1993 * Inhibit Write subcommand and controler modifier */
1994 erp = dasd_3990_erp_DCTL(erp, 0x20);
1998 /* wait for 5 seconds and retry again */
2001 dasd_3990_erp_block_queue (erp, 5*HZ);
2005 /* should not happen - continue */
2010 erp->function = dasd_3990_erp_compound_code;
2014 } /* end dasd_3990_erp_compound_code */
2017 * DASD_3990_ERP_COMPOUND_CONFIG
2020 * Handles the compound ERP action for configruation
2022 * Note: duplex handling is not implemented (yet).
2025 * sense sense data of the actual error
2026 * erp pointer to the currently created ERP
2029 * erp modified ERP pointer
2033 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2036 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2038 /* set to suspended duplex state then restart */
2039 struct dasd_device *device = erp->device;
2041 DEV_MESSAGE(KERN_ERR, device, "%s",
2042 "Set device to suspended duplex state should be "
2044 "This is not implemented yet (for compound ERP)"
2045 " - please report to linux390@de.ibm.com");
2049 erp->function = dasd_3990_erp_compound_config;
2051 } /* end dasd_3990_erp_compound_config */
2054 * DASD_3990_ERP_COMPOUND
2057 * Does the further compound program action if
2058 * compound retry was not successful.
2061 * sense sense data of the actual error
2062 * erp pointer to the current (failed) ERP
2065 * erp (additional) ERP pointer
2068 static struct dasd_ccw_req *
2069 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2072 if ((erp->function == dasd_3990_erp_compound_retry) &&
2073 (erp->status == DASD_CQR_ERROR)) {
2075 dasd_3990_erp_compound_path(erp, sense);
2078 if ((erp->function == dasd_3990_erp_compound_path) &&
2079 (erp->status == DASD_CQR_ERROR)) {
2081 erp = dasd_3990_erp_compound_code(erp, sense);
2084 if ((erp->function == dasd_3990_erp_compound_code) &&
2085 (erp->status == DASD_CQR_ERROR)) {
2087 dasd_3990_erp_compound_config(erp, sense);
2090 /* if no compound action ERP specified, the request failed */
2091 if (erp->status == DASD_CQR_ERROR) {
2093 erp->status = DASD_CQR_FAILED;
2098 } /* end dasd_3990_erp_compound */
2101 * DASD_3990_ERP_INSPECT_32
2104 * Does a detailed inspection of the 32 byte sense data
2105 * and sets up a related error recovery action.
2108 * sense sense data of the actual error
2109 * erp pointer to the currently created default ERP
2112 * erp_filled pointer to the ERP
2115 static struct dasd_ccw_req *
2116 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2119 struct dasd_device *device = erp->device;
2121 erp->function = dasd_3990_erp_inspect_32;
2123 if (sense[25] & DASD_SENSE_BIT_0) {
2125 /* compound program action codes (byte25 bit 0 == '1') */
2126 dasd_3990_erp_compound_retry(erp, sense);
2130 /* single program action codes (byte25 bit 0 == '0') */
2131 switch (sense[25]) {
2133 case 0x00: /* success - use default ERP for retries */
2134 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2135 "ERP called for successful request"
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);
2147 case 0x02: /* intervention required */
2148 case 0x03: /* intervention required during dual copy */
2149 erp = dasd_3990_erp_int_req(erp);
2152 case 0x0F: /* length mismatch during update write command */
2153 DEV_MESSAGE(KERN_ERR, device, "%s",
2154 "update write command error - should not "
2156 "Please send this message together with "
2157 "the above sense data to linux390@de."
2160 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2163 case 0x10: /* logging required for other channel program */
2164 erp = dasd_3990_erp_action_10_32(erp, sense);
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."
2175 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2178 case 0x1B: /* unexpected condition during write */
2180 erp = dasd_3990_erp_action_1B_32(erp, sense);
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 */
2190 ("Invalid data - No way to inform appliction about "
2191 "the possibly incorret data");
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);
2202 default: /* all others errors - default 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
2221 * Does a detailed inspection for sense data by calling either
2222 * the 24-byte or the 32-byte inspection routine.
2225 * erp pointer to the currently created default ERP
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);
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 */
2253 } /* END dasd_3990_erp_inspect */
2256 * DASD_3990_ERP_ADD_ERP
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)
2264 * cqr head of the current ERP-chain (or single cqr if
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;
2276 /* allocate additional request block */
2277 struct dasd_ccw_req *erp;
2279 erp = dasd_alloc_erp_request((char *) &cqr->magic, 2, 0, cqr->device);
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 ();
2287 DEV_MESSAGE (KERN_ERR, device,
2288 "Unable to allocate ERP request "
2289 "(%i retries left)",
2291 dasd_set_timer(device, (HZ << 3));
2296 /* initialize request with default TIC to current ERP/CQR */
2298 ccw->cmd_code = CCW_CMD_NOOP;
2299 ccw->flags = CCW_FLAG_CC;
2301 ccw->cmd_code = CCW_CMD_TIC;
2302 ccw->cda = (long)(cqr->cpaddr);
2303 erp->function = dasd_3990_erp_add_erp;
2305 erp->device = cqr->device;
2306 erp->magic = cqr->magic;
2310 erp->status = DASD_CQR_FILLED;
2316 * DASD_3990_ERP_ADDITIONAL_ERP
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.
2324 * cqr head of the current ERP-chain (or single cqr if
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 */
2342 erp = dasd_3990_erp_inspect(erp);
2347 } /* end dasd_3990_erp_additional_erp */
2350 * DASD_3990_ERP_ERROR_MATCH
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
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.
2360 * cqr1 first cqr, which will be compared with the
2364 * match 'boolean' for match found
2365 * returns 1 if match found, otherwise 0.
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
2392 * check if the current error already happened before.
2393 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2396 * cqr failed cqr (either original cqr or already an erp)
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 */
2415 /* check the erp/cqr chain for current error */
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));
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)
2435 * No retry is left for the current ERP. Check what has to be done
2437 * - do further defined ERP action or
2438 * - wait for interrupt or
2439 * - exit with permanent error
2442 * erp ERP which is in progress with no retry left
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]) {
2474 case 0x57:{ /* controller */
2475 erp = dasd_3990_erp_DCTL(erp, 0x20);
2479 case 0x58:{ /* channel path */
2480 erp = dasd_3990_erp_DCTL(erp, 0x40);
2484 case 0x59:{ /* storage director */
2485 erp = dasd_3990_erp_DCTL(erp, 0x80);
2489 DEV_MESSAGE(KERN_DEBUG, device,
2490 "invalid subcommand modifier 0x%x "
2491 "for Diagnostic Control Command",
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);
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;
2515 } /* end dasd_3990_erp_further_erp */
2518 * DASD_3990_ERP_HANDLE_MATCH_ERP
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
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.
2529 * erp_head first ERP in ERP-chain
2530 * erp ERP that handles the actual error.
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);
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);
2582 DEV_MESSAGE(KERN_DEBUG, device,
2583 "%i retries left for erp %p",
2586 /* handle the request again... */
2587 erp->status = DASD_CQR_QUEUED;
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);
2598 } /* end dasd_3990_erp_handle_match_erp */
2601 * DASD_3990_ERP_ACTION
2604 * controll routine for 3990 erp actions.
2605 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2608 * cqr failed cqr (either original cqr or already an erp)
2611 * erp erp-pointer to the head of the ERP action chain.
2613 * - either a ptr to an additional ERP cqr or
2614 * - the original given cqr (which's status might
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;
2626 /* print current erp_chain */
2627 DEV_MESSAGE(KERN_ERR, 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_ERR, device,
2636 " erp %p (%02x) refers to %p",
2637 temp_erp, temp_erp->status,
2641 #endif /* ERP_DEBUG */
2643 /* double-check if current erp/cqr was successfull */
2644 if ((cqr->dstat->scsw.cstat == 0x00) &&
2645 (cqr->dstat->scsw.dstat == (DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2647 DEV_MESSAGE(KERN_DEBUG, device,
2648 "ERP called for successful request %p"
2649 " - NO ERP necessary", cqr);
2651 cqr->status = DASD_CQR_DONE;
2655 /* check if sense data are available */
2656 if (!cqr->dstat->ecw) {
2657 DEV_MESSAGE(KERN_DEBUG, device,
2658 "ERP called witout sense data avail ..."
2659 "request %p - NO ERP possible", cqr);
2661 cqr->status = DASD_CQR_FAILED;
2667 /* check if error happened before */
2668 erp = dasd_3990_erp_in_erp(cqr);
2671 /* no matching erp found - set up erp */
2672 erp = dasd_3990_erp_additional_erp(cqr);
2674 /* matching erp found - set all leading erp's to DONE */
2675 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2679 /* print current erp_chain */
2680 DEV_MESSAGE(KERN_ERR, device, "%s", "ERP chain at END of ERP-ACTION");
2682 struct dasd_ccw_req *temp_erp = NULL;
2683 for (temp_erp = erp;
2684 temp_erp != NULL; temp_erp = temp_erp->refers) {
2686 DEV_MESSAGE(KERN_ERR, device,
2687 " erp %p (%02x) refers to %p",
2688 temp_erp, temp_erp->status,
2692 #endif /* ERP_DEBUG */
2694 if (erp->status == DASD_CQR_FAILED)
2695 dasd_log_ccw(erp, 1, cpa);
2697 /* enqueue added ERP request */
2698 if (erp->status == DASD_CQR_FILLED) {
2699 erp->status = DASD_CQR_QUEUED;
2700 list_add(&erp->list, &device->ccw_queue);
2705 } /* end dasd_3990_erp_action */
2708 * Overrides for Emacs so that we follow Linus's tabbing style.
2709 * Emacs will notice this stuff at the end of the file and automatically
2710 * adjust the settings for this buffer only. This must remain at the end
2712 * ---------------------------------------------------------------------------
2715 * c-brace-imaginary-offset: 0
2716 * c-brace-offset: -4
2717 * c-argdecl-indent: 4
2718 * c-label-offset: -4
2719 * c-continued-statement-offset: 4
2720 * c-continued-brace-offset: 0
2721 * indent-tabs-mode: 1