1
2
3
4
5
6
7
8
9
10#define KMSG_COMPONENT "dasd-eckd"
11
12#include <linux/timer.h>
13#include <asm/idals.h>
14
15#define PRINTK_HEADER "dasd_erp(3990): "
16
17#include "dasd_int.h"
18#include "dasd_eckd.h"
19
20
21struct DCTL_data {
22 unsigned char subcommand;
23 unsigned char modifier;
24 unsigned short res;
25} __attribute__ ((packed));
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52static struct dasd_ccw_req *
53dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
54{
55 struct dasd_ccw_req *cqr = erp->refers;
56
57 dasd_free_erp_request(erp, erp->memdev);
58 cqr->status = final_status;
59 return cqr;
60
61}
62
63
64
65
66
67
68
69
70
71static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires)
72{
73
74 struct dasd_device *device = erp->startdev;
75 unsigned long flags;
76
77 DBF_DEV_EVENT(DBF_INFO, device,
78 "blocking request queue for %is", expires/HZ);
79
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);
88}
89
90
91
92
93
94
95
96
97
98
99
100
101
102static struct dasd_ccw_req *
103dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
104{
105
106 struct dasd_device *device = erp->startdev;
107
108
109
110
111 if (erp->function != dasd_3990_erp_int_req) {
112
113 erp->retries = 256;
114 erp->function = dasd_3990_erp_int_req;
115
116 } else {
117
118
119 dev_err(&device->cdev->dev,
120 "is offline or not installed - "
121 "INTERVENTION REQUIRED!!\n");
122
123 dasd_3990_erp_block_queue(erp, 60*HZ);
124 }
125
126 return erp;
127
128}
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144static void
145dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
146{
147 struct dasd_device *device = erp->startdev;
148 __u8 opm;
149 unsigned long flags;
150
151
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 if (erp->lpm == 0)
156 erp->lpm = dasd_path_get_opm(device) &
157 ~(erp->irb.esw.esw0.sublog.lpum);
158 else
159 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
160
161 if ((erp->lpm & opm) != 0x00) {
162
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);
166
167
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);
174
175
176 erp->status = DASD_CQR_FAILED;
177 }
178}
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195static struct dasd_ccw_req *
196dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
197{
198
199 struct dasd_device *device = erp->startdev;
200 struct DCTL_data *DCTL_data;
201 struct ccw1 *ccw;
202 struct dasd_ccw_req *dctl_cqr;
203
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;
212 }
213
214 DCTL_data = dctl_cqr->data;
215
216 DCTL_data->subcommand = 0x02;
217 DCTL_data->modifier = modifier;
218
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->flags = erp->flags;
225 dctl_cqr->function = dasd_3990_erp_DCTL;
226 dctl_cqr->refers = erp;
227 dctl_cqr->startdev = device;
228 dctl_cqr->memdev = device;
229 dctl_cqr->magic = erp->magic;
230 dctl_cqr->expires = 5 * 60 * HZ;
231 dctl_cqr->retries = 2;
232
233 dctl_cqr->buildclk = get_tod_clock();
234
235 dctl_cqr->status = DASD_CQR_FILLED;
236
237 return dctl_cqr;
238
239}
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262static struct dasd_ccw_req *dasd_3990_erp_action_1_sec(struct dasd_ccw_req *erp)
263{
264 erp->function = dasd_3990_erp_action_1_sec;
265 dasd_3990_erp_alternate_path(erp);
266 return erp;
267}
268
269static struct dasd_ccw_req *dasd_3990_erp_action_1(struct dasd_ccw_req *erp)
270{
271 erp->function = dasd_3990_erp_action_1;
272 dasd_3990_erp_alternate_path(erp);
273 if (erp->status == DASD_CQR_FAILED &&
274 !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
275 erp->status = DASD_CQR_FILLED;
276 erp->retries = 10;
277 erp->lpm = dasd_path_get_opm(erp->startdev);
278 erp->function = dasd_3990_erp_action_1_sec;
279 }
280 return erp;
281}
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301static struct dasd_ccw_req *
302dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
303{
304
305 struct dasd_device *device = erp->startdev;
306
307
308
309
310 if (erp->function != dasd_3990_erp_action_4) {
311
312 DBF_DEV_EVENT(DBF_INFO, device, "%s",
313 "dasd_3990_erp_action_4: first time retry");
314
315 erp->retries = 256;
316 erp->function = dasd_3990_erp_action_4;
317
318 } else {
319 if (sense && (sense[25] == 0x1D)) {
320
321 DBF_DEV_EVENT(DBF_INFO, device,
322 "waiting for state change pending "
323 "interrupt, %d retries left",
324 erp->retries);
325
326 dasd_3990_erp_block_queue(erp, 30*HZ);
327
328 } else if (sense && (sense[25] == 0x1E)) {
329 DBF_DEV_EVENT(DBF_INFO, device,
330 "busy - redriving request later, "
331 "%d retries left",
332 erp->retries);
333 dasd_3990_erp_block_queue(erp, HZ);
334 } else {
335
336 DBF_DEV_EVENT(DBF_INFO, device,
337 "redriving request immediately, "
338 "%d retries left",
339 erp->retries);
340 erp->status = DASD_CQR_FILLED;
341 }
342 }
343
344 return erp;
345
346}
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368static struct dasd_ccw_req *
369dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
370{
371
372
373 erp->retries = 10;
374 erp->function = dasd_3990_erp_action_5;
375
376 return erp;
377
378}
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394static void
395dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
396{
397
398 struct dasd_device *device = erp->startdev;
399 char msg_format = (sense[7] & 0xF0);
400 char msg_no = (sense[7] & 0x0F);
401 char errorstring[ERRORLENGTH];
402
403 switch (msg_format) {
404 case 0x00:
405
406 if (sense[1] & 0x10) {
407
408 switch (msg_no) {
409 case 0x00:
410 break;
411 case 0x01:
412 dev_warn(&device->cdev->dev,
413 "FORMAT 0 - Invalid Command\n");
414 break;
415 case 0x02:
416 dev_warn(&device->cdev->dev,
417 "FORMAT 0 - Invalid Command "
418 "Sequence\n");
419 break;
420 case 0x03:
421 dev_warn(&device->cdev->dev,
422 "FORMAT 0 - CCW Count less than "
423 "required\n");
424 break;
425 case 0x04:
426 dev_warn(&device->cdev->dev,
427 "FORMAT 0 - Invalid Parameter\n");
428 break;
429 case 0x05:
430 dev_warn(&device->cdev->dev,
431 "FORMAT 0 - Diagnostic of Special"
432 " Command Violates File Mask\n");
433 break;
434 case 0x07:
435 dev_warn(&device->cdev->dev,
436 "FORMAT 0 - Channel Returned with "
437 "Incorrect retry CCW\n");
438 break;
439 case 0x08:
440 dev_warn(&device->cdev->dev,
441 "FORMAT 0 - Reset Notification\n");
442 break;
443 case 0x09:
444 dev_warn(&device->cdev->dev,
445 "FORMAT 0 - Storage Path Restart\n");
446 break;
447 case 0x0A:
448 dev_warn(&device->cdev->dev,
449 "FORMAT 0 - Channel requested "
450 "... %02x\n", sense[8]);
451 break;
452 case 0x0B:
453 dev_warn(&device->cdev->dev,
454 "FORMAT 0 - Invalid Defective/"
455 "Alternate Track Pointer\n");
456 break;
457 case 0x0C:
458 dev_warn(&device->cdev->dev,
459 "FORMAT 0 - DPS Installation "
460 "Check\n");
461 break;
462 case 0x0E:
463 dev_warn(&device->cdev->dev,
464 "FORMAT 0 - Command Invalid on "
465 "Secondary Address\n");
466 break;
467 case 0x0F:
468 dev_warn(&device->cdev->dev,
469 "FORMAT 0 - Status Not As "
470 "Required: reason %02x\n",
471 sense[8]);
472 break;
473 default:
474 dev_warn(&device->cdev->dev,
475 "FORMAT 0 - Reserved\n");
476 }
477 } else {
478 switch (msg_no) {
479 case 0x00:
480 break;
481 case 0x01:
482 dev_warn(&device->cdev->dev,
483 "FORMAT 0 - Device Error "
484 "Source\n");
485 break;
486 case 0x02:
487 dev_warn(&device->cdev->dev,
488 "FORMAT 0 - Reserved\n");
489 break;
490 case 0x03:
491 dev_warn(&device->cdev->dev,
492 "FORMAT 0 - Device Fenced - "
493 "device = %02x\n", sense[4]);
494 break;
495 case 0x04:
496 dev_warn(&device->cdev->dev,
497 "FORMAT 0 - Data Pinned for "
498 "Device\n");
499 break;
500 default:
501 dev_warn(&device->cdev->dev,
502 "FORMAT 0 - Reserved\n");
503 }
504 }
505 break;
506
507 case 0x10:
508 switch (msg_no) {
509 case 0x00:
510 break;
511 case 0x01:
512 dev_warn(&device->cdev->dev,
513 "FORMAT 1 - Device Status 1 not as "
514 "expected\n");
515 break;
516 case 0x03:
517 dev_warn(&device->cdev->dev,
518 "FORMAT 1 - Index missing\n");
519 break;
520 case 0x04:
521 dev_warn(&device->cdev->dev,
522 "FORMAT 1 - Interruption cannot be "
523 "reset\n");
524 break;
525 case 0x05:
526 dev_warn(&device->cdev->dev,
527 "FORMAT 1 - Device did not respond to "
528 "selection\n");
529 break;
530 case 0x06:
531 dev_warn(&device->cdev->dev,
532 "FORMAT 1 - Device check-2 error or Set "
533 "Sector is not complete\n");
534 break;
535 case 0x07:
536 dev_warn(&device->cdev->dev,
537 "FORMAT 1 - Head address does not "
538 "compare\n");
539 break;
540 case 0x08:
541 dev_warn(&device->cdev->dev,
542 "FORMAT 1 - Device status 1 not valid\n");
543 break;
544 case 0x09:
545 dev_warn(&device->cdev->dev,
546 "FORMAT 1 - Device not ready\n");
547 break;
548 case 0x0A:
549 dev_warn(&device->cdev->dev,
550 "FORMAT 1 - Track physical address did "
551 "not compare\n");
552 break;
553 case 0x0B:
554 dev_warn(&device->cdev->dev,
555 "FORMAT 1 - Missing device address bit\n");
556 break;
557 case 0x0C:
558 dev_warn(&device->cdev->dev,
559 "FORMAT 1 - Drive motor switch is off\n");
560 break;
561 case 0x0D:
562 dev_warn(&device->cdev->dev,
563 "FORMAT 1 - Seek incomplete\n");
564 break;
565 case 0x0E:
566 dev_warn(&device->cdev->dev,
567 "FORMAT 1 - Cylinder address did not "
568 "compare\n");
569 break;
570 case 0x0F:
571 dev_warn(&device->cdev->dev,
572 "FORMAT 1 - Offset active cannot be "
573 "reset\n");
574 break;
575 default:
576 dev_warn(&device->cdev->dev,
577 "FORMAT 1 - Reserved\n");
578 }
579 break;
580
581 case 0x20:
582 switch (msg_no) {
583 case 0x08:
584 dev_warn(&device->cdev->dev,
585 "FORMAT 2 - 3990 check-2 error\n");
586 break;
587 case 0x0E:
588 dev_warn(&device->cdev->dev,
589 "FORMAT 2 - Support facility errors\n");
590 break;
591 case 0x0F:
592 dev_warn(&device->cdev->dev,
593 "FORMAT 2 - Microcode detected error "
594 "%02x\n",
595 sense[8]);
596 break;
597 default:
598 dev_warn(&device->cdev->dev,
599 "FORMAT 2 - Reserved\n");
600 }
601 break;
602
603 case 0x30:
604 switch (msg_no) {
605 case 0x0F:
606 dev_warn(&device->cdev->dev,
607 "FORMAT 3 - Allegiance terminated\n");
608 break;
609 default:
610 dev_warn(&device->cdev->dev,
611 "FORMAT 3 - Reserved\n");
612 }
613 break;
614
615 case 0x40:
616 switch (msg_no) {
617 case 0x00:
618 dev_warn(&device->cdev->dev,
619 "FORMAT 4 - Home address area error\n");
620 break;
621 case 0x01:
622 dev_warn(&device->cdev->dev,
623 "FORMAT 4 - Count area error\n");
624 break;
625 case 0x02:
626 dev_warn(&device->cdev->dev,
627 "FORMAT 4 - Key area error\n");
628 break;
629 case 0x03:
630 dev_warn(&device->cdev->dev,
631 "FORMAT 4 - Data area error\n");
632 break;
633 case 0x04:
634 dev_warn(&device->cdev->dev,
635 "FORMAT 4 - No sync byte in home address "
636 "area\n");
637 break;
638 case 0x05:
639 dev_warn(&device->cdev->dev,
640 "FORMAT 4 - No sync byte in count address "
641 "area\n");
642 break;
643 case 0x06:
644 dev_warn(&device->cdev->dev,
645 "FORMAT 4 - No sync byte in key area\n");
646 break;
647 case 0x07:
648 dev_warn(&device->cdev->dev,
649 "FORMAT 4 - No sync byte in data area\n");
650 break;
651 case 0x08:
652 dev_warn(&device->cdev->dev,
653 "FORMAT 4 - Home address area error; "
654 "offset active\n");
655 break;
656 case 0x09:
657 dev_warn(&device->cdev->dev,
658 "FORMAT 4 - Count area error; offset "
659 "active\n");
660 break;
661 case 0x0A:
662 dev_warn(&device->cdev->dev,
663 "FORMAT 4 - Key area error; offset "
664 "active\n");
665 break;
666 case 0x0B:
667 dev_warn(&device->cdev->dev,
668 "FORMAT 4 - Data area error; "
669 "offset active\n");
670 break;
671 case 0x0C:
672 dev_warn(&device->cdev->dev,
673 "FORMAT 4 - No sync byte in home "
674 "address area; offset active\n");
675 break;
676 case 0x0D:
677 dev_warn(&device->cdev->dev,
678 "FORMAT 4 - No sync byte in count "
679 "address area; offset active\n");
680 break;
681 case 0x0E:
682 dev_warn(&device->cdev->dev,
683 "FORMAT 4 - No sync byte in key area; "
684 "offset active\n");
685 break;
686 case 0x0F:
687 dev_warn(&device->cdev->dev,
688 "FORMAT 4 - No sync byte in data area; "
689 "offset active\n");
690 break;
691 default:
692 dev_warn(&device->cdev->dev,
693 "FORMAT 4 - Reserved\n");
694 }
695 break;
696
697 case 0x50:
698 switch (msg_no) {
699 case 0x00:
700 dev_warn(&device->cdev->dev,
701 "FORMAT 5 - Data Check in the "
702 "home address area\n");
703 break;
704 case 0x01:
705 dev_warn(&device->cdev->dev,
706 "FORMAT 5 - Data Check in the count "
707 "area\n");
708 break;
709 case 0x02:
710 dev_warn(&device->cdev->dev,
711 "FORMAT 5 - Data Check in the key area\n");
712 break;
713 case 0x03:
714 dev_warn(&device->cdev->dev,
715 "FORMAT 5 - Data Check in the data "
716 "area\n");
717 break;
718 case 0x08:
719 dev_warn(&device->cdev->dev,
720 "FORMAT 5 - Data Check in the "
721 "home address area; offset active\n");
722 break;
723 case 0x09:
724 dev_warn(&device->cdev->dev,
725 "FORMAT 5 - Data Check in the count area; "
726 "offset active\n");
727 break;
728 case 0x0A:
729 dev_warn(&device->cdev->dev,
730 "FORMAT 5 - Data Check in the key area; "
731 "offset active\n");
732 break;
733 case 0x0B:
734 dev_warn(&device->cdev->dev,
735 "FORMAT 5 - Data Check in the data area; "
736 "offset active\n");
737 break;
738 default:
739 dev_warn(&device->cdev->dev,
740 "FORMAT 5 - Reserved\n");
741 }
742 break;
743
744 case 0x60:
745 switch (msg_no) {
746 case 0x00:
747 dev_warn(&device->cdev->dev,
748 "FORMAT 6 - Overrun on channel A\n");
749 break;
750 case 0x01:
751 dev_warn(&device->cdev->dev,
752 "FORMAT 6 - Overrun on channel B\n");
753 break;
754 case 0x02:
755 dev_warn(&device->cdev->dev,
756 "FORMAT 6 - Overrun on channel C\n");
757 break;
758 case 0x03:
759 dev_warn(&device->cdev->dev,
760 "FORMAT 6 - Overrun on channel D\n");
761 break;
762 case 0x04:
763 dev_warn(&device->cdev->dev,
764 "FORMAT 6 - Overrun on channel E\n");
765 break;
766 case 0x05:
767 dev_warn(&device->cdev->dev,
768 "FORMAT 6 - Overrun on channel F\n");
769 break;
770 case 0x06:
771 dev_warn(&device->cdev->dev,
772 "FORMAT 6 - Overrun on channel G\n");
773 break;
774 case 0x07:
775 dev_warn(&device->cdev->dev,
776 "FORMAT 6 - Overrun on channel H\n");
777 break;
778 default:
779 dev_warn(&device->cdev->dev,
780 "FORMAT 6 - Reserved\n");
781 }
782 break;
783
784 case 0x70:
785 switch (msg_no) {
786 case 0x00:
787 dev_warn(&device->cdev->dev,
788 "FORMAT 7 - RCC initiated by a connection "
789 "check alert\n");
790 break;
791 case 0x01:
792 dev_warn(&device->cdev->dev,
793 "FORMAT 7 - RCC 1 sequence not "
794 "successful\n");
795 break;
796 case 0x02:
797 dev_warn(&device->cdev->dev,
798 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
799 "successful\n");
800 break;
801 case 0x03:
802 dev_warn(&device->cdev->dev,
803 "FORMAT 7 - Invalid tag-in during "
804 "selection sequence\n");
805 break;
806 case 0x04:
807 dev_warn(&device->cdev->dev,
808 "FORMAT 7 - extra RCC required\n");
809 break;
810 case 0x05:
811 dev_warn(&device->cdev->dev,
812 "FORMAT 7 - Invalid DCC selection "
813 "response or timeout\n");
814 break;
815 case 0x06:
816 dev_warn(&device->cdev->dev,
817 "FORMAT 7 - Missing end operation; device "
818 "transfer complete\n");
819 break;
820 case 0x07:
821 dev_warn(&device->cdev->dev,
822 "FORMAT 7 - Missing end operation; device "
823 "transfer incomplete\n");
824 break;
825 case 0x08:
826 dev_warn(&device->cdev->dev,
827 "FORMAT 7 - Invalid tag-in for an "
828 "immediate command sequence\n");
829 break;
830 case 0x09:
831 dev_warn(&device->cdev->dev,
832 "FORMAT 7 - Invalid tag-in for an "
833 "extended command sequence\n");
834 break;
835 case 0x0A:
836 dev_warn(&device->cdev->dev,
837 "FORMAT 7 - 3990 microcode time out when "
838 "stopping selection\n");
839 break;
840 case 0x0B:
841 dev_warn(&device->cdev->dev,
842 "FORMAT 7 - No response to selection "
843 "after a poll interruption\n");
844 break;
845 case 0x0C:
846 dev_warn(&device->cdev->dev,
847 "FORMAT 7 - Permanent path error (DASD "
848 "controller not available)\n");
849 break;
850 case 0x0D:
851 dev_warn(&device->cdev->dev,
852 "FORMAT 7 - DASD controller not available"
853 " on disconnected command chain\n");
854 break;
855 default:
856 dev_warn(&device->cdev->dev,
857 "FORMAT 7 - Reserved\n");
858 }
859 break;
860
861 case 0x80:
862 switch (msg_no) {
863 case 0x00:
864 case 0x01:
865 dev_warn(&device->cdev->dev,
866 "FORMAT 8 - Error correction code "
867 "hardware fault\n");
868 break;
869 case 0x03:
870 dev_warn(&device->cdev->dev,
871 "FORMAT 8 - Unexpected end operation "
872 "response code\n");
873 break;
874 case 0x04:
875 dev_warn(&device->cdev->dev,
876 "FORMAT 8 - End operation with transfer "
877 "count not zero\n");
878 break;
879 case 0x05:
880 dev_warn(&device->cdev->dev,
881 "FORMAT 8 - End operation with transfer "
882 "count zero\n");
883 break;
884 case 0x06:
885 dev_warn(&device->cdev->dev,
886 "FORMAT 8 - DPS checks after a system "
887 "reset or selective reset\n");
888 break;
889 case 0x07:
890 dev_warn(&device->cdev->dev,
891 "FORMAT 8 - DPS cannot be filled\n");
892 break;
893 case 0x08:
894 dev_warn(&device->cdev->dev,
895 "FORMAT 8 - Short busy time-out during "
896 "device selection\n");
897 break;
898 case 0x09:
899 dev_warn(&device->cdev->dev,
900 "FORMAT 8 - DASD controller failed to "
901 "set or reset the long busy latch\n");
902 break;
903 case 0x0A:
904 dev_warn(&device->cdev->dev,
905 "FORMAT 8 - No interruption from device "
906 "during a command chain\n");
907 break;
908 default:
909 dev_warn(&device->cdev->dev,
910 "FORMAT 8 - Reserved\n");
911 }
912 break;
913
914 case 0x90:
915 switch (msg_no) {
916 case 0x00:
917 break;
918 case 0x06:
919 dev_warn(&device->cdev->dev,
920 "FORMAT 9 - Device check-2 error\n");
921 break;
922 case 0x07:
923 dev_warn(&device->cdev->dev,
924 "FORMAT 9 - Head address did not "
925 "compare\n");
926 break;
927 case 0x0A:
928 dev_warn(&device->cdev->dev,
929 "FORMAT 9 - Track physical address did "
930 "not compare while oriented\n");
931 break;
932 case 0x0E:
933 dev_warn(&device->cdev->dev,
934 "FORMAT 9 - Cylinder address did not "
935 "compare\n");
936 break;
937 default:
938 dev_warn(&device->cdev->dev,
939 "FORMAT 9 - Reserved\n");
940 }
941 break;
942
943 case 0xF0:
944 switch (msg_no) {
945 case 0x00:
946 dev_warn(&device->cdev->dev,
947 "FORMAT F - Operation Terminated\n");
948 break;
949 case 0x01:
950 dev_warn(&device->cdev->dev,
951 "FORMAT F - Subsystem Processing Error\n");
952 break;
953 case 0x02:
954 dev_warn(&device->cdev->dev,
955 "FORMAT F - Cache or nonvolatile storage "
956 "equipment failure\n");
957 break;
958 case 0x04:
959 dev_warn(&device->cdev->dev,
960 "FORMAT F - Caching terminated\n");
961 break;
962 case 0x06:
963 dev_warn(&device->cdev->dev,
964 "FORMAT F - Cache fast write access not "
965 "authorized\n");
966 break;
967 case 0x07:
968 dev_warn(&device->cdev->dev,
969 "FORMAT F - Track format incorrect\n");
970 break;
971 case 0x09:
972 dev_warn(&device->cdev->dev,
973 "FORMAT F - Caching reinitiated\n");
974 break;
975 case 0x0A:
976 dev_warn(&device->cdev->dev,
977 "FORMAT F - Nonvolatile storage "
978 "terminated\n");
979 break;
980 case 0x0B:
981 dev_warn(&device->cdev->dev,
982 "FORMAT F - Volume is suspended duplex\n");
983
984 dasd_eer_write(device, erp->refers,
985 DASD_EER_PPRCSUSPEND);
986 break;
987 case 0x0C:
988 dev_warn(&device->cdev->dev,
989 "FORMAT F - Subsystem status cannot be "
990 "determined\n");
991 break;
992 case 0x0D:
993 dev_warn(&device->cdev->dev,
994 "FORMAT F - Caching status reset to "
995 "default\n");
996 break;
997 case 0x0E:
998 dev_warn(&device->cdev->dev,
999 "FORMAT F - DASD Fast Write inhibited\n");
1000 break;
1001 default:
1002 dev_warn(&device->cdev->dev,
1003 "FORMAT F - Reserved\n");
1004 }
1005 break;
1006
1007 default:
1008
1009 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
1010 dev_err(&device->cdev->dev,
1011 "An error occurred in the DASD device driver, "
1012 "reason=%s\n", errorstring);
1013 break;
1014 }
1015
1016}
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031static struct dasd_ccw_req *
1032dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1033{
1034
1035 struct dasd_device *device = erp->startdev;
1036
1037 erp->function = dasd_3990_erp_com_rej;
1038
1039
1040 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1041
1042 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1043 "Command Reject - environmental data present");
1044
1045 dasd_3990_handle_env_data(erp, sense);
1046
1047 erp->retries = 5;
1048
1049 } else if (sense[1] & SNS1_WRITE_INHIBITED) {
1050 dev_err(&device->cdev->dev, "An I/O request was rejected"
1051 " because writing is inhibited\n");
1052 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1053 } else {
1054
1055
1056 if (!test_bit(DASD_CQR_SUPPRESS_CR, &erp->flags))
1057 dev_err(&device->cdev->dev,
1058 "An error occurred in the DASD device driver, reason=09\n");
1059
1060 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1061 }
1062
1063 return erp;
1064
1065}
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078static struct dasd_ccw_req *
1079dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1080{
1081
1082 struct dasd_device *device = erp->startdev;
1083
1084
1085
1086
1087 if (erp->function != dasd_3990_erp_bus_out) {
1088 erp->retries = 256;
1089 erp->function = dasd_3990_erp_bus_out;
1090
1091 } else {
1092
1093
1094 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1095 "bus out parity error or BOPC requested by "
1096 "channel");
1097
1098 dasd_3990_erp_block_queue(erp, 60*HZ);
1099
1100 }
1101
1102 return erp;
1103
1104}
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117static struct dasd_ccw_req *
1118dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1119{
1120
1121 struct dasd_device *device = erp->startdev;
1122
1123 erp->function = dasd_3990_erp_equip_check;
1124
1125 if (sense[1] & SNS1_WRITE_INHIBITED) {
1126 dev_info(&device->cdev->dev,
1127 "Write inhibited path encountered\n");
1128
1129
1130
1131 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1132 "device driver, reason=%s\n", "04");
1133
1134 erp = dasd_3990_erp_action_1(erp);
1135
1136 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1137
1138 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1139 "Equipment Check - " "environmental data present");
1140
1141 dasd_3990_handle_env_data(erp, sense);
1142
1143 erp = dasd_3990_erp_action_4(erp, sense);
1144
1145 } else if (sense[1] & SNS1_PERM_ERR) {
1146
1147 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1148 "Equipment Check - retry exhausted or "
1149 "undesirable");
1150
1151 erp = dasd_3990_erp_action_1(erp);
1152
1153 } else {
1154
1155
1156 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1157 "Equipment check or processing error");
1158
1159 erp = dasd_3990_erp_action_5(erp);
1160 }
1161 return erp;
1162
1163}
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176static struct dasd_ccw_req *
1177dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1178{
1179
1180 struct dasd_device *device = erp->startdev;
1181
1182 erp->function = dasd_3990_erp_data_check;
1183
1184 if (sense[2] & SNS2_CORRECTABLE) {
1185
1186
1187 dev_emerg(&device->cdev->dev,
1188 "Data recovered during retry with PCI "
1189 "fetch mode active\n");
1190
1191
1192 panic("No way to inform application about the possibly "
1193 "incorrect data");
1194
1195 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1196
1197 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1198 "Uncorrectable data check recovered secondary "
1199 "addr of duplex pair");
1200
1201 erp = dasd_3990_erp_action_4(erp, sense);
1202
1203 } else if (sense[1] & SNS1_PERM_ERR) {
1204
1205 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1206 "Uncorrectable data check with internal "
1207 "retry exhausted");
1208
1209 erp = dasd_3990_erp_action_1(erp);
1210
1211 } else {
1212
1213 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1214 "Uncorrectable data check with retry count "
1215 "exhausted...");
1216
1217 erp = dasd_3990_erp_action_5(erp);
1218 }
1219
1220 return erp;
1221
1222}
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235static struct dasd_ccw_req *
1236dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1237{
1238
1239 struct dasd_device *device = erp->startdev;
1240
1241 erp->function = dasd_3990_erp_overrun;
1242
1243 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1244 "Overrun - service overrun or overrun"
1245 " error requested by channel");
1246
1247 erp = dasd_3990_erp_action_5(erp);
1248
1249 return erp;
1250
1251}
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264static struct dasd_ccw_req *
1265dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1266{
1267
1268 struct dasd_device *device = erp->startdev;
1269
1270 erp->function = dasd_3990_erp_inv_format;
1271
1272 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1273
1274 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1275 "Track format error when destaging or "
1276 "staging data");
1277
1278 dasd_3990_handle_env_data(erp, sense);
1279
1280 erp = dasd_3990_erp_action_4(erp, sense);
1281
1282 } else {
1283
1284 dev_err(&device->cdev->dev,
1285 "An error occurred in the DASD device driver, "
1286 "reason=%s\n", "06");
1287
1288 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1289 }
1290
1291 return erp;
1292
1293}
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306static struct dasd_ccw_req *
1307dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1308{
1309
1310 struct dasd_device *device = default_erp->startdev;
1311
1312 dev_err(&device->cdev->dev,
1313 "The cylinder data for accessing the DASD is inconsistent\n");
1314
1315
1316 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1317
1318}
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331static struct dasd_ccw_req *
1332dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1333{
1334
1335 struct dasd_device *device = erp->startdev;
1336
1337 erp->function = dasd_3990_erp_env_data;
1338
1339 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
1340
1341 dasd_3990_handle_env_data(erp, sense);
1342
1343
1344 if (sense[7] != 0x0F) {
1345 erp = dasd_3990_erp_action_4(erp, sense);
1346 } else {
1347 erp->status = DASD_CQR_FILLED;
1348 }
1349
1350 return erp;
1351
1352}
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366static struct dasd_ccw_req *
1367dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1368{
1369
1370 struct dasd_device *device = default_erp->startdev;
1371
1372
1373
1374
1375
1376
1377 if (!test_bit(DASD_CQR_SUPPRESS_NRF, &default_erp->flags))
1378 dev_err(&device->cdev->dev,
1379 "The specified record was not found\n");
1380
1381 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1382
1383}
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398static struct dasd_ccw_req *
1399dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1400{
1401
1402 struct dasd_device *device = erp->startdev;
1403
1404
1405
1406
1407
1408
1409 if (!test_bit(DASD_CQR_SUPPRESS_FP, &erp->flags))
1410 dev_err(&device->cdev->dev,
1411 "Accessing the DASD failed because of a hardware error\n");
1412
1413 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1414
1415}
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1433 struct dasd_ccw_req *erp)
1434{
1435 struct dasd_ccw_req *cqr = erp->refers;
1436 char *sense;
1437
1438 if (cqr->block &&
1439 (cqr->block->base != cqr->startdev)) {
1440
1441 sense = dasd_get_sense(&erp->refers->irb);
1442
1443
1444
1445 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
1446 && (sense[0] == 0x10) && (sense[7] == 0x0F)
1447 && (sense[8] == 0x67)) {
1448
1449
1450
1451
1452
1453 dasd_alias_remove_device(cqr->startdev);
1454
1455
1456 dasd_reload_device(cqr->startdev);
1457 }
1458
1459 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
1460 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
1461 "ERP on alias device for request %p,"
1462 " recover on base device %s", cqr,
1463 dev_name(&cqr->block->base->cdev->dev));
1464 }
1465 dasd_eckd_reset_ccw_to_base_io(cqr);
1466 erp->startdev = cqr->block->base;
1467 erp->function = dasd_3990_erp_inspect_alias;
1468 return erp;
1469 } else
1470 return NULL;
1471}
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488static struct dasd_ccw_req *
1489dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1490{
1491
1492 struct dasd_ccw_req *erp_filled = NULL;
1493
1494
1495
1496 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1497 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1498 }
1499
1500 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1501 erp_filled = dasd_3990_erp_int_req(erp);
1502 }
1503
1504 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1505 erp_filled = dasd_3990_erp_bus_out(erp);
1506 }
1507
1508 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1509 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1510 }
1511
1512 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1513 erp_filled = dasd_3990_erp_data_check(erp, sense);
1514 }
1515
1516 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1517 erp_filled = dasd_3990_erp_overrun(erp, sense);
1518 }
1519
1520 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1521 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1522 }
1523
1524 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1525 erp_filled = dasd_3990_erp_EOC(erp, sense);
1526 }
1527
1528 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1529 erp_filled = dasd_3990_erp_env_data(erp, sense);
1530 }
1531
1532 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1533 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1534 }
1535
1536 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1537 erp_filled = dasd_3990_erp_file_prot(erp);
1538 }
1539
1540 if (erp_filled == NULL) {
1541
1542 erp_filled = erp;
1543 }
1544
1545 return erp_filled;
1546
1547}
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568static struct dasd_ccw_req *
1569dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1570{
1571
1572 struct dasd_device *device = erp->startdev;
1573
1574 erp->retries = 256;
1575 erp->function = dasd_3990_erp_action_10_32;
1576
1577 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
1578
1579 return erp;
1580
1581}
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602static struct dasd_ccw_req *
1603dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1604{
1605
1606 struct dasd_device *device = default_erp->startdev;
1607 __u32 cpa = 0;
1608 struct dasd_ccw_req *cqr;
1609 struct dasd_ccw_req *erp;
1610 struct DE_eckd_data *DE_data;
1611 struct PFX_eckd_data *PFX_data;
1612 char *LO_data;
1613 struct ccw1 *ccw, *oldccw;
1614
1615 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1616 "Write not finished because of unexpected condition");
1617
1618 default_erp->function = dasd_3990_erp_action_1B_32;
1619
1620
1621 cqr = default_erp;
1622
1623 while (cqr->refers != NULL) {
1624 cqr = cqr->refers;
1625 }
1626
1627 if (scsw_is_tm(&cqr->irb.scsw)) {
1628 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1629 "32 bit sense, action 1B is not defined"
1630 " in transport mode - just retry");
1631 return default_erp;
1632 }
1633
1634
1635 if (sense[1] & 0x01) {
1636 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1637 "Imprecise ending is set - just retry");
1638
1639 return default_erp;
1640 }
1641
1642
1643
1644 cpa = default_erp->refers->irb.scsw.cmd.cpa;
1645
1646 if (cpa == 0) {
1647 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1648 "Unable to determine address of the CCW "
1649 "to be restarted");
1650
1651 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1652 }
1653
1654
1655 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1656 2 + 1,
1657 sizeof(struct DE_eckd_data) +
1658 sizeof(struct LO_eckd_data), device);
1659
1660 if (IS_ERR(erp)) {
1661
1662 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1663 "device driver, reason=%s\n", "01");
1664 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1665 }
1666
1667
1668 DE_data = erp->data;
1669 oldccw = cqr->cpaddr;
1670 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1671 PFX_data = cqr->data;
1672 memcpy(DE_data, &PFX_data->define_extent,
1673 sizeof(struct DE_eckd_data));
1674 } else
1675 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
1676
1677
1678 LO_data = erp->data + sizeof(struct DE_eckd_data);
1679
1680 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1681
1682 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1683 }
1684
1685 if ((sense[7] & 0x3F) == 0x01) {
1686
1687 LO_data[0] = 0x81;
1688
1689 } else if ((sense[7] & 0x3F) == 0x03) {
1690
1691 LO_data[0] = 0xC3;
1692
1693 } else {
1694 LO_data[0] = sense[7];
1695 }
1696
1697 LO_data[1] = sense[8];
1698 LO_data[2] = sense[9];
1699 LO_data[3] = sense[3];
1700 LO_data[4] = sense[29];
1701 LO_data[5] = sense[30];
1702 LO_data[7] = sense[31];
1703
1704 memcpy(&(LO_data[8]), &(sense[11]), 8);
1705
1706
1707 ccw = erp->cpaddr;
1708 memset(ccw, 0, sizeof(struct ccw1));
1709 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1710 ccw->flags = CCW_FLAG_CC;
1711 ccw->count = 16;
1712 ccw->cda = (__u32)(addr_t) DE_data;
1713
1714
1715 ccw++;
1716 memset(ccw, 0, sizeof(struct ccw1));
1717 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1718 ccw->flags = CCW_FLAG_CC;
1719 ccw->count = 16;
1720 ccw->cda = (__u32)(addr_t) LO_data;
1721
1722
1723 ccw++;
1724 ccw->cmd_code = CCW_CMD_TIC;
1725 ccw->cda = cpa;
1726
1727
1728 erp->flags = default_erp->flags;
1729 erp->function = dasd_3990_erp_action_1B_32;
1730 erp->refers = default_erp->refers;
1731 erp->startdev = device;
1732 erp->memdev = device;
1733 erp->magic = default_erp->magic;
1734 erp->expires = default_erp->expires;
1735 erp->retries = 256;
1736 erp->buildclk = get_tod_clock();
1737 erp->status = DASD_CQR_FILLED;
1738
1739
1740 dasd_free_erp_request(default_erp, device);
1741
1742 return erp;
1743
1744}
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761static struct dasd_ccw_req *
1762dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1763{
1764
1765 struct dasd_device *device = previous_erp->startdev;
1766 __u32 cpa = 0;
1767 struct dasd_ccw_req *cqr;
1768 struct dasd_ccw_req *erp;
1769 char *LO_data;
1770 struct ccw1 *ccw;
1771
1772 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1773 "Write not finished because of unexpected condition"
1774 " - follow on");
1775
1776
1777 cqr = previous_erp;
1778
1779 while (cqr->refers != NULL) {
1780 cqr = cqr->refers;
1781 }
1782
1783 if (scsw_is_tm(&cqr->irb.scsw)) {
1784 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1785 "32 bit sense, action 1B, update,"
1786 " in transport mode - just retry");
1787 return previous_erp;
1788 }
1789
1790
1791 if (sense[1] & 0x01) {
1792 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1793 "Imprecise ending is set - just retry");
1794
1795 previous_erp->status = DASD_CQR_FILLED;
1796
1797 return previous_erp;
1798 }
1799
1800
1801
1802 cpa = previous_erp->irb.scsw.cmd.cpa;
1803
1804 if (cpa == 0) {
1805
1806
1807 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1808 "device driver, reason=%s\n", "02");
1809
1810 previous_erp->status = DASD_CQR_FAILED;
1811
1812 return previous_erp;
1813 }
1814
1815 erp = previous_erp;
1816
1817
1818 LO_data = erp->data + sizeof(struct DE_eckd_data);
1819
1820 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1821
1822 previous_erp->status = DASD_CQR_FAILED;
1823
1824 return previous_erp;
1825 }
1826
1827 if ((sense[7] & 0x3F) == 0x01) {
1828
1829 LO_data[0] = 0x81;
1830
1831 } else if ((sense[7] & 0x3F) == 0x03) {
1832
1833 LO_data[0] = 0xC3;
1834
1835 } else {
1836 LO_data[0] = sense[7];
1837 }
1838
1839 LO_data[1] = sense[8];
1840 LO_data[2] = sense[9];
1841 LO_data[3] = sense[3];
1842 LO_data[4] = sense[29];
1843 LO_data[5] = sense[30];
1844 LO_data[7] = sense[31];
1845
1846 memcpy(&(LO_data[8]), &(sense[11]), 8);
1847
1848
1849 ccw = erp->cpaddr;
1850 ccw++;
1851 ccw++;
1852 ccw->cda = cpa;
1853
1854 erp->status = DASD_CQR_FILLED;
1855
1856 return erp;
1857
1858}
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877static void
1878dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1879{
1880
1881 switch (sense[25] & 0x03) {
1882 case 0x00:
1883 erp->retries = 1;
1884 break;
1885
1886 case 0x01:
1887 erp->retries = 2;
1888 break;
1889
1890 case 0x02:
1891 erp->retries = 10;
1892 break;
1893
1894 case 0x03:
1895 erp->retries = 256;
1896 break;
1897
1898 default:
1899 BUG();
1900 }
1901
1902 erp->function = dasd_3990_erp_compound_retry;
1903
1904}
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921static void
1922dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1923{
1924 if (sense[25] & DASD_SENSE_BIT_3) {
1925 dasd_3990_erp_alternate_path(erp);
1926
1927 if (erp->status == DASD_CQR_FAILED &&
1928 !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
1929
1930
1931 erp->lpm = dasd_path_get_opm(erp->startdev);
1932 erp->status = DASD_CQR_NEED_ERP;
1933 }
1934 }
1935
1936 erp->function = dasd_3990_erp_compound_path;
1937
1938}
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954static struct dasd_ccw_req *
1955dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1956{
1957
1958 if (sense[25] & DASD_SENSE_BIT_2) {
1959
1960 switch (sense[28]) {
1961 case 0x17:
1962
1963
1964 erp = dasd_3990_erp_DCTL(erp, 0x20);
1965 break;
1966
1967 case 0x25:
1968
1969 erp->retries = 1;
1970
1971 dasd_3990_erp_block_queue (erp, 5*HZ);
1972 break;
1973
1974 default:
1975
1976 break;
1977 }
1978 }
1979
1980 erp->function = dasd_3990_erp_compound_code;
1981
1982 return erp;
1983
1984}
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002static void
2003dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2004{
2005
2006 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2007
2008
2009
2010
2011 struct dasd_device *device = erp->startdev;
2012 dev_err(&device->cdev->dev,
2013 "An error occurred in the DASD device driver, "
2014 "reason=%s\n", "05");
2015
2016 }
2017
2018 erp->function = dasd_3990_erp_compound_config;
2019
2020}
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037static struct dasd_ccw_req *
2038dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2039{
2040
2041 if ((erp->function == dasd_3990_erp_compound_retry) &&
2042 (erp->status == DASD_CQR_NEED_ERP)) {
2043
2044 dasd_3990_erp_compound_path(erp, sense);
2045 }
2046
2047 if ((erp->function == dasd_3990_erp_compound_path) &&
2048 (erp->status == DASD_CQR_NEED_ERP)) {
2049
2050 erp = dasd_3990_erp_compound_code(erp, sense);
2051 }
2052
2053 if ((erp->function == dasd_3990_erp_compound_code) &&
2054 (erp->status == DASD_CQR_NEED_ERP)) {
2055
2056 dasd_3990_erp_compound_config(erp, sense);
2057 }
2058
2059
2060 if (erp->status == DASD_CQR_NEED_ERP)
2061 erp->status = DASD_CQR_FAILED;
2062
2063 return erp;
2064
2065}
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079void
2080dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2081{
2082
2083 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
2084
2085 dev_err(&device->cdev->dev, "SIM - SRC: "
2086 "%02x%02x%02x%02x\n", sense[22],
2087 sense[23], sense[11], sense[12]);
2088 } else if (sense[24] & DASD_SIM_LOG) {
2089
2090 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2091 "%02x%02x%02x%02x\n", sense[22],
2092 sense[23], sense[11], sense[12]);
2093 }
2094}
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111static struct dasd_ccw_req *
2112dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2113{
2114
2115 struct dasd_device *device = erp->startdev;
2116
2117 erp->function = dasd_3990_erp_inspect_32;
2118
2119
2120 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2121 dasd_3990_erp_handle_sim(device, sense);
2122
2123 if (sense[25] & DASD_SENSE_BIT_0) {
2124
2125
2126 dasd_3990_erp_compound_retry(erp, sense);
2127
2128 } else {
2129
2130
2131 switch (sense[25]) {
2132
2133 case 0x00:
2134 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
2135 "ERP called for successful request"
2136 " - just retry");
2137 break;
2138
2139 case 0x01:
2140 dev_err(&device->cdev->dev,
2141 "ERP failed for the DASD\n");
2142
2143 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2144 break;
2145
2146 case 0x02:
2147 case 0x03:
2148 erp = dasd_3990_erp_int_req(erp);
2149 break;
2150
2151 case 0x0F:
2152
2153 dev_err(&device->cdev->dev, "An error occurred in the "
2154 "DASD device driver, reason=%s\n", "08");
2155
2156 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2157 break;
2158
2159 case 0x10:
2160 erp = dasd_3990_erp_action_10_32(erp, sense);
2161 break;
2162
2163 case 0x15:
2164
2165
2166 dev_err(&device->cdev->dev,
2167 "An error occurred in the DASD device driver, "
2168 "reason=%s\n", "07");
2169
2170 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2171 break;
2172
2173 case 0x1B:
2174
2175 erp = dasd_3990_erp_action_1B_32(erp, sense);
2176 break;
2177
2178 case 0x1C:
2179 dev_emerg(&device->cdev->dev,
2180 "Data recovered during retry with PCI "
2181 "fetch mode active\n");
2182
2183
2184 panic
2185 ("Invalid data - No way to inform application "
2186 "about the possibly incorrect data");
2187 break;
2188
2189 case 0x1D:
2190 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2191 "A State change pending condition exists "
2192 "for the subsystem or device");
2193
2194 erp = dasd_3990_erp_action_4(erp, sense);
2195 break;
2196
2197 case 0x1E:
2198 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2199 "Busy condition exists "
2200 "for the subsystem or device");
2201 erp = dasd_3990_erp_action_4(erp, sense);
2202 break;
2203
2204 default:
2205 break;
2206 }
2207 }
2208
2209 return erp;
2210
2211}
2212
2213static void dasd_3990_erp_disable_path(struct dasd_device *device, __u8 lpum)
2214{
2215 int pos = pathmask_to_pos(lpum);
2216
2217
2218 if (!(dasd_path_get_opm(device) & ~lpum))
2219 return;
2220
2221 dev_err(&device->cdev->dev,
2222 "Path %x.%02x (pathmask %02x) is disabled - IFCC threshold exceeded\n",
2223 device->path[pos].cssid, device->path[pos].chpid, lpum);
2224 dasd_path_remove_opm(device, lpum);
2225 dasd_path_add_ifccpm(device, lpum);
2226 device->path[pos].errorclk = 0;
2227 atomic_set(&device->path[pos].error_count, 0);
2228}
2229
2230static void dasd_3990_erp_account_error(struct dasd_ccw_req *erp)
2231{
2232 struct dasd_device *device = erp->startdev;
2233 __u8 lpum = erp->refers->irb.esw.esw1.lpum;
2234 int pos = pathmask_to_pos(lpum);
2235 unsigned long clk;
2236
2237 if (!device->path_thrhld)
2238 return;
2239
2240 clk = get_tod_clock();
2241
2242
2243
2244
2245 if ((tod_to_ns(clk - device->path[pos].errorclk) / NSEC_PER_SEC)
2246 >= device->path_interval) {
2247 atomic_set(&device->path[pos].error_count, 0);
2248 device->path[pos].errorclk = 0;
2249 }
2250 atomic_inc(&device->path[pos].error_count);
2251 device->path[pos].errorclk = clk;
2252
2253 if (atomic_read(&device->path[pos].error_count) >=
2254 device->path_thrhld)
2255 dasd_3990_erp_disable_path(device, lpum);
2256}
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278static struct dasd_ccw_req *
2279dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2280{
2281 struct dasd_device *device = erp->startdev;
2282
2283 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
2284 | SCHN_STAT_CHN_CTRL_CHK)) {
2285 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2286 "channel or interface control check");
2287 dasd_3990_erp_account_error(erp);
2288 erp = dasd_3990_erp_action_4(erp, NULL);
2289 }
2290 return erp;
2291}
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305static struct dasd_ccw_req *
2306dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
2307{
2308
2309 struct dasd_ccw_req *erp_new = NULL;
2310 char *sense;
2311
2312
2313 erp_new = dasd_3990_erp_inspect_alias(erp);
2314 if (erp_new)
2315 return erp_new;
2316
2317
2318
2319
2320
2321 sense = dasd_get_sense(&erp->refers->irb);
2322 if (!sense)
2323 erp_new = dasd_3990_erp_control_check(erp);
2324
2325 else if (sense[27] & DASD_SENSE_BIT_0) {
2326
2327
2328 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2329
2330 } else {
2331
2332
2333 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2334
2335 }
2336
2337 return erp_new;
2338}
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
2359{
2360
2361 struct dasd_device *device = cqr->startdev;
2362 struct ccw1 *ccw;
2363 struct dasd_ccw_req *erp;
2364 int cplength, datasize;
2365 struct tcw *tcw;
2366 struct tsb *tsb;
2367
2368 if (cqr->cpmode == 1) {
2369 cplength = 0;
2370
2371 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
2372 } else {
2373 cplength = 2;
2374 datasize = 0;
2375 }
2376
2377
2378 erp = dasd_alloc_erp_request((char *) &cqr->magic,
2379 cplength, datasize, device);
2380 if (IS_ERR(erp)) {
2381 if (cqr->retries <= 0) {
2382 DBF_DEV_EVENT(DBF_ERR, device, "%s",
2383 "Unable to allocate ERP request");
2384 cqr->status = DASD_CQR_FAILED;
2385 cqr->stopclk = get_tod_clock();
2386 } else {
2387 DBF_DEV_EVENT(DBF_ERR, device,
2388 "Unable to allocate ERP request "
2389 "(%i retries left)",
2390 cqr->retries);
2391 dasd_block_set_timer(device->block, (HZ << 3));
2392 }
2393 return erp;
2394 }
2395
2396 ccw = cqr->cpaddr;
2397 if (cqr->cpmode == 1) {
2398
2399 erp->cpmode = 1;
2400 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2401 tcw = erp->cpaddr;
2402 tsb = (struct tsb *) &tcw[1];
2403 *tcw = *((struct tcw *)cqr->cpaddr);
2404 tcw->tsb = (long)tsb;
2405 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
2406
2407 erp->cpaddr = cqr->cpaddr;
2408 } else {
2409
2410 ccw = erp->cpaddr;
2411 ccw->cmd_code = CCW_CMD_NOOP;
2412 ccw->flags = CCW_FLAG_CC;
2413 ccw++;
2414 ccw->cmd_code = CCW_CMD_TIC;
2415 ccw->cda = (long)(cqr->cpaddr);
2416 }
2417
2418 erp->flags = cqr->flags;
2419 erp->function = dasd_3990_erp_add_erp;
2420 erp->refers = cqr;
2421 erp->startdev = device;
2422 erp->memdev = device;
2423 erp->block = cqr->block;
2424 erp->magic = cqr->magic;
2425 erp->expires = cqr->expires;
2426 erp->retries = 256;
2427 erp->buildclk = get_tod_clock();
2428 erp->status = DASD_CQR_FILLED;
2429
2430 return erp;
2431}
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448static struct dasd_ccw_req *
2449dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2450{
2451
2452 struct dasd_ccw_req *erp = NULL;
2453
2454
2455 erp = dasd_3990_erp_add_erp(cqr);
2456
2457 if (IS_ERR(erp))
2458 return erp;
2459
2460
2461 if (erp != cqr) {
2462
2463 erp = dasd_3990_erp_inspect(erp);
2464 }
2465
2466 return erp;
2467
2468}
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2489 struct dasd_ccw_req *cqr2)
2490{
2491 char *sense1, *sense2;
2492
2493 if (cqr1->startdev != cqr2->startdev)
2494 return 0;
2495
2496 sense1 = dasd_get_sense(&cqr1->irb);
2497 sense2 = dasd_get_sense(&cqr2->irb);
2498
2499
2500 if (!sense1 != !sense2)
2501 return 0;
2502
2503 if (!sense1 && !sense2) {
2504 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2505 SCHN_STAT_CHN_CTRL_CHK)) ==
2506 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2507 SCHN_STAT_CHN_CTRL_CHK)))
2508 return 1;
2509 }
2510
2511 if (!(sense1 && sense2 &&
2512 (memcmp(sense1, sense2, 3) == 0) &&
2513 (sense1[27] == sense2[27]) &&
2514 (sense1[25] == sense2[25]))) {
2515
2516 return 0;
2517 }
2518
2519 return 1;
2520
2521}
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538static struct dasd_ccw_req *
2539dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2540{
2541
2542 struct dasd_ccw_req *erp_head = cqr,
2543 *erp_match = NULL;
2544 int match = 0;
2545
2546 if (cqr->refers == NULL) {
2547 return NULL;
2548 }
2549
2550
2551 do {
2552 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2553 erp_match = cqr;
2554 cqr = cqr->refers;
2555
2556 } while ((cqr->refers != NULL) && (!match));
2557
2558 if (!match) {
2559 return NULL;
2560 }
2561
2562 return erp_match;
2563
2564}
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582static struct dasd_ccw_req *
2583dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2584{
2585
2586 struct dasd_device *device = erp->startdev;
2587 char *sense = dasd_get_sense(&erp->irb);
2588
2589
2590 if ((erp->function == dasd_3990_erp_bus_out) ||
2591 (erp->function == dasd_3990_erp_action_1) ||
2592 (erp->function == dasd_3990_erp_action_4)) {
2593
2594 erp = dasd_3990_erp_action_1(erp);
2595
2596 } else if (erp->function == dasd_3990_erp_action_1_sec) {
2597 erp = dasd_3990_erp_action_1_sec(erp);
2598 } else if (erp->function == dasd_3990_erp_action_5) {
2599
2600
2601
2602 erp = dasd_3990_erp_action_1(erp);
2603
2604 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
2605
2606
2607
2608
2609 switch (sense[25]) {
2610 case 0x17:
2611 case 0x57:{
2612 erp = dasd_3990_erp_DCTL(erp, 0x20);
2613 break;
2614 }
2615 case 0x18:
2616 case 0x58:{
2617 erp = dasd_3990_erp_DCTL(erp, 0x40);
2618 break;
2619 }
2620 case 0x19:
2621 case 0x59:{
2622 erp = dasd_3990_erp_DCTL(erp, 0x80);
2623 break;
2624 }
2625 default:
2626 DBF_DEV_EVENT(DBF_WARNING, device,
2627 "invalid subcommand modifier 0x%x "
2628 "for Diagnostic Control Command",
2629 sense[25]);
2630 }
2631 }
2632
2633
2634 } else if (sense &&
2635 ((erp->function == dasd_3990_erp_compound_retry) ||
2636 (erp->function == dasd_3990_erp_compound_path) ||
2637 (erp->function == dasd_3990_erp_compound_code) ||
2638 (erp->function == dasd_3990_erp_compound_config))) {
2639
2640 erp = dasd_3990_erp_compound(erp, sense);
2641
2642 } else {
2643
2644
2645
2646
2647 dev_err(&device->cdev->dev,
2648 "ERP %p has run out of retries and failed\n", erp);
2649
2650 erp->status = DASD_CQR_FAILED;
2651 }
2652
2653 return erp;
2654
2655}
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676static struct dasd_ccw_req *
2677dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2678 struct dasd_ccw_req *erp)
2679{
2680
2681 struct dasd_device *device = erp_head->startdev;
2682 struct dasd_ccw_req *erp_done = erp_head;
2683 struct dasd_ccw_req *erp_free = NULL;
2684
2685
2686 while (erp_done != erp) {
2687
2688 if (erp_done == NULL)
2689 panic(PRINTK_HEADER "Programming error in ERP! The "
2690 "original request was lost\n");
2691
2692
2693 list_del(&erp_done->blocklist);
2694
2695 erp_free = erp_done;
2696 erp_done = erp_done->refers;
2697
2698
2699 dasd_free_erp_request(erp_free, erp_free->memdev);
2700
2701 }
2702
2703 if (erp->retries > 0) {
2704
2705 char *sense = dasd_get_sense(&erp->refers->irb);
2706
2707
2708 if (sense && erp->function == dasd_3990_erp_action_4) {
2709
2710 erp = dasd_3990_erp_action_4(erp, sense);
2711
2712 } else if (sense &&
2713 erp->function == dasd_3990_erp_action_1B_32) {
2714
2715 erp = dasd_3990_update_1B(erp, sense);
2716
2717 } else if (sense && erp->function == dasd_3990_erp_int_req) {
2718
2719 erp = dasd_3990_erp_int_req(erp);
2720
2721 } else {
2722
2723 DBF_DEV_EVENT(DBF_DEBUG, device,
2724 "%i retries left for erp %p",
2725 erp->retries, erp);
2726
2727
2728 erp->status = DASD_CQR_FILLED;
2729 }
2730
2731 } else {
2732
2733
2734 erp = dasd_3990_erp_further_erp(erp);
2735 }
2736
2737 return erp;
2738
2739}
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758struct dasd_ccw_req *
2759dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2760{
2761 struct dasd_ccw_req *erp = NULL;
2762 struct dasd_device *device = cqr->startdev;
2763 struct dasd_ccw_req *temp_erp = NULL;
2764
2765 if (device->features & DASD_FEATURE_ERPLOG) {
2766
2767 dev_err(&device->cdev->dev,
2768 "ERP chain at BEGINNING of ERP-ACTION\n");
2769 for (temp_erp = cqr;
2770 temp_erp != NULL; temp_erp = temp_erp->refers) {
2771
2772 dev_err(&device->cdev->dev,
2773 "ERP %p (%02x) refers to %p\n",
2774 temp_erp, temp_erp->status,
2775 temp_erp->refers);
2776 }
2777 }
2778
2779
2780 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2781 (scsw_dstat(&cqr->irb.scsw) ==
2782 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
2783
2784 DBF_DEV_EVENT(DBF_DEBUG, device,
2785 "ERP called for successful request %p"
2786 " - NO ERP necessary", cqr);
2787
2788 cqr->status = DASD_CQR_DONE;
2789
2790 return cqr;
2791 }
2792
2793
2794 erp = dasd_3990_erp_in_erp(cqr);
2795
2796 if (erp == NULL) {
2797
2798 erp = dasd_3990_erp_additional_erp(cqr);
2799 if (IS_ERR(erp))
2800 return erp;
2801 } else {
2802
2803 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2804 }
2805
2806 if (device->features & DASD_FEATURE_ERPLOG) {
2807
2808 dev_err(&device->cdev->dev,
2809 "ERP chain at END of ERP-ACTION\n");
2810 for (temp_erp = erp;
2811 temp_erp != NULL; temp_erp = temp_erp->refers) {
2812
2813 dev_err(&device->cdev->dev,
2814 "ERP %p (%02x) refers to %p\n",
2815 temp_erp, temp_erp->status,
2816 temp_erp->refers);
2817 }
2818 }
2819
2820
2821 if (list_empty(&erp->blocklist)) {
2822 cqr->status = DASD_CQR_IN_ERP;
2823
2824 list_add_tail(&erp->blocklist, &cqr->blocklist);
2825 }
2826
2827
2828
2829 return erp;
2830
2831}
2832