1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
4 * Holger Smolinski <Holger.Smolinski@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * Copyright IBM Corp. 2000, 2001
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
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));
26
27 /*
28 *****************************************************************************
29 * SECTION ERP HANDLING
30 *****************************************************************************
31 */
32 /*
33 *****************************************************************************
34 * 24 and 32 byte sense ERP functions
35 *****************************************************************************
36 */
37
38 /*
39 * DASD_3990_ERP_CLEANUP
40 *
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
44 *
45 * PARAMETER
46 * erp request to be blocked
47 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
48 *
49 * RETURN VALUES
50 * cqr original cqr
51 */
52 static struct dasd_ccw_req *
dasd_3990_erp_cleanup(struct dasd_ccw_req * erp,char final_status)53 dasd_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 } /* end dasd_3990_erp_cleanup */
62
63 /*
64 * DASD_3990_ERP_BLOCK_QUEUE
65 *
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.
70 */
dasd_3990_erp_block_queue(struct dasd_ccw_req * erp,int expires)71 static 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 * DASD_3990_ERP_INT_REQ
92 *
93 * DESCRIPTION
94 * Handles 'Intervention Required' error.
95 * This means either device offline or not installed.
96 *
97 * PARAMETER
98 * erp current erp
99 * RETURN VALUES
100 * erp modified erp
101 */
102 static struct dasd_ccw_req *
dasd_3990_erp_int_req(struct dasd_ccw_req * erp)103 dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
104 {
105
106 struct dasd_device *device = erp->startdev;
107
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) {
112
113 erp->retries = 256;
114 erp->function = dasd_3990_erp_int_req;
115
116 } else {
117
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");
122
123 dasd_3990_erp_block_queue(erp, 60*HZ);
124 }
125
126 return erp;
127
128 } /* end dasd_3990_erp_int_req */
129
130 /*
131 * DASD_3990_ERP_ALTERNATE_PATH
132 *
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.
137 *
138 * PARAMETER
139 * erp pointer to the current ERP
140 *
141 * RETURN VALUES
142 * erp modified pointer to the ERP
143 */
144 static void
dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)145 dasd_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 /* 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 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 /* 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);
174
175 /* post request with permanent error */
176 erp->status = DASD_CQR_FAILED;
177 }
178 } /* end dasd_3990_erp_alternate_path */
179
180 /*
181 * DASD_3990_ERP_DCTL
182 *
183 * DESCRIPTION
184 * Setup cqr to do the Diagnostic Control (DCTL) command with an
185 * Inhibit Write subcommand (0x20) and the given modifier.
186 *
187 * PARAMETER
188 * erp pointer to the current (failed) ERP
189 * modifier subcommand modifier
190 *
191 * RETURN VALUES
192 * dctl_cqr pointer to NEW dctl_cqr
193 *
194 */
195 static struct dasd_ccw_req *
dasd_3990_erp_DCTL(struct dasd_ccw_req * erp,char modifier)196 dasd_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(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; /* Inhibit Write */
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)virt_to_phys(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 } /* end dasd_3990_erp_DCTL */
240
241 /*
242 * DASD_3990_ERP_ACTION_1
243 *
244 * DESCRIPTION
245 * Setup ERP to do the ERP action 1 (see Reference manual).
246 * Repeat the operation on a different channel path.
247 * As deviation from the recommended recovery action, we reset the path mask
248 * after we have tried each path and go through all paths a second time.
249 * This will cover situations where only one path at a time is actually down,
250 * but all paths fail and recover just with the same sequence and timing as
251 * we try to use them (flapping links).
252 * If all alternate paths have been tried twice, the request is posted with
253 * a permanent error.
254 *
255 * PARAMETER
256 * erp pointer to the current ERP
257 *
258 * RETURN VALUES
259 * erp pointer to the ERP
260 *
261 */
dasd_3990_erp_action_1_sec(struct dasd_ccw_req * erp)262 static 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
dasd_3990_erp_action_1(struct dasd_ccw_req * erp)269 static 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 } /* end dasd_3990_erp_action_1(b) */
282
283 /*
284 * DASD_3990_ERP_ACTION_4
285 *
286 * DESCRIPTION
287 * Setup ERP to do the ERP action 4 (see Reference manual).
288 * Set the current request to PENDING to block the CQR queue for that device
289 * until the state change interrupt appears.
290 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
291 * missing.
292 *
293 * PARAMETER
294 * sense sense data of the actual error
295 * erp pointer to the current ERP
296 *
297 * RETURN VALUES
298 * erp pointer to the ERP
299 *
300 */
301 static struct dasd_ccw_req *
dasd_3990_erp_action_4(struct dasd_ccw_req * erp,char * sense)302 dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
303 {
304
305 struct dasd_device *device = erp->startdev;
306
307 /* first time set initial retry counter and erp_function */
308 /* and retry once without waiting for state change pending */
309 /* interrupt (this enables easier enqueing of the cqr) */
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)) { /* state change pending */
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)) { /* busy */
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 /* no state change pending - retry */
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 } /* end dasd_3990_erp_action_4 */
347
348 /*
349 *****************************************************************************
350 * 24 byte sense ERP functions (only)
351 *****************************************************************************
352 */
353
354 /*
355 * DASD_3990_ERP_ACTION_5
356 *
357 * DESCRIPTION
358 * Setup ERP to do the ERP action 5 (see Reference manual).
359 * NOTE: Further handling is done in xxx_further_erp after the retries.
360 *
361 * PARAMETER
362 * erp pointer to the current ERP
363 *
364 * RETURN VALUES
365 * erp pointer to the ERP
366 *
367 */
368 static struct dasd_ccw_req *
dasd_3990_erp_action_5(struct dasd_ccw_req * erp)369 dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
370 {
371
372 /* first of all retry */
373 erp->retries = 10;
374 erp->function = dasd_3990_erp_action_5;
375
376 return erp;
377
378 } /* end dasd_3990_erp_action_5 */
379
380 /*
381 * DASD_3990_HANDLE_ENV_DATA
382 *
383 * DESCRIPTION
384 * Handles 24 byte 'Environmental data present'.
385 * Does a analysis of the sense data (message Format)
386 * and prints the error messages.
387 *
388 * PARAMETER
389 * sense current sense data
390 *
391 * RETURN VALUES
392 * void
393 */
394 static void
dasd_3990_handle_env_data(struct dasd_ccw_req * erp,char * sense)395 dasd_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: /* Format 0 - Program or System Checks */
405
406 if (sense[1] & 0x10) { /* check message to operator bit */
407
408 switch (msg_no) {
409 case 0x00: /* No Message */
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: /* No Message */
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: /* Format 1 - Device Equipment Checks */
508 switch (msg_no) {
509 case 0x00: /* No Message */
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: /* Format 2 - 3990 Equipment Checks */
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: /* Format 3 - 3990 Control Checks */
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: /* Format 4 - Data Checks */
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: /* Format 5 - Data Check with displacement information */
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: /* Format 6 - Usage Statistics/Overrun Errors */
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: /* Format 7 - Device Connection Control Checks */
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: /* Format 8 - Additional Device Equipment Checks */
862 switch (msg_no) {
863 case 0x00: /* No Message */
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: /* Format 9 - Device Read, Write, and Seek Checks */
915 switch (msg_no) {
916 case 0x00:
917 break; /* No Message */
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: /* Format F - Cache Storage Checks */
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 /* call extended error reporting (EER) */
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: /* unknown message format - should not happen
1008 internal error 03 - unknown message format */
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 } /* end switch message format */
1015
1016 } /* end dasd_3990_handle_env_data */
1017
1018 /*
1019 * DASD_3990_ERP_COM_REJ
1020 *
1021 * DESCRIPTION
1022 * Handles 24 byte 'Command Reject' error.
1023 *
1024 * PARAMETER
1025 * erp current erp_head
1026 * sense current sense data
1027 *
1028 * RETURN VALUES
1029 * erp 'new' erp_head - pointer to new ERP
1030 */
1031 static struct dasd_ccw_req *
dasd_3990_erp_com_rej(struct dasd_ccw_req * erp,char * sense)1032 dasd_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 /* env data present (ACTION 10 - retry should work) */
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 if (sense[7] == SNS7_INVALID_ON_SEC) {
1054 dev_err(&device->cdev->dev, "An I/O request was rejected on a copy pair secondary device\n");
1055 /* suppress dump of sense data for this error */
1056 set_bit(DASD_CQR_SUPPRESS_CR, &erp->refers->flags);
1057 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1058 } else {
1059 /* fatal error - set status to FAILED
1060 internal error 09 - Command Reject */
1061 if (!test_bit(DASD_CQR_SUPPRESS_CR, &erp->flags))
1062 dev_err(&device->cdev->dev,
1063 "An error occurred in the DASD device driver, reason=09\n");
1064
1065 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1066 }
1067
1068 return erp;
1069
1070 } /* end dasd_3990_erp_com_rej */
1071
1072 /*
1073 * DASD_3990_ERP_BUS_OUT
1074 *
1075 * DESCRIPTION
1076 * Handles 24 byte 'Bus Out Parity Check' error.
1077 *
1078 * PARAMETER
1079 * erp current erp_head
1080 * RETURN VALUES
1081 * erp new erp_head - pointer to new ERP
1082 */
1083 static struct dasd_ccw_req *
dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)1084 dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1085 {
1086
1087 struct dasd_device *device = erp->startdev;
1088
1089 /* first time set initial retry counter and erp_function */
1090 /* and retry once without blocking queue */
1091 /* (this enables easier enqueing of the cqr) */
1092 if (erp->function != dasd_3990_erp_bus_out) {
1093 erp->retries = 256;
1094 erp->function = dasd_3990_erp_bus_out;
1095
1096 } else {
1097
1098 /* issue a message and wait for 'device ready' interrupt */
1099 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1100 "bus out parity error or BOPC requested by "
1101 "channel");
1102
1103 dasd_3990_erp_block_queue(erp, 60*HZ);
1104
1105 }
1106
1107 return erp;
1108
1109 } /* end dasd_3990_erp_bus_out */
1110
1111 /*
1112 * DASD_3990_ERP_EQUIP_CHECK
1113 *
1114 * DESCRIPTION
1115 * Handles 24 byte 'Equipment Check' error.
1116 *
1117 * PARAMETER
1118 * erp current erp_head
1119 * RETURN VALUES
1120 * erp new erp_head - pointer to new ERP
1121 */
1122 static struct dasd_ccw_req *
dasd_3990_erp_equip_check(struct dasd_ccw_req * erp,char * sense)1123 dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1124 {
1125
1126 struct dasd_device *device = erp->startdev;
1127
1128 erp->function = dasd_3990_erp_equip_check;
1129
1130 if (sense[1] & SNS1_WRITE_INHIBITED) {
1131 dev_info(&device->cdev->dev,
1132 "Write inhibited path encountered\n");
1133
1134 /* vary path offline
1135 internal error 04 - Path should be varied off-line.*/
1136 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1137 "device driver, reason=%s\n", "04");
1138
1139 erp = dasd_3990_erp_action_1(erp);
1140
1141 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1142
1143 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1144 "Equipment Check - " "environmental data present");
1145
1146 dasd_3990_handle_env_data(erp, sense);
1147
1148 erp = dasd_3990_erp_action_4(erp, sense);
1149
1150 } else if (sense[1] & SNS1_PERM_ERR) {
1151
1152 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1153 "Equipment Check - retry exhausted or "
1154 "undesirable");
1155
1156 erp = dasd_3990_erp_action_1(erp);
1157
1158 } else {
1159 /* all other equipment checks - Action 5 */
1160 /* rest is done when retries == 0 */
1161 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1162 "Equipment check or processing error");
1163
1164 erp = dasd_3990_erp_action_5(erp);
1165 }
1166 return erp;
1167
1168 } /* end dasd_3990_erp_equip_check */
1169
1170 /*
1171 * DASD_3990_ERP_DATA_CHECK
1172 *
1173 * DESCRIPTION
1174 * Handles 24 byte 'Data Check' error.
1175 *
1176 * PARAMETER
1177 * erp current erp_head
1178 * RETURN VALUES
1179 * erp new erp_head - pointer to new ERP
1180 */
1181 static struct dasd_ccw_req *
dasd_3990_erp_data_check(struct dasd_ccw_req * erp,char * sense)1182 dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1183 {
1184
1185 struct dasd_device *device = erp->startdev;
1186
1187 erp->function = dasd_3990_erp_data_check;
1188
1189 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1190
1191 /* issue message that the data has been corrected */
1192 dev_emerg(&device->cdev->dev,
1193 "Data recovered during retry with PCI "
1194 "fetch mode active\n");
1195
1196 /* not possible to handle this situation in Linux */
1197 panic("No way to inform application about the possibly "
1198 "incorrect data");
1199
1200 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1201
1202 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1203 "Uncorrectable data check recovered secondary "
1204 "addr of duplex pair");
1205
1206 erp = dasd_3990_erp_action_4(erp, sense);
1207
1208 } else if (sense[1] & SNS1_PERM_ERR) {
1209
1210 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1211 "Uncorrectable data check with internal "
1212 "retry exhausted");
1213
1214 erp = dasd_3990_erp_action_1(erp);
1215
1216 } else {
1217 /* all other data checks */
1218 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1219 "Uncorrectable data check with retry count "
1220 "exhausted...");
1221
1222 erp = dasd_3990_erp_action_5(erp);
1223 }
1224
1225 return erp;
1226
1227 } /* end dasd_3990_erp_data_check */
1228
1229 /*
1230 * DASD_3990_ERP_OVERRUN
1231 *
1232 * DESCRIPTION
1233 * Handles 24 byte 'Overrun' error.
1234 *
1235 * PARAMETER
1236 * erp current erp_head
1237 * RETURN VALUES
1238 * erp new erp_head - pointer to new ERP
1239 */
1240 static struct dasd_ccw_req *
dasd_3990_erp_overrun(struct dasd_ccw_req * erp,char * sense)1241 dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1242 {
1243
1244 struct dasd_device *device = erp->startdev;
1245
1246 erp->function = dasd_3990_erp_overrun;
1247
1248 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1249 "Overrun - service overrun or overrun"
1250 " error requested by channel");
1251
1252 erp = dasd_3990_erp_action_5(erp);
1253
1254 return erp;
1255
1256 } /* end dasd_3990_erp_overrun */
1257
1258 /*
1259 * DASD_3990_ERP_INV_FORMAT
1260 *
1261 * DESCRIPTION
1262 * Handles 24 byte 'Invalid Track Format' error.
1263 *
1264 * PARAMETER
1265 * erp current erp_head
1266 * RETURN VALUES
1267 * erp new erp_head - pointer to new ERP
1268 */
1269 static struct dasd_ccw_req *
dasd_3990_erp_inv_format(struct dasd_ccw_req * erp,char * sense)1270 dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1271 {
1272
1273 struct dasd_device *device = erp->startdev;
1274
1275 erp->function = dasd_3990_erp_inv_format;
1276
1277 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1278
1279 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1280 "Track format error when destaging or "
1281 "staging data");
1282
1283 dasd_3990_handle_env_data(erp, sense);
1284
1285 erp = dasd_3990_erp_action_4(erp, sense);
1286
1287 } else {
1288 /* internal error 06 - The track format is not valid*/
1289 dev_err(&device->cdev->dev,
1290 "An error occurred in the DASD device driver, "
1291 "reason=%s\n", "06");
1292
1293 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1294 }
1295
1296 return erp;
1297
1298 } /* end dasd_3990_erp_inv_format */
1299
1300 /*
1301 * DASD_3990_ERP_EOC
1302 *
1303 * DESCRIPTION
1304 * Handles 24 byte 'End-of-Cylinder' error.
1305 *
1306 * PARAMETER
1307 * erp already added default erp
1308 * RETURN VALUES
1309 * erp pointer to original (failed) cqr.
1310 */
1311 static struct dasd_ccw_req *
dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp,char * sense)1312 dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1313 {
1314
1315 struct dasd_device *device = default_erp->startdev;
1316
1317 dev_err(&device->cdev->dev,
1318 "The cylinder data for accessing the DASD is inconsistent\n");
1319
1320 /* implement action 7 - BUG */
1321 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1322
1323 } /* end dasd_3990_erp_EOC */
1324
1325 /*
1326 * DASD_3990_ERP_ENV_DATA
1327 *
1328 * DESCRIPTION
1329 * Handles 24 byte 'Environmental-Data Present' error.
1330 *
1331 * PARAMETER
1332 * erp current erp_head
1333 * RETURN VALUES
1334 * erp new erp_head - pointer to new ERP
1335 */
1336 static struct dasd_ccw_req *
dasd_3990_erp_env_data(struct dasd_ccw_req * erp,char * sense)1337 dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1338 {
1339
1340 struct dasd_device *device = erp->startdev;
1341
1342 erp->function = dasd_3990_erp_env_data;
1343
1344 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
1345
1346 dasd_3990_handle_env_data(erp, sense);
1347
1348 /* don't retry on disabled interface */
1349 if (sense[7] != 0x0F) {
1350 erp = dasd_3990_erp_action_4(erp, sense);
1351 } else {
1352 erp->status = DASD_CQR_FILLED;
1353 }
1354
1355 return erp;
1356
1357 } /* end dasd_3990_erp_env_data */
1358
1359 /*
1360 * DASD_3990_ERP_NO_REC
1361 *
1362 * DESCRIPTION
1363 * Handles 24 byte 'No Record Found' error.
1364 *
1365 * PARAMETER
1366 * erp already added default ERP
1367 *
1368 * RETURN VALUES
1369 * erp new erp_head - pointer to new ERP
1370 */
1371 static struct dasd_ccw_req *
dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp,char * sense)1372 dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1373 {
1374
1375 struct dasd_device *device = default_erp->startdev;
1376
1377 /*
1378 * In some cases the 'No Record Found' error might be expected and
1379 * log messages shouldn't be written then.
1380 * Check if the according suppress bit is set.
1381 */
1382 if (!test_bit(DASD_CQR_SUPPRESS_NRF, &default_erp->flags))
1383 dev_err(&device->cdev->dev,
1384 "The specified record was not found\n");
1385
1386 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1387
1388 } /* end dasd_3990_erp_no_rec */
1389
1390 /*
1391 * DASD_3990_ERP_FILE_PROT
1392 *
1393 * DESCRIPTION
1394 * Handles 24 byte 'File Protected' error.
1395 * Note: Seek related recovery is not implemented because
1396 * wee don't use the seek command yet.
1397 *
1398 * PARAMETER
1399 * erp current erp_head
1400 * RETURN VALUES
1401 * erp new erp_head - pointer to new ERP
1402 */
1403 static struct dasd_ccw_req *
dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)1404 dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1405 {
1406
1407 struct dasd_device *device = erp->startdev;
1408
1409 dev_err(&device->cdev->dev,
1410 "Accessing the DASD failed because of a hardware error\n");
1411
1412 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1413
1414 } /* end dasd_3990_erp_file_prot */
1415
1416 /*
1417 * DASD_3990_ERP_INSPECT_ALIAS
1418 *
1419 * DESCRIPTION
1420 * Checks if the original request was started on an alias device.
1421 * If yes, it modifies the original and the erp request so that
1422 * the erp request can be started on a base device.
1423 *
1424 * PARAMETER
1425 * erp pointer to the currently created default ERP
1426 *
1427 * RETURN VALUES
1428 * erp pointer to the modified ERP, or NULL
1429 */
1430
dasd_3990_erp_inspect_alias(struct dasd_ccw_req * erp)1431 static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1432 struct dasd_ccw_req *erp)
1433 {
1434 struct dasd_ccw_req *cqr = erp->refers;
1435 char *sense;
1436
1437 if (cqr->block &&
1438 (cqr->block->base != cqr->startdev)) {
1439
1440 sense = dasd_get_sense(&erp->refers->irb);
1441 /*
1442 * dynamic pav may have changed base alias mapping
1443 */
1444 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
1445 && (sense[0] == 0x10) && (sense[7] == 0x0F)
1446 && (sense[8] == 0x67)) {
1447 /*
1448 * remove device from alias handling to prevent new
1449 * requests from being scheduled on the
1450 * wrong alias device
1451 */
1452 dasd_alias_remove_device(cqr->startdev);
1453
1454 /* schedule worker to reload device */
1455 dasd_reload_device(cqr->startdev);
1456 }
1457
1458 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
1459 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
1460 "ERP on alias device for request %p,"
1461 " recover on base device %s", cqr,
1462 dev_name(&cqr->block->base->cdev->dev));
1463 }
1464 dasd_eckd_reset_ccw_to_base_io(cqr);
1465 erp->startdev = cqr->block->base;
1466 erp->function = dasd_3990_erp_inspect_alias;
1467 return erp;
1468 } else
1469 return NULL;
1470 }
1471
1472
1473 /*
1474 * DASD_3990_ERP_INSPECT_24
1475 *
1476 * DESCRIPTION
1477 * Does a detailed inspection of the 24 byte sense data
1478 * and sets up a related error recovery action.
1479 *
1480 * PARAMETER
1481 * sense sense data of the actual error
1482 * erp pointer to the currently created default ERP
1483 *
1484 * RETURN VALUES
1485 * erp pointer to the (addtitional) ERP
1486 */
1487 static struct dasd_ccw_req *
dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp,char * sense)1488 dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1489 {
1490
1491 struct dasd_ccw_req *erp_filled = NULL;
1492
1493 /* Check sense for .... */
1494 /* 'Command Reject' */
1495 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1496 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1497 }
1498 /* 'Intervention Required' */
1499 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1500 erp_filled = dasd_3990_erp_int_req(erp);
1501 }
1502 /* 'Bus Out Parity Check' */
1503 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1504 erp_filled = dasd_3990_erp_bus_out(erp);
1505 }
1506 /* 'Equipment Check' */
1507 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1508 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1509 }
1510 /* 'Data Check' */
1511 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1512 erp_filled = dasd_3990_erp_data_check(erp, sense);
1513 }
1514 /* 'Overrun' */
1515 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1516 erp_filled = dasd_3990_erp_overrun(erp, sense);
1517 }
1518 /* 'Invalid Track Format' */
1519 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1520 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1521 }
1522 /* 'End-of-Cylinder' */
1523 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1524 erp_filled = dasd_3990_erp_EOC(erp, sense);
1525 }
1526 /* 'Environmental Data' */
1527 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1528 erp_filled = dasd_3990_erp_env_data(erp, sense);
1529 }
1530 /* 'No Record Found' */
1531 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1532 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1533 }
1534 /* 'File Protected' */
1535 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1536 erp_filled = dasd_3990_erp_file_prot(erp);
1537 }
1538 /* other (unknown) error - do default ERP */
1539 if (erp_filled == NULL) {
1540
1541 erp_filled = erp;
1542 }
1543
1544 return erp_filled;
1545
1546 } /* END dasd_3990_erp_inspect_24 */
1547
1548 /*
1549 *****************************************************************************
1550 * 32 byte sense ERP functions (only)
1551 *****************************************************************************
1552 */
1553
1554 /*
1555 * DASD_3990_ERPACTION_10_32
1556 *
1557 * DESCRIPTION
1558 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1559 * Just retry and if retry doesn't work, return with error.
1560 *
1561 * PARAMETER
1562 * erp current erp_head
1563 * sense current sense data
1564 * RETURN VALUES
1565 * erp modified erp_head
1566 */
1567 static struct dasd_ccw_req *
dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp,char * sense)1568 dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1569 {
1570
1571 struct dasd_device *device = erp->startdev;
1572
1573 erp->retries = 256;
1574 erp->function = dasd_3990_erp_action_10_32;
1575
1576 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
1577
1578 return erp;
1579
1580 } /* end dasd_3990_erp_action_10_32 */
1581
1582 /*
1583 * DASD_3990_ERP_ACTION_1B_32
1584 *
1585 * DESCRIPTION
1586 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
1587 * A write operation could not be finished because of an unexpected
1588 * condition.
1589 * The already created 'default erp' is used to get the link to
1590 * the erp chain, but it can not be used for this recovery
1591 * action because it contains no DE/LO data space.
1592 *
1593 * PARAMETER
1594 * default_erp already added default erp.
1595 * sense current sense data
1596 *
1597 * RETURN VALUES
1598 * erp new erp or
1599 * default_erp in case of imprecise ending or error
1600 */
1601 static struct dasd_ccw_req *
dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp,char * sense)1602 dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1603 {
1604
1605 struct dasd_device *device = default_erp->startdev;
1606 __u32 cpa = 0;
1607 struct dasd_ccw_req *cqr;
1608 struct dasd_ccw_req *erp;
1609 struct DE_eckd_data *DE_data;
1610 struct PFX_eckd_data *PFX_data;
1611 char *LO_data; /* LO_eckd_data_t */
1612 struct ccw1 *ccw, *oldccw;
1613
1614 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1615 "Write not finished because of unexpected condition");
1616
1617 default_erp->function = dasd_3990_erp_action_1B_32;
1618
1619 /* determine the original cqr */
1620 cqr = default_erp;
1621
1622 while (cqr->refers != NULL) {
1623 cqr = cqr->refers;
1624 }
1625
1626 if (scsw_is_tm(&cqr->irb.scsw)) {
1627 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1628 "32 bit sense, action 1B is not defined"
1629 " in transport mode - just retry");
1630 return default_erp;
1631 }
1632
1633 /* for imprecise ending just do default erp */
1634 if (sense[1] & 0x01) {
1635 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1636 "Imprecise ending is set - just retry");
1637
1638 return default_erp;
1639 }
1640
1641 /* determine the address of the CCW to be restarted */
1642 /* Imprecise ending is not set -> addr from IRB-SCSW */
1643 cpa = default_erp->refers->irb.scsw.cmd.cpa;
1644
1645 if (cpa == 0) {
1646 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1647 "Unable to determine address of the CCW "
1648 "to be restarted");
1649
1650 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1651 }
1652
1653 /* Build new ERP request including DE/LO */
1654 erp = dasd_alloc_erp_request(cqr->magic,
1655 2 + 1,/* DE/LO + TIC */
1656 sizeof(struct DE_eckd_data) +
1657 sizeof(struct LO_eckd_data), device);
1658
1659 if (IS_ERR(erp)) {
1660 /* internal error 01 - Unable to allocate ERP */
1661 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1662 "device driver, reason=%s\n", "01");
1663 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1664 }
1665
1666 /* use original DE */
1667 DE_data = erp->data;
1668 oldccw = cqr->cpaddr;
1669 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1670 PFX_data = cqr->data;
1671 memcpy(DE_data, &PFX_data->define_extent,
1672 sizeof(struct DE_eckd_data));
1673 } else
1674 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
1675
1676 /* create LO */
1677 LO_data = erp->data + sizeof(struct DE_eckd_data);
1678
1679 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1680 /* should not */
1681 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1682 }
1683
1684 if ((sense[7] & 0x3F) == 0x01) {
1685 /* operation code is WRITE DATA -> data area orientation */
1686 LO_data[0] = 0x81;
1687
1688 } else if ((sense[7] & 0x3F) == 0x03) {
1689 /* operation code is FORMAT WRITE -> index orientation */
1690 LO_data[0] = 0xC3;
1691
1692 } else {
1693 LO_data[0] = sense[7]; /* operation */
1694 }
1695
1696 LO_data[1] = sense[8]; /* auxiliary */
1697 LO_data[2] = sense[9];
1698 LO_data[3] = sense[3]; /* count */
1699 LO_data[4] = sense[29]; /* seek_addr.cyl */
1700 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1701 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1702
1703 memcpy(&(LO_data[8]), &(sense[11]), 8);
1704
1705 /* create DE ccw */
1706 ccw = erp->cpaddr;
1707 memset(ccw, 0, sizeof(struct ccw1));
1708 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1709 ccw->flags = CCW_FLAG_CC;
1710 ccw->count = 16;
1711 ccw->cda = (__u32)virt_to_phys(DE_data);
1712
1713 /* create LO ccw */
1714 ccw++;
1715 memset(ccw, 0, sizeof(struct ccw1));
1716 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1717 ccw->flags = CCW_FLAG_CC;
1718 ccw->count = 16;
1719 ccw->cda = (__u32)virt_to_phys(LO_data);
1720
1721 /* TIC to the failed ccw */
1722 ccw++;
1723 ccw->cmd_code = CCW_CMD_TIC;
1724 ccw->cda = cpa;
1725
1726 /* fill erp related fields */
1727 erp->flags = default_erp->flags;
1728 erp->function = dasd_3990_erp_action_1B_32;
1729 erp->refers = default_erp->refers;
1730 erp->startdev = device;
1731 erp->memdev = device;
1732 erp->magic = default_erp->magic;
1733 erp->expires = default_erp->expires;
1734 erp->retries = 256;
1735 erp->buildclk = get_tod_clock();
1736 erp->status = DASD_CQR_FILLED;
1737
1738 /* remove the default erp */
1739 dasd_free_erp_request(default_erp, device);
1740
1741 return erp;
1742
1743 } /* end dasd_3990_erp_action_1B_32 */
1744
1745 /*
1746 * DASD_3990_UPDATE_1B
1747 *
1748 * DESCRIPTION
1749 * Handles the update to the 32 byte 'Action 1B' of Single Program
1750 * Action Codes in case the first action was not successful.
1751 * The already created 'previous_erp' is the currently not successful
1752 * ERP.
1753 *
1754 * PARAMETER
1755 * previous_erp already created previous erp.
1756 * sense current sense data
1757 * RETURN VALUES
1758 * erp modified erp
1759 */
1760 static struct dasd_ccw_req *
dasd_3990_update_1B(struct dasd_ccw_req * previous_erp,char * sense)1761 dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1762 {
1763
1764 struct dasd_device *device = previous_erp->startdev;
1765 __u32 cpa = 0;
1766 struct dasd_ccw_req *cqr;
1767 struct dasd_ccw_req *erp;
1768 char *LO_data; /* struct LO_eckd_data */
1769 struct ccw1 *ccw;
1770
1771 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1772 "Write not finished because of unexpected condition"
1773 " - follow on");
1774
1775 /* determine the original cqr */
1776 cqr = previous_erp;
1777
1778 while (cqr->refers != NULL) {
1779 cqr = cqr->refers;
1780 }
1781
1782 if (scsw_is_tm(&cqr->irb.scsw)) {
1783 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1784 "32 bit sense, action 1B, update,"
1785 " in transport mode - just retry");
1786 return previous_erp;
1787 }
1788
1789 /* for imprecise ending just do default erp */
1790 if (sense[1] & 0x01) {
1791 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1792 "Imprecise ending is set - just retry");
1793
1794 previous_erp->status = DASD_CQR_FILLED;
1795
1796 return previous_erp;
1797 }
1798
1799 /* determine the address of the CCW to be restarted */
1800 /* Imprecise ending is not set -> addr from IRB-SCSW */
1801 cpa = previous_erp->irb.scsw.cmd.cpa;
1802
1803 if (cpa == 0) {
1804 /* internal error 02 -
1805 Unable to determine address of the CCW to be restarted */
1806 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1807 "device driver, reason=%s\n", "02");
1808
1809 previous_erp->status = DASD_CQR_FAILED;
1810
1811 return previous_erp;
1812 }
1813
1814 erp = previous_erp;
1815
1816 /* update the LO with the new returned sense data */
1817 LO_data = erp->data + sizeof(struct DE_eckd_data);
1818
1819 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
1820 /* should not happen */
1821 previous_erp->status = DASD_CQR_FAILED;
1822
1823 return previous_erp;
1824 }
1825
1826 if ((sense[7] & 0x3F) == 0x01) {
1827 /* operation code is WRITE DATA -> data area orientation */
1828 LO_data[0] = 0x81;
1829
1830 } else if ((sense[7] & 0x3F) == 0x03) {
1831 /* operation code is FORMAT WRITE -> index orientation */
1832 LO_data[0] = 0xC3;
1833
1834 } else {
1835 LO_data[0] = sense[7]; /* operation */
1836 }
1837
1838 LO_data[1] = sense[8]; /* auxiliary */
1839 LO_data[2] = sense[9];
1840 LO_data[3] = sense[3]; /* count */
1841 LO_data[4] = sense[29]; /* seek_addr.cyl */
1842 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1843 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1844
1845 memcpy(&(LO_data[8]), &(sense[11]), 8);
1846
1847 /* TIC to the failed ccw */
1848 ccw = erp->cpaddr; /* addr of DE ccw */
1849 ccw++; /* addr of LE ccw */
1850 ccw++; /* addr of TIC ccw */
1851 ccw->cda = cpa;
1852
1853 erp->status = DASD_CQR_FILLED;
1854
1855 return erp;
1856
1857 } /* end dasd_3990_update_1B */
1858
1859 /*
1860 * DASD_3990_ERP_COMPOUND_RETRY
1861 *
1862 * DESCRIPTION
1863 * Handles the compound ERP action retry code.
1864 * NOTE: At least one retry is done even if zero is specified
1865 * by the sense data. This makes enqueueing of the request
1866 * easier.
1867 *
1868 * PARAMETER
1869 * sense sense data of the actual error
1870 * erp pointer to the currently created ERP
1871 *
1872 * RETURN VALUES
1873 * erp modified ERP pointer
1874 *
1875 */
1876 static void
dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp,char * sense)1877 dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1878 {
1879
1880 switch (sense[25] & 0x03) {
1881 case 0x00: /* no not retry */
1882 erp->retries = 1;
1883 break;
1884
1885 case 0x01: /* retry 2 times */
1886 erp->retries = 2;
1887 break;
1888
1889 case 0x02: /* retry 10 times */
1890 erp->retries = 10;
1891 break;
1892
1893 case 0x03: /* retry 256 times */
1894 erp->retries = 256;
1895 break;
1896
1897 default:
1898 BUG();
1899 }
1900
1901 erp->function = dasd_3990_erp_compound_retry;
1902
1903 } /* end dasd_3990_erp_compound_retry */
1904
1905 /*
1906 * DASD_3990_ERP_COMPOUND_PATH
1907 *
1908 * DESCRIPTION
1909 * Handles the compound ERP action for retry on alternate
1910 * channel path.
1911 *
1912 * PARAMETER
1913 * sense sense data of the actual error
1914 * erp pointer to the currently created ERP
1915 *
1916 * RETURN VALUES
1917 * erp modified ERP pointer
1918 *
1919 */
1920 static void
dasd_3990_erp_compound_path(struct dasd_ccw_req * erp,char * sense)1921 dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1922 {
1923 if (sense[25] & DASD_SENSE_BIT_3) {
1924 dasd_3990_erp_alternate_path(erp);
1925
1926 if (erp->status == DASD_CQR_FAILED &&
1927 !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
1928 /* reset the lpm and the status to be able to
1929 * try further actions. */
1930 erp->lpm = dasd_path_get_opm(erp->startdev);
1931 erp->status = DASD_CQR_NEED_ERP;
1932 }
1933 }
1934
1935 erp->function = dasd_3990_erp_compound_path;
1936
1937 } /* end dasd_3990_erp_compound_path */
1938
1939 /*
1940 * DASD_3990_ERP_COMPOUND_CODE
1941 *
1942 * DESCRIPTION
1943 * Handles the compound ERP action for retry code.
1944 *
1945 * PARAMETER
1946 * sense sense data of the actual error
1947 * erp pointer to the currently created ERP
1948 *
1949 * RETURN VALUES
1950 * erp NEW ERP pointer
1951 *
1952 */
1953 static struct dasd_ccw_req *
dasd_3990_erp_compound_code(struct dasd_ccw_req * erp,char * sense)1954 dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1955 {
1956
1957 if (sense[25] & DASD_SENSE_BIT_2) {
1958
1959 switch (sense[28]) {
1960 case 0x17:
1961 /* issue a Diagnostic Control command with an
1962 * Inhibit Write subcommand and controller modifier */
1963 erp = dasd_3990_erp_DCTL(erp, 0x20);
1964 break;
1965
1966 case 0x25:
1967 /* wait for 5 seconds and retry again */
1968 erp->retries = 1;
1969
1970 dasd_3990_erp_block_queue (erp, 5*HZ);
1971 break;
1972
1973 default:
1974 /* should not happen - continue */
1975 break;
1976 }
1977 }
1978
1979 erp->function = dasd_3990_erp_compound_code;
1980
1981 return erp;
1982
1983 } /* end dasd_3990_erp_compound_code */
1984
1985 /*
1986 * DASD_3990_ERP_COMPOUND_CONFIG
1987 *
1988 * DESCRIPTION
1989 * Handles the compound ERP action for configuration
1990 * dependent error.
1991 * Note: duplex handling is not implemented (yet).
1992 *
1993 * PARAMETER
1994 * sense sense data of the actual error
1995 * erp pointer to the currently created ERP
1996 *
1997 * RETURN VALUES
1998 * erp modified ERP pointer
1999 *
2000 */
2001 static void
dasd_3990_erp_compound_config(struct dasd_ccw_req * erp,char * sense)2002 dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2003 {
2004
2005 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2006
2007 /* set to suspended duplex state then restart
2008 internal error 05 - Set device to suspended duplex state
2009 should be done */
2010 struct dasd_device *device = erp->startdev;
2011 dev_err(&device->cdev->dev,
2012 "An error occurred in the DASD device driver, "
2013 "reason=%s\n", "05");
2014
2015 }
2016
2017 erp->function = dasd_3990_erp_compound_config;
2018
2019 } /* end dasd_3990_erp_compound_config */
2020
2021 /*
2022 * DASD_3990_ERP_COMPOUND
2023 *
2024 * DESCRIPTION
2025 * Does the further compound program action if
2026 * compound retry was not successful.
2027 *
2028 * PARAMETER
2029 * sense sense data of the actual error
2030 * erp pointer to the current (failed) ERP
2031 *
2032 * RETURN VALUES
2033 * erp (additional) ERP pointer
2034 *
2035 */
2036 static struct dasd_ccw_req *
dasd_3990_erp_compound(struct dasd_ccw_req * erp,char * sense)2037 dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2038 {
2039
2040 if ((erp->function == dasd_3990_erp_compound_retry) &&
2041 (erp->status == DASD_CQR_NEED_ERP)) {
2042
2043 dasd_3990_erp_compound_path(erp, sense);
2044 }
2045
2046 if ((erp->function == dasd_3990_erp_compound_path) &&
2047 (erp->status == DASD_CQR_NEED_ERP)) {
2048
2049 erp = dasd_3990_erp_compound_code(erp, sense);
2050 }
2051
2052 if ((erp->function == dasd_3990_erp_compound_code) &&
2053 (erp->status == DASD_CQR_NEED_ERP)) {
2054
2055 dasd_3990_erp_compound_config(erp, sense);
2056 }
2057
2058 /* if no compound action ERP specified, the request failed */
2059 if (erp->status == DASD_CQR_NEED_ERP)
2060 erp->status = DASD_CQR_FAILED;
2061
2062 return erp;
2063
2064 } /* end dasd_3990_erp_compound */
2065
2066 /*
2067 *DASD_3990_ERP_HANDLE_SIM
2068 *
2069 *DESCRIPTION
2070 * inspects the SIM SENSE data and starts an appropriate action
2071 *
2072 * PARAMETER
2073 * sense sense data of the actual error
2074 *
2075 * RETURN VALUES
2076 * none
2077 */
2078 void
dasd_3990_erp_handle_sim(struct dasd_device * device,char * sense)2079 dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2080 {
2081 /* print message according to log or message to operator mode */
2082 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
2083 /* print SIM SRC from RefCode */
2084 dev_err(&device->cdev->dev, "SIM - SRC: "
2085 "%02x%02x%02x%02x\n", sense[22],
2086 sense[23], sense[11], sense[12]);
2087 } else if (sense[24] & DASD_SIM_LOG) {
2088 /* print SIM SRC Refcode */
2089 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2090 "%02x%02x%02x%02x\n", sense[22],
2091 sense[23], sense[11], sense[12]);
2092 }
2093 }
2094
2095 /*
2096 * DASD_3990_ERP_INSPECT_32
2097 *
2098 * DESCRIPTION
2099 * Does a detailed inspection of the 32 byte sense data
2100 * and sets up a related error recovery action.
2101 *
2102 * PARAMETER
2103 * sense sense data of the actual error
2104 * erp pointer to the currently created default ERP
2105 *
2106 * RETURN VALUES
2107 * erp_filled pointer to the ERP
2108 *
2109 */
2110 static struct dasd_ccw_req *
dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp,char * sense)2111 dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2112 {
2113
2114 struct dasd_device *device = erp->startdev;
2115
2116 erp->function = dasd_3990_erp_inspect_32;
2117
2118 /* check for SIM sense data */
2119 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2120 dasd_3990_erp_handle_sim(device, sense);
2121
2122 if (sense[25] & DASD_SENSE_BIT_0) {
2123
2124 /* compound program action codes (byte25 bit 0 == '1') */
2125 dasd_3990_erp_compound_retry(erp, sense);
2126
2127 } else {
2128
2129 /* single program action codes (byte25 bit 0 == '0') */
2130 switch (sense[25]) {
2131
2132 case 0x00: /* success - use default ERP for retries */
2133 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
2134 "ERP called for successful request"
2135 " - just retry");
2136 break;
2137
2138 case 0x01: /* fatal error */
2139 dev_err(&device->cdev->dev,
2140 "ERP failed for the DASD\n");
2141
2142 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2143 break;
2144
2145 case 0x02: /* intervention required */
2146 case 0x03: /* intervention required during dual copy */
2147 erp = dasd_3990_erp_int_req(erp);
2148 break;
2149
2150 case 0x0F: /* length mismatch during update write command
2151 internal error 08 - update write command error*/
2152 dev_err(&device->cdev->dev, "An error occurred in the "
2153 "DASD device driver, reason=%s\n", "08");
2154
2155 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2156 break;
2157
2158 case 0x10: /* logging required for other channel program */
2159 erp = dasd_3990_erp_action_10_32(erp, sense);
2160 break;
2161
2162 case 0x15: /* next track outside defined extend
2163 internal error 07 - The next track is not
2164 within the defined storage extent */
2165 dev_err(&device->cdev->dev,
2166 "An error occurred in the DASD device driver, "
2167 "reason=%s\n", "07");
2168
2169 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2170 break;
2171
2172 case 0x1B: /* unexpected condition during write */
2173
2174 erp = dasd_3990_erp_action_1B_32(erp, sense);
2175 break;
2176
2177 case 0x1C: /* invalid data */
2178 dev_emerg(&device->cdev->dev,
2179 "Data recovered during retry with PCI "
2180 "fetch mode active\n");
2181
2182 /* not possible to handle this situation in Linux */
2183 panic
2184 ("Invalid data - No way to inform application "
2185 "about the possibly incorrect data");
2186 break;
2187
2188 case 0x1D: /* state-change pending */
2189 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2190 "A State change pending condition exists "
2191 "for the subsystem or device");
2192
2193 erp = dasd_3990_erp_action_4(erp, sense);
2194 break;
2195
2196 case 0x1E: /* busy */
2197 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2198 "Busy condition exists "
2199 "for the subsystem or device");
2200 erp = dasd_3990_erp_action_4(erp, sense);
2201 break;
2202
2203 default: /* all others errors - default erp */
2204 break;
2205 }
2206 }
2207
2208 return erp;
2209
2210 } /* end dasd_3990_erp_inspect_32 */
2211
dasd_3990_erp_disable_path(struct dasd_device * device,__u8 lpum)2212 static void dasd_3990_erp_disable_path(struct dasd_device *device, __u8 lpum)
2213 {
2214 int pos = pathmask_to_pos(lpum);
2215
2216 if (!(device->features & DASD_FEATURE_PATH_AUTODISABLE)) {
2217 dev_err(&device->cdev->dev,
2218 "Path %x.%02x (pathmask %02x) is operational despite excessive IFCCs\n",
2219 device->path[pos].cssid, device->path[pos].chpid, lpum);
2220 goto out;
2221 }
2222
2223 /* no remaining path, cannot disable */
2224 if (!(dasd_path_get_opm(device) & ~lpum)) {
2225 dev_err(&device->cdev->dev,
2226 "Last path %x.%02x (pathmask %02x) is operational despite excessive IFCCs\n",
2227 device->path[pos].cssid, device->path[pos].chpid, lpum);
2228 goto out;
2229 }
2230
2231 dev_err(&device->cdev->dev,
2232 "Path %x.%02x (pathmask %02x) is disabled - IFCC threshold exceeded\n",
2233 device->path[pos].cssid, device->path[pos].chpid, lpum);
2234 dasd_path_remove_opm(device, lpum);
2235 dasd_path_add_ifccpm(device, lpum);
2236
2237 out:
2238 device->path[pos].errorclk = 0;
2239 atomic_set(&device->path[pos].error_count, 0);
2240 }
2241
dasd_3990_erp_account_error(struct dasd_ccw_req * erp)2242 static void dasd_3990_erp_account_error(struct dasd_ccw_req *erp)
2243 {
2244 struct dasd_device *device = erp->startdev;
2245 __u8 lpum = erp->refers->irb.esw.esw1.lpum;
2246 int pos = pathmask_to_pos(lpum);
2247 unsigned long clk;
2248
2249 if (!device->path_thrhld)
2250 return;
2251
2252 clk = get_tod_clock();
2253 /*
2254 * check if the last error is longer ago than the timeout,
2255 * if so reset error state
2256 */
2257 if ((tod_to_ns(clk - device->path[pos].errorclk) / NSEC_PER_SEC)
2258 >= device->path_interval) {
2259 atomic_set(&device->path[pos].error_count, 0);
2260 device->path[pos].errorclk = 0;
2261 }
2262 atomic_inc(&device->path[pos].error_count);
2263 device->path[pos].errorclk = clk;
2264 /* threshold exceeded disable path if possible */
2265 if (atomic_read(&device->path[pos].error_count) >=
2266 device->path_thrhld)
2267 dasd_3990_erp_disable_path(device, lpum);
2268 }
2269
2270 /*
2271 *****************************************************************************
2272 * main ERP control functions (24 and 32 byte sense)
2273 *****************************************************************************
2274 */
2275
2276 /*
2277 * DASD_3990_ERP_CONTROL_CHECK
2278 *
2279 * DESCRIPTION
2280 * Does a generic inspection if a control check occurred and sets up
2281 * the related error recovery procedure
2282 *
2283 * PARAMETER
2284 * erp pointer to the currently created default ERP
2285 *
2286 * RETURN VALUES
2287 * erp_filled pointer to the erp
2288 */
2289
2290 static struct dasd_ccw_req *
dasd_3990_erp_control_check(struct dasd_ccw_req * erp)2291 dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2292 {
2293 struct dasd_device *device = erp->startdev;
2294
2295 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
2296 | SCHN_STAT_CHN_CTRL_CHK)) {
2297 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
2298 "channel or interface control check");
2299 dasd_3990_erp_account_error(erp);
2300 erp = dasd_3990_erp_action_4(erp, NULL);
2301 }
2302 return erp;
2303 }
2304
2305 /*
2306 * DASD_3990_ERP_INSPECT
2307 *
2308 * DESCRIPTION
2309 * Does a detailed inspection for sense data by calling either
2310 * the 24-byte or the 32-byte inspection routine.
2311 *
2312 * PARAMETER
2313 * erp pointer to the currently created default ERP
2314 * RETURN VALUES
2315 * erp_new contens was possibly modified
2316 */
2317 static struct dasd_ccw_req *
dasd_3990_erp_inspect(struct dasd_ccw_req * erp)2318 dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
2319 {
2320
2321 struct dasd_ccw_req *erp_new = NULL;
2322 char *sense;
2323
2324 /* if this problem occurred on an alias retry on base */
2325 erp_new = dasd_3990_erp_inspect_alias(erp);
2326 if (erp_new)
2327 return erp_new;
2328
2329 /* sense data are located in the refers record of the
2330 * already set up new ERP !
2331 * check if concurrent sens is available
2332 */
2333 sense = dasd_get_sense(&erp->refers->irb);
2334 if (!sense)
2335 erp_new = dasd_3990_erp_control_check(erp);
2336 /* distinguish between 24 and 32 byte sense data */
2337 else if (sense[27] & DASD_SENSE_BIT_0) {
2338
2339 /* inspect the 24 byte sense data */
2340 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2341
2342 } else {
2343
2344 /* inspect the 32 byte sense data */
2345 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2346
2347 } /* end distinguish between 24 and 32 byte sense data */
2348
2349 return erp_new;
2350 }
2351
2352 /*
2353 * DASD_3990_ERP_ADD_ERP
2354 *
2355 * DESCRIPTION
2356 * This function adds an additional request block (ERP) to the head of
2357 * the given cqr (or erp).
2358 * For a command mode cqr the erp is initialized as an default erp
2359 * (retry TIC).
2360 * For transport mode we make a copy of the original TCW (points to
2361 * the original TCCB, TIDALs, etc.) but give it a fresh
2362 * TSB so the original sense data will not be changed.
2363 *
2364 * PARAMETER
2365 * cqr head of the current ERP-chain (or single cqr if
2366 * first error)
2367 * RETURN VALUES
2368 * erp pointer to new ERP-chain head
2369 */
dasd_3990_erp_add_erp(struct dasd_ccw_req * cqr)2370 static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
2371 {
2372
2373 struct dasd_device *device = cqr->startdev;
2374 struct ccw1 *ccw;
2375 struct dasd_ccw_req *erp;
2376 int cplength, datasize;
2377 struct tcw *tcw;
2378 struct tsb *tsb;
2379
2380 if (cqr->cpmode == 1) {
2381 cplength = 0;
2382 /* TCW needs to be 64 byte aligned, so leave enough room */
2383 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
2384 } else {
2385 cplength = 2;
2386 datasize = 0;
2387 }
2388
2389 /* allocate additional request block */
2390 erp = dasd_alloc_erp_request(cqr->magic,
2391 cplength, datasize, device);
2392 if (IS_ERR(erp)) {
2393 if (cqr->retries <= 0) {
2394 DBF_DEV_EVENT(DBF_ERR, device, "%s",
2395 "Unable to allocate ERP request");
2396 cqr->status = DASD_CQR_FAILED;
2397 cqr->stopclk = get_tod_clock();
2398 } else {
2399 DBF_DEV_EVENT(DBF_ERR, device,
2400 "Unable to allocate ERP request "
2401 "(%i retries left)",
2402 cqr->retries);
2403 dasd_block_set_timer(device->block, (HZ << 3));
2404 }
2405 return erp;
2406 }
2407
2408 ccw = cqr->cpaddr;
2409 if (cqr->cpmode == 1) {
2410 /* make a shallow copy of the original tcw but set new tsb */
2411 erp->cpmode = 1;
2412 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2413 tcw = erp->cpaddr;
2414 tsb = (struct tsb *) &tcw[1];
2415 *tcw = *((struct tcw *)cqr->cpaddr);
2416 tcw->tsb = virt_to_phys(tsb);
2417 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
2418 /* PSF cannot be chained from NOOP/TIC */
2419 erp->cpaddr = cqr->cpaddr;
2420 } else {
2421 /* initialize request with default TIC to current ERP/CQR */
2422 ccw = erp->cpaddr;
2423 ccw->cmd_code = CCW_CMD_NOOP;
2424 ccw->flags = CCW_FLAG_CC;
2425 ccw++;
2426 ccw->cmd_code = CCW_CMD_TIC;
2427 ccw->cda = (__u32)virt_to_phys(cqr->cpaddr);
2428 }
2429
2430 erp->flags = cqr->flags;
2431 erp->function = dasd_3990_erp_add_erp;
2432 erp->refers = cqr;
2433 erp->startdev = device;
2434 erp->memdev = device;
2435 erp->block = cqr->block;
2436 erp->magic = cqr->magic;
2437 erp->expires = cqr->expires;
2438 erp->retries = device->default_retries;
2439 erp->buildclk = get_tod_clock();
2440 erp->status = DASD_CQR_FILLED;
2441
2442 return erp;
2443 }
2444
2445 /*
2446 * DASD_3990_ERP_ADDITIONAL_ERP
2447 *
2448 * DESCRIPTION
2449 * An additional ERP is needed to handle the current error.
2450 * Add ERP to the head of the ERP-chain containing the ERP processing
2451 * determined based on the sense data.
2452 *
2453 * PARAMETER
2454 * cqr head of the current ERP-chain (or single cqr if
2455 * first error)
2456 *
2457 * RETURN VALUES
2458 * erp pointer to new ERP-chain head
2459 */
2460 static struct dasd_ccw_req *
dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)2461 dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2462 {
2463
2464 struct dasd_ccw_req *erp = NULL;
2465
2466 /* add erp and initialize with default TIC */
2467 erp = dasd_3990_erp_add_erp(cqr);
2468
2469 if (IS_ERR(erp))
2470 return erp;
2471
2472 /* inspect sense, determine specific ERP if possible */
2473 if (erp != cqr) {
2474
2475 erp = dasd_3990_erp_inspect(erp);
2476 }
2477
2478 return erp;
2479
2480 } /* end dasd_3990_erp_additional_erp */
2481
2482 /*
2483 * DASD_3990_ERP_ERROR_MATCH
2484 *
2485 * DESCRIPTION
2486 * Check if the device status of the given cqr is the same.
2487 * This means that the failed CCW and the relevant sense data
2488 * must match.
2489 * I don't distinguish between 24 and 32 byte sense because in case of
2490 * 24 byte sense byte 25 and 27 is set as well.
2491 *
2492 * PARAMETER
2493 * cqr1 first cqr, which will be compared with the
2494 * cqr2 second cqr.
2495 *
2496 * RETURN VALUES
2497 * match 'boolean' for match found
2498 * returns 1 if match found, otherwise 0.
2499 */
dasd_3990_erp_error_match(struct dasd_ccw_req * cqr1,struct dasd_ccw_req * cqr2)2500 static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2501 struct dasd_ccw_req *cqr2)
2502 {
2503 char *sense1, *sense2;
2504
2505 if (cqr1->startdev != cqr2->startdev)
2506 return 0;
2507
2508 sense1 = dasd_get_sense(&cqr1->irb);
2509 sense2 = dasd_get_sense(&cqr2->irb);
2510
2511 /* one request has sense data, the other not -> no match, return 0 */
2512 if (!sense1 != !sense2)
2513 return 0;
2514 /* no sense data in both cases -> check cstat for IFCC */
2515 if (!sense1 && !sense2) {
2516 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2517 SCHN_STAT_CHN_CTRL_CHK)) ==
2518 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2519 SCHN_STAT_CHN_CTRL_CHK)))
2520 return 1; /* match with ifcc*/
2521 }
2522 /* check sense data; byte 0-2,25,27 */
2523 if (!(sense1 && sense2 &&
2524 (memcmp(sense1, sense2, 3) == 0) &&
2525 (sense1[27] == sense2[27]) &&
2526 (sense1[25] == sense2[25]))) {
2527
2528 return 0; /* sense doesn't match */
2529 }
2530
2531 return 1; /* match */
2532
2533 } /* end dasd_3990_erp_error_match */
2534
2535 /*
2536 * DASD_3990_ERP_IN_ERP
2537 *
2538 * DESCRIPTION
2539 * check if the current error already happened before.
2540 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2541 *
2542 * PARAMETER
2543 * cqr failed cqr (either original cqr or already an erp)
2544 *
2545 * RETURN VALUES
2546 * erp erp-pointer to the already defined error
2547 * recovery procedure OR
2548 * NULL if a 'new' error occurred.
2549 */
2550 static struct dasd_ccw_req *
dasd_3990_erp_in_erp(struct dasd_ccw_req * cqr)2551 dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2552 {
2553
2554 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2555 *erp_match = NULL; /* save erp chain head */
2556 int match = 0; /* 'boolean' for matching error found */
2557
2558 if (cqr->refers == NULL) { /* return if not in erp */
2559 return NULL;
2560 }
2561
2562 /* check the erp/cqr chain for current error */
2563 do {
2564 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2565 erp_match = cqr; /* save possible matching erp */
2566 cqr = cqr->refers; /* check next erp/cqr in queue */
2567
2568 } while ((cqr->refers != NULL) && (!match));
2569
2570 if (!match) {
2571 return NULL; /* no match was found */
2572 }
2573
2574 return erp_match; /* return address of matching erp */
2575
2576 } /* END dasd_3990_erp_in_erp */
2577
2578 /*
2579 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2580 *
2581 * DESCRIPTION
2582 * No retry is left for the current ERP. Check what has to be done
2583 * with the ERP.
2584 * - do further defined ERP action or
2585 * - wait for interrupt or
2586 * - exit with permanent error
2587 *
2588 * PARAMETER
2589 * erp ERP which is in progress with no retry left
2590 *
2591 * RETURN VALUES
2592 * erp modified/additional ERP
2593 */
2594 static struct dasd_ccw_req *
dasd_3990_erp_further_erp(struct dasd_ccw_req * erp)2595 dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2596 {
2597
2598 struct dasd_device *device = erp->startdev;
2599 char *sense = dasd_get_sense(&erp->irb);
2600
2601 /* check for 24 byte sense ERP */
2602 if ((erp->function == dasd_3990_erp_bus_out) ||
2603 (erp->function == dasd_3990_erp_action_1) ||
2604 (erp->function == dasd_3990_erp_action_4)) {
2605
2606 erp = dasd_3990_erp_action_1(erp);
2607
2608 } else if (erp->function == dasd_3990_erp_action_1_sec) {
2609 erp = dasd_3990_erp_action_1_sec(erp);
2610 } else if (erp->function == dasd_3990_erp_action_5) {
2611
2612 /* retries have not been successful */
2613 /* prepare erp for retry on different channel path */
2614 erp = dasd_3990_erp_action_1(erp);
2615
2616 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
2617
2618 /* issue a Diagnostic Control command with an
2619 * Inhibit Write subcommand */
2620
2621 switch (sense[25]) {
2622 case 0x17:
2623 case 0x57:{ /* controller */
2624 erp = dasd_3990_erp_DCTL(erp, 0x20);
2625 break;
2626 }
2627 case 0x18:
2628 case 0x58:{ /* channel path */
2629 erp = dasd_3990_erp_DCTL(erp, 0x40);
2630 break;
2631 }
2632 case 0x19:
2633 case 0x59:{ /* storage director */
2634 erp = dasd_3990_erp_DCTL(erp, 0x80);
2635 break;
2636 }
2637 default:
2638 DBF_DEV_EVENT(DBF_WARNING, device,
2639 "invalid subcommand modifier 0x%x "
2640 "for Diagnostic Control Command",
2641 sense[25]);
2642 }
2643 }
2644
2645 /* check for 32 byte sense ERP */
2646 } else if (sense &&
2647 ((erp->function == dasd_3990_erp_compound_retry) ||
2648 (erp->function == dasd_3990_erp_compound_path) ||
2649 (erp->function == dasd_3990_erp_compound_code) ||
2650 (erp->function == dasd_3990_erp_compound_config))) {
2651
2652 erp = dasd_3990_erp_compound(erp, sense);
2653
2654 } else {
2655 /*
2656 * No retry left and no additional special handling
2657 * necessary
2658 */
2659 dev_err(&device->cdev->dev,
2660 "ERP %p has run out of retries and failed\n", erp);
2661
2662 erp->status = DASD_CQR_FAILED;
2663 }
2664
2665 return erp;
2666
2667 } /* end dasd_3990_erp_further_erp */
2668
2669 /*
2670 * DASD_3990_ERP_HANDLE_MATCH_ERP
2671 *
2672 * DESCRIPTION
2673 * An error occurred again and an ERP has been detected which is already
2674 * used to handle this error (e.g. retries).
2675 * All prior ERP's are asumed to be successful and therefore removed
2676 * from queue.
2677 * If retry counter of matching erp is already 0, it is checked if further
2678 * action is needed (besides retry) or if the ERP has failed.
2679 *
2680 * PARAMETER
2681 * erp_head first ERP in ERP-chain
2682 * erp ERP that handles the actual error.
2683 * (matching erp)
2684 *
2685 * RETURN VALUES
2686 * erp modified/additional ERP
2687 */
2688 static struct dasd_ccw_req *
dasd_3990_erp_handle_match_erp(struct dasd_ccw_req * erp_head,struct dasd_ccw_req * erp)2689 dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2690 struct dasd_ccw_req *erp)
2691 {
2692
2693 struct dasd_device *device = erp_head->startdev;
2694 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2695 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2696
2697 /* loop over successful ERPs and remove them from chanq */
2698 while (erp_done != erp) {
2699
2700 if (erp_done == NULL) /* end of chain reached */
2701 panic(PRINTK_HEADER "Programming error in ERP! The "
2702 "original request was lost\n");
2703
2704 /* remove the request from the device queue */
2705 list_del(&erp_done->blocklist);
2706
2707 erp_free = erp_done;
2708 erp_done = erp_done->refers;
2709
2710 /* free the finished erp request */
2711 dasd_free_erp_request(erp_free, erp_free->memdev);
2712
2713 } /* end while */
2714
2715 if (erp->retries > 0) {
2716
2717 char *sense = dasd_get_sense(&erp->refers->irb);
2718
2719 /* check for special retries */
2720 if (sense && erp->function == dasd_3990_erp_action_4) {
2721
2722 erp = dasd_3990_erp_action_4(erp, sense);
2723
2724 } else if (sense &&
2725 erp->function == dasd_3990_erp_action_1B_32) {
2726
2727 erp = dasd_3990_update_1B(erp, sense);
2728
2729 } else if (sense && erp->function == dasd_3990_erp_int_req) {
2730
2731 erp = dasd_3990_erp_int_req(erp);
2732
2733 } else {
2734 /* simple retry */
2735 DBF_DEV_EVENT(DBF_DEBUG, device,
2736 "%i retries left for erp %p",
2737 erp->retries, erp);
2738
2739 /* handle the request again... */
2740 erp->status = DASD_CQR_FILLED;
2741 }
2742
2743 } else {
2744 /* no retry left - check for further necessary action */
2745 /* if no further actions, handle rest as permanent error */
2746 erp = dasd_3990_erp_further_erp(erp);
2747 }
2748
2749 return erp;
2750
2751 } /* end dasd_3990_erp_handle_match_erp */
2752
2753 /*
2754 * DASD_3990_ERP_ACTION
2755 *
2756 * DESCRIPTION
2757 * control routine for 3990 erp actions.
2758 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2759 *
2760 * PARAMETER
2761 * cqr failed cqr (either original cqr or already an erp)
2762 *
2763 * RETURN VALUES
2764 * erp erp-pointer to the head of the ERP action chain.
2765 * This means:
2766 * - either a ptr to an additional ERP cqr or
2767 * - the original given cqr (which's status might
2768 * be modified)
2769 */
2770 struct dasd_ccw_req *
dasd_3990_erp_action(struct dasd_ccw_req * cqr)2771 dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2772 {
2773 struct dasd_ccw_req *erp = NULL;
2774 struct dasd_device *device = cqr->startdev;
2775 struct dasd_ccw_req *temp_erp = NULL;
2776
2777 if (device->features & DASD_FEATURE_ERPLOG) {
2778 /* print current erp_chain */
2779 dev_err(&device->cdev->dev,
2780 "ERP chain at BEGINNING of ERP-ACTION\n");
2781 for (temp_erp = cqr;
2782 temp_erp != NULL; temp_erp = temp_erp->refers) {
2783
2784 dev_err(&device->cdev->dev,
2785 "ERP %p (%02x) refers to %p\n",
2786 temp_erp, temp_erp->status,
2787 temp_erp->refers);
2788 }
2789 }
2790
2791 /* double-check if current erp/cqr was successful */
2792 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2793 (scsw_dstat(&cqr->irb.scsw) ==
2794 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
2795
2796 DBF_DEV_EVENT(DBF_DEBUG, device,
2797 "ERP called for successful request %p"
2798 " - NO ERP necessary", cqr);
2799
2800 cqr->status = DASD_CQR_DONE;
2801
2802 return cqr;
2803 }
2804
2805 /* check if error happened before */
2806 erp = dasd_3990_erp_in_erp(cqr);
2807
2808 if (erp == NULL) {
2809 /* no matching erp found - set up erp */
2810 erp = dasd_3990_erp_additional_erp(cqr);
2811 if (IS_ERR(erp))
2812 return erp;
2813 } else {
2814 /* matching erp found - set all leading erp's to DONE */
2815 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2816 }
2817
2818
2819 /*
2820 * For path verification work we need to stick with the path that was
2821 * originally chosen so that the per path configuration data is
2822 * assigned correctly.
2823 */
2824 if (test_bit(DASD_CQR_VERIFY_PATH, &erp->flags) && cqr->lpm) {
2825 erp->lpm = cqr->lpm;
2826 }
2827
2828 if (device->features & DASD_FEATURE_ERPLOG) {
2829 /* print current erp_chain */
2830 dev_err(&device->cdev->dev,
2831 "ERP chain at END of ERP-ACTION\n");
2832 for (temp_erp = erp;
2833 temp_erp != NULL; temp_erp = temp_erp->refers) {
2834
2835 dev_err(&device->cdev->dev,
2836 "ERP %p (%02x) refers to %p\n",
2837 temp_erp, temp_erp->status,
2838 temp_erp->refers);
2839 }
2840 }
2841
2842 /* enqueue ERP request if it's a new one */
2843 if (list_empty(&erp->blocklist)) {
2844 cqr->status = DASD_CQR_IN_ERP;
2845 /* add erp request before the cqr */
2846 list_add_tail(&erp->blocklist, &cqr->blocklist);
2847 }
2848
2849
2850
2851 return erp;
2852
2853 } /* end dasd_3990_erp_action */
2854