blob: 968c76cf71276e91c8d21c5d523c3f4a214cbade [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;
Stefan Weinhuber7ea8d322010-10-25 16:10:08 +0200224 dctl_cqr->flags = erp->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 dctl_cqr->function = dasd_3990_erp_DCTL;
226 dctl_cqr->refers = erp;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100227 dctl_cqr->startdev = device;
228 dctl_cqr->memdev = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 dctl_cqr->magic = erp->magic;
230 dctl_cqr->expires = 5 * 60 * HZ;
231 dctl_cqr->retries = 2;
232
233 dctl_cqr->buildclk = get_clock();
234
235 dctl_cqr->status = DASD_CQR_FILLED;
236
237 return dctl_cqr;
238
239} /* end dasd_3990_erp_DCTL */
240
241/*
Horst Hummel138c0142006-06-29 14:58:12 +0200242 * DASD_3990_ERP_ACTION_1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 *
244 * DESCRIPTION
245 * Setup ERP to do the ERP action 1 (see Reference manual).
246 * Repeat the operation on a different channel path.
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100247 * As deviation from the recommended recovery action, we reset the path mask
248 * after we have tried each path and go through all paths a second time.
249 * This will cover situations where only one path at a time is actually down,
250 * but all paths fail and recover just with the same sequence and timing as
251 * we try to use them (flapping links).
252 * If all alternate paths have been tried twice, the request is posted with
253 * a permanent error.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 *
255 * PARAMETER
256 * erp pointer to the current ERP
257 *
258 * RETURN VALUES
259 * erp pointer to the ERP
260 *
261 */
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100262static struct dasd_ccw_req *dasd_3990_erp_action_1_sec(struct dasd_ccw_req *erp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263{
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100264 erp->function = dasd_3990_erp_action_1_sec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 dasd_3990_erp_alternate_path(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 return erp;
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100267}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100269static struct dasd_ccw_req *dasd_3990_erp_action_1(struct dasd_ccw_req *erp)
270{
271 erp->function = dasd_3990_erp_action_1;
272 dasd_3990_erp_alternate_path(erp);
273 if (erp->status == DASD_CQR_FAILED) {
274 erp->status = DASD_CQR_FILLED;
275 erp->retries = 10;
276 erp->lpm = LPM_ANYPATH;
277 erp->function = dasd_3990_erp_action_1_sec;
278 }
279 return erp;
280} /* end dasd_3990_erp_action_1(b) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282/*
Horst Hummel138c0142006-06-29 14:58:12 +0200283 * DASD_3990_ERP_ACTION_4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 *
285 * DESCRIPTION
286 * Setup ERP to do the ERP action 4 (see Reference manual).
287 * Set the current request to PENDING to block the CQR queue for that device
288 * until the state change interrupt appears.
289 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
290 * missing.
291 *
292 * PARAMETER
293 * sense sense data of the actual error
294 * erp pointer to the current ERP
295 *
296 * RETURN VALUES
297 * erp pointer to the ERP
298 *
299 */
300static struct dasd_ccw_req *
301dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
302{
303
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100304 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 /* first time set initial retry counter and erp_function */
307 /* and retry once without waiting for state change pending */
308 /* interrupt (this enables easier enqueing of the cqr) */
309 if (erp->function != dasd_3990_erp_action_4) {
310
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100311 DBF_DEV_EVENT(DBF_INFO, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 "dasd_3990_erp_action_4: first time retry");
313
314 erp->retries = 256;
315 erp->function = dasd_3990_erp_action_4;
316
317 } else {
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100318 if (sense && (sense[25] == 0x1D)) { /* state change pending */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100320 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 "waiting for state change pending "
322 "interrupt, %d retries left",
323 erp->retries);
Horst Hummel138c0142006-06-29 14:58:12 +0200324
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 dasd_3990_erp_block_queue(erp, 30*HZ);
326
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100327 } else if (sense && (sense[25] == 0x1E)) { /* busy */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100328 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 "busy - redriving request later, "
330 "%d retries left",
331 erp->retries);
332 dasd_3990_erp_block_queue(erp, HZ);
333 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 /* no state change pending - retry */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100335 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 "redriving request immediately, "
Horst Hummel138c0142006-06-29 14:58:12 +0200337 "%d retries left",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 erp->retries);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100339 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 }
341 }
342
343 return erp;
344
345} /* end dasd_3990_erp_action_4 */
346
347/*
Horst Hummel138c0142006-06-29 14:58:12 +0200348 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 * 24 byte sense ERP functions (only)
Horst Hummel138c0142006-06-29 14:58:12 +0200350 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 */
352
353/*
Horst Hummel138c0142006-06-29 14:58:12 +0200354 * DASD_3990_ERP_ACTION_5
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 *
356 * DESCRIPTION
357 * Setup ERP to do the ERP action 5 (see Reference manual).
358 * NOTE: Further handling is done in xxx_further_erp after the retries.
359 *
360 * PARAMETER
361 * erp pointer to the current ERP
362 *
363 * RETURN VALUES
364 * erp pointer to the ERP
365 *
366 */
367static struct dasd_ccw_req *
368dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
369{
370
371 /* first of all retry */
372 erp->retries = 10;
373 erp->function = dasd_3990_erp_action_5;
374
375 return erp;
376
377} /* end dasd_3990_erp_action_5 */
378
379/*
380 * DASD_3990_HANDLE_ENV_DATA
381 *
382 * DESCRIPTION
383 * Handles 24 byte 'Environmental data present'.
384 * Does a analysis of the sense data (message Format)
385 * and prints the error messages.
386 *
387 * PARAMETER
388 * sense current sense data
Horst Hummel138c0142006-06-29 14:58:12 +0200389 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 * RETURN VALUES
391 * void
392 */
393static void
394dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
395{
396
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100397 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 char msg_format = (sense[7] & 0xF0);
399 char msg_no = (sense[7] & 0x0F);
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100400 char errorstring[ERRORLENGTH];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 switch (msg_format) {
403 case 0x00: /* Format 0 - Program or System Checks */
404
405 if (sense[1] & 0x10) { /* check message to operator bit */
406
407 switch (msg_no) {
408 case 0x00: /* No Message */
409 break;
410 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100411 dev_warn(&device->cdev->dev,
412 "FORMAT 0 - Invalid Command\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 break;
414 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100415 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 "FORMAT 0 - Invalid Command "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100417 "Sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 break;
419 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100420 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 "FORMAT 0 - CCW Count less than "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100422 "required\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 break;
424 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100425 dev_warn(&device->cdev->dev,
426 "FORMAT 0 - Invalid Parameter\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 break;
428 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100429 dev_warn(&device->cdev->dev,
430 "FORMAT 0 - Diagnostic of Special"
431 " Command Violates File Mask\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 break;
433 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100434 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 "FORMAT 0 - Channel Returned with "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100436 "Incorrect retry CCW\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 break;
438 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100439 dev_warn(&device->cdev->dev,
440 "FORMAT 0 - Reset Notification\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 break;
442 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100443 dev_warn(&device->cdev->dev,
444 "FORMAT 0 - Storage Path Restart\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 break;
446 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100447 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 "FORMAT 0 - Channel requested "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100449 "... %02x\n", sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 break;
451 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100452 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 "FORMAT 0 - Invalid Defective/"
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100454 "Alternate Track Pointer\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 break;
456 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100457 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 "FORMAT 0 - DPS Installation "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100459 "Check\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 break;
461 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100462 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 "FORMAT 0 - Command Invalid on "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100464 "Secondary Address\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 break;
466 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100467 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 "FORMAT 0 - Status Not As "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100469 "Required: reason %02x\n",
470 sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 break;
472 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100473 dev_warn(&device->cdev->dev,
474 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 }
476 } else {
477 switch (msg_no) {
478 case 0x00: /* No Message */
479 break;
480 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100481 dev_warn(&device->cdev->dev,
482 "FORMAT 0 - Device Error "
483 "Source\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 break;
485 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100486 dev_warn(&device->cdev->dev,
487 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 break;
489 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100490 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 "FORMAT 0 - Device Fenced - "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100492 "device = %02x\n", sense[4]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 break;
494 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100495 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 "FORMAT 0 - Data Pinned for "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100497 "Device\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 break;
499 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100500 dev_warn(&device->cdev->dev,
501 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 }
503 }
504 break;
505
506 case 0x10: /* Format 1 - Device Equipment Checks */
507 switch (msg_no) {
508 case 0x00: /* No Message */
509 break;
510 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100511 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 "FORMAT 1 - Device Status 1 not as "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100513 "expected\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 break;
515 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100516 dev_warn(&device->cdev->dev,
517 "FORMAT 1 - Index missing\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 break;
519 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100520 dev_warn(&device->cdev->dev,
521 "FORMAT 1 - Interruption cannot be "
522 "reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 break;
524 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100525 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 "FORMAT 1 - Device did not respond to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100527 "selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 break;
529 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100530 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 "FORMAT 1 - Device check-2 error or Set "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100532 "Sector is not complete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 break;
534 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100535 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 "FORMAT 1 - Head address does not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100537 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 break;
539 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100540 dev_warn(&device->cdev->dev,
541 "FORMAT 1 - Device status 1 not valid\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 break;
543 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100544 dev_warn(&device->cdev->dev,
545 "FORMAT 1 - Device not ready\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 break;
547 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100548 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 "FORMAT 1 - Track physical address did "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100550 "not compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 break;
552 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100553 dev_warn(&device->cdev->dev,
554 "FORMAT 1 - Missing device address bit\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 break;
556 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100557 dev_warn(&device->cdev->dev,
558 "FORMAT 1 - Drive motor switch is off\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 break;
560 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100561 dev_warn(&device->cdev->dev,
562 "FORMAT 1 - Seek incomplete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 break;
564 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100565 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 "FORMAT 1 - Cylinder address did not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100567 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 break;
569 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100570 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 "FORMAT 1 - Offset active cannot be "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100572 "reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 break;
574 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100575 dev_warn(&device->cdev->dev,
576 "FORMAT 1 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 }
578 break;
579
580 case 0x20: /* Format 2 - 3990 Equipment Checks */
581 switch (msg_no) {
582 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100583 dev_warn(&device->cdev->dev,
584 "FORMAT 2 - 3990 check-2 error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 break;
586 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100587 dev_warn(&device->cdev->dev,
588 "FORMAT 2 - Support facility errors\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 break;
590 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100591 dev_warn(&device->cdev->dev,
592 "FORMAT 2 - Microcode detected error "
593 "%02x\n",
594 sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 break;
596 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100597 dev_warn(&device->cdev->dev,
598 "FORMAT 2 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 }
600 break;
601
602 case 0x30: /* Format 3 - 3990 Control Checks */
603 switch (msg_no) {
604 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100605 dev_warn(&device->cdev->dev,
606 "FORMAT 3 - Allegiance terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 break;
608 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100609 dev_warn(&device->cdev->dev,
610 "FORMAT 3 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 }
612 break;
613
614 case 0x40: /* Format 4 - Data Checks */
615 switch (msg_no) {
616 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100617 dev_warn(&device->cdev->dev,
618 "FORMAT 4 - Home address area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 break;
620 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100621 dev_warn(&device->cdev->dev,
622 "FORMAT 4 - Count area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 break;
624 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100625 dev_warn(&device->cdev->dev,
626 "FORMAT 4 - Key area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 break;
628 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100629 dev_warn(&device->cdev->dev,
630 "FORMAT 4 - Data area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 break;
632 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100633 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 "FORMAT 4 - No sync byte in home address "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100635 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 break;
637 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100638 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 "FORMAT 4 - No sync byte in count address "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100640 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 break;
642 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100643 dev_warn(&device->cdev->dev,
644 "FORMAT 4 - No sync byte in key area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 break;
646 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100647 dev_warn(&device->cdev->dev,
648 "FORMAT 4 - No sync byte in data area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 break;
650 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100651 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 "FORMAT 4 - Home address area error; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100653 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 break;
655 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100656 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 "FORMAT 4 - Count area error; offset "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100658 "active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 break;
660 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100661 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 "FORMAT 4 - Key area error; offset "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100663 "active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 break;
665 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100666 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 "FORMAT 4 - Data area error; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100668 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 break;
670 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100671 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 "FORMAT 4 - No sync byte in home "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100673 "address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 break;
675 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100676 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 "FORMAT 4 - No syn byte in count "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100678 "address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 break;
680 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100681 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 "FORMAT 4 - No sync byte in key area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100683 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 break;
685 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100686 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 "FORMAT 4 - No syn byte in data area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100688 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 break;
690 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100691 dev_warn(&device->cdev->dev,
692 "FORMAT 4 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 }
694 break;
695
696 case 0x50: /* Format 5 - Data Check with displacement information */
697 switch (msg_no) {
698 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100699 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 "FORMAT 5 - Data Check in the "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100701 "home address area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 break;
703 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100704 dev_warn(&device->cdev->dev,
705 "FORMAT 5 - Data Check in the count "
706 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 break;
708 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100709 dev_warn(&device->cdev->dev,
710 "FORMAT 5 - Data Check in the key area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 break;
712 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100713 dev_warn(&device->cdev->dev,
714 "FORMAT 5 - Data Check in the data "
715 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 break;
717 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100718 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 "FORMAT 5 - Data Check in the "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100720 "home address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 break;
722 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100723 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 "FORMAT 5 - Data Check in the count area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100725 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 break;
727 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100728 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 "FORMAT 5 - Data Check in the key area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100730 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 break;
732 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100733 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 "FORMAT 5 - Data Check in the data area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100735 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 break;
737 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100738 dev_warn(&device->cdev->dev,
739 "FORMAT 5 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 }
741 break;
742
743 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
744 switch (msg_no) {
745 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100746 dev_warn(&device->cdev->dev,
747 "FORMAT 6 - Overrun on channel A\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 break;
749 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100750 dev_warn(&device->cdev->dev,
751 "FORMAT 6 - Overrun on channel B\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 break;
753 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100754 dev_warn(&device->cdev->dev,
755 "FORMAT 6 - Overrun on channel C\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 break;
757 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100758 dev_warn(&device->cdev->dev,
759 "FORMAT 6 - Overrun on channel D\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 break;
761 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100762 dev_warn(&device->cdev->dev,
763 "FORMAT 6 - Overrun on channel E\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 break;
765 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100766 dev_warn(&device->cdev->dev,
767 "FORMAT 6 - Overrun on channel F\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 break;
769 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100770 dev_warn(&device->cdev->dev,
771 "FORMAT 6 - Overrun on channel G\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 break;
773 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100774 dev_warn(&device->cdev->dev,
775 "FORMAT 6 - Overrun on channel H\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 break;
777 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100778 dev_warn(&device->cdev->dev,
779 "FORMAT 6 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 }
781 break;
782
783 case 0x70: /* Format 7 - Device Connection Control Checks */
784 switch (msg_no) {
785 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100786 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 "FORMAT 7 - RCC initiated by a connection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100788 "check alert\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 break;
790 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100791 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 "FORMAT 7 - RCC 1 sequence not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100793 "successful\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 break;
795 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100796 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100798 "successful\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 break;
800 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100801 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 "FORMAT 7 - Invalid tag-in during "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100803 "selection sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 break;
805 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100806 dev_warn(&device->cdev->dev,
807 "FORMAT 7 - extra RCC required\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 break;
809 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100810 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 "FORMAT 7 - Invalid DCC selection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100812 "response or timeout\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 break;
814 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100815 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 "FORMAT 7 - Missing end operation; device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100817 "transfer complete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 break;
819 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100820 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 "FORMAT 7 - Missing end operation; device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100822 "transfer incomplete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 break;
824 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100825 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 "FORMAT 7 - Invalid tag-in for an "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100827 "immediate command sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 break;
829 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100830 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 "FORMAT 7 - Invalid tag-in for an "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100832 "extended command sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 break;
834 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100835 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 "FORMAT 7 - 3990 microcode time out when "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100837 "stopping selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 break;
839 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100840 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 "FORMAT 7 - No response to selection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100842 "after a poll interruption\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 break;
844 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100845 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 "FORMAT 7 - Permanent path error (DASD "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100847 "controller not available)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 break;
849 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100850 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 "FORMAT 7 - DASD controller not available"
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100852 " on disconnected command chain\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 break;
854 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100855 dev_warn(&device->cdev->dev,
856 "FORMAT 7 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 }
858 break;
859
860 case 0x80: /* Format 8 - Additional Device Equipment Checks */
861 switch (msg_no) {
862 case 0x00: /* No Message */
863 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100864 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 "FORMAT 8 - Error correction code "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100866 "hardware fault\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 break;
868 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100869 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 "FORMAT 8 - Unexpected end operation "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100871 "response code\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 break;
873 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100874 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 "FORMAT 8 - End operation with transfer "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100876 "count not zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 break;
878 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100879 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 "FORMAT 8 - End operation with transfer "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100881 "count zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 break;
883 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100884 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 "FORMAT 8 - DPS checks after a system "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100886 "reset or selective reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 break;
888 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100889 dev_warn(&device->cdev->dev,
890 "FORMAT 8 - DPS cannot be filled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 break;
892 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100893 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 "FORMAT 8 - Short busy time-out during "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100895 "device selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 break;
897 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100898 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 "FORMAT 8 - DASD controller failed to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100900 "set or reset the long busy latch\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 break;
902 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100903 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 "FORMAT 8 - No interruption from device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100905 "during a command chain\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 break;
907 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100908 dev_warn(&device->cdev->dev,
909 "FORMAT 8 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 }
911 break;
912
913 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
914 switch (msg_no) {
915 case 0x00:
916 break; /* No Message */
917 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100918 dev_warn(&device->cdev->dev,
919 "FORMAT 9 - Device check-2 error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 break;
921 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100922 dev_warn(&device->cdev->dev,
923 "FORMAT 9 - Head address did not "
924 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 break;
926 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100927 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 "FORMAT 9 - Track physical address did "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100929 "not compare while oriented\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 break;
931 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100932 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 "FORMAT 9 - Cylinder address did not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100934 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 break;
936 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100937 dev_warn(&device->cdev->dev,
938 "FORMAT 9 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 }
940 break;
941
942 case 0xF0: /* Format F - Cache Storage Checks */
943 switch (msg_no) {
944 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100945 dev_warn(&device->cdev->dev,
946 "FORMAT F - Operation Terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 break;
948 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100949 dev_warn(&device->cdev->dev,
950 "FORMAT F - Subsystem Processing Error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 break;
952 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100953 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 "FORMAT F - Cache or nonvolatile storage "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100955 "equipment failure\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 break;
957 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100958 dev_warn(&device->cdev->dev,
959 "FORMAT F - Caching terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 break;
961 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100962 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963 "FORMAT F - Cache fast write access not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100964 "authorized\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 break;
966 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100967 dev_warn(&device->cdev->dev,
968 "FORMAT F - Track format incorrect\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 break;
970 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100971 dev_warn(&device->cdev->dev,
972 "FORMAT F - Caching reinitiated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 break;
974 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100975 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 "FORMAT F - Nonvolatile storage "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100977 "terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 break;
979 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100980 dev_warn(&device->cdev->dev,
981 "FORMAT F - Volume is suspended duplex\n");
Stefan Weinhuber20c64462006-03-24 03:15:25 -0800982 /* call extended error reporting (EER) */
983 dasd_eer_write(device, erp->refers,
984 DASD_EER_PPRCSUSPEND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 break;
986 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100987 dev_warn(&device->cdev->dev,
988 "FORMAT F - Subsystem status cannot be "
989 "determined\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 break;
991 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100992 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 "FORMAT F - Caching status reset to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100994 "default\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 break;
996 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100997 dev_warn(&device->cdev->dev,
998 "FORMAT F - DASD Fast Write inhibited\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 break;
1000 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001001 dev_warn(&device->cdev->dev,
1002 "FORMAT D - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 }
1004 break;
1005
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001006 default: /* unknown message format - should not happen
1007 internal error 03 - unknown message format */
1008 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
1009 dev_err(&device->cdev->dev,
1010 "An error occurred in the DASD device driver, "
1011 "reason=%s\n", errorstring);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 break;
1013 } /* end switch message format */
1014
1015} /* end dasd_3990_handle_env_data */
1016
1017/*
1018 * DASD_3990_ERP_COM_REJ
1019 *
1020 * DESCRIPTION
1021 * Handles 24 byte 'Command Reject' error.
1022 *
1023 * PARAMETER
1024 * erp current erp_head
1025 * sense current sense data
Horst Hummel138c0142006-06-29 14:58:12 +02001026 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001028 * erp 'new' erp_head - pointer to new ERP
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 */
1030static struct dasd_ccw_req *
1031dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1032{
1033
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001034 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035
1036 erp->function = dasd_3990_erp_com_rej;
1037
1038 /* env data present (ACTION 10 - retry should work) */
1039 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1040
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001041 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 "Command Reject - environmental data present");
1043
1044 dasd_3990_handle_env_data(erp, sense);
1045
1046 erp->retries = 5;
1047
Stefan Weinhuber33b62a32010-03-08 12:26:24 +01001048 } else if (sense[1] & SNS1_WRITE_INHIBITED) {
1049 dev_err(&device->cdev->dev, "An I/O request was rejected"
1050 " because writing is inhibited\n");
1051 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001053 /* fatal error - set status to FAILED
1054 internal error 09 - Command Reject */
1055 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1056 "device driver, reason=%s\n", "09");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057
1058 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1059 }
1060
1061 return erp;
1062
1063} /* end dasd_3990_erp_com_rej */
1064
1065/*
Horst Hummel138c0142006-06-29 14:58:12 +02001066 * DASD_3990_ERP_BUS_OUT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 *
1068 * DESCRIPTION
1069 * Handles 24 byte 'Bus Out Parity Check' error.
1070 *
1071 * PARAMETER
1072 * erp current erp_head
1073 * RETURN VALUES
1074 * erp new erp_head - pointer to new ERP
1075 */
1076static struct dasd_ccw_req *
1077dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1078{
1079
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001080 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081
1082 /* first time set initial retry counter and erp_function */
1083 /* and retry once without blocking queue */
1084 /* (this enables easier enqueing of the cqr) */
1085 if (erp->function != dasd_3990_erp_bus_out) {
1086 erp->retries = 256;
1087 erp->function = dasd_3990_erp_bus_out;
1088
1089 } else {
1090
1091 /* issue a message and wait for 'device ready' interrupt */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001092 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 "bus out parity error or BOPC requested by "
1094 "channel");
1095
1096 dasd_3990_erp_block_queue(erp, 60*HZ);
1097
1098 }
1099
1100 return erp;
1101
1102} /* end dasd_3990_erp_bus_out */
1103
1104/*
1105 * DASD_3990_ERP_EQUIP_CHECK
1106 *
1107 * DESCRIPTION
1108 * Handles 24 byte 'Equipment Check' error.
1109 *
1110 * PARAMETER
1111 * erp current erp_head
1112 * RETURN VALUES
1113 * erp new erp_head - pointer to new ERP
1114 */
1115static struct dasd_ccw_req *
1116dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1117{
1118
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001119 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120
1121 erp->function = dasd_3990_erp_equip_check;
1122
1123 if (sense[1] & SNS1_WRITE_INHIBITED) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001124 dev_info(&device->cdev->dev,
1125 "Write inhibited path encountered\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001127 /* vary path offline
1128 internal error 04 - Path should be varied off-line.*/
1129 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1130 "device driver, reason=%s\n", "04");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131
1132 erp = dasd_3990_erp_action_1(erp);
1133
1134 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1135
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001136 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 "Equipment Check - " "environmental data present");
1138
1139 dasd_3990_handle_env_data(erp, sense);
1140
1141 erp = dasd_3990_erp_action_4(erp, sense);
1142
1143 } else if (sense[1] & SNS1_PERM_ERR) {
1144
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001145 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 "Equipment Check - retry exhausted or "
1147 "undesirable");
1148
1149 erp = dasd_3990_erp_action_1(erp);
1150
1151 } else {
1152 /* all other equipment checks - Action 5 */
1153 /* rest is done when retries == 0 */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001154 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 "Equipment check or processing error");
1156
1157 erp = dasd_3990_erp_action_5(erp);
1158 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 return erp;
1160
1161} /* end dasd_3990_erp_equip_check */
1162
1163/*
1164 * DASD_3990_ERP_DATA_CHECK
1165 *
1166 * DESCRIPTION
1167 * Handles 24 byte 'Data Check' error.
1168 *
1169 * PARAMETER
1170 * erp current erp_head
1171 * RETURN VALUES
1172 * erp new erp_head - pointer to new ERP
1173 */
1174static struct dasd_ccw_req *
1175dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1176{
1177
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001178 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179
1180 erp->function = dasd_3990_erp_data_check;
1181
1182 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1183
1184 /* issue message that the data has been corrected */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001185 dev_emerg(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 "Data recovered during retry with PCI "
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001187 "fetch mode active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188
1189 /* not possible to handle this situation in Linux */
1190 panic("No way to inform application about the possibly "
1191 "incorrect data");
1192
1193 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1194
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001195 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 "Uncorrectable data check recovered secondary "
1197 "addr of duplex pair");
1198
1199 erp = dasd_3990_erp_action_4(erp, sense);
1200
1201 } else if (sense[1] & SNS1_PERM_ERR) {
1202
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001203 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 "Uncorrectable data check with internal "
1205 "retry exhausted");
1206
1207 erp = dasd_3990_erp_action_1(erp);
1208
1209 } else {
1210 /* all other data checks */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001211 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 "Uncorrectable data check with retry count "
1213 "exhausted...");
1214
1215 erp = dasd_3990_erp_action_5(erp);
1216 }
1217
1218 return erp;
1219
1220} /* end dasd_3990_erp_data_check */
1221
1222/*
1223 * DASD_3990_ERP_OVERRUN
1224 *
1225 * DESCRIPTION
1226 * Handles 24 byte 'Overrun' error.
1227 *
1228 * PARAMETER
1229 * erp current erp_head
1230 * RETURN VALUES
1231 * erp new erp_head - pointer to new ERP
1232 */
1233static struct dasd_ccw_req *
1234dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1235{
1236
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001237 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238
1239 erp->function = dasd_3990_erp_overrun;
1240
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001241 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 "Overrun - service overrun or overrun"
1243 " error requested by channel");
1244
1245 erp = dasd_3990_erp_action_5(erp);
1246
1247 return erp;
1248
1249} /* end dasd_3990_erp_overrun */
1250
1251/*
1252 * DASD_3990_ERP_INV_FORMAT
1253 *
1254 * DESCRIPTION
1255 * Handles 24 byte 'Invalid Track Format' error.
1256 *
1257 * PARAMETER
1258 * erp current erp_head
1259 * RETURN VALUES
1260 * erp new erp_head - pointer to new ERP
1261 */
1262static struct dasd_ccw_req *
1263dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1264{
1265
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001266 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267
1268 erp->function = dasd_3990_erp_inv_format;
1269
1270 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1271
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001272 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 "Track format error when destaging or "
1274 "staging data");
1275
1276 dasd_3990_handle_env_data(erp, sense);
1277
1278 erp = dasd_3990_erp_action_4(erp, sense);
1279
1280 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001281 /* internal error 06 - The track format is not valid*/
1282 dev_err(&device->cdev->dev,
1283 "An error occurred in the DASD device driver, "
1284 "reason=%s\n", "06");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285
1286 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1287 }
1288
1289 return erp;
1290
1291} /* end dasd_3990_erp_inv_format */
1292
1293/*
1294 * DASD_3990_ERP_EOC
1295 *
1296 * DESCRIPTION
1297 * Handles 24 byte 'End-of-Cylinder' error.
1298 *
1299 * PARAMETER
1300 * erp already added default erp
1301 * RETURN VALUES
1302 * erp pointer to original (failed) cqr.
1303 */
1304static struct dasd_ccw_req *
1305dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1306{
1307
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001308 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001310 dev_err(&device->cdev->dev,
1311 "The cylinder data for accessing the DASD is inconsistent\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
1313 /* implement action 7 - BUG */
1314 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1315
1316} /* end dasd_3990_erp_EOC */
1317
1318/*
1319 * DASD_3990_ERP_ENV_DATA
1320 *
1321 * DESCRIPTION
1322 * Handles 24 byte 'Environmental-Data Present' error.
1323 *
1324 * PARAMETER
1325 * erp current erp_head
1326 * RETURN VALUES
1327 * erp new erp_head - pointer to new ERP
1328 */
1329static struct dasd_ccw_req *
1330dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1331{
1332
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001333 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334
1335 erp->function = dasd_3990_erp_env_data;
1336
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001337 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338
1339 dasd_3990_handle_env_data(erp, sense);
1340
1341 /* don't retry on disabled interface */
1342 if (sense[7] != 0x0F) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 erp = dasd_3990_erp_action_4(erp, sense);
1344 } else {
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001345 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 }
1347
1348 return erp;
1349
1350} /* end dasd_3990_erp_env_data */
1351
1352/*
1353 * DASD_3990_ERP_NO_REC
1354 *
1355 * DESCRIPTION
1356 * Handles 24 byte 'No Record Found' error.
1357 *
1358 * PARAMETER
1359 * erp already added default ERP
Horst Hummel138c0142006-06-29 14:58:12 +02001360 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 * RETURN VALUES
1362 * erp new erp_head - pointer to new ERP
1363 */
1364static struct dasd_ccw_req *
1365dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1366{
1367
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001368 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001370 dev_err(&device->cdev->dev,
1371 "The specified record was not found\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372
1373 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1374
1375} /* end dasd_3990_erp_no_rec */
1376
1377/*
1378 * DASD_3990_ERP_FILE_PROT
1379 *
1380 * DESCRIPTION
1381 * Handles 24 byte 'File Protected' error.
1382 * Note: Seek related recovery is not implemented because
1383 * wee don't use the seek command yet.
1384 *
1385 * PARAMETER
1386 * erp current erp_head
1387 * RETURN VALUES
1388 * erp new erp_head - pointer to new ERP
1389 */
1390static struct dasd_ccw_req *
1391dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1392{
1393
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001394 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001396 dev_err(&device->cdev->dev, "Accessing the DASD failed because of "
1397 "a hardware error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398
1399 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1400
1401} /* end dasd_3990_erp_file_prot */
1402
1403/*
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001404 * DASD_3990_ERP_INSPECT_ALIAS
1405 *
1406 * DESCRIPTION
1407 * Checks if the original request was started on an alias device.
1408 * If yes, it modifies the original and the erp request so that
1409 * the erp request can be started on a base device.
1410 *
1411 * PARAMETER
1412 * erp pointer to the currently created default ERP
1413 *
1414 * RETURN VALUES
1415 * erp pointer to the modified ERP, or NULL
1416 */
1417
1418static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1419 struct dasd_ccw_req *erp)
1420{
1421 struct dasd_ccw_req *cqr = erp->refers;
Stefan Haberland501183f2010-05-17 10:00:10 +02001422 char *sense;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001423
1424 if (cqr->block &&
1425 (cqr->block->base != cqr->startdev)) {
Stefan Haberland501183f2010-05-17 10:00:10 +02001426
1427 sense = dasd_get_sense(&erp->refers->irb);
1428 /*
1429 * dynamic pav may have changed base alias mapping
1430 */
1431 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
1432 && (sense[0] == 0x10) && (sense[7] == 0x0F)
1433 && (sense[8] == 0x67)) {
1434 /*
1435 * remove device from alias handling to prevent new
1436 * requests from being scheduled on the
1437 * wrong alias device
1438 */
1439 dasd_alias_remove_device(cqr->startdev);
1440
1441 /* schedule worker to reload device */
1442 dasd_reload_device(cqr->startdev);
1443 }
1444
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001445 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001446 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001447 "ERP on alias device for request %p,"
1448 " recover on base device %s", cqr,
Kay Sievers2a0217d2008-10-10 21:33:09 +02001449 dev_name(&cqr->block->base->cdev->dev));
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001450 }
1451 dasd_eckd_reset_ccw_to_base_io(cqr);
1452 erp->startdev = cqr->block->base;
1453 erp->function = dasd_3990_erp_inspect_alias;
1454 return erp;
1455 } else
1456 return NULL;
1457}
1458
1459
1460/*
Horst Hummel138c0142006-06-29 14:58:12 +02001461 * DASD_3990_ERP_INSPECT_24
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 *
1463 * DESCRIPTION
1464 * Does a detailed inspection of the 24 byte sense data
Horst Hummel138c0142006-06-29 14:58:12 +02001465 * and sets up a related error recovery action.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 *
1467 * PARAMETER
1468 * sense sense data of the actual error
1469 * erp pointer to the currently created default ERP
1470 *
1471 * RETURN VALUES
1472 * erp pointer to the (addtitional) ERP
1473 */
1474static struct dasd_ccw_req *
1475dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1476{
1477
1478 struct dasd_ccw_req *erp_filled = NULL;
1479
1480 /* Check sense for .... */
1481 /* 'Command Reject' */
1482 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1483 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1484 }
1485 /* 'Intervention Required' */
1486 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1487 erp_filled = dasd_3990_erp_int_req(erp);
1488 }
1489 /* 'Bus Out Parity Check' */
1490 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1491 erp_filled = dasd_3990_erp_bus_out(erp);
1492 }
1493 /* 'Equipment Check' */
1494 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1495 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1496 }
1497 /* 'Data Check' */
1498 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1499 erp_filled = dasd_3990_erp_data_check(erp, sense);
1500 }
1501 /* 'Overrun' */
1502 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1503 erp_filled = dasd_3990_erp_overrun(erp, sense);
1504 }
1505 /* 'Invalid Track Format' */
1506 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1507 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1508 }
1509 /* 'End-of-Cylinder' */
1510 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1511 erp_filled = dasd_3990_erp_EOC(erp, sense);
1512 }
1513 /* 'Environmental Data' */
1514 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1515 erp_filled = dasd_3990_erp_env_data(erp, sense);
1516 }
1517 /* 'No Record Found' */
1518 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1519 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1520 }
1521 /* 'File Protected' */
1522 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1523 erp_filled = dasd_3990_erp_file_prot(erp);
1524 }
1525 /* other (unknown) error - do default ERP */
1526 if (erp_filled == NULL) {
1527
1528 erp_filled = erp;
1529 }
1530
1531 return erp_filled;
1532
1533} /* END dasd_3990_erp_inspect_24 */
1534
1535/*
Horst Hummel138c0142006-06-29 14:58:12 +02001536 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 * 32 byte sense ERP functions (only)
Horst Hummel138c0142006-06-29 14:58:12 +02001538 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 */
1540
1541/*
Horst Hummel138c0142006-06-29 14:58:12 +02001542 * DASD_3990_ERPACTION_10_32
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 *
1544 * DESCRIPTION
1545 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1546 * Just retry and if retry doesn't work, return with error.
1547 *
1548 * PARAMETER
1549 * erp current erp_head
Horst Hummel138c0142006-06-29 14:58:12 +02001550 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 * RETURN VALUES
1552 * erp modified erp_head
1553 */
1554static struct dasd_ccw_req *
1555dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1556{
1557
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001558 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559
1560 erp->retries = 256;
1561 erp->function = dasd_3990_erp_action_10_32;
1562
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001563 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564
1565 return erp;
1566
1567} /* end dasd_3990_erp_action_10_32 */
1568
1569/*
1570 * DASD_3990_ERP_ACTION_1B_32
1571 *
1572 * DESCRIPTION
1573 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
Horst Hummel138c0142006-06-29 14:58:12 +02001574 * A write operation could not be finished because of an unexpected
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 * condition.
Horst Hummel138c0142006-06-29 14:58:12 +02001576 * The already created 'default erp' is used to get the link to
1577 * the erp chain, but it can not be used for this recovery
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 * action because it contains no DE/LO data space.
1579 *
1580 * PARAMETER
1581 * default_erp already added default erp.
Horst Hummel138c0142006-06-29 14:58:12 +02001582 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583 *
1584 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001585 * erp new erp or
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 * default_erp in case of imprecise ending or error
1587 */
1588static struct dasd_ccw_req *
1589dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1590{
1591
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001592 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593 __u32 cpa = 0;
1594 struct dasd_ccw_req *cqr;
1595 struct dasd_ccw_req *erp;
1596 struct DE_eckd_data *DE_data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001597 struct PFX_eckd_data *PFX_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598 char *LO_data; /* LO_eckd_data_t */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001599 struct ccw1 *ccw, *oldccw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001601 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 "Write not finished because of unexpected condition");
1603
1604 default_erp->function = dasd_3990_erp_action_1B_32;
1605
1606 /* determine the original cqr */
1607 cqr = default_erp;
1608
1609 while (cqr->refers != NULL) {
1610 cqr = cqr->refers;
1611 }
1612
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001613 if (scsw_is_tm(&cqr->irb.scsw)) {
1614 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1615 "32 bit sense, action 1B is not defined"
1616 " in transport mode - just retry");
1617 return default_erp;
1618 }
1619
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620 /* for imprecise ending just do default erp */
1621 if (sense[1] & 0x01) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001622 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 "Imprecise ending is set - just retry");
1624
1625 return default_erp;
1626 }
1627
1628 /* determine the address of the CCW to be restarted */
1629 /* Imprecise ending is not set -> addr from IRB-SCSW */
Peter Oberparleiter23d805b2008-07-14 09:58:50 +02001630 cpa = default_erp->refers->irb.scsw.cmd.cpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631
1632 if (cpa == 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001633 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 "Unable to determine address of the CCW "
1635 "to be restarted");
1636
1637 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1638 }
1639
1640 /* Build new ERP request including DE/LO */
1641 erp = dasd_alloc_erp_request((char *) &cqr->magic,
1642 2 + 1,/* DE/LO + TIC */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001643 sizeof(struct DE_eckd_data) +
1644 sizeof(struct LO_eckd_data), device);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645
1646 if (IS_ERR(erp)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001647 /* internal error 01 - Unable to allocate ERP */
1648 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1649 "device driver, reason=%s\n", "01");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1651 }
1652
1653 /* use original DE */
1654 DE_data = erp->data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001655 oldccw = cqr->cpaddr;
1656 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1657 PFX_data = cqr->data;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001658 memcpy(DE_data, &PFX_data->define_extent,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001659 sizeof(struct DE_eckd_data));
1660 } else
1661 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662
1663 /* create LO */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001664 LO_data = erp->data + sizeof(struct DE_eckd_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665
1666 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001667 /* should not */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1669 }
1670
1671 if ((sense[7] & 0x3F) == 0x01) {
1672 /* operation code is WRITE DATA -> data area orientation */
1673 LO_data[0] = 0x81;
1674
1675 } else if ((sense[7] & 0x3F) == 0x03) {
1676 /* operation code is FORMAT WRITE -> index orientation */
1677 LO_data[0] = 0xC3;
1678
1679 } else {
1680 LO_data[0] = sense[7]; /* operation */
1681 }
1682
1683 LO_data[1] = sense[8]; /* auxiliary */
1684 LO_data[2] = sense[9];
1685 LO_data[3] = sense[3]; /* count */
1686 LO_data[4] = sense[29]; /* seek_addr.cyl */
1687 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1688 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1689
1690 memcpy(&(LO_data[8]), &(sense[11]), 8);
1691
1692 /* create DE ccw */
1693 ccw = erp->cpaddr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001694 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1696 ccw->flags = CCW_FLAG_CC;
1697 ccw->count = 16;
1698 ccw->cda = (__u32)(addr_t) DE_data;
1699
1700 /* create LO ccw */
1701 ccw++;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001702 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1704 ccw->flags = CCW_FLAG_CC;
1705 ccw->count = 16;
1706 ccw->cda = (__u32)(addr_t) LO_data;
1707
1708 /* TIC to the failed ccw */
1709 ccw++;
1710 ccw->cmd_code = CCW_CMD_TIC;
1711 ccw->cda = cpa;
1712
1713 /* fill erp related fields */
Stefan Weinhuber7ea8d322010-10-25 16:10:08 +02001714 erp->flags = default_erp->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715 erp->function = dasd_3990_erp_action_1B_32;
1716 erp->refers = default_erp->refers;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001717 erp->startdev = device;
1718 erp->memdev = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 erp->magic = default_erp->magic;
1720 erp->expires = 0;
1721 erp->retries = 256;
1722 erp->buildclk = get_clock();
1723 erp->status = DASD_CQR_FILLED;
1724
1725 /* remove the default erp */
1726 dasd_free_erp_request(default_erp, device);
1727
1728 return erp;
1729
1730} /* end dasd_3990_erp_action_1B_32 */
1731
1732/*
1733 * DASD_3990_UPDATE_1B
1734 *
1735 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02001736 * Handles the update to the 32 byte 'Action 1B' of Single Program
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 * Action Codes in case the first action was not successful.
1738 * The already created 'previous_erp' is the currently not successful
Horst Hummel138c0142006-06-29 14:58:12 +02001739 * ERP.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 *
1741 * PARAMETER
1742 * previous_erp already created previous erp.
Horst Hummel138c0142006-06-29 14:58:12 +02001743 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001745 * erp modified erp
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 */
1747static struct dasd_ccw_req *
1748dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1749{
1750
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001751 struct dasd_device *device = previous_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752 __u32 cpa = 0;
1753 struct dasd_ccw_req *cqr;
1754 struct dasd_ccw_req *erp;
1755 char *LO_data; /* struct LO_eckd_data */
1756 struct ccw1 *ccw;
1757
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001758 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759 "Write not finished because of unexpected condition"
1760 " - follow on");
1761
1762 /* determine the original cqr */
1763 cqr = previous_erp;
1764
1765 while (cqr->refers != NULL) {
1766 cqr = cqr->refers;
1767 }
1768
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001769 if (scsw_is_tm(&cqr->irb.scsw)) {
1770 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1771 "32 bit sense, action 1B, update,"
1772 " in transport mode - just retry");
1773 return previous_erp;
1774 }
1775
Linus Torvalds1da177e2005-04-16 15:20:36 -07001776 /* for imprecise ending just do default erp */
1777 if (sense[1] & 0x01) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001778 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779 "Imprecise ending is set - just retry");
1780
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001781 previous_erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782
1783 return previous_erp;
1784 }
1785
1786 /* determine the address of the CCW to be restarted */
1787 /* Imprecise ending is not set -> addr from IRB-SCSW */
Peter Oberparleiter23d805b2008-07-14 09:58:50 +02001788 cpa = previous_erp->irb.scsw.cmd.cpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001789
1790 if (cpa == 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001791 /* internal error 02 -
1792 Unable to determine address of the CCW to be restarted */
1793 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1794 "device driver, reason=%s\n", "02");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795
1796 previous_erp->status = DASD_CQR_FAILED;
1797
1798 return previous_erp;
1799 }
1800
1801 erp = previous_erp;
1802
1803 /* update the LO with the new returned sense data */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001804 LO_data = erp->data + sizeof(struct DE_eckd_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805
1806 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001807 /* should not happen */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001808 previous_erp->status = DASD_CQR_FAILED;
1809
1810 return previous_erp;
1811 }
1812
1813 if ((sense[7] & 0x3F) == 0x01) {
1814 /* operation code is WRITE DATA -> data area orientation */
1815 LO_data[0] = 0x81;
1816
1817 } else if ((sense[7] & 0x3F) == 0x03) {
1818 /* operation code is FORMAT WRITE -> index orientation */
1819 LO_data[0] = 0xC3;
1820
1821 } else {
1822 LO_data[0] = sense[7]; /* operation */
1823 }
1824
1825 LO_data[1] = sense[8]; /* auxiliary */
1826 LO_data[2] = sense[9];
1827 LO_data[3] = sense[3]; /* count */
1828 LO_data[4] = sense[29]; /* seek_addr.cyl */
1829 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1830 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1831
1832 memcpy(&(LO_data[8]), &(sense[11]), 8);
1833
1834 /* TIC to the failed ccw */
1835 ccw = erp->cpaddr; /* addr of DE ccw */
1836 ccw++; /* addr of LE ccw */
1837 ccw++; /* addr of TIC ccw */
1838 ccw->cda = cpa;
1839
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001840 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841
1842 return erp;
1843
1844} /* end dasd_3990_update_1B */
1845
1846/*
Horst Hummel138c0142006-06-29 14:58:12 +02001847 * DASD_3990_ERP_COMPOUND_RETRY
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 *
1849 * DESCRIPTION
1850 * Handles the compound ERP action retry code.
1851 * NOTE: At least one retry is done even if zero is specified
1852 * by the sense data. This makes enqueueing of the request
1853 * easier.
1854 *
1855 * PARAMETER
1856 * sense sense data of the actual error
1857 * erp pointer to the currently created ERP
1858 *
1859 * RETURN VALUES
1860 * erp modified ERP pointer
1861 *
1862 */
1863static void
1864dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1865{
1866
1867 switch (sense[25] & 0x03) {
1868 case 0x00: /* no not retry */
1869 erp->retries = 1;
1870 break;
1871
1872 case 0x01: /* retry 2 times */
1873 erp->retries = 2;
1874 break;
1875
1876 case 0x02: /* retry 10 times */
1877 erp->retries = 10;
1878 break;
1879
1880 case 0x03: /* retry 256 times */
1881 erp->retries = 256;
1882 break;
1883
1884 default:
1885 BUG();
1886 }
1887
1888 erp->function = dasd_3990_erp_compound_retry;
1889
1890} /* end dasd_3990_erp_compound_retry */
1891
1892/*
Horst Hummel138c0142006-06-29 14:58:12 +02001893 * DASD_3990_ERP_COMPOUND_PATH
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 *
1895 * DESCRIPTION
1896 * Handles the compound ERP action for retry on alternate
1897 * channel path.
1898 *
1899 * PARAMETER
1900 * sense sense data of the actual error
1901 * erp pointer to the currently created ERP
1902 *
1903 * RETURN VALUES
1904 * erp modified ERP pointer
1905 *
1906 */
1907static void
1908dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1909{
1910
1911 if (sense[25] & DASD_SENSE_BIT_3) {
1912 dasd_3990_erp_alternate_path(erp);
1913
1914 if (erp->status == DASD_CQR_FAILED) {
Horst Hummel138c0142006-06-29 14:58:12 +02001915 /* reset the lpm and the status to be able to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 * try further actions. */
1917
1918 erp->lpm = 0;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001919 erp->status = DASD_CQR_NEED_ERP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 }
1921 }
1922
1923 erp->function = dasd_3990_erp_compound_path;
1924
1925} /* end dasd_3990_erp_compound_path */
1926
1927/*
Horst Hummel138c0142006-06-29 14:58:12 +02001928 * DASD_3990_ERP_COMPOUND_CODE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 *
1930 * DESCRIPTION
1931 * Handles the compound ERP action for retry code.
1932 *
1933 * PARAMETER
1934 * sense sense data of the actual error
1935 * erp pointer to the currently created ERP
1936 *
1937 * RETURN VALUES
1938 * erp NEW ERP pointer
1939 *
1940 */
1941static struct dasd_ccw_req *
1942dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1943{
1944
1945 if (sense[25] & DASD_SENSE_BIT_2) {
1946
1947 switch (sense[28]) {
1948 case 0x17:
Horst Hummel138c0142006-06-29 14:58:12 +02001949 /* issue a Diagnostic Control command with an
Robert P. J. Day3a4fa0a2007-10-19 23:10:43 +02001950 * Inhibit Write subcommand and controller modifier */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001951 erp = dasd_3990_erp_DCTL(erp, 0x20);
1952 break;
Horst Hummel138c0142006-06-29 14:58:12 +02001953
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954 case 0x25:
1955 /* wait for 5 seconds and retry again */
1956 erp->retries = 1;
Horst Hummel138c0142006-06-29 14:58:12 +02001957
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 dasd_3990_erp_block_queue (erp, 5*HZ);
1959 break;
Horst Hummel138c0142006-06-29 14:58:12 +02001960
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 default:
1962 /* should not happen - continue */
1963 break;
1964 }
1965 }
1966
1967 erp->function = dasd_3990_erp_compound_code;
1968
1969 return erp;
1970
1971} /* end dasd_3990_erp_compound_code */
1972
1973/*
Horst Hummel138c0142006-06-29 14:58:12 +02001974 * DASD_3990_ERP_COMPOUND_CONFIG
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975 *
1976 * DESCRIPTION
1977 * Handles the compound ERP action for configruation
1978 * dependent error.
1979 * Note: duplex handling is not implemented (yet).
1980 *
1981 * PARAMETER
1982 * sense sense data of the actual error
1983 * erp pointer to the currently created ERP
1984 *
1985 * RETURN VALUES
1986 * erp modified ERP pointer
1987 *
1988 */
1989static void
1990dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
1991{
1992
1993 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
1994
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001995 /* set to suspended duplex state then restart
1996 internal error 05 - Set device to suspended duplex state
1997 should be done */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001998 struct dasd_device *device = erp->startdev;
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001999 dev_err(&device->cdev->dev,
2000 "An error occurred in the DASD device driver, "
2001 "reason=%s\n", "05");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002
2003 }
2004
2005 erp->function = dasd_3990_erp_compound_config;
2006
2007} /* end dasd_3990_erp_compound_config */
2008
2009/*
Horst Hummel138c0142006-06-29 14:58:12 +02002010 * DASD_3990_ERP_COMPOUND
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011 *
2012 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02002013 * Does the further compound program action if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002014 * compound retry was not successful.
2015 *
2016 * PARAMETER
2017 * sense sense data of the actual error
2018 * erp pointer to the current (failed) ERP
2019 *
2020 * RETURN VALUES
2021 * erp (additional) ERP pointer
2022 *
2023 */
2024static struct dasd_ccw_req *
2025dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2026{
2027
2028 if ((erp->function == dasd_3990_erp_compound_retry) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002029 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030
2031 dasd_3990_erp_compound_path(erp, sense);
2032 }
2033
2034 if ((erp->function == dasd_3990_erp_compound_path) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002035 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036
2037 erp = dasd_3990_erp_compound_code(erp, sense);
2038 }
2039
2040 if ((erp->function == dasd_3990_erp_compound_code) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002041 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042
2043 dasd_3990_erp_compound_config(erp, sense);
2044 }
2045
2046 /* if no compound action ERP specified, the request failed */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002047 if (erp->status == DASD_CQR_NEED_ERP)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048 erp->status = DASD_CQR_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049
2050 return erp;
2051
2052} /* end dasd_3990_erp_compound */
2053
2054/*
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002055 *DASD_3990_ERP_HANDLE_SIM
2056 *
2057 *DESCRIPTION
2058 * inspects the SIM SENSE data and starts an appropriate action
2059 *
2060 * PARAMETER
2061 * sense sense data of the actual error
2062 *
2063 * RETURN VALUES
2064 * none
2065 */
2066void
2067dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2068{
2069 /* print message according to log or message to operator mode */
2070 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002071 /* print SIM SRC from RefCode */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002072 dev_err(&device->cdev->dev, "SIM - SRC: "
2073 "%02x%02x%02x%02x\n", sense[22],
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002074 sense[23], sense[11], sense[12]);
2075 } else if (sense[24] & DASD_SIM_LOG) {
2076 /* print SIM SRC Refcode */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002077 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2078 "%02x%02x%02x%02x\n", sense[22],
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002079 sense[23], sense[11], sense[12]);
2080 }
2081}
2082
2083/*
Horst Hummel138c0142006-06-29 14:58:12 +02002084 * DASD_3990_ERP_INSPECT_32
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 *
2086 * DESCRIPTION
2087 * Does a detailed inspection of the 32 byte sense data
Horst Hummel138c0142006-06-29 14:58:12 +02002088 * and sets up a related error recovery action.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 *
2090 * PARAMETER
2091 * sense sense data of the actual error
2092 * erp pointer to the currently created default ERP
2093 *
2094 * RETURN VALUES
2095 * erp_filled pointer to the ERP
2096 *
2097 */
2098static struct dasd_ccw_req *
2099dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2100{
2101
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002102 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103
2104 erp->function = dasd_3990_erp_inspect_32;
2105
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002106 /* check for SIM sense data */
2107 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2108 dasd_3990_erp_handle_sim(device, sense);
2109
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110 if (sense[25] & DASD_SENSE_BIT_0) {
2111
2112 /* compound program action codes (byte25 bit 0 == '1') */
2113 dasd_3990_erp_compound_retry(erp, sense);
2114
2115 } else {
2116
2117 /* single program action codes (byte25 bit 0 == '0') */
2118 switch (sense[25]) {
2119
2120 case 0x00: /* success - use default ERP for retries */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002121 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002122 "ERP called for successful request"
2123 " - just retry");
2124 break;
2125
2126 case 0x01: /* fatal error */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002127 dev_err(&device->cdev->dev,
2128 "ERP failed for the DASD\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129
2130 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2131 break;
2132
2133 case 0x02: /* intervention required */
2134 case 0x03: /* intervention required during dual copy */
2135 erp = dasd_3990_erp_int_req(erp);
2136 break;
2137
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002138 case 0x0F: /* length mismatch during update write command
2139 internal error 08 - update write command error*/
2140 dev_err(&device->cdev->dev, "An error occurred in the "
2141 "DASD device driver, reason=%s\n", "08");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142
2143 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2144 break;
2145
2146 case 0x10: /* logging required for other channel program */
2147 erp = dasd_3990_erp_action_10_32(erp, sense);
2148 break;
2149
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002150 case 0x15: /* next track outside defined extend
2151 internal error 07 - The next track is not
2152 within the defined storage extent */
2153 dev_err(&device->cdev->dev,
2154 "An error occurred in the DASD device driver, "
2155 "reason=%s\n", "07");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156
2157 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2158 break;
2159
2160 case 0x1B: /* unexpected condition during write */
2161
2162 erp = dasd_3990_erp_action_1B_32(erp, sense);
2163 break;
2164
2165 case 0x1C: /* invalid data */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002166 dev_emerg(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167 "Data recovered during retry with PCI "
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002168 "fetch mode active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169
2170 /* not possible to handle this situation in Linux */
2171 panic
2172 ("Invalid data - No way to inform application "
2173 "about the possibly incorrect data");
2174 break;
2175
2176 case 0x1D: /* state-change pending */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002177 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 "A State change pending condition exists "
2179 "for the subsystem or device");
2180
2181 erp = dasd_3990_erp_action_4(erp, sense);
2182 break;
2183
2184 case 0x1E: /* busy */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002185 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 "Busy condition exists "
2187 "for the subsystem or device");
2188 erp = dasd_3990_erp_action_4(erp, sense);
2189 break;
2190
2191 default: /* all others errors - default erp */
2192 break;
2193 }
2194 }
2195
2196 return erp;
2197
2198} /* end dasd_3990_erp_inspect_32 */
2199
2200/*
Horst Hummel138c0142006-06-29 14:58:12 +02002201 *****************************************************************************
Stefan Weileef35c22010-08-06 21:11:15 +02002202 * main ERP control functions (24 and 32 byte sense)
Horst Hummel138c0142006-06-29 14:58:12 +02002203 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 */
2205
2206/*
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002207 * DASD_3990_ERP_CONTROL_CHECK
2208 *
2209 * DESCRIPTION
2210 * Does a generic inspection if a control check occured and sets up
2211 * the related error recovery procedure
2212 *
2213 * PARAMETER
2214 * erp pointer to the currently created default ERP
2215 *
2216 * RETURN VALUES
2217 * erp_filled pointer to the erp
2218 */
2219
2220static struct dasd_ccw_req *
2221dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2222{
2223 struct dasd_device *device = erp->startdev;
2224
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002225 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002226 | SCHN_STAT_CHN_CTRL_CHK)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002227 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002228 "channel or interface control check");
2229 erp = dasd_3990_erp_action_4(erp, NULL);
2230 }
2231 return erp;
2232}
2233
2234/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 * DASD_3990_ERP_INSPECT
2236 *
2237 * DESCRIPTION
2238 * Does a detailed inspection for sense data by calling either
2239 * the 24-byte or the 32-byte inspection routine.
2240 *
2241 * PARAMETER
2242 * erp pointer to the currently created default ERP
2243 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02002244 * erp_new contens was possibly modified
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 */
2246static struct dasd_ccw_req *
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002247dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248{
2249
2250 struct dasd_ccw_req *erp_new = NULL;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002251 char *sense;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002253 /* if this problem occured on an alias retry on base */
2254 erp_new = dasd_3990_erp_inspect_alias(erp);
2255 if (erp_new)
2256 return erp_new;
2257
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002258 /* sense data are located in the refers record of the
2259 * already set up new ERP !
2260 * check if concurrent sens is available
2261 */
2262 sense = dasd_get_sense(&erp->refers->irb);
2263 if (!sense)
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002264 erp_new = dasd_3990_erp_control_check(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 /* distinguish between 24 and 32 byte sense data */
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002266 else if (sense[27] & DASD_SENSE_BIT_0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267
2268 /* inspect the 24 byte sense data */
2269 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2270
2271 } else {
2272
2273 /* inspect the 32 byte sense data */
2274 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2275
2276 } /* end distinguish between 24 and 32 byte sense data */
2277
2278 return erp_new;
2279}
2280
2281/*
2282 * DASD_3990_ERP_ADD_ERP
Horst Hummel138c0142006-06-29 14:58:12 +02002283 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 * DESCRIPTION
2285 * This funtion adds an additional request block (ERP) to the head of
2286 * the given cqr (or erp).
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002287 * For a command mode cqr the erp is initialized as an default erp
2288 * (retry TIC).
2289 * For transport mode we make a copy of the original TCW (points to
2290 * the original TCCB, TIDALs, etc.) but give it a fresh
2291 * TSB so the original sense data will not be changed.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 *
2293 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002294 * cqr head of the current ERP-chain (or single cqr if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 * first error)
2296 * RETURN VALUES
2297 * erp pointer to new ERP-chain head
2298 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002299static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300{
2301
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002302 struct dasd_device *device = cqr->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 struct ccw1 *ccw;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002304 struct dasd_ccw_req *erp;
2305 int cplength, datasize;
2306 struct tcw *tcw;
2307 struct tsb *tsb;
2308
2309 if (cqr->cpmode == 1) {
2310 cplength = 0;
Stefan Weinhuber4a31ba52010-03-24 11:49:53 +01002311 /* TCW needs to be 64 byte aligned, so leave enough room */
2312 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002313 } else {
2314 cplength = 2;
2315 datasize = 0;
2316 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317
2318 /* allocate additional request block */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002319 erp = dasd_alloc_erp_request((char *) &cqr->magic,
2320 cplength, datasize, device);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 if (IS_ERR(erp)) {
2322 if (cqr->retries <= 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002323 DBF_DEV_EVENT(DBF_ERR, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324 "Unable to allocate ERP request");
2325 cqr->status = DASD_CQR_FAILED;
2326 cqr->stopclk = get_clock ();
2327 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002328 DBF_DEV_EVENT(DBF_ERR, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 "Unable to allocate ERP request "
2330 "(%i retries left)",
2331 cqr->retries);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002332 dasd_block_set_timer(device->block, (HZ << 3));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 }
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002334 return erp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335 }
2336
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002337 ccw = cqr->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002338 if (cqr->cpmode == 1) {
2339 /* make a shallow copy of the original tcw but set new tsb */
2340 erp->cpmode = 1;
Stefan Weinhuber4a31ba52010-03-24 11:49:53 +01002341 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2342 tcw = erp->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002343 tsb = (struct tsb *) &tcw[1];
2344 *tcw = *((struct tcw *)cqr->cpaddr);
2345 tcw->tsb = (long)tsb;
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002346 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
2347 /* PSF cannot be chained from NOOP/TIC */
2348 erp->cpaddr = cqr->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002349 } else {
2350 /* initialize request with default TIC to current ERP/CQR */
2351 ccw = erp->cpaddr;
2352 ccw->cmd_code = CCW_CMD_NOOP;
2353 ccw->flags = CCW_FLAG_CC;
2354 ccw++;
2355 ccw->cmd_code = CCW_CMD_TIC;
2356 ccw->cda = (long)(cqr->cpaddr);
2357 }
2358
Stefan Weinhuber7ea8d322010-10-25 16:10:08 +02002359 erp->flags = cqr->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 erp->function = dasd_3990_erp_add_erp;
2361 erp->refers = cqr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002362 erp->startdev = device;
2363 erp->memdev = device;
2364 erp->block = cqr->block;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365 erp->magic = cqr->magic;
2366 erp->expires = 0;
2367 erp->retries = 256;
2368 erp->buildclk = get_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 erp->status = DASD_CQR_FILLED;
2370
2371 return erp;
2372}
2373
2374/*
Horst Hummel138c0142006-06-29 14:58:12 +02002375 * DASD_3990_ERP_ADDITIONAL_ERP
2376 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 * DESCRIPTION
2378 * An additional ERP is needed to handle the current error.
2379 * Add ERP to the head of the ERP-chain containing the ERP processing
2380 * determined based on the sense data.
2381 *
2382 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002383 * cqr head of the current ERP-chain (or single cqr if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 * first error)
2385 *
2386 * RETURN VALUES
2387 * erp pointer to new ERP-chain head
2388 */
2389static struct dasd_ccw_req *
2390dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2391{
2392
2393 struct dasd_ccw_req *erp = NULL;
2394
2395 /* add erp and initialize with default TIC */
2396 erp = dasd_3990_erp_add_erp(cqr);
2397
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002398 if (IS_ERR(erp))
2399 return erp;
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 /* inspect sense, determine specific ERP if possible */
2402 if (erp != cqr) {
2403
2404 erp = dasd_3990_erp_inspect(erp);
2405 }
2406
2407 return erp;
2408
2409} /* end dasd_3990_erp_additional_erp */
2410
2411/*
2412 * DASD_3990_ERP_ERROR_MATCH
2413 *
2414 * DESCRIPTION
2415 * Check if the device status of the given cqr is the same.
2416 * This means that the failed CCW and the relevant sense data
2417 * must match.
2418 * I don't distinguish between 24 and 32 byte sense because in case of
2419 * 24 byte sense byte 25 and 27 is set as well.
2420 *
2421 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002422 * cqr1 first cqr, which will be compared with the
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 * cqr2 second cqr.
2424 *
2425 * RETURN VALUES
2426 * match 'boolean' for match found
2427 * returns 1 if match found, otherwise 0.
2428 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002429static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2430 struct dasd_ccw_req *cqr2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431{
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002432 char *sense1, *sense2;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433
Stefan Weinhuber5c12f242008-03-05 12:37:10 +01002434 if (cqr1->startdev != cqr2->startdev)
2435 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002437 sense1 = dasd_get_sense(&cqr1->irb);
2438 sense2 = dasd_get_sense(&cqr2->irb);
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002439
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002440 /* one request has sense data, the other not -> no match, return 0 */
2441 if (!sense1 != !sense2)
2442 return 0;
2443 /* no sense data in both cases -> check cstat for IFCC */
2444 if (!sense1 && !sense2) {
2445 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2446 SCHN_STAT_CHN_CTRL_CHK)) ==
2447 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2448 SCHN_STAT_CHN_CTRL_CHK)))
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002449 return 1; /* match with ifcc*/
2450 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 /* check sense data; byte 0-2,25,27 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002452 if (!(sense1 && sense2 &&
2453 (memcmp(sense1, sense2, 3) == 0) &&
2454 (sense1[27] == sense2[27]) &&
2455 (sense1[25] == sense2[25]))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456
2457 return 0; /* sense doesn't match */
2458 }
2459
2460 return 1; /* match */
2461
2462} /* end dasd_3990_erp_error_match */
2463
2464/*
2465 * DASD_3990_ERP_IN_ERP
2466 *
2467 * DESCRIPTION
2468 * check if the current error already happened before.
2469 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2470 *
2471 * PARAMETER
2472 * cqr failed cqr (either original cqr or already an erp)
2473 *
2474 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02002475 * erp erp-pointer to the already defined error
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 * recovery procedure OR
2477 * NULL if a 'new' error occurred.
2478 */
2479static struct dasd_ccw_req *
2480dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2481{
2482
2483 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2484 *erp_match = NULL; /* save erp chain head */
2485 int match = 0; /* 'boolean' for matching error found */
2486
2487 if (cqr->refers == NULL) { /* return if not in erp */
2488 return NULL;
2489 }
2490
2491 /* check the erp/cqr chain for current error */
2492 do {
2493 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2494 erp_match = cqr; /* save possible matching erp */
2495 cqr = cqr->refers; /* check next erp/cqr in queue */
2496
2497 } while ((cqr->refers != NULL) && (!match));
2498
2499 if (!match) {
2500 return NULL; /* no match was found */
2501 }
2502
2503 return erp_match; /* return address of matching erp */
2504
2505} /* END dasd_3990_erp_in_erp */
2506
2507/*
2508 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2509 *
2510 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02002511 * No retry is left for the current ERP. Check what has to be done
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 * with the ERP.
2513 * - do further defined ERP action or
Horst Hummel138c0142006-06-29 14:58:12 +02002514 * - wait for interrupt or
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515 * - exit with permanent error
2516 *
2517 * PARAMETER
2518 * erp ERP which is in progress with no retry left
2519 *
2520 * RETURN VALUES
2521 * erp modified/additional ERP
2522 */
2523static struct dasd_ccw_req *
2524dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2525{
2526
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002527 struct dasd_device *device = erp->startdev;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002528 char *sense = dasd_get_sense(&erp->irb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529
2530 /* check for 24 byte sense ERP */
2531 if ((erp->function == dasd_3990_erp_bus_out) ||
2532 (erp->function == dasd_3990_erp_action_1) ||
2533 (erp->function == dasd_3990_erp_action_4)) {
2534
2535 erp = dasd_3990_erp_action_1(erp);
2536
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002537 } else if (erp->function == dasd_3990_erp_action_1_sec) {
2538 erp = dasd_3990_erp_action_1_sec(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 } else if (erp->function == dasd_3990_erp_action_5) {
2540
2541 /* retries have not been successful */
2542 /* prepare erp for retry on different channel path */
2543 erp = dasd_3990_erp_action_1(erp);
2544
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002545 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546
Horst Hummel138c0142006-06-29 14:58:12 +02002547 /* issue a Diagnostic Control command with an
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 * Inhibit Write subcommand */
2549
2550 switch (sense[25]) {
2551 case 0x17:
2552 case 0x57:{ /* controller */
2553 erp = dasd_3990_erp_DCTL(erp, 0x20);
2554 break;
2555 }
2556 case 0x18:
2557 case 0x58:{ /* channel path */
2558 erp = dasd_3990_erp_DCTL(erp, 0x40);
2559 break;
2560 }
2561 case 0x19:
2562 case 0x59:{ /* storage director */
2563 erp = dasd_3990_erp_DCTL(erp, 0x80);
2564 break;
2565 }
2566 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002567 DBF_DEV_EVENT(DBF_WARNING, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 "invalid subcommand modifier 0x%x "
2569 "for Diagnostic Control Command",
2570 sense[25]);
2571 }
2572 }
2573
2574 /* check for 32 byte sense ERP */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002575 } else if (sense &&
2576 ((erp->function == dasd_3990_erp_compound_retry) ||
2577 (erp->function == dasd_3990_erp_compound_path) ||
2578 (erp->function == dasd_3990_erp_compound_code) ||
2579 (erp->function == dasd_3990_erp_compound_config))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580
2581 erp = dasd_3990_erp_compound(erp, sense);
2582
2583 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002584 /*
2585 * No retry left and no additional special handling
2586 * necessary
2587 */
2588 dev_err(&device->cdev->dev,
2589 "ERP %p has run out of retries and failed\n", erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590
2591 erp->status = DASD_CQR_FAILED;
2592 }
2593
2594 return erp;
2595
2596} /* end dasd_3990_erp_further_erp */
2597
2598/*
Horst Hummel138c0142006-06-29 14:58:12 +02002599 * DASD_3990_ERP_HANDLE_MATCH_ERP
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 *
2601 * DESCRIPTION
2602 * An error occurred again and an ERP has been detected which is already
Horst Hummel138c0142006-06-29 14:58:12 +02002603 * used to handle this error (e.g. retries).
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604 * All prior ERP's are asumed to be successful and therefore removed
2605 * from queue.
Horst Hummel138c0142006-06-29 14:58:12 +02002606 * If retry counter of matching erp is already 0, it is checked if further
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 * action is needed (besides retry) or if the ERP has failed.
2608 *
2609 * PARAMETER
2610 * erp_head first ERP in ERP-chain
2611 * erp ERP that handles the actual error.
2612 * (matching erp)
2613 *
2614 * RETURN VALUES
2615 * erp modified/additional ERP
2616 */
2617static struct dasd_ccw_req *
2618dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2619 struct dasd_ccw_req *erp)
2620{
2621
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002622 struct dasd_device *device = erp_head->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2624 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2625
2626 /* loop over successful ERPs and remove them from chanq */
2627 while (erp_done != erp) {
2628
2629 if (erp_done == NULL) /* end of chain reached */
2630 panic(PRINTK_HEADER "Programming error in ERP! The "
2631 "original request was lost\n");
2632
2633 /* remove the request from the device queue */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002634 list_del(&erp_done->blocklist);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635
2636 erp_free = erp_done;
2637 erp_done = erp_done->refers;
2638
2639 /* free the finished erp request */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002640 dasd_free_erp_request(erp_free, erp_free->memdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641
2642 } /* end while */
2643
2644 if (erp->retries > 0) {
2645
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002646 char *sense = dasd_get_sense(&erp->refers->irb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647
2648 /* check for special retries */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002649 if (sense && erp->function == dasd_3990_erp_action_4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650
2651 erp = dasd_3990_erp_action_4(erp, sense);
2652
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002653 } else if (sense &&
2654 erp->function == dasd_3990_erp_action_1B_32) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655
2656 erp = dasd_3990_update_1B(erp, sense);
2657
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002658 } else if (sense && erp->function == dasd_3990_erp_int_req) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659
2660 erp = dasd_3990_erp_int_req(erp);
2661
2662 } else {
2663 /* simple retry */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002664 DBF_DEV_EVENT(DBF_DEBUG, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665 "%i retries left for erp %p",
2666 erp->retries, erp);
2667
2668 /* handle the request again... */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002669 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 }
2671
2672 } else {
2673 /* no retry left - check for further necessary action */
2674 /* if no further actions, handle rest as permanent error */
2675 erp = dasd_3990_erp_further_erp(erp);
2676 }
2677
2678 return erp;
2679
2680} /* end dasd_3990_erp_handle_match_erp */
2681
2682/*
2683 * DASD_3990_ERP_ACTION
2684 *
2685 * DESCRIPTION
Joe Perches5d67d162008-01-26 14:11:20 +01002686 * control routine for 3990 erp actions.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002687 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2688 *
2689 * PARAMETER
2690 * cqr failed cqr (either original cqr or already an erp)
2691 *
2692 * RETURN VALUES
2693 * erp erp-pointer to the head of the ERP action chain.
2694 * This means:
2695 * - either a ptr to an additional ERP cqr or
Horst Hummel138c0142006-06-29 14:58:12 +02002696 * - the original given cqr (which's status might
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 * be modified)
2698 */
2699struct dasd_ccw_req *
2700dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2701{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 struct dasd_ccw_req *erp = NULL;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002703 struct dasd_device *device = cqr->startdev;
Horst Hummel9575bf22006-12-08 15:54:15 +01002704 struct dasd_ccw_req *temp_erp = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705
Horst Hummel9575bf22006-12-08 15:54:15 +01002706 if (device->features & DASD_FEATURE_ERPLOG) {
2707 /* print current erp_chain */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002708 dev_err(&device->cdev->dev,
2709 "ERP chain at BEGINNING of ERP-ACTION\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002710 for (temp_erp = cqr;
2711 temp_erp != NULL; temp_erp = temp_erp->refers) {
2712
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002713 dev_err(&device->cdev->dev,
2714 "ERP %p (%02x) refers to %p\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 temp_erp, temp_erp->status,
2716 temp_erp->refers);
2717 }
2718 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719
Coly Li73ac36e2009-01-07 18:09:16 -08002720 /* double-check if current erp/cqr was successful */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002721 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2722 (scsw_dstat(&cqr->irb.scsw) ==
Peter Oberparleiter23d805b2008-07-14 09:58:50 +02002723 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002725 DBF_DEV_EVENT(DBF_DEBUG, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 "ERP called for successful request %p"
2727 " - NO ERP necessary", cqr);
2728
2729 cqr->status = DASD_CQR_DONE;
2730
2731 return cqr;
2732 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733
2734 /* check if error happened before */
2735 erp = dasd_3990_erp_in_erp(cqr);
2736
2737 if (erp == NULL) {
2738 /* no matching erp found - set up erp */
2739 erp = dasd_3990_erp_additional_erp(cqr);
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002740 if (IS_ERR(erp))
2741 return erp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 } else {
2743 /* matching erp found - set all leading erp's to DONE */
2744 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2745 }
2746
Horst Hummel9575bf22006-12-08 15:54:15 +01002747 if (device->features & DASD_FEATURE_ERPLOG) {
2748 /* print current erp_chain */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002749 dev_err(&device->cdev->dev,
2750 "ERP chain at END of ERP-ACTION\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 for (temp_erp = erp;
2752 temp_erp != NULL; temp_erp = temp_erp->refers) {
2753
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002754 dev_err(&device->cdev->dev,
2755 "ERP %p (%02x) refers to %p\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002756 temp_erp, temp_erp->status,
2757 temp_erp->refers);
2758 }
2759 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002760
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002761 /* enqueue ERP request if it's a new one */
2762 if (list_empty(&erp->blocklist)) {
2763 cqr->status = DASD_CQR_IN_ERP;
2764 /* add erp request before the cqr */
2765 list_add_tail(&erp->blocklist, &cqr->blocklist);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002766 }
2767
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002768
2769
Linus Torvalds1da177e2005-04-16 15:20:36 -07002770 return erp;
2771
2772} /* end dasd_3990_erp_action */