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 #define KMSG_COMPONENT "dasd"
12 #include <linux/timer.h>
13 #include <linux/slab.h>
14 #include <asm/idals.h>
15 #include <asm/todclk.h>
17 #define PRINTK_HEADER "dasd_erp(3990): "
20 #include "dasd_eckd.h"
24 unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
25 unsigned char modifier; /* Subcommand modifier */
26 unsigned short res; /* reserved */
27 } __attribute__ ((packed));
30 *****************************************************************************
31 * SECTION ERP HANDLING
32 *****************************************************************************
35 *****************************************************************************
36 * 24 and 32 byte sense ERP functions
37 *****************************************************************************
41 * DASD_3990_ERP_CLEANUP
44 * Removes the already build but not necessary ERP request and sets
45 * the status of the original cqr / erp to the given (final) status
48 * erp request to be blocked
49 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
54 static struct dasd_ccw_req *
55 dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
57 struct dasd_ccw_req *cqr = erp->refers;
59 dasd_free_erp_request(erp, erp->memdev);
60 cqr->status = final_status;
63 } /* end dasd_3990_erp_cleanup */
66 * DASD_3990_ERP_BLOCK_QUEUE
69 * Block the given device request queue to prevent from further
70 * processing until the started timer has expired or an related
71 * interrupt was received.
74 dasd_3990_erp_block_queue(struct dasd_ccw_req * erp, int expires)
77 struct dasd_device *device = erp->startdev;
80 DBF_DEV_EVENT(DBF_INFO, device,
81 "blocking request queue for %is", expires/HZ);
83 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
84 device->stopped |= DASD_STOPPED_PENDING;
85 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
86 erp->status = DASD_CQR_FILLED;
87 dasd_block_set_timer(device->block, expires);
91 * DASD_3990_ERP_INT_REQ
94 * Handles 'Intervention Required' error.
95 * This means either device offline or not installed.
102 static struct dasd_ccw_req *
103 dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
106 struct dasd_device *device = erp->startdev;
108 /* first time set initial retry counter and erp_function */
109 /* and retry once without blocking queue */
110 /* (this enables easier enqueing of the cqr) */
111 if (erp->function != dasd_3990_erp_int_req) {
114 erp->function = dasd_3990_erp_int_req;
118 /* issue a message and wait for 'device ready' interrupt */
119 dev_err(&device->cdev->dev,
120 "is offline or not installed - "
121 "INTERVENTION REQUIRED!!\n");
123 dasd_3990_erp_block_queue(erp, 60*HZ);
128 } /* end dasd_3990_erp_int_req */
131 * DASD_3990_ERP_ALTERNATE_PATH
134 * Repeat the operation on a different channel path.
135 * If all alternate paths have been tried, the request is posted with a
139 * erp pointer to the current ERP
142 * erp modified pointer to the ERP
145 dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
147 struct dasd_device *device = erp->startdev;
151 /* try alternate valid path */
152 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
153 opm = ccw_device_get_path_mask(device->cdev);
154 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
155 //FIXME: start with get_opm ?
157 erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
159 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
161 if ((erp->lpm & opm) != 0x00) {
163 DBF_DEV_EVENT(DBF_WARNING, device,
164 "try alternate lpm=%x (lpum=%x / opm=%x)",
165 erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
167 /* reset status to submit the request again... */
168 erp->status = DASD_CQR_FILLED;
171 dev_err(&device->cdev->dev,
172 "The DASD cannot be reached on any path (lpum=%x"
173 "/opm=%x)\n", erp->irb.esw.esw0.sublog.lpum, opm);
175 /* post request with permanent error */
176 erp->status = DASD_CQR_FAILED;
178 } /* end dasd_3990_erp_alternate_path */
184 * Setup cqr to do the Diagnostic Control (DCTL) command with an
185 * Inhibit Write subcommand (0x20) and the given modifier.
188 * erp pointer to the current (failed) ERP
189 * modifier subcommand modifier
192 * dctl_cqr pointer to NEW dctl_cqr
195 static struct dasd_ccw_req *
196 dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
199 struct dasd_device *device = erp->startdev;
200 struct DCTL_data *DCTL_data;
202 struct dasd_ccw_req *dctl_cqr;
204 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
205 sizeof(struct DCTL_data),
207 if (IS_ERR(dctl_cqr)) {
208 dev_err(&device->cdev->dev,
209 "Unable to allocate DCTL-CQR\n");
210 erp->status = DASD_CQR_FAILED;
214 DCTL_data = dctl_cqr->data;
216 DCTL_data->subcommand = 0x02; /* Inhibit Write */
217 DCTL_data->modifier = modifier;
219 ccw = dctl_cqr->cpaddr;
220 memset(ccw, 0, sizeof(struct ccw1));
221 ccw->cmd_code = CCW_CMD_DCTL;
223 ccw->cda = (__u32)(addr_t) DCTL_data;
224 dctl_cqr->function = dasd_3990_erp_DCTL;
225 dctl_cqr->refers = erp;
226 dctl_cqr->startdev = device;
227 dctl_cqr->memdev = device;
228 dctl_cqr->magic = erp->magic;
229 dctl_cqr->expires = 5 * 60 * HZ;
230 dctl_cqr->retries = 2;
232 dctl_cqr->buildclk = get_clock();
234 dctl_cqr->status = DASD_CQR_FILLED;
238 } /* end dasd_3990_erp_DCTL */
241 * DASD_3990_ERP_ACTION_1
244 * Setup ERP to do the ERP action 1 (see Reference manual).
245 * Repeat the operation on a different channel path.
246 * If all alternate paths have been tried, the request is posted with a
248 * Note: duplex handling is not implemented (yet).
251 * erp pointer to the current ERP
254 * erp pointer to the ERP
257 static struct dasd_ccw_req *
258 dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
261 erp->function = dasd_3990_erp_action_1;
263 dasd_3990_erp_alternate_path(erp);
267 } /* end dasd_3990_erp_action_1 */
270 * DASD_3990_ERP_ACTION_4
273 * Setup ERP to do the ERP action 4 (see Reference manual).
274 * Set the current request to PENDING to block the CQR queue for that device
275 * until the state change interrupt appears.
276 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
280 * sense sense data of the actual error
281 * erp pointer to the current ERP
284 * erp pointer to the ERP
287 static struct dasd_ccw_req *
288 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
291 struct dasd_device *device = erp->startdev;
293 /* first time set initial retry counter and erp_function */
294 /* and retry once without waiting for state change pending */
295 /* interrupt (this enables easier enqueing of the cqr) */
296 if (erp->function != dasd_3990_erp_action_4) {
298 DBF_DEV_EVENT(DBF_INFO, device, "%s",
299 "dasd_3990_erp_action_4: first time retry");
302 erp->function = dasd_3990_erp_action_4;
305 if (sense && (sense[25] == 0x1D)) { /* state change pending */
307 DBF_DEV_EVENT(DBF_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 && (sense[25] == 0x1E)) { /* busy */
315 DBF_DEV_EVENT(DBF_INFO, device,
316 "busy - redriving request later, "
319 dasd_3990_erp_block_queue(erp, HZ);
321 /* no state change pending - retry */
322 DBF_DEV_EVENT(DBF_INFO, device,
323 "redriving request immediately, "
326 erp->status = DASD_CQR_FILLED;
332 } /* end dasd_3990_erp_action_4 */
335 *****************************************************************************
336 * 24 byte sense ERP functions (only)
337 *****************************************************************************
341 * DASD_3990_ERP_ACTION_5
344 * Setup ERP to do the ERP action 5 (see Reference manual).
345 * NOTE: Further handling is done in xxx_further_erp after the retries.
348 * erp pointer to the current ERP
351 * erp pointer to the ERP
354 static struct dasd_ccw_req *
355 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
358 /* first of all retry */
360 erp->function = dasd_3990_erp_action_5;
364 } /* end dasd_3990_erp_action_5 */
367 * DASD_3990_HANDLE_ENV_DATA
370 * Handles 24 byte 'Environmental data present'.
371 * Does a analysis of the sense data (message Format)
372 * and prints the error messages.
375 * sense current sense data
381 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
384 struct dasd_device *device = erp->startdev;
385 char msg_format = (sense[7] & 0xF0);
386 char msg_no = (sense[7] & 0x0F);
387 char errorstring[ERRORLENGTH];
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_warn(&device->cdev->dev,
399 "FORMAT 0 - Invalid Command\n");
402 dev_warn(&device->cdev->dev,
403 "FORMAT 0 - Invalid Command "
407 dev_warn(&device->cdev->dev,
408 "FORMAT 0 - CCW Count less than "
412 dev_warn(&device->cdev->dev,
413 "FORMAT 0 - Invalid Parameter\n");
416 dev_warn(&device->cdev->dev,
417 "FORMAT 0 - Diagnostic of Special"
418 " Command Violates File Mask\n");
421 dev_warn(&device->cdev->dev,
422 "FORMAT 0 - Channel Returned with "
423 "Incorrect retry CCW\n");
426 dev_warn(&device->cdev->dev,
427 "FORMAT 0 - Reset Notification\n");
430 dev_warn(&device->cdev->dev,
431 "FORMAT 0 - Storage Path Restart\n");
434 dev_warn(&device->cdev->dev,
435 "FORMAT 0 - Channel requested "
436 "... %02x\n", sense[8]);
439 dev_warn(&device->cdev->dev,
440 "FORMAT 0 - Invalid Defective/"
441 "Alternate Track Pointer\n");
444 dev_warn(&device->cdev->dev,
445 "FORMAT 0 - DPS Installation "
449 dev_warn(&device->cdev->dev,
450 "FORMAT 0 - Command Invalid on "
451 "Secondary Address\n");
454 dev_warn(&device->cdev->dev,
455 "FORMAT 0 - Status Not As "
456 "Required: reason %02x\n",
460 dev_warn(&device->cdev->dev,
461 "FORMAT 0 - Reserved\n");
465 case 0x00: /* No Message */
468 dev_warn(&device->cdev->dev,
469 "FORMAT 0 - Device Error "
473 dev_warn(&device->cdev->dev,
474 "FORMAT 0 - Reserved\n");
477 dev_warn(&device->cdev->dev,
478 "FORMAT 0 - Device Fenced - "
479 "device = %02x\n", sense[4]);
482 dev_warn(&device->cdev->dev,
483 "FORMAT 0 - Data Pinned for "
487 dev_warn(&device->cdev->dev,
488 "FORMAT 0 - Reserved\n");
493 case 0x10: /* Format 1 - Device Equipment Checks */
495 case 0x00: /* No Message */
498 dev_warn(&device->cdev->dev,
499 "FORMAT 1 - Device Status 1 not as "
503 dev_warn(&device->cdev->dev,
504 "FORMAT 1 - Index missing\n");
507 dev_warn(&device->cdev->dev,
508 "FORMAT 1 - Interruption cannot be "
512 dev_warn(&device->cdev->dev,
513 "FORMAT 1 - Device did not respond to "
517 dev_warn(&device->cdev->dev,
518 "FORMAT 1 - Device check-2 error or Set "
519 "Sector is not complete\n");
522 dev_warn(&device->cdev->dev,
523 "FORMAT 1 - Head address does not "
527 dev_warn(&device->cdev->dev,
528 "FORMAT 1 - Device status 1 not valid\n");
531 dev_warn(&device->cdev->dev,
532 "FORMAT 1 - Device not ready\n");
535 dev_warn(&device->cdev->dev,
536 "FORMAT 1 - Track physical address did "
540 dev_warn(&device->cdev->dev,
541 "FORMAT 1 - Missing device address bit\n");
544 dev_warn(&device->cdev->dev,
545 "FORMAT 1 - Drive motor switch is off\n");
548 dev_warn(&device->cdev->dev,
549 "FORMAT 1 - Seek incomplete\n");
552 dev_warn(&device->cdev->dev,
553 "FORMAT 1 - Cylinder address did not "
557 dev_warn(&device->cdev->dev,
558 "FORMAT 1 - Offset active cannot be "
562 dev_warn(&device->cdev->dev,
563 "FORMAT 1 - Reserved\n");
567 case 0x20: /* Format 2 - 3990 Equipment Checks */
570 dev_warn(&device->cdev->dev,
571 "FORMAT 2 - 3990 check-2 error\n");
574 dev_warn(&device->cdev->dev,
575 "FORMAT 2 - Support facility errors\n");
578 dev_warn(&device->cdev->dev,
579 "FORMAT 2 - Microcode detected error "
584 dev_warn(&device->cdev->dev,
585 "FORMAT 2 - Reserved\n");
589 case 0x30: /* Format 3 - 3990 Control Checks */
592 dev_warn(&device->cdev->dev,
593 "FORMAT 3 - Allegiance terminated\n");
596 dev_warn(&device->cdev->dev,
597 "FORMAT 3 - Reserved\n");
601 case 0x40: /* Format 4 - Data Checks */
604 dev_warn(&device->cdev->dev,
605 "FORMAT 4 - Home address area error\n");
608 dev_warn(&device->cdev->dev,
609 "FORMAT 4 - Count area error\n");
612 dev_warn(&device->cdev->dev,
613 "FORMAT 4 - Key area error\n");
616 dev_warn(&device->cdev->dev,
617 "FORMAT 4 - Data area error\n");
620 dev_warn(&device->cdev->dev,
621 "FORMAT 4 - No sync byte in home address "
625 dev_warn(&device->cdev->dev,
626 "FORMAT 4 - No sync byte in count address "
630 dev_warn(&device->cdev->dev,
631 "FORMAT 4 - No sync byte in key area\n");
634 dev_warn(&device->cdev->dev,
635 "FORMAT 4 - No sync byte in data area\n");
638 dev_warn(&device->cdev->dev,
639 "FORMAT 4 - Home address area error; "
643 dev_warn(&device->cdev->dev,
644 "FORMAT 4 - Count area error; offset "
648 dev_warn(&device->cdev->dev,
649 "FORMAT 4 - Key area error; offset "
653 dev_warn(&device->cdev->dev,
654 "FORMAT 4 - Data area error; "
658 dev_warn(&device->cdev->dev,
659 "FORMAT 4 - No sync byte in home "
660 "address area; offset active\n");
663 dev_warn(&device->cdev->dev,
664 "FORMAT 4 - No syn byte in count "
665 "address area; offset active\n");
668 dev_warn(&device->cdev->dev,
669 "FORMAT 4 - No sync byte in key area; "
673 dev_warn(&device->cdev->dev,
674 "FORMAT 4 - No syn byte in data area; "
678 dev_warn(&device->cdev->dev,
679 "FORMAT 4 - Reserved\n");
683 case 0x50: /* Format 5 - Data Check with displacement information */
686 dev_warn(&device->cdev->dev,
687 "FORMAT 5 - Data Check in the "
688 "home address area\n");
691 dev_warn(&device->cdev->dev,
692 "FORMAT 5 - Data Check in the count "
696 dev_warn(&device->cdev->dev,
697 "FORMAT 5 - Data Check in the key area\n");
700 dev_warn(&device->cdev->dev,
701 "FORMAT 5 - Data Check in the data "
705 dev_warn(&device->cdev->dev,
706 "FORMAT 5 - Data Check in the "
707 "home address area; offset active\n");
710 dev_warn(&device->cdev->dev,
711 "FORMAT 5 - Data Check in the count area; "
715 dev_warn(&device->cdev->dev,
716 "FORMAT 5 - Data Check in the key area; "
720 dev_warn(&device->cdev->dev,
721 "FORMAT 5 - Data Check in the data area; "
725 dev_warn(&device->cdev->dev,
726 "FORMAT 5 - Reserved\n");
730 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
733 dev_warn(&device->cdev->dev,
734 "FORMAT 6 - Overrun on channel A\n");
737 dev_warn(&device->cdev->dev,
738 "FORMAT 6 - Overrun on channel B\n");
741 dev_warn(&device->cdev->dev,
742 "FORMAT 6 - Overrun on channel C\n");
745 dev_warn(&device->cdev->dev,
746 "FORMAT 6 - Overrun on channel D\n");
749 dev_warn(&device->cdev->dev,
750 "FORMAT 6 - Overrun on channel E\n");
753 dev_warn(&device->cdev->dev,
754 "FORMAT 6 - Overrun on channel F\n");
757 dev_warn(&device->cdev->dev,
758 "FORMAT 6 - Overrun on channel G\n");
761 dev_warn(&device->cdev->dev,
762 "FORMAT 6 - Overrun on channel H\n");
765 dev_warn(&device->cdev->dev,
766 "FORMAT 6 - Reserved\n");
770 case 0x70: /* Format 7 - Device Connection Control Checks */
773 dev_warn(&device->cdev->dev,
774 "FORMAT 7 - RCC initiated by a connection "
778 dev_warn(&device->cdev->dev,
779 "FORMAT 7 - RCC 1 sequence not "
783 dev_warn(&device->cdev->dev,
784 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
788 dev_warn(&device->cdev->dev,
789 "FORMAT 7 - Invalid tag-in during "
790 "selection sequence\n");
793 dev_warn(&device->cdev->dev,
794 "FORMAT 7 - extra RCC required\n");
797 dev_warn(&device->cdev->dev,
798 "FORMAT 7 - Invalid DCC selection "
799 "response or timeout\n");
802 dev_warn(&device->cdev->dev,
803 "FORMAT 7 - Missing end operation; device "
804 "transfer complete\n");
807 dev_warn(&device->cdev->dev,
808 "FORMAT 7 - Missing end operation; device "
809 "transfer incomplete\n");
812 dev_warn(&device->cdev->dev,
813 "FORMAT 7 - Invalid tag-in for an "
814 "immediate command sequence\n");
817 dev_warn(&device->cdev->dev,
818 "FORMAT 7 - Invalid tag-in for an "
819 "extended command sequence\n");
822 dev_warn(&device->cdev->dev,
823 "FORMAT 7 - 3990 microcode time out when "
824 "stopping selection\n");
827 dev_warn(&device->cdev->dev,
828 "FORMAT 7 - No response to selection "
829 "after a poll interruption\n");
832 dev_warn(&device->cdev->dev,
833 "FORMAT 7 - Permanent path error (DASD "
834 "controller not available)\n");
837 dev_warn(&device->cdev->dev,
838 "FORMAT 7 - DASD controller not available"
839 " on disconnected command chain\n");
842 dev_warn(&device->cdev->dev,
843 "FORMAT 7 - Reserved\n");
847 case 0x80: /* Format 8 - Additional Device Equipment Checks */
849 case 0x00: /* No Message */
851 dev_warn(&device->cdev->dev,
852 "FORMAT 8 - Error correction code "
856 dev_warn(&device->cdev->dev,
857 "FORMAT 8 - Unexpected end operation "
861 dev_warn(&device->cdev->dev,
862 "FORMAT 8 - End operation with transfer "
866 dev_warn(&device->cdev->dev,
867 "FORMAT 8 - End operation with transfer "
871 dev_warn(&device->cdev->dev,
872 "FORMAT 8 - DPS checks after a system "
873 "reset or selective reset\n");
876 dev_warn(&device->cdev->dev,
877 "FORMAT 8 - DPS cannot be filled\n");
880 dev_warn(&device->cdev->dev,
881 "FORMAT 8 - Short busy time-out during "
882 "device selection\n");
885 dev_warn(&device->cdev->dev,
886 "FORMAT 8 - DASD controller failed to "
887 "set or reset the long busy latch\n");
890 dev_warn(&device->cdev->dev,
891 "FORMAT 8 - No interruption from device "
892 "during a command chain\n");
895 dev_warn(&device->cdev->dev,
896 "FORMAT 8 - Reserved\n");
900 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
903 break; /* No Message */
905 dev_warn(&device->cdev->dev,
906 "FORMAT 9 - Device check-2 error\n");
909 dev_warn(&device->cdev->dev,
910 "FORMAT 9 - Head address did not "
914 dev_warn(&device->cdev->dev,
915 "FORMAT 9 - Track physical address did "
916 "not compare while oriented\n");
919 dev_warn(&device->cdev->dev,
920 "FORMAT 9 - Cylinder address did not "
924 dev_warn(&device->cdev->dev,
925 "FORMAT 9 - Reserved\n");
929 case 0xF0: /* Format F - Cache Storage Checks */
932 dev_warn(&device->cdev->dev,
933 "FORMAT F - Operation Terminated\n");
936 dev_warn(&device->cdev->dev,
937 "FORMAT F - Subsystem Processing Error\n");
940 dev_warn(&device->cdev->dev,
941 "FORMAT F - Cache or nonvolatile storage "
942 "equipment failure\n");
945 dev_warn(&device->cdev->dev,
946 "FORMAT F - Caching terminated\n");
949 dev_warn(&device->cdev->dev,
950 "FORMAT F - Cache fast write access not "
954 dev_warn(&device->cdev->dev,
955 "FORMAT F - Track format incorrect\n");
958 dev_warn(&device->cdev->dev,
959 "FORMAT F - Caching reinitiated\n");
962 dev_warn(&device->cdev->dev,
963 "FORMAT F - Nonvolatile storage "
967 dev_warn(&device->cdev->dev,
968 "FORMAT F - Volume is suspended duplex\n");
969 /* call extended error reporting (EER) */
970 dasd_eer_write(device, erp->refers,
971 DASD_EER_PPRCSUSPEND);
974 dev_warn(&device->cdev->dev,
975 "FORMAT F - Subsystem status cannot be "
979 dev_warn(&device->cdev->dev,
980 "FORMAT F - Caching status reset to "
984 dev_warn(&device->cdev->dev,
985 "FORMAT F - DASD Fast Write inhibited\n");
988 dev_warn(&device->cdev->dev,
989 "FORMAT D - Reserved\n");
993 default: /* unknown message format - should not happen
994 internal error 03 - unknown message format */
995 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
996 dev_err(&device->cdev->dev,
997 "An error occurred in the DASD device driver, "
998 "reason=%s\n", errorstring);
1000 } /* end switch message format */
1002 } /* end dasd_3990_handle_env_data */
1005 * DASD_3990_ERP_COM_REJ
1008 * Handles 24 byte 'Command Reject' error.
1011 * erp current erp_head
1012 * sense current sense data
1015 * erp 'new' erp_head - pointer to new ERP
1017 static struct dasd_ccw_req *
1018 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1021 struct dasd_device *device = erp->startdev;
1023 erp->function = dasd_3990_erp_com_rej;
1025 /* env data present (ACTION 10 - retry should work) */
1026 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1028 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1029 "Command Reject - environmental data present");
1031 dasd_3990_handle_env_data(erp, sense);
1036 /* fatal error - set status to FAILED
1037 internal error 09 - Command Reject */
1038 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1039 "device driver, reason=%s\n", "09");
1041 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1046 } /* end dasd_3990_erp_com_rej */
1049 * DASD_3990_ERP_BUS_OUT
1052 * Handles 24 byte 'Bus Out Parity Check' error.
1055 * erp current erp_head
1057 * erp new erp_head - pointer to new ERP
1059 static struct dasd_ccw_req *
1060 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1063 struct dasd_device *device = erp->startdev;
1065 /* first time set initial retry counter and erp_function */
1066 /* and retry once without blocking queue */
1067 /* (this enables easier enqueing of the cqr) */
1068 if (erp->function != dasd_3990_erp_bus_out) {
1070 erp->function = dasd_3990_erp_bus_out;
1074 /* issue a message and wait for 'device ready' interrupt */
1075 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1076 "bus out parity error or BOPC requested by "
1079 dasd_3990_erp_block_queue(erp, 60*HZ);
1085 } /* end dasd_3990_erp_bus_out */
1088 * DASD_3990_ERP_EQUIP_CHECK
1091 * Handles 24 byte 'Equipment Check' error.
1094 * erp current erp_head
1096 * erp new erp_head - pointer to new ERP
1098 static struct dasd_ccw_req *
1099 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1102 struct dasd_device *device = erp->startdev;
1104 erp->function = dasd_3990_erp_equip_check;
1106 if (sense[1] & SNS1_WRITE_INHIBITED) {
1107 dev_info(&device->cdev->dev,
1108 "Write inhibited path encountered\n");
1110 /* vary path offline
1111 internal error 04 - Path should be varied off-line.*/
1112 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1113 "device driver, reason=%s\n", "04");
1115 erp = dasd_3990_erp_action_1(erp);
1117 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1119 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1120 "Equipment Check - " "environmental data present");
1122 dasd_3990_handle_env_data(erp, sense);
1124 erp = dasd_3990_erp_action_4(erp, sense);
1126 } else if (sense[1] & SNS1_PERM_ERR) {
1128 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1129 "Equipment Check - retry exhausted or "
1132 erp = dasd_3990_erp_action_1(erp);
1135 /* all other equipment checks - Action 5 */
1136 /* rest is done when retries == 0 */
1137 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1138 "Equipment check or processing error");
1140 erp = dasd_3990_erp_action_5(erp);
1144 } /* end dasd_3990_erp_equip_check */
1147 * DASD_3990_ERP_DATA_CHECK
1150 * Handles 24 byte 'Data Check' error.
1153 * erp current erp_head
1155 * erp new erp_head - pointer to new ERP
1157 static struct dasd_ccw_req *
1158 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1161 struct dasd_device *device = erp->startdev;
1163 erp->function = dasd_3990_erp_data_check;
1165 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1167 /* issue message that the data has been corrected */
1168 dev_emerg(&device->cdev->dev,
1169 "Data recovered during retry with PCI "
1170 "fetch mode active\n");
1172 /* not possible to handle this situation in Linux */
1173 panic("No way to inform application about the possibly "
1176 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1178 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1179 "Uncorrectable data check recovered secondary "
1180 "addr of duplex pair");
1182 erp = dasd_3990_erp_action_4(erp, sense);
1184 } else if (sense[1] & SNS1_PERM_ERR) {
1186 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1187 "Uncorrectable data check with internal "
1190 erp = dasd_3990_erp_action_1(erp);
1193 /* all other data checks */
1194 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1195 "Uncorrectable data check with retry count "
1198 erp = dasd_3990_erp_action_5(erp);
1203 } /* end dasd_3990_erp_data_check */
1206 * DASD_3990_ERP_OVERRUN
1209 * Handles 24 byte 'Overrun' error.
1212 * erp current erp_head
1214 * erp new erp_head - pointer to new ERP
1216 static struct dasd_ccw_req *
1217 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1220 struct dasd_device *device = erp->startdev;
1222 erp->function = dasd_3990_erp_overrun;
1224 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1225 "Overrun - service overrun or overrun"
1226 " error requested by channel");
1228 erp = dasd_3990_erp_action_5(erp);
1232 } /* end dasd_3990_erp_overrun */
1235 * DASD_3990_ERP_INV_FORMAT
1238 * Handles 24 byte 'Invalid Track Format' error.
1241 * erp current erp_head
1243 * erp new erp_head - pointer to new ERP
1245 static struct dasd_ccw_req *
1246 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1249 struct dasd_device *device = erp->startdev;
1251 erp->function = dasd_3990_erp_inv_format;
1253 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1255 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1256 "Track format error when destaging or "
1259 dasd_3990_handle_env_data(erp, sense);
1261 erp = dasd_3990_erp_action_4(erp, sense);
1264 /* internal error 06 - The track format is not valid*/
1265 dev_err(&device->cdev->dev,
1266 "An error occurred in the DASD device driver, "
1267 "reason=%s\n", "06");
1269 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1274 } /* end dasd_3990_erp_inv_format */
1280 * Handles 24 byte 'End-of-Cylinder' error.
1283 * erp already added default erp
1285 * erp pointer to original (failed) cqr.
1287 static struct dasd_ccw_req *
1288 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1291 struct dasd_device *device = default_erp->startdev;
1293 dev_err(&device->cdev->dev,
1294 "The cylinder data for accessing the DASD is inconsistent\n");
1296 /* implement action 7 - BUG */
1297 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1299 } /* end dasd_3990_erp_EOC */
1302 * DASD_3990_ERP_ENV_DATA
1305 * Handles 24 byte 'Environmental-Data Present' error.
1308 * erp current erp_head
1310 * erp new erp_head - pointer to new ERP
1312 static struct dasd_ccw_req *
1313 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1316 struct dasd_device *device = erp->startdev;
1318 erp->function = dasd_3990_erp_env_data;
1320 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
1322 dasd_3990_handle_env_data(erp, sense);
1324 /* don't retry on disabled interface */
1325 if (sense[7] != 0x0F) {
1326 erp = dasd_3990_erp_action_4(erp, sense);
1328 erp->status = DASD_CQR_FILLED;
1333 } /* end dasd_3990_erp_env_data */
1336 * DASD_3990_ERP_NO_REC
1339 * Handles 24 byte 'No Record Found' error.
1342 * erp already added default ERP
1345 * erp new erp_head - pointer to new ERP
1347 static struct dasd_ccw_req *
1348 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1351 struct dasd_device *device = default_erp->startdev;
1353 dev_err(&device->cdev->dev,
1354 "The specified record was not found\n");
1356 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1358 } /* end dasd_3990_erp_no_rec */
1361 * DASD_3990_ERP_FILE_PROT
1364 * Handles 24 byte 'File Protected' error.
1365 * Note: Seek related recovery is not implemented because
1366 * wee don't use the seek command yet.
1369 * erp current erp_head
1371 * erp new erp_head - pointer to new ERP
1373 static struct dasd_ccw_req *
1374 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1377 struct dasd_device *device = erp->startdev;
1379 dev_err(&device->cdev->dev, "Accessing the DASD failed because of "
1380 "a hardware error\n");
1382 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1384 } /* end dasd_3990_erp_file_prot */
1387 * DASD_3990_ERP_INSPECT_ALIAS
1390 * Checks if the original request was started on an alias device.
1391 * If yes, it modifies the original and the erp request so that
1392 * the erp request can be started on a base device.
1395 * erp pointer to the currently created default ERP
1398 * erp pointer to the modified ERP, or NULL
1401 static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1402 struct dasd_ccw_req *erp)
1404 struct dasd_ccw_req *cqr = erp->refers;
1407 (cqr->block->base != cqr->startdev)) {
1408 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
1409 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
1410 "ERP on alias device for request %p,"
1411 " recover on base device %s", cqr,
1412 dev_name(&cqr->block->base->cdev->dev));
1414 dasd_eckd_reset_ccw_to_base_io(cqr);
1415 erp->startdev = cqr->block->base;
1416 erp->function = dasd_3990_erp_inspect_alias;
1424 * DASD_3990_ERP_INSPECT_24
1427 * Does a detailed inspection of the 24 byte sense data
1428 * and sets up a related error recovery action.
1431 * sense sense data of the actual error
1432 * erp pointer to the currently created default ERP
1435 * erp pointer to the (addtitional) ERP
1437 static struct dasd_ccw_req *
1438 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1441 struct dasd_ccw_req *erp_filled = NULL;
1443 /* Check sense for .... */
1444 /* 'Command Reject' */
1445 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1446 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1448 /* 'Intervention Required' */
1449 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1450 erp_filled = dasd_3990_erp_int_req(erp);
1452 /* 'Bus Out Parity Check' */
1453 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1454 erp_filled = dasd_3990_erp_bus_out(erp);
1456 /* 'Equipment Check' */
1457 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1458 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1461 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1462 erp_filled = dasd_3990_erp_data_check(erp, sense);
1465 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1466 erp_filled = dasd_3990_erp_overrun(erp, sense);
1468 /* 'Invalid Track Format' */
1469 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1470 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1472 /* 'End-of-Cylinder' */
1473 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1474 erp_filled = dasd_3990_erp_EOC(erp, sense);
1476 /* 'Environmental Data' */
1477 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1478 erp_filled = dasd_3990_erp_env_data(erp, sense);
1480 /* 'No Record Found' */
1481 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1482 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1484 /* 'File Protected' */
1485 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1486 erp_filled = dasd_3990_erp_file_prot(erp);
1488 /* other (unknown) error - do default ERP */
1489 if (erp_filled == NULL) {
1496 } /* END dasd_3990_erp_inspect_24 */
1499 *****************************************************************************
1500 * 32 byte sense ERP functions (only)
1501 *****************************************************************************
1505 * DASD_3990_ERPACTION_10_32
1508 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1509 * Just retry and if retry doesn't work, return with error.
1512 * erp current erp_head
1513 * sense current sense data
1515 * erp modified erp_head
1517 static struct dasd_ccw_req *
1518 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1521 struct dasd_device *device = erp->startdev;
1524 erp->function = dasd_3990_erp_action_10_32;
1526 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
1530 } /* end dasd_3990_erp_action_10_32 */
1533 * DASD_3990_ERP_ACTION_1B_32
1536 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1537 * A write operation could not be finished because of an unexpected
1539 * The already created 'default erp' is used to get the link to
1540 * the erp chain, but it can not be used for this recovery
1541 * action because it contains no DE/LO data space.
1544 * default_erp already added default erp.
1545 * sense current sense data
1549 * default_erp in case of imprecise ending or error
1551 static struct dasd_ccw_req *
1552 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1555 struct dasd_device *device = default_erp->startdev;
1557 struct dasd_ccw_req *cqr;
1558 struct dasd_ccw_req *erp;
1559 struct DE_eckd_data *DE_data;
1560 struct PFX_eckd_data *PFX_data;
1561 char *LO_data; /* LO_eckd_data_t */
1562 struct ccw1 *ccw, *oldccw;
1564 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1565 "Write not finished because of unexpected condition");
1567 default_erp->function = dasd_3990_erp_action_1B_32;
1569 /* determine the original cqr */
1572 while (cqr->refers != NULL) {
1576 if (scsw_is_tm(&cqr->irb.scsw)) {
1577 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1578 "32 bit sense, action 1B is not defined"
1579 " in transport mode - just retry");
1583 /* for imprecise ending just do default erp */
1584 if (sense[1] & 0x01) {
1585 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1586 "Imprecise ending is set - just retry");
1591 /* determine the address of the CCW to be restarted */
1592 /* Imprecise ending is not set -> addr from IRB-SCSW */
1593 cpa = default_erp->refers->irb.scsw.cmd.cpa;
1596 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1597 "Unable to determine address of the CCW "
1600 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1603 /* Build new ERP request including DE/LO */
1604 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1605 2 + 1,/* DE/LO + TIC */
1606 sizeof(struct DE_eckd_data) +
1607 sizeof(struct LO_eckd_data), device);
1610 /* internal error 01 - Unable to allocate ERP */
1611 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1612 "device driver, reason=%s\n", "01");
1613 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1616 /* use original DE */
1617 DE_data = erp->data;
1618 oldccw = cqr->cpaddr;
1619 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1620 PFX_data = cqr->data;
1621 memcpy(DE_data, &PFX_data->define_extent,
1622 sizeof(struct DE_eckd_data));
1624 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
1627 LO_data = erp->data + sizeof(struct DE_eckd_data);
1629 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1631 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1634 if ((sense[7] & 0x3F) == 0x01) {
1635 /* operation code is WRITE DATA -> data area orientation */
1638 } else if ((sense[7] & 0x3F) == 0x03) {
1639 /* operation code is FORMAT WRITE -> index orientation */
1643 LO_data[0] = sense[7]; /* operation */
1646 LO_data[1] = sense[8]; /* auxiliary */
1647 LO_data[2] = sense[9];
1648 LO_data[3] = sense[3]; /* count */
1649 LO_data[4] = sense[29]; /* seek_addr.cyl */
1650 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1651 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1653 memcpy(&(LO_data[8]), &(sense[11]), 8);
1657 memset(ccw, 0, sizeof(struct ccw1));
1658 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1659 ccw->flags = CCW_FLAG_CC;
1661 ccw->cda = (__u32)(addr_t) DE_data;
1665 memset(ccw, 0, sizeof(struct ccw1));
1666 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1667 ccw->flags = CCW_FLAG_CC;
1669 ccw->cda = (__u32)(addr_t) LO_data;
1671 /* TIC to the failed ccw */
1673 ccw->cmd_code = CCW_CMD_TIC;
1676 /* fill erp related fields */
1677 erp->function = dasd_3990_erp_action_1B_32;
1678 erp->refers = default_erp->refers;
1679 erp->startdev = device;
1680 erp->memdev = device;
1681 erp->magic = default_erp->magic;
1684 erp->buildclk = get_clock();
1685 erp->status = DASD_CQR_FILLED;
1687 /* remove the default erp */
1688 dasd_free_erp_request(default_erp, device);
1692 } /* end dasd_3990_erp_action_1B_32 */
1695 * DASD_3990_UPDATE_1B
1698 * Handles the update to the 32 byte 'Action 1B' of Single Program
1699 * Action Codes in case the first action was not successful.
1700 * The already created 'previous_erp' is the currently not successful
1704 * previous_erp already created previous erp.
1705 * sense current sense data
1709 static struct dasd_ccw_req *
1710 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1713 struct dasd_device *device = previous_erp->startdev;
1715 struct dasd_ccw_req *cqr;
1716 struct dasd_ccw_req *erp;
1717 char *LO_data; /* struct LO_eckd_data */
1720 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1721 "Write not finished because of unexpected condition"
1724 /* determine the original cqr */
1727 while (cqr->refers != NULL) {
1731 if (scsw_is_tm(&cqr->irb.scsw)) {
1732 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1733 "32 bit sense, action 1B, update,"
1734 " in transport mode - just retry");
1735 return previous_erp;
1738 /* for imprecise ending just do default erp */
1739 if (sense[1] & 0x01) {
1740 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1741 "Imprecise ending is set - just retry");
1743 previous_erp->status = DASD_CQR_FILLED;
1745 return previous_erp;
1748 /* determine the address of the CCW to be restarted */
1749 /* Imprecise ending is not set -> addr from IRB-SCSW */
1750 cpa = previous_erp->irb.scsw.cmd.cpa;
1753 /* internal error 02 -
1754 Unable to determine address of the CCW to be restarted */
1755 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1756 "device driver, reason=%s\n", "02");
1758 previous_erp->status = DASD_CQR_FAILED;
1760 return previous_erp;
1765 /* update the LO with the new returned sense data */
1766 LO_data = erp->data + sizeof(struct DE_eckd_data);
1768 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1769 /* should not happen */
1770 previous_erp->status = DASD_CQR_FAILED;
1772 return previous_erp;
1775 if ((sense[7] & 0x3F) == 0x01) {
1776 /* operation code is WRITE DATA -> data area orientation */
1779 } else if ((sense[7] & 0x3F) == 0x03) {
1780 /* operation code is FORMAT WRITE -> index orientation */
1784 LO_data[0] = sense[7]; /* operation */
1787 LO_data[1] = sense[8]; /* auxiliary */
1788 LO_data[2] = sense[9];
1789 LO_data[3] = sense[3]; /* count */
1790 LO_data[4] = sense[29]; /* seek_addr.cyl */
1791 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1792 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1794 memcpy(&(LO_data[8]), &(sense[11]), 8);
1796 /* TIC to the failed ccw */
1797 ccw = erp->cpaddr; /* addr of DE ccw */
1798 ccw++; /* addr of LE ccw */
1799 ccw++; /* addr of TIC ccw */
1802 erp->status = DASD_CQR_FILLED;
1806 } /* end dasd_3990_update_1B */
1809 * DASD_3990_ERP_COMPOUND_RETRY
1812 * Handles the compound ERP action retry code.
1813 * NOTE: At least one retry is done even if zero is specified
1814 * by the sense data. This makes enqueueing of the request
1818 * sense sense data of the actual error
1819 * erp pointer to the currently created ERP
1822 * erp modified ERP pointer
1826 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1829 switch (sense[25] & 0x03) {
1830 case 0x00: /* no not retry */
1834 case 0x01: /* retry 2 times */
1838 case 0x02: /* retry 10 times */
1842 case 0x03: /* retry 256 times */
1850 erp->function = dasd_3990_erp_compound_retry;
1852 } /* end dasd_3990_erp_compound_retry */
1855 * DASD_3990_ERP_COMPOUND_PATH
1858 * Handles the compound ERP action for retry on alternate
1862 * sense sense data of the actual error
1863 * erp pointer to the currently created ERP
1866 * erp modified ERP pointer
1870 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1873 if (sense[25] & DASD_SENSE_BIT_3) {
1874 dasd_3990_erp_alternate_path(erp);
1876 if (erp->status == DASD_CQR_FAILED) {
1877 /* reset the lpm and the status to be able to
1878 * try further actions. */
1881 erp->status = DASD_CQR_NEED_ERP;
1885 erp->function = dasd_3990_erp_compound_path;
1887 } /* end dasd_3990_erp_compound_path */
1890 * DASD_3990_ERP_COMPOUND_CODE
1893 * Handles the compound ERP action for retry code.
1896 * sense sense data of the actual error
1897 * erp pointer to the currently created ERP
1900 * erp NEW ERP pointer
1903 static struct dasd_ccw_req *
1904 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1907 if (sense[25] & DASD_SENSE_BIT_2) {
1909 switch (sense[28]) {
1911 /* issue a Diagnostic Control command with an
1912 * Inhibit Write subcommand and controller modifier */
1913 erp = dasd_3990_erp_DCTL(erp, 0x20);
1917 /* wait for 5 seconds and retry again */
1920 dasd_3990_erp_block_queue (erp, 5*HZ);
1924 /* should not happen - continue */
1929 erp->function = dasd_3990_erp_compound_code;
1933 } /* end dasd_3990_erp_compound_code */
1936 * DASD_3990_ERP_COMPOUND_CONFIG
1939 * Handles the compound ERP action for configruation
1941 * Note: duplex handling is not implemented (yet).
1944 * sense sense data of the actual error
1945 * erp pointer to the currently created ERP
1948 * erp modified ERP pointer
1952 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
1955 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
1957 /* set to suspended duplex state then restart
1958 internal error 05 - Set device to suspended duplex state
1960 struct dasd_device *device = erp->startdev;
1961 dev_err(&device->cdev->dev,
1962 "An error occurred in the DASD device driver, "
1963 "reason=%s\n", "05");
1967 erp->function = dasd_3990_erp_compound_config;
1969 } /* end dasd_3990_erp_compound_config */
1972 * DASD_3990_ERP_COMPOUND
1975 * Does the further compound program action if
1976 * compound retry was not successful.
1979 * sense sense data of the actual error
1980 * erp pointer to the current (failed) ERP
1983 * erp (additional) ERP pointer
1986 static struct dasd_ccw_req *
1987 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
1990 if ((erp->function == dasd_3990_erp_compound_retry) &&
1991 (erp->status == DASD_CQR_NEED_ERP)) {
1993 dasd_3990_erp_compound_path(erp, sense);
1996 if ((erp->function == dasd_3990_erp_compound_path) &&
1997 (erp->status == DASD_CQR_NEED_ERP)) {
1999 erp = dasd_3990_erp_compound_code(erp, sense);
2002 if ((erp->function == dasd_3990_erp_compound_code) &&
2003 (erp->status == DASD_CQR_NEED_ERP)) {
2005 dasd_3990_erp_compound_config(erp, sense);
2008 /* if no compound action ERP specified, the request failed */
2009 if (erp->status == DASD_CQR_NEED_ERP)
2010 erp->status = DASD_CQR_FAILED;
2014 } /* end dasd_3990_erp_compound */
2017 *DASD_3990_ERP_HANDLE_SIM
2020 * inspects the SIM SENSE data and starts an appropriate action
2023 * sense sense data of the actual error
2029 dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2031 /* print message according to log or message to operator mode */
2032 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
2033 /* print SIM SRC from RefCode */
2034 dev_err(&device->cdev->dev, "SIM - SRC: "
2035 "%02x%02x%02x%02x\n", sense[22],
2036 sense[23], sense[11], sense[12]);
2037 } else if (sense[24] & DASD_SIM_LOG) {
2038 /* print SIM SRC Refcode */
2039 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2040 "%02x%02x%02x%02x\n", sense[22],
2041 sense[23], sense[11], sense[12]);
2046 * DASD_3990_ERP_INSPECT_32
2049 * Does a detailed inspection of the 32 byte sense data
2050 * and sets up a related error recovery action.
2053 * sense sense data of the actual error
2054 * erp pointer to the currently created default ERP
2057 * erp_filled pointer to the ERP
2060 static struct dasd_ccw_req *
2061 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2064 struct dasd_device *device = erp->startdev;
2066 erp->function = dasd_3990_erp_inspect_32;
2068 /* check for SIM sense data */
2069 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2070 dasd_3990_erp_handle_sim(device, sense);
2072 if (sense[25] & DASD_SENSE_BIT_0) {
2074 /* compound program action codes (byte25 bit 0 == '1') */
2075 dasd_3990_erp_compound_retry(erp, sense);
2079 /* single program action codes (byte25 bit 0 == '0') */
2080 switch (sense[25]) {
2082 case 0x00: /* success - use default ERP for retries */
2083 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
2084 "ERP called for successful request"
2088 case 0x01: /* fatal error */
2089 dev_err(&device->cdev->dev,
2090 "ERP failed for the DASD\n");
2092 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2095 case 0x02: /* intervention required */
2096 case 0x03: /* intervention required during dual copy */
2097 erp = dasd_3990_erp_int_req(erp);
2100 case 0x0F: /* length mismatch during update write command
2101 internal error 08 - update write command error*/
2102 dev_err(&device->cdev->dev, "An error occurred in the "
2103 "DASD device driver, reason=%s\n", "08");
2105 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2108 case 0x10: /* logging required for other channel program */
2109 erp = dasd_3990_erp_action_10_32(erp, sense);
2112 case 0x15: /* next track outside defined extend
2113 internal error 07 - The next track is not
2114 within the defined storage extent */
2115 dev_err(&device->cdev->dev,
2116 "An error occurred in the DASD device driver, "
2117 "reason=%s\n", "07");
2119 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2122 case 0x1B: /* unexpected condition during write */
2124 erp = dasd_3990_erp_action_1B_32(erp, sense);
2127 case 0x1C: /* invalid data */
2128 dev_emerg(&device->cdev->dev,
2129 "Data recovered during retry with PCI "
2130 "fetch mode active\n");
2132 /* not possible to handle this situation in Linux */
2134 ("Invalid data - No way to inform application "
2135 "about the possibly incorrect data");
2138 case 0x1D: /* state-change pending */
2139 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2140 "A State change pending condition exists "
2141 "for the subsystem or device");
2143 erp = dasd_3990_erp_action_4(erp, sense);
2146 case 0x1E: /* busy */
2147 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2148 "Busy condition exists "
2149 "for the subsystem or device");
2150 erp = dasd_3990_erp_action_4(erp, sense);
2153 default: /* all others errors - default erp */
2160 } /* end dasd_3990_erp_inspect_32 */
2163 *****************************************************************************
2164 * main ERP control fuctions (24 and 32 byte sense)
2165 *****************************************************************************
2169 * DASD_3990_ERP_CONTROL_CHECK
2172 * Does a generic inspection if a control check occured and sets up
2173 * the related error recovery procedure
2176 * erp pointer to the currently created default ERP
2179 * erp_filled pointer to the erp
2182 static struct dasd_ccw_req *
2183 dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2185 struct dasd_device *device = erp->startdev;
2187 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
2188 | SCHN_STAT_CHN_CTRL_CHK)) {
2189 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2190 "channel or interface control check");
2191 erp = dasd_3990_erp_action_4(erp, NULL);
2197 * DASD_3990_ERP_INSPECT
2200 * Does a detailed inspection for sense data by calling either
2201 * the 24-byte or the 32-byte inspection routine.
2204 * erp pointer to the currently created default ERP
2206 * erp_new contens was possibly modified
2208 static struct dasd_ccw_req *
2209 dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
2212 struct dasd_ccw_req *erp_new = NULL;
2215 /* if this problem occured on an alias retry on base */
2216 erp_new = dasd_3990_erp_inspect_alias(erp);
2220 /* sense data are located in the refers record of the
2221 * already set up new ERP !
2222 * check if concurrent sens is available
2224 sense = dasd_get_sense(&erp->refers->irb);
2226 erp_new = dasd_3990_erp_control_check(erp);
2227 /* distinguish between 24 and 32 byte sense data */
2228 else if (sense[27] & DASD_SENSE_BIT_0) {
2230 /* inspect the 24 byte sense data */
2231 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2235 /* inspect the 32 byte sense data */
2236 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2238 } /* end distinguish between 24 and 32 byte sense data */
2244 * DASD_3990_ERP_ADD_ERP
2247 * This funtion adds an additional request block (ERP) to the head of
2248 * the given cqr (or erp).
2249 * For a command mode cqr the erp is initialized as an default erp
2251 * For transport mode we make a copy of the original TCW (points to
2252 * the original TCCB, TIDALs, etc.) but give it a fresh
2253 * TSB so the original sense data will not be changed.
2256 * cqr head of the current ERP-chain (or single cqr if
2259 * erp pointer to new ERP-chain head
2261 static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
2264 struct dasd_device *device = cqr->startdev;
2266 struct dasd_ccw_req *erp;
2267 int cplength, datasize;
2271 if (cqr->cpmode == 1) {
2273 datasize = sizeof(struct tcw) + sizeof(struct tsb);
2279 /* allocate additional request block */
2280 erp = dasd_alloc_erp_request((char *) &cqr->magic,
2281 cplength, datasize, device);
2283 if (cqr->retries <= 0) {
2284 DBF_DEV_EVENT(DBF_ERR, device, "%s",
2285 "Unable to allocate ERP request");
2286 cqr->status = DASD_CQR_FAILED;
2287 cqr->stopclk = get_clock ();
2289 DBF_DEV_EVENT(DBF_ERR, device,
2290 "Unable to allocate ERP request "
2291 "(%i retries left)",
2293 dasd_block_set_timer(device->block, (HZ << 3));
2298 if (cqr->cpmode == 1) {
2299 /* make a shallow copy of the original tcw but set new tsb */
2301 erp->cpaddr = erp->data;
2303 tsb = (struct tsb *) &tcw[1];
2304 *tcw = *((struct tcw *)cqr->cpaddr);
2305 tcw->tsb = (long)tsb;
2307 /* initialize request with default TIC to current ERP/CQR */
2309 ccw->cmd_code = CCW_CMD_NOOP;
2310 ccw->flags = CCW_FLAG_CC;
2312 ccw->cmd_code = CCW_CMD_TIC;
2313 ccw->cda = (long)(cqr->cpaddr);
2316 erp->function = dasd_3990_erp_add_erp;
2318 erp->startdev = device;
2319 erp->memdev = device;
2320 erp->block = cqr->block;
2321 erp->magic = cqr->magic;
2324 erp->buildclk = get_clock();
2325 erp->status = DASD_CQR_FILLED;
2331 * DASD_3990_ERP_ADDITIONAL_ERP
2334 * An additional ERP is needed to handle the current error.
2335 * Add ERP to the head of the ERP-chain containing the ERP processing
2336 * determined based on the sense data.
2339 * cqr head of the current ERP-chain (or single cqr if
2343 * erp pointer to new ERP-chain head
2345 static struct dasd_ccw_req *
2346 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2349 struct dasd_ccw_req *erp = NULL;
2351 /* add erp and initialize with default TIC */
2352 erp = dasd_3990_erp_add_erp(cqr);
2354 /* inspect sense, determine specific ERP if possible */
2357 erp = dasd_3990_erp_inspect(erp);
2362 } /* end dasd_3990_erp_additional_erp */
2365 * DASD_3990_ERP_ERROR_MATCH
2368 * Check if the device status of the given cqr is the same.
2369 * This means that the failed CCW and the relevant sense data
2371 * I don't distinguish between 24 and 32 byte sense because in case of
2372 * 24 byte sense byte 25 and 27 is set as well.
2375 * cqr1 first cqr, which will be compared with the
2379 * match 'boolean' for match found
2380 * returns 1 if match found, otherwise 0.
2382 static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2383 struct dasd_ccw_req *cqr2)
2385 char *sense1, *sense2;
2387 if (cqr1->startdev != cqr2->startdev)
2390 sense1 = dasd_get_sense(&cqr1->irb);
2391 sense2 = dasd_get_sense(&cqr2->irb);
2393 /* one request has sense data, the other not -> no match, return 0 */
2394 if (!sense1 != !sense2)
2396 /* no sense data in both cases -> check cstat for IFCC */
2397 if (!sense1 && !sense2) {
2398 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2399 SCHN_STAT_CHN_CTRL_CHK)) ==
2400 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2401 SCHN_STAT_CHN_CTRL_CHK)))
2402 return 1; /* match with ifcc*/
2404 /* check sense data; byte 0-2,25,27 */
2405 if (!(sense1 && sense2 &&
2406 (memcmp(sense1, sense2, 3) == 0) &&
2407 (sense1[27] == sense2[27]) &&
2408 (sense1[25] == sense2[25]))) {
2410 return 0; /* sense doesn't match */
2413 return 1; /* match */
2415 } /* end dasd_3990_erp_error_match */
2418 * DASD_3990_ERP_IN_ERP
2421 * check if the current error already happened before.
2422 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2425 * cqr failed cqr (either original cqr or already an erp)
2428 * erp erp-pointer to the already defined error
2429 * recovery procedure OR
2430 * NULL if a 'new' error occurred.
2432 static struct dasd_ccw_req *
2433 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2436 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2437 *erp_match = NULL; /* save erp chain head */
2438 int match = 0; /* 'boolean' for matching error found */
2440 if (cqr->refers == NULL) { /* return if not in erp */
2444 /* check the erp/cqr chain for current error */
2446 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2447 erp_match = cqr; /* save possible matching erp */
2448 cqr = cqr->refers; /* check next erp/cqr in queue */
2450 } while ((cqr->refers != NULL) && (!match));
2453 return NULL; /* no match was found */
2456 return erp_match; /* return address of matching erp */
2458 } /* END dasd_3990_erp_in_erp */
2461 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2464 * No retry is left for the current ERP. Check what has to be done
2466 * - do further defined ERP action or
2467 * - wait for interrupt or
2468 * - exit with permanent error
2471 * erp ERP which is in progress with no retry left
2474 * erp modified/additional ERP
2476 static struct dasd_ccw_req *
2477 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2480 struct dasd_device *device = erp->startdev;
2481 char *sense = dasd_get_sense(&erp->irb);
2483 /* check for 24 byte sense ERP */
2484 if ((erp->function == dasd_3990_erp_bus_out) ||
2485 (erp->function == dasd_3990_erp_action_1) ||
2486 (erp->function == dasd_3990_erp_action_4)) {
2488 erp = dasd_3990_erp_action_1(erp);
2490 } else if (erp->function == dasd_3990_erp_action_5) {
2492 /* retries have not been successful */
2493 /* prepare erp for retry on different channel path */
2494 erp = dasd_3990_erp_action_1(erp);
2496 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
2498 /* issue a Diagnostic Control command with an
2499 * Inhibit Write subcommand */
2501 switch (sense[25]) {
2503 case 0x57:{ /* controller */
2504 erp = dasd_3990_erp_DCTL(erp, 0x20);
2508 case 0x58:{ /* channel path */
2509 erp = dasd_3990_erp_DCTL(erp, 0x40);
2513 case 0x59:{ /* storage director */
2514 erp = dasd_3990_erp_DCTL(erp, 0x80);
2518 DBF_DEV_EVENT(DBF_WARNING, device,
2519 "invalid subcommand modifier 0x%x "
2520 "for Diagnostic Control Command",
2525 /* check for 32 byte sense ERP */
2527 ((erp->function == dasd_3990_erp_compound_retry) ||
2528 (erp->function == dasd_3990_erp_compound_path) ||
2529 (erp->function == dasd_3990_erp_compound_code) ||
2530 (erp->function == dasd_3990_erp_compound_config))) {
2532 erp = dasd_3990_erp_compound(erp, sense);
2536 * No retry left and no additional special handling
2539 dev_err(&device->cdev->dev,
2540 "ERP %p has run out of retries and failed\n", erp);
2542 erp->status = DASD_CQR_FAILED;
2547 } /* end dasd_3990_erp_further_erp */
2550 * DASD_3990_ERP_HANDLE_MATCH_ERP
2553 * An error occurred again and an ERP has been detected which is already
2554 * used to handle this error (e.g. retries).
2555 * All prior ERP's are asumed to be successful and therefore removed
2557 * If retry counter of matching erp is already 0, it is checked if further
2558 * action is needed (besides retry) or if the ERP has failed.
2561 * erp_head first ERP in ERP-chain
2562 * erp ERP that handles the actual error.
2566 * erp modified/additional ERP
2568 static struct dasd_ccw_req *
2569 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2570 struct dasd_ccw_req *erp)
2573 struct dasd_device *device = erp_head->startdev;
2574 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2575 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2577 /* loop over successful ERPs and remove them from chanq */
2578 while (erp_done != erp) {
2580 if (erp_done == NULL) /* end of chain reached */
2581 panic(PRINTK_HEADER "Programming error in ERP! The "
2582 "original request was lost\n");
2584 /* remove the request from the device queue */
2585 list_del(&erp_done->blocklist);
2587 erp_free = erp_done;
2588 erp_done = erp_done->refers;
2590 /* free the finished erp request */
2591 dasd_free_erp_request(erp_free, erp_free->memdev);
2595 if (erp->retries > 0) {
2597 char *sense = dasd_get_sense(&erp->refers->irb);
2599 /* check for special retries */
2600 if (sense && erp->function == dasd_3990_erp_action_4) {
2602 erp = dasd_3990_erp_action_4(erp, sense);
2605 erp->function == dasd_3990_erp_action_1B_32) {
2607 erp = dasd_3990_update_1B(erp, sense);
2609 } else if (sense && erp->function == dasd_3990_erp_int_req) {
2611 erp = dasd_3990_erp_int_req(erp);
2615 DBF_DEV_EVENT(DBF_DEBUG, device,
2616 "%i retries left for erp %p",
2619 /* handle the request again... */
2620 erp->status = DASD_CQR_FILLED;
2624 /* no retry left - check for further necessary action */
2625 /* if no further actions, handle rest as permanent error */
2626 erp = dasd_3990_erp_further_erp(erp);
2631 } /* end dasd_3990_erp_handle_match_erp */
2634 * DASD_3990_ERP_ACTION
2637 * control routine for 3990 erp actions.
2638 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2641 * cqr failed cqr (either original cqr or already an erp)
2644 * erp erp-pointer to the head of the ERP action chain.
2646 * - either a ptr to an additional ERP cqr or
2647 * - the original given cqr (which's status might
2650 struct dasd_ccw_req *
2651 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2653 struct dasd_ccw_req *erp = NULL;
2654 struct dasd_device *device = cqr->startdev;
2655 struct dasd_ccw_req *temp_erp = NULL;
2657 if (device->features & DASD_FEATURE_ERPLOG) {
2658 /* print current erp_chain */
2659 dev_err(&device->cdev->dev,
2660 "ERP chain at BEGINNING of ERP-ACTION\n");
2661 for (temp_erp = cqr;
2662 temp_erp != NULL; temp_erp = temp_erp->refers) {
2664 dev_err(&device->cdev->dev,
2665 "ERP %p (%02x) refers to %p\n",
2666 temp_erp, temp_erp->status,
2671 /* double-check if current erp/cqr was successful */
2672 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2673 (scsw_dstat(&cqr->irb.scsw) ==
2674 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
2676 DBF_DEV_EVENT(DBF_DEBUG, device,
2677 "ERP called for successful request %p"
2678 " - NO ERP necessary", cqr);
2680 cqr->status = DASD_CQR_DONE;
2685 /* check if error happened before */
2686 erp = dasd_3990_erp_in_erp(cqr);
2689 /* no matching erp found - set up erp */
2690 erp = dasd_3990_erp_additional_erp(cqr);
2692 /* matching erp found - set all leading erp's to DONE */
2693 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2696 if (device->features & DASD_FEATURE_ERPLOG) {
2697 /* print current erp_chain */
2698 dev_err(&device->cdev->dev,
2699 "ERP chain at END of ERP-ACTION\n");
2700 for (temp_erp = erp;
2701 temp_erp != NULL; temp_erp = temp_erp->refers) {
2703 dev_err(&device->cdev->dev,
2704 "ERP %p (%02x) refers to %p\n",
2705 temp_erp, temp_erp->status,
2710 /* enqueue ERP request if it's a new one */
2711 if (list_empty(&erp->blocklist)) {
2712 cqr->status = DASD_CQR_IN_ERP;
2713 /* add erp request before the cqr */
2714 list_add_tail(&erp->blocklist, &cqr->blocklist);
2721 } /* end dasd_3990_erp_action */