[NETFILTER]: Move ip6_masked_addrcmp to include/net/ipv6.h
[linux-2.6/verdex.git] / drivers / s390 / block / dasd_3990_erp.c
blob4ee0f934e325388c779e20c05e32098b55ebe1ce
1 /*
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
8 */
10 #include <linux/timer.h>
11 #include <linux/slab.h>
12 #include <asm/idals.h>
13 #include <asm/todclk.h>
15 #define PRINTK_HEADER "dasd_erp(3990): "
17 #include "dasd_int.h"
18 #include "dasd_eckd.h"
21 struct DCTL_data {
22 unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
23 unsigned char modifier; /* Subcommand modifier */
24 unsigned short res; /* reserved */
25 } __attribute__ ((packed));
28 *****************************************************************************
29 * SECTION ERP EXAMINATION
30 *****************************************************************************
34 * DASD_3990_ERP_EXAMINE_24
36 * DESCRIPTION
37 * Checks only for fatal (unrecoverable) error.
38 * A detailed examination of the sense data is done later outside
39 * the interrupt handler.
41 * Each bit configuration leading to an action code 2 (Exit with
42 * programming error or unusual condition indication)
43 * are handled as fatal errorĀ“s.
45 * All other configurations are handled as recoverable errors.
47 * RETURN VALUES
48 * dasd_era_fatal for all fatal (unrecoverable errors)
49 * dasd_era_recover for all others.
51 static dasd_era_t
52 dasd_3990_erp_examine_24(struct dasd_ccw_req * cqr, char *sense)
55 struct dasd_device *device = cqr->device;
57 /* check for 'Command Reject' */
58 if ((sense[0] & SNS0_CMD_REJECT) &&
59 (!(sense[2] & SNS2_ENV_DATA_PRESENT))) {
61 DEV_MESSAGE(KERN_ERR, device, "%s",
62 "EXAMINE 24: Command Reject detected - "
63 "fatal error");
65 return dasd_era_fatal;
68 /* check for 'Invalid Track Format' */
69 if ((sense[1] & SNS1_INV_TRACK_FORMAT) &&
70 (!(sense[2] & SNS2_ENV_DATA_PRESENT))) {
72 DEV_MESSAGE(KERN_ERR, device, "%s",
73 "EXAMINE 24: Invalid Track Format detected "
74 "- fatal error");
76 return dasd_era_fatal;
79 /* check for 'No Record Found' */
80 if (sense[1] & SNS1_NO_REC_FOUND) {
82 /* FIXME: fatal error ?!? */
83 DEV_MESSAGE(KERN_ERR, device,
84 "EXAMINE 24: No Record Found detected %s",
85 device->state <= DASD_STATE_BASIC ?
86 " " : "- fatal error");
88 return dasd_era_fatal;
91 /* return recoverable for all others */
92 return dasd_era_recover;
93 } /* END dasd_3990_erp_examine_24 */
96 * DASD_3990_ERP_EXAMINE_32
98 * DESCRIPTION
99 * Checks only for fatal/no/recoverable error.
100 * A detailed examination of the sense data is done later outside
101 * the interrupt handler.
103 * RETURN VALUES
104 * dasd_era_none no error
105 * dasd_era_fatal for all fatal (unrecoverable errors)
106 * dasd_era_recover for recoverable others.
108 static dasd_era_t
109 dasd_3990_erp_examine_32(struct dasd_ccw_req * cqr, char *sense)
112 struct dasd_device *device = cqr->device;
114 switch (sense[25]) {
115 case 0x00:
116 return dasd_era_none;
118 case 0x01:
119 DEV_MESSAGE(KERN_ERR, device, "%s", "EXAMINE 32: fatal error");
121 return dasd_era_fatal;
123 default:
125 return dasd_era_recover;
128 } /* end dasd_3990_erp_examine_32 */
131 * DASD_3990_ERP_EXAMINE
133 * DESCRIPTION
134 * Checks only for fatal/no/recover error.
135 * A detailed examination of the sense data is done later outside
136 * the interrupt handler.
138 * The logic is based on the 'IBM 3990 Storage Control Reference' manual
139 * 'Chapter 7. Error Recovery Procedures'.
141 * RETURN VALUES
142 * dasd_era_none no error
143 * dasd_era_fatal for all fatal (unrecoverable errors)
144 * dasd_era_recover for all others.
146 dasd_era_t
147 dasd_3990_erp_examine(struct dasd_ccw_req * cqr, struct irb * irb)
150 char *sense = irb->ecw;
151 dasd_era_t era = dasd_era_recover;
152 struct dasd_device *device = cqr->device;
154 /* check for successful execution first */
155 if (irb->scsw.cstat == 0x00 &&
156 irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END))
157 return dasd_era_none;
159 /* distinguish between 24 and 32 byte sense data */
160 if (sense[27] & DASD_SENSE_BIT_0) {
162 era = dasd_3990_erp_examine_24(cqr, sense);
164 } else {
166 era = dasd_3990_erp_examine_32(cqr, sense);
170 /* log the erp chain if fatal error occurred */
171 if ((era == dasd_era_fatal) && (device->state >= DASD_STATE_READY)) {
172 dasd_log_sense(cqr, irb);
173 dasd_log_ccw(cqr, 0, irb->scsw.cpa);
176 return era;
178 } /* END dasd_3990_erp_examine */
181 *****************************************************************************
182 * SECTION ERP HANDLING
183 *****************************************************************************
186 *****************************************************************************
187 * 24 and 32 byte sense ERP functions
188 *****************************************************************************
192 * DASD_3990_ERP_CLEANUP
194 * DESCRIPTION
195 * Removes the already build but not necessary ERP request and sets
196 * the status of the original cqr / erp to the given (final) status
198 * PARAMETER
199 * erp request to be blocked
200 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
202 * RETURN VALUES
203 * cqr original cqr
205 static struct dasd_ccw_req *
206 dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
208 struct dasd_ccw_req *cqr = erp->refers;
210 dasd_free_erp_request(erp, erp->device);
211 cqr->status = final_status;
212 return cqr;
214 } /* end dasd_3990_erp_cleanup */
217 * DASD_3990_ERP_BLOCK_QUEUE
219 * DESCRIPTION
220 * Block the given device request queue to prevent from further
221 * processing until the started timer has expired or an related
222 * interrupt was received.
224 static void
225 dasd_3990_erp_block_queue(struct dasd_ccw_req * erp, int expires)
228 struct dasd_device *device = erp->device;
230 DEV_MESSAGE(KERN_INFO, device,
231 "blocking request queue for %is", expires/HZ);
233 device->stopped |= DASD_STOPPED_PENDING;
234 erp->status = DASD_CQR_QUEUED;
236 dasd_set_timer(device, expires);
240 * DASD_3990_ERP_INT_REQ
242 * DESCRIPTION
243 * Handles 'Intervention Required' error.
244 * This means either device offline or not installed.
246 * PARAMETER
247 * erp current erp
248 * RETURN VALUES
249 * erp modified erp
251 static struct dasd_ccw_req *
252 dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
255 struct dasd_device *device = erp->device;
257 /* first time set initial retry counter and erp_function */
258 /* and retry once without blocking queue */
259 /* (this enables easier enqueing of the cqr) */
260 if (erp->function != dasd_3990_erp_int_req) {
262 erp->retries = 256;
263 erp->function = dasd_3990_erp_int_req;
265 } else {
267 /* issue a message and wait for 'device ready' interrupt */
268 DEV_MESSAGE(KERN_ERR, device, "%s",
269 "is offline or not installed - "
270 "INTERVENTION REQUIRED!!");
272 dasd_3990_erp_block_queue(erp, 60*HZ);
275 return erp;
277 } /* end dasd_3990_erp_int_req */
280 * DASD_3990_ERP_ALTERNATE_PATH
282 * DESCRIPTION
283 * Repeat the operation on a different channel path.
284 * If all alternate paths have been tried, the request is posted with a
285 * permanent error.
287 * PARAMETER
288 * erp pointer to the current ERP
290 * RETURN VALUES
291 * erp modified pointer to the ERP
293 static void
294 dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
296 struct dasd_device *device = erp->device;
297 __u8 opm;
299 /* try alternate valid path */
300 opm = ccw_device_get_path_mask(device->cdev);
301 //FIXME: start with get_opm ?
302 if (erp->lpm == 0)
303 erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
304 else
305 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
307 if ((erp->lpm & opm) != 0x00) {
309 DEV_MESSAGE(KERN_DEBUG, device,
310 "try alternate lpm=%x (lpum=%x / opm=%x)",
311 erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
313 /* reset status to queued to handle the request again... */
314 if (erp->status > DASD_CQR_QUEUED)
315 erp->status = DASD_CQR_QUEUED;
316 erp->retries = 1;
317 } else {
318 DEV_MESSAGE(KERN_ERR, device,
319 "No alternate channel path left (lpum=%x / "
320 "opm=%x) -> permanent error",
321 erp->irb.esw.esw0.sublog.lpum, opm);
323 /* post request with permanent error */
324 if (erp->status > DASD_CQR_QUEUED)
325 erp->status = DASD_CQR_FAILED;
327 } /* end dasd_3990_erp_alternate_path */
330 * DASD_3990_ERP_DCTL
332 * DESCRIPTION
333 * Setup cqr to do the Diagnostic Control (DCTL) command with an
334 * Inhibit Write subcommand (0x20) and the given modifier.
336 * PARAMETER
337 * erp pointer to the current (failed) ERP
338 * modifier subcommand modifier
340 * RETURN VALUES
341 * dctl_cqr pointer to NEW dctl_cqr
344 static struct dasd_ccw_req *
345 dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
348 struct dasd_device *device = erp->device;
349 struct DCTL_data *DCTL_data;
350 struct ccw1 *ccw;
351 struct dasd_ccw_req *dctl_cqr;
353 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
354 sizeof (struct DCTL_data),
355 erp->device);
356 if (IS_ERR(dctl_cqr)) {
357 DEV_MESSAGE(KERN_ERR, device, "%s",
358 "Unable to allocate DCTL-CQR");
359 erp->status = DASD_CQR_FAILED;
360 return erp;
363 DCTL_data = dctl_cqr->data;
365 DCTL_data->subcommand = 0x02; /* Inhibit Write */
366 DCTL_data->modifier = modifier;
368 ccw = dctl_cqr->cpaddr;
369 memset(ccw, 0, sizeof (struct ccw1));
370 ccw->cmd_code = CCW_CMD_DCTL;
371 ccw->count = 4;
372 ccw->cda = (__u32)(addr_t) DCTL_data;
373 dctl_cqr->function = dasd_3990_erp_DCTL;
374 dctl_cqr->refers = erp;
375 dctl_cqr->device = erp->device;
376 dctl_cqr->magic = erp->magic;
377 dctl_cqr->expires = 5 * 60 * HZ;
378 dctl_cqr->retries = 2;
380 dctl_cqr->buildclk = get_clock();
382 dctl_cqr->status = DASD_CQR_FILLED;
384 return dctl_cqr;
386 } /* end dasd_3990_erp_DCTL */
389 * DASD_3990_ERP_ACTION_1
391 * DESCRIPTION
392 * Setup ERP to do the ERP action 1 (see Reference manual).
393 * Repeat the operation on a different channel path.
394 * If all alternate paths have been tried, the request is posted with a
395 * permanent error.
396 * Note: duplex handling is not implemented (yet).
398 * PARAMETER
399 * erp pointer to the current ERP
401 * RETURN VALUES
402 * erp pointer to the ERP
405 static struct dasd_ccw_req *
406 dasd_3990_erp_action_1(struct dasd_ccw_req * erp)
409 erp->function = dasd_3990_erp_action_1;
411 dasd_3990_erp_alternate_path(erp);
413 return erp;
415 } /* end dasd_3990_erp_action_1 */
418 * DASD_3990_ERP_ACTION_4
420 * DESCRIPTION
421 * Setup ERP to do the ERP action 4 (see Reference manual).
422 * Set the current request to PENDING to block the CQR queue for that device
423 * until the state change interrupt appears.
424 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
425 * missing.
427 * PARAMETER
428 * sense sense data of the actual error
429 * erp pointer to the current ERP
431 * RETURN VALUES
432 * erp pointer to the ERP
435 static struct dasd_ccw_req *
436 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
439 struct dasd_device *device = erp->device;
441 /* first time set initial retry counter and erp_function */
442 /* and retry once without waiting for state change pending */
443 /* interrupt (this enables easier enqueing of the cqr) */
444 if (erp->function != dasd_3990_erp_action_4) {
446 DEV_MESSAGE(KERN_INFO, device, "%s",
447 "dasd_3990_erp_action_4: first time retry");
449 erp->retries = 256;
450 erp->function = dasd_3990_erp_action_4;
452 } else {
454 if (sense[25] == 0x1D) { /* state change pending */
456 DEV_MESSAGE(KERN_INFO, device,
457 "waiting for state change pending "
458 "interrupt, %d retries left",
459 erp->retries);
461 dasd_3990_erp_block_queue(erp, 30*HZ);
463 } else if (sense[25] == 0x1E) { /* busy */
464 DEV_MESSAGE(KERN_INFO, device,
465 "busy - redriving request later, "
466 "%d retries left",
467 erp->retries);
468 dasd_3990_erp_block_queue(erp, HZ);
469 } else {
471 /* no state change pending - retry */
472 DEV_MESSAGE (KERN_INFO, device,
473 "redriving request immediately, "
474 "%d retries left",
475 erp->retries);
476 erp->status = DASD_CQR_QUEUED;
480 return erp;
482 } /* end dasd_3990_erp_action_4 */
485 *****************************************************************************
486 * 24 byte sense ERP functions (only)
487 *****************************************************************************
491 * DASD_3990_ERP_ACTION_5
493 * DESCRIPTION
494 * Setup ERP to do the ERP action 5 (see Reference manual).
495 * NOTE: Further handling is done in xxx_further_erp after the retries.
497 * PARAMETER
498 * erp pointer to the current ERP
500 * RETURN VALUES
501 * erp pointer to the ERP
504 static struct dasd_ccw_req *
505 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
508 /* first of all retry */
509 erp->retries = 10;
510 erp->function = dasd_3990_erp_action_5;
512 return erp;
514 } /* end dasd_3990_erp_action_5 */
517 * DASD_3990_HANDLE_ENV_DATA
519 * DESCRIPTION
520 * Handles 24 byte 'Environmental data present'.
521 * Does a analysis of the sense data (message Format)
522 * and prints the error messages.
524 * PARAMETER
525 * sense current sense data
527 * RETURN VALUES
528 * void
530 static void
531 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
534 struct dasd_device *device = erp->device;
535 char msg_format = (sense[7] & 0xF0);
536 char msg_no = (sense[7] & 0x0F);
538 switch (msg_format) {
539 case 0x00: /* Format 0 - Program or System Checks */
541 if (sense[1] & 0x10) { /* check message to operator bit */
543 switch (msg_no) {
544 case 0x00: /* No Message */
545 break;
546 case 0x01:
547 DEV_MESSAGE(KERN_WARNING, device, "%s",
548 "FORMAT 0 - Invalid Command");
549 break;
550 case 0x02:
551 DEV_MESSAGE(KERN_WARNING, device, "%s",
552 "FORMAT 0 - Invalid Command "
553 "Sequence");
554 break;
555 case 0x03:
556 DEV_MESSAGE(KERN_WARNING, device, "%s",
557 "FORMAT 0 - CCW Count less than "
558 "required");
559 break;
560 case 0x04:
561 DEV_MESSAGE(KERN_WARNING, device, "%s",
562 "FORMAT 0 - Invalid Parameter");
563 break;
564 case 0x05:
565 DEV_MESSAGE(KERN_WARNING, device, "%s",
566 "FORMAT 0 - Diagnostic of Sepecial"
567 " Command Violates File Mask");
568 break;
569 case 0x07:
570 DEV_MESSAGE(KERN_WARNING, device, "%s",
571 "FORMAT 0 - Channel Returned with "
572 "Incorrect retry CCW");
573 break;
574 case 0x08:
575 DEV_MESSAGE(KERN_WARNING, device, "%s",
576 "FORMAT 0 - Reset Notification");
577 break;
578 case 0x09:
579 DEV_MESSAGE(KERN_WARNING, device, "%s",
580 "FORMAT 0 - Storage Path Restart");
581 break;
582 case 0x0A:
583 DEV_MESSAGE(KERN_WARNING, device,
584 "FORMAT 0 - Channel requested "
585 "... %02x", sense[8]);
586 break;
587 case 0x0B:
588 DEV_MESSAGE(KERN_WARNING, device, "%s",
589 "FORMAT 0 - Invalid Defective/"
590 "Alternate Track Pointer");
591 break;
592 case 0x0C:
593 DEV_MESSAGE(KERN_WARNING, device, "%s",
594 "FORMAT 0 - DPS Installation "
595 "Check");
596 break;
597 case 0x0E:
598 DEV_MESSAGE(KERN_WARNING, device, "%s",
599 "FORMAT 0 - Command Invalid on "
600 "Secondary Address");
601 break;
602 case 0x0F:
603 DEV_MESSAGE(KERN_WARNING, device,
604 "FORMAT 0 - Status Not As "
605 "Required: reason %02x", sense[8]);
606 break;
607 default:
608 DEV_MESSAGE(KERN_WARNING, device, "%s",
609 "FORMAT 0 - Reseved");
611 } else {
612 switch (msg_no) {
613 case 0x00: /* No Message */
614 break;
615 case 0x01:
616 DEV_MESSAGE(KERN_WARNING, device, "%s",
617 "FORMAT 0 - Device Error Source");
618 break;
619 case 0x02:
620 DEV_MESSAGE(KERN_WARNING, device, "%s",
621 "FORMAT 0 - Reserved");
622 break;
623 case 0x03:
624 DEV_MESSAGE(KERN_WARNING, device,
625 "FORMAT 0 - Device Fenced - "
626 "device = %02x", sense[4]);
627 break;
628 case 0x04:
629 DEV_MESSAGE(KERN_WARNING, device, "%s",
630 "FORMAT 0 - Data Pinned for "
631 "Device");
632 break;
633 default:
634 DEV_MESSAGE(KERN_WARNING, device, "%s",
635 "FORMAT 0 - Reserved");
638 break;
640 case 0x10: /* Format 1 - Device Equipment Checks */
641 switch (msg_no) {
642 case 0x00: /* No Message */
643 break;
644 case 0x01:
645 DEV_MESSAGE(KERN_WARNING, device, "%s",
646 "FORMAT 1 - Device Status 1 not as "
647 "expected");
648 break;
649 case 0x03:
650 DEV_MESSAGE(KERN_WARNING, device, "%s",
651 "FORMAT 1 - Index missing");
652 break;
653 case 0x04:
654 DEV_MESSAGE(KERN_WARNING, device, "%s",
655 "FORMAT 1 - Interruption cannot be reset");
656 break;
657 case 0x05:
658 DEV_MESSAGE(KERN_WARNING, device, "%s",
659 "FORMAT 1 - Device did not respond to "
660 "selection");
661 break;
662 case 0x06:
663 DEV_MESSAGE(KERN_WARNING, device, "%s",
664 "FORMAT 1 - Device check-2 error or Set "
665 "Sector is not complete");
666 break;
667 case 0x07:
668 DEV_MESSAGE(KERN_WARNING, device, "%s",
669 "FORMAT 1 - Head address does not "
670 "compare");
671 break;
672 case 0x08:
673 DEV_MESSAGE(KERN_WARNING, device, "%s",
674 "FORMAT 1 - Device status 1 not valid");
675 break;
676 case 0x09:
677 DEV_MESSAGE(KERN_WARNING, device, "%s",
678 "FORMAT 1 - Device not ready");
679 break;
680 case 0x0A:
681 DEV_MESSAGE(KERN_WARNING, device, "%s",
682 "FORMAT 1 - Track physical address did "
683 "not compare");
684 break;
685 case 0x0B:
686 DEV_MESSAGE(KERN_WARNING, device, "%s",
687 "FORMAT 1 - Missing device address bit");
688 break;
689 case 0x0C:
690 DEV_MESSAGE(KERN_WARNING, device, "%s",
691 "FORMAT 1 - Drive motor switch is off");
692 break;
693 case 0x0D:
694 DEV_MESSAGE(KERN_WARNING, device, "%s",
695 "FORMAT 1 - Seek incomplete");
696 break;
697 case 0x0E:
698 DEV_MESSAGE(KERN_WARNING, device, "%s",
699 "FORMAT 1 - Cylinder address did not "
700 "compare");
701 break;
702 case 0x0F:
703 DEV_MESSAGE(KERN_WARNING, device, "%s",
704 "FORMAT 1 - Offset active cannot be "
705 "reset");
706 break;
707 default:
708 DEV_MESSAGE(KERN_WARNING, device, "%s",
709 "FORMAT 1 - Reserved");
711 break;
713 case 0x20: /* Format 2 - 3990 Equipment Checks */
714 switch (msg_no) {
715 case 0x08:
716 DEV_MESSAGE(KERN_WARNING, device, "%s",
717 "FORMAT 2 - 3990 check-2 error");
718 break;
719 case 0x0E:
720 DEV_MESSAGE(KERN_WARNING, device, "%s",
721 "FORMAT 2 - Support facility errors");
722 break;
723 case 0x0F:
724 DEV_MESSAGE(KERN_WARNING, device,
725 "FORMAT 2 - Microcode detected error %02x",
726 sense[8]);
727 break;
728 default:
729 DEV_MESSAGE(KERN_WARNING, device, "%s",
730 "FORMAT 2 - Reserved");
732 break;
734 case 0x30: /* Format 3 - 3990 Control Checks */
735 switch (msg_no) {
736 case 0x0F:
737 DEV_MESSAGE(KERN_WARNING, device, "%s",
738 "FORMAT 3 - Allegiance terminated");
739 break;
740 default:
741 DEV_MESSAGE(KERN_WARNING, device, "%s",
742 "FORMAT 3 - Reserved");
744 break;
746 case 0x40: /* Format 4 - Data Checks */
747 switch (msg_no) {
748 case 0x00:
749 DEV_MESSAGE(KERN_WARNING, device, "%s",
750 "FORMAT 4 - Home address area error");
751 break;
752 case 0x01:
753 DEV_MESSAGE(KERN_WARNING, device, "%s",
754 "FORMAT 4 - Count area error");
755 break;
756 case 0x02:
757 DEV_MESSAGE(KERN_WARNING, device, "%s",
758 "FORMAT 4 - Key area error");
759 break;
760 case 0x03:
761 DEV_MESSAGE(KERN_WARNING, device, "%s",
762 "FORMAT 4 - Data area error");
763 break;
764 case 0x04:
765 DEV_MESSAGE(KERN_WARNING, device, "%s",
766 "FORMAT 4 - No sync byte in home address "
767 "area");
768 break;
769 case 0x05:
770 DEV_MESSAGE(KERN_WARNING, device, "%s",
771 "FORMAT 4 - No sync byte in count address "
772 "area");
773 break;
774 case 0x06:
775 DEV_MESSAGE(KERN_WARNING, device, "%s",
776 "FORMAT 4 - No sync byte in key area");
777 break;
778 case 0x07:
779 DEV_MESSAGE(KERN_WARNING, device, "%s",
780 "FORMAT 4 - No sync byte in data area");
781 break;
782 case 0x08:
783 DEV_MESSAGE(KERN_WARNING, device, "%s",
784 "FORMAT 4 - Home address area error; "
785 "offset active");
786 break;
787 case 0x09:
788 DEV_MESSAGE(KERN_WARNING, device, "%s",
789 "FORMAT 4 - Count area error; offset "
790 "active");
791 break;
792 case 0x0A:
793 DEV_MESSAGE(KERN_WARNING, device, "%s",
794 "FORMAT 4 - Key area error; offset "
795 "active");
796 break;
797 case 0x0B:
798 DEV_MESSAGE(KERN_WARNING, device, "%s",
799 "FORMAT 4 - Data area error; "
800 "offset active");
801 break;
802 case 0x0C:
803 DEV_MESSAGE(KERN_WARNING, device, "%s",
804 "FORMAT 4 - No sync byte in home "
805 "address area; offset active");
806 break;
807 case 0x0D:
808 DEV_MESSAGE(KERN_WARNING, device, "%s",
809 "FORMAT 4 - No syn byte in count "
810 "address area; offset active");
811 break;
812 case 0x0E:
813 DEV_MESSAGE(KERN_WARNING, device, "%s",
814 "FORMAT 4 - No sync byte in key area; "
815 "offset active");
816 break;
817 case 0x0F:
818 DEV_MESSAGE(KERN_WARNING, device, "%s",
819 "FORMAT 4 - No syn byte in data area; "
820 "offset active");
821 break;
822 default:
823 DEV_MESSAGE(KERN_WARNING, device, "%s",
824 "FORMAT 4 - Reserved");
826 break;
828 case 0x50: /* Format 5 - Data Check with displacement information */
829 switch (msg_no) {
830 case 0x00:
831 DEV_MESSAGE(KERN_WARNING, device, "%s",
832 "FORMAT 5 - Data Check in the "
833 "home address area");
834 break;
835 case 0x01:
836 DEV_MESSAGE(KERN_WARNING, device, "%s",
837 "FORMAT 5 - Data Check in the count area");
838 break;
839 case 0x02:
840 DEV_MESSAGE(KERN_WARNING, device, "%s",
841 "FORMAT 5 - Data Check in the key area");
842 break;
843 case 0x03:
844 DEV_MESSAGE(KERN_WARNING, device, "%s",
845 "FORMAT 5 - Data Check in the data area");
846 break;
847 case 0x08:
848 DEV_MESSAGE(KERN_WARNING, device, "%s",
849 "FORMAT 5 - Data Check in the "
850 "home address area; offset active");
851 break;
852 case 0x09:
853 DEV_MESSAGE(KERN_WARNING, device, "%s",
854 "FORMAT 5 - Data Check in the count area; "
855 "offset active");
856 break;
857 case 0x0A:
858 DEV_MESSAGE(KERN_WARNING, device, "%s",
859 "FORMAT 5 - Data Check in the key area; "
860 "offset active");
861 break;
862 case 0x0B:
863 DEV_MESSAGE(KERN_WARNING, device, "%s",
864 "FORMAT 5 - Data Check in the data area; "
865 "offset active");
866 break;
867 default:
868 DEV_MESSAGE(KERN_WARNING, device, "%s",
869 "FORMAT 5 - Reserved");
871 break;
873 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
874 switch (msg_no) {
875 case 0x00:
876 DEV_MESSAGE(KERN_WARNING, device, "%s",
877 "FORMAT 6 - Overrun on channel A");
878 break;
879 case 0x01:
880 DEV_MESSAGE(KERN_WARNING, device, "%s",
881 "FORMAT 6 - Overrun on channel B");
882 break;
883 case 0x02:
884 DEV_MESSAGE(KERN_WARNING, device, "%s",
885 "FORMAT 6 - Overrun on channel C");
886 break;
887 case 0x03:
888 DEV_MESSAGE(KERN_WARNING, device, "%s",
889 "FORMAT 6 - Overrun on channel D");
890 break;
891 case 0x04:
892 DEV_MESSAGE(KERN_WARNING, device, "%s",
893 "FORMAT 6 - Overrun on channel E");
894 break;
895 case 0x05:
896 DEV_MESSAGE(KERN_WARNING, device, "%s",
897 "FORMAT 6 - Overrun on channel F");
898 break;
899 case 0x06:
900 DEV_MESSAGE(KERN_WARNING, device, "%s",
901 "FORMAT 6 - Overrun on channel G");
902 break;
903 case 0x07:
904 DEV_MESSAGE(KERN_WARNING, device, "%s",
905 "FORMAT 6 - Overrun on channel H");
906 break;
907 default:
908 DEV_MESSAGE(KERN_WARNING, device, "%s",
909 "FORMAT 6 - Reserved");
911 break;
913 case 0x70: /* Format 7 - Device Connection Control Checks */
914 switch (msg_no) {
915 case 0x00:
916 DEV_MESSAGE(KERN_WARNING, device, "%s",
917 "FORMAT 7 - RCC initiated by a connection "
918 "check alert");
919 break;
920 case 0x01:
921 DEV_MESSAGE(KERN_WARNING, device, "%s",
922 "FORMAT 7 - RCC 1 sequence not "
923 "successful");
924 break;
925 case 0x02:
926 DEV_MESSAGE(KERN_WARNING, device, "%s",
927 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
928 "successful");
929 break;
930 case 0x03:
931 DEV_MESSAGE(KERN_WARNING, device, "%s",
932 "FORMAT 7 - Invalid tag-in during "
933 "selection sequence");
934 break;
935 case 0x04:
936 DEV_MESSAGE(KERN_WARNING, device, "%s",
937 "FORMAT 7 - extra RCC required");
938 break;
939 case 0x05:
940 DEV_MESSAGE(KERN_WARNING, device, "%s",
941 "FORMAT 7 - Invalid DCC selection "
942 "response or timeout");
943 break;
944 case 0x06:
945 DEV_MESSAGE(KERN_WARNING, device, "%s",
946 "FORMAT 7 - Missing end operation; device "
947 "transfer complete");
948 break;
949 case 0x07:
950 DEV_MESSAGE(KERN_WARNING, device, "%s",
951 "FORMAT 7 - Missing end operation; device "
952 "transfer incomplete");
953 break;
954 case 0x08:
955 DEV_MESSAGE(KERN_WARNING, device, "%s",
956 "FORMAT 7 - Invalid tag-in for an "
957 "immediate command sequence");
958 break;
959 case 0x09:
960 DEV_MESSAGE(KERN_WARNING, device, "%s",
961 "FORMAT 7 - Invalid tag-in for an "
962 "extended command sequence");
963 break;
964 case 0x0A:
965 DEV_MESSAGE(KERN_WARNING, device, "%s",
966 "FORMAT 7 - 3990 microcode time out when "
967 "stopping selection");
968 break;
969 case 0x0B:
970 DEV_MESSAGE(KERN_WARNING, device, "%s",
971 "FORMAT 7 - No response to selection "
972 "after a poll interruption");
973 break;
974 case 0x0C:
975 DEV_MESSAGE(KERN_WARNING, device, "%s",
976 "FORMAT 7 - Permanent path error (DASD "
977 "controller not available)");
978 break;
979 case 0x0D:
980 DEV_MESSAGE(KERN_WARNING, device, "%s",
981 "FORMAT 7 - DASD controller not available"
982 " on disconnected command chain");
983 break;
984 default:
985 DEV_MESSAGE(KERN_WARNING, device, "%s",
986 "FORMAT 7 - Reserved");
988 break;
990 case 0x80: /* Format 8 - Additional Device Equipment Checks */
991 switch (msg_no) {
992 case 0x00: /* No Message */
993 case 0x01:
994 DEV_MESSAGE(KERN_WARNING, device, "%s",
995 "FORMAT 8 - Error correction code "
996 "hardware fault");
997 break;
998 case 0x03:
999 DEV_MESSAGE(KERN_WARNING, device, "%s",
1000 "FORMAT 8 - Unexpected end operation "
1001 "response code");
1002 break;
1003 case 0x04:
1004 DEV_MESSAGE(KERN_WARNING, device, "%s",
1005 "FORMAT 8 - End operation with transfer "
1006 "count not zero");
1007 break;
1008 case 0x05:
1009 DEV_MESSAGE(KERN_WARNING, device, "%s",
1010 "FORMAT 8 - End operation with transfer "
1011 "count zero");
1012 break;
1013 case 0x06:
1014 DEV_MESSAGE(KERN_WARNING, device, "%s",
1015 "FORMAT 8 - DPS checks after a system "
1016 "reset or selective reset");
1017 break;
1018 case 0x07:
1019 DEV_MESSAGE(KERN_WARNING, device, "%s",
1020 "FORMAT 8 - DPS cannot be filled");
1021 break;
1022 case 0x08:
1023 DEV_MESSAGE(KERN_WARNING, device, "%s",
1024 "FORMAT 8 - Short busy time-out during "
1025 "device selection");
1026 break;
1027 case 0x09:
1028 DEV_MESSAGE(KERN_WARNING, device, "%s",
1029 "FORMAT 8 - DASD controller failed to "
1030 "set or reset the long busy latch");
1031 break;
1032 case 0x0A:
1033 DEV_MESSAGE(KERN_WARNING, device, "%s",
1034 "FORMAT 8 - No interruption from device "
1035 "during a command chain");
1036 break;
1037 default:
1038 DEV_MESSAGE(KERN_WARNING, device, "%s",
1039 "FORMAT 8 - Reserved");
1041 break;
1043 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
1044 switch (msg_no) {
1045 case 0x00:
1046 break; /* No Message */
1047 case 0x06:
1048 DEV_MESSAGE(KERN_WARNING, device, "%s",
1049 "FORMAT 9 - Device check-2 error");
1050 break;
1051 case 0x07:
1052 DEV_MESSAGE(KERN_WARNING, device, "%s",
1053 "FORMAT 9 - Head address did not compare");
1054 break;
1055 case 0x0A:
1056 DEV_MESSAGE(KERN_WARNING, device, "%s",
1057 "FORMAT 9 - Track physical address did "
1058 "not compare while oriented");
1059 break;
1060 case 0x0E:
1061 DEV_MESSAGE(KERN_WARNING, device, "%s",
1062 "FORMAT 9 - Cylinder address did not "
1063 "compare");
1064 break;
1065 default:
1066 DEV_MESSAGE(KERN_WARNING, device, "%s",
1067 "FORMAT 9 - Reserved");
1069 break;
1071 case 0xF0: /* Format F - Cache Storage Checks */
1072 switch (msg_no) {
1073 case 0x00:
1074 DEV_MESSAGE(KERN_WARNING, device, "%s",
1075 "FORMAT F - Operation Terminated");
1076 break;
1077 case 0x01:
1078 DEV_MESSAGE(KERN_WARNING, device, "%s",
1079 "FORMAT F - Subsystem Processing Error");
1080 break;
1081 case 0x02:
1082 DEV_MESSAGE(KERN_WARNING, device, "%s",
1083 "FORMAT F - Cache or nonvolatile storage "
1084 "equipment failure");
1085 break;
1086 case 0x04:
1087 DEV_MESSAGE(KERN_WARNING, device, "%s",
1088 "FORMAT F - Caching terminated");
1089 break;
1090 case 0x06:
1091 DEV_MESSAGE(KERN_WARNING, device, "%s",
1092 "FORMAT F - Cache fast write access not "
1093 "authorized");
1094 break;
1095 case 0x07:
1096 DEV_MESSAGE(KERN_WARNING, device, "%s",
1097 "FORMAT F - Track format incorrect");
1098 break;
1099 case 0x09:
1100 DEV_MESSAGE(KERN_WARNING, device, "%s",
1101 "FORMAT F - Caching reinitiated");
1102 break;
1103 case 0x0A:
1104 DEV_MESSAGE(KERN_WARNING, device, "%s",
1105 "FORMAT F - Nonvolatile storage "
1106 "terminated");
1107 break;
1108 case 0x0B:
1109 DEV_MESSAGE(KERN_WARNING, device, "%s",
1110 "FORMAT F - Volume is suspended duplex");
1111 break;
1112 case 0x0C:
1113 DEV_MESSAGE(KERN_WARNING, device, "%s",
1114 "FORMAT F - Subsystem status connot be "
1115 "determined");
1116 break;
1117 case 0x0D:
1118 DEV_MESSAGE(KERN_WARNING, device, "%s",
1119 "FORMAT F - Caching status reset to "
1120 "default");
1121 break;
1122 case 0x0E:
1123 DEV_MESSAGE(KERN_WARNING, device, "%s",
1124 "FORMAT F - DASD Fast Write inhibited");
1125 break;
1126 default:
1127 DEV_MESSAGE(KERN_WARNING, device, "%s",
1128 "FORMAT D - Reserved");
1130 break;
1132 default: /* unknown message format - should not happen */
1133 DEV_MESSAGE (KERN_WARNING, device,
1134 "unknown message format %02x",
1135 msg_format);
1136 break;
1137 } /* end switch message format */
1139 } /* end dasd_3990_handle_env_data */
1142 * DASD_3990_ERP_COM_REJ
1144 * DESCRIPTION
1145 * Handles 24 byte 'Command Reject' error.
1147 * PARAMETER
1148 * erp current erp_head
1149 * sense current sense data
1151 * RETURN VALUES
1152 * erp 'new' erp_head - pointer to new ERP
1154 static struct dasd_ccw_req *
1155 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1158 struct dasd_device *device = erp->device;
1160 erp->function = dasd_3990_erp_com_rej;
1162 /* env data present (ACTION 10 - retry should work) */
1163 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1165 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1166 "Command Reject - environmental data present");
1168 dasd_3990_handle_env_data(erp, sense);
1170 erp->retries = 5;
1172 } else {
1173 /* fatal error - set status to FAILED */
1174 DEV_MESSAGE(KERN_ERR, device, "%s",
1175 "Command Reject - Fatal error");
1177 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1180 return erp;
1182 } /* end dasd_3990_erp_com_rej */
1185 * DASD_3990_ERP_BUS_OUT
1187 * DESCRIPTION
1188 * Handles 24 byte 'Bus Out Parity Check' error.
1190 * PARAMETER
1191 * erp current erp_head
1192 * RETURN VALUES
1193 * erp new erp_head - pointer to new ERP
1195 static struct dasd_ccw_req *
1196 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1199 struct dasd_device *device = erp->device;
1201 /* first time set initial retry counter and erp_function */
1202 /* and retry once without blocking queue */
1203 /* (this enables easier enqueing of the cqr) */
1204 if (erp->function != dasd_3990_erp_bus_out) {
1205 erp->retries = 256;
1206 erp->function = dasd_3990_erp_bus_out;
1208 } else {
1210 /* issue a message and wait for 'device ready' interrupt */
1211 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1212 "bus out parity error or BOPC requested by "
1213 "channel");
1215 dasd_3990_erp_block_queue(erp, 60*HZ);
1219 return erp;
1221 } /* end dasd_3990_erp_bus_out */
1224 * DASD_3990_ERP_EQUIP_CHECK
1226 * DESCRIPTION
1227 * Handles 24 byte 'Equipment Check' error.
1229 * PARAMETER
1230 * erp current erp_head
1231 * RETURN VALUES
1232 * erp new erp_head - pointer to new ERP
1234 static struct dasd_ccw_req *
1235 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1238 struct dasd_device *device = erp->device;
1240 erp->function = dasd_3990_erp_equip_check;
1242 if (sense[1] & SNS1_WRITE_INHIBITED) {
1244 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1245 "Write inhibited path encountered");
1247 /* vary path offline */
1248 DEV_MESSAGE(KERN_ERR, device, "%s",
1249 "Path should be varied off-line. "
1250 "This is not implemented yet \n - please report "
1251 "to linux390@de.ibm.com");
1253 erp = dasd_3990_erp_action_1(erp);
1255 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1257 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1258 "Equipment Check - " "environmental data present");
1260 dasd_3990_handle_env_data(erp, sense);
1262 erp = dasd_3990_erp_action_4(erp, sense);
1264 } else if (sense[1] & SNS1_PERM_ERR) {
1266 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1267 "Equipment Check - retry exhausted or "
1268 "undesirable");
1270 erp = dasd_3990_erp_action_1(erp);
1272 } else {
1273 /* all other equipment checks - Action 5 */
1274 /* rest is done when retries == 0 */
1275 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1276 "Equipment check or processing error");
1278 erp = dasd_3990_erp_action_5(erp);
1281 return erp;
1283 } /* end dasd_3990_erp_equip_check */
1286 * DASD_3990_ERP_DATA_CHECK
1288 * DESCRIPTION
1289 * Handles 24 byte 'Data Check' error.
1291 * PARAMETER
1292 * erp current erp_head
1293 * RETURN VALUES
1294 * erp new erp_head - pointer to new ERP
1296 static struct dasd_ccw_req *
1297 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1300 struct dasd_device *device = erp->device;
1302 erp->function = dasd_3990_erp_data_check;
1304 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1306 /* issue message that the data has been corrected */
1307 DEV_MESSAGE(KERN_EMERG, device, "%s",
1308 "Data recovered during retry with PCI "
1309 "fetch mode active");
1311 /* not possible to handle this situation in Linux */
1312 panic("No way to inform application about the possibly "
1313 "incorrect data");
1315 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1317 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1318 "Uncorrectable data check recovered secondary "
1319 "addr of duplex pair");
1321 erp = dasd_3990_erp_action_4(erp, sense);
1323 } else if (sense[1] & SNS1_PERM_ERR) {
1325 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1326 "Uncorrectable data check with internal "
1327 "retry exhausted");
1329 erp = dasd_3990_erp_action_1(erp);
1331 } else {
1332 /* all other data checks */
1333 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1334 "Uncorrectable data check with retry count "
1335 "exhausted...");
1337 erp = dasd_3990_erp_action_5(erp);
1340 return erp;
1342 } /* end dasd_3990_erp_data_check */
1345 * DASD_3990_ERP_OVERRUN
1347 * DESCRIPTION
1348 * Handles 24 byte 'Overrun' error.
1350 * PARAMETER
1351 * erp current erp_head
1352 * RETURN VALUES
1353 * erp new erp_head - pointer to new ERP
1355 static struct dasd_ccw_req *
1356 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1359 struct dasd_device *device = erp->device;
1361 erp->function = dasd_3990_erp_overrun;
1363 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1364 "Overrun - service overrun or overrun"
1365 " error requested by channel");
1367 erp = dasd_3990_erp_action_5(erp);
1369 return erp;
1371 } /* end dasd_3990_erp_overrun */
1374 * DASD_3990_ERP_INV_FORMAT
1376 * DESCRIPTION
1377 * Handles 24 byte 'Invalid Track Format' error.
1379 * PARAMETER
1380 * erp current erp_head
1381 * RETURN VALUES
1382 * erp new erp_head - pointer to new ERP
1384 static struct dasd_ccw_req *
1385 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1388 struct dasd_device *device = erp->device;
1390 erp->function = dasd_3990_erp_inv_format;
1392 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1394 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1395 "Track format error when destaging or "
1396 "staging data");
1398 dasd_3990_handle_env_data(erp, sense);
1400 erp = dasd_3990_erp_action_4(erp, sense);
1402 } else {
1403 DEV_MESSAGE(KERN_ERR, device, "%s",
1404 "Invalid Track Format - Fatal error should have "
1405 "been handled within the interrupt handler");
1407 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1410 return erp;
1412 } /* end dasd_3990_erp_inv_format */
1415 * DASD_3990_ERP_EOC
1417 * DESCRIPTION
1418 * Handles 24 byte 'End-of-Cylinder' error.
1420 * PARAMETER
1421 * erp already added default erp
1422 * RETURN VALUES
1423 * erp pointer to original (failed) cqr.
1425 static struct dasd_ccw_req *
1426 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1429 struct dasd_device *device = default_erp->device;
1431 DEV_MESSAGE(KERN_ERR, device, "%s",
1432 "End-of-Cylinder - must never happen");
1434 /* implement action 7 - BUG */
1435 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1437 } /* end dasd_3990_erp_EOC */
1440 * DASD_3990_ERP_ENV_DATA
1442 * DESCRIPTION
1443 * Handles 24 byte 'Environmental-Data Present' error.
1445 * PARAMETER
1446 * erp current erp_head
1447 * RETURN VALUES
1448 * erp new erp_head - pointer to new ERP
1450 static struct dasd_ccw_req *
1451 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1454 struct dasd_device *device = erp->device;
1456 erp->function = dasd_3990_erp_env_data;
1458 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Environmental data present");
1460 dasd_3990_handle_env_data(erp, sense);
1462 /* don't retry on disabled interface */
1463 if (sense[7] != 0x0F) {
1465 erp = dasd_3990_erp_action_4(erp, sense);
1466 } else {
1468 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_IN_IO);
1471 return erp;
1473 } /* end dasd_3990_erp_env_data */
1476 * DASD_3990_ERP_NO_REC
1478 * DESCRIPTION
1479 * Handles 24 byte 'No Record Found' error.
1481 * PARAMETER
1482 * erp already added default ERP
1484 * RETURN VALUES
1485 * erp new erp_head - pointer to new ERP
1487 static struct dasd_ccw_req *
1488 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1491 struct dasd_device *device = default_erp->device;
1493 DEV_MESSAGE(KERN_ERR, device, "%s",
1494 "No Record Found - Fatal error should "
1495 "have been handled within the interrupt handler");
1497 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1499 } /* end dasd_3990_erp_no_rec */
1502 * DASD_3990_ERP_FILE_PROT
1504 * DESCRIPTION
1505 * Handles 24 byte 'File Protected' error.
1506 * Note: Seek related recovery is not implemented because
1507 * wee don't use the seek command yet.
1509 * PARAMETER
1510 * erp current erp_head
1511 * RETURN VALUES
1512 * erp new erp_head - pointer to new ERP
1514 static struct dasd_ccw_req *
1515 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1518 struct dasd_device *device = erp->device;
1520 DEV_MESSAGE(KERN_ERR, device, "%s", "File Protected");
1522 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1524 } /* end dasd_3990_erp_file_prot */
1527 * DASD_3990_ERP_INSPECT_24
1529 * DESCRIPTION
1530 * Does a detailed inspection of the 24 byte sense data
1531 * and sets up a related error recovery action.
1533 * PARAMETER
1534 * sense sense data of the actual error
1535 * erp pointer to the currently created default ERP
1537 * RETURN VALUES
1538 * erp pointer to the (addtitional) ERP
1540 static struct dasd_ccw_req *
1541 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1544 struct dasd_ccw_req *erp_filled = NULL;
1546 /* Check sense for .... */
1547 /* 'Command Reject' */
1548 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1549 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1551 /* 'Intervention Required' */
1552 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1553 erp_filled = dasd_3990_erp_int_req(erp);
1555 /* 'Bus Out Parity Check' */
1556 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1557 erp_filled = dasd_3990_erp_bus_out(erp);
1559 /* 'Equipment Check' */
1560 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1561 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1563 /* 'Data Check' */
1564 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1565 erp_filled = dasd_3990_erp_data_check(erp, sense);
1567 /* 'Overrun' */
1568 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1569 erp_filled = dasd_3990_erp_overrun(erp, sense);
1571 /* 'Invalid Track Format' */
1572 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1573 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1575 /* 'End-of-Cylinder' */
1576 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1577 erp_filled = dasd_3990_erp_EOC(erp, sense);
1579 /* 'Environmental Data' */
1580 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1581 erp_filled = dasd_3990_erp_env_data(erp, sense);
1583 /* 'No Record Found' */
1584 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1585 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1587 /* 'File Protected' */
1588 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1589 erp_filled = dasd_3990_erp_file_prot(erp);
1591 /* other (unknown) error - do default ERP */
1592 if (erp_filled == NULL) {
1594 erp_filled = erp;
1597 return erp_filled;
1599 } /* END dasd_3990_erp_inspect_24 */
1602 *****************************************************************************
1603 * 32 byte sense ERP functions (only)
1604 *****************************************************************************
1608 * DASD_3990_ERPACTION_10_32
1610 * DESCRIPTION
1611 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1612 * Just retry and if retry doesn't work, return with error.
1614 * PARAMETER
1615 * erp current erp_head
1616 * sense current sense data
1617 * RETURN VALUES
1618 * erp modified erp_head
1620 static struct dasd_ccw_req *
1621 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1624 struct dasd_device *device = erp->device;
1626 erp->retries = 256;
1627 erp->function = dasd_3990_erp_action_10_32;
1629 DEV_MESSAGE(KERN_DEBUG, device, "%s", "Perform logging requested");
1631 return erp;
1633 } /* end dasd_3990_erp_action_10_32 */
1636 * DASD_3990_ERP_ACTION_1B_32
1638 * DESCRIPTION
1639 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1640 * A write operation could not be finished because of an unexpected
1641 * condition.
1642 * The already created 'default erp' is used to get the link to
1643 * the erp chain, but it can not be used for this recovery
1644 * action because it contains no DE/LO data space.
1646 * PARAMETER
1647 * default_erp already added default erp.
1648 * sense current sense data
1650 * RETURN VALUES
1651 * erp new erp or
1652 * default_erp in case of imprecise ending or error
1654 static struct dasd_ccw_req *
1655 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1658 struct dasd_device *device = default_erp->device;
1659 __u32 cpa = 0;
1660 struct dasd_ccw_req *cqr;
1661 struct dasd_ccw_req *erp;
1662 struct DE_eckd_data *DE_data;
1663 char *LO_data; /* LO_eckd_data_t */
1664 struct ccw1 *ccw;
1666 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1667 "Write not finished because of unexpected condition");
1669 default_erp->function = dasd_3990_erp_action_1B_32;
1671 /* determine the original cqr */
1672 cqr = default_erp;
1674 while (cqr->refers != NULL) {
1675 cqr = cqr->refers;
1678 /* for imprecise ending just do default erp */
1679 if (sense[1] & 0x01) {
1681 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1682 "Imprecise ending is set - just retry");
1684 return default_erp;
1687 /* determine the address of the CCW to be restarted */
1688 /* Imprecise ending is not set -> addr from IRB-SCSW */
1689 cpa = default_erp->refers->irb.scsw.cpa;
1691 if (cpa == 0) {
1693 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1694 "Unable to determine address of the CCW "
1695 "to be restarted");
1697 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1700 /* Build new ERP request including DE/LO */
1701 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1702 2 + 1,/* DE/LO + TIC */
1703 sizeof (struct DE_eckd_data) +
1704 sizeof (struct LO_eckd_data), device);
1706 if (IS_ERR(erp)) {
1707 DEV_MESSAGE(KERN_ERR, device, "%s", "Unable to allocate ERP");
1708 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1711 /* use original DE */
1712 DE_data = erp->data;
1713 memcpy(DE_data, cqr->data, sizeof (struct DE_eckd_data));
1715 /* create LO */
1716 LO_data = erp->data + sizeof (struct DE_eckd_data);
1718 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1720 DEV_MESSAGE(KERN_ERR, device, "%s",
1721 "BUG - this should not happen");
1723 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1726 if ((sense[7] & 0x3F) == 0x01) {
1727 /* operation code is WRITE DATA -> data area orientation */
1728 LO_data[0] = 0x81;
1730 } else if ((sense[7] & 0x3F) == 0x03) {
1731 /* operation code is FORMAT WRITE -> index orientation */
1732 LO_data[0] = 0xC3;
1734 } else {
1735 LO_data[0] = sense[7]; /* operation */
1738 LO_data[1] = sense[8]; /* auxiliary */
1739 LO_data[2] = sense[9];
1740 LO_data[3] = sense[3]; /* count */
1741 LO_data[4] = sense[29]; /* seek_addr.cyl */
1742 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1743 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1745 memcpy(&(LO_data[8]), &(sense[11]), 8);
1747 /* create DE ccw */
1748 ccw = erp->cpaddr;
1749 memset(ccw, 0, sizeof (struct ccw1));
1750 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1751 ccw->flags = CCW_FLAG_CC;
1752 ccw->count = 16;
1753 ccw->cda = (__u32)(addr_t) DE_data;
1755 /* create LO ccw */
1756 ccw++;
1757 memset(ccw, 0, sizeof (struct ccw1));
1758 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1759 ccw->flags = CCW_FLAG_CC;
1760 ccw->count = 16;
1761 ccw->cda = (__u32)(addr_t) LO_data;
1763 /* TIC to the failed ccw */
1764 ccw++;
1765 ccw->cmd_code = CCW_CMD_TIC;
1766 ccw->cda = cpa;
1768 /* fill erp related fields */
1769 erp->function = dasd_3990_erp_action_1B_32;
1770 erp->refers = default_erp->refers;
1771 erp->device = device;
1772 erp->magic = default_erp->magic;
1773 erp->expires = 0;
1774 erp->retries = 256;
1775 erp->buildclk = get_clock();
1776 erp->status = DASD_CQR_FILLED;
1778 /* remove the default erp */
1779 dasd_free_erp_request(default_erp, device);
1781 return erp;
1783 } /* end dasd_3990_erp_action_1B_32 */
1786 * DASD_3990_UPDATE_1B
1788 * DESCRIPTION
1789 * Handles the update to the 32 byte 'Action 1B' of Single Program
1790 * Action Codes in case the first action was not successful.
1791 * The already created 'previous_erp' is the currently not successful
1792 * ERP.
1794 * PARAMETER
1795 * previous_erp already created previous erp.
1796 * sense current sense data
1797 * RETURN VALUES
1798 * erp modified erp
1800 static struct dasd_ccw_req *
1801 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1804 struct dasd_device *device = previous_erp->device;
1805 __u32 cpa = 0;
1806 struct dasd_ccw_req *cqr;
1807 struct dasd_ccw_req *erp;
1808 char *LO_data; /* struct LO_eckd_data */
1809 struct ccw1 *ccw;
1811 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1812 "Write not finished because of unexpected condition"
1813 " - follow on");
1815 /* determine the original cqr */
1816 cqr = previous_erp;
1818 while (cqr->refers != NULL) {
1819 cqr = cqr->refers;
1822 /* for imprecise ending just do default erp */
1823 if (sense[1] & 0x01) {
1825 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1826 "Imprecise ending is set - just retry");
1828 previous_erp->status = DASD_CQR_QUEUED;
1830 return previous_erp;
1833 /* determine the address of the CCW to be restarted */
1834 /* Imprecise ending is not set -> addr from IRB-SCSW */
1835 cpa = previous_erp->irb.scsw.cpa;
1837 if (cpa == 0) {
1839 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1840 "Unable to determine address of the CCW "
1841 "to be restarted");
1843 previous_erp->status = DASD_CQR_FAILED;
1845 return previous_erp;
1848 erp = previous_erp;
1850 /* update the LO with the new returned sense data */
1851 LO_data = erp->data + sizeof (struct DE_eckd_data);
1853 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1855 DEV_MESSAGE(KERN_ERR, device, "%s",
1856 "BUG - this should not happen");
1858 previous_erp->status = DASD_CQR_FAILED;
1860 return previous_erp;
1863 if ((sense[7] & 0x3F) == 0x01) {
1864 /* operation code is WRITE DATA -> data area orientation */
1865 LO_data[0] = 0x81;
1867 } else if ((sense[7] & 0x3F) == 0x03) {
1868 /* operation code is FORMAT WRITE -> index orientation */
1869 LO_data[0] = 0xC3;
1871 } else {
1872 LO_data[0] = sense[7]; /* operation */
1875 LO_data[1] = sense[8]; /* auxiliary */
1876 LO_data[2] = sense[9];
1877 LO_data[3] = sense[3]; /* count */
1878 LO_data[4] = sense[29]; /* seek_addr.cyl */
1879 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1880 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1882 memcpy(&(LO_data[8]), &(sense[11]), 8);
1884 /* TIC to the failed ccw */
1885 ccw = erp->cpaddr; /* addr of DE ccw */
1886 ccw++; /* addr of LE ccw */
1887 ccw++; /* addr of TIC ccw */
1888 ccw->cda = cpa;
1890 erp->status = DASD_CQR_QUEUED;
1892 return erp;
1894 } /* end dasd_3990_update_1B */
1897 * DASD_3990_ERP_COMPOUND_RETRY
1899 * DESCRIPTION
1900 * Handles the compound ERP action retry code.
1901 * NOTE: At least one retry is done even if zero is specified
1902 * by the sense data. This makes enqueueing of the request
1903 * easier.
1905 * PARAMETER
1906 * sense sense data of the actual error
1907 * erp pointer to the currently created ERP
1909 * RETURN VALUES
1910 * erp modified ERP pointer
1913 static void
1914 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1917 switch (sense[25] & 0x03) {
1918 case 0x00: /* no not retry */
1919 erp->retries = 1;
1920 break;
1922 case 0x01: /* retry 2 times */
1923 erp->retries = 2;
1924 break;
1926 case 0x02: /* retry 10 times */
1927 erp->retries = 10;
1928 break;
1930 case 0x03: /* retry 256 times */
1931 erp->retries = 256;
1932 break;
1934 default:
1935 BUG();
1938 erp->function = dasd_3990_erp_compound_retry;
1940 } /* end dasd_3990_erp_compound_retry */
1943 * DASD_3990_ERP_COMPOUND_PATH
1945 * DESCRIPTION
1946 * Handles the compound ERP action for retry on alternate
1947 * channel path.
1949 * PARAMETER
1950 * sense sense data of the actual error
1951 * erp pointer to the currently created ERP
1953 * RETURN VALUES
1954 * erp modified ERP pointer
1957 static void
1958 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1961 if (sense[25] & DASD_SENSE_BIT_3) {
1962 dasd_3990_erp_alternate_path(erp);
1964 if (erp->status == DASD_CQR_FAILED) {
1965 /* reset the lpm and the status to be able to
1966 * try further actions. */
1968 erp->lpm = 0;
1970 erp->status = DASD_CQR_ERROR;
1975 erp->function = dasd_3990_erp_compound_path;
1977 } /* end dasd_3990_erp_compound_path */
1980 * DASD_3990_ERP_COMPOUND_CODE
1982 * DESCRIPTION
1983 * Handles the compound ERP action for retry code.
1985 * PARAMETER
1986 * sense sense data of the actual error
1987 * erp pointer to the currently created ERP
1989 * RETURN VALUES
1990 * erp NEW ERP pointer
1993 static struct dasd_ccw_req *
1994 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1997 if (sense[25] & DASD_SENSE_BIT_2) {
1999 switch (sense[28]) {
2000 case 0x17:
2001 /* issue a Diagnostic Control command with an
2002 * Inhibit Write subcommand and controler modifier */
2003 erp = dasd_3990_erp_DCTL(erp, 0x20);
2004 break;
2006 case 0x25:
2007 /* wait for 5 seconds and retry again */
2008 erp->retries = 1;
2010 dasd_3990_erp_block_queue (erp, 5*HZ);
2011 break;
2013 default:
2014 /* should not happen - continue */
2015 break;
2019 erp->function = dasd_3990_erp_compound_code;
2021 return erp;
2023 } /* end dasd_3990_erp_compound_code */
2026 * DASD_3990_ERP_COMPOUND_CONFIG
2028 * DESCRIPTION
2029 * Handles the compound ERP action for configruation
2030 * dependent error.
2031 * Note: duplex handling is not implemented (yet).
2033 * PARAMETER
2034 * sense sense data of the actual error
2035 * erp pointer to the currently created ERP
2037 * RETURN VALUES
2038 * erp modified ERP pointer
2041 static void
2042 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2045 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2047 /* set to suspended duplex state then restart */
2048 struct dasd_device *device = erp->device;
2050 DEV_MESSAGE(KERN_ERR, device, "%s",
2051 "Set device to suspended duplex state should be "
2052 "done!\n"
2053 "This is not implemented yet (for compound ERP)"
2054 " - please report to linux390@de.ibm.com");
2058 erp->function = dasd_3990_erp_compound_config;
2060 } /* end dasd_3990_erp_compound_config */
2063 * DASD_3990_ERP_COMPOUND
2065 * DESCRIPTION
2066 * Does the further compound program action if
2067 * compound retry was not successful.
2069 * PARAMETER
2070 * sense sense data of the actual error
2071 * erp pointer to the current (failed) ERP
2073 * RETURN VALUES
2074 * erp (additional) ERP pointer
2077 static struct dasd_ccw_req *
2078 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2081 if ((erp->function == dasd_3990_erp_compound_retry) &&
2082 (erp->status == DASD_CQR_ERROR)) {
2084 dasd_3990_erp_compound_path(erp, sense);
2087 if ((erp->function == dasd_3990_erp_compound_path) &&
2088 (erp->status == DASD_CQR_ERROR)) {
2090 erp = dasd_3990_erp_compound_code(erp, sense);
2093 if ((erp->function == dasd_3990_erp_compound_code) &&
2094 (erp->status == DASD_CQR_ERROR)) {
2096 dasd_3990_erp_compound_config(erp, sense);
2099 /* if no compound action ERP specified, the request failed */
2100 if (erp->status == DASD_CQR_ERROR) {
2102 erp->status = DASD_CQR_FAILED;
2105 return erp;
2107 } /* end dasd_3990_erp_compound */
2110 * DASD_3990_ERP_INSPECT_32
2112 * DESCRIPTION
2113 * Does a detailed inspection of the 32 byte sense data
2114 * and sets up a related error recovery action.
2116 * PARAMETER
2117 * sense sense data of the actual error
2118 * erp pointer to the currently created default ERP
2120 * RETURN VALUES
2121 * erp_filled pointer to the ERP
2124 static struct dasd_ccw_req *
2125 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2128 struct dasd_device *device = erp->device;
2130 erp->function = dasd_3990_erp_inspect_32;
2132 if (sense[25] & DASD_SENSE_BIT_0) {
2134 /* compound program action codes (byte25 bit 0 == '1') */
2135 dasd_3990_erp_compound_retry(erp, sense);
2137 } else {
2139 /* single program action codes (byte25 bit 0 == '0') */
2140 switch (sense[25]) {
2142 case 0x00: /* success - use default ERP for retries */
2143 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2144 "ERP called for successful request"
2145 " - just retry");
2146 break;
2148 case 0x01: /* fatal error */
2149 DEV_MESSAGE(KERN_ERR, device, "%s",
2150 "Fatal error should have been "
2151 "handled within the interrupt handler");
2153 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2154 break;
2156 case 0x02: /* intervention required */
2157 case 0x03: /* intervention required during dual copy */
2158 erp = dasd_3990_erp_int_req(erp);
2159 break;
2161 case 0x0F: /* length mismatch during update write command */
2162 DEV_MESSAGE(KERN_ERR, device, "%s",
2163 "update write command error - should not "
2164 "happen;\n"
2165 "Please send this message together with "
2166 "the above sense data to linux390@de."
2167 "ibm.com");
2169 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2170 break;
2172 case 0x10: /* logging required for other channel program */
2173 erp = dasd_3990_erp_action_10_32(erp, sense);
2174 break;
2176 case 0x15: /* next track outside defined extend */
2177 DEV_MESSAGE(KERN_ERR, device, "%s",
2178 "next track outside defined extend - "
2179 "should not happen;\n"
2180 "Please send this message together with "
2181 "the above sense data to linux390@de."
2182 "ibm.com");
2184 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2185 break;
2187 case 0x1B: /* unexpected condition during write */
2189 erp = dasd_3990_erp_action_1B_32(erp, sense);
2190 break;
2192 case 0x1C: /* invalid data */
2193 DEV_MESSAGE(KERN_EMERG, device, "%s",
2194 "Data recovered during retry with PCI "
2195 "fetch mode active");
2197 /* not possible to handle this situation in Linux */
2198 panic
2199 ("Invalid data - No way to inform application "
2200 "about the possibly incorrect data");
2201 break;
2203 case 0x1D: /* state-change pending */
2204 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2205 "A State change pending condition exists "
2206 "for the subsystem or device");
2208 erp = dasd_3990_erp_action_4(erp, sense);
2209 break;
2211 case 0x1E: /* busy */
2212 DEV_MESSAGE(KERN_DEBUG, device, "%s",
2213 "Busy condition exists "
2214 "for the subsystem or device");
2215 erp = dasd_3990_erp_action_4(erp, sense);
2216 break;
2218 default: /* all others errors - default erp */
2219 break;
2223 return erp;
2225 } /* end dasd_3990_erp_inspect_32 */
2228 *****************************************************************************
2229 * main ERP control fuctions (24 and 32 byte sense)
2230 *****************************************************************************
2234 * DASD_3990_ERP_INSPECT
2236 * DESCRIPTION
2237 * Does a detailed inspection for sense data by calling either
2238 * the 24-byte or the 32-byte inspection routine.
2240 * PARAMETER
2241 * erp pointer to the currently created default ERP
2242 * RETURN VALUES
2243 * erp_new contens was possibly modified
2245 static struct dasd_ccw_req *
2246 dasd_3990_erp_inspect(struct dasd_ccw_req * erp)
2249 struct dasd_ccw_req *erp_new = NULL;
2250 /* sense data are located in the refers record of the */
2251 /* already set up new ERP ! */
2252 char *sense = erp->refers->irb.ecw;
2254 /* distinguish between 24 and 32 byte sense data */
2255 if (sense[27] & DASD_SENSE_BIT_0) {
2257 /* inspect the 24 byte sense data */
2258 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2260 } else {
2262 /* inspect the 32 byte sense data */
2263 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2265 } /* end distinguish between 24 and 32 byte sense data */
2267 return erp_new;
2271 * DASD_3990_ERP_ADD_ERP
2273 * DESCRIPTION
2274 * This funtion adds an additional request block (ERP) to the head of
2275 * the given cqr (or erp).
2276 * This erp is initialized as an default erp (retry TIC)
2278 * PARAMETER
2279 * cqr head of the current ERP-chain (or single cqr if
2280 * first error)
2281 * RETURN VALUES
2282 * erp pointer to new ERP-chain head
2284 static struct dasd_ccw_req *
2285 dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)
2288 struct dasd_device *device = cqr->device;
2289 struct ccw1 *ccw;
2291 /* allocate additional request block */
2292 struct dasd_ccw_req *erp;
2294 erp = dasd_alloc_erp_request((char *) &cqr->magic, 2, 0, cqr->device);
2295 if (IS_ERR(erp)) {
2296 if (cqr->retries <= 0) {
2297 DEV_MESSAGE(KERN_ERR, device, "%s",
2298 "Unable to allocate ERP request");
2299 cqr->status = DASD_CQR_FAILED;
2300 cqr->stopclk = get_clock ();
2301 } else {
2302 DEV_MESSAGE (KERN_ERR, device,
2303 "Unable to allocate ERP request "
2304 "(%i retries left)",
2305 cqr->retries);
2306 dasd_set_timer(device, (HZ << 3));
2308 return cqr;
2311 /* initialize request with default TIC to current ERP/CQR */
2312 ccw = erp->cpaddr;
2313 ccw->cmd_code = CCW_CMD_NOOP;
2314 ccw->flags = CCW_FLAG_CC;
2315 ccw++;
2316 ccw->cmd_code = CCW_CMD_TIC;
2317 ccw->cda = (long)(cqr->cpaddr);
2318 erp->function = dasd_3990_erp_add_erp;
2319 erp->refers = cqr;
2320 erp->device = cqr->device;
2321 erp->magic = cqr->magic;
2322 erp->expires = 0;
2323 erp->retries = 256;
2324 erp->buildclk = get_clock();
2326 erp->status = DASD_CQR_FILLED;
2328 return erp;
2332 * DASD_3990_ERP_ADDITIONAL_ERP
2334 * DESCRIPTION
2335 * An additional ERP is needed to handle the current error.
2336 * Add ERP to the head of the ERP-chain containing the ERP processing
2337 * determined based on the sense data.
2339 * PARAMETER
2340 * cqr head of the current ERP-chain (or single cqr if
2341 * first error)
2343 * RETURN VALUES
2344 * erp pointer to new ERP-chain head
2346 static struct dasd_ccw_req *
2347 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2350 struct dasd_ccw_req *erp = NULL;
2352 /* add erp and initialize with default TIC */
2353 erp = dasd_3990_erp_add_erp(cqr);
2355 /* inspect sense, determine specific ERP if possible */
2356 if (erp != cqr) {
2358 erp = dasd_3990_erp_inspect(erp);
2361 return erp;
2363 } /* end dasd_3990_erp_additional_erp */
2366 * DASD_3990_ERP_ERROR_MATCH
2368 * DESCRIPTION
2369 * Check if the device status of the given cqr is the same.
2370 * This means that the failed CCW and the relevant sense data
2371 * must match.
2372 * I don't distinguish between 24 and 32 byte sense because in case of
2373 * 24 byte sense byte 25 and 27 is set as well.
2375 * PARAMETER
2376 * cqr1 first cqr, which will be compared with the
2377 * cqr2 second cqr.
2379 * RETURN VALUES
2380 * match 'boolean' for match found
2381 * returns 1 if match found, otherwise 0.
2383 static int
2384 dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1, struct dasd_ccw_req *cqr2)
2387 /* check failed CCW */
2388 if (cqr1->irb.scsw.cpa != cqr2->irb.scsw.cpa) {
2389 // return 0; /* CCW doesn't match */
2392 /* check sense data; byte 0-2,25,27 */
2393 if (!((memcmp (cqr1->irb.ecw, cqr2->irb.ecw, 3) == 0) &&
2394 (cqr1->irb.ecw[27] == cqr2->irb.ecw[27]) &&
2395 (cqr1->irb.ecw[25] == cqr2->irb.ecw[25]))) {
2397 return 0; /* sense doesn't match */
2400 return 1; /* match */
2402 } /* end dasd_3990_erp_error_match */
2405 * DASD_3990_ERP_IN_ERP
2407 * DESCRIPTION
2408 * check if the current error already happened before.
2409 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2411 * PARAMETER
2412 * cqr failed cqr (either original cqr or already an erp)
2414 * RETURN VALUES
2415 * erp erp-pointer to the already defined error
2416 * recovery procedure OR
2417 * NULL if a 'new' error occurred.
2419 static struct dasd_ccw_req *
2420 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2423 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2424 *erp_match = NULL; /* save erp chain head */
2425 int match = 0; /* 'boolean' for matching error found */
2427 if (cqr->refers == NULL) { /* return if not in erp */
2428 return NULL;
2431 /* check the erp/cqr chain for current error */
2432 do {
2433 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2434 erp_match = cqr; /* save possible matching erp */
2435 cqr = cqr->refers; /* check next erp/cqr in queue */
2437 } while ((cqr->refers != NULL) && (!match));
2439 if (!match) {
2440 return NULL; /* no match was found */
2443 return erp_match; /* return address of matching erp */
2445 } /* END dasd_3990_erp_in_erp */
2448 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2450 * DESCRIPTION
2451 * No retry is left for the current ERP. Check what has to be done
2452 * with the ERP.
2453 * - do further defined ERP action or
2454 * - wait for interrupt or
2455 * - exit with permanent error
2457 * PARAMETER
2458 * erp ERP which is in progress with no retry left
2460 * RETURN VALUES
2461 * erp modified/additional ERP
2463 static struct dasd_ccw_req *
2464 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2467 struct dasd_device *device = erp->device;
2468 char *sense = erp->irb.ecw;
2470 /* check for 24 byte sense ERP */
2471 if ((erp->function == dasd_3990_erp_bus_out) ||
2472 (erp->function == dasd_3990_erp_action_1) ||
2473 (erp->function == dasd_3990_erp_action_4)) {
2475 erp = dasd_3990_erp_action_1(erp);
2477 } else if (erp->function == dasd_3990_erp_action_5) {
2479 /* retries have not been successful */
2480 /* prepare erp for retry on different channel path */
2481 erp = dasd_3990_erp_action_1(erp);
2483 if (!(sense[2] & DASD_SENSE_BIT_0)) {
2485 /* issue a Diagnostic Control command with an
2486 * Inhibit Write subcommand */
2488 switch (sense[25]) {
2489 case 0x17:
2490 case 0x57:{ /* controller */
2491 erp = dasd_3990_erp_DCTL(erp, 0x20);
2492 break;
2494 case 0x18:
2495 case 0x58:{ /* channel path */
2496 erp = dasd_3990_erp_DCTL(erp, 0x40);
2497 break;
2499 case 0x19:
2500 case 0x59:{ /* storage director */
2501 erp = dasd_3990_erp_DCTL(erp, 0x80);
2502 break;
2504 default:
2505 DEV_MESSAGE(KERN_DEBUG, device,
2506 "invalid subcommand modifier 0x%x "
2507 "for Diagnostic Control Command",
2508 sense[25]);
2512 /* check for 32 byte sense ERP */
2513 } else if ((erp->function == dasd_3990_erp_compound_retry) ||
2514 (erp->function == dasd_3990_erp_compound_path) ||
2515 (erp->function == dasd_3990_erp_compound_code) ||
2516 (erp->function == dasd_3990_erp_compound_config)) {
2518 erp = dasd_3990_erp_compound(erp, sense);
2520 } else {
2521 /* No retry left and no additional special handling */
2522 /*necessary */
2523 DEV_MESSAGE(KERN_ERR, device,
2524 "no retries left for erp %p - "
2525 "set status to FAILED", erp);
2527 erp->status = DASD_CQR_FAILED;
2530 return erp;
2532 } /* end dasd_3990_erp_further_erp */
2535 * DASD_3990_ERP_HANDLE_MATCH_ERP
2537 * DESCRIPTION
2538 * An error occurred again and an ERP has been detected which is already
2539 * used to handle this error (e.g. retries).
2540 * All prior ERP's are asumed to be successful and therefore removed
2541 * from queue.
2542 * If retry counter of matching erp is already 0, it is checked if further
2543 * action is needed (besides retry) or if the ERP has failed.
2545 * PARAMETER
2546 * erp_head first ERP in ERP-chain
2547 * erp ERP that handles the actual error.
2548 * (matching erp)
2550 * RETURN VALUES
2551 * erp modified/additional ERP
2553 static struct dasd_ccw_req *
2554 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2555 struct dasd_ccw_req *erp)
2558 struct dasd_device *device = erp_head->device;
2559 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2560 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2562 /* loop over successful ERPs and remove them from chanq */
2563 while (erp_done != erp) {
2565 if (erp_done == NULL) /* end of chain reached */
2566 panic(PRINTK_HEADER "Programming error in ERP! The "
2567 "original request was lost\n");
2569 /* remove the request from the device queue */
2570 list_del(&erp_done->list);
2572 erp_free = erp_done;
2573 erp_done = erp_done->refers;
2575 /* free the finished erp request */
2576 dasd_free_erp_request(erp_free, erp_free->device);
2578 } /* end while */
2580 if (erp->retries > 0) {
2582 char *sense = erp->refers->irb.ecw;
2584 /* check for special retries */
2585 if (erp->function == dasd_3990_erp_action_4) {
2587 erp = dasd_3990_erp_action_4(erp, sense);
2589 } else if (erp->function == dasd_3990_erp_action_1B_32) {
2591 erp = dasd_3990_update_1B(erp, sense);
2593 } else if (erp->function == dasd_3990_erp_int_req) {
2595 erp = dasd_3990_erp_int_req(erp);
2597 } else {
2598 /* simple retry */
2599 DEV_MESSAGE(KERN_DEBUG, device,
2600 "%i retries left for erp %p",
2601 erp->retries, erp);
2603 /* handle the request again... */
2604 erp->status = DASD_CQR_QUEUED;
2607 } else {
2608 /* no retry left - check for further necessary action */
2609 /* if no further actions, handle rest as permanent error */
2610 erp = dasd_3990_erp_further_erp(erp);
2613 return erp;
2615 } /* end dasd_3990_erp_handle_match_erp */
2618 * DASD_3990_ERP_ACTION
2620 * DESCRIPTION
2621 * controll routine for 3990 erp actions.
2622 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2624 * PARAMETER
2625 * cqr failed cqr (either original cqr or already an erp)
2627 * RETURN VALUES
2628 * erp erp-pointer to the head of the ERP action chain.
2629 * This means:
2630 * - either a ptr to an additional ERP cqr or
2631 * - the original given cqr (which's status might
2632 * be modified)
2634 struct dasd_ccw_req *
2635 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2638 struct dasd_ccw_req *erp = NULL;
2639 struct dasd_device *device = cqr->device;
2640 __u32 cpa = cqr->irb.scsw.cpa;
2642 #ifdef ERP_DEBUG
2643 /* print current erp_chain */
2644 DEV_MESSAGE(KERN_ERR, device, "%s",
2645 "ERP chain at BEGINNING of ERP-ACTION");
2647 struct dasd_ccw_req *temp_erp = NULL;
2649 for (temp_erp = cqr;
2650 temp_erp != NULL; temp_erp = temp_erp->refers) {
2652 DEV_MESSAGE(KERN_ERR, device,
2653 " erp %p (%02x) refers to %p",
2654 temp_erp, temp_erp->status,
2655 temp_erp->refers);
2658 #endif /* ERP_DEBUG */
2660 /* double-check if current erp/cqr was successfull */
2661 if ((cqr->irb.scsw.cstat == 0x00) &&
2662 (cqr->irb.scsw.dstat == (DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2664 DEV_MESSAGE(KERN_DEBUG, device,
2665 "ERP called for successful request %p"
2666 " - NO ERP necessary", cqr);
2668 cqr->status = DASD_CQR_DONE;
2670 return cqr;
2672 /* check if sense data are available */
2673 if (!cqr->irb.ecw) {
2674 DEV_MESSAGE(KERN_DEBUG, device,
2675 "ERP called witout sense data avail ..."
2676 "request %p - NO ERP possible", cqr);
2678 cqr->status = DASD_CQR_FAILED;
2680 return cqr;
2684 /* check if error happened before */
2685 erp = dasd_3990_erp_in_erp(cqr);
2687 if (erp == NULL) {
2688 /* no matching erp found - set up erp */
2689 erp = dasd_3990_erp_additional_erp(cqr);
2690 } else {
2691 /* matching erp found - set all leading erp's to DONE */
2692 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2695 #ifdef ERP_DEBUG
2696 /* print current erp_chain */
2697 DEV_MESSAGE(KERN_ERR, device, "%s", "ERP chain at END of ERP-ACTION");
2699 struct dasd_ccw_req *temp_erp = NULL;
2700 for (temp_erp = erp;
2701 temp_erp != NULL; temp_erp = temp_erp->refers) {
2703 DEV_MESSAGE(KERN_ERR, device,
2704 " erp %p (%02x) refers to %p",
2705 temp_erp, temp_erp->status,
2706 temp_erp->refers);
2709 #endif /* ERP_DEBUG */
2711 if (erp->status == DASD_CQR_FAILED)
2712 dasd_log_ccw(erp, 1, cpa);
2714 /* enqueue added ERP request */
2715 if (erp->status == DASD_CQR_FILLED) {
2716 erp->status = DASD_CQR_QUEUED;
2717 list_add(&erp->list, &device->ccw_queue);
2720 return erp;
2722 } /* end dasd_3990_erp_action */
2725 * Overrides for Emacs so that we follow Linus's tabbing style.
2726 * Emacs will notice this stuff at the end of the file and automatically
2727 * adjust the settings for this buffer only. This must remain at the end
2728 * of the file.
2729 * ---------------------------------------------------------------------------
2730 * Local variables:
2731 * c-indent-level: 4
2732 * c-brace-imaginary-offset: 0
2733 * c-brace-offset: -4
2734 * c-argdecl-indent: 4
2735 * c-label-offset: -4
2736 * c-continued-statement-offset: 4
2737 * c-continued-brace-offset: 0
2738 * indent-tabs-mode: 1
2739 * tab-width: 8
2740 * End: