1 // SPDX-License-Identifier: GPL-2.0
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 * Copyright IBM Corp. 2000, 2001
10 #include <linux/timer.h>
11 #include <asm/idals.h>
14 #include "dasd_eckd.h"
18 unsigned char subcommand
; /* e.g Inhibit Write, Enable Write,... */
19 unsigned char modifier
; /* Subcommand modifier */
20 unsigned short res
; /* reserved */
21 } __attribute__ ((packed
));
24 *****************************************************************************
25 * SECTION ERP HANDLING
26 *****************************************************************************
29 *****************************************************************************
30 * 24 and 32 byte sense ERP functions
31 *****************************************************************************
35 * DASD_3990_ERP_CLEANUP
38 * Removes the already build but not necessary ERP request and sets
39 * the status of the original cqr / erp to the given (final) status
42 * erp request to be blocked
43 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
48 static struct dasd_ccw_req
*
49 dasd_3990_erp_cleanup(struct dasd_ccw_req
* erp
, char final_status
)
51 struct dasd_ccw_req
*cqr
= erp
->refers
;
53 dasd_free_erp_request(erp
, erp
->memdev
);
54 cqr
->status
= final_status
;
57 } /* end dasd_3990_erp_cleanup */
60 * DASD_3990_ERP_BLOCK_QUEUE
63 * Block the given device request queue to prevent from further
64 * processing until the started timer has expired or an related
65 * interrupt was received.
67 static void dasd_3990_erp_block_queue(struct dasd_ccw_req
*erp
, int expires
)
70 struct dasd_device
*device
= erp
->startdev
;
73 DBF_DEV_EVENT(DBF_INFO
, device
,
74 "blocking request queue for %is", expires
/HZ
);
76 spin_lock_irqsave(get_ccwdev_lock(device
->cdev
), flags
);
77 dasd_device_set_stop_bits(device
, DASD_STOPPED_PENDING
);
78 spin_unlock_irqrestore(get_ccwdev_lock(device
->cdev
), flags
);
79 erp
->status
= DASD_CQR_FILLED
;
81 dasd_block_set_timer(erp
->block
, expires
);
83 dasd_device_set_timer(device
, expires
);
87 * DASD_3990_ERP_INT_REQ
90 * Handles 'Intervention Required' error.
91 * This means either device offline or not installed.
98 static struct dasd_ccw_req
*
99 dasd_3990_erp_int_req(struct dasd_ccw_req
* erp
)
102 struct dasd_device
*device
= erp
->startdev
;
104 /* first time set initial retry counter and erp_function */
105 /* and retry once without blocking queue */
106 /* (this enables easier enqueing of the cqr) */
107 if (erp
->function
!= dasd_3990_erp_int_req
) {
110 erp
->function
= dasd_3990_erp_int_req
;
114 /* issue a message and wait for 'device ready' interrupt */
115 dev_err(&device
->cdev
->dev
,
116 "is offline or not installed - "
117 "INTERVENTION REQUIRED!!\n");
119 dasd_3990_erp_block_queue(erp
, 60*HZ
);
124 } /* end dasd_3990_erp_int_req */
127 * DASD_3990_ERP_ALTERNATE_PATH
130 * Repeat the operation on a different channel path.
131 * If all alternate paths have been tried, the request is posted with a
135 * erp pointer to the current ERP
138 * erp modified pointer to the ERP
141 dasd_3990_erp_alternate_path(struct dasd_ccw_req
* erp
)
143 struct dasd_device
*device
= erp
->startdev
;
147 /* try alternate valid path */
148 spin_lock_irqsave(get_ccwdev_lock(device
->cdev
), flags
);
149 opm
= ccw_device_get_path_mask(device
->cdev
);
150 spin_unlock_irqrestore(get_ccwdev_lock(device
->cdev
), flags
);
152 erp
->lpm
= dasd_path_get_opm(device
) &
153 ~(erp
->irb
.esw
.esw0
.sublog
.lpum
);
155 erp
->lpm
&= ~(erp
->irb
.esw
.esw0
.sublog
.lpum
);
157 if ((erp
->lpm
& opm
) != 0x00) {
159 DBF_DEV_EVENT(DBF_WARNING
, device
,
160 "try alternate lpm=%x (lpum=%x / opm=%x)",
161 erp
->lpm
, erp
->irb
.esw
.esw0
.sublog
.lpum
, opm
);
163 /* reset status to submit the request again... */
164 erp
->status
= DASD_CQR_FILLED
;
167 dev_err(&device
->cdev
->dev
,
168 "The DASD cannot be reached on any path (lpum=%x"
169 "/opm=%x)\n", erp
->irb
.esw
.esw0
.sublog
.lpum
, opm
);
171 /* post request with permanent error */
172 erp
->status
= DASD_CQR_FAILED
;
174 } /* end dasd_3990_erp_alternate_path */
180 * Setup cqr to do the Diagnostic Control (DCTL) command with an
181 * Inhibit Write subcommand (0x20) and the given modifier.
184 * erp pointer to the current (failed) ERP
185 * modifier subcommand modifier
188 * dctl_cqr pointer to NEW dctl_cqr
191 static struct dasd_ccw_req
*
192 dasd_3990_erp_DCTL(struct dasd_ccw_req
* erp
, char modifier
)
195 struct dasd_device
*device
= erp
->startdev
;
196 struct DCTL_data
*DCTL_data
;
198 struct dasd_ccw_req
*dctl_cqr
;
200 dctl_cqr
= dasd_alloc_erp_request(erp
->magic
, 1,
201 sizeof(struct DCTL_data
),
203 if (IS_ERR(dctl_cqr
)) {
204 dev_err(&device
->cdev
->dev
,
205 "Unable to allocate DCTL-CQR\n");
206 erp
->status
= DASD_CQR_FAILED
;
210 DCTL_data
= dctl_cqr
->data
;
212 DCTL_data
->subcommand
= 0x02; /* Inhibit Write */
213 DCTL_data
->modifier
= modifier
;
215 ccw
= dctl_cqr
->cpaddr
;
216 memset(ccw
, 0, sizeof(struct ccw1
));
217 ccw
->cmd_code
= CCW_CMD_DCTL
;
219 ccw
->cda
= virt_to_dma32(DCTL_data
);
220 dctl_cqr
->flags
= erp
->flags
;
221 dctl_cqr
->function
= dasd_3990_erp_DCTL
;
222 dctl_cqr
->refers
= erp
;
223 dctl_cqr
->startdev
= device
;
224 dctl_cqr
->memdev
= device
;
225 dctl_cqr
->magic
= erp
->magic
;
226 dctl_cqr
->expires
= 5 * 60 * HZ
;
227 dctl_cqr
->retries
= 2;
229 dctl_cqr
->buildclk
= get_tod_clock();
231 dctl_cqr
->status
= DASD_CQR_FILLED
;
235 } /* end dasd_3990_erp_DCTL */
238 * DASD_3990_ERP_ACTION_1
241 * Setup ERP to do the ERP action 1 (see Reference manual).
242 * Repeat the operation on a different channel path.
243 * As deviation from the recommended recovery action, we reset the path mask
244 * after we have tried each path and go through all paths a second time.
245 * This will cover situations where only one path at a time is actually down,
246 * but all paths fail and recover just with the same sequence and timing as
247 * we try to use them (flapping links).
248 * If all alternate paths have been tried twice, the request is posted with
252 * erp pointer to the current ERP
255 * erp pointer to the ERP
258 static struct dasd_ccw_req
*dasd_3990_erp_action_1_sec(struct dasd_ccw_req
*erp
)
260 erp
->function
= dasd_3990_erp_action_1_sec
;
261 dasd_3990_erp_alternate_path(erp
);
265 static struct dasd_ccw_req
*dasd_3990_erp_action_1(struct dasd_ccw_req
*erp
)
267 erp
->function
= dasd_3990_erp_action_1
;
268 dasd_3990_erp_alternate_path(erp
);
269 if (erp
->status
== DASD_CQR_FAILED
&&
270 !test_bit(DASD_CQR_VERIFY_PATH
, &erp
->flags
)) {
271 erp
->status
= DASD_CQR_FILLED
;
273 erp
->lpm
= dasd_path_get_opm(erp
->startdev
);
274 erp
->function
= dasd_3990_erp_action_1_sec
;
277 } /* end dasd_3990_erp_action_1(b) */
280 * DASD_3990_ERP_ACTION_4
283 * Setup ERP to do the ERP action 4 (see Reference manual).
284 * Set the current request to PENDING to block the CQR queue for that device
285 * until the state change interrupt appears.
286 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
290 * sense sense data of the actual error
291 * erp pointer to the current ERP
294 * erp pointer to the ERP
297 static struct dasd_ccw_req
*
298 dasd_3990_erp_action_4(struct dasd_ccw_req
* erp
, char *sense
)
301 struct dasd_device
*device
= erp
->startdev
;
303 /* first time set initial retry counter and erp_function */
304 /* and retry once without waiting for state change pending */
305 /* interrupt (this enables easier enqueing of the cqr) */
306 if (erp
->function
!= dasd_3990_erp_action_4
) {
308 DBF_DEV_EVENT(DBF_INFO
, device
, "%s",
309 "dasd_3990_erp_action_4: first time retry");
312 erp
->function
= dasd_3990_erp_action_4
;
315 if (sense
&& (sense
[25] == 0x1D)) { /* state change pending */
317 DBF_DEV_EVENT(DBF_INFO
, device
,
318 "waiting for state change pending "
319 "interrupt, %d retries left",
322 dasd_3990_erp_block_queue(erp
, 30*HZ
);
324 } else if (sense
&& (sense
[25] == 0x1E)) { /* busy */
325 DBF_DEV_EVENT(DBF_INFO
, device
,
326 "busy - redriving request later, "
329 dasd_3990_erp_block_queue(erp
, HZ
);
331 /* no state change pending - retry */
332 DBF_DEV_EVENT(DBF_INFO
, device
,
333 "redriving request immediately, "
336 erp
->status
= DASD_CQR_FILLED
;
342 } /* end dasd_3990_erp_action_4 */
345 *****************************************************************************
346 * 24 byte sense ERP functions (only)
347 *****************************************************************************
351 * DASD_3990_ERP_ACTION_5
354 * Setup ERP to do the ERP action 5 (see Reference manual).
355 * NOTE: Further handling is done in xxx_further_erp after the retries.
358 * erp pointer to the current ERP
361 * erp pointer to the ERP
364 static struct dasd_ccw_req
*
365 dasd_3990_erp_action_5(struct dasd_ccw_req
* erp
)
368 /* first of all retry */
370 erp
->function
= dasd_3990_erp_action_5
;
374 } /* end dasd_3990_erp_action_5 */
377 * DASD_3990_HANDLE_ENV_DATA
380 * Handles 24 byte 'Environmental data present'.
381 * Does a analysis of the sense data (message Format)
382 * and prints the error messages.
385 * sense current sense data
391 dasd_3990_handle_env_data(struct dasd_ccw_req
* erp
, char *sense
)
394 struct dasd_device
*device
= erp
->startdev
;
395 char msg_format
= (sense
[7] & 0xF0);
396 char msg_no
= (sense
[7] & 0x0F);
398 switch (msg_format
) {
399 case 0x00: /* Format 0 - Program or System Checks */
401 if (sense
[1] & 0x10) { /* check message to operator bit */
404 case 0x00: /* No Message */
407 dev_warn(&device
->cdev
->dev
,
408 "FORMAT 0 - Invalid Command\n");
411 dev_warn(&device
->cdev
->dev
,
412 "FORMAT 0 - Invalid Command "
416 dev_warn(&device
->cdev
->dev
,
417 "FORMAT 0 - CCW Count less than "
421 dev_warn(&device
->cdev
->dev
,
422 "FORMAT 0 - Invalid Parameter\n");
425 dev_warn(&device
->cdev
->dev
,
426 "FORMAT 0 - Diagnostic of Special"
427 " Command Violates File Mask\n");
430 dev_warn(&device
->cdev
->dev
,
431 "FORMAT 0 - Channel Returned with "
432 "Incorrect retry CCW\n");
435 dev_warn(&device
->cdev
->dev
,
436 "FORMAT 0 - Reset Notification\n");
439 dev_warn(&device
->cdev
->dev
,
440 "FORMAT 0 - Storage Path Restart\n");
443 dev_warn(&device
->cdev
->dev
,
444 "FORMAT 0 - Channel requested "
445 "... %02x\n", sense
[8]);
448 dev_warn(&device
->cdev
->dev
,
449 "FORMAT 0 - Invalid Defective/"
450 "Alternate Track Pointer\n");
453 dev_warn(&device
->cdev
->dev
,
454 "FORMAT 0 - DPS Installation "
458 dev_warn(&device
->cdev
->dev
,
459 "FORMAT 0 - Command Invalid on "
460 "Secondary Address\n");
463 dev_warn(&device
->cdev
->dev
,
464 "FORMAT 0 - Status Not As "
465 "Required: reason %02x\n",
469 dev_warn(&device
->cdev
->dev
,
470 "FORMAT 0 - Reserved\n");
474 case 0x00: /* No Message */
477 dev_warn(&device
->cdev
->dev
,
478 "FORMAT 0 - Device Error "
482 dev_warn(&device
->cdev
->dev
,
483 "FORMAT 0 - Reserved\n");
486 dev_warn(&device
->cdev
->dev
,
487 "FORMAT 0 - Device Fenced - "
488 "device = %02x\n", sense
[4]);
491 dev_warn(&device
->cdev
->dev
,
492 "FORMAT 0 - Data Pinned for "
496 dev_warn(&device
->cdev
->dev
,
497 "FORMAT 0 - Reserved\n");
502 case 0x10: /* Format 1 - Device Equipment Checks */
504 case 0x00: /* No Message */
507 dev_warn(&device
->cdev
->dev
,
508 "FORMAT 1 - Device Status 1 not as "
512 dev_warn(&device
->cdev
->dev
,
513 "FORMAT 1 - Index missing\n");
516 dev_warn(&device
->cdev
->dev
,
517 "FORMAT 1 - Interruption cannot be "
521 dev_warn(&device
->cdev
->dev
,
522 "FORMAT 1 - Device did not respond to "
526 dev_warn(&device
->cdev
->dev
,
527 "FORMAT 1 - Device check-2 error or Set "
528 "Sector is not complete\n");
531 dev_warn(&device
->cdev
->dev
,
532 "FORMAT 1 - Head address does not "
536 dev_warn(&device
->cdev
->dev
,
537 "FORMAT 1 - Device status 1 not valid\n");
540 dev_warn(&device
->cdev
->dev
,
541 "FORMAT 1 - Device not ready\n");
544 dev_warn(&device
->cdev
->dev
,
545 "FORMAT 1 - Track physical address did "
549 dev_warn(&device
->cdev
->dev
,
550 "FORMAT 1 - Missing device address bit\n");
553 dev_warn(&device
->cdev
->dev
,
554 "FORMAT 1 - Drive motor switch is off\n");
557 dev_warn(&device
->cdev
->dev
,
558 "FORMAT 1 - Seek incomplete\n");
561 dev_warn(&device
->cdev
->dev
,
562 "FORMAT 1 - Cylinder address did not "
566 dev_warn(&device
->cdev
->dev
,
567 "FORMAT 1 - Offset active cannot be "
571 dev_warn(&device
->cdev
->dev
,
572 "FORMAT 1 - Reserved\n");
576 case 0x20: /* Format 2 - 3990 Equipment Checks */
579 dev_warn(&device
->cdev
->dev
,
580 "FORMAT 2 - 3990 check-2 error\n");
583 dev_warn(&device
->cdev
->dev
,
584 "FORMAT 2 - Support facility errors\n");
587 dev_warn(&device
->cdev
->dev
,
588 "FORMAT 2 - Microcode detected error "
593 dev_warn(&device
->cdev
->dev
,
594 "FORMAT 2 - Reserved\n");
598 case 0x30: /* Format 3 - 3990 Control Checks */
601 dev_warn(&device
->cdev
->dev
,
602 "FORMAT 3 - Allegiance terminated\n");
605 dev_warn(&device
->cdev
->dev
,
606 "FORMAT 3 - Reserved\n");
610 case 0x40: /* Format 4 - Data Checks */
613 dev_warn(&device
->cdev
->dev
,
614 "FORMAT 4 - Home address area error\n");
617 dev_warn(&device
->cdev
->dev
,
618 "FORMAT 4 - Count area error\n");
621 dev_warn(&device
->cdev
->dev
,
622 "FORMAT 4 - Key area error\n");
625 dev_warn(&device
->cdev
->dev
,
626 "FORMAT 4 - Data area error\n");
629 dev_warn(&device
->cdev
->dev
,
630 "FORMAT 4 - No sync byte in home address "
634 dev_warn(&device
->cdev
->dev
,
635 "FORMAT 4 - No sync byte in count address "
639 dev_warn(&device
->cdev
->dev
,
640 "FORMAT 4 - No sync byte in key area\n");
643 dev_warn(&device
->cdev
->dev
,
644 "FORMAT 4 - No sync byte in data area\n");
647 dev_warn(&device
->cdev
->dev
,
648 "FORMAT 4 - Home address area error; "
652 dev_warn(&device
->cdev
->dev
,
653 "FORMAT 4 - Count area error; offset "
657 dev_warn(&device
->cdev
->dev
,
658 "FORMAT 4 - Key area error; offset "
662 dev_warn(&device
->cdev
->dev
,
663 "FORMAT 4 - Data area error; "
667 dev_warn(&device
->cdev
->dev
,
668 "FORMAT 4 - No sync byte in home "
669 "address area; offset active\n");
672 dev_warn(&device
->cdev
->dev
,
673 "FORMAT 4 - No sync byte in count "
674 "address area; offset active\n");
677 dev_warn(&device
->cdev
->dev
,
678 "FORMAT 4 - No sync byte in key area; "
682 dev_warn(&device
->cdev
->dev
,
683 "FORMAT 4 - No sync byte in data area; "
687 dev_warn(&device
->cdev
->dev
,
688 "FORMAT 4 - Reserved\n");
692 case 0x50: /* Format 5 - Data Check with displacement information */
695 dev_warn(&device
->cdev
->dev
,
696 "FORMAT 5 - Data Check in the "
697 "home address area\n");
700 dev_warn(&device
->cdev
->dev
,
701 "FORMAT 5 - Data Check in the count "
705 dev_warn(&device
->cdev
->dev
,
706 "FORMAT 5 - Data Check in the key area\n");
709 dev_warn(&device
->cdev
->dev
,
710 "FORMAT 5 - Data Check in the data "
714 dev_warn(&device
->cdev
->dev
,
715 "FORMAT 5 - Data Check in the "
716 "home address area; offset active\n");
719 dev_warn(&device
->cdev
->dev
,
720 "FORMAT 5 - Data Check in the count area; "
724 dev_warn(&device
->cdev
->dev
,
725 "FORMAT 5 - Data Check in the key area; "
729 dev_warn(&device
->cdev
->dev
,
730 "FORMAT 5 - Data Check in the data area; "
734 dev_warn(&device
->cdev
->dev
,
735 "FORMAT 5 - Reserved\n");
739 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
742 dev_warn(&device
->cdev
->dev
,
743 "FORMAT 6 - Overrun on channel A\n");
746 dev_warn(&device
->cdev
->dev
,
747 "FORMAT 6 - Overrun on channel B\n");
750 dev_warn(&device
->cdev
->dev
,
751 "FORMAT 6 - Overrun on channel C\n");
754 dev_warn(&device
->cdev
->dev
,
755 "FORMAT 6 - Overrun on channel D\n");
758 dev_warn(&device
->cdev
->dev
,
759 "FORMAT 6 - Overrun on channel E\n");
762 dev_warn(&device
->cdev
->dev
,
763 "FORMAT 6 - Overrun on channel F\n");
766 dev_warn(&device
->cdev
->dev
,
767 "FORMAT 6 - Overrun on channel G\n");
770 dev_warn(&device
->cdev
->dev
,
771 "FORMAT 6 - Overrun on channel H\n");
774 dev_warn(&device
->cdev
->dev
,
775 "FORMAT 6 - Reserved\n");
779 case 0x70: /* Format 7 - Device Connection Control Checks */
782 dev_warn(&device
->cdev
->dev
,
783 "FORMAT 7 - RCC initiated by a connection "
787 dev_warn(&device
->cdev
->dev
,
788 "FORMAT 7 - RCC 1 sequence not "
792 dev_warn(&device
->cdev
->dev
,
793 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
797 dev_warn(&device
->cdev
->dev
,
798 "FORMAT 7 - Invalid tag-in during "
799 "selection sequence\n");
802 dev_warn(&device
->cdev
->dev
,
803 "FORMAT 7 - extra RCC required\n");
806 dev_warn(&device
->cdev
->dev
,
807 "FORMAT 7 - Invalid DCC selection "
808 "response or timeout\n");
811 dev_warn(&device
->cdev
->dev
,
812 "FORMAT 7 - Missing end operation; device "
813 "transfer complete\n");
816 dev_warn(&device
->cdev
->dev
,
817 "FORMAT 7 - Missing end operation; device "
818 "transfer incomplete\n");
821 dev_warn(&device
->cdev
->dev
,
822 "FORMAT 7 - Invalid tag-in for an "
823 "immediate command sequence\n");
826 dev_warn(&device
->cdev
->dev
,
827 "FORMAT 7 - Invalid tag-in for an "
828 "extended command sequence\n");
831 dev_warn(&device
->cdev
->dev
,
832 "FORMAT 7 - 3990 microcode time out when "
833 "stopping selection\n");
836 dev_warn(&device
->cdev
->dev
,
837 "FORMAT 7 - No response to selection "
838 "after a poll interruption\n");
841 dev_warn(&device
->cdev
->dev
,
842 "FORMAT 7 - Permanent path error (DASD "
843 "controller not available)\n");
846 dev_warn(&device
->cdev
->dev
,
847 "FORMAT 7 - DASD controller not available"
848 " on disconnected command chain\n");
851 dev_warn(&device
->cdev
->dev
,
852 "FORMAT 7 - Reserved\n");
856 case 0x80: /* Format 8 - Additional Device Equipment Checks */
858 case 0x00: /* No Message */
860 dev_warn(&device
->cdev
->dev
,
861 "FORMAT 8 - Error correction code "
865 dev_warn(&device
->cdev
->dev
,
866 "FORMAT 8 - Unexpected end operation "
870 dev_warn(&device
->cdev
->dev
,
871 "FORMAT 8 - End operation with transfer "
875 dev_warn(&device
->cdev
->dev
,
876 "FORMAT 8 - End operation with transfer "
880 dev_warn(&device
->cdev
->dev
,
881 "FORMAT 8 - DPS checks after a system "
882 "reset or selective reset\n");
885 dev_warn(&device
->cdev
->dev
,
886 "FORMAT 8 - DPS cannot be filled\n");
889 dev_warn(&device
->cdev
->dev
,
890 "FORMAT 8 - Short busy time-out during "
891 "device selection\n");
894 dev_warn(&device
->cdev
->dev
,
895 "FORMAT 8 - DASD controller failed to "
896 "set or reset the long busy latch\n");
899 dev_warn(&device
->cdev
->dev
,
900 "FORMAT 8 - No interruption from device "
901 "during a command chain\n");
904 dev_warn(&device
->cdev
->dev
,
905 "FORMAT 8 - Reserved\n");
909 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
912 break; /* No Message */
914 dev_warn(&device
->cdev
->dev
,
915 "FORMAT 9 - Device check-2 error\n");
918 dev_warn(&device
->cdev
->dev
,
919 "FORMAT 9 - Head address did not "
923 dev_warn(&device
->cdev
->dev
,
924 "FORMAT 9 - Track physical address did "
925 "not compare while oriented\n");
928 dev_warn(&device
->cdev
->dev
,
929 "FORMAT 9 - Cylinder address did not "
933 dev_warn(&device
->cdev
->dev
,
934 "FORMAT 9 - Reserved\n");
938 case 0xF0: /* Format F - Cache Storage Checks */
941 dev_warn(&device
->cdev
->dev
,
942 "FORMAT F - Operation Terminated\n");
945 dev_warn(&device
->cdev
->dev
,
946 "FORMAT F - Subsystem Processing Error\n");
949 dev_warn(&device
->cdev
->dev
,
950 "FORMAT F - Cache or nonvolatile storage "
951 "equipment failure\n");
954 dev_warn(&device
->cdev
->dev
,
955 "FORMAT F - Caching terminated\n");
958 dev_warn(&device
->cdev
->dev
,
959 "FORMAT F - Cache fast write access not "
963 dev_warn(&device
->cdev
->dev
,
964 "FORMAT F - Track format incorrect\n");
967 dev_warn(&device
->cdev
->dev
,
968 "FORMAT F - Caching reinitiated\n");
971 dev_warn(&device
->cdev
->dev
,
972 "FORMAT F - Nonvolatile storage "
976 dev_warn(&device
->cdev
->dev
,
977 "FORMAT F - Volume is suspended duplex\n");
978 /* call extended error reporting (EER) */
979 dasd_eer_write(device
, erp
->refers
,
980 DASD_EER_PPRCSUSPEND
);
983 dev_warn(&device
->cdev
->dev
,
984 "FORMAT F - Subsystem status cannot be "
988 dev_warn(&device
->cdev
->dev
,
989 "FORMAT F - Caching status reset to "
993 dev_warn(&device
->cdev
->dev
,
994 "FORMAT F - DASD Fast Write inhibited\n");
997 dev_warn(&device
->cdev
->dev
,
998 "FORMAT F - Reserved\n");
1003 dev_err(&device
->cdev
->dev
,
1004 "Unknown message format %02x", msg_format
);
1006 } /* end switch message format */
1008 } /* end dasd_3990_handle_env_data */
1011 * DASD_3990_ERP_COM_REJ
1014 * Handles 24 byte 'Command Reject' error.
1017 * erp current erp_head
1018 * sense current sense data
1021 * erp 'new' erp_head - pointer to new ERP
1023 static struct dasd_ccw_req
*
1024 dasd_3990_erp_com_rej(struct dasd_ccw_req
* erp
, char *sense
)
1027 struct dasd_device
*device
= erp
->startdev
;
1029 erp
->function
= dasd_3990_erp_com_rej
;
1031 /* env data present (ACTION 10 - retry should work) */
1032 if (sense
[2] & SNS2_ENV_DATA_PRESENT
) {
1034 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1035 "Command Reject - environmental data present");
1037 dasd_3990_handle_env_data(erp
, sense
);
1041 } else if (sense
[1] & SNS1_WRITE_INHIBITED
) {
1042 dev_err(&device
->cdev
->dev
, "An I/O request was rejected"
1043 " because writing is inhibited\n");
1044 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
1045 } else if (sense
[7] == SNS7_INVALID_ON_SEC
) {
1046 dev_err(&device
->cdev
->dev
, "An I/O request was rejected on a copy pair secondary device\n");
1047 /* suppress dump of sense data for this error */
1048 set_bit(DASD_CQR_SUPPRESS_CR
, &erp
->refers
->flags
);
1049 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
1051 if (!test_bit(DASD_CQR_SUPPRESS_CR
, &erp
->flags
))
1052 dev_err(&device
->cdev
->dev
,
1053 "An I/O command request was rejected\n");
1055 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
1060 } /* end dasd_3990_erp_com_rej */
1063 * DASD_3990_ERP_BUS_OUT
1066 * Handles 24 byte 'Bus Out Parity Check' error.
1069 * erp current erp_head
1071 * erp new erp_head - pointer to new ERP
1073 static struct dasd_ccw_req
*
1074 dasd_3990_erp_bus_out(struct dasd_ccw_req
* erp
)
1077 struct dasd_device
*device
= erp
->startdev
;
1079 /* first time set initial retry counter and erp_function */
1080 /* and retry once without blocking queue */
1081 /* (this enables easier enqueing of the cqr) */
1082 if (erp
->function
!= dasd_3990_erp_bus_out
) {
1084 erp
->function
= dasd_3990_erp_bus_out
;
1088 /* issue a message and wait for 'device ready' interrupt */
1089 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1090 "bus out parity error or BOPC requested by "
1093 dasd_3990_erp_block_queue(erp
, 60*HZ
);
1099 } /* end dasd_3990_erp_bus_out */
1102 * DASD_3990_ERP_EQUIP_CHECK
1105 * Handles 24 byte 'Equipment Check' error.
1108 * erp current erp_head
1110 * erp new erp_head - pointer to new ERP
1112 static struct dasd_ccw_req
*
1113 dasd_3990_erp_equip_check(struct dasd_ccw_req
* erp
, char *sense
)
1116 struct dasd_device
*device
= erp
->startdev
;
1118 erp
->function
= dasd_3990_erp_equip_check
;
1120 if (sense
[1] & SNS1_WRITE_INHIBITED
) {
1121 dev_err(&device
->cdev
->dev
, "Write inhibited path encountered\n");
1123 erp
= dasd_3990_erp_action_1(erp
);
1125 } else if (sense
[2] & SNS2_ENV_DATA_PRESENT
) {
1127 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1128 "Equipment Check - " "environmental data present");
1130 dasd_3990_handle_env_data(erp
, sense
);
1132 erp
= dasd_3990_erp_action_4(erp
, sense
);
1134 } else if (sense
[1] & SNS1_PERM_ERR
) {
1136 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1137 "Equipment Check - retry exhausted or "
1140 erp
= dasd_3990_erp_action_1(erp
);
1143 /* all other equipment checks - Action 5 */
1144 /* rest is done when retries == 0 */
1145 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1146 "Equipment check or processing error");
1148 erp
= dasd_3990_erp_action_5(erp
);
1152 } /* end dasd_3990_erp_equip_check */
1155 * DASD_3990_ERP_DATA_CHECK
1158 * Handles 24 byte 'Data Check' error.
1161 * erp current erp_head
1163 * erp new erp_head - pointer to new ERP
1165 static struct dasd_ccw_req
*
1166 dasd_3990_erp_data_check(struct dasd_ccw_req
* erp
, char *sense
)
1169 struct dasd_device
*device
= erp
->startdev
;
1171 erp
->function
= dasd_3990_erp_data_check
;
1173 if (sense
[2] & SNS2_CORRECTABLE
) { /* correctable data check */
1175 /* issue message that the data has been corrected */
1176 dev_emerg(&device
->cdev
->dev
,
1177 "Data recovered during retry with PCI "
1178 "fetch mode active\n");
1180 /* not possible to handle this situation in Linux */
1181 panic("No way to inform application about the possibly "
1184 } else if (sense
[2] & SNS2_ENV_DATA_PRESENT
) {
1186 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1187 "Uncorrectable data check recovered secondary "
1188 "addr of duplex pair");
1190 erp
= dasd_3990_erp_action_4(erp
, sense
);
1192 } else if (sense
[1] & SNS1_PERM_ERR
) {
1194 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1195 "Uncorrectable data check with internal "
1198 erp
= dasd_3990_erp_action_1(erp
);
1201 /* all other data checks */
1202 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1203 "Uncorrectable data check with retry count "
1206 erp
= dasd_3990_erp_action_5(erp
);
1211 } /* end dasd_3990_erp_data_check */
1214 * DASD_3990_ERP_OVERRUN
1217 * Handles 24 byte 'Overrun' error.
1220 * erp current erp_head
1222 * erp new erp_head - pointer to new ERP
1224 static struct dasd_ccw_req
*
1225 dasd_3990_erp_overrun(struct dasd_ccw_req
* erp
, char *sense
)
1228 struct dasd_device
*device
= erp
->startdev
;
1230 erp
->function
= dasd_3990_erp_overrun
;
1232 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1233 "Overrun - service overrun or overrun"
1234 " error requested by channel");
1236 erp
= dasd_3990_erp_action_5(erp
);
1240 } /* end dasd_3990_erp_overrun */
1243 * DASD_3990_ERP_INV_FORMAT
1246 * Handles 24 byte 'Invalid Track Format' error.
1249 * erp current erp_head
1251 * erp new erp_head - pointer to new ERP
1253 static struct dasd_ccw_req
*
1254 dasd_3990_erp_inv_format(struct dasd_ccw_req
* erp
, char *sense
)
1257 struct dasd_device
*device
= erp
->startdev
;
1259 erp
->function
= dasd_3990_erp_inv_format
;
1261 if (sense
[2] & SNS2_ENV_DATA_PRESENT
) {
1263 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1264 "Track format error when destaging or "
1267 dasd_3990_handle_env_data(erp
, sense
);
1269 erp
= dasd_3990_erp_action_4(erp
, sense
);
1272 dev_err(&device
->cdev
->dev
, "Track format is not valid\n");
1273 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
1278 } /* end dasd_3990_erp_inv_format */
1284 * Handles 24 byte 'End-of-Cylinder' error.
1287 * erp already added default erp
1289 * erp pointer to original (failed) cqr.
1291 static struct dasd_ccw_req
*
1292 dasd_3990_erp_EOC(struct dasd_ccw_req
* default_erp
, char *sense
)
1295 struct dasd_device
*device
= default_erp
->startdev
;
1297 dev_err(&device
->cdev
->dev
,
1298 "The cylinder data for accessing the DASD is inconsistent\n");
1300 /* implement action 7 - BUG */
1301 return dasd_3990_erp_cleanup(default_erp
, DASD_CQR_FAILED
);
1303 } /* end dasd_3990_erp_EOC */
1306 * DASD_3990_ERP_ENV_DATA
1309 * Handles 24 byte 'Environmental-Data Present' error.
1312 * erp current erp_head
1314 * erp new erp_head - pointer to new ERP
1316 static struct dasd_ccw_req
*
1317 dasd_3990_erp_env_data(struct dasd_ccw_req
* erp
, char *sense
)
1320 struct dasd_device
*device
= erp
->startdev
;
1322 erp
->function
= dasd_3990_erp_env_data
;
1324 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s", "Environmental data present");
1326 dasd_3990_handle_env_data(erp
, sense
);
1328 /* don't retry on disabled interface */
1329 if (sense
[7] != 0x0F) {
1330 erp
= dasd_3990_erp_action_4(erp
, sense
);
1332 erp
->status
= DASD_CQR_FILLED
;
1337 } /* end dasd_3990_erp_env_data */
1340 * DASD_3990_ERP_NO_REC
1343 * Handles 24 byte 'No Record Found' error.
1346 * erp already added default ERP
1349 * erp new erp_head - pointer to new ERP
1351 static struct dasd_ccw_req
*
1352 dasd_3990_erp_no_rec(struct dasd_ccw_req
* default_erp
, char *sense
)
1355 struct dasd_device
*device
= default_erp
->startdev
;
1358 * In some cases the 'No Record Found' error might be expected and
1359 * log messages shouldn't be written then.
1360 * Check if the according suppress bit is set.
1362 if (!test_bit(DASD_CQR_SUPPRESS_NRF
, &default_erp
->flags
))
1363 dev_err(&device
->cdev
->dev
,
1364 "The specified record was not found\n");
1366 return dasd_3990_erp_cleanup(default_erp
, DASD_CQR_FAILED
);
1368 } /* end dasd_3990_erp_no_rec */
1371 * DASD_3990_ERP_FILE_PROT
1374 * Handles 24 byte 'File Protected' error.
1375 * Note: Seek related recovery is not implemented because
1376 * wee don't use the seek command yet.
1379 * erp current erp_head
1381 * erp new erp_head - pointer to new ERP
1383 static struct dasd_ccw_req
*
1384 dasd_3990_erp_file_prot(struct dasd_ccw_req
* erp
)
1387 struct dasd_device
*device
= erp
->startdev
;
1389 dev_err(&device
->cdev
->dev
,
1390 "Accessing the DASD failed because of a hardware error\n");
1392 return dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
1394 } /* end dasd_3990_erp_file_prot */
1397 * DASD_3990_ERP_INSPECT_ALIAS
1400 * Checks if the original request was started on an alias device.
1401 * If yes, it modifies the original and the erp request so that
1402 * the erp request can be started on a base device.
1405 * erp pointer to the currently created default ERP
1408 * erp pointer to the modified ERP, or NULL
1411 static struct dasd_ccw_req
*dasd_3990_erp_inspect_alias(
1412 struct dasd_ccw_req
*erp
)
1414 struct dasd_ccw_req
*cqr
= erp
->refers
;
1418 (cqr
->block
->base
!= cqr
->startdev
)) {
1420 sense
= dasd_get_sense(&erp
->refers
->irb
);
1422 * dynamic pav may have changed base alias mapping
1424 if (!test_bit(DASD_FLAG_OFFLINE
, &cqr
->startdev
->flags
) && sense
1425 && (sense
[0] == 0x10) && (sense
[7] == 0x0F)
1426 && (sense
[8] == 0x67)) {
1428 * remove device from alias handling to prevent new
1429 * requests from being scheduled on the
1430 * wrong alias device
1432 dasd_alias_remove_device(cqr
->startdev
);
1434 /* schedule worker to reload device */
1435 dasd_reload_device(cqr
->startdev
);
1438 if (cqr
->startdev
->features
& DASD_FEATURE_ERPLOG
) {
1439 DBF_DEV_EVENT(DBF_ERR
, cqr
->startdev
,
1440 "ERP on alias device for request %p,"
1441 " recover on base device %s", cqr
,
1442 dev_name(&cqr
->block
->base
->cdev
->dev
));
1444 dasd_eckd_reset_ccw_to_base_io(cqr
);
1445 erp
->startdev
= cqr
->block
->base
;
1446 erp
->function
= dasd_3990_erp_inspect_alias
;
1454 * DASD_3990_ERP_INSPECT_24
1457 * Does a detailed inspection of the 24 byte sense data
1458 * and sets up a related error recovery action.
1461 * sense sense data of the actual error
1462 * erp pointer to the currently created default ERP
1465 * erp pointer to the (addtitional) ERP
1467 static struct dasd_ccw_req
*
1468 dasd_3990_erp_inspect_24(struct dasd_ccw_req
* erp
, char *sense
)
1471 struct dasd_ccw_req
*erp_filled
= NULL
;
1473 /* Check sense for .... */
1474 /* 'Command Reject' */
1475 if ((erp_filled
== NULL
) && (sense
[0] & SNS0_CMD_REJECT
)) {
1476 erp_filled
= dasd_3990_erp_com_rej(erp
, sense
);
1478 /* 'Intervention Required' */
1479 if ((erp_filled
== NULL
) && (sense
[0] & SNS0_INTERVENTION_REQ
)) {
1480 erp_filled
= dasd_3990_erp_int_req(erp
);
1482 /* 'Bus Out Parity Check' */
1483 if ((erp_filled
== NULL
) && (sense
[0] & SNS0_BUS_OUT_CHECK
)) {
1484 erp_filled
= dasd_3990_erp_bus_out(erp
);
1486 /* 'Equipment Check' */
1487 if ((erp_filled
== NULL
) && (sense
[0] & SNS0_EQUIPMENT_CHECK
)) {
1488 erp_filled
= dasd_3990_erp_equip_check(erp
, sense
);
1491 if ((erp_filled
== NULL
) && (sense
[0] & SNS0_DATA_CHECK
)) {
1492 erp_filled
= dasd_3990_erp_data_check(erp
, sense
);
1495 if ((erp_filled
== NULL
) && (sense
[0] & SNS0_OVERRUN
)) {
1496 erp_filled
= dasd_3990_erp_overrun(erp
, sense
);
1498 /* 'Invalid Track Format' */
1499 if ((erp_filled
== NULL
) && (sense
[1] & SNS1_INV_TRACK_FORMAT
)) {
1500 erp_filled
= dasd_3990_erp_inv_format(erp
, sense
);
1502 /* 'End-of-Cylinder' */
1503 if ((erp_filled
== NULL
) && (sense
[1] & SNS1_EOC
)) {
1504 erp_filled
= dasd_3990_erp_EOC(erp
, sense
);
1506 /* 'Environmental Data' */
1507 if ((erp_filled
== NULL
) && (sense
[2] & SNS2_ENV_DATA_PRESENT
)) {
1508 erp_filled
= dasd_3990_erp_env_data(erp
, sense
);
1510 /* 'No Record Found' */
1511 if ((erp_filled
== NULL
) && (sense
[1] & SNS1_NO_REC_FOUND
)) {
1512 erp_filled
= dasd_3990_erp_no_rec(erp
, sense
);
1514 /* 'File Protected' */
1515 if ((erp_filled
== NULL
) && (sense
[1] & SNS1_FILE_PROTECTED
)) {
1516 erp_filled
= dasd_3990_erp_file_prot(erp
);
1518 /* other (unknown) error - do default ERP */
1519 if (erp_filled
== NULL
) {
1526 } /* END dasd_3990_erp_inspect_24 */
1529 *****************************************************************************
1530 * 32 byte sense ERP functions (only)
1531 *****************************************************************************
1535 * DASD_3990_ERPACTION_10_32
1538 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1539 * Just retry and if retry doesn't work, return with error.
1542 * erp current erp_head
1543 * sense current sense data
1545 * erp modified erp_head
1547 static struct dasd_ccw_req
*
1548 dasd_3990_erp_action_10_32(struct dasd_ccw_req
* erp
, char *sense
)
1551 struct dasd_device
*device
= erp
->startdev
;
1554 erp
->function
= dasd_3990_erp_action_10_32
;
1556 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s", "Perform logging requested");
1560 } /* end dasd_3990_erp_action_10_32 */
1563 * DASD_3990_ERP_ACTION_1B_32
1566 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1567 * A write operation could not be finished because of an unexpected
1569 * The already created 'default erp' is used to get the link to
1570 * the erp chain, but it can not be used for this recovery
1571 * action because it contains no DE/LO data space.
1574 * default_erp already added default erp.
1575 * sense current sense data
1579 * default_erp in case of imprecise ending or error
1581 static struct dasd_ccw_req
*
1582 dasd_3990_erp_action_1B_32(struct dasd_ccw_req
* default_erp
, char *sense
)
1585 struct dasd_device
*device
= default_erp
->startdev
;
1587 struct dasd_ccw_req
*cqr
;
1588 struct dasd_ccw_req
*erp
;
1589 struct DE_eckd_data
*DE_data
;
1590 struct PFX_eckd_data
*PFX_data
;
1591 char *LO_data
; /* LO_eckd_data_t */
1592 struct ccw1
*ccw
, *oldccw
;
1594 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1595 "Write not finished because of unexpected condition");
1597 default_erp
->function
= dasd_3990_erp_action_1B_32
;
1599 /* determine the original cqr */
1602 while (cqr
->refers
!= NULL
) {
1606 if (scsw_is_tm(&cqr
->irb
.scsw
)) {
1607 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1608 "32 bit sense, action 1B is not defined"
1609 " in transport mode - just retry");
1613 /* for imprecise ending just do default erp */
1614 if (sense
[1] & 0x01) {
1615 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1616 "Imprecise ending is set - just retry");
1621 /* determine the address of the CCW to be restarted */
1622 /* Imprecise ending is not set -> addr from IRB-SCSW */
1623 cpa
= default_erp
->refers
->irb
.scsw
.cmd
.cpa
;
1626 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1627 "Unable to determine address of the CCW "
1630 return dasd_3990_erp_cleanup(default_erp
, DASD_CQR_FAILED
);
1633 /* Build new ERP request including DE/LO */
1634 erp
= dasd_alloc_erp_request(cqr
->magic
,
1635 2 + 1,/* DE/LO + TIC */
1636 sizeof(struct DE_eckd_data
) +
1637 sizeof(struct LO_eckd_data
), device
);
1640 DBF_DEV_EVENT(DBF_ERR
, device
, "%s",
1641 "Unable to allocate ERP request (1B 32)");
1642 return dasd_3990_erp_cleanup(default_erp
, DASD_CQR_FAILED
);
1645 /* use original DE */
1646 DE_data
= erp
->data
;
1647 oldccw
= cqr
->cpaddr
;
1648 if (oldccw
->cmd_code
== DASD_ECKD_CCW_PFX
) {
1649 PFX_data
= cqr
->data
;
1650 memcpy(DE_data
, &PFX_data
->define_extent
,
1651 sizeof(struct DE_eckd_data
));
1653 memcpy(DE_data
, cqr
->data
, sizeof(struct DE_eckd_data
));
1656 LO_data
= erp
->data
+ sizeof(struct DE_eckd_data
);
1658 if ((sense
[3] == 0x01) && (LO_data
[1] & 0x01)) {
1660 return dasd_3990_erp_cleanup(default_erp
, DASD_CQR_FAILED
);
1663 if ((sense
[7] & 0x3F) == 0x01) {
1664 /* operation code is WRITE DATA -> data area orientation */
1667 } else if ((sense
[7] & 0x3F) == 0x03) {
1668 /* operation code is FORMAT WRITE -> index orientation */
1672 LO_data
[0] = sense
[7]; /* operation */
1675 LO_data
[1] = sense
[8]; /* auxiliary */
1676 LO_data
[2] = sense
[9];
1677 LO_data
[3] = sense
[3]; /* count */
1678 LO_data
[4] = sense
[29]; /* seek_addr.cyl */
1679 LO_data
[5] = sense
[30]; /* seek_addr.cyl 2nd byte */
1680 LO_data
[7] = sense
[31]; /* seek_addr.head 2nd byte */
1682 memcpy(&(LO_data
[8]), &(sense
[11]), 8);
1686 memset(ccw
, 0, sizeof(struct ccw1
));
1687 ccw
->cmd_code
= DASD_ECKD_CCW_DEFINE_EXTENT
;
1688 ccw
->flags
= CCW_FLAG_CC
;
1690 ccw
->cda
= virt_to_dma32(DE_data
);
1694 memset(ccw
, 0, sizeof(struct ccw1
));
1695 ccw
->cmd_code
= DASD_ECKD_CCW_LOCATE_RECORD
;
1696 ccw
->flags
= CCW_FLAG_CC
;
1698 ccw
->cda
= virt_to_dma32(LO_data
);
1700 /* TIC to the failed ccw */
1702 ccw
->cmd_code
= CCW_CMD_TIC
;
1705 /* fill erp related fields */
1706 erp
->flags
= default_erp
->flags
;
1707 erp
->function
= dasd_3990_erp_action_1B_32
;
1708 erp
->refers
= default_erp
->refers
;
1709 erp
->startdev
= device
;
1710 erp
->memdev
= device
;
1711 erp
->magic
= default_erp
->magic
;
1712 erp
->expires
= default_erp
->expires
;
1714 erp
->buildclk
= get_tod_clock();
1715 erp
->status
= DASD_CQR_FILLED
;
1717 /* remove the default erp */
1718 dasd_free_erp_request(default_erp
, device
);
1722 } /* end dasd_3990_erp_action_1B_32 */
1725 * DASD_3990_UPDATE_1B
1728 * Handles the update to the 32 byte 'Action 1B' of Single Program
1729 * Action Codes in case the first action was not successful.
1730 * The already created 'previous_erp' is the currently not successful
1734 * previous_erp already created previous erp.
1735 * sense current sense data
1739 static struct dasd_ccw_req
*
1740 dasd_3990_update_1B(struct dasd_ccw_req
* previous_erp
, char *sense
)
1743 struct dasd_device
*device
= previous_erp
->startdev
;
1745 struct dasd_ccw_req
*cqr
;
1746 struct dasd_ccw_req
*erp
;
1747 char *LO_data
; /* struct LO_eckd_data */
1750 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1751 "Write not finished because of unexpected condition"
1754 /* determine the original cqr */
1757 while (cqr
->refers
!= NULL
) {
1761 if (scsw_is_tm(&cqr
->irb
.scsw
)) {
1762 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1763 "32 bit sense, action 1B, update,"
1764 " in transport mode - just retry");
1765 return previous_erp
;
1768 /* for imprecise ending just do default erp */
1769 if (sense
[1] & 0x01) {
1770 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
1771 "Imprecise ending is set - just retry");
1773 previous_erp
->status
= DASD_CQR_FILLED
;
1775 return previous_erp
;
1778 /* determine the address of the CCW to be restarted */
1779 /* Imprecise ending is not set -> addr from IRB-SCSW */
1780 cpa
= previous_erp
->irb
.scsw
.cmd
.cpa
;
1783 dev_err(&device
->cdev
->dev
,
1784 "Unable to determine address of to be restarted CCW\n");
1786 previous_erp
->status
= DASD_CQR_FAILED
;
1788 return previous_erp
;
1793 /* update the LO with the new returned sense data */
1794 LO_data
= erp
->data
+ sizeof(struct DE_eckd_data
);
1796 if ((sense
[3] == 0x01) && (LO_data
[1] & 0x01)) {
1797 /* should not happen */
1798 previous_erp
->status
= DASD_CQR_FAILED
;
1800 return previous_erp
;
1803 if ((sense
[7] & 0x3F) == 0x01) {
1804 /* operation code is WRITE DATA -> data area orientation */
1807 } else if ((sense
[7] & 0x3F) == 0x03) {
1808 /* operation code is FORMAT WRITE -> index orientation */
1812 LO_data
[0] = sense
[7]; /* operation */
1815 LO_data
[1] = sense
[8]; /* auxiliary */
1816 LO_data
[2] = sense
[9];
1817 LO_data
[3] = sense
[3]; /* count */
1818 LO_data
[4] = sense
[29]; /* seek_addr.cyl */
1819 LO_data
[5] = sense
[30]; /* seek_addr.cyl 2nd byte */
1820 LO_data
[7] = sense
[31]; /* seek_addr.head 2nd byte */
1822 memcpy(&(LO_data
[8]), &(sense
[11]), 8);
1824 /* TIC to the failed ccw */
1825 ccw
= erp
->cpaddr
; /* addr of DE ccw */
1826 ccw
++; /* addr of LE ccw */
1827 ccw
++; /* addr of TIC ccw */
1830 erp
->status
= DASD_CQR_FILLED
;
1834 } /* end dasd_3990_update_1B */
1837 * DASD_3990_ERP_COMPOUND_RETRY
1840 * Handles the compound ERP action retry code.
1841 * NOTE: At least one retry is done even if zero is specified
1842 * by the sense data. This makes enqueueing of the request
1846 * sense sense data of the actual error
1847 * erp pointer to the currently created ERP
1850 * erp modified ERP pointer
1854 dasd_3990_erp_compound_retry(struct dasd_ccw_req
* erp
, char *sense
)
1857 switch (sense
[25] & 0x03) {
1858 case 0x00: /* no not retry */
1862 case 0x01: /* retry 2 times */
1866 case 0x02: /* retry 10 times */
1870 case 0x03: /* retry 256 times */
1878 erp
->function
= dasd_3990_erp_compound_retry
;
1880 } /* end dasd_3990_erp_compound_retry */
1883 * DASD_3990_ERP_COMPOUND_PATH
1886 * Handles the compound ERP action for retry on alternate
1890 * sense sense data of the actual error
1891 * erp pointer to the currently created ERP
1894 * erp modified ERP pointer
1898 dasd_3990_erp_compound_path(struct dasd_ccw_req
* erp
, char *sense
)
1900 if (sense
[25] & DASD_SENSE_BIT_3
) {
1901 dasd_3990_erp_alternate_path(erp
);
1903 if (erp
->status
== DASD_CQR_FAILED
&&
1904 !test_bit(DASD_CQR_VERIFY_PATH
, &erp
->flags
)) {
1905 /* reset the lpm and the status to be able to
1906 * try further actions. */
1907 erp
->lpm
= dasd_path_get_opm(erp
->startdev
);
1908 erp
->status
= DASD_CQR_NEED_ERP
;
1912 erp
->function
= dasd_3990_erp_compound_path
;
1914 } /* end dasd_3990_erp_compound_path */
1917 * DASD_3990_ERP_COMPOUND_CODE
1920 * Handles the compound ERP action for retry code.
1923 * sense sense data of the actual error
1924 * erp pointer to the currently created ERP
1927 * erp NEW ERP pointer
1930 static struct dasd_ccw_req
*
1931 dasd_3990_erp_compound_code(struct dasd_ccw_req
* erp
, char *sense
)
1934 if (sense
[25] & DASD_SENSE_BIT_2
) {
1936 switch (sense
[28]) {
1938 /* issue a Diagnostic Control command with an
1939 * Inhibit Write subcommand and controller modifier */
1940 erp
= dasd_3990_erp_DCTL(erp
, 0x20);
1944 /* wait for 5 seconds and retry again */
1947 dasd_3990_erp_block_queue (erp
, 5*HZ
);
1951 /* should not happen - continue */
1956 erp
->function
= dasd_3990_erp_compound_code
;
1960 } /* end dasd_3990_erp_compound_code */
1963 * DASD_3990_ERP_COMPOUND_CONFIG
1966 * Handles the compound ERP action for configuration
1968 * Note: duplex handling is not implemented (yet).
1971 * sense sense data of the actual error
1972 * erp pointer to the currently created ERP
1975 * erp modified ERP pointer
1979 dasd_3990_erp_compound_config(struct dasd_ccw_req
* erp
, char *sense
)
1982 if ((sense
[25] & DASD_SENSE_BIT_1
) && (sense
[26] & DASD_SENSE_BIT_2
)) {
1983 struct dasd_device
*device
= erp
->startdev
;
1984 dev_err(&device
->cdev
->dev
,
1985 "Compound configuration error occurred\n");
1988 erp
->function
= dasd_3990_erp_compound_config
;
1990 } /* end dasd_3990_erp_compound_config */
1993 * DASD_3990_ERP_COMPOUND
1996 * Does the further compound program action if
1997 * compound retry was not successful.
2000 * sense sense data of the actual error
2001 * erp pointer to the current (failed) ERP
2004 * erp (additional) ERP pointer
2007 static struct dasd_ccw_req
*
2008 dasd_3990_erp_compound(struct dasd_ccw_req
* erp
, char *sense
)
2011 if ((erp
->function
== dasd_3990_erp_compound_retry
) &&
2012 (erp
->status
== DASD_CQR_NEED_ERP
)) {
2014 dasd_3990_erp_compound_path(erp
, sense
);
2017 if ((erp
->function
== dasd_3990_erp_compound_path
) &&
2018 (erp
->status
== DASD_CQR_NEED_ERP
)) {
2020 erp
= dasd_3990_erp_compound_code(erp
, sense
);
2023 if ((erp
->function
== dasd_3990_erp_compound_code
) &&
2024 (erp
->status
== DASD_CQR_NEED_ERP
)) {
2026 dasd_3990_erp_compound_config(erp
, sense
);
2029 /* if no compound action ERP specified, the request failed */
2030 if (erp
->status
== DASD_CQR_NEED_ERP
)
2031 erp
->status
= DASD_CQR_FAILED
;
2035 } /* end dasd_3990_erp_compound */
2038 *DASD_3990_ERP_HANDLE_SIM
2041 * inspects the SIM SENSE data and starts an appropriate action
2044 * sense sense data of the actual error
2050 dasd_3990_erp_handle_sim(struct dasd_device
*device
, char *sense
)
2052 /* print message according to log or message to operator mode */
2053 if ((sense
[24] & DASD_SIM_MSG_TO_OP
) || (sense
[1] & 0x10)) {
2054 /* print SIM SRC from RefCode */
2055 dev_err(&device
->cdev
->dev
, "SIM - SRC: "
2056 "%02x%02x%02x%02x\n", sense
[22],
2057 sense
[23], sense
[11], sense
[12]);
2058 } else if (sense
[24] & DASD_SIM_LOG
) {
2059 /* print SIM SRC Refcode */
2060 dev_warn(&device
->cdev
->dev
, "log SIM - SRC: "
2061 "%02x%02x%02x%02x\n", sense
[22],
2062 sense
[23], sense
[11], sense
[12]);
2067 * DASD_3990_ERP_INSPECT_32
2070 * Does a detailed inspection of the 32 byte sense data
2071 * and sets up a related error recovery action.
2074 * sense sense data of the actual error
2075 * erp pointer to the currently created default ERP
2078 * erp_filled pointer to the ERP
2081 static struct dasd_ccw_req
*
2082 dasd_3990_erp_inspect_32(struct dasd_ccw_req
* erp
, char *sense
)
2085 struct dasd_device
*device
= erp
->startdev
;
2087 erp
->function
= dasd_3990_erp_inspect_32
;
2089 /* check for SIM sense data */
2090 if ((sense
[6] & DASD_SIM_SENSE
) == DASD_SIM_SENSE
)
2091 dasd_3990_erp_handle_sim(device
, sense
);
2093 if (sense
[25] & DASD_SENSE_BIT_0
) {
2095 /* compound program action codes (byte25 bit 0 == '1') */
2096 dasd_3990_erp_compound_retry(erp
, sense
);
2100 /* single program action codes (byte25 bit 0 == '0') */
2101 switch (sense
[25]) {
2103 case 0x00: /* success - use default ERP for retries */
2104 DBF_DEV_EVENT(DBF_DEBUG
, device
, "%s",
2105 "ERP called for successful request"
2109 case 0x01: /* fatal error */
2110 dev_err(&device
->cdev
->dev
,
2111 "ERP failed for the DASD\n");
2113 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
2116 case 0x02: /* intervention required */
2117 case 0x03: /* intervention required during dual copy */
2118 erp
= dasd_3990_erp_int_req(erp
);
2122 dev_err(&device
->cdev
->dev
,
2123 "Update write command error occurred\n");
2125 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
2128 case 0x10: /* logging required for other channel program */
2129 erp
= dasd_3990_erp_action_10_32(erp
, sense
);
2133 dev_err(&device
->cdev
->dev
,
2134 "Track outside defined extent error occurred\n");
2136 erp
= dasd_3990_erp_cleanup(erp
, DASD_CQR_FAILED
);
2139 case 0x1B: /* unexpected condition during write */
2141 erp
= dasd_3990_erp_action_1B_32(erp
, sense
);
2144 case 0x1C: /* invalid data */
2145 dev_emerg(&device
->cdev
->dev
,
2146 "Data recovered during retry with PCI "
2147 "fetch mode active\n");
2149 /* not possible to handle this situation in Linux */
2151 ("Invalid data - No way to inform application "
2152 "about the possibly incorrect data");
2155 case 0x1D: /* state-change pending */
2156 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
2157 "A State change pending condition exists "
2158 "for the subsystem or device");
2160 erp
= dasd_3990_erp_action_4(erp
, sense
);
2163 case 0x1E: /* busy */
2164 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
2165 "Busy condition exists "
2166 "for the subsystem or device");
2167 erp
= dasd_3990_erp_action_4(erp
, sense
);
2170 default: /* all others errors - default erp */
2177 } /* end dasd_3990_erp_inspect_32 */
2179 static void dasd_3990_erp_disable_path(struct dasd_device
*device
, __u8 lpum
)
2181 int pos
= pathmask_to_pos(lpum
);
2183 if (!(device
->features
& DASD_FEATURE_PATH_AUTODISABLE
)) {
2184 dev_err(&device
->cdev
->dev
,
2185 "Path %x.%02x (pathmask %02x) is operational despite excessive IFCCs\n",
2186 device
->path
[pos
].cssid
, device
->path
[pos
].chpid
, lpum
);
2190 /* no remaining path, cannot disable */
2191 if (!(dasd_path_get_opm(device
) & ~lpum
)) {
2192 dev_err(&device
->cdev
->dev
,
2193 "Last path %x.%02x (pathmask %02x) is operational despite excessive IFCCs\n",
2194 device
->path
[pos
].cssid
, device
->path
[pos
].chpid
, lpum
);
2198 dev_err(&device
->cdev
->dev
,
2199 "Path %x.%02x (pathmask %02x) is disabled - IFCC threshold exceeded\n",
2200 device
->path
[pos
].cssid
, device
->path
[pos
].chpid
, lpum
);
2201 dasd_path_remove_opm(device
, lpum
);
2202 dasd_path_add_ifccpm(device
, lpum
);
2205 device
->path
[pos
].errorclk
= 0;
2206 atomic_set(&device
->path
[pos
].error_count
, 0);
2209 static void dasd_3990_erp_account_error(struct dasd_ccw_req
*erp
)
2211 struct dasd_device
*device
= erp
->startdev
;
2212 __u8 lpum
= erp
->refers
->irb
.esw
.esw1
.lpum
;
2213 int pos
= pathmask_to_pos(lpum
);
2216 if (!device
->path_thrhld
)
2219 clk
= get_tod_clock();
2221 * check if the last error is longer ago than the timeout,
2222 * if so reset error state
2224 if ((tod_to_ns(clk
- device
->path
[pos
].errorclk
) / NSEC_PER_SEC
)
2225 >= device
->path_interval
) {
2226 atomic_set(&device
->path
[pos
].error_count
, 0);
2227 device
->path
[pos
].errorclk
= 0;
2229 atomic_inc(&device
->path
[pos
].error_count
);
2230 device
->path
[pos
].errorclk
= clk
;
2231 /* threshold exceeded disable path if possible */
2232 if (atomic_read(&device
->path
[pos
].error_count
) >=
2233 device
->path_thrhld
)
2234 dasd_3990_erp_disable_path(device
, lpum
);
2238 *****************************************************************************
2239 * main ERP control functions (24 and 32 byte sense)
2240 *****************************************************************************
2244 * DASD_3990_ERP_CONTROL_CHECK
2247 * Does a generic inspection if a control check occurred and sets up
2248 * the related error recovery procedure
2251 * erp pointer to the currently created default ERP
2254 * erp_filled pointer to the erp
2257 static struct dasd_ccw_req
*
2258 dasd_3990_erp_control_check(struct dasd_ccw_req
*erp
)
2260 struct dasd_device
*device
= erp
->startdev
;
2262 if (scsw_cstat(&erp
->refers
->irb
.scsw
) & (SCHN_STAT_INTF_CTRL_CHK
2263 | SCHN_STAT_CHN_CTRL_CHK
)) {
2264 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
2265 "channel or interface control check");
2266 dasd_3990_erp_account_error(erp
);
2267 erp
= dasd_3990_erp_action_4(erp
, NULL
);
2273 * DASD_3990_ERP_INSPECT
2276 * Does a detailed inspection for sense data by calling either
2277 * the 24-byte or the 32-byte inspection routine.
2280 * erp pointer to the currently created default ERP
2282 * erp_new contens was possibly modified
2284 static struct dasd_ccw_req
*
2285 dasd_3990_erp_inspect(struct dasd_ccw_req
*erp
)
2288 struct dasd_ccw_req
*erp_new
= NULL
;
2291 /* if this problem occurred on an alias retry on base */
2292 erp_new
= dasd_3990_erp_inspect_alias(erp
);
2296 /* sense data are located in the refers record of the
2297 * already set up new ERP !
2298 * check if concurrent sens is available
2300 sense
= dasd_get_sense(&erp
->refers
->irb
);
2302 erp_new
= dasd_3990_erp_control_check(erp
);
2303 /* distinguish between 24 and 32 byte sense data */
2304 else if (sense
[27] & DASD_SENSE_BIT_0
) {
2306 /* inspect the 24 byte sense data */
2307 erp_new
= dasd_3990_erp_inspect_24(erp
, sense
);
2311 /* inspect the 32 byte sense data */
2312 erp_new
= dasd_3990_erp_inspect_32(erp
, sense
);
2314 } /* end distinguish between 24 and 32 byte sense data */
2320 * DASD_3990_ERP_ADD_ERP
2323 * This function adds an additional request block (ERP) to the head of
2324 * the given cqr (or erp).
2325 * For a command mode cqr the erp is initialized as an default erp
2327 * For transport mode we make a copy of the original TCW (points to
2328 * the original TCCB, TIDALs, etc.) but give it a fresh
2329 * TSB so the original sense data will not be changed.
2332 * cqr head of the current ERP-chain (or single cqr if
2335 * erp pointer to new ERP-chain head
2337 static struct dasd_ccw_req
*dasd_3990_erp_add_erp(struct dasd_ccw_req
*cqr
)
2340 struct dasd_device
*device
= cqr
->startdev
;
2342 struct dasd_ccw_req
*erp
;
2343 int cplength
, datasize
;
2347 if (cqr
->cpmode
== 1) {
2349 /* TCW needs to be 64 byte aligned, so leave enough room */
2350 datasize
= 64 + sizeof(struct tcw
) + sizeof(struct tsb
);
2356 /* allocate additional request block */
2357 erp
= dasd_alloc_erp_request(cqr
->magic
,
2358 cplength
, datasize
, device
);
2360 if (cqr
->retries
<= 0) {
2361 DBF_DEV_EVENT(DBF_ERR
, device
, "%s",
2362 "Unable to allocate ERP request");
2363 cqr
->status
= DASD_CQR_FAILED
;
2364 cqr
->stopclk
= get_tod_clock();
2366 DBF_DEV_EVENT(DBF_ERR
, device
,
2367 "Unable to allocate ERP request "
2368 "(%i retries left)",
2370 dasd_block_set_timer(device
->block
, (HZ
<< 3));
2376 if (cqr
->cpmode
== 1) {
2377 /* make a shallow copy of the original tcw but set new tsb */
2379 erp
->cpaddr
= PTR_ALIGN(erp
->data
, 64);
2381 tsb
= (struct tsb
*) &tcw
[1];
2382 *tcw
= *((struct tcw
*)cqr
->cpaddr
);
2383 tcw
->tsb
= virt_to_dma64(tsb
);
2384 } else if (ccw
->cmd_code
== DASD_ECKD_CCW_PSF
) {
2385 /* PSF cannot be chained from NOOP/TIC */
2386 erp
->cpaddr
= cqr
->cpaddr
;
2388 /* initialize request with default TIC to current ERP/CQR */
2390 ccw
->cmd_code
= CCW_CMD_NOOP
;
2391 ccw
->flags
= CCW_FLAG_CC
;
2393 ccw
->cmd_code
= CCW_CMD_TIC
;
2394 ccw
->cda
= virt_to_dma32(cqr
->cpaddr
);
2397 erp
->flags
= cqr
->flags
;
2398 erp
->function
= dasd_3990_erp_add_erp
;
2400 erp
->startdev
= device
;
2401 erp
->memdev
= device
;
2402 erp
->block
= cqr
->block
;
2403 erp
->magic
= cqr
->magic
;
2404 erp
->expires
= cqr
->expires
;
2405 erp
->retries
= device
->default_retries
;
2406 erp
->buildclk
= get_tod_clock();
2407 erp
->status
= DASD_CQR_FILLED
;
2413 * DASD_3990_ERP_ADDITIONAL_ERP
2416 * An additional ERP is needed to handle the current error.
2417 * Add ERP to the head of the ERP-chain containing the ERP processing
2418 * determined based on the sense data.
2421 * cqr head of the current ERP-chain (or single cqr if
2425 * erp pointer to new ERP-chain head
2427 static struct dasd_ccw_req
*
2428 dasd_3990_erp_additional_erp(struct dasd_ccw_req
* cqr
)
2431 struct dasd_ccw_req
*erp
= NULL
;
2433 /* add erp and initialize with default TIC */
2434 erp
= dasd_3990_erp_add_erp(cqr
);
2439 /* inspect sense, determine specific ERP if possible */
2442 erp
= dasd_3990_erp_inspect(erp
);
2447 } /* end dasd_3990_erp_additional_erp */
2450 * DASD_3990_ERP_ERROR_MATCH
2453 * Check if the device status of the given cqr is the same.
2454 * This means that the failed CCW and the relevant sense data
2456 * I don't distinguish between 24 and 32 byte sense because in case of
2457 * 24 byte sense byte 25 and 27 is set as well.
2460 * cqr1 first cqr, which will be compared with the
2464 * match 'boolean' for match found
2465 * returns 1 if match found, otherwise 0.
2467 static int dasd_3990_erp_error_match(struct dasd_ccw_req
*cqr1
,
2468 struct dasd_ccw_req
*cqr2
)
2470 char *sense1
, *sense2
;
2472 if (cqr1
->startdev
!= cqr2
->startdev
)
2475 sense1
= dasd_get_sense(&cqr1
->irb
);
2476 sense2
= dasd_get_sense(&cqr2
->irb
);
2478 /* one request has sense data, the other not -> no match, return 0 */
2479 if (!sense1
!= !sense2
)
2481 /* no sense data in both cases -> check cstat for IFCC */
2482 if (!sense1
&& !sense2
) {
2483 if ((scsw_cstat(&cqr1
->irb
.scsw
) & (SCHN_STAT_INTF_CTRL_CHK
|
2484 SCHN_STAT_CHN_CTRL_CHK
)) ==
2485 (scsw_cstat(&cqr2
->irb
.scsw
) & (SCHN_STAT_INTF_CTRL_CHK
|
2486 SCHN_STAT_CHN_CTRL_CHK
)))
2487 return 1; /* match with ifcc*/
2489 /* check sense data; byte 0-2,25,27 */
2490 if (!(sense1
&& sense2
&&
2491 (memcmp(sense1
, sense2
, 3) == 0) &&
2492 (sense1
[27] == sense2
[27]) &&
2493 (sense1
[25] == sense2
[25]))) {
2495 return 0; /* sense doesn't match */
2498 return 1; /* match */
2500 } /* end dasd_3990_erp_error_match */
2503 * DASD_3990_ERP_IN_ERP
2506 * check if the current error already happened before.
2507 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2510 * cqr failed cqr (either original cqr or already an erp)
2513 * erp erp-pointer to the already defined error
2514 * recovery procedure OR
2515 * NULL if a 'new' error occurred.
2517 static struct dasd_ccw_req
*
2518 dasd_3990_erp_in_erp(struct dasd_ccw_req
*cqr
)
2521 struct dasd_ccw_req
*erp_head
= cqr
, /* save erp chain head */
2522 *erp_match
= NULL
; /* save erp chain head */
2523 int match
= 0; /* 'boolean' for matching error found */
2525 if (cqr
->refers
== NULL
) { /* return if not in erp */
2529 /* check the erp/cqr chain for current error */
2531 match
= dasd_3990_erp_error_match(erp_head
, cqr
->refers
);
2532 erp_match
= cqr
; /* save possible matching erp */
2533 cqr
= cqr
->refers
; /* check next erp/cqr in queue */
2535 } while ((cqr
->refers
!= NULL
) && (!match
));
2538 return NULL
; /* no match was found */
2541 return erp_match
; /* return address of matching erp */
2543 } /* END dasd_3990_erp_in_erp */
2546 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2549 * No retry is left for the current ERP. Check what has to be done
2551 * - do further defined ERP action or
2552 * - wait for interrupt or
2553 * - exit with permanent error
2556 * erp ERP which is in progress with no retry left
2559 * erp modified/additional ERP
2561 static struct dasd_ccw_req
*
2562 dasd_3990_erp_further_erp(struct dasd_ccw_req
*erp
)
2565 struct dasd_device
*device
= erp
->startdev
;
2566 char *sense
= dasd_get_sense(&erp
->irb
);
2568 /* check for 24 byte sense ERP */
2569 if ((erp
->function
== dasd_3990_erp_bus_out
) ||
2570 (erp
->function
== dasd_3990_erp_action_1
) ||
2571 (erp
->function
== dasd_3990_erp_action_4
)) {
2573 erp
= dasd_3990_erp_action_1(erp
);
2575 } else if (erp
->function
== dasd_3990_erp_action_1_sec
) {
2576 erp
= dasd_3990_erp_action_1_sec(erp
);
2577 } else if (erp
->function
== dasd_3990_erp_action_5
) {
2579 /* retries have not been successful */
2580 /* prepare erp for retry on different channel path */
2581 erp
= dasd_3990_erp_action_1(erp
);
2583 if (sense
&& !(sense
[2] & DASD_SENSE_BIT_0
)) {
2585 /* issue a Diagnostic Control command with an
2586 * Inhibit Write subcommand */
2588 switch (sense
[25]) {
2590 case 0x57:{ /* controller */
2591 erp
= dasd_3990_erp_DCTL(erp
, 0x20);
2595 case 0x58:{ /* channel path */
2596 erp
= dasd_3990_erp_DCTL(erp
, 0x40);
2600 case 0x59:{ /* storage director */
2601 erp
= dasd_3990_erp_DCTL(erp
, 0x80);
2605 DBF_DEV_EVENT(DBF_WARNING
, device
,
2606 "invalid subcommand modifier 0x%x "
2607 "for Diagnostic Control Command",
2612 /* check for 32 byte sense ERP */
2614 ((erp
->function
== dasd_3990_erp_compound_retry
) ||
2615 (erp
->function
== dasd_3990_erp_compound_path
) ||
2616 (erp
->function
== dasd_3990_erp_compound_code
) ||
2617 (erp
->function
== dasd_3990_erp_compound_config
))) {
2619 erp
= dasd_3990_erp_compound(erp
, sense
);
2623 * No retry left and no additional special handling
2626 dev_err(&device
->cdev
->dev
,
2627 "ERP %px has run out of retries and failed\n", erp
);
2629 erp
->status
= DASD_CQR_FAILED
;
2634 } /* end dasd_3990_erp_further_erp */
2637 * DASD_3990_ERP_HANDLE_MATCH_ERP
2640 * An error occurred again and an ERP has been detected which is already
2641 * used to handle this error (e.g. retries).
2642 * All prior ERP's are asumed to be successful and therefore removed
2644 * If retry counter of matching erp is already 0, it is checked if further
2645 * action is needed (besides retry) or if the ERP has failed.
2648 * erp_head first ERP in ERP-chain
2649 * erp ERP that handles the actual error.
2653 * erp modified/additional ERP
2655 static struct dasd_ccw_req
*
2656 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req
*erp_head
,
2657 struct dasd_ccw_req
*erp
)
2660 struct dasd_device
*device
= erp_head
->startdev
;
2661 struct dasd_ccw_req
*erp_done
= erp_head
; /* finished req */
2662 struct dasd_ccw_req
*erp_free
= NULL
; /* req to be freed */
2664 /* loop over successful ERPs and remove them from chanq */
2665 while (erp_done
!= erp
) {
2667 if (erp_done
== NULL
) /* end of chain reached */
2668 panic("Programming error in ERP! The original request was lost\n");
2670 /* remove the request from the device queue */
2671 list_del(&erp_done
->blocklist
);
2673 erp_free
= erp_done
;
2674 erp_done
= erp_done
->refers
;
2676 /* free the finished erp request */
2677 dasd_free_erp_request(erp_free
, erp_free
->memdev
);
2681 if (erp
->retries
> 0) {
2683 char *sense
= dasd_get_sense(&erp
->refers
->irb
);
2685 /* check for special retries */
2686 if (sense
&& erp
->function
== dasd_3990_erp_action_4
) {
2688 erp
= dasd_3990_erp_action_4(erp
, sense
);
2691 erp
->function
== dasd_3990_erp_action_1B_32
) {
2693 erp
= dasd_3990_update_1B(erp
, sense
);
2695 } else if (sense
&& erp
->function
== dasd_3990_erp_int_req
) {
2697 erp
= dasd_3990_erp_int_req(erp
);
2701 DBF_DEV_EVENT(DBF_DEBUG
, device
,
2702 "%i retries left for erp %p",
2705 /* handle the request again... */
2706 erp
->status
= DASD_CQR_FILLED
;
2710 /* no retry left - check for further necessary action */
2711 /* if no further actions, handle rest as permanent error */
2712 erp
= dasd_3990_erp_further_erp(erp
);
2717 } /* end dasd_3990_erp_handle_match_erp */
2720 * DASD_3990_ERP_ACTION
2723 * control routine for 3990 erp actions.
2724 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2727 * cqr failed cqr (either original cqr or already an erp)
2730 * erp erp-pointer to the head of the ERP action chain.
2732 * - either a ptr to an additional ERP cqr or
2733 * - the original given cqr (which's status might
2736 struct dasd_ccw_req
*
2737 dasd_3990_erp_action(struct dasd_ccw_req
* cqr
)
2739 struct dasd_ccw_req
*erp
= NULL
;
2740 struct dasd_device
*device
= cqr
->startdev
;
2741 struct dasd_ccw_req
*temp_erp
= NULL
;
2743 if (device
->features
& DASD_FEATURE_ERPLOG
) {
2744 /* print current erp_chain */
2745 dev_err(&device
->cdev
->dev
,
2746 "ERP chain at BEGINNING of ERP-ACTION\n");
2747 for (temp_erp
= cqr
;
2748 temp_erp
!= NULL
; temp_erp
= temp_erp
->refers
) {
2749 dev_err(&device
->cdev
->dev
,
2750 "ERP %px (%02x) refers to %px\n",
2751 temp_erp
, temp_erp
->status
, temp_erp
->refers
);
2755 /* double-check if current erp/cqr was successful */
2756 if ((scsw_cstat(&cqr
->irb
.scsw
) == 0x00) &&
2757 (scsw_dstat(&cqr
->irb
.scsw
) ==
2758 (DEV_STAT_CHN_END
| DEV_STAT_DEV_END
))) {
2760 DBF_DEV_EVENT(DBF_DEBUG
, device
,
2761 "ERP called for successful request %p"
2762 " - NO ERP necessary", cqr
);
2764 cqr
->status
= DASD_CQR_DONE
;
2769 /* check if error happened before */
2770 erp
= dasd_3990_erp_in_erp(cqr
);
2773 /* no matching erp found - set up erp */
2774 erp
= dasd_3990_erp_additional_erp(cqr
);
2778 /* matching erp found - set all leading erp's to DONE */
2779 erp
= dasd_3990_erp_handle_match_erp(cqr
, erp
);
2784 * For path verification work we need to stick with the path that was
2785 * originally chosen so that the per path configuration data is
2786 * assigned correctly.
2788 if (test_bit(DASD_CQR_VERIFY_PATH
, &erp
->flags
) && cqr
->lpm
) {
2789 erp
->lpm
= cqr
->lpm
;
2792 if (device
->features
& DASD_FEATURE_ERPLOG
) {
2793 /* print current erp_chain */
2794 dev_err(&device
->cdev
->dev
,
2795 "ERP chain at END of ERP-ACTION\n");
2796 for (temp_erp
= erp
;
2797 temp_erp
!= NULL
; temp_erp
= temp_erp
->refers
) {
2798 dev_err(&device
->cdev
->dev
,
2799 "ERP %px (%02x) refers to %px\n",
2800 temp_erp
, temp_erp
->status
, temp_erp
->refers
);
2804 /* enqueue ERP request if it's a new one */
2805 if (list_empty(&erp
->blocklist
)) {
2806 cqr
->status
= DASD_CQR_IN_ERP
;
2807 /* add erp request before the cqr */
2808 list_add_tail(&erp
->blocklist
, &cqr
->blocklist
);
2815 } /* end dasd_3990_erp_action */