blob: e82d427ff5ebc8bf14a0e227e0ae5c32077bd797 [file] [log] [blame]
Horst Hummel138c0142006-06-29 14:58:12 +02001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * File...........: linux/drivers/s390/block/dasd_3990_erp.c
Horst Hummel138c0142006-06-29 14:58:12 +02003 * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
Stefan Haberlandca99dab2009-09-11 10:28:30 +020010#define KMSG_COMPONENT "dasd-eckd"
Stefan Haberlandfc19f382009-03-26 15:23:49 +010011
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/timer.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/idals.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15#define PRINTK_HEADER "dasd_erp(3990): "
16
17#include "dasd_int.h"
18#include "dasd_eckd.h"
19
20
21struct DCTL_data {
22 unsigned char subcommand; /* e.g Inhibit Write, Enable Write,... */
23 unsigned char modifier; /* Subcommand modifier */
24 unsigned short res; /* reserved */
25} __attribute__ ((packed));
26
27/*
Horst Hummel138c0142006-06-29 14:58:12 +020028 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 * SECTION ERP HANDLING
Horst Hummel138c0142006-06-29 14:58:12 +020030 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 */
32/*
Horst Hummel138c0142006-06-29 14:58:12 +020033 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 * 24 and 32 byte sense ERP functions
Horst Hummel138c0142006-06-29 14:58:12 +020035 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 */
37
38/*
Horst Hummel138c0142006-06-29 14:58:12 +020039 * DASD_3990_ERP_CLEANUP
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 *
41 * DESCRIPTION
42 * Removes the already build but not necessary ERP request and sets
43 * the status of the original cqr / erp to the given (final) status
44 *
45 * PARAMETER
46 * erp request to be blocked
Horst Hummel138c0142006-06-29 14:58:12 +020047 * final_status either DASD_CQR_DONE or DASD_CQR_FAILED
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 *
49 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +020050 * cqr original cqr
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 */
52static struct dasd_ccw_req *
53dasd_3990_erp_cleanup(struct dasd_ccw_req * erp, char final_status)
54{
55 struct dasd_ccw_req *cqr = erp->refers;
56
Stefan Weinhuber8e09f212008-01-26 14:11:23 +010057 dasd_free_erp_request(erp, erp->memdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 cqr->status = final_status;
59 return cqr;
60
61} /* end dasd_3990_erp_cleanup */
62
63/*
Horst Hummel138c0142006-06-29 14:58:12 +020064 * DASD_3990_ERP_BLOCK_QUEUE
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 *
66 * DESCRIPTION
67 * Block the given device request queue to prevent from further
68 * processing until the started timer has expired or an related
69 * interrupt was received.
70 */
Stefan Weinhubereb6e1992009-12-07 12:51:51 +010071static void dasd_3990_erp_block_queue(struct dasd_ccw_req *erp, int expires)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
73
Stefan Weinhuber8e09f212008-01-26 14:11:23 +010074 struct dasd_device *device = erp->startdev;
75 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Stefan Haberlandfc19f382009-03-26 15:23:49 +010077 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 "blocking request queue for %is", expires/HZ);
79
Stefan Weinhuber8e09f212008-01-26 14:11:23 +010080 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
Stefan Weinhubereb6e1992009-12-07 12:51:51 +010081 dasd_device_set_stop_bits(device, DASD_STOPPED_PENDING);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +010082 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
83 erp->status = DASD_CQR_FILLED;
Stefan Weinhubereb6e1992009-12-07 12:51:51 +010084 if (erp->block)
85 dasd_block_set_timer(erp->block, expires);
86 else
87 dasd_device_set_timer(device, expires);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}
89
90/*
Horst Hummel138c0142006-06-29 14:58:12 +020091 * DASD_3990_ERP_INT_REQ
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 *
93 * DESCRIPTION
94 * Handles 'Intervention Required' error.
95 * This means either device offline or not installed.
96 *
97 * PARAMETER
98 * erp current erp
99 * RETURN VALUES
100 * erp modified erp
101 */
102static struct dasd_ccw_req *
103dasd_3990_erp_int_req(struct dasd_ccw_req * erp)
104{
105
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100106 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108 /* first time set initial retry counter and erp_function */
109 /* and retry once without blocking queue */
110 /* (this enables easier enqueing of the cqr) */
111 if (erp->function != dasd_3990_erp_int_req) {
112
113 erp->retries = 256;
114 erp->function = dasd_3990_erp_int_req;
115
116 } else {
117
118 /* issue a message and wait for 'device ready' interrupt */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100119 dev_err(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 "is offline or not installed - "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100121 "INTERVENTION REQUIRED!!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 dasd_3990_erp_block_queue(erp, 60*HZ);
124 }
125
126 return erp;
127
128} /* end dasd_3990_erp_int_req */
129
130/*
Horst Hummel138c0142006-06-29 14:58:12 +0200131 * DASD_3990_ERP_ALTERNATE_PATH
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 *
133 * DESCRIPTION
134 * Repeat the operation on a different channel path.
135 * If all alternate paths have been tried, the request is posted with a
136 * permanent error.
137 *
138 * PARAMETER
139 * erp pointer to the current ERP
140 *
141 * RETURN VALUES
142 * erp modified pointer to the ERP
143 */
144static void
145dasd_3990_erp_alternate_path(struct dasd_ccw_req * erp)
146{
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100147 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 __u8 opm;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100149 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151 /* try alternate valid path */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100152 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 opm = ccw_device_get_path_mask(device->cdev);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100154 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 //FIXME: start with get_opm ?
156 if (erp->lpm == 0)
157 erp->lpm = LPM_ANYPATH & ~(erp->irb.esw.esw0.sublog.lpum);
158 else
159 erp->lpm &= ~(erp->irb.esw.esw0.sublog.lpum);
160
161 if ((erp->lpm & opm) != 0x00) {
162
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100163 DBF_DEV_EVENT(DBF_WARNING, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 "try alternate lpm=%x (lpum=%x / opm=%x)",
165 erp->lpm, erp->irb.esw.esw0.sublog.lpum, opm);
166
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100167 /* reset status to submit the request again... */
168 erp->status = DASD_CQR_FILLED;
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100169 erp->retries = 10;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100171 dev_err(&device->cdev->dev,
172 "The DASD cannot be reached on any path (lpum=%x"
173 "/opm=%x)\n", erp->irb.esw.esw0.sublog.lpum, opm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 /* post request with permanent error */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100176 erp->status = DASD_CQR_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 }
178} /* end dasd_3990_erp_alternate_path */
179
180/*
181 * DASD_3990_ERP_DCTL
182 *
183 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +0200184 * Setup cqr to do the Diagnostic Control (DCTL) command with an
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 * Inhibit Write subcommand (0x20) and the given modifier.
186 *
187 * PARAMETER
188 * erp pointer to the current (failed) ERP
189 * modifier subcommand modifier
Horst Hummel138c0142006-06-29 14:58:12 +0200190 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +0200192 * dctl_cqr pointer to NEW dctl_cqr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 *
194 */
195static struct dasd_ccw_req *
196dasd_3990_erp_DCTL(struct dasd_ccw_req * erp, char modifier)
197{
198
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100199 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 struct DCTL_data *DCTL_data;
201 struct ccw1 *ccw;
202 struct dasd_ccw_req *dctl_cqr;
203
204 dctl_cqr = dasd_alloc_erp_request((char *) &erp->magic, 1,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100205 sizeof(struct DCTL_data),
206 device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 if (IS_ERR(dctl_cqr)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100208 dev_err(&device->cdev->dev,
209 "Unable to allocate DCTL-CQR\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 erp->status = DASD_CQR_FAILED;
211 return erp;
212 }
213
214 DCTL_data = dctl_cqr->data;
215
216 DCTL_data->subcommand = 0x02; /* Inhibit Write */
217 DCTL_data->modifier = modifier;
218
219 ccw = dctl_cqr->cpaddr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100220 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 ccw->cmd_code = CCW_CMD_DCTL;
222 ccw->count = 4;
223 ccw->cda = (__u32)(addr_t) DCTL_data;
224 dctl_cqr->function = dasd_3990_erp_DCTL;
225 dctl_cqr->refers = erp;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100226 dctl_cqr->startdev = device;
227 dctl_cqr->memdev = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 dctl_cqr->magic = erp->magic;
229 dctl_cqr->expires = 5 * 60 * HZ;
230 dctl_cqr->retries = 2;
231
232 dctl_cqr->buildclk = get_clock();
233
234 dctl_cqr->status = DASD_CQR_FILLED;
235
236 return dctl_cqr;
237
238} /* end dasd_3990_erp_DCTL */
239
240/*
Horst Hummel138c0142006-06-29 14:58:12 +0200241 * DASD_3990_ERP_ACTION_1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 *
243 * DESCRIPTION
244 * Setup ERP to do the ERP action 1 (see Reference manual).
245 * Repeat the operation on a different channel path.
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100246 * As deviation from the recommended recovery action, we reset the path mask
247 * after we have tried each path and go through all paths a second time.
248 * This will cover situations where only one path at a time is actually down,
249 * but all paths fail and recover just with the same sequence and timing as
250 * we try to use them (flapping links).
251 * If all alternate paths have been tried twice, the request is posted with
252 * a permanent error.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 *
254 * PARAMETER
255 * erp pointer to the current ERP
256 *
257 * RETURN VALUES
258 * erp pointer to the ERP
259 *
260 */
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100261static struct dasd_ccw_req *dasd_3990_erp_action_1_sec(struct dasd_ccw_req *erp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100263 erp->function = dasd_3990_erp_action_1_sec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 dasd_3990_erp_alternate_path(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 return erp;
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100266}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100268static struct dasd_ccw_req *dasd_3990_erp_action_1(struct dasd_ccw_req *erp)
269{
270 erp->function = dasd_3990_erp_action_1;
271 dasd_3990_erp_alternate_path(erp);
272 if (erp->status == DASD_CQR_FAILED) {
273 erp->status = DASD_CQR_FILLED;
274 erp->retries = 10;
275 erp->lpm = LPM_ANYPATH;
276 erp->function = dasd_3990_erp_action_1_sec;
277 }
278 return erp;
279} /* end dasd_3990_erp_action_1(b) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281/*
Horst Hummel138c0142006-06-29 14:58:12 +0200282 * DASD_3990_ERP_ACTION_4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 *
284 * DESCRIPTION
285 * Setup ERP to do the ERP action 4 (see Reference manual).
286 * Set the current request to PENDING to block the CQR queue for that device
287 * until the state change interrupt appears.
288 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
289 * missing.
290 *
291 * PARAMETER
292 * sense sense data of the actual error
293 * erp pointer to the current ERP
294 *
295 * RETURN VALUES
296 * erp pointer to the ERP
297 *
298 */
299static struct dasd_ccw_req *
300dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
301{
302
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100303 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
305 /* first time set initial retry counter and erp_function */
306 /* and retry once without waiting for state change pending */
307 /* interrupt (this enables easier enqueing of the cqr) */
308 if (erp->function != dasd_3990_erp_action_4) {
309
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100310 DBF_DEV_EVENT(DBF_INFO, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 "dasd_3990_erp_action_4: first time retry");
312
313 erp->retries = 256;
314 erp->function = dasd_3990_erp_action_4;
315
316 } else {
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100317 if (sense && (sense[25] == 0x1D)) { /* state change pending */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100319 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 "waiting for state change pending "
321 "interrupt, %d retries left",
322 erp->retries);
Horst Hummel138c0142006-06-29 14:58:12 +0200323
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 dasd_3990_erp_block_queue(erp, 30*HZ);
325
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100326 } else if (sense && (sense[25] == 0x1E)) { /* busy */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100327 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 "busy - redriving request later, "
329 "%d retries left",
330 erp->retries);
331 dasd_3990_erp_block_queue(erp, HZ);
332 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 /* no state change pending - retry */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100334 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 "redriving request immediately, "
Horst Hummel138c0142006-06-29 14:58:12 +0200336 "%d retries left",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 erp->retries);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100338 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 }
340 }
341
342 return erp;
343
344} /* end dasd_3990_erp_action_4 */
345
346/*
Horst Hummel138c0142006-06-29 14:58:12 +0200347 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 * 24 byte sense ERP functions (only)
Horst Hummel138c0142006-06-29 14:58:12 +0200349 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 */
351
352/*
Horst Hummel138c0142006-06-29 14:58:12 +0200353 * DASD_3990_ERP_ACTION_5
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 *
355 * DESCRIPTION
356 * Setup ERP to do the ERP action 5 (see Reference manual).
357 * NOTE: Further handling is done in xxx_further_erp after the retries.
358 *
359 * PARAMETER
360 * erp pointer to the current ERP
361 *
362 * RETURN VALUES
363 * erp pointer to the ERP
364 *
365 */
366static struct dasd_ccw_req *
367dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
368{
369
370 /* first of all retry */
371 erp->retries = 10;
372 erp->function = dasd_3990_erp_action_5;
373
374 return erp;
375
376} /* end dasd_3990_erp_action_5 */
377
378/*
379 * DASD_3990_HANDLE_ENV_DATA
380 *
381 * DESCRIPTION
382 * Handles 24 byte 'Environmental data present'.
383 * Does a analysis of the sense data (message Format)
384 * and prints the error messages.
385 *
386 * PARAMETER
387 * sense current sense data
Horst Hummel138c0142006-06-29 14:58:12 +0200388 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 * RETURN VALUES
390 * void
391 */
392static void
393dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
394{
395
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100396 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 char msg_format = (sense[7] & 0xF0);
398 char msg_no = (sense[7] & 0x0F);
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100399 char errorstring[ERRORLENGTH];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401 switch (msg_format) {
402 case 0x00: /* Format 0 - Program or System Checks */
403
404 if (sense[1] & 0x10) { /* check message to operator bit */
405
406 switch (msg_no) {
407 case 0x00: /* No Message */
408 break;
409 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100410 dev_warn(&device->cdev->dev,
411 "FORMAT 0 - Invalid Command\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 break;
413 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100414 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 "FORMAT 0 - Invalid Command "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100416 "Sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 break;
418 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100419 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 "FORMAT 0 - CCW Count less than "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100421 "required\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 break;
423 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100424 dev_warn(&device->cdev->dev,
425 "FORMAT 0 - Invalid Parameter\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 break;
427 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100428 dev_warn(&device->cdev->dev,
429 "FORMAT 0 - Diagnostic of Special"
430 " Command Violates File Mask\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 break;
432 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100433 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 "FORMAT 0 - Channel Returned with "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100435 "Incorrect retry CCW\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 break;
437 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100438 dev_warn(&device->cdev->dev,
439 "FORMAT 0 - Reset Notification\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 break;
441 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100442 dev_warn(&device->cdev->dev,
443 "FORMAT 0 - Storage Path Restart\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 break;
445 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100446 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 "FORMAT 0 - Channel requested "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100448 "... %02x\n", sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 break;
450 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100451 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 "FORMAT 0 - Invalid Defective/"
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100453 "Alternate Track Pointer\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 break;
455 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100456 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 "FORMAT 0 - DPS Installation "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100458 "Check\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 break;
460 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100461 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 "FORMAT 0 - Command Invalid on "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100463 "Secondary Address\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 break;
465 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100466 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 "FORMAT 0 - Status Not As "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100468 "Required: reason %02x\n",
469 sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 break;
471 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100472 dev_warn(&device->cdev->dev,
473 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 }
475 } else {
476 switch (msg_no) {
477 case 0x00: /* No Message */
478 break;
479 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100480 dev_warn(&device->cdev->dev,
481 "FORMAT 0 - Device Error "
482 "Source\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 break;
484 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100485 dev_warn(&device->cdev->dev,
486 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 break;
488 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100489 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 "FORMAT 0 - Device Fenced - "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100491 "device = %02x\n", sense[4]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 break;
493 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100494 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 "FORMAT 0 - Data Pinned for "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100496 "Device\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 break;
498 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100499 dev_warn(&device->cdev->dev,
500 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 }
502 }
503 break;
504
505 case 0x10: /* Format 1 - Device Equipment Checks */
506 switch (msg_no) {
507 case 0x00: /* No Message */
508 break;
509 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100510 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 "FORMAT 1 - Device Status 1 not as "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100512 "expected\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 break;
514 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100515 dev_warn(&device->cdev->dev,
516 "FORMAT 1 - Index missing\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 break;
518 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100519 dev_warn(&device->cdev->dev,
520 "FORMAT 1 - Interruption cannot be "
521 "reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 break;
523 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100524 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 "FORMAT 1 - Device did not respond to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100526 "selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 break;
528 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100529 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 "FORMAT 1 - Device check-2 error or Set "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100531 "Sector is not complete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 break;
533 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100534 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 "FORMAT 1 - Head address does not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100536 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 break;
538 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100539 dev_warn(&device->cdev->dev,
540 "FORMAT 1 - Device status 1 not valid\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 break;
542 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100543 dev_warn(&device->cdev->dev,
544 "FORMAT 1 - Device not ready\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 break;
546 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100547 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 "FORMAT 1 - Track physical address did "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100549 "not compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 break;
551 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100552 dev_warn(&device->cdev->dev,
553 "FORMAT 1 - Missing device address bit\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 break;
555 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100556 dev_warn(&device->cdev->dev,
557 "FORMAT 1 - Drive motor switch is off\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 break;
559 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100560 dev_warn(&device->cdev->dev,
561 "FORMAT 1 - Seek incomplete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 break;
563 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100564 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 "FORMAT 1 - Cylinder address did not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100566 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 break;
568 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100569 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 "FORMAT 1 - Offset active cannot be "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100571 "reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 break;
573 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100574 dev_warn(&device->cdev->dev,
575 "FORMAT 1 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 }
577 break;
578
579 case 0x20: /* Format 2 - 3990 Equipment Checks */
580 switch (msg_no) {
581 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100582 dev_warn(&device->cdev->dev,
583 "FORMAT 2 - 3990 check-2 error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 break;
585 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100586 dev_warn(&device->cdev->dev,
587 "FORMAT 2 - Support facility errors\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 break;
589 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100590 dev_warn(&device->cdev->dev,
591 "FORMAT 2 - Microcode detected error "
592 "%02x\n",
593 sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 break;
595 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100596 dev_warn(&device->cdev->dev,
597 "FORMAT 2 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 }
599 break;
600
601 case 0x30: /* Format 3 - 3990 Control Checks */
602 switch (msg_no) {
603 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100604 dev_warn(&device->cdev->dev,
605 "FORMAT 3 - Allegiance terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 break;
607 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100608 dev_warn(&device->cdev->dev,
609 "FORMAT 3 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 }
611 break;
612
613 case 0x40: /* Format 4 - Data Checks */
614 switch (msg_no) {
615 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100616 dev_warn(&device->cdev->dev,
617 "FORMAT 4 - Home address area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 break;
619 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100620 dev_warn(&device->cdev->dev,
621 "FORMAT 4 - Count area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 break;
623 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100624 dev_warn(&device->cdev->dev,
625 "FORMAT 4 - Key area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 break;
627 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100628 dev_warn(&device->cdev->dev,
629 "FORMAT 4 - Data area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 break;
631 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100632 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 "FORMAT 4 - No sync byte in home address "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100634 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 break;
636 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100637 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 "FORMAT 4 - No sync byte in count address "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100639 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 break;
641 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100642 dev_warn(&device->cdev->dev,
643 "FORMAT 4 - No sync byte in key area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 break;
645 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100646 dev_warn(&device->cdev->dev,
647 "FORMAT 4 - No sync byte in data area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 break;
649 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100650 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 "FORMAT 4 - Home address area error; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100652 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 break;
654 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100655 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 "FORMAT 4 - Count area error; offset "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100657 "active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 break;
659 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100660 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 "FORMAT 4 - Key area error; offset "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100662 "active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 break;
664 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100665 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 "FORMAT 4 - Data area error; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100667 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 break;
669 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100670 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 "FORMAT 4 - No sync byte in home "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100672 "address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 break;
674 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100675 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 "FORMAT 4 - No syn byte in count "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100677 "address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 break;
679 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100680 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 "FORMAT 4 - No sync byte in key area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100682 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 break;
684 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100685 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 "FORMAT 4 - No syn byte in data area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100687 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 break;
689 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100690 dev_warn(&device->cdev->dev,
691 "FORMAT 4 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 }
693 break;
694
695 case 0x50: /* Format 5 - Data Check with displacement information */
696 switch (msg_no) {
697 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100698 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 "FORMAT 5 - Data Check in the "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100700 "home address area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 break;
702 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100703 dev_warn(&device->cdev->dev,
704 "FORMAT 5 - Data Check in the count "
705 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 break;
707 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100708 dev_warn(&device->cdev->dev,
709 "FORMAT 5 - Data Check in the key area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 break;
711 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100712 dev_warn(&device->cdev->dev,
713 "FORMAT 5 - Data Check in the data "
714 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 break;
716 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100717 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 "FORMAT 5 - Data Check in the "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100719 "home address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 break;
721 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100722 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 "FORMAT 5 - Data Check in the count area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100724 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 break;
726 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100727 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 "FORMAT 5 - Data Check in the key area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100729 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 break;
731 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100732 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 "FORMAT 5 - Data Check in the data area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100734 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 break;
736 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100737 dev_warn(&device->cdev->dev,
738 "FORMAT 5 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 }
740 break;
741
742 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
743 switch (msg_no) {
744 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100745 dev_warn(&device->cdev->dev,
746 "FORMAT 6 - Overrun on channel A\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 break;
748 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100749 dev_warn(&device->cdev->dev,
750 "FORMAT 6 - Overrun on channel B\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 break;
752 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100753 dev_warn(&device->cdev->dev,
754 "FORMAT 6 - Overrun on channel C\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 break;
756 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100757 dev_warn(&device->cdev->dev,
758 "FORMAT 6 - Overrun on channel D\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 break;
760 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100761 dev_warn(&device->cdev->dev,
762 "FORMAT 6 - Overrun on channel E\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 break;
764 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100765 dev_warn(&device->cdev->dev,
766 "FORMAT 6 - Overrun on channel F\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 break;
768 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100769 dev_warn(&device->cdev->dev,
770 "FORMAT 6 - Overrun on channel G\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 break;
772 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100773 dev_warn(&device->cdev->dev,
774 "FORMAT 6 - Overrun on channel H\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 break;
776 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100777 dev_warn(&device->cdev->dev,
778 "FORMAT 6 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 }
780 break;
781
782 case 0x70: /* Format 7 - Device Connection Control Checks */
783 switch (msg_no) {
784 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100785 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 "FORMAT 7 - RCC initiated by a connection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100787 "check alert\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 break;
789 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100790 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 "FORMAT 7 - RCC 1 sequence not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100792 "successful\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 break;
794 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100795 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100797 "successful\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 break;
799 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100800 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 "FORMAT 7 - Invalid tag-in during "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100802 "selection sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 break;
804 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100805 dev_warn(&device->cdev->dev,
806 "FORMAT 7 - extra RCC required\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 break;
808 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100809 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 "FORMAT 7 - Invalid DCC selection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100811 "response or timeout\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 break;
813 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100814 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 "FORMAT 7 - Missing end operation; device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100816 "transfer complete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 break;
818 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100819 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 "FORMAT 7 - Missing end operation; device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100821 "transfer incomplete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 break;
823 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100824 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 "FORMAT 7 - Invalid tag-in for an "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100826 "immediate command sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 break;
828 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100829 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 "FORMAT 7 - Invalid tag-in for an "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100831 "extended command sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 break;
833 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100834 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 "FORMAT 7 - 3990 microcode time out when "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100836 "stopping selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 break;
838 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100839 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 "FORMAT 7 - No response to selection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100841 "after a poll interruption\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 break;
843 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100844 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 "FORMAT 7 - Permanent path error (DASD "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100846 "controller not available)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 break;
848 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100849 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 "FORMAT 7 - DASD controller not available"
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100851 " on disconnected command chain\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 break;
853 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100854 dev_warn(&device->cdev->dev,
855 "FORMAT 7 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 }
857 break;
858
859 case 0x80: /* Format 8 - Additional Device Equipment Checks */
860 switch (msg_no) {
861 case 0x00: /* No Message */
862 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100863 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 "FORMAT 8 - Error correction code "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100865 "hardware fault\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 break;
867 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100868 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 "FORMAT 8 - Unexpected end operation "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100870 "response code\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 break;
872 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100873 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 "FORMAT 8 - End operation with transfer "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100875 "count not zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 break;
877 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100878 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 "FORMAT 8 - End operation with transfer "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100880 "count zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 break;
882 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100883 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 "FORMAT 8 - DPS checks after a system "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100885 "reset or selective reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 break;
887 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100888 dev_warn(&device->cdev->dev,
889 "FORMAT 8 - DPS cannot be filled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 break;
891 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100892 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 "FORMAT 8 - Short busy time-out during "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100894 "device selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 break;
896 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100897 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 "FORMAT 8 - DASD controller failed to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100899 "set or reset the long busy latch\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 break;
901 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100902 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 "FORMAT 8 - No interruption from device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100904 "during a command chain\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 break;
906 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100907 dev_warn(&device->cdev->dev,
908 "FORMAT 8 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 }
910 break;
911
912 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
913 switch (msg_no) {
914 case 0x00:
915 break; /* No Message */
916 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100917 dev_warn(&device->cdev->dev,
918 "FORMAT 9 - Device check-2 error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 break;
920 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100921 dev_warn(&device->cdev->dev,
922 "FORMAT 9 - Head address did not "
923 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 break;
925 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100926 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 "FORMAT 9 - Track physical address did "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100928 "not compare while oriented\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 break;
930 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100931 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 "FORMAT 9 - Cylinder address did not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100933 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 break;
935 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100936 dev_warn(&device->cdev->dev,
937 "FORMAT 9 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 }
939 break;
940
941 case 0xF0: /* Format F - Cache Storage Checks */
942 switch (msg_no) {
943 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100944 dev_warn(&device->cdev->dev,
945 "FORMAT F - Operation Terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 break;
947 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100948 dev_warn(&device->cdev->dev,
949 "FORMAT F - Subsystem Processing Error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 break;
951 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100952 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 "FORMAT F - Cache or nonvolatile storage "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100954 "equipment failure\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 break;
956 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100957 dev_warn(&device->cdev->dev,
958 "FORMAT F - Caching terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 break;
960 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100961 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 "FORMAT F - Cache fast write access not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100963 "authorized\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 break;
965 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100966 dev_warn(&device->cdev->dev,
967 "FORMAT F - Track format incorrect\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 break;
969 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100970 dev_warn(&device->cdev->dev,
971 "FORMAT F - Caching reinitiated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972 break;
973 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100974 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 "FORMAT F - Nonvolatile storage "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100976 "terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 break;
978 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100979 dev_warn(&device->cdev->dev,
980 "FORMAT F - Volume is suspended duplex\n");
Stefan Weinhuber20c64462006-03-24 03:15:25 -0800981 /* call extended error reporting (EER) */
982 dasd_eer_write(device, erp->refers,
983 DASD_EER_PPRCSUSPEND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 break;
985 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100986 dev_warn(&device->cdev->dev,
987 "FORMAT F - Subsystem status cannot be "
988 "determined\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 break;
990 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100991 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 "FORMAT F - Caching status reset to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100993 "default\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 break;
995 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100996 dev_warn(&device->cdev->dev,
997 "FORMAT F - DASD Fast Write inhibited\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 break;
999 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001000 dev_warn(&device->cdev->dev,
1001 "FORMAT D - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 }
1003 break;
1004
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001005 default: /* unknown message format - should not happen
1006 internal error 03 - unknown message format */
1007 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
1008 dev_err(&device->cdev->dev,
1009 "An error occurred in the DASD device driver, "
1010 "reason=%s\n", errorstring);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 break;
1012 } /* end switch message format */
1013
1014} /* end dasd_3990_handle_env_data */
1015
1016/*
1017 * DASD_3990_ERP_COM_REJ
1018 *
1019 * DESCRIPTION
1020 * Handles 24 byte 'Command Reject' error.
1021 *
1022 * PARAMETER
1023 * erp current erp_head
1024 * sense current sense data
Horst Hummel138c0142006-06-29 14:58:12 +02001025 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001027 * erp 'new' erp_head - pointer to new ERP
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 */
1029static struct dasd_ccw_req *
1030dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1031{
1032
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001033 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034
1035 erp->function = dasd_3990_erp_com_rej;
1036
1037 /* env data present (ACTION 10 - retry should work) */
1038 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1039
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001040 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 "Command Reject - environmental data present");
1042
1043 dasd_3990_handle_env_data(erp, sense);
1044
1045 erp->retries = 5;
1046
Stefan Weinhuber33b62a32010-03-08 12:26:24 +01001047 } else if (sense[1] & SNS1_WRITE_INHIBITED) {
1048 dev_err(&device->cdev->dev, "An I/O request was rejected"
1049 " because writing is inhibited\n");
1050 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001052 /* fatal error - set status to FAILED
1053 internal error 09 - Command Reject */
1054 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1055 "device driver, reason=%s\n", "09");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056
1057 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1058 }
1059
1060 return erp;
1061
1062} /* end dasd_3990_erp_com_rej */
1063
1064/*
Horst Hummel138c0142006-06-29 14:58:12 +02001065 * DASD_3990_ERP_BUS_OUT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 *
1067 * DESCRIPTION
1068 * Handles 24 byte 'Bus Out Parity Check' error.
1069 *
1070 * PARAMETER
1071 * erp current erp_head
1072 * RETURN VALUES
1073 * erp new erp_head - pointer to new ERP
1074 */
1075static struct dasd_ccw_req *
1076dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1077{
1078
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001079 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080
1081 /* first time set initial retry counter and erp_function */
1082 /* and retry once without blocking queue */
1083 /* (this enables easier enqueing of the cqr) */
1084 if (erp->function != dasd_3990_erp_bus_out) {
1085 erp->retries = 256;
1086 erp->function = dasd_3990_erp_bus_out;
1087
1088 } else {
1089
1090 /* issue a message and wait for 'device ready' interrupt */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001091 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 "bus out parity error or BOPC requested by "
1093 "channel");
1094
1095 dasd_3990_erp_block_queue(erp, 60*HZ);
1096
1097 }
1098
1099 return erp;
1100
1101} /* end dasd_3990_erp_bus_out */
1102
1103/*
1104 * DASD_3990_ERP_EQUIP_CHECK
1105 *
1106 * DESCRIPTION
1107 * Handles 24 byte 'Equipment Check' error.
1108 *
1109 * PARAMETER
1110 * erp current erp_head
1111 * RETURN VALUES
1112 * erp new erp_head - pointer to new ERP
1113 */
1114static struct dasd_ccw_req *
1115dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1116{
1117
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001118 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119
1120 erp->function = dasd_3990_erp_equip_check;
1121
1122 if (sense[1] & SNS1_WRITE_INHIBITED) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001123 dev_info(&device->cdev->dev,
1124 "Write inhibited path encountered\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001126 /* vary path offline
1127 internal error 04 - Path should be varied off-line.*/
1128 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1129 "device driver, reason=%s\n", "04");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130
1131 erp = dasd_3990_erp_action_1(erp);
1132
1133 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1134
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001135 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 "Equipment Check - " "environmental data present");
1137
1138 dasd_3990_handle_env_data(erp, sense);
1139
1140 erp = dasd_3990_erp_action_4(erp, sense);
1141
1142 } else if (sense[1] & SNS1_PERM_ERR) {
1143
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001144 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 "Equipment Check - retry exhausted or "
1146 "undesirable");
1147
1148 erp = dasd_3990_erp_action_1(erp);
1149
1150 } else {
1151 /* all other equipment checks - Action 5 */
1152 /* rest is done when retries == 0 */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001153 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 "Equipment check or processing error");
1155
1156 erp = dasd_3990_erp_action_5(erp);
1157 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 return erp;
1159
1160} /* end dasd_3990_erp_equip_check */
1161
1162/*
1163 * DASD_3990_ERP_DATA_CHECK
1164 *
1165 * DESCRIPTION
1166 * Handles 24 byte 'Data Check' error.
1167 *
1168 * PARAMETER
1169 * erp current erp_head
1170 * RETURN VALUES
1171 * erp new erp_head - pointer to new ERP
1172 */
1173static struct dasd_ccw_req *
1174dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1175{
1176
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001177 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178
1179 erp->function = dasd_3990_erp_data_check;
1180
1181 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1182
1183 /* issue message that the data has been corrected */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001184 dev_emerg(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 "Data recovered during retry with PCI "
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001186 "fetch mode active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187
1188 /* not possible to handle this situation in Linux */
1189 panic("No way to inform application about the possibly "
1190 "incorrect data");
1191
1192 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1193
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001194 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 "Uncorrectable data check recovered secondary "
1196 "addr of duplex pair");
1197
1198 erp = dasd_3990_erp_action_4(erp, sense);
1199
1200 } else if (sense[1] & SNS1_PERM_ERR) {
1201
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001202 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 "Uncorrectable data check with internal "
1204 "retry exhausted");
1205
1206 erp = dasd_3990_erp_action_1(erp);
1207
1208 } else {
1209 /* all other data checks */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001210 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 "Uncorrectable data check with retry count "
1212 "exhausted...");
1213
1214 erp = dasd_3990_erp_action_5(erp);
1215 }
1216
1217 return erp;
1218
1219} /* end dasd_3990_erp_data_check */
1220
1221/*
1222 * DASD_3990_ERP_OVERRUN
1223 *
1224 * DESCRIPTION
1225 * Handles 24 byte 'Overrun' error.
1226 *
1227 * PARAMETER
1228 * erp current erp_head
1229 * RETURN VALUES
1230 * erp new erp_head - pointer to new ERP
1231 */
1232static struct dasd_ccw_req *
1233dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1234{
1235
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001236 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237
1238 erp->function = dasd_3990_erp_overrun;
1239
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001240 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 "Overrun - service overrun or overrun"
1242 " error requested by channel");
1243
1244 erp = dasd_3990_erp_action_5(erp);
1245
1246 return erp;
1247
1248} /* end dasd_3990_erp_overrun */
1249
1250/*
1251 * DASD_3990_ERP_INV_FORMAT
1252 *
1253 * DESCRIPTION
1254 * Handles 24 byte 'Invalid Track Format' error.
1255 *
1256 * PARAMETER
1257 * erp current erp_head
1258 * RETURN VALUES
1259 * erp new erp_head - pointer to new ERP
1260 */
1261static struct dasd_ccw_req *
1262dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1263{
1264
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001265 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266
1267 erp->function = dasd_3990_erp_inv_format;
1268
1269 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1270
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001271 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272 "Track format error when destaging or "
1273 "staging data");
1274
1275 dasd_3990_handle_env_data(erp, sense);
1276
1277 erp = dasd_3990_erp_action_4(erp, sense);
1278
1279 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001280 /* internal error 06 - The track format is not valid*/
1281 dev_err(&device->cdev->dev,
1282 "An error occurred in the DASD device driver, "
1283 "reason=%s\n", "06");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284
1285 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1286 }
1287
1288 return erp;
1289
1290} /* end dasd_3990_erp_inv_format */
1291
1292/*
1293 * DASD_3990_ERP_EOC
1294 *
1295 * DESCRIPTION
1296 * Handles 24 byte 'End-of-Cylinder' error.
1297 *
1298 * PARAMETER
1299 * erp already added default erp
1300 * RETURN VALUES
1301 * erp pointer to original (failed) cqr.
1302 */
1303static struct dasd_ccw_req *
1304dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1305{
1306
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001307 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001309 dev_err(&device->cdev->dev,
1310 "The cylinder data for accessing the DASD is inconsistent\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311
1312 /* implement action 7 - BUG */
1313 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1314
1315} /* end dasd_3990_erp_EOC */
1316
1317/*
1318 * DASD_3990_ERP_ENV_DATA
1319 *
1320 * DESCRIPTION
1321 * Handles 24 byte 'Environmental-Data Present' error.
1322 *
1323 * PARAMETER
1324 * erp current erp_head
1325 * RETURN VALUES
1326 * erp new erp_head - pointer to new ERP
1327 */
1328static struct dasd_ccw_req *
1329dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1330{
1331
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001332 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333
1334 erp->function = dasd_3990_erp_env_data;
1335
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001336 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337
1338 dasd_3990_handle_env_data(erp, sense);
1339
1340 /* don't retry on disabled interface */
1341 if (sense[7] != 0x0F) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 erp = dasd_3990_erp_action_4(erp, sense);
1343 } else {
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001344 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 }
1346
1347 return erp;
1348
1349} /* end dasd_3990_erp_env_data */
1350
1351/*
1352 * DASD_3990_ERP_NO_REC
1353 *
1354 * DESCRIPTION
1355 * Handles 24 byte 'No Record Found' error.
1356 *
1357 * PARAMETER
1358 * erp already added default ERP
Horst Hummel138c0142006-06-29 14:58:12 +02001359 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 * RETURN VALUES
1361 * erp new erp_head - pointer to new ERP
1362 */
1363static struct dasd_ccw_req *
1364dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1365{
1366
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001367 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001369 dev_err(&device->cdev->dev,
1370 "The specified record was not found\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371
1372 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1373
1374} /* end dasd_3990_erp_no_rec */
1375
1376/*
1377 * DASD_3990_ERP_FILE_PROT
1378 *
1379 * DESCRIPTION
1380 * Handles 24 byte 'File Protected' error.
1381 * Note: Seek related recovery is not implemented because
1382 * wee don't use the seek command yet.
1383 *
1384 * PARAMETER
1385 * erp current erp_head
1386 * RETURN VALUES
1387 * erp new erp_head - pointer to new ERP
1388 */
1389static struct dasd_ccw_req *
1390dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1391{
1392
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001393 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001395 dev_err(&device->cdev->dev, "Accessing the DASD failed because of "
1396 "a hardware error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397
1398 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1399
1400} /* end dasd_3990_erp_file_prot */
1401
1402/*
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001403 * DASD_3990_ERP_INSPECT_ALIAS
1404 *
1405 * DESCRIPTION
1406 * Checks if the original request was started on an alias device.
1407 * If yes, it modifies the original and the erp request so that
1408 * the erp request can be started on a base device.
1409 *
1410 * PARAMETER
1411 * erp pointer to the currently created default ERP
1412 *
1413 * RETURN VALUES
1414 * erp pointer to the modified ERP, or NULL
1415 */
1416
1417static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1418 struct dasd_ccw_req *erp)
1419{
1420 struct dasd_ccw_req *cqr = erp->refers;
Stefan Haberland501183f2010-05-17 10:00:10 +02001421 char *sense;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001422
1423 if (cqr->block &&
1424 (cqr->block->base != cqr->startdev)) {
Stefan Haberland501183f2010-05-17 10:00:10 +02001425
1426 sense = dasd_get_sense(&erp->refers->irb);
1427 /*
1428 * dynamic pav may have changed base alias mapping
1429 */
1430 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
1431 && (sense[0] == 0x10) && (sense[7] == 0x0F)
1432 && (sense[8] == 0x67)) {
1433 /*
1434 * remove device from alias handling to prevent new
1435 * requests from being scheduled on the
1436 * wrong alias device
1437 */
1438 dasd_alias_remove_device(cqr->startdev);
1439
1440 /* schedule worker to reload device */
1441 dasd_reload_device(cqr->startdev);
1442 }
1443
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001444 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001445 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001446 "ERP on alias device for request %p,"
1447 " recover on base device %s", cqr,
Kay Sievers2a0217d2008-10-10 21:33:09 +02001448 dev_name(&cqr->block->base->cdev->dev));
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001449 }
1450 dasd_eckd_reset_ccw_to_base_io(cqr);
1451 erp->startdev = cqr->block->base;
1452 erp->function = dasd_3990_erp_inspect_alias;
1453 return erp;
1454 } else
1455 return NULL;
1456}
1457
1458
1459/*
Horst Hummel138c0142006-06-29 14:58:12 +02001460 * DASD_3990_ERP_INSPECT_24
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 *
1462 * DESCRIPTION
1463 * Does a detailed inspection of the 24 byte sense data
Horst Hummel138c0142006-06-29 14:58:12 +02001464 * and sets up a related error recovery action.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 *
1466 * PARAMETER
1467 * sense sense data of the actual error
1468 * erp pointer to the currently created default ERP
1469 *
1470 * RETURN VALUES
1471 * erp pointer to the (addtitional) ERP
1472 */
1473static struct dasd_ccw_req *
1474dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1475{
1476
1477 struct dasd_ccw_req *erp_filled = NULL;
1478
1479 /* Check sense for .... */
1480 /* 'Command Reject' */
1481 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1482 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1483 }
1484 /* 'Intervention Required' */
1485 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1486 erp_filled = dasd_3990_erp_int_req(erp);
1487 }
1488 /* 'Bus Out Parity Check' */
1489 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1490 erp_filled = dasd_3990_erp_bus_out(erp);
1491 }
1492 /* 'Equipment Check' */
1493 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1494 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1495 }
1496 /* 'Data Check' */
1497 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1498 erp_filled = dasd_3990_erp_data_check(erp, sense);
1499 }
1500 /* 'Overrun' */
1501 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1502 erp_filled = dasd_3990_erp_overrun(erp, sense);
1503 }
1504 /* 'Invalid Track Format' */
1505 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1506 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1507 }
1508 /* 'End-of-Cylinder' */
1509 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1510 erp_filled = dasd_3990_erp_EOC(erp, sense);
1511 }
1512 /* 'Environmental Data' */
1513 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1514 erp_filled = dasd_3990_erp_env_data(erp, sense);
1515 }
1516 /* 'No Record Found' */
1517 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1518 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1519 }
1520 /* 'File Protected' */
1521 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1522 erp_filled = dasd_3990_erp_file_prot(erp);
1523 }
1524 /* other (unknown) error - do default ERP */
1525 if (erp_filled == NULL) {
1526
1527 erp_filled = erp;
1528 }
1529
1530 return erp_filled;
1531
1532} /* END dasd_3990_erp_inspect_24 */
1533
1534/*
Horst Hummel138c0142006-06-29 14:58:12 +02001535 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001536 * 32 byte sense ERP functions (only)
Horst Hummel138c0142006-06-29 14:58:12 +02001537 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 */
1539
1540/*
Horst Hummel138c0142006-06-29 14:58:12 +02001541 * DASD_3990_ERPACTION_10_32
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 *
1543 * DESCRIPTION
1544 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1545 * Just retry and if retry doesn't work, return with error.
1546 *
1547 * PARAMETER
1548 * erp current erp_head
Horst Hummel138c0142006-06-29 14:58:12 +02001549 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 * RETURN VALUES
1551 * erp modified erp_head
1552 */
1553static struct dasd_ccw_req *
1554dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1555{
1556
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001557 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558
1559 erp->retries = 256;
1560 erp->function = dasd_3990_erp_action_10_32;
1561
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001562 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563
1564 return erp;
1565
1566} /* end dasd_3990_erp_action_10_32 */
1567
1568/*
1569 * DASD_3990_ERP_ACTION_1B_32
1570 *
1571 * DESCRIPTION
1572 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
Horst Hummel138c0142006-06-29 14:58:12 +02001573 * A write operation could not be finished because of an unexpected
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574 * condition.
Horst Hummel138c0142006-06-29 14:58:12 +02001575 * The already created 'default erp' is used to get the link to
1576 * the erp chain, but it can not be used for this recovery
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 * action because it contains no DE/LO data space.
1578 *
1579 * PARAMETER
1580 * default_erp already added default erp.
Horst Hummel138c0142006-06-29 14:58:12 +02001581 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 *
1583 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001584 * erp new erp or
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585 * default_erp in case of imprecise ending or error
1586 */
1587static struct dasd_ccw_req *
1588dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1589{
1590
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001591 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 __u32 cpa = 0;
1593 struct dasd_ccw_req *cqr;
1594 struct dasd_ccw_req *erp;
1595 struct DE_eckd_data *DE_data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001596 struct PFX_eckd_data *PFX_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597 char *LO_data; /* LO_eckd_data_t */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001598 struct ccw1 *ccw, *oldccw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001600 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001601 "Write not finished because of unexpected condition");
1602
1603 default_erp->function = dasd_3990_erp_action_1B_32;
1604
1605 /* determine the original cqr */
1606 cqr = default_erp;
1607
1608 while (cqr->refers != NULL) {
1609 cqr = cqr->refers;
1610 }
1611
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001612 if (scsw_is_tm(&cqr->irb.scsw)) {
1613 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1614 "32 bit sense, action 1B is not defined"
1615 " in transport mode - just retry");
1616 return default_erp;
1617 }
1618
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619 /* for imprecise ending just do default erp */
1620 if (sense[1] & 0x01) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001621 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622 "Imprecise ending is set - just retry");
1623
1624 return default_erp;
1625 }
1626
1627 /* determine the address of the CCW to be restarted */
1628 /* Imprecise ending is not set -> addr from IRB-SCSW */
Peter Oberparleiter23d805b2008-07-14 09:58:50 +02001629 cpa = default_erp->refers->irb.scsw.cmd.cpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630
1631 if (cpa == 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001632 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633 "Unable to determine address of the CCW "
1634 "to be restarted");
1635
1636 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1637 }
1638
1639 /* Build new ERP request including DE/LO */
1640 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1641 2 + 1,/* DE/LO + TIC */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001642 sizeof(struct DE_eckd_data) +
1643 sizeof(struct LO_eckd_data), device);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644
1645 if (IS_ERR(erp)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001646 /* internal error 01 - Unable to allocate ERP */
1647 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1648 "device driver, reason=%s\n", "01");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1650 }
1651
1652 /* use original DE */
1653 DE_data = erp->data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001654 oldccw = cqr->cpaddr;
1655 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1656 PFX_data = cqr->data;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001657 memcpy(DE_data, &PFX_data->define_extent,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001658 sizeof(struct DE_eckd_data));
1659 } else
1660 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661
1662 /* create LO */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001663 LO_data = erp->data + sizeof(struct DE_eckd_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664
1665 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001666 /* should not */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1668 }
1669
1670 if ((sense[7] & 0x3F) == 0x01) {
1671 /* operation code is WRITE DATA -> data area orientation */
1672 LO_data[0] = 0x81;
1673
1674 } else if ((sense[7] & 0x3F) == 0x03) {
1675 /* operation code is FORMAT WRITE -> index orientation */
1676 LO_data[0] = 0xC3;
1677
1678 } else {
1679 LO_data[0] = sense[7]; /* operation */
1680 }
1681
1682 LO_data[1] = sense[8]; /* auxiliary */
1683 LO_data[2] = sense[9];
1684 LO_data[3] = sense[3]; /* count */
1685 LO_data[4] = sense[29]; /* seek_addr.cyl */
1686 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1687 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1688
1689 memcpy(&(LO_data[8]), &(sense[11]), 8);
1690
1691 /* create DE ccw */
1692 ccw = erp->cpaddr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001693 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1695 ccw->flags = CCW_FLAG_CC;
1696 ccw->count = 16;
1697 ccw->cda = (__u32)(addr_t) DE_data;
1698
1699 /* create LO ccw */
1700 ccw++;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001701 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1703 ccw->flags = CCW_FLAG_CC;
1704 ccw->count = 16;
1705 ccw->cda = (__u32)(addr_t) LO_data;
1706
1707 /* TIC to the failed ccw */
1708 ccw++;
1709 ccw->cmd_code = CCW_CMD_TIC;
1710 ccw->cda = cpa;
1711
1712 /* fill erp related fields */
1713 erp->function = dasd_3990_erp_action_1B_32;
1714 erp->refers = default_erp->refers;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001715 erp->startdev = device;
1716 erp->memdev = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 erp->magic = default_erp->magic;
1718 erp->expires = 0;
1719 erp->retries = 256;
1720 erp->buildclk = get_clock();
1721 erp->status = DASD_CQR_FILLED;
1722
1723 /* remove the default erp */
1724 dasd_free_erp_request(default_erp, device);
1725
1726 return erp;
1727
1728} /* end dasd_3990_erp_action_1B_32 */
1729
1730/*
1731 * DASD_3990_UPDATE_1B
1732 *
1733 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02001734 * Handles the update to the 32 byte 'Action 1B' of Single Program
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 * Action Codes in case the first action was not successful.
1736 * The already created 'previous_erp' is the currently not successful
Horst Hummel138c0142006-06-29 14:58:12 +02001737 * ERP.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 *
1739 * PARAMETER
1740 * previous_erp already created previous erp.
Horst Hummel138c0142006-06-29 14:58:12 +02001741 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001743 * erp modified erp
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 */
1745static struct dasd_ccw_req *
1746dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1747{
1748
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001749 struct dasd_device *device = previous_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 __u32 cpa = 0;
1751 struct dasd_ccw_req *cqr;
1752 struct dasd_ccw_req *erp;
1753 char *LO_data; /* struct LO_eckd_data */
1754 struct ccw1 *ccw;
1755
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001756 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 "Write not finished because of unexpected condition"
1758 " - follow on");
1759
1760 /* determine the original cqr */
1761 cqr = previous_erp;
1762
1763 while (cqr->refers != NULL) {
1764 cqr = cqr->refers;
1765 }
1766
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001767 if (scsw_is_tm(&cqr->irb.scsw)) {
1768 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1769 "32 bit sense, action 1B, update,"
1770 " in transport mode - just retry");
1771 return previous_erp;
1772 }
1773
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774 /* for imprecise ending just do default erp */
1775 if (sense[1] & 0x01) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001776 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001777 "Imprecise ending is set - just retry");
1778
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001779 previous_erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780
1781 return previous_erp;
1782 }
1783
1784 /* determine the address of the CCW to be restarted */
1785 /* Imprecise ending is not set -> addr from IRB-SCSW */
Peter Oberparleiter23d805b2008-07-14 09:58:50 +02001786 cpa = previous_erp->irb.scsw.cmd.cpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001787
1788 if (cpa == 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001789 /* internal error 02 -
1790 Unable to determine address of the CCW to be restarted */
1791 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1792 "device driver, reason=%s\n", "02");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793
1794 previous_erp->status = DASD_CQR_FAILED;
1795
1796 return previous_erp;
1797 }
1798
1799 erp = previous_erp;
1800
1801 /* update the LO with the new returned sense data */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001802 LO_data = erp->data + sizeof(struct DE_eckd_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803
1804 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001805 /* should not happen */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001806 previous_erp->status = DASD_CQR_FAILED;
1807
1808 return previous_erp;
1809 }
1810
1811 if ((sense[7] & 0x3F) == 0x01) {
1812 /* operation code is WRITE DATA -> data area orientation */
1813 LO_data[0] = 0x81;
1814
1815 } else if ((sense[7] & 0x3F) == 0x03) {
1816 /* operation code is FORMAT WRITE -> index orientation */
1817 LO_data[0] = 0xC3;
1818
1819 } else {
1820 LO_data[0] = sense[7]; /* operation */
1821 }
1822
1823 LO_data[1] = sense[8]; /* auxiliary */
1824 LO_data[2] = sense[9];
1825 LO_data[3] = sense[3]; /* count */
1826 LO_data[4] = sense[29]; /* seek_addr.cyl */
1827 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1828 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1829
1830 memcpy(&(LO_data[8]), &(sense[11]), 8);
1831
1832 /* TIC to the failed ccw */
1833 ccw = erp->cpaddr; /* addr of DE ccw */
1834 ccw++; /* addr of LE ccw */
1835 ccw++; /* addr of TIC ccw */
1836 ccw->cda = cpa;
1837
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001838 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839
1840 return erp;
1841
1842} /* end dasd_3990_update_1B */
1843
1844/*
Horst Hummel138c0142006-06-29 14:58:12 +02001845 * DASD_3990_ERP_COMPOUND_RETRY
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 *
1847 * DESCRIPTION
1848 * Handles the compound ERP action retry code.
1849 * NOTE: At least one retry is done even if zero is specified
1850 * by the sense data. This makes enqueueing of the request
1851 * easier.
1852 *
1853 * PARAMETER
1854 * sense sense data of the actual error
1855 * erp pointer to the currently created ERP
1856 *
1857 * RETURN VALUES
1858 * erp modified ERP pointer
1859 *
1860 */
1861static void
1862dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1863{
1864
1865 switch (sense[25] & 0x03) {
1866 case 0x00: /* no not retry */
1867 erp->retries = 1;
1868 break;
1869
1870 case 0x01: /* retry 2 times */
1871 erp->retries = 2;
1872 break;
1873
1874 case 0x02: /* retry 10 times */
1875 erp->retries = 10;
1876 break;
1877
1878 case 0x03: /* retry 256 times */
1879 erp->retries = 256;
1880 break;
1881
1882 default:
1883 BUG();
1884 }
1885
1886 erp->function = dasd_3990_erp_compound_retry;
1887
1888} /* end dasd_3990_erp_compound_retry */
1889
1890/*
Horst Hummel138c0142006-06-29 14:58:12 +02001891 * DASD_3990_ERP_COMPOUND_PATH
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 *
1893 * DESCRIPTION
1894 * Handles the compound ERP action for retry on alternate
1895 * channel path.
1896 *
1897 * PARAMETER
1898 * sense sense data of the actual error
1899 * erp pointer to the currently created ERP
1900 *
1901 * RETURN VALUES
1902 * erp modified ERP pointer
1903 *
1904 */
1905static void
1906dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1907{
1908
1909 if (sense[25] & DASD_SENSE_BIT_3) {
1910 dasd_3990_erp_alternate_path(erp);
1911
1912 if (erp->status == DASD_CQR_FAILED) {
Horst Hummel138c0142006-06-29 14:58:12 +02001913 /* reset the lpm and the status to be able to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 * try further actions. */
1915
1916 erp->lpm = 0;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001917 erp->status = DASD_CQR_NEED_ERP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 }
1919 }
1920
1921 erp->function = dasd_3990_erp_compound_path;
1922
1923} /* end dasd_3990_erp_compound_path */
1924
1925/*
Horst Hummel138c0142006-06-29 14:58:12 +02001926 * DASD_3990_ERP_COMPOUND_CODE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 *
1928 * DESCRIPTION
1929 * Handles the compound ERP action for retry code.
1930 *
1931 * PARAMETER
1932 * sense sense data of the actual error
1933 * erp pointer to the currently created ERP
1934 *
1935 * RETURN VALUES
1936 * erp NEW ERP pointer
1937 *
1938 */
1939static struct dasd_ccw_req *
1940dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1941{
1942
1943 if (sense[25] & DASD_SENSE_BIT_2) {
1944
1945 switch (sense[28]) {
1946 case 0x17:
Horst Hummel138c0142006-06-29 14:58:12 +02001947 /* issue a Diagnostic Control command with an
Robert P. J. Day3a4fa0a2007-10-19 23:10:43 +02001948 * Inhibit Write subcommand and controller modifier */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949 erp = dasd_3990_erp_DCTL(erp, 0x20);
1950 break;
Horst Hummel138c0142006-06-29 14:58:12 +02001951
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 case 0x25:
1953 /* wait for 5 seconds and retry again */
1954 erp->retries = 1;
Horst Hummel138c0142006-06-29 14:58:12 +02001955
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956 dasd_3990_erp_block_queue (erp, 5*HZ);
1957 break;
Horst Hummel138c0142006-06-29 14:58:12 +02001958
Linus Torvalds1da177e2005-04-16 15:20:36 -07001959 default:
1960 /* should not happen - continue */
1961 break;
1962 }
1963 }
1964
1965 erp->function = dasd_3990_erp_compound_code;
1966
1967 return erp;
1968
1969} /* end dasd_3990_erp_compound_code */
1970
1971/*
Horst Hummel138c0142006-06-29 14:58:12 +02001972 * DASD_3990_ERP_COMPOUND_CONFIG
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973 *
1974 * DESCRIPTION
1975 * Handles the compound ERP action for configruation
1976 * dependent error.
1977 * Note: duplex handling is not implemented (yet).
1978 *
1979 * PARAMETER
1980 * sense sense data of the actual error
1981 * erp pointer to the currently created ERP
1982 *
1983 * RETURN VALUES
1984 * erp modified ERP pointer
1985 *
1986 */
1987static void
1988dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
1989{
1990
1991 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
1992
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001993 /* set to suspended duplex state then restart
1994 internal error 05 - Set device to suspended duplex state
1995 should be done */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001996 struct dasd_device *device = erp->startdev;
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001997 dev_err(&device->cdev->dev,
1998 "An error occurred in the DASD device driver, "
1999 "reason=%s\n", "05");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000
2001 }
2002
2003 erp->function = dasd_3990_erp_compound_config;
2004
2005} /* end dasd_3990_erp_compound_config */
2006
2007/*
Horst Hummel138c0142006-06-29 14:58:12 +02002008 * DASD_3990_ERP_COMPOUND
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009 *
2010 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02002011 * Does the further compound program action if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012 * compound retry was not successful.
2013 *
2014 * PARAMETER
2015 * sense sense data of the actual error
2016 * erp pointer to the current (failed) ERP
2017 *
2018 * RETURN VALUES
2019 * erp (additional) ERP pointer
2020 *
2021 */
2022static struct dasd_ccw_req *
2023dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2024{
2025
2026 if ((erp->function == dasd_3990_erp_compound_retry) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002027 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028
2029 dasd_3990_erp_compound_path(erp, sense);
2030 }
2031
2032 if ((erp->function == dasd_3990_erp_compound_path) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002033 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034
2035 erp = dasd_3990_erp_compound_code(erp, sense);
2036 }
2037
2038 if ((erp->function == dasd_3990_erp_compound_code) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002039 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040
2041 dasd_3990_erp_compound_config(erp, sense);
2042 }
2043
2044 /* if no compound action ERP specified, the request failed */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002045 if (erp->status == DASD_CQR_NEED_ERP)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046 erp->status = DASD_CQR_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047
2048 return erp;
2049
2050} /* end dasd_3990_erp_compound */
2051
2052/*
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002053 *DASD_3990_ERP_HANDLE_SIM
2054 *
2055 *DESCRIPTION
2056 * inspects the SIM SENSE data and starts an appropriate action
2057 *
2058 * PARAMETER
2059 * sense sense data of the actual error
2060 *
2061 * RETURN VALUES
2062 * none
2063 */
2064void
2065dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2066{
2067 /* print message according to log or message to operator mode */
2068 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002069 /* print SIM SRC from RefCode */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002070 dev_err(&device->cdev->dev, "SIM - SRC: "
2071 "%02x%02x%02x%02x\n", sense[22],
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002072 sense[23], sense[11], sense[12]);
2073 } else if (sense[24] & DASD_SIM_LOG) {
2074 /* print SIM SRC Refcode */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002075 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2076 "%02x%02x%02x%02x\n", sense[22],
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002077 sense[23], sense[11], sense[12]);
2078 }
2079}
2080
2081/*
Horst Hummel138c0142006-06-29 14:58:12 +02002082 * DASD_3990_ERP_INSPECT_32
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083 *
2084 * DESCRIPTION
2085 * Does a detailed inspection of the 32 byte sense data
Horst Hummel138c0142006-06-29 14:58:12 +02002086 * and sets up a related error recovery action.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087 *
2088 * PARAMETER
2089 * sense sense data of the actual error
2090 * erp pointer to the currently created default ERP
2091 *
2092 * RETURN VALUES
2093 * erp_filled pointer to the ERP
2094 *
2095 */
2096static struct dasd_ccw_req *
2097dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2098{
2099
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002100 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101
2102 erp->function = dasd_3990_erp_inspect_32;
2103
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002104 /* check for SIM sense data */
2105 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2106 dasd_3990_erp_handle_sim(device, sense);
2107
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 if (sense[25] & DASD_SENSE_BIT_0) {
2109
2110 /* compound program action codes (byte25 bit 0 == '1') */
2111 dasd_3990_erp_compound_retry(erp, sense);
2112
2113 } else {
2114
2115 /* single program action codes (byte25 bit 0 == '0') */
2116 switch (sense[25]) {
2117
2118 case 0x00: /* success - use default ERP for retries */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002119 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120 "ERP called for successful request"
2121 " - just retry");
2122 break;
2123
2124 case 0x01: /* fatal error */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002125 dev_err(&device->cdev->dev,
2126 "ERP failed for the DASD\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127
2128 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2129 break;
2130
2131 case 0x02: /* intervention required */
2132 case 0x03: /* intervention required during dual copy */
2133 erp = dasd_3990_erp_int_req(erp);
2134 break;
2135
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002136 case 0x0F: /* length mismatch during update write command
2137 internal error 08 - update write command error*/
2138 dev_err(&device->cdev->dev, "An error occurred in the "
2139 "DASD device driver, reason=%s\n", "08");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140
2141 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2142 break;
2143
2144 case 0x10: /* logging required for other channel program */
2145 erp = dasd_3990_erp_action_10_32(erp, sense);
2146 break;
2147
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002148 case 0x15: /* next track outside defined extend
2149 internal error 07 - The next track is not
2150 within the defined storage extent */
2151 dev_err(&device->cdev->dev,
2152 "An error occurred in the DASD device driver, "
2153 "reason=%s\n", "07");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154
2155 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2156 break;
2157
2158 case 0x1B: /* unexpected condition during write */
2159
2160 erp = dasd_3990_erp_action_1B_32(erp, sense);
2161 break;
2162
2163 case 0x1C: /* invalid data */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002164 dev_emerg(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165 "Data recovered during retry with PCI "
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002166 "fetch mode active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167
2168 /* not possible to handle this situation in Linux */
2169 panic
2170 ("Invalid data - No way to inform application "
2171 "about the possibly incorrect data");
2172 break;
2173
2174 case 0x1D: /* state-change pending */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002175 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176 "A State change pending condition exists "
2177 "for the subsystem or device");
2178
2179 erp = dasd_3990_erp_action_4(erp, sense);
2180 break;
2181
2182 case 0x1E: /* busy */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002183 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184 "Busy condition exists "
2185 "for the subsystem or device");
2186 erp = dasd_3990_erp_action_4(erp, sense);
2187 break;
2188
2189 default: /* all others errors - default erp */
2190 break;
2191 }
2192 }
2193
2194 return erp;
2195
2196} /* end dasd_3990_erp_inspect_32 */
2197
2198/*
Horst Hummel138c0142006-06-29 14:58:12 +02002199 *****************************************************************************
Stefan Weileef35c22010-08-06 21:11:15 +02002200 * main ERP control functions (24 and 32 byte sense)
Horst Hummel138c0142006-06-29 14:58:12 +02002201 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 */
2203
2204/*
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002205 * DASD_3990_ERP_CONTROL_CHECK
2206 *
2207 * DESCRIPTION
2208 * Does a generic inspection if a control check occured and sets up
2209 * the related error recovery procedure
2210 *
2211 * PARAMETER
2212 * erp pointer to the currently created default ERP
2213 *
2214 * RETURN VALUES
2215 * erp_filled pointer to the erp
2216 */
2217
2218static struct dasd_ccw_req *
2219dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2220{
2221 struct dasd_device *device = erp->startdev;
2222
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002223 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002224 | SCHN_STAT_CHN_CTRL_CHK)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002225 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002226 "channel or interface control check");
2227 erp = dasd_3990_erp_action_4(erp, NULL);
2228 }
2229 return erp;
2230}
2231
2232/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 * DASD_3990_ERP_INSPECT
2234 *
2235 * DESCRIPTION
2236 * Does a detailed inspection for sense data by calling either
2237 * the 24-byte or the 32-byte inspection routine.
2238 *
2239 * PARAMETER
2240 * erp pointer to the currently created default ERP
2241 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02002242 * erp_new contens was possibly modified
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 */
2244static struct dasd_ccw_req *
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002245dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246{
2247
2248 struct dasd_ccw_req *erp_new = NULL;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002249 char *sense;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002251 /* if this problem occured on an alias retry on base */
2252 erp_new = dasd_3990_erp_inspect_alias(erp);
2253 if (erp_new)
2254 return erp_new;
2255
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002256 /* sense data are located in the refers record of the
2257 * already set up new ERP !
2258 * check if concurrent sens is available
2259 */
2260 sense = dasd_get_sense(&erp->refers->irb);
2261 if (!sense)
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002262 erp_new = dasd_3990_erp_control_check(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 /* distinguish between 24 and 32 byte sense data */
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002264 else if (sense[27] & DASD_SENSE_BIT_0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265
2266 /* inspect the 24 byte sense data */
2267 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2268
2269 } else {
2270
2271 /* inspect the 32 byte sense data */
2272 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2273
2274 } /* end distinguish between 24 and 32 byte sense data */
2275
2276 return erp_new;
2277}
2278
2279/*
2280 * DASD_3990_ERP_ADD_ERP
Horst Hummel138c0142006-06-29 14:58:12 +02002281 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 * DESCRIPTION
2283 * This funtion adds an additional request block (ERP) to the head of
2284 * the given cqr (or erp).
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002285 * For a command mode cqr the erp is initialized as an default erp
2286 * (retry TIC).
2287 * For transport mode we make a copy of the original TCW (points to
2288 * the original TCCB, TIDALs, etc.) but give it a fresh
2289 * TSB so the original sense data will not be changed.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 *
2291 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002292 * cqr head of the current ERP-chain (or single cqr if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293 * first error)
2294 * RETURN VALUES
2295 * erp pointer to new ERP-chain head
2296 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002297static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298{
2299
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002300 struct dasd_device *device = cqr->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 struct ccw1 *ccw;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002302 struct dasd_ccw_req *erp;
2303 int cplength, datasize;
2304 struct tcw *tcw;
2305 struct tsb *tsb;
2306
2307 if (cqr->cpmode == 1) {
2308 cplength = 0;
Stefan Weinhuber4a31ba52010-03-24 11:49:53 +01002309 /* TCW needs to be 64 byte aligned, so leave enough room */
2310 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002311 } else {
2312 cplength = 2;
2313 datasize = 0;
2314 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315
2316 /* allocate additional request block */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002317 erp = dasd_alloc_erp_request((char *) &cqr->magic,
2318 cplength, datasize, device);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 if (IS_ERR(erp)) {
2320 if (cqr->retries <= 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002321 DBF_DEV_EVENT(DBF_ERR, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 "Unable to allocate ERP request");
2323 cqr->status = DASD_CQR_FAILED;
2324 cqr->stopclk = get_clock ();
2325 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002326 DBF_DEV_EVENT(DBF_ERR, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 "Unable to allocate ERP request "
2328 "(%i retries left)",
2329 cqr->retries);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002330 dasd_block_set_timer(device->block, (HZ << 3));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 }
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002332 return erp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 }
2334
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002335 ccw = cqr->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002336 if (cqr->cpmode == 1) {
2337 /* make a shallow copy of the original tcw but set new tsb */
2338 erp->cpmode = 1;
Stefan Weinhuber4a31ba52010-03-24 11:49:53 +01002339 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2340 tcw = erp->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002341 tsb = (struct tsb *) &tcw[1];
2342 *tcw = *((struct tcw *)cqr->cpaddr);
2343 tcw->tsb = (long)tsb;
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002344 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
2345 /* PSF cannot be chained from NOOP/TIC */
2346 erp->cpaddr = cqr->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002347 } else {
2348 /* initialize request with default TIC to current ERP/CQR */
2349 ccw = erp->cpaddr;
2350 ccw->cmd_code = CCW_CMD_NOOP;
2351 ccw->flags = CCW_FLAG_CC;
2352 ccw++;
2353 ccw->cmd_code = CCW_CMD_TIC;
2354 ccw->cda = (long)(cqr->cpaddr);
2355 }
2356
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 erp->function = dasd_3990_erp_add_erp;
2358 erp->refers = cqr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002359 erp->startdev = device;
2360 erp->memdev = device;
2361 erp->block = cqr->block;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 erp->magic = cqr->magic;
2363 erp->expires = 0;
2364 erp->retries = 256;
2365 erp->buildclk = get_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 erp->status = DASD_CQR_FILLED;
2367
2368 return erp;
2369}
2370
2371/*
Horst Hummel138c0142006-06-29 14:58:12 +02002372 * DASD_3990_ERP_ADDITIONAL_ERP
2373 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374 * DESCRIPTION
2375 * An additional ERP is needed to handle the current error.
2376 * Add ERP to the head of the ERP-chain containing the ERP processing
2377 * determined based on the sense data.
2378 *
2379 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002380 * cqr head of the current ERP-chain (or single cqr if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 * first error)
2382 *
2383 * RETURN VALUES
2384 * erp pointer to new ERP-chain head
2385 */
2386static struct dasd_ccw_req *
2387dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2388{
2389
2390 struct dasd_ccw_req *erp = NULL;
2391
2392 /* add erp and initialize with default TIC */
2393 erp = dasd_3990_erp_add_erp(cqr);
2394
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002395 if (IS_ERR(erp))
2396 return erp;
2397
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 /* inspect sense, determine specific ERP if possible */
2399 if (erp != cqr) {
2400
2401 erp = dasd_3990_erp_inspect(erp);
2402 }
2403
2404 return erp;
2405
2406} /* end dasd_3990_erp_additional_erp */
2407
2408/*
2409 * DASD_3990_ERP_ERROR_MATCH
2410 *
2411 * DESCRIPTION
2412 * Check if the device status of the given cqr is the same.
2413 * This means that the failed CCW and the relevant sense data
2414 * must match.
2415 * I don't distinguish between 24 and 32 byte sense because in case of
2416 * 24 byte sense byte 25 and 27 is set as well.
2417 *
2418 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002419 * cqr1 first cqr, which will be compared with the
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 * cqr2 second cqr.
2421 *
2422 * RETURN VALUES
2423 * match 'boolean' for match found
2424 * returns 1 if match found, otherwise 0.
2425 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002426static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2427 struct dasd_ccw_req *cqr2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428{
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002429 char *sense1, *sense2;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430
Stefan Weinhuber5c12f242008-03-05 12:37:10 +01002431 if (cqr1->startdev != cqr2->startdev)
2432 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002434 sense1 = dasd_get_sense(&cqr1->irb);
2435 sense2 = dasd_get_sense(&cqr2->irb);
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002436
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002437 /* one request has sense data, the other not -> no match, return 0 */
2438 if (!sense1 != !sense2)
2439 return 0;
2440 /* no sense data in both cases -> check cstat for IFCC */
2441 if (!sense1 && !sense2) {
2442 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2443 SCHN_STAT_CHN_CTRL_CHK)) ==
2444 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2445 SCHN_STAT_CHN_CTRL_CHK)))
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002446 return 1; /* match with ifcc*/
2447 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 /* check sense data; byte 0-2,25,27 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002449 if (!(sense1 && sense2 &&
2450 (memcmp(sense1, sense2, 3) == 0) &&
2451 (sense1[27] == sense2[27]) &&
2452 (sense1[25] == sense2[25]))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453
2454 return 0; /* sense doesn't match */
2455 }
2456
2457 return 1; /* match */
2458
2459} /* end dasd_3990_erp_error_match */
2460
2461/*
2462 * DASD_3990_ERP_IN_ERP
2463 *
2464 * DESCRIPTION
2465 * check if the current error already happened before.
2466 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2467 *
2468 * PARAMETER
2469 * cqr failed cqr (either original cqr or already an erp)
2470 *
2471 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02002472 * erp erp-pointer to the already defined error
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 * recovery procedure OR
2474 * NULL if a 'new' error occurred.
2475 */
2476static struct dasd_ccw_req *
2477dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2478{
2479
2480 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2481 *erp_match = NULL; /* save erp chain head */
2482 int match = 0; /* 'boolean' for matching error found */
2483
2484 if (cqr->refers == NULL) { /* return if not in erp */
2485 return NULL;
2486 }
2487
2488 /* check the erp/cqr chain for current error */
2489 do {
2490 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2491 erp_match = cqr; /* save possible matching erp */
2492 cqr = cqr->refers; /* check next erp/cqr in queue */
2493
2494 } while ((cqr->refers != NULL) && (!match));
2495
2496 if (!match) {
2497 return NULL; /* no match was found */
2498 }
2499
2500 return erp_match; /* return address of matching erp */
2501
2502} /* END dasd_3990_erp_in_erp */
2503
2504/*
2505 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2506 *
2507 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02002508 * No retry is left for the current ERP. Check what has to be done
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 * with the ERP.
2510 * - do further defined ERP action or
Horst Hummel138c0142006-06-29 14:58:12 +02002511 * - wait for interrupt or
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 * - exit with permanent error
2513 *
2514 * PARAMETER
2515 * erp ERP which is in progress with no retry left
2516 *
2517 * RETURN VALUES
2518 * erp modified/additional ERP
2519 */
2520static struct dasd_ccw_req *
2521dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2522{
2523
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002524 struct dasd_device *device = erp->startdev;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002525 char *sense = dasd_get_sense(&erp->irb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526
2527 /* check for 24 byte sense ERP */
2528 if ((erp->function == dasd_3990_erp_bus_out) ||
2529 (erp->function == dasd_3990_erp_action_1) ||
2530 (erp->function == dasd_3990_erp_action_4)) {
2531
2532 erp = dasd_3990_erp_action_1(erp);
2533
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002534 } else if (erp->function == dasd_3990_erp_action_1_sec) {
2535 erp = dasd_3990_erp_action_1_sec(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536 } else if (erp->function == dasd_3990_erp_action_5) {
2537
2538 /* retries have not been successful */
2539 /* prepare erp for retry on different channel path */
2540 erp = dasd_3990_erp_action_1(erp);
2541
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002542 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543
Horst Hummel138c0142006-06-29 14:58:12 +02002544 /* issue a Diagnostic Control command with an
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 * Inhibit Write subcommand */
2546
2547 switch (sense[25]) {
2548 case 0x17:
2549 case 0x57:{ /* controller */
2550 erp = dasd_3990_erp_DCTL(erp, 0x20);
2551 break;
2552 }
2553 case 0x18:
2554 case 0x58:{ /* channel path */
2555 erp = dasd_3990_erp_DCTL(erp, 0x40);
2556 break;
2557 }
2558 case 0x19:
2559 case 0x59:{ /* storage director */
2560 erp = dasd_3990_erp_DCTL(erp, 0x80);
2561 break;
2562 }
2563 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002564 DBF_DEV_EVENT(DBF_WARNING, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 "invalid subcommand modifier 0x%x "
2566 "for Diagnostic Control Command",
2567 sense[25]);
2568 }
2569 }
2570
2571 /* check for 32 byte sense ERP */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002572 } else if (sense &&
2573 ((erp->function == dasd_3990_erp_compound_retry) ||
2574 (erp->function == dasd_3990_erp_compound_path) ||
2575 (erp->function == dasd_3990_erp_compound_code) ||
2576 (erp->function == dasd_3990_erp_compound_config))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577
2578 erp = dasd_3990_erp_compound(erp, sense);
2579
2580 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002581 /*
2582 * No retry left and no additional special handling
2583 * necessary
2584 */
2585 dev_err(&device->cdev->dev,
2586 "ERP %p has run out of retries and failed\n", erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587
2588 erp->status = DASD_CQR_FAILED;
2589 }
2590
2591 return erp;
2592
2593} /* end dasd_3990_erp_further_erp */
2594
2595/*
Horst Hummel138c0142006-06-29 14:58:12 +02002596 * DASD_3990_ERP_HANDLE_MATCH_ERP
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 *
2598 * DESCRIPTION
2599 * An error occurred again and an ERP has been detected which is already
Horst Hummel138c0142006-06-29 14:58:12 +02002600 * used to handle this error (e.g. retries).
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 * All prior ERP's are asumed to be successful and therefore removed
2602 * from queue.
Horst Hummel138c0142006-06-29 14:58:12 +02002603 * If retry counter of matching erp is already 0, it is checked if further
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604 * action is needed (besides retry) or if the ERP has failed.
2605 *
2606 * PARAMETER
2607 * erp_head first ERP in ERP-chain
2608 * erp ERP that handles the actual error.
2609 * (matching erp)
2610 *
2611 * RETURN VALUES
2612 * erp modified/additional ERP
2613 */
2614static struct dasd_ccw_req *
2615dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2616 struct dasd_ccw_req *erp)
2617{
2618
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002619 struct dasd_device *device = erp_head->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2621 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2622
2623 /* loop over successful ERPs and remove them from chanq */
2624 while (erp_done != erp) {
2625
2626 if (erp_done == NULL) /* end of chain reached */
2627 panic(PRINTK_HEADER "Programming error in ERP! The "
2628 "original request was lost\n");
2629
2630 /* remove the request from the device queue */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002631 list_del(&erp_done->blocklist);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632
2633 erp_free = erp_done;
2634 erp_done = erp_done->refers;
2635
2636 /* free the finished erp request */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002637 dasd_free_erp_request(erp_free, erp_free->memdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638
2639 } /* end while */
2640
2641 if (erp->retries > 0) {
2642
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002643 char *sense = dasd_get_sense(&erp->refers->irb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644
2645 /* check for special retries */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002646 if (sense && erp->function == dasd_3990_erp_action_4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647
2648 erp = dasd_3990_erp_action_4(erp, sense);
2649
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002650 } else if (sense &&
2651 erp->function == dasd_3990_erp_action_1B_32) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652
2653 erp = dasd_3990_update_1B(erp, sense);
2654
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002655 } else if (sense && erp->function == dasd_3990_erp_int_req) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656
2657 erp = dasd_3990_erp_int_req(erp);
2658
2659 } else {
2660 /* simple retry */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002661 DBF_DEV_EVENT(DBF_DEBUG, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 "%i retries left for erp %p",
2663 erp->retries, erp);
2664
2665 /* handle the request again... */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002666 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 }
2668
2669 } else {
2670 /* no retry left - check for further necessary action */
2671 /* if no further actions, handle rest as permanent error */
2672 erp = dasd_3990_erp_further_erp(erp);
2673 }
2674
2675 return erp;
2676
2677} /* end dasd_3990_erp_handle_match_erp */
2678
2679/*
2680 * DASD_3990_ERP_ACTION
2681 *
2682 * DESCRIPTION
Joe Perches5d67d162008-01-26 14:11:20 +01002683 * control routine for 3990 erp actions.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2685 *
2686 * PARAMETER
2687 * cqr failed cqr (either original cqr or already an erp)
2688 *
2689 * RETURN VALUES
2690 * erp erp-pointer to the head of the ERP action chain.
2691 * This means:
2692 * - either a ptr to an additional ERP cqr or
Horst Hummel138c0142006-06-29 14:58:12 +02002693 * - the original given cqr (which's status might
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 * be modified)
2695 */
2696struct dasd_ccw_req *
2697dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2698{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002699 struct dasd_ccw_req *erp = NULL;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002700 struct dasd_device *device = cqr->startdev;
Horst Hummel9575bf22006-12-08 15:54:15 +01002701 struct dasd_ccw_req *temp_erp = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702
Horst Hummel9575bf22006-12-08 15:54:15 +01002703 if (device->features & DASD_FEATURE_ERPLOG) {
2704 /* print current erp_chain */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002705 dev_err(&device->cdev->dev,
2706 "ERP chain at BEGINNING of ERP-ACTION\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002707 for (temp_erp = cqr;
2708 temp_erp != NULL; temp_erp = temp_erp->refers) {
2709
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002710 dev_err(&device->cdev->dev,
2711 "ERP %p (%02x) refers to %p\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 temp_erp, temp_erp->status,
2713 temp_erp->refers);
2714 }
2715 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002716
Coly Li73ac36e2009-01-07 18:09:16 -08002717 /* double-check if current erp/cqr was successful */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002718 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2719 (scsw_dstat(&cqr->irb.scsw) ==
Peter Oberparleiter23d805b2008-07-14 09:58:50 +02002720 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002722 DBF_DEV_EVENT(DBF_DEBUG, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 "ERP called for successful request %p"
2724 " - NO ERP necessary", cqr);
2725
2726 cqr->status = DASD_CQR_DONE;
2727
2728 return cqr;
2729 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730
2731 /* check if error happened before */
2732 erp = dasd_3990_erp_in_erp(cqr);
2733
2734 if (erp == NULL) {
2735 /* no matching erp found - set up erp */
2736 erp = dasd_3990_erp_additional_erp(cqr);
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002737 if (IS_ERR(erp))
2738 return erp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002739 } else {
2740 /* matching erp found - set all leading erp's to DONE */
2741 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2742 }
2743
Horst Hummel9575bf22006-12-08 15:54:15 +01002744 if (device->features & DASD_FEATURE_ERPLOG) {
2745 /* print current erp_chain */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002746 dev_err(&device->cdev->dev,
2747 "ERP chain at END of ERP-ACTION\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002748 for (temp_erp = erp;
2749 temp_erp != NULL; temp_erp = temp_erp->refers) {
2750
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002751 dev_err(&device->cdev->dev,
2752 "ERP %p (%02x) refers to %p\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002753 temp_erp, temp_erp->status,
2754 temp_erp->refers);
2755 }
2756 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002757
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002758 /* enqueue ERP request if it's a new one */
2759 if (list_empty(&erp->blocklist)) {
2760 cqr->status = DASD_CQR_IN_ERP;
2761 /* add erp request before the cqr */
2762 list_add_tail(&erp->blocklist, &cqr->blocklist);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763 }
2764
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002765
2766
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 return erp;
2768
2769} /* end dasd_3990_erp_action */