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->irb.esw.esw0.sublog.lpum);
306 erp->lpm &= ~(erp->irb.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->irb.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->irb.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) {
446 DEV_MESSAGE(KERN_INFO, device,
447 "dasd_3990_erp_action_4: first time retry"
451 erp->function = dasd_3990_erp_action_4;
455 if (sense[25] == 0x1D) { /* state change pending */
457 DEV_MESSAGE(KERN_INFO, device,
458 "waiting for state change pending "
459 "interrupt, %d retries left",
462 dasd_3990_erp_block_queue(erp, 30*HZ);
466 /* no state change pending - retry */
467 DEV_MESSAGE (KERN_INFO, device,
468 "redriving request immediately, "
471 erp->status = DASD_CQR_QUEUED;
477 } /* end dasd_3990_erp_action_4 */
480 *****************************************************************************
481 * 24 byte sense ERP functions (only)
482 *****************************************************************************
486 * DASD_3990_ERP_ACTION_5
489 * Setup ERP to do the ERP action 5 (see Reference manual).
490 * NOTE: Further handling is done in xxx_further_erp after the retries.
493 * erp pointer to the current ERP
496 * erp pointer to the ERP
499 static struct dasd_ccw_req *
500 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
503 /* first of all retry */
505 erp->function = dasd_3990_erp_action_5;
509 } /* end dasd_3990_erp_action_5 */
512 * DASD_3990_HANDLE_ENV_DATA
515 * Handles 24 byte 'Environmental data present'.
516 * Does a analysis of the sense data (message Format)
517 * and prints the error messages.
520 * sense current sense data
526 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
529 struct dasd_device *device = erp->device;
530 char msg_format = (sense[7] & 0xF0);
531 char msg_no = (sense[7] & 0x0F);
533 switch (msg_format) {
534 case 0x00: /* Format 0 - Program or System Checks */
536 if (sense[1] & 0x10) { /* check message to operator bit */
539 case 0x00: /* No Message */
542 DEV_MESSAGE(KERN_WARNING, device, "%s",
543 "FORMAT 0 - Invalid Command");
546 DEV_MESSAGE(KERN_WARNING, device, "%s",
547 "FORMAT 0 - Invalid Command "
551 DEV_MESSAGE(KERN_WARNING, device, "%s",
552 "FORMAT 0 - CCW Count less than "
556 DEV_MESSAGE(KERN_WARNING, device, "%s",
557 "FORMAT 0 - Invalid Parameter");
560 DEV_MESSAGE(KERN_WARNING, device, "%s",
561 "FORMAT 0 - Diagnostic of Sepecial"
562 " Command Violates File Mask");
565 DEV_MESSAGE(KERN_WARNING, device, "%s",
566 "FORMAT 0 - Channel Returned with "
567 "Incorrect retry CCW");
570 DEV_MESSAGE(KERN_WARNING, device, "%s",
571 "FORMAT 0 - Reset Notification");
574 DEV_MESSAGE(KERN_WARNING, device, "%s",
575 "FORMAT 0 - Storage Path Restart");
578 DEV_MESSAGE(KERN_WARNING, device,
579 "FORMAT 0 - Channel requested "
580 "... %02x", sense[8]);
583 DEV_MESSAGE(KERN_WARNING, device, "%s",
584 "FORMAT 0 - Invalid Defective/"
585 "Alternate Track Pointer");
588 DEV_MESSAGE(KERN_WARNING, device, "%s",
589 "FORMAT 0 - DPS Installation "
593 DEV_MESSAGE(KERN_WARNING, device, "%s",
594 "FORMAT 0 - Command Invalid on "
595 "Secondary Address");
598 DEV_MESSAGE(KERN_WARNING, device,
599 "FORMAT 0 - Status Not As "
600 "Required: reason %02x", sense[8]);
603 DEV_MESSAGE(KERN_WARNING, device, "%s",
604 "FORMAT 0 - Reseved");
608 case 0x00: /* No Message */
611 DEV_MESSAGE(KERN_WARNING, device, "%s",
612 "FORMAT 0 - Device Error Source");
615 DEV_MESSAGE(KERN_WARNING, device, "%s",
616 "FORMAT 0 - Reserved");
619 DEV_MESSAGE(KERN_WARNING, device,
620 "FORMAT 0 - Device Fenced - "
621 "device = %02x", sense[4]);
624 DEV_MESSAGE(KERN_WARNING, device, "%s",
625 "FORMAT 0 - Data Pinned for "
629 DEV_MESSAGE(KERN_WARNING, device, "%s",
630 "FORMAT 0 - Reserved");
635 case 0x10: /* Format 1 - Device Equipment Checks */
637 case 0x00: /* No Message */
640 DEV_MESSAGE(KERN_WARNING, device, "%s",
641 "FORMAT 1 - Device Status 1 not as "
645 DEV_MESSAGE(KERN_WARNING, device, "%s",
646 "FORMAT 1 - Index missing");
649 DEV_MESSAGE(KERN_WARNING, device, "%s",
650 "FORMAT 1 - Interruption cannot be reset");
653 DEV_MESSAGE(KERN_WARNING, device, "%s",
654 "FORMAT 1 - Device did not respond to "
658 DEV_MESSAGE(KERN_WARNING, device, "%s",
659 "FORMAT 1 - Device check-2 error or Set "
660 "Sector is not complete");
663 DEV_MESSAGE(KERN_WARNING, device, "%s",
664 "FORMAT 1 - Head address does not "
668 DEV_MESSAGE(KERN_WARNING, device, "%s",
669 "FORMAT 1 - Device status 1 not valid");
672 DEV_MESSAGE(KERN_WARNING, device, "%s",
673 "FORMAT 1 - Device not ready");
676 DEV_MESSAGE(KERN_WARNING, device, "%s",
677 "FORMAT 1 - Track physical address did "
681 DEV_MESSAGE(KERN_WARNING, device, "%s",
682 "FORMAT 1 - Missing device address bit");
685 DEV_MESSAGE(KERN_WARNING, device, "%s",
686 "FORMAT 1 - Drive motor switch is off");
689 DEV_MESSAGE(KERN_WARNING, device, "%s",
690 "FORMAT 1 - Seek incomplete");
693 DEV_MESSAGE(KERN_WARNING, device, "%s",
694 "FORMAT 1 - Cylinder address did not "
698 DEV_MESSAGE(KERN_WARNING, device, "%s",
699 "FORMAT 1 - Offset active cannot be "
703 DEV_MESSAGE(KERN_WARNING, device, "%s",
704 "FORMAT 1 - Reserved");
708 case 0x20: /* Format 2 - 3990 Equipment Checks */
711 DEV_MESSAGE(KERN_WARNING, device, "%s",
712 "FORMAT 2 - 3990 check-2 error");
715 DEV_MESSAGE(KERN_WARNING, device, "%s",
716 "FORMAT 2 - Support facility errors");
719 DEV_MESSAGE(KERN_WARNING, device,
720 "FORMAT 2 - Microcode detected error %02x",
724 DEV_MESSAGE(KERN_WARNING, device, "%s",
725 "FORMAT 2 - Reserved");
729 case 0x30: /* Format 3 - 3990 Control Checks */
732 DEV_MESSAGE(KERN_WARNING, device, "%s",
733 "FORMAT 3 - Allegiance terminated");
736 DEV_MESSAGE(KERN_WARNING, device, "%s",
737 "FORMAT 3 - Reserved");
741 case 0x40: /* Format 4 - Data Checks */
744 DEV_MESSAGE(KERN_WARNING, device, "%s",
745 "FORMAT 4 - Home address area error");
748 DEV_MESSAGE(KERN_WARNING, device, "%s",
749 "FORMAT 4 - Count area error");
752 DEV_MESSAGE(KERN_WARNING, device, "%s",
753 "FORMAT 4 - Key area error");
756 DEV_MESSAGE(KERN_WARNING, device, "%s",
757 "FORMAT 4 - Data area error");
760 DEV_MESSAGE(KERN_WARNING, device, "%s",
761 "FORMAT 4 - No sync byte in home address "
765 DEV_MESSAGE(KERN_WARNING, device, "%s",
766 "FORMAT 4 - No sync byte in count address "
770 DEV_MESSAGE(KERN_WARNING, device, "%s",
771 "FORMAT 4 - No sync byte in key area");
774 DEV_MESSAGE(KERN_WARNING, device, "%s",
775 "FORMAT 4 - No sync byte in data area");
778 DEV_MESSAGE(KERN_WARNING, device, "%s",
779 "FORMAT 4 - Home address area error; "
783 DEV_MESSAGE(KERN_WARNING, device, "%s",
784 "FORMAT 4 - Count area error; offset "
788 DEV_MESSAGE(KERN_WARNING, device, "%s",
789 "FORMAT 4 - Key area error; offset "
793 DEV_MESSAGE(KERN_WARNING, device, "%s",
794 "FORMAT 4 - Data area error; "
798 DEV_MESSAGE(KERN_WARNING, device, "%s",
799 "FORMAT 4 - No sync byte in home "
800 "address area; offset active");
803 DEV_MESSAGE(KERN_WARNING, device, "%s",
804 "FORMAT 4 - No syn byte in count "
805 "address area; offset active");
808 DEV_MESSAGE(KERN_WARNING, device, "%s",
809 "FORMAT 4 - No sync byte in key area; "
813 DEV_MESSAGE(KERN_WARNING, device, "%s",
814 "FORMAT 4 - No syn byte in data area; "
818 DEV_MESSAGE(KERN_WARNING, device, "%s",
819 "FORMAT 4 - Reserved");
823 case 0x50: /* Format 5 - Data Check with displacement information */
826 DEV_MESSAGE(KERN_WARNING, device, "%s",
827 "FORMAT 5 - Data Check in the "
828 "home address area");
831 DEV_MESSAGE(KERN_WARNING, device, "%s",
832 "FORMAT 5 - Data Check in the count area");
835 DEV_MESSAGE(KERN_WARNING, device, "%s",
836 "FORMAT 5 - Data Check in the key area");
839 DEV_MESSAGE(KERN_WARNING, device, "%s",
840 "FORMAT 5 - Data Check in the data area");
843 DEV_MESSAGE(KERN_WARNING, device, "%s",
844 "FORMAT 5 - Data Check in the "
845 "home address area; offset active");
848 DEV_MESSAGE(KERN_WARNING, device, "%s",
849 "FORMAT 5 - Data Check in the count area; "
853 DEV_MESSAGE(KERN_WARNING, device, "%s",
854 "FORMAT 5 - Data Check in the key area; "
858 DEV_MESSAGE(KERN_WARNING, device, "%s",
859 "FORMAT 5 - Data Check in the data area; "
863 DEV_MESSAGE(KERN_WARNING, device, "%s",
864 "FORMAT 5 - Reserved");
868 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
871 DEV_MESSAGE(KERN_WARNING, device, "%s",
872 "FORMAT 6 - Overrun on channel A");
875 DEV_MESSAGE(KERN_WARNING, device, "%s",
876 "FORMAT 6 - Overrun on channel B");
879 DEV_MESSAGE(KERN_WARNING, device, "%s",
880 "FORMAT 6 - Overrun on channel C");
883 DEV_MESSAGE(KERN_WARNING, device, "%s",
884 "FORMAT 6 - Overrun on channel D");
887 DEV_MESSAGE(KERN_WARNING, device, "%s",
888 "FORMAT 6 - Overrun on channel E");
891 DEV_MESSAGE(KERN_WARNING, device, "%s",
892 "FORMAT 6 - Overrun on channel F");
895 DEV_MESSAGE(KERN_WARNING, device, "%s",
896 "FORMAT 6 - Overrun on channel G");
899 DEV_MESSAGE(KERN_WARNING, device, "%s",
900 "FORMAT 6 - Overrun on channel H");
903 DEV_MESSAGE(KERN_WARNING, device, "%s",
904 "FORMAT 6 - Reserved");
908 case 0x70: /* Format 7 - Device Connection Control Checks */
911 DEV_MESSAGE(KERN_WARNING, device, "%s",
912 "FORMAT 7 - RCC initiated by a connection "
916 DEV_MESSAGE(KERN_WARNING, device, "%s",
917 "FORMAT 7 - RCC 1 sequence not "
921 DEV_MESSAGE(KERN_WARNING, device, "%s",
922 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
926 DEV_MESSAGE(KERN_WARNING, device, "%s",
927 "FORMAT 7 - Invalid tag-in during "
928 "selection sequence");
931 DEV_MESSAGE(KERN_WARNING, device, "%s",
932 "FORMAT 7 - extra RCC required");
935 DEV_MESSAGE(KERN_WARNING, device, "%s",
936 "FORMAT 7 - Invalid DCC selection "
937 "response or timeout");
940 DEV_MESSAGE(KERN_WARNING, device, "%s",
941 "FORMAT 7 - Missing end operation; device "
942 "transfer complete");
945 DEV_MESSAGE(KERN_WARNING, device, "%s",
946 "FORMAT 7 - Missing end operation; device "
947 "transfer incomplete");
950 DEV_MESSAGE(KERN_WARNING, device, "%s",
951 "FORMAT 7 - Invalid tag-in for an "
952 "immediate command sequence");
955 DEV_MESSAGE(KERN_WARNING, device, "%s",
956 "FORMAT 7 - Invalid tag-in for an "
957 "extended command sequence");
960 DEV_MESSAGE(KERN_WARNING, device, "%s",
961 "FORMAT 7 - 3990 microcode time out when "
962 "stopping selection");
965 DEV_MESSAGE(KERN_WARNING, device, "%s",
966 "FORMAT 7 - No response to selection "
967 "after a poll interruption");
970 DEV_MESSAGE(KERN_WARNING, device, "%s",
971 "FORMAT 7 - Permanent path error (DASD "
972 "controller not available)");
975 DEV_MESSAGE(KERN_WARNING, device, "%s",
976 "FORMAT 7 - DASD controller not available"
977 " on disconnected command chain");
980 DEV_MESSAGE(KERN_WARNING, device, "%s",
981 "FORMAT 7 - Reserved");
985 case 0x80: /* Format 8 - Additional Device Equipment Checks */
987 case 0x00: /* No Message */
989 DEV_MESSAGE(KERN_WARNING, device, "%s",
990 "FORMAT 8 - Error correction code "
994 DEV_MESSAGE(KERN_WARNING, device, "%s",
995 "FORMAT 8 - Unexpected end operation "
999 DEV_MESSAGE(KERN_WARNING, device, "%s",
1000 "FORMAT 8 - End operation with transfer "
1004 DEV_MESSAGE(KERN_WARNING, device, "%s",
1005 "FORMAT 8 - End operation with transfer "
1009 DEV_MESSAGE(KERN_WARNING, device, "%s",
1010 "FORMAT 8 - DPS checks after a system "
1011 "reset or selective reset");
1014 DEV_MESSAGE(KERN_WARNING, device, "%s",
1015 "FORMAT 8 - DPS cannot be filled");
1018 DEV_MESSAGE(KERN_WARNING, device, "%s",
1019 "FORMAT 8 - Short busy time-out during "
1020 "device selection");
1023 DEV_MESSAGE(KERN_WARNING, device, "%s",
1024 "FORMAT 8 - DASD controller failed to "
1025 "set or reset the long busy latch");
1028 DEV_MESSAGE(KERN_WARNING, device, "%s",
1029 "FORMAT 8 - No interruption from device "
1030 "during a command chain");
1033 DEV_MESSAGE(KERN_WARNING, device, "%s",
1034 "FORMAT 8 - Reserved");
1038 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
1041 break; /* No Message */
1043 DEV_MESSAGE(KERN_WARNING, device, "%s",
1044 "FORMAT 9 - Device check-2 error");
1047 DEV_MESSAGE(KERN_WARNING, device, "%s",
1048 "FORMAT 9 - Head address did not compare");
1051 DEV_MESSAGE(KERN_WARNING, device, "%s",
1052 "FORMAT 9 - Track physical address did "
1053 "not compare while oriented");
1056 DEV_MESSAGE(KERN_WARNING, device, "%s",
1057 "FORMAT 9 - Cylinder address did not "
1061 DEV_MESSAGE(KERN_WARNING, device, "%s",
1062 "FORMAT 9 - Reserved");
1066 case 0xF0: /* Format F - Cache Storage Checks */
1069 DEV_MESSAGE(KERN_WARNING, device, "%s",
1070 "FORMAT F - Operation Terminated");
1073 DEV_MESSAGE(KERN_WARNING, device, "%s",
1074 "FORMAT F - Subsystem Processing Error");
1077 DEV_MESSAGE(KERN_WARNING, device, "%s",
1078 "FORMAT F - Cache or nonvolatile storage "
1079 "equipment failure");
1082 DEV_MESSAGE(KERN_WARNING, device, "%s",
1083 "FORMAT F - Caching terminated");
1086 DEV_MESSAGE(KERN_WARNING, device, "%s",
1087 "FORMAT F - Cache fast write access not "
1091 DEV_MESSAGE(KERN_WARNING, device, "%s",
1092 "FORMAT F - Track format incorrect");
1095 DEV_MESSAGE(KERN_WARNING, device, "%s",
1096 "FORMAT F - Caching reinitiated");
1099 DEV_MESSAGE(KERN_WARNING, device, "%s",
1100 "FORMAT F - Nonvolatile storage "
1104 DEV_MESSAGE(KERN_WARNING, device, "%s",
1105 "FORMAT F - Volume is suspended duplex");
1108 DEV_MESSAGE(KERN_WARNING, device, "%s",
1109 "FORMAT F - Subsystem status connot be "
1113 DEV_MESSAGE(KERN_WARNING, device, "%s",
1114 "FORMAT F - Caching status reset to "
1118 DEV_MESSAGE(KERN_WARNING, device, "%s",
1119 "FORMAT F - DASD Fast Write inhibited");
1122 DEV_MESSAGE(KERN_WARNING, device, "%s",
1123 "FORMAT D - Reserved");
1127 default: /* unknown message format - should not happen */
1128 DEV_MESSAGE (KERN_WARNING, device,
1129 "unknown message format %02x",
1132 } /* end switch message format */
1134 } /* end dasd_3990_handle_env_data */
1137 * DASD_3990_ERP_COM_REJ
1140 * Handles 24 byte 'Command Reject' error.
1143 * erp current erp_head
1144 * sense current sense data
1147 * erp 'new' erp_head - pointer to new ERP
1149 static struct dasd_ccw_req *
1150 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1153 struct dasd_device *device = erp->device;
1155 erp->function = dasd_3990_erp_com_rej;
1157 /* env data present (ACTION 10 - retry should work) */
1158 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1160 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1161 "Command Reject - environmental data present");
1163 dasd_3990_handle_env_data(erp, sense);
1168 /* fatal error - set status to FAILED */
1169 DEV_MESSAGE(KERN_ERR, device, "%s",
1170 "Command Reject - Fatal error");
1172 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1177 } /* end dasd_3990_erp_com_rej */
1180 * DASD_3990_ERP_BUS_OUT
1183 * Handles 24 byte 'Bus Out Parity Check' error.
1186 * erp current erp_head
1188 * erp new erp_head - pointer to new ERP
1190 static struct dasd_ccw_req *
1191 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1194 struct dasd_device *device = erp->device;
1196 /* first time set initial retry counter and erp_function */
1197 /* and retry once without blocking queue */
1198 /* (this enables easier enqueing of the cqr) */
1199 if (erp->function != dasd_3990_erp_bus_out) {
1201 erp->function = dasd_3990_erp_bus_out;
1205 /* issue a message and wait for 'device ready' interrupt */
1206 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1207 "bus out parity error or BOPC requested by "
1210 dasd_3990_erp_block_queue(erp, 60*HZ);
1216 } /* end dasd_3990_erp_bus_out */
1219 * DASD_3990_ERP_EQUIP_CHECK
1222 * Handles 24 byte 'Equipment Check' error.
1225 * erp current erp_head
1227 * erp new erp_head - pointer to new ERP
1229 static struct dasd_ccw_req *
1230 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1233 struct dasd_device *device = erp->device;
1235 erp->function = dasd_3990_erp_equip_check;
1237 if (sense[1] & SNS1_WRITE_INHIBITED) {
1239 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1240 "Write inhibited path encountered");
1242 /* vary path offline */
1243 DEV_MESSAGE(KERN_ERR, device, "%s",
1244 "Path should be varied off-line. "
1245 "This is not implemented yet \n - please report "
1246 "to linux390@de.ibm.com");
1248 erp = dasd_3990_erp_action_1(erp);
1250 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1252 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1253 "Equipment Check - " "environmental data present");
1255 dasd_3990_handle_env_data(erp, sense);
1257 erp = dasd_3990_erp_action_4(erp, sense);
1259 } else if (sense[1] & SNS1_PERM_ERR) {
1261 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1262 "Equipment Check - retry exhausted or "
1265 erp = dasd_3990_erp_action_1(erp);
1268 /* all other equipment checks - Action 5 */
1269 /* rest is done when retries == 0 */
1270 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1271 "Equipment check or processing error");
1273 erp = dasd_3990_erp_action_5(erp);
1278 } /* end dasd_3990_erp_equip_check */
1281 * DASD_3990_ERP_DATA_CHECK
1284 * Handles 24 byte 'Data Check' error.
1287 * erp current erp_head
1289 * erp new erp_head - pointer to new ERP
1291 static struct dasd_ccw_req *
1292 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1295 struct dasd_device *device = erp->device;
1297 erp->function = dasd_3990_erp_data_check;
1299 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1301 /* issue message that the data has been corrected */
1302 DEV_MESSAGE(KERN_EMERG, device, "%s",
1303 "Data recovered during retry with PCI "
1304 "fetch mode active");
1306 /* not possible to handle this situation in Linux */
1307 panic("No way to inform appliction about the possibly "
1310 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1312 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1313 "Uncorrectable data check recovered secondary "
1314 "addr of duplex pair");
1316 erp = dasd_3990_erp_action_4(erp, sense);
1318 } else if (sense[1] & SNS1_PERM_ERR) {
1320 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1321 "Uncorrectable data check with internal "
1324 erp = dasd_3990_erp_action_1(erp);
1327 /* all other data checks */
1328 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1329 "Uncorrectable data check with retry count "
1332 erp = dasd_3990_erp_action_5(erp);
1337 } /* end dasd_3990_erp_data_check */
1340 * DASD_3990_ERP_OVERRUN
1343 * Handles 24 byte 'Overrun' error.
1346 * erp current erp_head
1348 * erp new erp_head - pointer to new ERP
1350 static struct dasd_ccw_req *
1351 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1354 struct dasd_device *device = erp->device;
1356 erp->function = dasd_3990_erp_overrun;
1358 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1359 "Overrun - service overrun or overrun"
1360 " error requested by channel");
1362 erp = dasd_3990_erp_action_5(erp);
1366 } /* end dasd_3990_erp_overrun */
1369 * DASD_3990_ERP_INV_FORMAT
1372 * Handles 24 byte 'Invalid Track Format' error.
1375 * erp current erp_head
1377 * erp new erp_head - pointer to new ERP
1379 static struct dasd_ccw_req *
1380 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1383 struct dasd_device *device = erp->device;
1385 erp->function = dasd_3990_erp_inv_format;
1387 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1389 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1390 "Track format error when destaging or "
1393 dasd_3990_handle_env_data(erp, sense);
1395 erp = dasd_3990_erp_action_4(erp, sense);
1398 DEV_MESSAGE(KERN_ERR, device, "%s",
1399 "Invalid Track Format - Fatal error should have "
1400 "been handled within the interrupt handler");
1402 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1407 } /* end dasd_3990_erp_inv_format */
1413 * Handles 24 byte 'End-of-Cylinder' error.
1416 * erp already added default erp
1418 * erp pointer to original (failed) cqr.
1420 static struct dasd_ccw_req *
1421 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1424 struct dasd_device *device = default_erp->device;
1426 DEV_MESSAGE(KERN_ERR, device, "%s",
1427 "End-of-Cylinder - must never happen");
1429 /* implement action 7 - BUG */
1430 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1432 } /* end dasd_3990_erp_EOC */
1435 * DASD_3990_ERP_ENV_DATA
1438 * Handles 24 byte 'Environmental-Data Present' error.
1441 * erp current erp_head
1443 * erp new erp_head - pointer to new ERP
1445 static struct dasd_ccw_req *
1446 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1449 struct dasd_device *device = erp->device;
1451 erp->function = dasd_3990_erp_env_data;
1453 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Environmental data present");
1455 dasd_3990_handle_env_data(erp, sense);
1457 /* don't retry on disabled interface */
1458 if (sense[7] != 0x0F) {
1460 erp = dasd_3990_erp_action_4(erp, sense);
1463 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_IN_IO);
1468 } /* end dasd_3990_erp_env_data */
1471 * DASD_3990_ERP_NO_REC
1474 * Handles 24 byte 'No Record Found' error.
1477 * erp already added default ERP
1480 * erp new erp_head - pointer to new ERP
1482 static struct dasd_ccw_req *
1483 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1486 struct dasd_device *device = default_erp->device;
1488 DEV_MESSAGE(KERN_ERR, device, "%s",
1489 "No Record Found - Fatal error should "
1490 "have been handled within the interrupt handler");
1492 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1494 } /* end dasd_3990_erp_no_rec */
1497 * DASD_3990_ERP_FILE_PROT
1500 * Handles 24 byte 'File Protected' error.
1501 * Note: Seek related recovery is not implemented because
1502 * wee don't use the seek command yet.
1505 * erp current erp_head
1507 * erp new erp_head - pointer to new ERP
1509 static struct dasd_ccw_req *
1510 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1513 struct dasd_device *device = erp->device;
1515 DEV_MESSAGE(KERN_ERR, device, "%s", "File Protected");
1517 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1519 } /* end dasd_3990_erp_file_prot */
1522 * DASD_3990_ERP_INSPECT_24
1525 * Does a detailed inspection of the 24 byte sense data
1526 * and sets up a related error recovery action.
1529 * sense sense data of the actual error
1530 * erp pointer to the currently created default ERP
1533 * erp pointer to the (addtitional) ERP
1535 static struct dasd_ccw_req *
1536 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1539 struct dasd_ccw_req *erp_filled = NULL;
1541 /* Check sense for .... */
1542 /* 'Command Reject' */
1543 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1544 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1546 /* 'Intervention Required' */
1547 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1548 erp_filled = dasd_3990_erp_int_req(erp);
1550 /* 'Bus Out Parity Check' */
1551 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1552 erp_filled = dasd_3990_erp_bus_out(erp);
1554 /* 'Equipment Check' */
1555 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1556 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1559 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1560 erp_filled = dasd_3990_erp_data_check(erp, sense);
1563 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1564 erp_filled = dasd_3990_erp_overrun(erp, sense);
1566 /* 'Invalid Track Format' */
1567 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1568 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1570 /* 'End-of-Cylinder' */
1571 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1572 erp_filled = dasd_3990_erp_EOC(erp, sense);
1574 /* 'Environmental Data' */
1575 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1576 erp_filled = dasd_3990_erp_env_data(erp, sense);
1578 /* 'No Record Found' */
1579 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1580 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1582 /* 'File Protected' */
1583 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1584 erp_filled = dasd_3990_erp_file_prot(erp);
1586 /* other (unknown) error - do default ERP */
1587 if (erp_filled == NULL) {
1594 } /* END dasd_3990_erp_inspect_24 */
1597 *****************************************************************************
1598 * 32 byte sense ERP functions (only)
1599 *****************************************************************************
1603 * DASD_3990_ERPACTION_10_32
1606 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1607 * Just retry and if retry doesn't work, return with error.
1610 * erp current erp_head
1611 * sense current sense data
1613 * erp modified erp_head
1615 static struct dasd_ccw_req *
1616 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1619 struct dasd_device *device = erp->device;
1622 erp->function = dasd_3990_erp_action_10_32;
1624 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Perform logging requested");
1628 } /* end dasd_3990_erp_action_10_32 */
1631 * DASD_3990_ERP_ACTION_1B_32
1634 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1635 * A write operation could not be finished because of an unexpected
1637 * The already created 'default erp' is used to get the link to
1638 * the erp chain, but it can not be used for this recovery
1639 * action because it contains no DE/LO data space.
1642 * default_erp already added default erp.
1643 * sense current sense data
1647 * default_erp in case of imprecise ending or error
1649 static struct dasd_ccw_req *
1650 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1653 struct dasd_device *device = default_erp->device;
1655 struct dasd_ccw_req *cqr;
1656 struct dasd_ccw_req *erp;
1657 struct DE_eckd_data *DE_data;
1658 char *LO_data; /* LO_eckd_data_t */
1661 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1662 "Write not finished because of unexpected condition");
1664 default_erp->function = dasd_3990_erp_action_1B_32;
1666 /* determine the original cqr */
1669 while (cqr->refers != NULL) {
1673 /* for imprecise ending just do default erp */
1674 if (sense[1] & 0x01) {
1676 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1677 "Imprecise ending is set - just retry");
1682 /* determine the address of the CCW to be restarted */
1683 /* Imprecise ending is not set -> addr from IRB-SCSW */
1684 cpa = default_erp->refers->irb.scsw.cpa;
1688 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1689 "Unable to determine address of the CCW "
1692 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1695 /* Build new ERP request including DE/LO */
1696 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1697 2 + 1,/* DE/LO + TIC */
1698 sizeof (struct DE_eckd_data) +
1699 sizeof (struct LO_eckd_data), device);
1702 DEV_MESSAGE(KERN_ERR, device, "%s", "Unable to allocate ERP");
1703 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1706 /* use original DE */
1707 DE_data = erp->data;
1708 memcpy(DE_data, cqr->data, sizeof (struct DE_eckd_data));
1711 LO_data = erp->data + sizeof (struct DE_eckd_data);
1713 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1715 DEV_MESSAGE(KERN_ERR, device, "%s",
1716 "BUG - this should not happen");
1718 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1721 if ((sense[7] & 0x3F) == 0x01) {
1722 /* operation code is WRITE DATA -> data area orientation */
1725 } else if ((sense[7] & 0x3F) == 0x03) {
1726 /* operation code is FORMAT WRITE -> index orientation */
1730 LO_data[0] = sense[7]; /* operation */
1733 LO_data[1] = sense[8]; /* auxiliary */
1734 LO_data[2] = sense[9];
1735 LO_data[3] = sense[3]; /* count */
1736 LO_data[4] = sense[29]; /* seek_addr.cyl */
1737 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1738 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1740 memcpy(&(LO_data[8]), &(sense[11]), 8);
1744 memset(ccw, 0, sizeof (struct ccw1));
1745 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1746 ccw->flags = CCW_FLAG_CC;
1748 ccw->cda = (__u32)(addr_t) DE_data;
1752 memset(ccw, 0, sizeof (struct ccw1));
1753 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1754 ccw->flags = CCW_FLAG_CC;
1756 ccw->cda = (__u32)(addr_t) LO_data;
1758 /* TIC to the failed ccw */
1760 ccw->cmd_code = CCW_CMD_TIC;
1763 /* fill erp related fields */
1764 erp->function = dasd_3990_erp_action_1B_32;
1765 erp->refers = default_erp->refers;
1766 erp->device = device;
1767 erp->magic = default_erp->magic;
1770 erp->buildclk = get_clock();
1771 erp->status = DASD_CQR_FILLED;
1773 /* remove the default erp */
1774 dasd_free_erp_request(default_erp, device);
1778 } /* end dasd_3990_erp_action_1B_32 */
1781 * DASD_3990_UPDATE_1B
1784 * Handles the update to the 32 byte 'Action 1B' of Single Program
1785 * Action Codes in case the first action was not successful.
1786 * The already created 'previous_erp' is the currently not successful
1790 * previous_erp already created previous erp.
1791 * sense current sense data
1795 static struct dasd_ccw_req *
1796 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1799 struct dasd_device *device = previous_erp->device;
1801 struct dasd_ccw_req *cqr;
1802 struct dasd_ccw_req *erp;
1803 char *LO_data; /* struct LO_eckd_data */
1806 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1807 "Write not finished because of unexpected condition"
1810 /* determine the original cqr */
1813 while (cqr->refers != NULL) {
1817 /* for imprecise ending just do default erp */
1818 if (sense[1] & 0x01) {
1820 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1821 "Imprecise ending is set - just retry");
1823 previous_erp->status = DASD_CQR_QUEUED;
1825 return previous_erp;
1828 /* determine the address of the CCW to be restarted */
1829 /* Imprecise ending is not set -> addr from IRB-SCSW */
1830 cpa = previous_erp->irb.scsw.cpa;
1834 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1835 "Unable to determine address of the CCW "
1838 previous_erp->status = DASD_CQR_FAILED;
1840 return previous_erp;
1845 /* update the LO with the new returned sense data */
1846 LO_data = erp->data + sizeof (struct DE_eckd_data);
1848 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1850 DEV_MESSAGE(KERN_ERR, device, "%s",
1851 "BUG - this should not happen");
1853 previous_erp->status = DASD_CQR_FAILED;
1855 return previous_erp;
1858 if ((sense[7] & 0x3F) == 0x01) {
1859 /* operation code is WRITE DATA -> data area orientation */
1862 } else if ((sense[7] & 0x3F) == 0x03) {
1863 /* operation code is FORMAT WRITE -> index orientation */
1867 LO_data[0] = sense[7]; /* operation */
1870 LO_data[1] = sense[8]; /* auxiliary */
1871 LO_data[2] = sense[9];
1872 LO_data[3] = sense[3]; /* count */
1873 LO_data[4] = sense[29]; /* seek_addr.cyl */
1874 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1875 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1877 memcpy(&(LO_data[8]), &(sense[11]), 8);
1879 /* TIC to the failed ccw */
1880 ccw = erp->cpaddr; /* addr of DE ccw */
1881 ccw++; /* addr of LE ccw */
1882 ccw++; /* addr of TIC ccw */
1885 erp->status = DASD_CQR_QUEUED;
1889 } /* end dasd_3990_update_1B */
1892 * DASD_3990_ERP_COMPOUND_RETRY
1895 * Handles the compound ERP action retry code.
1896 * NOTE: At least one retry is done even if zero is specified
1897 * by the sense data. This makes enqueueing of the request
1901 * sense sense data of the actual error
1902 * erp pointer to the currently created ERP
1905 * erp modified ERP pointer
1909 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1912 switch (sense[25] & 0x03) {
1913 case 0x00: /* no not retry */
1917 case 0x01: /* retry 2 times */
1921 case 0x02: /* retry 10 times */
1925 case 0x03: /* retry 256 times */
1933 erp->function = dasd_3990_erp_compound_retry;
1935 } /* end dasd_3990_erp_compound_retry */
1938 * DASD_3990_ERP_COMPOUND_PATH
1941 * Handles the compound ERP action for retry on alternate
1945 * sense sense data of the actual error
1946 * erp pointer to the currently created ERP
1949 * erp modified ERP pointer
1953 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1956 if (sense[25] & DASD_SENSE_BIT_3) {
1957 dasd_3990_erp_alternate_path(erp);
1959 if (erp->status == DASD_CQR_FAILED) {
1960 /* reset the lpm and the status to be able to
1961 * try further actions. */
1965 erp->status = DASD_CQR_ERROR;
1970 erp->function = dasd_3990_erp_compound_path;
1972 } /* end dasd_3990_erp_compound_path */
1975 * DASD_3990_ERP_COMPOUND_CODE
1978 * Handles the compound ERP action for retry code.
1981 * sense sense data of the actual error
1982 * erp pointer to the currently created ERP
1985 * erp NEW ERP pointer
1988 static struct dasd_ccw_req *
1989 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1992 if (sense[25] & DASD_SENSE_BIT_2) {
1994 switch (sense[28]) {
1996 /* issue a Diagnostic Control command with an
1997 * Inhibit Write subcommand and controler modifier */
1998 erp = dasd_3990_erp_DCTL(erp, 0x20);
2002 /* wait for 5 seconds and retry again */
2005 dasd_3990_erp_block_queue (erp, 5*HZ);
2009 /* should not happen - continue */
2014 erp->function = dasd_3990_erp_compound_code;
2018 } /* end dasd_3990_erp_compound_code */
2021 * DASD_3990_ERP_COMPOUND_CONFIG
2024 * Handles the compound ERP action for configruation
2026 * Note: duplex handling is not implemented (yet).
2029 * sense sense data of the actual error
2030 * erp pointer to the currently created ERP
2033 * erp modified ERP pointer
2037 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2040 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2042 /* set to suspended duplex state then restart */
2043 struct dasd_device *device = erp->device;
2045 DEV_MESSAGE(KERN_ERR, device, "%s",
2046 "Set device to suspended duplex state should be "
2048 "This is not implemented yet (for compound ERP)"
2049 " - please report to linux390@de.ibm.com");
2053 erp->function = dasd_3990_erp_compound_config;
2055 } /* end dasd_3990_erp_compound_config */
2058 * DASD_3990_ERP_COMPOUND
2061 * Does the further compound program action if
2062 * compound retry was not successful.
2065 * sense sense data of the actual error
2066 * erp pointer to the current (failed) ERP
2069 * erp (additional) ERP pointer
2072 static struct dasd_ccw_req *
2073 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2076 if ((erp->function == dasd_3990_erp_compound_retry) &&
2077 (erp->status == DASD_CQR_ERROR)) {
2079 dasd_3990_erp_compound_path(erp, sense);
2082 if ((erp->function == dasd_3990_erp_compound_path) &&
2083 (erp->status == DASD_CQR_ERROR)) {
2085 erp = dasd_3990_erp_compound_code(erp, sense);
2088 if ((erp->function == dasd_3990_erp_compound_code) &&
2089 (erp->status == DASD_CQR_ERROR)) {
2091 dasd_3990_erp_compound_config(erp, sense);
2094 /* if no compound action ERP specified, the request failed */
2095 if (erp->status == DASD_CQR_ERROR) {
2097 erp->status = DASD_CQR_FAILED;
2102 } /* end dasd_3990_erp_compound */
2105 * DASD_3990_ERP_INSPECT_32
2108 * Does a detailed inspection of the 32 byte sense data
2109 * and sets up a related error recovery action.
2112 * sense sense data of the actual error
2113 * erp pointer to the currently created default ERP
2116 * erp_filled pointer to the ERP
2119 static struct dasd_ccw_req *
2120 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2123 struct dasd_device *device = erp->device;
2125 erp->function = dasd_3990_erp_inspect_32;
2127 if (sense[25] & DASD_SENSE_BIT_0) {
2129 /* compound program action codes (byte25 bit 0 == '1') */
2130 dasd_3990_erp_compound_retry(erp, sense);
2134 /* single program action codes (byte25 bit 0 == '0') */
2135 switch (sense[25]) {
2137 case 0x00: /* success - use default ERP for retries */
2138 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2139 "ERP called for successful request"
2143 case 0x01: /* fatal error */
2144 DEV_MESSAGE(KERN_ERR, device, "%s",
2145 "Fatal error should have been "
2146 "handled within the interrupt handler");
2148 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2151 case 0x02: /* intervention required */
2152 case 0x03: /* intervention required during dual copy */
2153 erp = dasd_3990_erp_int_req(erp);
2156 case 0x0F: /* length mismatch during update write command */
2157 DEV_MESSAGE(KERN_ERR, device, "%s",
2158 "update write command error - should not "
2160 "Please send this message together with "
2161 "the above sense data to linux390@de."
2164 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2167 case 0x10: /* logging required for other channel program */
2168 erp = dasd_3990_erp_action_10_32(erp, sense);
2171 case 0x15: /* next track outside defined extend */
2172 DEV_MESSAGE(KERN_ERR, device, "%s",
2173 "next track outside defined extend - "
2174 "should not happen;\n"
2175 "Please send this message together with "
2176 "the above sense data to linux390@de."
2179 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2182 case 0x1B: /* unexpected condition during write */
2184 erp = dasd_3990_erp_action_1B_32(erp, sense);
2187 case 0x1C: /* invalid data */
2188 DEV_MESSAGE(KERN_EMERG, device, "%s",
2189 "Data recovered during retry with PCI "
2190 "fetch mode active");
2192 /* not possible to handle this situation in Linux */
2194 ("Invalid data - No way to inform appliction about "
2195 "the possibly incorret data");
2198 case 0x1D: /* state-change pending */
2199 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2200 "A State change pending condition exists "
2201 "for the subsystem or device");
2203 erp = dasd_3990_erp_action_4(erp, sense);
2206 default: /* all others errors - default erp */
2213 } /* end dasd_3990_erp_inspect_32 */
2216 *****************************************************************************
2217 * main ERP control fuctions (24 and 32 byte sense)
2218 *****************************************************************************
2222 * DASD_3990_ERP_INSPECT
2225 * Does a detailed inspection for sense data by calling either
2226 * the 24-byte or the 32-byte inspection routine.
2229 * erp pointer to the currently created default ERP
2231 * erp_new contens was possibly modified
2233 static struct dasd_ccw_req *
2234 dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
2237 struct dasd_ccw_req *erp_new = NULL;
2238 /* sense data are located in the refers record of the */
2239 /* already set up new ERP ! */
2240 char *sense = erp->refers->irb.ecw;
2242 /* distinguish between 24 and 32 byte sense data */
2243 if (sense[27] & DASD_SENSE_BIT_0) {
2245 /* inspect the 24 byte sense data */
2246 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2250 /* inspect the 32 byte sense data */
2251 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2253 } /* end distinguish between 24 and 32 byte sense data */
2257 } /* END dasd_3990_erp_inspect */
2260 * DASD_3990_ERP_ADD_ERP
2263 * This funtion adds an additional request block (ERP) to the head of
2264 * the given cqr (or erp).
2265 * This erp is initialized as an default erp (retry TIC)
2268 * cqr head of the current ERP-chain (or single cqr if
2271 * erp pointer to new ERP-chain head
2273 static struct dasd_ccw_req *
2274 dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)
2277 struct dasd_device *device = cqr->device;
2280 /* allocate additional request block */
2281 struct dasd_ccw_req *erp;
2283 erp = dasd_alloc_erp_request((char *) &cqr->magic, 2, 0, cqr->device);
2285 if (cqr->retries <= 0) {
2286 DEV_MESSAGE(KERN_ERR, device, "%s",
2287 "Unable to allocate ERP request");
2288 cqr->status = DASD_CQR_FAILED;
2289 cqr->stopclk = get_clock ();
2291 DEV_MESSAGE (KERN_ERR, device,
2292 "Unable to allocate ERP request "
2293 "(%i retries left)",
2295 dasd_set_timer(device, (HZ << 3));
2300 /* initialize request with default TIC to current ERP/CQR */
2302 ccw->cmd_code = CCW_CMD_NOOP;
2303 ccw->flags = CCW_FLAG_CC;
2305 ccw->cmd_code = CCW_CMD_TIC;
2306 ccw->cda = (long)(cqr->cpaddr);
2307 erp->function = dasd_3990_erp_add_erp;
2309 erp->device = cqr->device;
2310 erp->magic = cqr->magic;
2313 erp->buildclk = get_clock();
2315 erp->status = DASD_CQR_FILLED;
2321 * DASD_3990_ERP_ADDITIONAL_ERP
2324 * An additional ERP is needed to handle the current error.
2325 * Add ERP to the head of the ERP-chain containing the ERP processing
2326 * determined based on the sense data.
2329 * cqr head of the current ERP-chain (or single cqr if
2333 * erp pointer to new ERP-chain head
2335 static struct dasd_ccw_req *
2336 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2339 struct dasd_ccw_req *erp = NULL;
2341 /* add erp and initialize with default TIC */
2342 erp = dasd_3990_erp_add_erp(cqr);
2344 /* inspect sense, determine specific ERP if possible */
2347 erp = dasd_3990_erp_inspect(erp);
2352 } /* end dasd_3990_erp_additional_erp */
2355 * DASD_3990_ERP_ERROR_MATCH
2358 * Check if the device status of the given cqr is the same.
2359 * This means that the failed CCW and the relevant sense data
2361 * I don't distinguish between 24 and 32 byte sense because in case of
2362 * 24 byte sense byte 25 and 27 is set as well.
2365 * cqr1 first cqr, which will be compared with the
2369 * match 'boolean' for match found
2370 * returns 1 if match found, otherwise 0.
2373 dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, struct dasd_ccw_req *cqr2)
2376 /* check failed CCW */
2377 if (cqr1->irb.scsw.cpa != cqr2->irb.scsw.cpa) {
2378 // return 0; /* CCW doesn't match */
2381 /* check sense data; byte 0-2,25,27 */
2382 if (!((memcmp (cqr1->irb.ecw, cqr2->irb.ecw, 3) == 0) &&
2383 (cqr1->irb.ecw[27] == cqr2->irb.ecw[27]) &&
2384 (cqr1->irb.ecw[25] == cqr2->irb.ecw[25]))) {
2386 return 0; /* sense doesn't match */
2389 return 1; /* match */
2391 } /* end dasd_3990_erp_error_match */
2394 * DASD_3990_ERP_IN_ERP
2397 * check if the current error already happened before.
2398 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2401 * cqr failed cqr (either original cqr or already an erp)
2404 * erp erp-pointer to the already defined error
2405 * recovery procedure OR
2406 * NULL if a 'new' error occurred.
2408 static struct dasd_ccw_req *
2409 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2412 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2413 *erp_match = NULL; /* save erp chain head */
2414 int match = 0; /* 'boolean' for matching error found */
2416 if (cqr->refers == NULL) { /* return if not in erp */
2420 /* check the erp/cqr chain for current error */
2422 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2423 erp_match = cqr; /* save possible matching erp */
2424 cqr = cqr->refers; /* check next erp/cqr in queue */
2426 } while ((cqr->refers != NULL) && (!match));
2429 return NULL; /* no match was found */
2432 return erp_match; /* return address of matching erp */
2434 } /* END dasd_3990_erp_in_erp */
2437 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2440 * No retry is left for the current ERP. Check what has to be done
2442 * - do further defined ERP action or
2443 * - wait for interrupt or
2444 * - exit with permanent error
2447 * erp ERP which is in progress with no retry left
2450 * erp modified/additional ERP
2452 static struct dasd_ccw_req *
2453 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2456 struct dasd_device *device = erp->device;
2457 char *sense = erp->irb.ecw;
2459 /* check for 24 byte sense ERP */
2460 if ((erp->function == dasd_3990_erp_bus_out) ||
2461 (erp->function == dasd_3990_erp_action_1) ||
2462 (erp->function == dasd_3990_erp_action_4)) {
2464 erp = dasd_3990_erp_action_1(erp);
2466 } else if (erp->function == dasd_3990_erp_action_5) {
2468 /* retries have not been successful */
2469 /* prepare erp for retry on different channel path */
2470 erp = dasd_3990_erp_action_1(erp);
2472 if (!(sense[2] & DASD_SENSE_BIT_0)) {
2474 /* issue a Diagnostic Control command with an
2475 * Inhibit Write subcommand */
2477 switch (sense[25]) {
2479 case 0x57:{ /* controller */
2480 erp = dasd_3990_erp_DCTL(erp, 0x20);
2484 case 0x58:{ /* channel path */
2485 erp = dasd_3990_erp_DCTL(erp, 0x40);
2489 case 0x59:{ /* storage director */
2490 erp = dasd_3990_erp_DCTL(erp, 0x80);
2494 DEV_MESSAGE(KERN_DEBUG, device,
2495 "invalid subcommand modifier 0x%x "
2496 "for Diagnostic Control Command",
2501 /* check for 32 byte sense ERP */
2502 } else if ((erp->function == dasd_3990_erp_compound_retry) ||
2503 (erp->function == dasd_3990_erp_compound_path) ||
2504 (erp->function == dasd_3990_erp_compound_code) ||
2505 (erp->function == dasd_3990_erp_compound_config)) {
2507 erp = dasd_3990_erp_compound(erp, sense);
2510 /* no retry left and no additional special handling necessary */
2511 DEV_MESSAGE(KERN_ERR, device,
2512 "no retries left for erp %p - "
2513 "set status to FAILED", erp);
2515 erp->status = DASD_CQR_FAILED;
2520 } /* end dasd_3990_erp_further_erp */
2523 * DASD_3990_ERP_HANDLE_MATCH_ERP
2526 * An error occurred again and an ERP has been detected which is already
2527 * used to handle this error (e.g. retries).
2528 * All prior ERP's are asumed to be successful and therefore removed
2530 * If retry counter of matching erp is already 0, it is checked if further
2531 * action is needed (besides retry) or if the ERP has failed.
2534 * erp_head first ERP in ERP-chain
2535 * erp ERP that handles the actual error.
2539 * erp modified/additional ERP
2541 static struct dasd_ccw_req *
2542 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2543 struct dasd_ccw_req *erp)
2546 struct dasd_device *device = erp_head->device;
2547 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2548 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2550 /* loop over successful ERPs and remove them from chanq */
2551 while (erp_done != erp) {
2553 if (erp_done == NULL) /* end of chain reached */
2554 panic(PRINTK_HEADER "Programming error in ERP! The "
2555 "original request was lost\n");
2557 /* remove the request from the device queue */
2558 list_del(&erp_done->list);
2560 erp_free = erp_done;
2561 erp_done = erp_done->refers;
2563 /* free the finished erp request */
2564 dasd_free_erp_request(erp_free, erp_free->device);
2568 if (erp->retries > 0) {
2570 char *sense = erp->refers->irb.ecw;
2572 /* check for special retries */
2573 if (erp->function == dasd_3990_erp_action_4) {
2575 erp = dasd_3990_erp_action_4(erp, sense);
2577 } else if (erp->function == dasd_3990_erp_action_1B_32) {
2579 erp = dasd_3990_update_1B(erp, sense);
2581 } else if (erp->function == dasd_3990_erp_int_req) {
2583 erp = dasd_3990_erp_int_req(erp);
2587 DEV_MESSAGE(KERN_DEBUG, device,
2588 "%i retries left for erp %p",
2591 /* handle the request again... */
2592 erp->status = DASD_CQR_QUEUED;
2596 /* no retry left - check for further necessary action */
2597 /* if no further actions, handle rest as permanent error */
2598 erp = dasd_3990_erp_further_erp(erp);
2603 } /* end dasd_3990_erp_handle_match_erp */
2606 * DASD_3990_ERP_ACTION
2609 * controll routine for 3990 erp actions.
2610 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2613 * cqr failed cqr (either original cqr or already an erp)
2616 * erp erp-pointer to the head of the ERP action chain.
2618 * - either a ptr to an additional ERP cqr or
2619 * - the original given cqr (which's status might
2622 struct dasd_ccw_req *
2623 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2626 struct dasd_ccw_req *erp = NULL;
2627 struct dasd_device *device = cqr->device;
2628 __u32 cpa = cqr->irb.scsw.cpa;
2631 /* print current erp_chain */
2632 DEV_MESSAGE(KERN_ERR, device, "%s",
2633 "ERP chain at BEGINNING of ERP-ACTION");
2635 struct dasd_ccw_req *temp_erp = NULL;
2637 for (temp_erp = cqr;
2638 temp_erp != NULL; temp_erp = temp_erp->refers) {
2640 DEV_MESSAGE(KERN_ERR, device,
2641 " erp %p (%02x) refers to %p",
2642 temp_erp, temp_erp->status,
2646 #endif /* ERP_DEBUG */
2648 /* double-check if current erp/cqr was successfull */
2649 if ((cqr->irb.scsw.cstat == 0x00) &&
2650 (cqr->irb.scsw.dstat == (DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2652 DEV_MESSAGE(KERN_DEBUG, device,
2653 "ERP called for successful request %p"
2654 " - NO ERP necessary", cqr);
2656 cqr->status = DASD_CQR_DONE;
2660 /* check if sense data are available */
2661 if (!cqr->irb.ecw) {
2662 DEV_MESSAGE(KERN_DEBUG, device,
2663 "ERP called witout sense data avail ..."
2664 "request %p - NO ERP possible", cqr);
2666 cqr->status = DASD_CQR_FAILED;
2672 /* check if error happened before */
2673 erp = dasd_3990_erp_in_erp(cqr);
2676 /* no matching erp found - set up erp */
2677 erp = dasd_3990_erp_additional_erp(cqr);
2679 /* matching erp found - set all leading erp's to DONE */
2680 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2684 /* print current erp_chain */
2685 DEV_MESSAGE(KERN_ERR, device, "%s", "ERP chain at END of ERP-ACTION");
2687 struct dasd_ccw_req *temp_erp = NULL;
2688 for (temp_erp = erp;
2689 temp_erp != NULL; temp_erp = temp_erp->refers) {
2691 DEV_MESSAGE(KERN_ERR, device,
2692 " erp %p (%02x) refers to %p",
2693 temp_erp, temp_erp->status,
2697 #endif /* ERP_DEBUG */
2699 if (erp->status == DASD_CQR_FAILED)
2700 dasd_log_ccw(erp, 1, cpa);
2702 /* enqueue added ERP request */
2703 if (erp->status == DASD_CQR_FILLED) {
2704 erp->status = DASD_CQR_QUEUED;
2705 list_add(&erp->list, &device->ccw_queue);
2710 } /* end dasd_3990_erp_action */
2713 * Overrides for Emacs so that we follow Linus's tabbing style.
2714 * Emacs will notice this stuff at the end of the file and automatically
2715 * adjust the settings for this buffer only. This must remain at the end
2717 * ---------------------------------------------------------------------------
2720 * c-brace-imaginary-offset: 0
2721 * c-brace-offset: -4
2722 * c-argdecl-indent: 4
2723 * c-label-offset: -4
2724 * c-continued-statement-offset: 4
2725 * c-continued-brace-offset: 0
2726 * indent-tabs-mode: 1