staging: brcm80211: cleanup headers
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / s390 / block / dasd_3990_erp.c
blob85bfd87948561cf17e758c9074bdaef2a33140a8
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 #define KMSG_COMPONENT "dasd-eckd"
12 #include <linux/timer.h>
13 #include <asm/idals.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 HANDLING
30 *****************************************************************************
33 *****************************************************************************
34 * 24 and 32 byte sense ERP functions
35 *****************************************************************************
39 * DASD_3990_ERP_CLEANUP
41 * DESCRIPTION
42 * Removes the already build but not necessary ERP request and sets
43 * the status of the original cqr / erp to the given (final) status
45 * PARAMETER
46 * erp request to be blocked
47 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
49 * RETURN VALUES
50 * cqr original cqr
52 static struct dasd_ccw_req *
53 dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
55 struct dasd_ccw_req *cqr = erp->refers;
57 dasd_free_erp_request(erp, erp->memdev);
58 cqr->status = final_status;
59 return cqr;
61 } /* end dasd_3990_erp_cleanup */
64 * DASD_3990_ERP_BLOCK_QUEUE
66 * DESCRIPTION
67 * Block the given device request queue to prevent from further
68 * processing until the started timer has expired or an related
69 * interrupt was received.
71 static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires)
74 struct dasd_device *device = erp->startdev;
75 unsigned long flags;
77 DBF_DEV_EVENT(DBF_INFO, device,
78 "blocking request queue for %is", expires/HZ);
80 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
81 dasd_device_set_stop_bits(device, DASD_STOPPED_PENDING);
82 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
83 erp->status = DASD_CQR_FILLED;
84 if (erp->block)
85 dasd_block_set_timer(erp->block, expires);
86 else
87 dasd_device_set_timer(device, expires);
91 * DASD_3990_ERP_INT_REQ
93 * DESCRIPTION
94 * Handles 'Intervention Required' error.
95 * This means either device offline or not installed.
97 * PARAMETER
98 * erp current erp
99 * RETURN VALUES
100 * erp modified erp
102 static struct dasd_ccw_req *
103 dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
106 struct dasd_device *device = erp->startdev;
108 /* first time set initial retry counter and erp_function */
109 /* and retry once without blocking queue */
110 /* (this enables easier enqueing of the cqr) */
111 if (erp->function != dasd_3990_erp_int_req) {
113 erp->retries = 256;
114 erp->function = dasd_3990_erp_int_req;
116 } else {
118 /* issue a message and wait for 'device ready' interrupt */
119 dev_err(&device->cdev->dev,
120 "is offline or not installed - "
121 "INTERVENTION REQUIRED!!\n");
123 dasd_3990_erp_block_queue(erp, 60*HZ);
126 return erp;
128 } /* end dasd_3990_erp_int_req */
131 * DASD_3990_ERP_ALTERNATE_PATH
133 * DESCRIPTION
134 * Repeat the operation on a different channel path.
135 * If all alternate paths have been tried, the request is posted with a
136 * permanent error.
138 * PARAMETER
139 * erp pointer to the current ERP
141 * RETURN VALUES
142 * erp modified pointer to the ERP
144 static void
145 dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
147 struct dasd_device *device = erp->startdev;
148 __u8 opm;
149 unsigned long flags;
151 /* try alternate valid path */
152 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
153 opm = ccw_device_get_path_mask(device->cdev);
154 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
155 //FIXME: start with get_opm ?
156 if (erp->lpm == 0)
157 erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
158 else
159 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
161 if ((erp->lpm & opm) != 0x00) {
163 DBF_DEV_EVENT(DBF_WARNING, device,
164 "try alternate lpm=%x (lpum=%x / opm=%x)",
165 erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
167 /* reset status to submit the request again... */
168 erp->status = DASD_CQR_FILLED;
169 erp->retries = 10;
170 } else {
171 dev_err(&device->cdev->dev,
172 "The DASD cannot be reached on any path (lpum=%x"
173 "/opm=%x)\n", erp->irb.esw.esw0.sublog.lpum, opm);
175 /* post request with permanent error */
176 erp->status = DASD_CQR_FAILED;
178 } /* end dasd_3990_erp_alternate_path */
181 * DASD_3990_ERP_DCTL
183 * DESCRIPTION
184 * Setup cqr to do the Diagnostic Control (DCTL) command with an
185 * Inhibit Write subcommand (0x20) and the given modifier.
187 * PARAMETER
188 * erp pointer to the current (failed) ERP
189 * modifier subcommand modifier
191 * RETURN VALUES
192 * dctl_cqr pointer to NEW dctl_cqr
195 static struct dasd_ccw_req *
196 dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
199 struct dasd_device *device = erp->startdev;
200 struct DCTL_data *DCTL_data;
201 struct ccw1 *ccw;
202 struct dasd_ccw_req *dctl_cqr;
204 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
205 sizeof(struct DCTL_data),
206 device);
207 if (IS_ERR(dctl_cqr)) {
208 dev_err(&device->cdev->dev,
209 "Unable to allocate DCTL-CQR\n");
210 erp->status = DASD_CQR_FAILED;
211 return erp;
214 DCTL_data = dctl_cqr->data;
216 DCTL_data->subcommand = 0x02; /* Inhibit Write */
217 DCTL_data->modifier = modifier;
219 ccw = dctl_cqr->cpaddr;
220 memset(ccw, 0, sizeof(struct ccw1));
221 ccw->cmd_code = CCW_CMD_DCTL;
222 ccw->count = 4;
223 ccw->cda = (__u32)(addr_t) DCTL_data;
224 dctl_cqr->function = dasd_3990_erp_DCTL;
225 dctl_cqr->refers = erp;
226 dctl_cqr->startdev = device;
227 dctl_cqr->memdev = device;
228 dctl_cqr->magic = erp->magic;
229 dctl_cqr->expires = 5 * 60 * HZ;
230 dctl_cqr->retries = 2;
232 dctl_cqr->buildclk = get_clock();
234 dctl_cqr->status = DASD_CQR_FILLED;
236 return dctl_cqr;
238 } /* end dasd_3990_erp_DCTL */
241 * DASD_3990_ERP_ACTION_1
243 * DESCRIPTION
244 * Setup ERP to do the ERP action 1 (see Reference manual).
245 * Repeat the operation on a different channel path.
246 * As deviation from the recommended recovery action, we reset the path mask
247 * after we have tried each path and go through all paths a second time.
248 * This will cover situations where only one path at a time is actually down,
249 * but all paths fail and recover just with the same sequence and timing as
250 * we try to use them (flapping links).
251 * If all alternate paths have been tried twice, the request is posted with
252 * a permanent error.
254 * PARAMETER
255 * erp pointer to the current ERP
257 * RETURN VALUES
258 * erp pointer to the ERP
261 static struct dasd_ccw_req *dasd_3990_erp_action_1_sec(struct dasd_ccw_req *erp)
263 erp->function = dasd_3990_erp_action_1_sec;
264 dasd_3990_erp_alternate_path(erp);
265 return erp;
268 static struct dasd_ccw_req *dasd_3990_erp_action_1(struct dasd_ccw_req *erp)
270 erp->function = dasd_3990_erp_action_1;
271 dasd_3990_erp_alternate_path(erp);
272 if (erp->status == DASD_CQR_FAILED) {
273 erp->status = DASD_CQR_FILLED;
274 erp->retries = 10;
275 erp->lpm = LPM_ANYPATH;
276 erp->function = dasd_3990_erp_action_1_sec;
278 return erp;
279 } /* end dasd_3990_erp_action_1(b) */
282 * DASD_3990_ERP_ACTION_4
284 * DESCRIPTION
285 * Setup ERP to do the ERP action 4 (see Reference manual).
286 * Set the current request to PENDING to block the CQR queue for that device
287 * until the state change interrupt appears.
288 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
289 * missing.
291 * PARAMETER
292 * sense sense data of the actual error
293 * erp pointer to the current ERP
295 * RETURN VALUES
296 * erp pointer to the ERP
299 static struct dasd_ccw_req *
300 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
303 struct dasd_device *device = erp->startdev;
305 /* first time set initial retry counter and erp_function */
306 /* and retry once without waiting for state change pending */
307 /* interrupt (this enables easier enqueing of the cqr) */
308 if (erp->function != dasd_3990_erp_action_4) {
310 DBF_DEV_EVENT(DBF_INFO, device, "%s",
311 "dasd_3990_erp_action_4: first time retry");
313 erp->retries = 256;
314 erp->function = dasd_3990_erp_action_4;
316 } else {
317 if (sense && (sense[25] == 0x1D)) { /* state change pending */
319 DBF_DEV_EVENT(DBF_INFO, device,
320 "waiting for state change pending "
321 "interrupt, %d retries left",
322 erp->retries);
324 dasd_3990_erp_block_queue(erp, 30*HZ);
326 } else if (sense && (sense[25] == 0x1E)) { /* busy */
327 DBF_DEV_EVENT(DBF_INFO, device,
328 "busy - redriving request later, "
329 "%d retries left",
330 erp->retries);
331 dasd_3990_erp_block_queue(erp, HZ);
332 } else {
333 /* no state change pending - retry */
334 DBF_DEV_EVENT(DBF_INFO, device,
335 "redriving request immediately, "
336 "%d retries left",
337 erp->retries);
338 erp->status = DASD_CQR_FILLED;
342 return erp;
344 } /* end dasd_3990_erp_action_4 */
347 *****************************************************************************
348 * 24 byte sense ERP functions (only)
349 *****************************************************************************
353 * DASD_3990_ERP_ACTION_5
355 * DESCRIPTION
356 * Setup ERP to do the ERP action 5 (see Reference manual).
357 * NOTE: Further handling is done in xxx_further_erp after the retries.
359 * PARAMETER
360 * erp pointer to the current ERP
362 * RETURN VALUES
363 * erp pointer to the ERP
366 static struct dasd_ccw_req *
367 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
370 /* first of all retry */
371 erp->retries = 10;
372 erp->function = dasd_3990_erp_action_5;
374 return erp;
376 } /* end dasd_3990_erp_action_5 */
379 * DASD_3990_HANDLE_ENV_DATA
381 * DESCRIPTION
382 * Handles 24 byte 'Environmental data present'.
383 * Does a analysis of the sense data (message Format)
384 * and prints the error messages.
386 * PARAMETER
387 * sense current sense data
389 * RETURN VALUES
390 * void
392 static void
393 dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
396 struct dasd_device *device = erp->startdev;
397 char msg_format = (sense[7] & 0xF0);
398 char msg_no = (sense[7] & 0x0F);
399 char errorstring[ERRORLENGTH];
401 switch (msg_format) {
402 case 0x00: /* Format 0 - Program or System Checks */
404 if (sense[1] & 0x10) { /* check message to operator bit */
406 switch (msg_no) {
407 case 0x00: /* No Message */
408 break;
409 case 0x01:
410 dev_warn(&device->cdev->dev,
411 "FORMAT 0 - Invalid Command\n");
412 break;
413 case 0x02:
414 dev_warn(&device->cdev->dev,
415 "FORMAT 0 - Invalid Command "
416 "Sequence\n");
417 break;
418 case 0x03:
419 dev_warn(&device->cdev->dev,
420 "FORMAT 0 - CCW Count less than "
421 "required\n");
422 break;
423 case 0x04:
424 dev_warn(&device->cdev->dev,
425 "FORMAT 0 - Invalid Parameter\n");
426 break;
427 case 0x05:
428 dev_warn(&device->cdev->dev,
429 "FORMAT 0 - Diagnostic of Special"
430 " Command Violates File Mask\n");
431 break;
432 case 0x07:
433 dev_warn(&device->cdev->dev,
434 "FORMAT 0 - Channel Returned with "
435 "Incorrect retry CCW\n");
436 break;
437 case 0x08:
438 dev_warn(&device->cdev->dev,
439 "FORMAT 0 - Reset Notification\n");
440 break;
441 case 0x09:
442 dev_warn(&device->cdev->dev,
443 "FORMAT 0 - Storage Path Restart\n");
444 break;
445 case 0x0A:
446 dev_warn(&device->cdev->dev,
447 "FORMAT 0 - Channel requested "
448 "... %02x\n", sense[8]);
449 break;
450 case 0x0B:
451 dev_warn(&device->cdev->dev,
452 "FORMAT 0 - Invalid Defective/"
453 "Alternate Track Pointer\n");
454 break;
455 case 0x0C:
456 dev_warn(&device->cdev->dev,
457 "FORMAT 0 - DPS Installation "
458 "Check\n");
459 break;
460 case 0x0E:
461 dev_warn(&device->cdev->dev,
462 "FORMAT 0 - Command Invalid on "
463 "Secondary Address\n");
464 break;
465 case 0x0F:
466 dev_warn(&device->cdev->dev,
467 "FORMAT 0 - Status Not As "
468 "Required: reason %02x\n",
469 sense[8]);
470 break;
471 default:
472 dev_warn(&device->cdev->dev,
473 "FORMAT 0 - Reserved\n");
475 } else {
476 switch (msg_no) {
477 case 0x00: /* No Message */
478 break;
479 case 0x01:
480 dev_warn(&device->cdev->dev,
481 "FORMAT 0 - Device Error "
482 "Source\n");
483 break;
484 case 0x02:
485 dev_warn(&device->cdev->dev,
486 "FORMAT 0 - Reserved\n");
487 break;
488 case 0x03:
489 dev_warn(&device->cdev->dev,
490 "FORMAT 0 - Device Fenced - "
491 "device = %02x\n", sense[4]);
492 break;
493 case 0x04:
494 dev_warn(&device->cdev->dev,
495 "FORMAT 0 - Data Pinned for "
496 "Device\n");
497 break;
498 default:
499 dev_warn(&device->cdev->dev,
500 "FORMAT 0 - Reserved\n");
503 break;
505 case 0x10: /* Format 1 - Device Equipment Checks */
506 switch (msg_no) {
507 case 0x00: /* No Message */
508 break;
509 case 0x01:
510 dev_warn(&device->cdev->dev,
511 "FORMAT 1 - Device Status 1 not as "
512 "expected\n");
513 break;
514 case 0x03:
515 dev_warn(&device->cdev->dev,
516 "FORMAT 1 - Index missing\n");
517 break;
518 case 0x04:
519 dev_warn(&device->cdev->dev,
520 "FORMAT 1 - Interruption cannot be "
521 "reset\n");
522 break;
523 case 0x05:
524 dev_warn(&device->cdev->dev,
525 "FORMAT 1 - Device did not respond to "
526 "selection\n");
527 break;
528 case 0x06:
529 dev_warn(&device->cdev->dev,
530 "FORMAT 1 - Device check-2 error or Set "
531 "Sector is not complete\n");
532 break;
533 case 0x07:
534 dev_warn(&device->cdev->dev,
535 "FORMAT 1 - Head address does not "
536 "compare\n");
537 break;
538 case 0x08:
539 dev_warn(&device->cdev->dev,
540 "FORMAT 1 - Device status 1 not valid\n");
541 break;
542 case 0x09:
543 dev_warn(&device->cdev->dev,
544 "FORMAT 1 - Device not ready\n");
545 break;
546 case 0x0A:
547 dev_warn(&device->cdev->dev,
548 "FORMAT 1 - Track physical address did "
549 "not compare\n");
550 break;
551 case 0x0B:
552 dev_warn(&device->cdev->dev,
553 "FORMAT 1 - Missing device address bit\n");
554 break;
555 case 0x0C:
556 dev_warn(&device->cdev->dev,
557 "FORMAT 1 - Drive motor switch is off\n");
558 break;
559 case 0x0D:
560 dev_warn(&device->cdev->dev,
561 "FORMAT 1 - Seek incomplete\n");
562 break;
563 case 0x0E:
564 dev_warn(&device->cdev->dev,
565 "FORMAT 1 - Cylinder address did not "
566 "compare\n");
567 break;
568 case 0x0F:
569 dev_warn(&device->cdev->dev,
570 "FORMAT 1 - Offset active cannot be "
571 "reset\n");
572 break;
573 default:
574 dev_warn(&device->cdev->dev,
575 "FORMAT 1 - Reserved\n");
577 break;
579 case 0x20: /* Format 2 - 3990 Equipment Checks */
580 switch (msg_no) {
581 case 0x08:
582 dev_warn(&device->cdev->dev,
583 "FORMAT 2 - 3990 check-2 error\n");
584 break;
585 case 0x0E:
586 dev_warn(&device->cdev->dev,
587 "FORMAT 2 - Support facility errors\n");
588 break;
589 case 0x0F:
590 dev_warn(&device->cdev->dev,
591 "FORMAT 2 - Microcode detected error "
592 "%02x\n",
593 sense[8]);
594 break;
595 default:
596 dev_warn(&device->cdev->dev,
597 "FORMAT 2 - Reserved\n");
599 break;
601 case 0x30: /* Format 3 - 3990 Control Checks */
602 switch (msg_no) {
603 case 0x0F:
604 dev_warn(&device->cdev->dev,
605 "FORMAT 3 - Allegiance terminated\n");
606 break;
607 default:
608 dev_warn(&device->cdev->dev,
609 "FORMAT 3 - Reserved\n");
611 break;
613 case 0x40: /* Format 4 - Data Checks */
614 switch (msg_no) {
615 case 0x00:
616 dev_warn(&device->cdev->dev,
617 "FORMAT 4 - Home address area error\n");
618 break;
619 case 0x01:
620 dev_warn(&device->cdev->dev,
621 "FORMAT 4 - Count area error\n");
622 break;
623 case 0x02:
624 dev_warn(&device->cdev->dev,
625 "FORMAT 4 - Key area error\n");
626 break;
627 case 0x03:
628 dev_warn(&device->cdev->dev,
629 "FORMAT 4 - Data area error\n");
630 break;
631 case 0x04:
632 dev_warn(&device->cdev->dev,
633 "FORMAT 4 - No sync byte in home address "
634 "area\n");
635 break;
636 case 0x05:
637 dev_warn(&device->cdev->dev,
638 "FORMAT 4 - No sync byte in count address "
639 "area\n");
640 break;
641 case 0x06:
642 dev_warn(&device->cdev->dev,
643 "FORMAT 4 - No sync byte in key area\n");
644 break;
645 case 0x07:
646 dev_warn(&device->cdev->dev,
647 "FORMAT 4 - No sync byte in data area\n");
648 break;
649 case 0x08:
650 dev_warn(&device->cdev->dev,
651 "FORMAT 4 - Home address area error; "
652 "offset active\n");
653 break;
654 case 0x09:
655 dev_warn(&device->cdev->dev,
656 "FORMAT 4 - Count area error; offset "
657 "active\n");
658 break;
659 case 0x0A:
660 dev_warn(&device->cdev->dev,
661 "FORMAT 4 - Key area error; offset "
662 "active\n");
663 break;
664 case 0x0B:
665 dev_warn(&device->cdev->dev,
666 "FORMAT 4 - Data area error; "
667 "offset active\n");
668 break;
669 case 0x0C:
670 dev_warn(&device->cdev->dev,
671 "FORMAT 4 - No sync byte in home "
672 "address area; offset active\n");
673 break;
674 case 0x0D:
675 dev_warn(&device->cdev->dev,
676 "FORMAT 4 - No syn byte in count "
677 "address area; offset active\n");
678 break;
679 case 0x0E:
680 dev_warn(&device->cdev->dev,
681 "FORMAT 4 - No sync byte in key area; "
682 "offset active\n");
683 break;
684 case 0x0F:
685 dev_warn(&device->cdev->dev,
686 "FORMAT 4 - No syn byte in data area; "
687 "offset active\n");
688 break;
689 default:
690 dev_warn(&device->cdev->dev,
691 "FORMAT 4 - Reserved\n");
693 break;
695 case 0x50: /* Format 5 - Data Check with displacement information */
696 switch (msg_no) {
697 case 0x00:
698 dev_warn(&device->cdev->dev,
699 "FORMAT 5 - Data Check in the "
700 "home address area\n");
701 break;
702 case 0x01:
703 dev_warn(&device->cdev->dev,
704 "FORMAT 5 - Data Check in the count "
705 "area\n");
706 break;
707 case 0x02:
708 dev_warn(&device->cdev->dev,
709 "FORMAT 5 - Data Check in the key area\n");
710 break;
711 case 0x03:
712 dev_warn(&device->cdev->dev,
713 "FORMAT 5 - Data Check in the data "
714 "area\n");
715 break;
716 case 0x08:
717 dev_warn(&device->cdev->dev,
718 "FORMAT 5 - Data Check in the "
719 "home address area; offset active\n");
720 break;
721 case 0x09:
722 dev_warn(&device->cdev->dev,
723 "FORMAT 5 - Data Check in the count area; "
724 "offset active\n");
725 break;
726 case 0x0A:
727 dev_warn(&device->cdev->dev,
728 "FORMAT 5 - Data Check in the key area; "
729 "offset active\n");
730 break;
731 case 0x0B:
732 dev_warn(&device->cdev->dev,
733 "FORMAT 5 - Data Check in the data area; "
734 "offset active\n");
735 break;
736 default:
737 dev_warn(&device->cdev->dev,
738 "FORMAT 5 - Reserved\n");
740 break;
742 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
743 switch (msg_no) {
744 case 0x00:
745 dev_warn(&device->cdev->dev,
746 "FORMAT 6 - Overrun on channel A\n");
747 break;
748 case 0x01:
749 dev_warn(&device->cdev->dev,
750 "FORMAT 6 - Overrun on channel B\n");
751 break;
752 case 0x02:
753 dev_warn(&device->cdev->dev,
754 "FORMAT 6 - Overrun on channel C\n");
755 break;
756 case 0x03:
757 dev_warn(&device->cdev->dev,
758 "FORMAT 6 - Overrun on channel D\n");
759 break;
760 case 0x04:
761 dev_warn(&device->cdev->dev,
762 "FORMAT 6 - Overrun on channel E\n");
763 break;
764 case 0x05:
765 dev_warn(&device->cdev->dev,
766 "FORMAT 6 - Overrun on channel F\n");
767 break;
768 case 0x06:
769 dev_warn(&device->cdev->dev,
770 "FORMAT 6 - Overrun on channel G\n");
771 break;
772 case 0x07:
773 dev_warn(&device->cdev->dev,
774 "FORMAT 6 - Overrun on channel H\n");
775 break;
776 default:
777 dev_warn(&device->cdev->dev,
778 "FORMAT 6 - Reserved\n");
780 break;
782 case 0x70: /* Format 7 - Device Connection Control Checks */
783 switch (msg_no) {
784 case 0x00:
785 dev_warn(&device->cdev->dev,
786 "FORMAT 7 - RCC initiated by a connection "
787 "check alert\n");
788 break;
789 case 0x01:
790 dev_warn(&device->cdev->dev,
791 "FORMAT 7 - RCC 1 sequence not "
792 "successful\n");
793 break;
794 case 0x02:
795 dev_warn(&device->cdev->dev,
796 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
797 "successful\n");
798 break;
799 case 0x03:
800 dev_warn(&device->cdev->dev,
801 "FORMAT 7 - Invalid tag-in during "
802 "selection sequence\n");
803 break;
804 case 0x04:
805 dev_warn(&device->cdev->dev,
806 "FORMAT 7 - extra RCC required\n");
807 break;
808 case 0x05:
809 dev_warn(&device->cdev->dev,
810 "FORMAT 7 - Invalid DCC selection "
811 "response or timeout\n");
812 break;
813 case 0x06:
814 dev_warn(&device->cdev->dev,
815 "FORMAT 7 - Missing end operation; device "
816 "transfer complete\n");
817 break;
818 case 0x07:
819 dev_warn(&device->cdev->dev,
820 "FORMAT 7 - Missing end operation; device "
821 "transfer incomplete\n");
822 break;
823 case 0x08:
824 dev_warn(&device->cdev->dev,
825 "FORMAT 7 - Invalid tag-in for an "
826 "immediate command sequence\n");
827 break;
828 case 0x09:
829 dev_warn(&device->cdev->dev,
830 "FORMAT 7 - Invalid tag-in for an "
831 "extended command sequence\n");
832 break;
833 case 0x0A:
834 dev_warn(&device->cdev->dev,
835 "FORMAT 7 - 3990 microcode time out when "
836 "stopping selection\n");
837 break;
838 case 0x0B:
839 dev_warn(&device->cdev->dev,
840 "FORMAT 7 - No response to selection "
841 "after a poll interruption\n");
842 break;
843 case 0x0C:
844 dev_warn(&device->cdev->dev,
845 "FORMAT 7 - Permanent path error (DASD "
846 "controller not available)\n");
847 break;
848 case 0x0D:
849 dev_warn(&device->cdev->dev,
850 "FORMAT 7 - DASD controller not available"
851 " on disconnected command chain\n");
852 break;
853 default:
854 dev_warn(&device->cdev->dev,
855 "FORMAT 7 - Reserved\n");
857 break;
859 case 0x80: /* Format 8 - Additional Device Equipment Checks */
860 switch (msg_no) {
861 case 0x00: /* No Message */
862 case 0x01:
863 dev_warn(&device->cdev->dev,
864 "FORMAT 8 - Error correction code "
865 "hardware fault\n");
866 break;
867 case 0x03:
868 dev_warn(&device->cdev->dev,
869 "FORMAT 8 - Unexpected end operation "
870 "response code\n");
871 break;
872 case 0x04:
873 dev_warn(&device->cdev->dev,
874 "FORMAT 8 - End operation with transfer "
875 "count not zero\n");
876 break;
877 case 0x05:
878 dev_warn(&device->cdev->dev,
879 "FORMAT 8 - End operation with transfer "
880 "count zero\n");
881 break;
882 case 0x06:
883 dev_warn(&device->cdev->dev,
884 "FORMAT 8 - DPS checks after a system "
885 "reset or selective reset\n");
886 break;
887 case 0x07:
888 dev_warn(&device->cdev->dev,
889 "FORMAT 8 - DPS cannot be filled\n");
890 break;
891 case 0x08:
892 dev_warn(&device->cdev->dev,
893 "FORMAT 8 - Short busy time-out during "
894 "device selection\n");
895 break;
896 case 0x09:
897 dev_warn(&device->cdev->dev,
898 "FORMAT 8 - DASD controller failed to "
899 "set or reset the long busy latch\n");
900 break;
901 case 0x0A:
902 dev_warn(&device->cdev->dev,
903 "FORMAT 8 - No interruption from device "
904 "during a command chain\n");
905 break;
906 default:
907 dev_warn(&device->cdev->dev,
908 "FORMAT 8 - Reserved\n");
910 break;
912 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
913 switch (msg_no) {
914 case 0x00:
915 break; /* No Message */
916 case 0x06:
917 dev_warn(&device->cdev->dev,
918 "FORMAT 9 - Device check-2 error\n");
919 break;
920 case 0x07:
921 dev_warn(&device->cdev->dev,
922 "FORMAT 9 - Head address did not "
923 "compare\n");
924 break;
925 case 0x0A:
926 dev_warn(&device->cdev->dev,
927 "FORMAT 9 - Track physical address did "
928 "not compare while oriented\n");
929 break;
930 case 0x0E:
931 dev_warn(&device->cdev->dev,
932 "FORMAT 9 - Cylinder address did not "
933 "compare\n");
934 break;
935 default:
936 dev_warn(&device->cdev->dev,
937 "FORMAT 9 - Reserved\n");
939 break;
941 case 0xF0: /* Format F - Cache Storage Checks */
942 switch (msg_no) {
943 case 0x00:
944 dev_warn(&device->cdev->dev,
945 "FORMAT F - Operation Terminated\n");
946 break;
947 case 0x01:
948 dev_warn(&device->cdev->dev,
949 "FORMAT F - Subsystem Processing Error\n");
950 break;
951 case 0x02:
952 dev_warn(&device->cdev->dev,
953 "FORMAT F - Cache or nonvolatile storage "
954 "equipment failure\n");
955 break;
956 case 0x04:
957 dev_warn(&device->cdev->dev,
958 "FORMAT F - Caching terminated\n");
959 break;
960 case 0x06:
961 dev_warn(&device->cdev->dev,
962 "FORMAT F - Cache fast write access not "
963 "authorized\n");
964 break;
965 case 0x07:
966 dev_warn(&device->cdev->dev,
967 "FORMAT F - Track format incorrect\n");
968 break;
969 case 0x09:
970 dev_warn(&device->cdev->dev,
971 "FORMAT F - Caching reinitiated\n");
972 break;
973 case 0x0A:
974 dev_warn(&device->cdev->dev,
975 "FORMAT F - Nonvolatile storage "
976 "terminated\n");
977 break;
978 case 0x0B:
979 dev_warn(&device->cdev->dev,
980 "FORMAT F - Volume is suspended duplex\n");
981 /* call extended error reporting (EER) */
982 dasd_eer_write(device, erp->refers,
983 DASD_EER_PPRCSUSPEND);
984 break;
985 case 0x0C:
986 dev_warn(&device->cdev->dev,
987 "FORMAT F - Subsystem status cannot be "
988 "determined\n");
989 break;
990 case 0x0D:
991 dev_warn(&device->cdev->dev,
992 "FORMAT F - Caching status reset to "
993 "default\n");
994 break;
995 case 0x0E:
996 dev_warn(&device->cdev->dev,
997 "FORMAT F - DASD Fast Write inhibited\n");
998 break;
999 default:
1000 dev_warn(&device->cdev->dev,
1001 "FORMAT D - Reserved\n");
1003 break;
1005 default: /* unknown message format - should not happen
1006 internal error 03 - unknown message format */
1007 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
1008 dev_err(&device->cdev->dev,
1009 "An error occurred in the DASD device driver, "
1010 "reason=%s\n", errorstring);
1011 break;
1012 } /* end switch message format */
1014 } /* end dasd_3990_handle_env_data */
1017 * DASD_3990_ERP_COM_REJ
1019 * DESCRIPTION
1020 * Handles 24 byte 'Command Reject' error.
1022 * PARAMETER
1023 * erp current erp_head
1024 * sense current sense data
1026 * RETURN VALUES
1027 * erp 'new' erp_head - pointer to new ERP
1029 static struct dasd_ccw_req *
1030 dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1033 struct dasd_device *device = erp->startdev;
1035 erp->function = dasd_3990_erp_com_rej;
1037 /* env data present (ACTION 10 - retry should work) */
1038 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1040 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1041 "Command Reject - environmental data present");
1043 dasd_3990_handle_env_data(erp, sense);
1045 erp->retries = 5;
1047 } else if (sense[1] & SNS1_WRITE_INHIBITED) {
1048 dev_err(&device->cdev->dev, "An I/O request was rejected"
1049 " because writing is inhibited\n");
1050 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1051 } else {
1052 /* fatal error - set status to FAILED
1053 internal error 09 - Command Reject */
1054 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1055 "device driver, reason=%s\n", "09");
1057 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1060 return erp;
1062 } /* end dasd_3990_erp_com_rej */
1065 * DASD_3990_ERP_BUS_OUT
1067 * DESCRIPTION
1068 * Handles 24 byte 'Bus Out Parity Check' error.
1070 * PARAMETER
1071 * erp current erp_head
1072 * RETURN VALUES
1073 * erp new erp_head - pointer to new ERP
1075 static struct dasd_ccw_req *
1076 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1079 struct dasd_device *device = erp->startdev;
1081 /* first time set initial retry counter and erp_function */
1082 /* and retry once without blocking queue */
1083 /* (this enables easier enqueing of the cqr) */
1084 if (erp->function != dasd_3990_erp_bus_out) {
1085 erp->retries = 256;
1086 erp->function = dasd_3990_erp_bus_out;
1088 } else {
1090 /* issue a message and wait for 'device ready' interrupt */
1091 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1092 "bus out parity error or BOPC requested by "
1093 "channel");
1095 dasd_3990_erp_block_queue(erp, 60*HZ);
1099 return erp;
1101 } /* end dasd_3990_erp_bus_out */
1104 * DASD_3990_ERP_EQUIP_CHECK
1106 * DESCRIPTION
1107 * Handles 24 byte 'Equipment Check' error.
1109 * PARAMETER
1110 * erp current erp_head
1111 * RETURN VALUES
1112 * erp new erp_head - pointer to new ERP
1114 static struct dasd_ccw_req *
1115 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1118 struct dasd_device *device = erp->startdev;
1120 erp->function = dasd_3990_erp_equip_check;
1122 if (sense[1] & SNS1_WRITE_INHIBITED) {
1123 dev_info(&device->cdev->dev,
1124 "Write inhibited path encountered\n");
1126 /* vary path offline
1127 internal error 04 - Path should be varied off-line.*/
1128 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1129 "device driver, reason=%s\n", "04");
1131 erp = dasd_3990_erp_action_1(erp);
1133 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1135 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1136 "Equipment Check - " "environmental data present");
1138 dasd_3990_handle_env_data(erp, sense);
1140 erp = dasd_3990_erp_action_4(erp, sense);
1142 } else if (sense[1] & SNS1_PERM_ERR) {
1144 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1145 "Equipment Check - retry exhausted or "
1146 "undesirable");
1148 erp = dasd_3990_erp_action_1(erp);
1150 } else {
1151 /* all other equipment checks - Action 5 */
1152 /* rest is done when retries == 0 */
1153 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1154 "Equipment check or processing error");
1156 erp = dasd_3990_erp_action_5(erp);
1158 return erp;
1160 } /* end dasd_3990_erp_equip_check */
1163 * DASD_3990_ERP_DATA_CHECK
1165 * DESCRIPTION
1166 * Handles 24 byte 'Data Check' error.
1168 * PARAMETER
1169 * erp current erp_head
1170 * RETURN VALUES
1171 * erp new erp_head - pointer to new ERP
1173 static struct dasd_ccw_req *
1174 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1177 struct dasd_device *device = erp->startdev;
1179 erp->function = dasd_3990_erp_data_check;
1181 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1183 /* issue message that the data has been corrected */
1184 dev_emerg(&device->cdev->dev,
1185 "Data recovered during retry with PCI "
1186 "fetch mode active\n");
1188 /* not possible to handle this situation in Linux */
1189 panic("No way to inform application about the possibly "
1190 "incorrect data");
1192 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1194 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1195 "Uncorrectable data check recovered secondary "
1196 "addr of duplex pair");
1198 erp = dasd_3990_erp_action_4(erp, sense);
1200 } else if (sense[1] & SNS1_PERM_ERR) {
1202 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1203 "Uncorrectable data check with internal "
1204 "retry exhausted");
1206 erp = dasd_3990_erp_action_1(erp);
1208 } else {
1209 /* all other data checks */
1210 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1211 "Uncorrectable data check with retry count "
1212 "exhausted...");
1214 erp = dasd_3990_erp_action_5(erp);
1217 return erp;
1219 } /* end dasd_3990_erp_data_check */
1222 * DASD_3990_ERP_OVERRUN
1224 * DESCRIPTION
1225 * Handles 24 byte 'Overrun' error.
1227 * PARAMETER
1228 * erp current erp_head
1229 * RETURN VALUES
1230 * erp new erp_head - pointer to new ERP
1232 static struct dasd_ccw_req *
1233 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1236 struct dasd_device *device = erp->startdev;
1238 erp->function = dasd_3990_erp_overrun;
1240 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1241 "Overrun - service overrun or overrun"
1242 " error requested by channel");
1244 erp = dasd_3990_erp_action_5(erp);
1246 return erp;
1248 } /* end dasd_3990_erp_overrun */
1251 * DASD_3990_ERP_INV_FORMAT
1253 * DESCRIPTION
1254 * Handles 24 byte 'Invalid Track Format' error.
1256 * PARAMETER
1257 * erp current erp_head
1258 * RETURN VALUES
1259 * erp new erp_head - pointer to new ERP
1261 static struct dasd_ccw_req *
1262 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1265 struct dasd_device *device = erp->startdev;
1267 erp->function = dasd_3990_erp_inv_format;
1269 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1271 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1272 "Track format error when destaging or "
1273 "staging data");
1275 dasd_3990_handle_env_data(erp, sense);
1277 erp = dasd_3990_erp_action_4(erp, sense);
1279 } else {
1280 /* internal error 06 - The track format is not valid*/
1281 dev_err(&device->cdev->dev,
1282 "An error occurred in the DASD device driver, "
1283 "reason=%s\n", "06");
1285 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1288 return erp;
1290 } /* end dasd_3990_erp_inv_format */
1293 * DASD_3990_ERP_EOC
1295 * DESCRIPTION
1296 * Handles 24 byte 'End-of-Cylinder' error.
1298 * PARAMETER
1299 * erp already added default erp
1300 * RETURN VALUES
1301 * erp pointer to original (failed) cqr.
1303 static struct dasd_ccw_req *
1304 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1307 struct dasd_device *device = default_erp->startdev;
1309 dev_err(&device->cdev->dev,
1310 "The cylinder data for accessing the DASD is inconsistent\n");
1312 /* implement action 7 - BUG */
1313 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1315 } /* end dasd_3990_erp_EOC */
1318 * DASD_3990_ERP_ENV_DATA
1320 * DESCRIPTION
1321 * Handles 24 byte 'Environmental-Data Present' error.
1323 * PARAMETER
1324 * erp current erp_head
1325 * RETURN VALUES
1326 * erp new erp_head - pointer to new ERP
1328 static struct dasd_ccw_req *
1329 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1332 struct dasd_device *device = erp->startdev;
1334 erp->function = dasd_3990_erp_env_data;
1336 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
1338 dasd_3990_handle_env_data(erp, sense);
1340 /* don't retry on disabled interface */
1341 if (sense[7] != 0x0F) {
1342 erp = dasd_3990_erp_action_4(erp, sense);
1343 } else {
1344 erp->status = DASD_CQR_FILLED;
1347 return erp;
1349 } /* end dasd_3990_erp_env_data */
1352 * DASD_3990_ERP_NO_REC
1354 * DESCRIPTION
1355 * Handles 24 byte 'No Record Found' error.
1357 * PARAMETER
1358 * erp already added default ERP
1360 * RETURN VALUES
1361 * erp new erp_head - pointer to new ERP
1363 static struct dasd_ccw_req *
1364 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1367 struct dasd_device *device = default_erp->startdev;
1369 dev_err(&device->cdev->dev,
1370 "The specified record was not found\n");
1372 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1374 } /* end dasd_3990_erp_no_rec */
1377 * DASD_3990_ERP_FILE_PROT
1379 * DESCRIPTION
1380 * Handles 24 byte 'File Protected' error.
1381 * Note: Seek related recovery is not implemented because
1382 * wee don't use the seek command yet.
1384 * PARAMETER
1385 * erp current erp_head
1386 * RETURN VALUES
1387 * erp new erp_head - pointer to new ERP
1389 static struct dasd_ccw_req *
1390 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1393 struct dasd_device *device = erp->startdev;
1395 dev_err(&device->cdev->dev, "Accessing the DASD failed because of "
1396 "a hardware error\n");
1398 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1400 } /* end dasd_3990_erp_file_prot */
1403 * DASD_3990_ERP_INSPECT_ALIAS
1405 * DESCRIPTION
1406 * Checks if the original request was started on an alias device.
1407 * If yes, it modifies the original and the erp request so that
1408 * the erp request can be started on a base device.
1410 * PARAMETER
1411 * erp pointer to the currently created default ERP
1413 * RETURN VALUES
1414 * erp pointer to the modified ERP, or NULL
1417 static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1418 struct dasd_ccw_req *erp)
1420 struct dasd_ccw_req *cqr = erp->refers;
1421 char *sense;
1423 if (cqr->block &&
1424 (cqr->block->base != cqr->startdev)) {
1426 sense = dasd_get_sense(&erp->refers->irb);
1428 * dynamic pav may have changed base alias mapping
1430 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
1431 && (sense[0] == 0x10) && (sense[7] == 0x0F)
1432 && (sense[8] == 0x67)) {
1434 * remove device from alias handling to prevent new
1435 * requests from being scheduled on the
1436 * wrong alias device
1438 dasd_alias_remove_device(cqr->startdev);
1440 /* schedule worker to reload device */
1441 dasd_reload_device(cqr->startdev);
1444 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
1445 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
1446 "ERP on alias device for request %p,"
1447 " recover on base device %s", cqr,
1448 dev_name(&cqr->block->base->cdev->dev));
1450 dasd_eckd_reset_ccw_to_base_io(cqr);
1451 erp->startdev = cqr->block->base;
1452 erp->function = dasd_3990_erp_inspect_alias;
1453 return erp;
1454 } else
1455 return NULL;
1460 * DASD_3990_ERP_INSPECT_24
1462 * DESCRIPTION
1463 * Does a detailed inspection of the 24 byte sense data
1464 * and sets up a related error recovery action.
1466 * PARAMETER
1467 * sense sense data of the actual error
1468 * erp pointer to the currently created default ERP
1470 * RETURN VALUES
1471 * erp pointer to the (addtitional) ERP
1473 static struct dasd_ccw_req *
1474 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1477 struct dasd_ccw_req *erp_filled = NULL;
1479 /* Check sense for .... */
1480 /* 'Command Reject' */
1481 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1482 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1484 /* 'Intervention Required' */
1485 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1486 erp_filled = dasd_3990_erp_int_req(erp);
1488 /* 'Bus Out Parity Check' */
1489 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1490 erp_filled = dasd_3990_erp_bus_out(erp);
1492 /* 'Equipment Check' */
1493 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1494 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1496 /* 'Data Check' */
1497 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1498 erp_filled = dasd_3990_erp_data_check(erp, sense);
1500 /* 'Overrun' */
1501 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1502 erp_filled = dasd_3990_erp_overrun(erp, sense);
1504 /* 'Invalid Track Format' */
1505 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1506 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1508 /* 'End-of-Cylinder' */
1509 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1510 erp_filled = dasd_3990_erp_EOC(erp, sense);
1512 /* 'Environmental Data' */
1513 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1514 erp_filled = dasd_3990_erp_env_data(erp, sense);
1516 /* 'No Record Found' */
1517 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1518 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1520 /* 'File Protected' */
1521 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1522 erp_filled = dasd_3990_erp_file_prot(erp);
1524 /* other (unknown) error - do default ERP */
1525 if (erp_filled == NULL) {
1527 erp_filled = erp;
1530 return erp_filled;
1532 } /* END dasd_3990_erp_inspect_24 */
1535 *****************************************************************************
1536 * 32 byte sense ERP functions (only)
1537 *****************************************************************************
1541 * DASD_3990_ERPACTION_10_32
1543 * DESCRIPTION
1544 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1545 * Just retry and if retry doesn't work, return with error.
1547 * PARAMETER
1548 * erp current erp_head
1549 * sense current sense data
1550 * RETURN VALUES
1551 * erp modified erp_head
1553 static struct dasd_ccw_req *
1554 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1557 struct dasd_device *device = erp->startdev;
1559 erp->retries = 256;
1560 erp->function = dasd_3990_erp_action_10_32;
1562 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
1564 return erp;
1566 } /* end dasd_3990_erp_action_10_32 */
1569 * DASD_3990_ERP_ACTION_1B_32
1571 * DESCRIPTION
1572 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1573 * A write operation could not be finished because of an unexpected
1574 * condition.
1575 * The already created 'default erp' is used to get the link to
1576 * the erp chain, but it can not be used for this recovery
1577 * action because it contains no DE/LO data space.
1579 * PARAMETER
1580 * default_erp already added default erp.
1581 * sense current sense data
1583 * RETURN VALUES
1584 * erp new erp or
1585 * default_erp in case of imprecise ending or error
1587 static struct dasd_ccw_req *
1588 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1591 struct dasd_device *device = default_erp->startdev;
1592 __u32 cpa = 0;
1593 struct dasd_ccw_req *cqr;
1594 struct dasd_ccw_req *erp;
1595 struct DE_eckd_data *DE_data;
1596 struct PFX_eckd_data *PFX_data;
1597 char *LO_data; /* LO_eckd_data_t */
1598 struct ccw1 *ccw, *oldccw;
1600 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1601 "Write not finished because of unexpected condition");
1603 default_erp->function = dasd_3990_erp_action_1B_32;
1605 /* determine the original cqr */
1606 cqr = default_erp;
1608 while (cqr->refers != NULL) {
1609 cqr = cqr->refers;
1612 if (scsw_is_tm(&cqr->irb.scsw)) {
1613 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1614 "32 bit sense, action 1B is not defined"
1615 " in transport mode - just retry");
1616 return default_erp;
1619 /* for imprecise ending just do default erp */
1620 if (sense[1] & 0x01) {
1621 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1622 "Imprecise ending is set - just retry");
1624 return default_erp;
1627 /* determine the address of the CCW to be restarted */
1628 /* Imprecise ending is not set -> addr from IRB-SCSW */
1629 cpa = default_erp->refers->irb.scsw.cmd.cpa;
1631 if (cpa == 0) {
1632 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1633 "Unable to determine address of the CCW "
1634 "to be restarted");
1636 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1639 /* Build new ERP request including DE/LO */
1640 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1641 2 + 1,/* DE/LO + TIC */
1642 sizeof(struct DE_eckd_data) +
1643 sizeof(struct LO_eckd_data), device);
1645 if (IS_ERR(erp)) {
1646 /* internal error 01 - Unable to allocate ERP */
1647 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1648 "device driver, reason=%s\n", "01");
1649 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1652 /* use original DE */
1653 DE_data = erp->data;
1654 oldccw = cqr->cpaddr;
1655 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1656 PFX_data = cqr->data;
1657 memcpy(DE_data, &PFX_data->define_extent,
1658 sizeof(struct DE_eckd_data));
1659 } else
1660 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
1662 /* create LO */
1663 LO_data = erp->data + sizeof(struct DE_eckd_data);
1665 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1666 /* should not */
1667 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1670 if ((sense[7] & 0x3F) == 0x01) {
1671 /* operation code is WRITE DATA -> data area orientation */
1672 LO_data[0] = 0x81;
1674 } else if ((sense[7] & 0x3F) == 0x03) {
1675 /* operation code is FORMAT WRITE -> index orientation */
1676 LO_data[0] = 0xC3;
1678 } else {
1679 LO_data[0] = sense[7]; /* operation */
1682 LO_data[1] = sense[8]; /* auxiliary */
1683 LO_data[2] = sense[9];
1684 LO_data[3] = sense[3]; /* count */
1685 LO_data[4] = sense[29]; /* seek_addr.cyl */
1686 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1687 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1689 memcpy(&(LO_data[8]), &(sense[11]), 8);
1691 /* create DE ccw */
1692 ccw = erp->cpaddr;
1693 memset(ccw, 0, sizeof(struct ccw1));
1694 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1695 ccw->flags = CCW_FLAG_CC;
1696 ccw->count = 16;
1697 ccw->cda = (__u32)(addr_t) DE_data;
1699 /* create LO ccw */
1700 ccw++;
1701 memset(ccw, 0, sizeof(struct ccw1));
1702 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1703 ccw->flags = CCW_FLAG_CC;
1704 ccw->count = 16;
1705 ccw->cda = (__u32)(addr_t) LO_data;
1707 /* TIC to the failed ccw */
1708 ccw++;
1709 ccw->cmd_code = CCW_CMD_TIC;
1710 ccw->cda = cpa;
1712 /* fill erp related fields */
1713 erp->function = dasd_3990_erp_action_1B_32;
1714 erp->refers = default_erp->refers;
1715 erp->startdev = device;
1716 erp->memdev = device;
1717 erp->magic = default_erp->magic;
1718 erp->expires = 0;
1719 erp->retries = 256;
1720 erp->buildclk = get_clock();
1721 erp->status = DASD_CQR_FILLED;
1723 /* remove the default erp */
1724 dasd_free_erp_request(default_erp, device);
1726 return erp;
1728 } /* end dasd_3990_erp_action_1B_32 */
1731 * DASD_3990_UPDATE_1B
1733 * DESCRIPTION
1734 * Handles the update to the 32 byte 'Action 1B' of Single Program
1735 * Action Codes in case the first action was not successful.
1736 * The already created 'previous_erp' is the currently not successful
1737 * ERP.
1739 * PARAMETER
1740 * previous_erp already created previous erp.
1741 * sense current sense data
1742 * RETURN VALUES
1743 * erp modified erp
1745 static struct dasd_ccw_req *
1746 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1749 struct dasd_device *device = previous_erp->startdev;
1750 __u32 cpa = 0;
1751 struct dasd_ccw_req *cqr;
1752 struct dasd_ccw_req *erp;
1753 char *LO_data; /* struct LO_eckd_data */
1754 struct ccw1 *ccw;
1756 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1757 "Write not finished because of unexpected condition"
1758 " - follow on");
1760 /* determine the original cqr */
1761 cqr = previous_erp;
1763 while (cqr->refers != NULL) {
1764 cqr = cqr->refers;
1767 if (scsw_is_tm(&cqr->irb.scsw)) {
1768 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1769 "32 bit sense, action 1B, update,"
1770 " in transport mode - just retry");
1771 return previous_erp;
1774 /* for imprecise ending just do default erp */
1775 if (sense[1] & 0x01) {
1776 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1777 "Imprecise ending is set - just retry");
1779 previous_erp->status = DASD_CQR_FILLED;
1781 return previous_erp;
1784 /* determine the address of the CCW to be restarted */
1785 /* Imprecise ending is not set -> addr from IRB-SCSW */
1786 cpa = previous_erp->irb.scsw.cmd.cpa;
1788 if (cpa == 0) {
1789 /* internal error 02 -
1790 Unable to determine address of the CCW to be restarted */
1791 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1792 "device driver, reason=%s\n", "02");
1794 previous_erp->status = DASD_CQR_FAILED;
1796 return previous_erp;
1799 erp = previous_erp;
1801 /* update the LO with the new returned sense data */
1802 LO_data = erp->data + sizeof(struct DE_eckd_data);
1804 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1805 /* should not happen */
1806 previous_erp->status = DASD_CQR_FAILED;
1808 return previous_erp;
1811 if ((sense[7] & 0x3F) == 0x01) {
1812 /* operation code is WRITE DATA -> data area orientation */
1813 LO_data[0] = 0x81;
1815 } else if ((sense[7] & 0x3F) == 0x03) {
1816 /* operation code is FORMAT WRITE -> index orientation */
1817 LO_data[0] = 0xC3;
1819 } else {
1820 LO_data[0] = sense[7]; /* operation */
1823 LO_data[1] = sense[8]; /* auxiliary */
1824 LO_data[2] = sense[9];
1825 LO_data[3] = sense[3]; /* count */
1826 LO_data[4] = sense[29]; /* seek_addr.cyl */
1827 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1828 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1830 memcpy(&(LO_data[8]), &(sense[11]), 8);
1832 /* TIC to the failed ccw */
1833 ccw = erp->cpaddr; /* addr of DE ccw */
1834 ccw++; /* addr of LE ccw */
1835 ccw++; /* addr of TIC ccw */
1836 ccw->cda = cpa;
1838 erp->status = DASD_CQR_FILLED;
1840 return erp;
1842 } /* end dasd_3990_update_1B */
1845 * DASD_3990_ERP_COMPOUND_RETRY
1847 * DESCRIPTION
1848 * Handles the compound ERP action retry code.
1849 * NOTE: At least one retry is done even if zero is specified
1850 * by the sense data. This makes enqueueing of the request
1851 * easier.
1853 * PARAMETER
1854 * sense sense data of the actual error
1855 * erp pointer to the currently created ERP
1857 * RETURN VALUES
1858 * erp modified ERP pointer
1861 static void
1862 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1865 switch (sense[25] & 0x03) {
1866 case 0x00: /* no not retry */
1867 erp->retries = 1;
1868 break;
1870 case 0x01: /* retry 2 times */
1871 erp->retries = 2;
1872 break;
1874 case 0x02: /* retry 10 times */
1875 erp->retries = 10;
1876 break;
1878 case 0x03: /* retry 256 times */
1879 erp->retries = 256;
1880 break;
1882 default:
1883 BUG();
1886 erp->function = dasd_3990_erp_compound_retry;
1888 } /* end dasd_3990_erp_compound_retry */
1891 * DASD_3990_ERP_COMPOUND_PATH
1893 * DESCRIPTION
1894 * Handles the compound ERP action for retry on alternate
1895 * channel path.
1897 * PARAMETER
1898 * sense sense data of the actual error
1899 * erp pointer to the currently created ERP
1901 * RETURN VALUES
1902 * erp modified ERP pointer
1905 static void
1906 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1909 if (sense[25] & DASD_SENSE_BIT_3) {
1910 dasd_3990_erp_alternate_path(erp);
1912 if (erp->status == DASD_CQR_FAILED) {
1913 /* reset the lpm and the status to be able to
1914 * try further actions. */
1916 erp->lpm = 0;
1917 erp->status = DASD_CQR_NEED_ERP;
1921 erp->function = dasd_3990_erp_compound_path;
1923 } /* end dasd_3990_erp_compound_path */
1926 * DASD_3990_ERP_COMPOUND_CODE
1928 * DESCRIPTION
1929 * Handles the compound ERP action for retry code.
1931 * PARAMETER
1932 * sense sense data of the actual error
1933 * erp pointer to the currently created ERP
1935 * RETURN VALUES
1936 * erp NEW ERP pointer
1939 static struct dasd_ccw_req *
1940 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1943 if (sense[25] & DASD_SENSE_BIT_2) {
1945 switch (sense[28]) {
1946 case 0x17:
1947 /* issue a Diagnostic Control command with an
1948 * Inhibit Write subcommand and controller modifier */
1949 erp = dasd_3990_erp_DCTL(erp, 0x20);
1950 break;
1952 case 0x25:
1953 /* wait for 5 seconds and retry again */
1954 erp->retries = 1;
1956 dasd_3990_erp_block_queue (erp, 5*HZ);
1957 break;
1959 default:
1960 /* should not happen - continue */
1961 break;
1965 erp->function = dasd_3990_erp_compound_code;
1967 return erp;
1969 } /* end dasd_3990_erp_compound_code */
1972 * DASD_3990_ERP_COMPOUND_CONFIG
1974 * DESCRIPTION
1975 * Handles the compound ERP action for configruation
1976 * dependent error.
1977 * Note: duplex handling is not implemented (yet).
1979 * PARAMETER
1980 * sense sense data of the actual error
1981 * erp pointer to the currently created ERP
1983 * RETURN VALUES
1984 * erp modified ERP pointer
1987 static void
1988 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
1991 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
1993 /* set to suspended duplex state then restart
1994 internal error 05 - Set device to suspended duplex state
1995 should be done */
1996 struct dasd_device *device = erp->startdev;
1997 dev_err(&device->cdev->dev,
1998 "An error occurred in the DASD device driver, "
1999 "reason=%s\n", "05");
2003 erp->function = dasd_3990_erp_compound_config;
2005 } /* end dasd_3990_erp_compound_config */
2008 * DASD_3990_ERP_COMPOUND
2010 * DESCRIPTION
2011 * Does the further compound program action if
2012 * compound retry was not successful.
2014 * PARAMETER
2015 * sense sense data of the actual error
2016 * erp pointer to the current (failed) ERP
2018 * RETURN VALUES
2019 * erp (additional) ERP pointer
2022 static struct dasd_ccw_req *
2023 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2026 if ((erp->function == dasd_3990_erp_compound_retry) &&
2027 (erp->status == DASD_CQR_NEED_ERP)) {
2029 dasd_3990_erp_compound_path(erp, sense);
2032 if ((erp->function == dasd_3990_erp_compound_path) &&
2033 (erp->status == DASD_CQR_NEED_ERP)) {
2035 erp = dasd_3990_erp_compound_code(erp, sense);
2038 if ((erp->function == dasd_3990_erp_compound_code) &&
2039 (erp->status == DASD_CQR_NEED_ERP)) {
2041 dasd_3990_erp_compound_config(erp, sense);
2044 /* if no compound action ERP specified, the request failed */
2045 if (erp->status == DASD_CQR_NEED_ERP)
2046 erp->status = DASD_CQR_FAILED;
2048 return erp;
2050 } /* end dasd_3990_erp_compound */
2053 *DASD_3990_ERP_HANDLE_SIM
2055 *DESCRIPTION
2056 * inspects the SIM SENSE data and starts an appropriate action
2058 * PARAMETER
2059 * sense sense data of the actual error
2061 * RETURN VALUES
2062 * none
2064 void
2065 dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2067 /* print message according to log or message to operator mode */
2068 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
2069 /* print SIM SRC from RefCode */
2070 dev_err(&device->cdev->dev, "SIM - SRC: "
2071 "%02x%02x%02x%02x\n", sense[22],
2072 sense[23], sense[11], sense[12]);
2073 } else if (sense[24] & DASD_SIM_LOG) {
2074 /* print SIM SRC Refcode */
2075 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2076 "%02x%02x%02x%02x\n", sense[22],
2077 sense[23], sense[11], sense[12]);
2082 * DASD_3990_ERP_INSPECT_32
2084 * DESCRIPTION
2085 * Does a detailed inspection of the 32 byte sense data
2086 * and sets up a related error recovery action.
2088 * PARAMETER
2089 * sense sense data of the actual error
2090 * erp pointer to the currently created default ERP
2092 * RETURN VALUES
2093 * erp_filled pointer to the ERP
2096 static struct dasd_ccw_req *
2097 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2100 struct dasd_device *device = erp->startdev;
2102 erp->function = dasd_3990_erp_inspect_32;
2104 /* check for SIM sense data */
2105 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2106 dasd_3990_erp_handle_sim(device, sense);
2108 if (sense[25] & DASD_SENSE_BIT_0) {
2110 /* compound program action codes (byte25 bit 0 == '1') */
2111 dasd_3990_erp_compound_retry(erp, sense);
2113 } else {
2115 /* single program action codes (byte25 bit 0 == '0') */
2116 switch (sense[25]) {
2118 case 0x00: /* success - use default ERP for retries */
2119 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
2120 "ERP called for successful request"
2121 " - just retry");
2122 break;
2124 case 0x01: /* fatal error */
2125 dev_err(&device->cdev->dev,
2126 "ERP failed for the DASD\n");
2128 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2129 break;
2131 case 0x02: /* intervention required */
2132 case 0x03: /* intervention required during dual copy */
2133 erp = dasd_3990_erp_int_req(erp);
2134 break;
2136 case 0x0F: /* length mismatch during update write command
2137 internal error 08 - update write command error*/
2138 dev_err(&device->cdev->dev, "An error occurred in the "
2139 "DASD device driver, reason=%s\n", "08");
2141 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2142 break;
2144 case 0x10: /* logging required for other channel program */
2145 erp = dasd_3990_erp_action_10_32(erp, sense);
2146 break;
2148 case 0x15: /* next track outside defined extend
2149 internal error 07 - The next track is not
2150 within the defined storage extent */
2151 dev_err(&device->cdev->dev,
2152 "An error occurred in the DASD device driver, "
2153 "reason=%s\n", "07");
2155 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2156 break;
2158 case 0x1B: /* unexpected condition during write */
2160 erp = dasd_3990_erp_action_1B_32(erp, sense);
2161 break;
2163 case 0x1C: /* invalid data */
2164 dev_emerg(&device->cdev->dev,
2165 "Data recovered during retry with PCI "
2166 "fetch mode active\n");
2168 /* not possible to handle this situation in Linux */
2169 panic
2170 ("Invalid data - No way to inform application "
2171 "about the possibly incorrect data");
2172 break;
2174 case 0x1D: /* state-change pending */
2175 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2176 "A State change pending condition exists "
2177 "for the subsystem or device");
2179 erp = dasd_3990_erp_action_4(erp, sense);
2180 break;
2182 case 0x1E: /* busy */
2183 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2184 "Busy condition exists "
2185 "for the subsystem or device");
2186 erp = dasd_3990_erp_action_4(erp, sense);
2187 break;
2189 default: /* all others errors - default erp */
2190 break;
2194 return erp;
2196 } /* end dasd_3990_erp_inspect_32 */
2199 *****************************************************************************
2200 * main ERP control fuctions (24 and 32 byte sense)
2201 *****************************************************************************
2205 * DASD_3990_ERP_CONTROL_CHECK
2207 * DESCRIPTION
2208 * Does a generic inspection if a control check occured and sets up
2209 * the related error recovery procedure
2211 * PARAMETER
2212 * erp pointer to the currently created default ERP
2214 * RETURN VALUES
2215 * erp_filled pointer to the erp
2218 static struct dasd_ccw_req *
2219 dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2221 struct dasd_device *device = erp->startdev;
2223 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
2224 | SCHN_STAT_CHN_CTRL_CHK)) {
2225 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2226 "channel or interface control check");
2227 erp = dasd_3990_erp_action_4(erp, NULL);
2229 return erp;
2233 * DASD_3990_ERP_INSPECT
2235 * DESCRIPTION
2236 * Does a detailed inspection for sense data by calling either
2237 * the 24-byte or the 32-byte inspection routine.
2239 * PARAMETER
2240 * erp pointer to the currently created default ERP
2241 * RETURN VALUES
2242 * erp_new contens was possibly modified
2244 static struct dasd_ccw_req *
2245 dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
2248 struct dasd_ccw_req *erp_new = NULL;
2249 char *sense;
2251 /* if this problem occured on an alias retry on base */
2252 erp_new = dasd_3990_erp_inspect_alias(erp);
2253 if (erp_new)
2254 return erp_new;
2256 /* sense data are located in the refers record of the
2257 * already set up new ERP !
2258 * check if concurrent sens is available
2260 sense = dasd_get_sense(&erp->refers->irb);
2261 if (!sense)
2262 erp_new = dasd_3990_erp_control_check(erp);
2263 /* distinguish between 24 and 32 byte sense data */
2264 else if (sense[27] & DASD_SENSE_BIT_0) {
2266 /* inspect the 24 byte sense data */
2267 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2269 } else {
2271 /* inspect the 32 byte sense data */
2272 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2274 } /* end distinguish between 24 and 32 byte sense data */
2276 return erp_new;
2280 * DASD_3990_ERP_ADD_ERP
2282 * DESCRIPTION
2283 * This funtion adds an additional request block (ERP) to the head of
2284 * the given cqr (or erp).
2285 * For a command mode cqr the erp is initialized as an default erp
2286 * (retry TIC).
2287 * For transport mode we make a copy of the original TCW (points to
2288 * the original TCCB, TIDALs, etc.) but give it a fresh
2289 * TSB so the original sense data will not be changed.
2291 * PARAMETER
2292 * cqr head of the current ERP-chain (or single cqr if
2293 * first error)
2294 * RETURN VALUES
2295 * erp pointer to new ERP-chain head
2297 static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
2300 struct dasd_device *device = cqr->startdev;
2301 struct ccw1 *ccw;
2302 struct dasd_ccw_req *erp;
2303 int cplength, datasize;
2304 struct tcw *tcw;
2305 struct tsb *tsb;
2307 if (cqr->cpmode == 1) {
2308 cplength = 0;
2309 /* TCW needs to be 64 byte aligned, so leave enough room */
2310 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
2311 } else {
2312 cplength = 2;
2313 datasize = 0;
2316 /* allocate additional request block */
2317 erp = dasd_alloc_erp_request((char *) &cqr->magic,
2318 cplength, datasize, device);
2319 if (IS_ERR(erp)) {
2320 if (cqr->retries <= 0) {
2321 DBF_DEV_EVENT(DBF_ERR, device, "%s",
2322 "Unable to allocate ERP request");
2323 cqr->status = DASD_CQR_FAILED;
2324 cqr->stopclk = get_clock ();
2325 } else {
2326 DBF_DEV_EVENT(DBF_ERR, device,
2327 "Unable to allocate ERP request "
2328 "(%i retries left)",
2329 cqr->retries);
2330 dasd_block_set_timer(device->block, (HZ << 3));
2332 return erp;
2335 ccw = cqr->cpaddr;
2336 if (cqr->cpmode == 1) {
2337 /* make a shallow copy of the original tcw but set new tsb */
2338 erp->cpmode = 1;
2339 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2340 tcw = erp->cpaddr;
2341 tsb = (struct tsb *) &tcw[1];
2342 *tcw = *((struct tcw *)cqr->cpaddr);
2343 tcw->tsb = (long)tsb;
2344 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
2345 /* PSF cannot be chained from NOOP/TIC */
2346 erp->cpaddr = cqr->cpaddr;
2347 } else {
2348 /* initialize request with default TIC to current ERP/CQR */
2349 ccw = erp->cpaddr;
2350 ccw->cmd_code = CCW_CMD_NOOP;
2351 ccw->flags = CCW_FLAG_CC;
2352 ccw++;
2353 ccw->cmd_code = CCW_CMD_TIC;
2354 ccw->cda = (long)(cqr->cpaddr);
2357 erp->function = dasd_3990_erp_add_erp;
2358 erp->refers = cqr;
2359 erp->startdev = device;
2360 erp->memdev = device;
2361 erp->block = cqr->block;
2362 erp->magic = cqr->magic;
2363 erp->expires = 0;
2364 erp->retries = 256;
2365 erp->buildclk = get_clock();
2366 erp->status = DASD_CQR_FILLED;
2368 return erp;
2372 * DASD_3990_ERP_ADDITIONAL_ERP
2374 * DESCRIPTION
2375 * An additional ERP is needed to handle the current error.
2376 * Add ERP to the head of the ERP-chain containing the ERP processing
2377 * determined based on the sense data.
2379 * PARAMETER
2380 * cqr head of the current ERP-chain (or single cqr if
2381 * first error)
2383 * RETURN VALUES
2384 * erp pointer to new ERP-chain head
2386 static struct dasd_ccw_req *
2387 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2390 struct dasd_ccw_req *erp = NULL;
2392 /* add erp and initialize with default TIC */
2393 erp = dasd_3990_erp_add_erp(cqr);
2395 if (IS_ERR(erp))
2396 return erp;
2398 /* inspect sense, determine specific ERP if possible */
2399 if (erp != cqr) {
2401 erp = dasd_3990_erp_inspect(erp);
2404 return erp;
2406 } /* end dasd_3990_erp_additional_erp */
2409 * DASD_3990_ERP_ERROR_MATCH
2411 * DESCRIPTION
2412 * Check if the device status of the given cqr is the same.
2413 * This means that the failed CCW and the relevant sense data
2414 * must match.
2415 * I don't distinguish between 24 and 32 byte sense because in case of
2416 * 24 byte sense byte 25 and 27 is set as well.
2418 * PARAMETER
2419 * cqr1 first cqr, which will be compared with the
2420 * cqr2 second cqr.
2422 * RETURN VALUES
2423 * match 'boolean' for match found
2424 * returns 1 if match found, otherwise 0.
2426 static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2427 struct dasd_ccw_req *cqr2)
2429 char *sense1, *sense2;
2431 if (cqr1->startdev != cqr2->startdev)
2432 return 0;
2434 sense1 = dasd_get_sense(&cqr1->irb);
2435 sense2 = dasd_get_sense(&cqr2->irb);
2437 /* one request has sense data, the other not -> no match, return 0 */
2438 if (!sense1 != !sense2)
2439 return 0;
2440 /* no sense data in both cases -> check cstat for IFCC */
2441 if (!sense1 && !sense2) {
2442 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2443 SCHN_STAT_CHN_CTRL_CHK)) ==
2444 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2445 SCHN_STAT_CHN_CTRL_CHK)))
2446 return 1; /* match with ifcc*/
2448 /* check sense data; byte 0-2,25,27 */
2449 if (!(sense1 && sense2 &&
2450 (memcmp(sense1, sense2, 3) == 0) &&
2451 (sense1[27] == sense2[27]) &&
2452 (sense1[25] == sense2[25]))) {
2454 return 0; /* sense doesn't match */
2457 return 1; /* match */
2459 } /* end dasd_3990_erp_error_match */
2462 * DASD_3990_ERP_IN_ERP
2464 * DESCRIPTION
2465 * check if the current error already happened before.
2466 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2468 * PARAMETER
2469 * cqr failed cqr (either original cqr or already an erp)
2471 * RETURN VALUES
2472 * erp erp-pointer to the already defined error
2473 * recovery procedure OR
2474 * NULL if a 'new' error occurred.
2476 static struct dasd_ccw_req *
2477 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2480 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2481 *erp_match = NULL; /* save erp chain head */
2482 int match = 0; /* 'boolean' for matching error found */
2484 if (cqr->refers == NULL) { /* return if not in erp */
2485 return NULL;
2488 /* check the erp/cqr chain for current error */
2489 do {
2490 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2491 erp_match = cqr; /* save possible matching erp */
2492 cqr = cqr->refers; /* check next erp/cqr in queue */
2494 } while ((cqr->refers != NULL) && (!match));
2496 if (!match) {
2497 return NULL; /* no match was found */
2500 return erp_match; /* return address of matching erp */
2502 } /* END dasd_3990_erp_in_erp */
2505 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2507 * DESCRIPTION
2508 * No retry is left for the current ERP. Check what has to be done
2509 * with the ERP.
2510 * - do further defined ERP action or
2511 * - wait for interrupt or
2512 * - exit with permanent error
2514 * PARAMETER
2515 * erp ERP which is in progress with no retry left
2517 * RETURN VALUES
2518 * erp modified/additional ERP
2520 static struct dasd_ccw_req *
2521 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2524 struct dasd_device *device = erp->startdev;
2525 char *sense = dasd_get_sense(&erp->irb);
2527 /* check for 24 byte sense ERP */
2528 if ((erp->function == dasd_3990_erp_bus_out) ||
2529 (erp->function == dasd_3990_erp_action_1) ||
2530 (erp->function == dasd_3990_erp_action_4)) {
2532 erp = dasd_3990_erp_action_1(erp);
2534 } else if (erp->function == dasd_3990_erp_action_1_sec) {
2535 erp = dasd_3990_erp_action_1_sec(erp);
2536 } else if (erp->function == dasd_3990_erp_action_5) {
2538 /* retries have not been successful */
2539 /* prepare erp for retry on different channel path */
2540 erp = dasd_3990_erp_action_1(erp);
2542 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
2544 /* issue a Diagnostic Control command with an
2545 * Inhibit Write subcommand */
2547 switch (sense[25]) {
2548 case 0x17:
2549 case 0x57:{ /* controller */
2550 erp = dasd_3990_erp_DCTL(erp, 0x20);
2551 break;
2553 case 0x18:
2554 case 0x58:{ /* channel path */
2555 erp = dasd_3990_erp_DCTL(erp, 0x40);
2556 break;
2558 case 0x19:
2559 case 0x59:{ /* storage director */
2560 erp = dasd_3990_erp_DCTL(erp, 0x80);
2561 break;
2563 default:
2564 DBF_DEV_EVENT(DBF_WARNING, device,
2565 "invalid subcommand modifier 0x%x "
2566 "for Diagnostic Control Command",
2567 sense[25]);
2571 /* check for 32 byte sense ERP */
2572 } else if (sense &&
2573 ((erp->function == dasd_3990_erp_compound_retry) ||
2574 (erp->function == dasd_3990_erp_compound_path) ||
2575 (erp->function == dasd_3990_erp_compound_code) ||
2576 (erp->function == dasd_3990_erp_compound_config))) {
2578 erp = dasd_3990_erp_compound(erp, sense);
2580 } else {
2582 * No retry left and no additional special handling
2583 * necessary
2585 dev_err(&device->cdev->dev,
2586 "ERP %p has run out of retries and failed\n", erp);
2588 erp->status = DASD_CQR_FAILED;
2591 return erp;
2593 } /* end dasd_3990_erp_further_erp */
2596 * DASD_3990_ERP_HANDLE_MATCH_ERP
2598 * DESCRIPTION
2599 * An error occurred again and an ERP has been detected which is already
2600 * used to handle this error (e.g. retries).
2601 * All prior ERP's are asumed to be successful and therefore removed
2602 * from queue.
2603 * If retry counter of matching erp is already 0, it is checked if further
2604 * action is needed (besides retry) or if the ERP has failed.
2606 * PARAMETER
2607 * erp_head first ERP in ERP-chain
2608 * erp ERP that handles the actual error.
2609 * (matching erp)
2611 * RETURN VALUES
2612 * erp modified/additional ERP
2614 static struct dasd_ccw_req *
2615 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2616 struct dasd_ccw_req *erp)
2619 struct dasd_device *device = erp_head->startdev;
2620 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2621 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2623 /* loop over successful ERPs and remove them from chanq */
2624 while (erp_done != erp) {
2626 if (erp_done == NULL) /* end of chain reached */
2627 panic(PRINTK_HEADER "Programming error in ERP! The "
2628 "original request was lost\n");
2630 /* remove the request from the device queue */
2631 list_del(&erp_done->blocklist);
2633 erp_free = erp_done;
2634 erp_done = erp_done->refers;
2636 /* free the finished erp request */
2637 dasd_free_erp_request(erp_free, erp_free->memdev);
2639 } /* end while */
2641 if (erp->retries > 0) {
2643 char *sense = dasd_get_sense(&erp->refers->irb);
2645 /* check for special retries */
2646 if (sense && erp->function == dasd_3990_erp_action_4) {
2648 erp = dasd_3990_erp_action_4(erp, sense);
2650 } else if (sense &&
2651 erp->function == dasd_3990_erp_action_1B_32) {
2653 erp = dasd_3990_update_1B(erp, sense);
2655 } else if (sense && erp->function == dasd_3990_erp_int_req) {
2657 erp = dasd_3990_erp_int_req(erp);
2659 } else {
2660 /* simple retry */
2661 DBF_DEV_EVENT(DBF_DEBUG, device,
2662 "%i retries left for erp %p",
2663 erp->retries, erp);
2665 /* handle the request again... */
2666 erp->status = DASD_CQR_FILLED;
2669 } else {
2670 /* no retry left - check for further necessary action */
2671 /* if no further actions, handle rest as permanent error */
2672 erp = dasd_3990_erp_further_erp(erp);
2675 return erp;
2677 } /* end dasd_3990_erp_handle_match_erp */
2680 * DASD_3990_ERP_ACTION
2682 * DESCRIPTION
2683 * control routine for 3990 erp actions.
2684 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2686 * PARAMETER
2687 * cqr failed cqr (either original cqr or already an erp)
2689 * RETURN VALUES
2690 * erp erp-pointer to the head of the ERP action chain.
2691 * This means:
2692 * - either a ptr to an additional ERP cqr or
2693 * - the original given cqr (which's status might
2694 * be modified)
2696 struct dasd_ccw_req *
2697 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2699 struct dasd_ccw_req *erp = NULL;
2700 struct dasd_device *device = cqr->startdev;
2701 struct dasd_ccw_req *temp_erp = NULL;
2703 if (device->features & DASD_FEATURE_ERPLOG) {
2704 /* print current erp_chain */
2705 dev_err(&device->cdev->dev,
2706 "ERP chain at BEGINNING of ERP-ACTION\n");
2707 for (temp_erp = cqr;
2708 temp_erp != NULL; temp_erp = temp_erp->refers) {
2710 dev_err(&device->cdev->dev,
2711 "ERP %p (%02x) refers to %p\n",
2712 temp_erp, temp_erp->status,
2713 temp_erp->refers);
2717 /* double-check if current erp/cqr was successful */
2718 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2719 (scsw_dstat(&cqr->irb.scsw) ==
2720 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
2722 DBF_DEV_EVENT(DBF_DEBUG, device,
2723 "ERP called for successful request %p"
2724 " - NO ERP necessary", cqr);
2726 cqr->status = DASD_CQR_DONE;
2728 return cqr;
2731 /* check if error happened before */
2732 erp = dasd_3990_erp_in_erp(cqr);
2734 if (erp == NULL) {
2735 /* no matching erp found - set up erp */
2736 erp = dasd_3990_erp_additional_erp(cqr);
2737 if (IS_ERR(erp))
2738 return erp;
2739 } else {
2740 /* matching erp found - set all leading erp's to DONE */
2741 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2744 if (device->features & DASD_FEATURE_ERPLOG) {
2745 /* print current erp_chain */
2746 dev_err(&device->cdev->dev,
2747 "ERP chain at END of ERP-ACTION\n");
2748 for (temp_erp = erp;
2749 temp_erp != NULL; temp_erp = temp_erp->refers) {
2751 dev_err(&device->cdev->dev,
2752 "ERP %p (%02x) refers to %p\n",
2753 temp_erp, temp_erp->status,
2754 temp_erp->refers);
2758 /* enqueue ERP request if it's a new one */
2759 if (list_empty(&erp->blocklist)) {
2760 cqr->status = DASD_CQR_IN_ERP;
2761 /* add erp request before the cqr */
2762 list_add_tail(&erp->blocklist, &cqr->blocklist);
2767 return erp;
2769 } /* end dasd_3990_erp_action */