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
10 #include <linux/timer.h>
11 #include <linux/slab.h>
12 #include <asm/idals.h>
13 #include <asm/todclk.h>
15 #define PRINTK_HEADER "dasd_erp(3990): "
18 #include "dasd_eckd.h"
22 unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
23 unsigned char modifier; /* Subcommand modifier */
24 unsigned short res; /* reserved */
25 } __attribute__ ((packed));
28 *****************************************************************************
29 * SECTION ERP HANDLING
30 *****************************************************************************
33 *****************************************************************************
34 * 24 and 32 byte sense ERP functions
35 *****************************************************************************
39 * DASD_3990_ERP_CLEANUP
42 * Removes the already build but not necessary ERP request and sets
43 * the status of the original cqr / erp to the given (final) status
46 * erp request to be blocked
47 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
52 static struct dasd_ccw_req *
53 dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
55 struct dasd_ccw_req *cqr = erp->refers;
57 dasd_free_erp_request(erp, erp->memdev);
58 cqr->status = final_status;
61 } /* end dasd_3990_erp_cleanup */
64 * DASD_3990_ERP_BLOCK_QUEUE
67 * Block the given device request queue to prevent from further
68 * processing until the started timer has expired or an related
69 * interrupt was received.
72 dasd_3990_erp_block_queue(struct dasd_ccw_req * erp, int expires)
75 struct dasd_device *device = erp->startdev;
78 DEV_MESSAGE(KERN_INFO, device,
79 "blocking request queue for %is", expires/HZ);
81 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
82 device->stopped |= DASD_STOPPED_PENDING;
83 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
84 erp->status = DASD_CQR_FILLED;
85 dasd_block_set_timer(device->block, expires);
89 * DASD_3990_ERP_INT_REQ
92 * Handles 'Intervention Required' error.
93 * This means either device offline or not installed.
100 static struct dasd_ccw_req *
101 dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
104 struct dasd_device *device = erp->startdev;
106 /* first time set initial retry counter and erp_function */
107 /* and retry once without blocking queue */
108 /* (this enables easier enqueing of the cqr) */
109 if (erp->function != dasd_3990_erp_int_req) {
112 erp->function = dasd_3990_erp_int_req;
116 /* issue a message and wait for 'device ready' interrupt */
117 DEV_MESSAGE(KERN_ERR, device, "%s",
118 "is offline or not installed - "
119 "INTERVENTION REQUIRED!!");
121 dasd_3990_erp_block_queue(erp, 60*HZ);
126 } /* end dasd_3990_erp_int_req */
129 * DASD_3990_ERP_ALTERNATE_PATH
132 * Repeat the operation on a different channel path.
133 * If all alternate paths have been tried, the request is posted with a
137 * erp pointer to the current ERP
140 * erp modified pointer to the ERP
143 dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
145 struct dasd_device *device = erp->startdev;
149 /* try alternate valid path */
150 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
151 opm = ccw_device_get_path_mask(device->cdev);
152 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
153 //FIXME: start with get_opm ?
155 erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
157 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
159 if ((erp->lpm & opm) != 0x00) {
161 DEV_MESSAGE(KERN_DEBUG, device,
162 "try alternate lpm=%x (lpum=%x / opm=%x)",
163 erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
165 /* reset status to submit the request again... */
166 erp->status = DASD_CQR_FILLED;
169 DEV_MESSAGE(KERN_ERR, device,
170 "No alternate channel path left (lpum=%x / "
171 "opm=%x) -> permanent error",
172 erp->irb.esw.esw0.sublog.lpum, opm);
174 /* post request with permanent error */
175 erp->status = DASD_CQR_FAILED;
177 } /* end dasd_3990_erp_alternate_path */
183 * Setup cqr to do the Diagnostic Control (DCTL) command with an
184 * Inhibit Write subcommand (0x20) and the given modifier.
187 * erp pointer to the current (failed) ERP
188 * modifier subcommand modifier
191 * dctl_cqr pointer to NEW dctl_cqr
194 static struct dasd_ccw_req *
195 dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
198 struct dasd_device *device = erp->startdev;
199 struct DCTL_data *DCTL_data;
201 struct dasd_ccw_req *dctl_cqr;
203 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
204 sizeof(struct DCTL_data),
206 if (IS_ERR(dctl_cqr)) {
207 DEV_MESSAGE(KERN_ERR, device, "%s",
208 "Unable to allocate DCTL-CQR");
209 erp->status = DASD_CQR_FAILED;
213 DCTL_data = dctl_cqr->data;
215 DCTL_data->subcommand = 0x02; /* Inhibit Write */
216 DCTL_data->modifier = modifier;
218 ccw = dctl_cqr->cpaddr;
219 memset(ccw, 0, sizeof(struct ccw1));
220 ccw->cmd_code = CCW_CMD_DCTL;
222 ccw->cda = (__u32)(addr_t) DCTL_data;
223 dctl_cqr->function = dasd_3990_erp_DCTL;
224 dctl_cqr->refers = erp;
225 dctl_cqr->startdev = device;
226 dctl_cqr->memdev = device;
227 dctl_cqr->magic = erp->magic;
228 dctl_cqr->expires = 5 * 60 * HZ;
229 dctl_cqr->retries = 2;
231 dctl_cqr->buildclk = get_clock();
233 dctl_cqr->status = DASD_CQR_FILLED;
237 } /* end dasd_3990_erp_DCTL */
240 * DASD_3990_ERP_ACTION_1
243 * Setup ERP to do the ERP action 1 (see Reference manual).
244 * Repeat the operation on a different channel path.
245 * If all alternate paths have been tried, the request is posted with a
247 * Note: duplex handling is not implemented (yet).
250 * erp pointer to the current ERP
253 * erp pointer to the ERP
256 static struct dasd_ccw_req *
257 dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
260 erp->function = dasd_3990_erp_action_1;
262 dasd_3990_erp_alternate_path(erp);
266 } /* end dasd_3990_erp_action_1 */
269 * DASD_3990_ERP_ACTION_4
272 * Setup ERP to do the ERP action 4 (see Reference manual).
273 * Set the current request to PENDING to block the CQR queue for that device
274 * until the state change interrupt appears.
275 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
279 * sense sense data of the actual error
280 * erp pointer to the current ERP
283 * erp pointer to the ERP
286 static struct dasd_ccw_req *
287 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
290 struct dasd_device *device = erp->startdev;
292 /* first time set initial retry counter and erp_function */
293 /* and retry once without waiting for state change pending */
294 /* interrupt (this enables easier enqueing of the cqr) */
295 if (erp->function != dasd_3990_erp_action_4) {
297 DEV_MESSAGE(KERN_INFO, device, "%s",
298 "dasd_3990_erp_action_4: first time retry");
301 erp->function = dasd_3990_erp_action_4;
305 if (sense[25] == 0x1D) { /* state change pending */
307 DEV_MESSAGE(KERN_INFO, device,
308 "waiting for state change pending "
309 "interrupt, %d retries left",
312 dasd_3990_erp_block_queue(erp, 30*HZ);
314 } else if (sense[25] == 0x1E) { /* busy */
315 DEV_MESSAGE(KERN_INFO, device,
316 "busy - redriving request later, "
319 dasd_3990_erp_block_queue(erp, HZ);
322 /* no state change pending - retry */
323 DEV_MESSAGE (KERN_INFO, device,
324 "redriving request immediately, "
327 erp->status = DASD_CQR_FILLED;
333 } /* end dasd_3990_erp_action_4 */
336 *****************************************************************************
337 * 24 byte sense ERP functions (only)
338 *****************************************************************************
342 * DASD_3990_ERP_ACTION_5
345 * Setup ERP to do the ERP action 5 (see Reference manual).
346 * NOTE: Further handling is done in xxx_further_erp after the retries.
349 * erp pointer to the current ERP
352 * erp pointer to the ERP
355 static struct dasd_ccw_req *
356 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
359 /* first of all retry */
361 erp->function = dasd_3990_erp_action_5;
365 } /* end dasd_3990_erp_action_5 */
368 * DASD_3990_HANDLE_ENV_DATA
371 * Handles 24 byte 'Environmental data present'.
372 * Does a analysis of the sense data (message Format)
373 * and prints the error messages.
376 * sense current sense data
382 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
385 struct dasd_device *device = erp->startdev;
386 char msg_format = (sense[7] & 0xF0);
387 char msg_no = (sense[7] & 0x0F);
389 switch (msg_format) {
390 case 0x00: /* Format 0 - Program or System Checks */
392 if (sense[1] & 0x10) { /* check message to operator bit */
395 case 0x00: /* No Message */
398 DEV_MESSAGE(KERN_WARNING, device, "%s",
399 "FORMAT 0 - Invalid Command");
402 DEV_MESSAGE(KERN_WARNING, device, "%s",
403 "FORMAT 0 - Invalid Command "
407 DEV_MESSAGE(KERN_WARNING, device, "%s",
408 "FORMAT 0 - CCW Count less than "
412 DEV_MESSAGE(KERN_WARNING, device, "%s",
413 "FORMAT 0 - Invalid Parameter");
416 DEV_MESSAGE(KERN_WARNING, device, "%s",
417 "FORMAT 0 - Diagnostic of Sepecial"
418 " Command Violates File Mask");
421 DEV_MESSAGE(KERN_WARNING, device, "%s",
422 "FORMAT 0 - Channel Returned with "
423 "Incorrect retry CCW");
426 DEV_MESSAGE(KERN_WARNING, device, "%s",
427 "FORMAT 0 - Reset Notification");
430 DEV_MESSAGE(KERN_WARNING, device, "%s",
431 "FORMAT 0 - Storage Path Restart");
434 DEV_MESSAGE(KERN_WARNING, device,
435 "FORMAT 0 - Channel requested "
436 "... %02x", sense[8]);
439 DEV_MESSAGE(KERN_WARNING, device, "%s",
440 "FORMAT 0 - Invalid Defective/"
441 "Alternate Track Pointer");
444 DEV_MESSAGE(KERN_WARNING, device, "%s",
445 "FORMAT 0 - DPS Installation "
449 DEV_MESSAGE(KERN_WARNING, device, "%s",
450 "FORMAT 0 - Command Invalid on "
451 "Secondary Address");
454 DEV_MESSAGE(KERN_WARNING, device,
455 "FORMAT 0 - Status Not As "
456 "Required: reason %02x", sense[8]);
459 DEV_MESSAGE(KERN_WARNING, device, "%s",
460 "FORMAT 0 - Reseved");
464 case 0x00: /* No Message */
467 DEV_MESSAGE(KERN_WARNING, device, "%s",
468 "FORMAT 0 - Device Error Source");
471 DEV_MESSAGE(KERN_WARNING, device, "%s",
472 "FORMAT 0 - Reserved");
475 DEV_MESSAGE(KERN_WARNING, device,
476 "FORMAT 0 - Device Fenced - "
477 "device = %02x", sense[4]);
480 DEV_MESSAGE(KERN_WARNING, device, "%s",
481 "FORMAT 0 - Data Pinned for "
485 DEV_MESSAGE(KERN_WARNING, device, "%s",
486 "FORMAT 0 - Reserved");
491 case 0x10: /* Format 1 - Device Equipment Checks */
493 case 0x00: /* No Message */
496 DEV_MESSAGE(KERN_WARNING, device, "%s",
497 "FORMAT 1 - Device Status 1 not as "
501 DEV_MESSAGE(KERN_WARNING, device, "%s",
502 "FORMAT 1 - Index missing");
505 DEV_MESSAGE(KERN_WARNING, device, "%s",
506 "FORMAT 1 - Interruption cannot be reset");
509 DEV_MESSAGE(KERN_WARNING, device, "%s",
510 "FORMAT 1 - Device did not respond to "
514 DEV_MESSAGE(KERN_WARNING, device, "%s",
515 "FORMAT 1 - Device check-2 error or Set "
516 "Sector is not complete");
519 DEV_MESSAGE(KERN_WARNING, device, "%s",
520 "FORMAT 1 - Head address does not "
524 DEV_MESSAGE(KERN_WARNING, device, "%s",
525 "FORMAT 1 - Device status 1 not valid");
528 DEV_MESSAGE(KERN_WARNING, device, "%s",
529 "FORMAT 1 - Device not ready");
532 DEV_MESSAGE(KERN_WARNING, device, "%s",
533 "FORMAT 1 - Track physical address did "
537 DEV_MESSAGE(KERN_WARNING, device, "%s",
538 "FORMAT 1 - Missing device address bit");
541 DEV_MESSAGE(KERN_WARNING, device, "%s",
542 "FORMAT 1 - Drive motor switch is off");
545 DEV_MESSAGE(KERN_WARNING, device, "%s",
546 "FORMAT 1 - Seek incomplete");
549 DEV_MESSAGE(KERN_WARNING, device, "%s",
550 "FORMAT 1 - Cylinder address did not "
554 DEV_MESSAGE(KERN_WARNING, device, "%s",
555 "FORMAT 1 - Offset active cannot be "
559 DEV_MESSAGE(KERN_WARNING, device, "%s",
560 "FORMAT 1 - Reserved");
564 case 0x20: /* Format 2 - 3990 Equipment Checks */
567 DEV_MESSAGE(KERN_WARNING, device, "%s",
568 "FORMAT 2 - 3990 check-2 error");
571 DEV_MESSAGE(KERN_WARNING, device, "%s",
572 "FORMAT 2 - Support facility errors");
575 DEV_MESSAGE(KERN_WARNING, device,
576 "FORMAT 2 - Microcode detected error %02x",
580 DEV_MESSAGE(KERN_WARNING, device, "%s",
581 "FORMAT 2 - Reserved");
585 case 0x30: /* Format 3 - 3990 Control Checks */
588 DEV_MESSAGE(KERN_WARNING, device, "%s",
589 "FORMAT 3 - Allegiance terminated");
592 DEV_MESSAGE(KERN_WARNING, device, "%s",
593 "FORMAT 3 - Reserved");
597 case 0x40: /* Format 4 - Data Checks */
600 DEV_MESSAGE(KERN_WARNING, device, "%s",
601 "FORMAT 4 - Home address area error");
604 DEV_MESSAGE(KERN_WARNING, device, "%s",
605 "FORMAT 4 - Count area error");
608 DEV_MESSAGE(KERN_WARNING, device, "%s",
609 "FORMAT 4 - Key area error");
612 DEV_MESSAGE(KERN_WARNING, device, "%s",
613 "FORMAT 4 - Data area error");
616 DEV_MESSAGE(KERN_WARNING, device, "%s",
617 "FORMAT 4 - No sync byte in home address "
621 DEV_MESSAGE(KERN_WARNING, device, "%s",
622 "FORMAT 4 - No sync byte in count address "
626 DEV_MESSAGE(KERN_WARNING, device, "%s",
627 "FORMAT 4 - No sync byte in key area");
630 DEV_MESSAGE(KERN_WARNING, device, "%s",
631 "FORMAT 4 - No sync byte in data area");
634 DEV_MESSAGE(KERN_WARNING, device, "%s",
635 "FORMAT 4 - Home address area error; "
639 DEV_MESSAGE(KERN_WARNING, device, "%s",
640 "FORMAT 4 - Count area error; offset "
644 DEV_MESSAGE(KERN_WARNING, device, "%s",
645 "FORMAT 4 - Key area error; offset "
649 DEV_MESSAGE(KERN_WARNING, device, "%s",
650 "FORMAT 4 - Data area error; "
654 DEV_MESSAGE(KERN_WARNING, device, "%s",
655 "FORMAT 4 - No sync byte in home "
656 "address area; offset active");
659 DEV_MESSAGE(KERN_WARNING, device, "%s",
660 "FORMAT 4 - No syn byte in count "
661 "address area; offset active");
664 DEV_MESSAGE(KERN_WARNING, device, "%s",
665 "FORMAT 4 - No sync byte in key area; "
669 DEV_MESSAGE(KERN_WARNING, device, "%s",
670 "FORMAT 4 - No syn byte in data area; "
674 DEV_MESSAGE(KERN_WARNING, device, "%s",
675 "FORMAT 4 - Reserved");
679 case 0x50: /* Format 5 - Data Check with displacement information */
682 DEV_MESSAGE(KERN_WARNING, device, "%s",
683 "FORMAT 5 - Data Check in the "
684 "home address area");
687 DEV_MESSAGE(KERN_WARNING, device, "%s",
688 "FORMAT 5 - Data Check in the count area");
691 DEV_MESSAGE(KERN_WARNING, device, "%s",
692 "FORMAT 5 - Data Check in the key area");
695 DEV_MESSAGE(KERN_WARNING, device, "%s",
696 "FORMAT 5 - Data Check in the data area");
699 DEV_MESSAGE(KERN_WARNING, device, "%s",
700 "FORMAT 5 - Data Check in the "
701 "home address area; offset active");
704 DEV_MESSAGE(KERN_WARNING, device, "%s",
705 "FORMAT 5 - Data Check in the count area; "
709 DEV_MESSAGE(KERN_WARNING, device, "%s",
710 "FORMAT 5 - Data Check in the key area; "
714 DEV_MESSAGE(KERN_WARNING, device, "%s",
715 "FORMAT 5 - Data Check in the data area; "
719 DEV_MESSAGE(KERN_WARNING, device, "%s",
720 "FORMAT 5 - Reserved");
724 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
727 DEV_MESSAGE(KERN_WARNING, device, "%s",
728 "FORMAT 6 - Overrun on channel A");
731 DEV_MESSAGE(KERN_WARNING, device, "%s",
732 "FORMAT 6 - Overrun on channel B");
735 DEV_MESSAGE(KERN_WARNING, device, "%s",
736 "FORMAT 6 - Overrun on channel C");
739 DEV_MESSAGE(KERN_WARNING, device, "%s",
740 "FORMAT 6 - Overrun on channel D");
743 DEV_MESSAGE(KERN_WARNING, device, "%s",
744 "FORMAT 6 - Overrun on channel E");
747 DEV_MESSAGE(KERN_WARNING, device, "%s",
748 "FORMAT 6 - Overrun on channel F");
751 DEV_MESSAGE(KERN_WARNING, device, "%s",
752 "FORMAT 6 - Overrun on channel G");
755 DEV_MESSAGE(KERN_WARNING, device, "%s",
756 "FORMAT 6 - Overrun on channel H");
759 DEV_MESSAGE(KERN_WARNING, device, "%s",
760 "FORMAT 6 - Reserved");
764 case 0x70: /* Format 7 - Device Connection Control Checks */
767 DEV_MESSAGE(KERN_WARNING, device, "%s",
768 "FORMAT 7 - RCC initiated by a connection "
772 DEV_MESSAGE(KERN_WARNING, device, "%s",
773 "FORMAT 7 - RCC 1 sequence not "
777 DEV_MESSAGE(KERN_WARNING, device, "%s",
778 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
782 DEV_MESSAGE(KERN_WARNING, device, "%s",
783 "FORMAT 7 - Invalid tag-in during "
784 "selection sequence");
787 DEV_MESSAGE(KERN_WARNING, device, "%s",
788 "FORMAT 7 - extra RCC required");
791 DEV_MESSAGE(KERN_WARNING, device, "%s",
792 "FORMAT 7 - Invalid DCC selection "
793 "response or timeout");
796 DEV_MESSAGE(KERN_WARNING, device, "%s",
797 "FORMAT 7 - Missing end operation; device "
798 "transfer complete");
801 DEV_MESSAGE(KERN_WARNING, device, "%s",
802 "FORMAT 7 - Missing end operation; device "
803 "transfer incomplete");
806 DEV_MESSAGE(KERN_WARNING, device, "%s",
807 "FORMAT 7 - Invalid tag-in for an "
808 "immediate command sequence");
811 DEV_MESSAGE(KERN_WARNING, device, "%s",
812 "FORMAT 7 - Invalid tag-in for an "
813 "extended command sequence");
816 DEV_MESSAGE(KERN_WARNING, device, "%s",
817 "FORMAT 7 - 3990 microcode time out when "
818 "stopping selection");
821 DEV_MESSAGE(KERN_WARNING, device, "%s",
822 "FORMAT 7 - No response to selection "
823 "after a poll interruption");
826 DEV_MESSAGE(KERN_WARNING, device, "%s",
827 "FORMAT 7 - Permanent path error (DASD "
828 "controller not available)");
831 DEV_MESSAGE(KERN_WARNING, device, "%s",
832 "FORMAT 7 - DASD controller not available"
833 " on disconnected command chain");
836 DEV_MESSAGE(KERN_WARNING, device, "%s",
837 "FORMAT 7 - Reserved");
841 case 0x80: /* Format 8 - Additional Device Equipment Checks */
843 case 0x00: /* No Message */
845 DEV_MESSAGE(KERN_WARNING, device, "%s",
846 "FORMAT 8 - Error correction code "
850 DEV_MESSAGE(KERN_WARNING, device, "%s",
851 "FORMAT 8 - Unexpected end operation "
855 DEV_MESSAGE(KERN_WARNING, device, "%s",
856 "FORMAT 8 - End operation with transfer "
860 DEV_MESSAGE(KERN_WARNING, device, "%s",
861 "FORMAT 8 - End operation with transfer "
865 DEV_MESSAGE(KERN_WARNING, device, "%s",
866 "FORMAT 8 - DPS checks after a system "
867 "reset or selective reset");
870 DEV_MESSAGE(KERN_WARNING, device, "%s",
871 "FORMAT 8 - DPS cannot be filled");
874 DEV_MESSAGE(KERN_WARNING, device, "%s",
875 "FORMAT 8 - Short busy time-out during "
879 DEV_MESSAGE(KERN_WARNING, device, "%s",
880 "FORMAT 8 - DASD controller failed to "
881 "set or reset the long busy latch");
884 DEV_MESSAGE(KERN_WARNING, device, "%s",
885 "FORMAT 8 - No interruption from device "
886 "during a command chain");
889 DEV_MESSAGE(KERN_WARNING, device, "%s",
890 "FORMAT 8 - Reserved");
894 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
897 break; /* No Message */
899 DEV_MESSAGE(KERN_WARNING, device, "%s",
900 "FORMAT 9 - Device check-2 error");
903 DEV_MESSAGE(KERN_WARNING, device, "%s",
904 "FORMAT 9 - Head address did not compare");
907 DEV_MESSAGE(KERN_WARNING, device, "%s",
908 "FORMAT 9 - Track physical address did "
909 "not compare while oriented");
912 DEV_MESSAGE(KERN_WARNING, device, "%s",
913 "FORMAT 9 - Cylinder address did not "
917 DEV_MESSAGE(KERN_WARNING, device, "%s",
918 "FORMAT 9 - Reserved");
922 case 0xF0: /* Format F - Cache Storage Checks */
925 DEV_MESSAGE(KERN_WARNING, device, "%s",
926 "FORMAT F - Operation Terminated");
929 DEV_MESSAGE(KERN_WARNING, device, "%s",
930 "FORMAT F - Subsystem Processing Error");
933 DEV_MESSAGE(KERN_WARNING, device, "%s",
934 "FORMAT F - Cache or nonvolatile storage "
935 "equipment failure");
938 DEV_MESSAGE(KERN_WARNING, device, "%s",
939 "FORMAT F - Caching terminated");
942 DEV_MESSAGE(KERN_WARNING, device, "%s",
943 "FORMAT F - Cache fast write access not "
947 DEV_MESSAGE(KERN_WARNING, device, "%s",
948 "FORMAT F - Track format incorrect");
951 DEV_MESSAGE(KERN_WARNING, device, "%s",
952 "FORMAT F - Caching reinitiated");
955 DEV_MESSAGE(KERN_WARNING, device, "%s",
956 "FORMAT F - Nonvolatile storage "
960 DEV_MESSAGE(KERN_WARNING, device, "%s",
961 "FORMAT F - Volume is suspended duplex");
962 /* call extended error reporting (EER) */
963 dasd_eer_write(device, erp->refers,
964 DASD_EER_PPRCSUSPEND);
967 DEV_MESSAGE(KERN_WARNING, device, "%s",
968 "FORMAT F - Subsystem status connot be "
972 DEV_MESSAGE(KERN_WARNING, device, "%s",
973 "FORMAT F - Caching status reset to "
977 DEV_MESSAGE(KERN_WARNING, device, "%s",
978 "FORMAT F - DASD Fast Write inhibited");
981 DEV_MESSAGE(KERN_WARNING, device, "%s",
982 "FORMAT D - Reserved");
986 default: /* unknown message format - should not happen */
987 DEV_MESSAGE (KERN_WARNING, device,
988 "unknown message format %02x",
991 } /* end switch message format */
993 } /* end dasd_3990_handle_env_data */
996 * DASD_3990_ERP_COM_REJ
999 * Handles 24 byte 'Command Reject' error.
1002 * erp current erp_head
1003 * sense current sense data
1006 * erp 'new' erp_head - pointer to new ERP
1008 static struct dasd_ccw_req *
1009 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1012 struct dasd_device *device = erp->startdev;
1014 erp->function = dasd_3990_erp_com_rej;
1016 /* env data present (ACTION 10 - retry should work) */
1017 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1019 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1020 "Command Reject - environmental data present");
1022 dasd_3990_handle_env_data(erp, sense);
1027 /* fatal error - set status to FAILED */
1028 DEV_MESSAGE(KERN_ERR, device, "%s",
1029 "Command Reject - Fatal error");
1031 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1036 } /* end dasd_3990_erp_com_rej */
1039 * DASD_3990_ERP_BUS_OUT
1042 * Handles 24 byte 'Bus Out Parity Check' error.
1045 * erp current erp_head
1047 * erp new erp_head - pointer to new ERP
1049 static struct dasd_ccw_req *
1050 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1053 struct dasd_device *device = erp->startdev;
1055 /* first time set initial retry counter and erp_function */
1056 /* and retry once without blocking queue */
1057 /* (this enables easier enqueing of the cqr) */
1058 if (erp->function != dasd_3990_erp_bus_out) {
1060 erp->function = dasd_3990_erp_bus_out;
1064 /* issue a message and wait for 'device ready' interrupt */
1065 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1066 "bus out parity error or BOPC requested by "
1069 dasd_3990_erp_block_queue(erp, 60*HZ);
1075 } /* end dasd_3990_erp_bus_out */
1078 * DASD_3990_ERP_EQUIP_CHECK
1081 * Handles 24 byte 'Equipment Check' error.
1084 * erp current erp_head
1086 * erp new erp_head - pointer to new ERP
1088 static struct dasd_ccw_req *
1089 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1092 struct dasd_device *device = erp->startdev;
1094 erp->function = dasd_3990_erp_equip_check;
1096 if (sense[1] & SNS1_WRITE_INHIBITED) {
1098 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1099 "Write inhibited path encountered");
1101 /* vary path offline */
1102 DEV_MESSAGE(KERN_ERR, device, "%s",
1103 "Path should be varied off-line. "
1104 "This is not implemented yet \n - please report "
1105 "to linux390@de.ibm.com");
1107 erp = dasd_3990_erp_action_1(erp);
1109 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1111 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1112 "Equipment Check - " "environmental data present");
1114 dasd_3990_handle_env_data(erp, sense);
1116 erp = dasd_3990_erp_action_4(erp, sense);
1118 } else if (sense[1] & SNS1_PERM_ERR) {
1120 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1121 "Equipment Check - retry exhausted or "
1124 erp = dasd_3990_erp_action_1(erp);
1127 /* all other equipment checks - Action 5 */
1128 /* rest is done when retries == 0 */
1129 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1130 "Equipment check or processing error");
1132 erp = dasd_3990_erp_action_5(erp);
1136 } /* end dasd_3990_erp_equip_check */
1139 * DASD_3990_ERP_DATA_CHECK
1142 * Handles 24 byte 'Data Check' error.
1145 * erp current erp_head
1147 * erp new erp_head - pointer to new ERP
1149 static struct dasd_ccw_req *
1150 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1153 struct dasd_device *device = erp->startdev;
1155 erp->function = dasd_3990_erp_data_check;
1157 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1159 /* issue message that the data has been corrected */
1160 DEV_MESSAGE(KERN_EMERG, device, "%s",
1161 "Data recovered during retry with PCI "
1162 "fetch mode active");
1164 /* not possible to handle this situation in Linux */
1165 panic("No way to inform application about the possibly "
1168 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1170 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1171 "Uncorrectable data check recovered secondary "
1172 "addr of duplex pair");
1174 erp = dasd_3990_erp_action_4(erp, sense);
1176 } else if (sense[1] & SNS1_PERM_ERR) {
1178 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1179 "Uncorrectable data check with internal "
1182 erp = dasd_3990_erp_action_1(erp);
1185 /* all other data checks */
1186 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1187 "Uncorrectable data check with retry count "
1190 erp = dasd_3990_erp_action_5(erp);
1195 } /* end dasd_3990_erp_data_check */
1198 * DASD_3990_ERP_OVERRUN
1201 * Handles 24 byte 'Overrun' error.
1204 * erp current erp_head
1206 * erp new erp_head - pointer to new ERP
1208 static struct dasd_ccw_req *
1209 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1212 struct dasd_device *device = erp->startdev;
1214 erp->function = dasd_3990_erp_overrun;
1216 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1217 "Overrun - service overrun or overrun"
1218 " error requested by channel");
1220 erp = dasd_3990_erp_action_5(erp);
1224 } /* end dasd_3990_erp_overrun */
1227 * DASD_3990_ERP_INV_FORMAT
1230 * Handles 24 byte 'Invalid Track Format' error.
1233 * erp current erp_head
1235 * erp new erp_head - pointer to new ERP
1237 static struct dasd_ccw_req *
1238 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1241 struct dasd_device *device = erp->startdev;
1243 erp->function = dasd_3990_erp_inv_format;
1245 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1247 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1248 "Track format error when destaging or "
1251 dasd_3990_handle_env_data(erp, sense);
1253 erp = dasd_3990_erp_action_4(erp, sense);
1256 DEV_MESSAGE(KERN_ERR, device, "%s",
1257 "Invalid Track Format - Fatal error");
1259 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1264 } /* end dasd_3990_erp_inv_format */
1270 * Handles 24 byte 'End-of-Cylinder' error.
1273 * erp already added default erp
1275 * erp pointer to original (failed) cqr.
1277 static struct dasd_ccw_req *
1278 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1281 struct dasd_device *device = default_erp->startdev;
1283 DEV_MESSAGE(KERN_ERR, device, "%s",
1284 "End-of-Cylinder - must never happen");
1286 /* implement action 7 - BUG */
1287 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1289 } /* end dasd_3990_erp_EOC */
1292 * DASD_3990_ERP_ENV_DATA
1295 * Handles 24 byte 'Environmental-Data Present' error.
1298 * erp current erp_head
1300 * erp new erp_head - pointer to new ERP
1302 static struct dasd_ccw_req *
1303 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1306 struct dasd_device *device = erp->startdev;
1308 erp->function = dasd_3990_erp_env_data;
1310 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Environmental data present");
1312 dasd_3990_handle_env_data(erp, sense);
1314 /* don't retry on disabled interface */
1315 if (sense[7] != 0x0F) {
1316 erp = dasd_3990_erp_action_4(erp, sense);
1318 erp->status = DASD_CQR_FILLED;
1323 } /* end dasd_3990_erp_env_data */
1326 * DASD_3990_ERP_NO_REC
1329 * Handles 24 byte 'No Record Found' error.
1332 * erp already added default ERP
1335 * erp new erp_head - pointer to new ERP
1337 static struct dasd_ccw_req *
1338 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1341 struct dasd_device *device = default_erp->startdev;
1343 DEV_MESSAGE(KERN_ERR, device, "%s",
1344 "No Record Found - Fatal error ");
1346 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1348 } /* end dasd_3990_erp_no_rec */
1351 * DASD_3990_ERP_FILE_PROT
1354 * Handles 24 byte 'File Protected' error.
1355 * Note: Seek related recovery is not implemented because
1356 * wee don't use the seek command yet.
1359 * erp current erp_head
1361 * erp new erp_head - pointer to new ERP
1363 static struct dasd_ccw_req *
1364 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1367 struct dasd_device *device = erp->startdev;
1369 DEV_MESSAGE(KERN_ERR, device, "%s", "File Protected");
1371 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1373 } /* end dasd_3990_erp_file_prot */
1376 * DASD_3990_ERP_INSPECT_ALIAS
1379 * Checks if the original request was started on an alias device.
1380 * If yes, it modifies the original and the erp request so that
1381 * the erp request can be started on a base device.
1384 * erp pointer to the currently created default ERP
1387 * erp pointer to the modified ERP, or NULL
1390 static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1391 struct dasd_ccw_req *erp)
1393 struct dasd_ccw_req *cqr = erp->refers;
1396 (cqr->block->base != cqr->startdev)) {
1397 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
1398 DEV_MESSAGE(KERN_ERR, cqr->startdev,
1399 "ERP on alias device for request %p,"
1400 " recover on base device %s", cqr,
1401 cqr->block->base->cdev->dev.bus_id);
1403 dasd_eckd_reset_ccw_to_base_io(cqr);
1404 erp->startdev = cqr->block->base;
1405 erp->function = dasd_3990_erp_inspect_alias;
1413 * DASD_3990_ERP_INSPECT_24
1416 * Does a detailed inspection of the 24 byte sense data
1417 * and sets up a related error recovery action.
1420 * sense sense data of the actual error
1421 * erp pointer to the currently created default ERP
1424 * erp pointer to the (addtitional) ERP
1426 static struct dasd_ccw_req *
1427 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1430 struct dasd_ccw_req *erp_filled = NULL;
1432 /* Check sense for .... */
1433 /* 'Command Reject' */
1434 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1435 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1437 /* 'Intervention Required' */
1438 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1439 erp_filled = dasd_3990_erp_int_req(erp);
1441 /* 'Bus Out Parity Check' */
1442 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1443 erp_filled = dasd_3990_erp_bus_out(erp);
1445 /* 'Equipment Check' */
1446 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1447 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1450 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1451 erp_filled = dasd_3990_erp_data_check(erp, sense);
1454 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1455 erp_filled = dasd_3990_erp_overrun(erp, sense);
1457 /* 'Invalid Track Format' */
1458 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1459 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1461 /* 'End-of-Cylinder' */
1462 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1463 erp_filled = dasd_3990_erp_EOC(erp, sense);
1465 /* 'Environmental Data' */
1466 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1467 erp_filled = dasd_3990_erp_env_data(erp, sense);
1469 /* 'No Record Found' */
1470 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1471 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1473 /* 'File Protected' */
1474 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1475 erp_filled = dasd_3990_erp_file_prot(erp);
1477 /* other (unknown) error - do default ERP */
1478 if (erp_filled == NULL) {
1485 } /* END dasd_3990_erp_inspect_24 */
1488 *****************************************************************************
1489 * 32 byte sense ERP functions (only)
1490 *****************************************************************************
1494 * DASD_3990_ERPACTION_10_32
1497 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1498 * Just retry and if retry doesn't work, return with error.
1501 * erp current erp_head
1502 * sense current sense data
1504 * erp modified erp_head
1506 static struct dasd_ccw_req *
1507 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1510 struct dasd_device *device = erp->startdev;
1513 erp->function = dasd_3990_erp_action_10_32;
1515 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Perform logging requested");
1519 } /* end dasd_3990_erp_action_10_32 */
1522 * DASD_3990_ERP_ACTION_1B_32
1525 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1526 * A write operation could not be finished because of an unexpected
1528 * The already created 'default erp' is used to get the link to
1529 * the erp chain, but it can not be used for this recovery
1530 * action because it contains no DE/LO data space.
1533 * default_erp already added default erp.
1534 * sense current sense data
1538 * default_erp in case of imprecise ending or error
1540 static struct dasd_ccw_req *
1541 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1544 struct dasd_device *device = default_erp->startdev;
1546 struct dasd_ccw_req *cqr;
1547 struct dasd_ccw_req *erp;
1548 struct DE_eckd_data *DE_data;
1549 struct PFX_eckd_data *PFX_data;
1550 char *LO_data; /* LO_eckd_data_t */
1551 struct ccw1 *ccw, *oldccw;
1553 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1554 "Write not finished because of unexpected condition");
1556 default_erp->function = dasd_3990_erp_action_1B_32;
1558 /* determine the original cqr */
1561 while (cqr->refers != NULL) {
1565 /* for imprecise ending just do default erp */
1566 if (sense[1] & 0x01) {
1568 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1569 "Imprecise ending is set - just retry");
1574 /* determine the address of the CCW to be restarted */
1575 /* Imprecise ending is not set -> addr from IRB-SCSW */
1576 cpa = default_erp->refers->irb.scsw.cpa;
1580 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1581 "Unable to determine address of the CCW "
1584 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1587 /* Build new ERP request including DE/LO */
1588 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1589 2 + 1,/* DE/LO + TIC */
1590 sizeof(struct DE_eckd_data) +
1591 sizeof(struct LO_eckd_data), device);
1594 DEV_MESSAGE(KERN_ERR, device, "%s", "Unable to allocate ERP");
1595 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1598 /* use original DE */
1599 DE_data = erp->data;
1600 oldccw = cqr->cpaddr;
1601 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1602 PFX_data = cqr->data;
1603 memcpy(DE_data, &PFX_data->define_extend,
1604 sizeof(struct DE_eckd_data));
1606 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
1609 LO_data = erp->data + sizeof(struct DE_eckd_data);
1611 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1613 DEV_MESSAGE(KERN_ERR, device, "%s",
1614 "BUG - this should not happen");
1616 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1619 if ((sense[7] & 0x3F) == 0x01) {
1620 /* operation code is WRITE DATA -> data area orientation */
1623 } else if ((sense[7] & 0x3F) == 0x03) {
1624 /* operation code is FORMAT WRITE -> index orientation */
1628 LO_data[0] = sense[7]; /* operation */
1631 LO_data[1] = sense[8]; /* auxiliary */
1632 LO_data[2] = sense[9];
1633 LO_data[3] = sense[3]; /* count */
1634 LO_data[4] = sense[29]; /* seek_addr.cyl */
1635 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1636 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1638 memcpy(&(LO_data[8]), &(sense[11]), 8);
1642 memset(ccw, 0, sizeof(struct ccw1));
1643 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1644 ccw->flags = CCW_FLAG_CC;
1646 ccw->cda = (__u32)(addr_t) DE_data;
1650 memset(ccw, 0, sizeof(struct ccw1));
1651 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1652 ccw->flags = CCW_FLAG_CC;
1654 ccw->cda = (__u32)(addr_t) LO_data;
1656 /* TIC to the failed ccw */
1658 ccw->cmd_code = CCW_CMD_TIC;
1661 /* fill erp related fields */
1662 erp->function = dasd_3990_erp_action_1B_32;
1663 erp->refers = default_erp->refers;
1664 erp->startdev = device;
1665 erp->memdev = device;
1666 erp->magic = default_erp->magic;
1669 erp->buildclk = get_clock();
1670 erp->status = DASD_CQR_FILLED;
1672 /* remove the default erp */
1673 dasd_free_erp_request(default_erp, device);
1677 } /* end dasd_3990_erp_action_1B_32 */
1680 * DASD_3990_UPDATE_1B
1683 * Handles the update to the 32 byte 'Action 1B' of Single Program
1684 * Action Codes in case the first action was not successful.
1685 * The already created 'previous_erp' is the currently not successful
1689 * previous_erp already created previous erp.
1690 * sense current sense data
1694 static struct dasd_ccw_req *
1695 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1698 struct dasd_device *device = previous_erp->startdev;
1700 struct dasd_ccw_req *cqr;
1701 struct dasd_ccw_req *erp;
1702 char *LO_data; /* struct LO_eckd_data */
1705 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1706 "Write not finished because of unexpected condition"
1709 /* determine the original cqr */
1712 while (cqr->refers != NULL) {
1716 /* for imprecise ending just do default erp */
1717 if (sense[1] & 0x01) {
1719 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1720 "Imprecise ending is set - just retry");
1722 previous_erp->status = DASD_CQR_FILLED;
1724 return previous_erp;
1727 /* determine the address of the CCW to be restarted */
1728 /* Imprecise ending is not set -> addr from IRB-SCSW */
1729 cpa = previous_erp->irb.scsw.cpa;
1733 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1734 "Unable to determine address of the CCW "
1737 previous_erp->status = DASD_CQR_FAILED;
1739 return previous_erp;
1744 /* update the LO with the new returned sense data */
1745 LO_data = erp->data + sizeof(struct DE_eckd_data);
1747 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1749 DEV_MESSAGE(KERN_ERR, device, "%s",
1750 "BUG - this should not happen");
1752 previous_erp->status = DASD_CQR_FAILED;
1754 return previous_erp;
1757 if ((sense[7] & 0x3F) == 0x01) {
1758 /* operation code is WRITE DATA -> data area orientation */
1761 } else if ((sense[7] & 0x3F) == 0x03) {
1762 /* operation code is FORMAT WRITE -> index orientation */
1766 LO_data[0] = sense[7]; /* operation */
1769 LO_data[1] = sense[8]; /* auxiliary */
1770 LO_data[2] = sense[9];
1771 LO_data[3] = sense[3]; /* count */
1772 LO_data[4] = sense[29]; /* seek_addr.cyl */
1773 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1774 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1776 memcpy(&(LO_data[8]), &(sense[11]), 8);
1778 /* TIC to the failed ccw */
1779 ccw = erp->cpaddr; /* addr of DE ccw */
1780 ccw++; /* addr of LE ccw */
1781 ccw++; /* addr of TIC ccw */
1784 erp->status = DASD_CQR_FILLED;
1788 } /* end dasd_3990_update_1B */
1791 * DASD_3990_ERP_COMPOUND_RETRY
1794 * Handles the compound ERP action retry code.
1795 * NOTE: At least one retry is done even if zero is specified
1796 * by the sense data. This makes enqueueing of the request
1800 * sense sense data of the actual error
1801 * erp pointer to the currently created ERP
1804 * erp modified ERP pointer
1808 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1811 switch (sense[25] & 0x03) {
1812 case 0x00: /* no not retry */
1816 case 0x01: /* retry 2 times */
1820 case 0x02: /* retry 10 times */
1824 case 0x03: /* retry 256 times */
1832 erp->function = dasd_3990_erp_compound_retry;
1834 } /* end dasd_3990_erp_compound_retry */
1837 * DASD_3990_ERP_COMPOUND_PATH
1840 * Handles the compound ERP action for retry on alternate
1844 * sense sense data of the actual error
1845 * erp pointer to the currently created ERP
1848 * erp modified ERP pointer
1852 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1855 if (sense[25] & DASD_SENSE_BIT_3) {
1856 dasd_3990_erp_alternate_path(erp);
1858 if (erp->status == DASD_CQR_FAILED) {
1859 /* reset the lpm and the status to be able to
1860 * try further actions. */
1863 erp->status = DASD_CQR_NEED_ERP;
1867 erp->function = dasd_3990_erp_compound_path;
1869 } /* end dasd_3990_erp_compound_path */
1872 * DASD_3990_ERP_COMPOUND_CODE
1875 * Handles the compound ERP action for retry code.
1878 * sense sense data of the actual error
1879 * erp pointer to the currently created ERP
1882 * erp NEW ERP pointer
1885 static struct dasd_ccw_req *
1886 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1889 if (sense[25] & DASD_SENSE_BIT_2) {
1891 switch (sense[28]) {
1893 /* issue a Diagnostic Control command with an
1894 * Inhibit Write subcommand and controller modifier */
1895 erp = dasd_3990_erp_DCTL(erp, 0x20);
1899 /* wait for 5 seconds and retry again */
1902 dasd_3990_erp_block_queue (erp, 5*HZ);
1906 /* should not happen - continue */
1911 erp->function = dasd_3990_erp_compound_code;
1915 } /* end dasd_3990_erp_compound_code */
1918 * DASD_3990_ERP_COMPOUND_CONFIG
1921 * Handles the compound ERP action for configruation
1923 * Note: duplex handling is not implemented (yet).
1926 * sense sense data of the actual error
1927 * erp pointer to the currently created ERP
1930 * erp modified ERP pointer
1934 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
1937 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
1939 /* set to suspended duplex state then restart */
1940 struct dasd_device *device = erp->startdev;
1942 DEV_MESSAGE(KERN_ERR, device, "%s",
1943 "Set device to suspended duplex state should be "
1945 "This is not implemented yet (for compound ERP)"
1946 " - please report to linux390@de.ibm.com");
1950 erp->function = dasd_3990_erp_compound_config;
1952 } /* end dasd_3990_erp_compound_config */
1955 * DASD_3990_ERP_COMPOUND
1958 * Does the further compound program action if
1959 * compound retry was not successful.
1962 * sense sense data of the actual error
1963 * erp pointer to the current (failed) ERP
1966 * erp (additional) ERP pointer
1969 static struct dasd_ccw_req *
1970 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
1973 if ((erp->function == dasd_3990_erp_compound_retry) &&
1974 (erp->status == DASD_CQR_NEED_ERP)) {
1976 dasd_3990_erp_compound_path(erp, sense);
1979 if ((erp->function == dasd_3990_erp_compound_path) &&
1980 (erp->status == DASD_CQR_NEED_ERP)) {
1982 erp = dasd_3990_erp_compound_code(erp, sense);
1985 if ((erp->function == dasd_3990_erp_compound_code) &&
1986 (erp->status == DASD_CQR_NEED_ERP)) {
1988 dasd_3990_erp_compound_config(erp, sense);
1991 /* if no compound action ERP specified, the request failed */
1992 if (erp->status == DASD_CQR_NEED_ERP)
1993 erp->status = DASD_CQR_FAILED;
1997 } /* end dasd_3990_erp_compound */
2000 * DASD_3990_ERP_INSPECT_32
2003 * Does a detailed inspection of the 32 byte sense data
2004 * and sets up a related error recovery action.
2007 * sense sense data of the actual error
2008 * erp pointer to the currently created default ERP
2011 * erp_filled pointer to the ERP
2014 static struct dasd_ccw_req *
2015 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2018 struct dasd_device *device = erp->startdev;
2020 erp->function = dasd_3990_erp_inspect_32;
2022 if (sense[25] & DASD_SENSE_BIT_0) {
2024 /* compound program action codes (byte25 bit 0 == '1') */
2025 dasd_3990_erp_compound_retry(erp, sense);
2029 /* single program action codes (byte25 bit 0 == '0') */
2030 switch (sense[25]) {
2032 case 0x00: /* success - use default ERP for retries */
2033 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2034 "ERP called for successful request"
2038 case 0x01: /* fatal error */
2039 DEV_MESSAGE(KERN_ERR, device, "%s",
2040 "Retry not recommended - Fatal error");
2042 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2045 case 0x02: /* intervention required */
2046 case 0x03: /* intervention required during dual copy */
2047 erp = dasd_3990_erp_int_req(erp);
2050 case 0x0F: /* length mismatch during update write command */
2051 DEV_MESSAGE(KERN_ERR, device, "%s",
2052 "update write command error - should not "
2054 "Please send this message together with "
2055 "the above sense data to linux390@de."
2058 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2061 case 0x10: /* logging required for other channel program */
2062 erp = dasd_3990_erp_action_10_32(erp, sense);
2065 case 0x15: /* next track outside defined extend */
2066 DEV_MESSAGE(KERN_ERR, device, "%s",
2067 "next track outside defined extend - "
2068 "should not happen;\n"
2069 "Please send this message together with "
2070 "the above sense data to linux390@de."
2073 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2076 case 0x1B: /* unexpected condition during write */
2078 erp = dasd_3990_erp_action_1B_32(erp, sense);
2081 case 0x1C: /* invalid data */
2082 DEV_MESSAGE(KERN_EMERG, device, "%s",
2083 "Data recovered during retry with PCI "
2084 "fetch mode active");
2086 /* not possible to handle this situation in Linux */
2088 ("Invalid data - No way to inform application "
2089 "about the possibly incorrect data");
2092 case 0x1D: /* state-change pending */
2093 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2094 "A State change pending condition exists "
2095 "for the subsystem or device");
2097 erp = dasd_3990_erp_action_4(erp, sense);
2100 case 0x1E: /* busy */
2101 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2102 "Busy condition exists "
2103 "for the subsystem or device");
2104 erp = dasd_3990_erp_action_4(erp, sense);
2107 default: /* all others errors - default erp */
2114 } /* end dasd_3990_erp_inspect_32 */
2117 *****************************************************************************
2118 * main ERP control fuctions (24 and 32 byte sense)
2119 *****************************************************************************
2123 * DASD_3990_ERP_INSPECT
2126 * Does a detailed inspection for sense data by calling either
2127 * the 24-byte or the 32-byte inspection routine.
2130 * erp pointer to the currently created default ERP
2132 * erp_new contens was possibly modified
2134 static struct dasd_ccw_req *
2135 dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
2138 struct dasd_ccw_req *erp_new = NULL;
2139 /* sense data are located in the refers record of the */
2140 /* already set up new ERP ! */
2141 char *sense = erp->refers->irb.ecw;
2143 /* if this problem occured on an alias retry on base */
2144 erp_new = dasd_3990_erp_inspect_alias(erp);
2148 /* distinguish between 24 and 32 byte sense data */
2149 if (sense[27] & DASD_SENSE_BIT_0) {
2151 /* inspect the 24 byte sense data */
2152 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2156 /* inspect the 32 byte sense data */
2157 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2159 } /* end distinguish between 24 and 32 byte sense data */
2165 * DASD_3990_ERP_ADD_ERP
2168 * This funtion adds an additional request block (ERP) to the head of
2169 * the given cqr (or erp).
2170 * This erp is initialized as an default erp (retry TIC)
2173 * cqr head of the current ERP-chain (or single cqr if
2176 * erp pointer to new ERP-chain head
2178 static struct dasd_ccw_req *
2179 dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)
2182 struct dasd_device *device = cqr->startdev;
2185 /* allocate additional request block */
2186 struct dasd_ccw_req *erp;
2188 erp = dasd_alloc_erp_request((char *) &cqr->magic, 2, 0, device);
2190 if (cqr->retries <= 0) {
2191 DEV_MESSAGE(KERN_ERR, device, "%s",
2192 "Unable to allocate ERP request");
2193 cqr->status = DASD_CQR_FAILED;
2194 cqr->stopclk = get_clock ();
2196 DEV_MESSAGE (KERN_ERR, device,
2197 "Unable to allocate ERP request "
2198 "(%i retries left)",
2200 dasd_block_set_timer(device->block, (HZ << 3));
2205 /* initialize request with default TIC to current ERP/CQR */
2207 ccw->cmd_code = CCW_CMD_NOOP;
2208 ccw->flags = CCW_FLAG_CC;
2210 ccw->cmd_code = CCW_CMD_TIC;
2211 ccw->cda = (long)(cqr->cpaddr);
2212 erp->function = dasd_3990_erp_add_erp;
2214 erp->startdev = device;
2215 erp->memdev = device;
2216 erp->block = cqr->block;
2217 erp->magic = cqr->magic;
2220 erp->buildclk = get_clock();
2222 erp->status = DASD_CQR_FILLED;
2228 * DASD_3990_ERP_ADDITIONAL_ERP
2231 * An additional ERP is needed to handle the current error.
2232 * Add ERP to the head of the ERP-chain containing the ERP processing
2233 * determined based on the sense data.
2236 * cqr head of the current ERP-chain (or single cqr if
2240 * erp pointer to new ERP-chain head
2242 static struct dasd_ccw_req *
2243 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2246 struct dasd_ccw_req *erp = NULL;
2248 /* add erp and initialize with default TIC */
2249 erp = dasd_3990_erp_add_erp(cqr);
2251 /* inspect sense, determine specific ERP if possible */
2254 erp = dasd_3990_erp_inspect(erp);
2259 } /* end dasd_3990_erp_additional_erp */
2262 * DASD_3990_ERP_ERROR_MATCH
2265 * Check if the device status of the given cqr is the same.
2266 * This means that the failed CCW and the relevant sense data
2268 * I don't distinguish between 24 and 32 byte sense because in case of
2269 * 24 byte sense byte 25 and 27 is set as well.
2272 * cqr1 first cqr, which will be compared with the
2276 * match 'boolean' for match found
2277 * returns 1 if match found, otherwise 0.
2280 dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, struct dasd_ccw_req *cqr2)
2283 /* check failed CCW */
2284 if (cqr1->irb.scsw.cpa != cqr2->irb.scsw.cpa) {
2285 // return 0; /* CCW doesn't match */
2288 /* check sense data; byte 0-2,25,27 */
2289 if (!((memcmp (cqr1->irb.ecw, cqr2->irb.ecw, 3) == 0) &&
2290 (cqr1->irb.ecw[27] == cqr2->irb.ecw[27]) &&
2291 (cqr1->irb.ecw[25] == cqr2->irb.ecw[25]))) {
2293 return 0; /* sense doesn't match */
2296 return 1; /* match */
2298 } /* end dasd_3990_erp_error_match */
2301 * DASD_3990_ERP_IN_ERP
2304 * check if the current error already happened before.
2305 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2308 * cqr failed cqr (either original cqr or already an erp)
2311 * erp erp-pointer to the already defined error
2312 * recovery procedure OR
2313 * NULL if a 'new' error occurred.
2315 static struct dasd_ccw_req *
2316 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2319 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2320 *erp_match = NULL; /* save erp chain head */
2321 int match = 0; /* 'boolean' for matching error found */
2323 if (cqr->refers == NULL) { /* return if not in erp */
2327 /* check the erp/cqr chain for current error */
2329 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2330 erp_match = cqr; /* save possible matching erp */
2331 cqr = cqr->refers; /* check next erp/cqr in queue */
2333 } while ((cqr->refers != NULL) && (!match));
2336 return NULL; /* no match was found */
2339 return erp_match; /* return address of matching erp */
2341 } /* END dasd_3990_erp_in_erp */
2344 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2347 * No retry is left for the current ERP. Check what has to be done
2349 * - do further defined ERP action or
2350 * - wait for interrupt or
2351 * - exit with permanent error
2354 * erp ERP which is in progress with no retry left
2357 * erp modified/additional ERP
2359 static struct dasd_ccw_req *
2360 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2363 struct dasd_device *device = erp->startdev;
2364 char *sense = erp->irb.ecw;
2366 /* check for 24 byte sense ERP */
2367 if ((erp->function == dasd_3990_erp_bus_out) ||
2368 (erp->function == dasd_3990_erp_action_1) ||
2369 (erp->function == dasd_3990_erp_action_4)) {
2371 erp = dasd_3990_erp_action_1(erp);
2373 } else if (erp->function == dasd_3990_erp_action_5) {
2375 /* retries have not been successful */
2376 /* prepare erp for retry on different channel path */
2377 erp = dasd_3990_erp_action_1(erp);
2379 if (!(sense[2] & DASD_SENSE_BIT_0)) {
2381 /* issue a Diagnostic Control command with an
2382 * Inhibit Write subcommand */
2384 switch (sense[25]) {
2386 case 0x57:{ /* controller */
2387 erp = dasd_3990_erp_DCTL(erp, 0x20);
2391 case 0x58:{ /* channel path */
2392 erp = dasd_3990_erp_DCTL(erp, 0x40);
2396 case 0x59:{ /* storage director */
2397 erp = dasd_3990_erp_DCTL(erp, 0x80);
2401 DEV_MESSAGE(KERN_DEBUG, device,
2402 "invalid subcommand modifier 0x%x "
2403 "for Diagnostic Control Command",
2408 /* check for 32 byte sense ERP */
2409 } else if ((erp->function == dasd_3990_erp_compound_retry) ||
2410 (erp->function == dasd_3990_erp_compound_path) ||
2411 (erp->function == dasd_3990_erp_compound_code) ||
2412 (erp->function == dasd_3990_erp_compound_config)) {
2414 erp = dasd_3990_erp_compound(erp, sense);
2417 /* No retry left and no additional special handling */
2419 DEV_MESSAGE(KERN_ERR, device,
2420 "no retries left for erp %p - "
2421 "set status to FAILED", erp);
2423 erp->status = DASD_CQR_FAILED;
2428 } /* end dasd_3990_erp_further_erp */
2431 * DASD_3990_ERP_HANDLE_MATCH_ERP
2434 * An error occurred again and an ERP has been detected which is already
2435 * used to handle this error (e.g. retries).
2436 * All prior ERP's are asumed to be successful and therefore removed
2438 * If retry counter of matching erp is already 0, it is checked if further
2439 * action is needed (besides retry) or if the ERP has failed.
2442 * erp_head first ERP in ERP-chain
2443 * erp ERP that handles the actual error.
2447 * erp modified/additional ERP
2449 static struct dasd_ccw_req *
2450 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2451 struct dasd_ccw_req *erp)
2454 struct dasd_device *device = erp_head->startdev;
2455 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2456 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2458 /* loop over successful ERPs and remove them from chanq */
2459 while (erp_done != erp) {
2461 if (erp_done == NULL) /* end of chain reached */
2462 panic(PRINTK_HEADER "Programming error in ERP! The "
2463 "original request was lost\n");
2465 /* remove the request from the device queue */
2466 list_del(&erp_done->blocklist);
2468 erp_free = erp_done;
2469 erp_done = erp_done->refers;
2471 /* free the finished erp request */
2472 dasd_free_erp_request(erp_free, erp_free->memdev);
2476 if (erp->retries > 0) {
2478 char *sense = erp->refers->irb.ecw;
2480 /* check for special retries */
2481 if (erp->function == dasd_3990_erp_action_4) {
2483 erp = dasd_3990_erp_action_4(erp, sense);
2485 } else if (erp->function == dasd_3990_erp_action_1B_32) {
2487 erp = dasd_3990_update_1B(erp, sense);
2489 } else if (erp->function == dasd_3990_erp_int_req) {
2491 erp = dasd_3990_erp_int_req(erp);
2495 DEV_MESSAGE(KERN_DEBUG, device,
2496 "%i retries left for erp %p",
2499 /* handle the request again... */
2500 erp->status = DASD_CQR_FILLED;
2504 /* no retry left - check for further necessary action */
2505 /* if no further actions, handle rest as permanent error */
2506 erp = dasd_3990_erp_further_erp(erp);
2511 } /* end dasd_3990_erp_handle_match_erp */
2514 * DASD_3990_ERP_ACTION
2517 * control routine for 3990 erp actions.
2518 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2521 * cqr failed cqr (either original cqr or already an erp)
2524 * erp erp-pointer to the head of the ERP action chain.
2526 * - either a ptr to an additional ERP cqr or
2527 * - the original given cqr (which's status might
2530 struct dasd_ccw_req *
2531 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2533 struct dasd_ccw_req *erp = NULL;
2534 struct dasd_device *device = cqr->startdev;
2535 struct dasd_ccw_req *temp_erp = NULL;
2537 if (device->features & DASD_FEATURE_ERPLOG) {
2538 /* print current erp_chain */
2539 DEV_MESSAGE(KERN_ERR, device, "%s",
2540 "ERP chain at BEGINNING of ERP-ACTION");
2541 for (temp_erp = cqr;
2542 temp_erp != NULL; temp_erp = temp_erp->refers) {
2544 DEV_MESSAGE(KERN_ERR, device,
2545 " erp %p (%02x) refers to %p",
2546 temp_erp, temp_erp->status,
2551 /* double-check if current erp/cqr was successfull */
2552 if ((cqr->irb.scsw.cstat == 0x00) &&
2553 (cqr->irb.scsw.dstat == (DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2555 DEV_MESSAGE(KERN_DEBUG, device,
2556 "ERP called for successful request %p"
2557 " - NO ERP necessary", cqr);
2559 cqr->status = DASD_CQR_DONE;
2563 /* check if sense data are available */
2564 if (!cqr->irb.ecw) {
2565 DEV_MESSAGE(KERN_DEBUG, device,
2566 "ERP called witout sense data avail ..."
2567 "request %p - NO ERP possible", cqr);
2569 cqr->status = DASD_CQR_FAILED;
2575 /* check if error happened before */
2576 erp = dasd_3990_erp_in_erp(cqr);
2579 /* no matching erp found - set up erp */
2580 erp = dasd_3990_erp_additional_erp(cqr);
2582 /* matching erp found - set all leading erp's to DONE */
2583 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2586 if (device->features & DASD_FEATURE_ERPLOG) {
2587 /* print current erp_chain */
2588 DEV_MESSAGE(KERN_ERR, device, "%s",
2589 "ERP chain at END of ERP-ACTION");
2590 for (temp_erp = erp;
2591 temp_erp != NULL; temp_erp = temp_erp->refers) {
2593 DEV_MESSAGE(KERN_ERR, device,
2594 " erp %p (%02x) refers to %p",
2595 temp_erp, temp_erp->status,
2600 /* enqueue ERP request if it's a new one */
2601 if (list_empty(&erp->blocklist)) {
2602 cqr->status = DASD_CQR_IN_ERP;
2603 /* add erp request before the cqr */
2604 list_add_tail(&erp->blocklist, &cqr->blocklist);
2609 } /* end dasd_3990_erp_action */