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