blob: 299001ad9a32d8c0ff23e54cb33543ef67f8902b [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Horst Hummel138c0142006-06-29 14:58:12 +02002/*
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>
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02006 * Copyright IBM Corp. 2000, 2001
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
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 if (erp->lpm == 0)
Stefan Haberlandc9346152016-08-08 15:53:54 +0200156 erp->lpm = dasd_path_get_opm(device) &
Stefan Weinhubera4d26c62011-01-05 12:48:03 +0100157 ~(erp->irb.esw.esw0.sublog.lpum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 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
Heiko Carstens169bbda2021-10-20 13:51:18 +0200204 dctl_cqr = dasd_alloc_erp_request(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
Heiko Carstens1aae0562013-01-30 09:49:40 +0100233 dctl_cqr->buildclk = get_tod_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
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);
Stefan Weinhubera4d26c62011-01-05 12:48:03 +0100273 if (erp->status == DASD_CQR_FAILED &&
274 !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100275 erp->status = DASD_CQR_FILLED;
276 erp->retries = 10;
Stefan Haberlandc9346152016-08-08 15:53:54 +0200277 erp->lpm = dasd_path_get_opm(erp->startdev);
Stefan Weinhubereb6e1992009-12-07 12:51:51 +0100278 erp->function = dasd_3990_erp_action_1_sec;
279 }
280 return erp;
281} /* end dasd_3990_erp_action_1(b) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
283/*
Horst Hummel138c0142006-06-29 14:58:12 +0200284 * DASD_3990_ERP_ACTION_4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 *
286 * DESCRIPTION
287 * Setup ERP to do the ERP action 4 (see Reference manual).
288 * Set the current request to PENDING to block the CQR queue for that device
289 * until the state change interrupt appears.
290 * Use a timer (20 seconds) to retry the cqr if the interrupt is still
291 * missing.
292 *
293 * PARAMETER
294 * sense sense data of the actual error
295 * erp pointer to the current ERP
296 *
297 * RETURN VALUES
298 * erp pointer to the ERP
299 *
300 */
301static struct dasd_ccw_req *
302dasd_3990_erp_action_4(struct dasd_ccw_req * erp, char *sense)
303{
304
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100305 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 /* first time set initial retry counter and erp_function */
308 /* and retry once without waiting for state change pending */
309 /* interrupt (this enables easier enqueing of the cqr) */
310 if (erp->function != dasd_3990_erp_action_4) {
311
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100312 DBF_DEV_EVENT(DBF_INFO, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 "dasd_3990_erp_action_4: first time retry");
314
315 erp->retries = 256;
316 erp->function = dasd_3990_erp_action_4;
317
318 } else {
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100319 if (sense && (sense[25] == 0x1D)) { /* state change pending */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100321 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 "waiting for state change pending "
323 "interrupt, %d retries left",
324 erp->retries);
Horst Hummel138c0142006-06-29 14:58:12 +0200325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 dasd_3990_erp_block_queue(erp, 30*HZ);
327
Stefan Haberland6c5f57c2008-02-05 16:50:46 +0100328 } else if (sense && (sense[25] == 0x1E)) { /* busy */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100329 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 "busy - redriving request later, "
331 "%d retries left",
332 erp->retries);
333 dasd_3990_erp_block_queue(erp, HZ);
334 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 /* no state change pending - retry */
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100336 DBF_DEV_EVENT(DBF_INFO, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 "redriving request immediately, "
Horst Hummel138c0142006-06-29 14:58:12 +0200338 "%d retries left",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 erp->retries);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100340 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 }
342 }
343
344 return erp;
345
346} /* end dasd_3990_erp_action_4 */
347
348/*
Horst Hummel138c0142006-06-29 14:58:12 +0200349 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 * 24 byte sense ERP functions (only)
Horst Hummel138c0142006-06-29 14:58:12 +0200351 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 */
353
354/*
Horst Hummel138c0142006-06-29 14:58:12 +0200355 * DASD_3990_ERP_ACTION_5
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 *
357 * DESCRIPTION
358 * Setup ERP to do the ERP action 5 (see Reference manual).
359 * NOTE: Further handling is done in xxx_further_erp after the retries.
360 *
361 * PARAMETER
362 * erp pointer to the current ERP
363 *
364 * RETURN VALUES
365 * erp pointer to the ERP
366 *
367 */
368static struct dasd_ccw_req *
369dasd_3990_erp_action_5(struct dasd_ccw_req * erp)
370{
371
372 /* first of all retry */
373 erp->retries = 10;
374 erp->function = dasd_3990_erp_action_5;
375
376 return erp;
377
378} /* end dasd_3990_erp_action_5 */
379
380/*
381 * DASD_3990_HANDLE_ENV_DATA
382 *
383 * DESCRIPTION
384 * Handles 24 byte 'Environmental data present'.
385 * Does a analysis of the sense data (message Format)
386 * and prints the error messages.
387 *
388 * PARAMETER
389 * sense current sense data
Horst Hummel138c0142006-06-29 14:58:12 +0200390 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 * RETURN VALUES
392 * void
393 */
394static void
395dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
396{
397
Stefan Weinhuber8e09f212008-01-26 14:11:23 +0100398 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 char msg_format = (sense[7] & 0xF0);
400 char msg_no = (sense[7] & 0x0F);
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100401 char errorstring[ERRORLENGTH];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403 switch (msg_format) {
404 case 0x00: /* Format 0 - Program or System Checks */
405
406 if (sense[1] & 0x10) { /* check message to operator bit */
407
408 switch (msg_no) {
409 case 0x00: /* No Message */
410 break;
411 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100412 dev_warn(&device->cdev->dev,
413 "FORMAT 0 - Invalid Command\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 break;
415 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100416 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 "FORMAT 0 - Invalid Command "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100418 "Sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 break;
420 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100421 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 "FORMAT 0 - CCW Count less than "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100423 "required\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 break;
425 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100426 dev_warn(&device->cdev->dev,
427 "FORMAT 0 - Invalid Parameter\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 break;
429 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100430 dev_warn(&device->cdev->dev,
431 "FORMAT 0 - Diagnostic of Special"
432 " Command Violates File Mask\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 break;
434 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100435 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 "FORMAT 0 - Channel Returned with "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100437 "Incorrect retry CCW\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 break;
439 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100440 dev_warn(&device->cdev->dev,
441 "FORMAT 0 - Reset Notification\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 break;
443 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100444 dev_warn(&device->cdev->dev,
445 "FORMAT 0 - Storage Path Restart\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 break;
447 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100448 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 "FORMAT 0 - Channel requested "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100450 "... %02x\n", sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 break;
452 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100453 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 "FORMAT 0 - Invalid Defective/"
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100455 "Alternate Track Pointer\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 break;
457 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100458 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 "FORMAT 0 - DPS Installation "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100460 "Check\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 break;
462 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100463 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 "FORMAT 0 - Command Invalid on "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100465 "Secondary Address\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 break;
467 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100468 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 "FORMAT 0 - Status Not As "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100470 "Required: reason %02x\n",
471 sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 break;
473 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100474 dev_warn(&device->cdev->dev,
475 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 }
477 } else {
478 switch (msg_no) {
479 case 0x00: /* No Message */
480 break;
481 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100482 dev_warn(&device->cdev->dev,
483 "FORMAT 0 - Device Error "
484 "Source\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 break;
486 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100487 dev_warn(&device->cdev->dev,
488 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 break;
490 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100491 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 "FORMAT 0 - Device Fenced - "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100493 "device = %02x\n", sense[4]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 break;
495 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100496 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 "FORMAT 0 - Data Pinned for "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100498 "Device\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 break;
500 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100501 dev_warn(&device->cdev->dev,
502 "FORMAT 0 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 }
504 }
505 break;
506
507 case 0x10: /* Format 1 - Device Equipment Checks */
508 switch (msg_no) {
509 case 0x00: /* No Message */
510 break;
511 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100512 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 "FORMAT 1 - Device Status 1 not as "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100514 "expected\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 break;
516 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100517 dev_warn(&device->cdev->dev,
518 "FORMAT 1 - Index missing\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 break;
520 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100521 dev_warn(&device->cdev->dev,
522 "FORMAT 1 - Interruption cannot be "
523 "reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 break;
525 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100526 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 "FORMAT 1 - Device did not respond to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100528 "selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 break;
530 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100531 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 "FORMAT 1 - Device check-2 error or Set "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100533 "Sector is not complete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 break;
535 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100536 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 "FORMAT 1 - Head address does not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100538 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 break;
540 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100541 dev_warn(&device->cdev->dev,
542 "FORMAT 1 - Device status 1 not valid\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 break;
544 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100545 dev_warn(&device->cdev->dev,
546 "FORMAT 1 - Device not ready\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 break;
548 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100549 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 "FORMAT 1 - Track physical address did "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100551 "not compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 break;
553 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100554 dev_warn(&device->cdev->dev,
555 "FORMAT 1 - Missing device address bit\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 break;
557 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100558 dev_warn(&device->cdev->dev,
559 "FORMAT 1 - Drive motor switch is off\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 break;
561 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100562 dev_warn(&device->cdev->dev,
563 "FORMAT 1 - Seek incomplete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 break;
565 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100566 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 "FORMAT 1 - Cylinder address did not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100568 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 break;
570 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100571 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 "FORMAT 1 - Offset active cannot be "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100573 "reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 break;
575 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100576 dev_warn(&device->cdev->dev,
577 "FORMAT 1 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 }
579 break;
580
581 case 0x20: /* Format 2 - 3990 Equipment Checks */
582 switch (msg_no) {
583 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100584 dev_warn(&device->cdev->dev,
585 "FORMAT 2 - 3990 check-2 error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 break;
587 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100588 dev_warn(&device->cdev->dev,
589 "FORMAT 2 - Support facility errors\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 break;
591 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100592 dev_warn(&device->cdev->dev,
593 "FORMAT 2 - Microcode detected error "
594 "%02x\n",
595 sense[8]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 break;
597 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100598 dev_warn(&device->cdev->dev,
599 "FORMAT 2 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 }
601 break;
602
603 case 0x30: /* Format 3 - 3990 Control Checks */
604 switch (msg_no) {
605 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100606 dev_warn(&device->cdev->dev,
607 "FORMAT 3 - Allegiance terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 break;
609 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100610 dev_warn(&device->cdev->dev,
611 "FORMAT 3 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 }
613 break;
614
615 case 0x40: /* Format 4 - Data Checks */
616 switch (msg_no) {
617 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100618 dev_warn(&device->cdev->dev,
619 "FORMAT 4 - Home address area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 break;
621 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100622 dev_warn(&device->cdev->dev,
623 "FORMAT 4 - Count area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 break;
625 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100626 dev_warn(&device->cdev->dev,
627 "FORMAT 4 - Key area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 break;
629 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100630 dev_warn(&device->cdev->dev,
631 "FORMAT 4 - Data area error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 break;
633 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100634 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 "FORMAT 4 - No sync byte in home address "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100636 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 break;
638 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100639 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 "FORMAT 4 - No sync byte in count address "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100641 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 break;
643 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100644 dev_warn(&device->cdev->dev,
645 "FORMAT 4 - No sync byte in key area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 break;
647 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100648 dev_warn(&device->cdev->dev,
649 "FORMAT 4 - No sync byte in data area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 break;
651 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100652 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 "FORMAT 4 - Home address area error; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100654 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 break;
656 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100657 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 "FORMAT 4 - Count area error; offset "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100659 "active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 break;
661 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100662 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 "FORMAT 4 - Key area error; offset "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100664 "active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 break;
666 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100667 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 "FORMAT 4 - Data area error; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100669 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 break;
671 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100672 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 "FORMAT 4 - No sync byte in home "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100674 "address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 break;
676 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100677 dev_warn(&device->cdev->dev,
Stefan Haberland50cff5a2016-11-18 14:39:05 +0100678 "FORMAT 4 - No sync byte in count "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100679 "address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 break;
681 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100682 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 "FORMAT 4 - No sync byte in key area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100684 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 break;
686 case 0x0F:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100687 dev_warn(&device->cdev->dev,
Stefan Haberland50cff5a2016-11-18 14:39:05 +0100688 "FORMAT 4 - No sync byte in data area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100689 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 break;
691 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100692 dev_warn(&device->cdev->dev,
693 "FORMAT 4 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 }
695 break;
696
697 case 0x50: /* Format 5 - Data Check with displacement information */
698 switch (msg_no) {
699 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100700 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 "FORMAT 5 - Data Check in the "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100702 "home address area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 break;
704 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100705 dev_warn(&device->cdev->dev,
706 "FORMAT 5 - Data Check in the count "
707 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 break;
709 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100710 dev_warn(&device->cdev->dev,
711 "FORMAT 5 - Data Check in the key area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 break;
713 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100714 dev_warn(&device->cdev->dev,
715 "FORMAT 5 - Data Check in the data "
716 "area\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 break;
718 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100719 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 "FORMAT 5 - Data Check in the "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100721 "home address area; offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 break;
723 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100724 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 "FORMAT 5 - Data Check in the count area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100726 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 break;
728 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100729 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 "FORMAT 5 - Data Check in the key area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100731 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 break;
733 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100734 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 "FORMAT 5 - Data Check in the data area; "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100736 "offset active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 break;
738 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100739 dev_warn(&device->cdev->dev,
740 "FORMAT 5 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 }
742 break;
743
744 case 0x60: /* Format 6 - Usage Statistics/Overrun Errors */
745 switch (msg_no) {
746 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100747 dev_warn(&device->cdev->dev,
748 "FORMAT 6 - Overrun on channel A\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 break;
750 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100751 dev_warn(&device->cdev->dev,
752 "FORMAT 6 - Overrun on channel B\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 break;
754 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100755 dev_warn(&device->cdev->dev,
756 "FORMAT 6 - Overrun on channel C\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 break;
758 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100759 dev_warn(&device->cdev->dev,
760 "FORMAT 6 - Overrun on channel D\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 break;
762 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100763 dev_warn(&device->cdev->dev,
764 "FORMAT 6 - Overrun on channel E\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 break;
766 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100767 dev_warn(&device->cdev->dev,
768 "FORMAT 6 - Overrun on channel F\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 break;
770 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100771 dev_warn(&device->cdev->dev,
772 "FORMAT 6 - Overrun on channel G\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 break;
774 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100775 dev_warn(&device->cdev->dev,
776 "FORMAT 6 - Overrun on channel H\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 break;
778 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100779 dev_warn(&device->cdev->dev,
780 "FORMAT 6 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 }
782 break;
783
784 case 0x70: /* Format 7 - Device Connection Control Checks */
785 switch (msg_no) {
786 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100787 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 "FORMAT 7 - RCC initiated by a connection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100789 "check alert\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 break;
791 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100792 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 "FORMAT 7 - RCC 1 sequence not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100794 "successful\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 break;
796 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100797 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 "FORMAT 7 - RCC 1 and RCC 2 sequences not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100799 "successful\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 break;
801 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100802 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 "FORMAT 7 - Invalid tag-in during "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100804 "selection sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 break;
806 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100807 dev_warn(&device->cdev->dev,
808 "FORMAT 7 - extra RCC required\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 break;
810 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100811 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 "FORMAT 7 - Invalid DCC selection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100813 "response or timeout\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 break;
815 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100816 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 "FORMAT 7 - Missing end operation; device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100818 "transfer complete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 break;
820 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100821 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 "FORMAT 7 - Missing end operation; device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100823 "transfer incomplete\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 break;
825 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100826 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 "FORMAT 7 - Invalid tag-in for an "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100828 "immediate command sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 break;
830 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100831 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 "FORMAT 7 - Invalid tag-in for an "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100833 "extended command sequence\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 break;
835 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100836 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 "FORMAT 7 - 3990 microcode time out when "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100838 "stopping selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 break;
840 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100841 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 "FORMAT 7 - No response to selection "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100843 "after a poll interruption\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 break;
845 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100846 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 "FORMAT 7 - Permanent path error (DASD "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100848 "controller not available)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 break;
850 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100851 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 "FORMAT 7 - DASD controller not available"
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100853 " on disconnected command chain\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 break;
855 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100856 dev_warn(&device->cdev->dev,
857 "FORMAT 7 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 }
859 break;
860
861 case 0x80: /* Format 8 - Additional Device Equipment Checks */
862 switch (msg_no) {
863 case 0x00: /* No Message */
864 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100865 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 "FORMAT 8 - Error correction code "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100867 "hardware fault\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 break;
869 case 0x03:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100870 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 "FORMAT 8 - Unexpected end operation "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100872 "response code\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 break;
874 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100875 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 "FORMAT 8 - End operation with transfer "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100877 "count not zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 break;
879 case 0x05:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100880 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 "FORMAT 8 - End operation with transfer "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100882 "count zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 break;
884 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100885 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 "FORMAT 8 - DPS checks after a system "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100887 "reset or selective reset\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 break;
889 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100890 dev_warn(&device->cdev->dev,
891 "FORMAT 8 - DPS cannot be filled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 break;
893 case 0x08:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100894 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 "FORMAT 8 - Short busy time-out during "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100896 "device selection\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 break;
898 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100899 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 "FORMAT 8 - DASD controller failed to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100901 "set or reset the long busy latch\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 break;
903 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100904 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 "FORMAT 8 - No interruption from device "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100906 "during a command chain\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 break;
908 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100909 dev_warn(&device->cdev->dev,
910 "FORMAT 8 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 }
912 break;
913
914 case 0x90: /* Format 9 - Device Read, Write, and Seek Checks */
915 switch (msg_no) {
916 case 0x00:
917 break; /* No Message */
918 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100919 dev_warn(&device->cdev->dev,
920 "FORMAT 9 - Device check-2 error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 break;
922 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100923 dev_warn(&device->cdev->dev,
924 "FORMAT 9 - Head address did not "
925 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 break;
927 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100928 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 "FORMAT 9 - Track physical address did "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100930 "not compare while oriented\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 break;
932 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100933 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 "FORMAT 9 - Cylinder address did not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100935 "compare\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 break;
937 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100938 dev_warn(&device->cdev->dev,
939 "FORMAT 9 - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 }
941 break;
942
943 case 0xF0: /* Format F - Cache Storage Checks */
944 switch (msg_no) {
945 case 0x00:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100946 dev_warn(&device->cdev->dev,
947 "FORMAT F - Operation Terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 break;
949 case 0x01:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100950 dev_warn(&device->cdev->dev,
951 "FORMAT F - Subsystem Processing Error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 break;
953 case 0x02:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100954 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 "FORMAT F - Cache or nonvolatile storage "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100956 "equipment failure\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 break;
958 case 0x04:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100959 dev_warn(&device->cdev->dev,
960 "FORMAT F - Caching terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 break;
962 case 0x06:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100963 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 "FORMAT F - Cache fast write access not "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100965 "authorized\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 break;
967 case 0x07:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100968 dev_warn(&device->cdev->dev,
969 "FORMAT F - Track format incorrect\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 break;
971 case 0x09:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100972 dev_warn(&device->cdev->dev,
973 "FORMAT F - Caching reinitiated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 break;
975 case 0x0A:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100976 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 "FORMAT F - Nonvolatile storage "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100978 "terminated\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 break;
980 case 0x0B:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100981 dev_warn(&device->cdev->dev,
982 "FORMAT F - Volume is suspended duplex\n");
Stefan Weinhuber20c64462006-03-24 03:15:25 -0800983 /* call extended error reporting (EER) */
984 dasd_eer_write(device, erp->refers,
985 DASD_EER_PPRCSUSPEND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 break;
987 case 0x0C:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100988 dev_warn(&device->cdev->dev,
989 "FORMAT F - Subsystem status cannot be "
990 "determined\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 break;
992 case 0x0D:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100993 dev_warn(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 "FORMAT F - Caching status reset to "
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100995 "default\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 break;
997 case 0x0E:
Stefan Haberlandfc19f382009-03-26 15:23:49 +0100998 dev_warn(&device->cdev->dev,
999 "FORMAT F - DASD Fast Write inhibited\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 break;
1001 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001002 dev_warn(&device->cdev->dev,
Stefan Haberland50cff5a2016-11-18 14:39:05 +01001003 "FORMAT F - Reserved\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004 }
1005 break;
1006
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001007 default: /* unknown message format - should not happen
1008 internal error 03 - unknown message format */
1009 snprintf(errorstring, ERRORLENGTH, "03 %x02", msg_format);
1010 dev_err(&device->cdev->dev,
1011 "An error occurred in the DASD device driver, "
1012 "reason=%s\n", errorstring);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 break;
1014 } /* end switch message format */
1015
1016} /* end dasd_3990_handle_env_data */
1017
1018/*
1019 * DASD_3990_ERP_COM_REJ
1020 *
1021 * DESCRIPTION
1022 * Handles 24 byte 'Command Reject' error.
1023 *
1024 * PARAMETER
1025 * erp current erp_head
1026 * sense current sense data
Horst Hummel138c0142006-06-29 14:58:12 +02001027 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001029 * erp 'new' erp_head - pointer to new ERP
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030 */
1031static struct dasd_ccw_req *
1032dasd_3990_erp_com_rej(struct dasd_ccw_req * erp, char *sense)
1033{
1034
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001035 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036
1037 erp->function = dasd_3990_erp_com_rej;
1038
1039 /* env data present (ACTION 10 - retry should work) */
1040 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1041
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001042 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 "Command Reject - environmental data present");
1044
1045 dasd_3990_handle_env_data(erp, sense);
1046
1047 erp->retries = 5;
1048
Stefan Weinhuber33b62a32010-03-08 12:26:24 +01001049 } else if (sense[1] & SNS1_WRITE_INHIBITED) {
1050 dev_err(&device->cdev->dev, "An I/O request was rejected"
1051 " because writing is inhibited\n");
1052 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001054 /* fatal error - set status to FAILED
1055 internal error 09 - Command Reject */
Stefan Haberlandab24fbd2017-03-22 11:06:20 +01001056 if (!test_bit(DASD_CQR_SUPPRESS_CR, &erp->flags))
1057 dev_err(&device->cdev->dev,
1058 "An error occurred in the DASD device driver, reason=09\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059
1060 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1061 }
1062
1063 return erp;
1064
1065} /* end dasd_3990_erp_com_rej */
1066
1067/*
Horst Hummel138c0142006-06-29 14:58:12 +02001068 * DASD_3990_ERP_BUS_OUT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 *
1070 * DESCRIPTION
1071 * Handles 24 byte 'Bus Out Parity Check' error.
1072 *
1073 * PARAMETER
1074 * erp current erp_head
1075 * RETURN VALUES
1076 * erp new erp_head - pointer to new ERP
1077 */
1078static struct dasd_ccw_req *
1079dasd_3990_erp_bus_out(struct dasd_ccw_req * erp)
1080{
1081
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001082 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083
1084 /* first time set initial retry counter and erp_function */
1085 /* and retry once without blocking queue */
1086 /* (this enables easier enqueing of the cqr) */
1087 if (erp->function != dasd_3990_erp_bus_out) {
1088 erp->retries = 256;
1089 erp->function = dasd_3990_erp_bus_out;
1090
1091 } else {
1092
1093 /* issue a message and wait for 'device ready' interrupt */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001094 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 "bus out parity error or BOPC requested by "
1096 "channel");
1097
1098 dasd_3990_erp_block_queue(erp, 60*HZ);
1099
1100 }
1101
1102 return erp;
1103
1104} /* end dasd_3990_erp_bus_out */
1105
1106/*
1107 * DASD_3990_ERP_EQUIP_CHECK
1108 *
1109 * DESCRIPTION
1110 * Handles 24 byte 'Equipment Check' error.
1111 *
1112 * PARAMETER
1113 * erp current erp_head
1114 * RETURN VALUES
1115 * erp new erp_head - pointer to new ERP
1116 */
1117static struct dasd_ccw_req *
1118dasd_3990_erp_equip_check(struct dasd_ccw_req * erp, char *sense)
1119{
1120
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001121 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122
1123 erp->function = dasd_3990_erp_equip_check;
1124
1125 if (sense[1] & SNS1_WRITE_INHIBITED) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001126 dev_info(&device->cdev->dev,
1127 "Write inhibited path encountered\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001129 /* vary path offline
1130 internal error 04 - Path should be varied off-line.*/
1131 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1132 "device driver, reason=%s\n", "04");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133
1134 erp = dasd_3990_erp_action_1(erp);
1135
1136 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1137
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001138 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 "Equipment Check - " "environmental data present");
1140
1141 dasd_3990_handle_env_data(erp, sense);
1142
1143 erp = dasd_3990_erp_action_4(erp, sense);
1144
1145 } else if (sense[1] & SNS1_PERM_ERR) {
1146
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001147 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 "Equipment Check - retry exhausted or "
1149 "undesirable");
1150
1151 erp = dasd_3990_erp_action_1(erp);
1152
1153 } else {
1154 /* all other equipment checks - Action 5 */
1155 /* rest is done when retries == 0 */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001156 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 "Equipment check or processing error");
1158
1159 erp = dasd_3990_erp_action_5(erp);
1160 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 return erp;
1162
1163} /* end dasd_3990_erp_equip_check */
1164
1165/*
1166 * DASD_3990_ERP_DATA_CHECK
1167 *
1168 * DESCRIPTION
1169 * Handles 24 byte 'Data Check' error.
1170 *
1171 * PARAMETER
1172 * erp current erp_head
1173 * RETURN VALUES
1174 * erp new erp_head - pointer to new ERP
1175 */
1176static struct dasd_ccw_req *
1177dasd_3990_erp_data_check(struct dasd_ccw_req * erp, char *sense)
1178{
1179
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001180 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181
1182 erp->function = dasd_3990_erp_data_check;
1183
1184 if (sense[2] & SNS2_CORRECTABLE) { /* correctable data check */
1185
1186 /* issue message that the data has been corrected */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001187 dev_emerg(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 "Data recovered during retry with PCI "
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001189 "fetch mode active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190
1191 /* not possible to handle this situation in Linux */
1192 panic("No way to inform application about the possibly "
1193 "incorrect data");
1194
1195 } else if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1196
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001197 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 "Uncorrectable data check recovered secondary "
1199 "addr of duplex pair");
1200
1201 erp = dasd_3990_erp_action_4(erp, sense);
1202
1203 } else if (sense[1] & SNS1_PERM_ERR) {
1204
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001205 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 "Uncorrectable data check with internal "
1207 "retry exhausted");
1208
1209 erp = dasd_3990_erp_action_1(erp);
1210
1211 } else {
1212 /* all other data checks */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001213 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214 "Uncorrectable data check with retry count "
1215 "exhausted...");
1216
1217 erp = dasd_3990_erp_action_5(erp);
1218 }
1219
1220 return erp;
1221
1222} /* end dasd_3990_erp_data_check */
1223
1224/*
1225 * DASD_3990_ERP_OVERRUN
1226 *
1227 * DESCRIPTION
1228 * Handles 24 byte 'Overrun' error.
1229 *
1230 * PARAMETER
1231 * erp current erp_head
1232 * RETURN VALUES
1233 * erp new erp_head - pointer to new ERP
1234 */
1235static struct dasd_ccw_req *
1236dasd_3990_erp_overrun(struct dasd_ccw_req * erp, char *sense)
1237{
1238
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001239 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240
1241 erp->function = dasd_3990_erp_overrun;
1242
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001243 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244 "Overrun - service overrun or overrun"
1245 " error requested by channel");
1246
1247 erp = dasd_3990_erp_action_5(erp);
1248
1249 return erp;
1250
1251} /* end dasd_3990_erp_overrun */
1252
1253/*
1254 * DASD_3990_ERP_INV_FORMAT
1255 *
1256 * DESCRIPTION
1257 * Handles 24 byte 'Invalid Track Format' error.
1258 *
1259 * PARAMETER
1260 * erp current erp_head
1261 * RETURN VALUES
1262 * erp new erp_head - pointer to new ERP
1263 */
1264static struct dasd_ccw_req *
1265dasd_3990_erp_inv_format(struct dasd_ccw_req * erp, char *sense)
1266{
1267
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001268 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269
1270 erp->function = dasd_3990_erp_inv_format;
1271
1272 if (sense[2] & SNS2_ENV_DATA_PRESENT) {
1273
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001274 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 "Track format error when destaging or "
1276 "staging data");
1277
1278 dasd_3990_handle_env_data(erp, sense);
1279
1280 erp = dasd_3990_erp_action_4(erp, sense);
1281
1282 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001283 /* internal error 06 - The track format is not valid*/
1284 dev_err(&device->cdev->dev,
1285 "An error occurred in the DASD device driver, "
1286 "reason=%s\n", "06");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287
1288 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1289 }
1290
1291 return erp;
1292
1293} /* end dasd_3990_erp_inv_format */
1294
1295/*
1296 * DASD_3990_ERP_EOC
1297 *
1298 * DESCRIPTION
1299 * Handles 24 byte 'End-of-Cylinder' error.
1300 *
1301 * PARAMETER
1302 * erp already added default erp
1303 * RETURN VALUES
1304 * erp pointer to original (failed) cqr.
1305 */
1306static struct dasd_ccw_req *
1307dasd_3990_erp_EOC(struct dasd_ccw_req * default_erp, char *sense)
1308{
1309
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001310 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001312 dev_err(&device->cdev->dev,
1313 "The cylinder data for accessing the DASD is inconsistent\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314
1315 /* implement action 7 - BUG */
1316 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1317
1318} /* end dasd_3990_erp_EOC */
1319
1320/*
1321 * DASD_3990_ERP_ENV_DATA
1322 *
1323 * DESCRIPTION
1324 * Handles 24 byte 'Environmental-Data Present' error.
1325 *
1326 * PARAMETER
1327 * erp current erp_head
1328 * RETURN VALUES
1329 * erp new erp_head - pointer to new ERP
1330 */
1331static struct dasd_ccw_req *
1332dasd_3990_erp_env_data(struct dasd_ccw_req * erp, char *sense)
1333{
1334
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001335 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336
1337 erp->function = dasd_3990_erp_env_data;
1338
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001339 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Environmental data present");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340
1341 dasd_3990_handle_env_data(erp, sense);
1342
1343 /* don't retry on disabled interface */
1344 if (sense[7] != 0x0F) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 erp = dasd_3990_erp_action_4(erp, sense);
1346 } else {
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001347 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 }
1349
1350 return erp;
1351
1352} /* end dasd_3990_erp_env_data */
1353
1354/*
1355 * DASD_3990_ERP_NO_REC
1356 *
1357 * DESCRIPTION
1358 * Handles 24 byte 'No Record Found' error.
1359 *
1360 * PARAMETER
1361 * erp already added default ERP
Horst Hummel138c0142006-06-29 14:58:12 +02001362 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 * RETURN VALUES
1364 * erp new erp_head - pointer to new ERP
1365 */
1366static struct dasd_ccw_req *
1367dasd_3990_erp_no_rec(struct dasd_ccw_req * default_erp, char *sense)
1368{
1369
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001370 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371
Jan Höppner8fd57522015-08-19 13:41:20 +02001372 /*
1373 * In some cases the 'No Record Found' error might be expected and
1374 * log messages shouldn't be written then.
1375 * Check if the according suppress bit is set.
1376 */
1377 if (!test_bit(DASD_CQR_SUPPRESS_NRF, &default_erp->flags))
1378 dev_err(&device->cdev->dev,
1379 "The specified record was not found\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380
1381 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1382
1383} /* end dasd_3990_erp_no_rec */
1384
1385/*
1386 * DASD_3990_ERP_FILE_PROT
1387 *
1388 * DESCRIPTION
1389 * Handles 24 byte 'File Protected' error.
1390 * Note: Seek related recovery is not implemented because
1391 * wee don't use the seek command yet.
1392 *
1393 * PARAMETER
1394 * erp current erp_head
1395 * RETURN VALUES
1396 * erp new erp_head - pointer to new ERP
1397 */
1398static struct dasd_ccw_req *
1399dasd_3990_erp_file_prot(struct dasd_ccw_req * erp)
1400{
1401
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001402 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403
Jan Höppner8fd57522015-08-19 13:41:20 +02001404 /*
1405 * In some cases the 'File Protected' error might be expected and
1406 * log messages shouldn't be written then.
1407 * Check if the according suppress bit is set.
1408 */
1409 if (!test_bit(DASD_CQR_SUPPRESS_FP, &erp->flags))
1410 dev_err(&device->cdev->dev,
1411 "Accessing the DASD failed because of a hardware error\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412
1413 return dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
1414
1415} /* end dasd_3990_erp_file_prot */
1416
1417/*
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001418 * DASD_3990_ERP_INSPECT_ALIAS
1419 *
1420 * DESCRIPTION
1421 * Checks if the original request was started on an alias device.
1422 * If yes, it modifies the original and the erp request so that
1423 * the erp request can be started on a base device.
1424 *
1425 * PARAMETER
1426 * erp pointer to the currently created default ERP
1427 *
1428 * RETURN VALUES
1429 * erp pointer to the modified ERP, or NULL
1430 */
1431
1432static struct dasd_ccw_req *dasd_3990_erp_inspect_alias(
1433 struct dasd_ccw_req *erp)
1434{
1435 struct dasd_ccw_req *cqr = erp->refers;
Stefan Haberland501183f2010-05-17 10:00:10 +02001436 char *sense;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001437
1438 if (cqr->block &&
1439 (cqr->block->base != cqr->startdev)) {
Stefan Haberland501183f2010-05-17 10:00:10 +02001440
1441 sense = dasd_get_sense(&erp->refers->irb);
1442 /*
1443 * dynamic pav may have changed base alias mapping
1444 */
1445 if (!test_bit(DASD_FLAG_OFFLINE, &cqr->startdev->flags) && sense
1446 && (sense[0] == 0x10) && (sense[7] == 0x0F)
1447 && (sense[8] == 0x67)) {
1448 /*
1449 * remove device from alias handling to prevent new
1450 * requests from being scheduled on the
1451 * wrong alias device
1452 */
1453 dasd_alias_remove_device(cqr->startdev);
1454
1455 /* schedule worker to reload device */
1456 dasd_reload_device(cqr->startdev);
1457 }
1458
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001459 if (cqr->startdev->features & DASD_FEATURE_ERPLOG) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001460 DBF_DEV_EVENT(DBF_ERR, cqr->startdev,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001461 "ERP on alias device for request %p,"
1462 " recover on base device %s", cqr,
Kay Sievers2a0217d2008-10-10 21:33:09 +02001463 dev_name(&cqr->block->base->cdev->dev));
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001464 }
1465 dasd_eckd_reset_ccw_to_base_io(cqr);
1466 erp->startdev = cqr->block->base;
1467 erp->function = dasd_3990_erp_inspect_alias;
1468 return erp;
1469 } else
1470 return NULL;
1471}
1472
1473
1474/*
Horst Hummel138c0142006-06-29 14:58:12 +02001475 * DASD_3990_ERP_INSPECT_24
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 *
1477 * DESCRIPTION
1478 * Does a detailed inspection of the 24 byte sense data
Horst Hummel138c0142006-06-29 14:58:12 +02001479 * and sets up a related error recovery action.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 *
1481 * PARAMETER
1482 * sense sense data of the actual error
1483 * erp pointer to the currently created default ERP
1484 *
1485 * RETURN VALUES
1486 * erp pointer to the (addtitional) ERP
1487 */
1488static struct dasd_ccw_req *
1489dasd_3990_erp_inspect_24(struct dasd_ccw_req * erp, char *sense)
1490{
1491
1492 struct dasd_ccw_req *erp_filled = NULL;
1493
1494 /* Check sense for .... */
1495 /* 'Command Reject' */
1496 if ((erp_filled == NULL) && (sense[0] & SNS0_CMD_REJECT)) {
1497 erp_filled = dasd_3990_erp_com_rej(erp, sense);
1498 }
1499 /* 'Intervention Required' */
1500 if ((erp_filled == NULL) && (sense[0] & SNS0_INTERVENTION_REQ)) {
1501 erp_filled = dasd_3990_erp_int_req(erp);
1502 }
1503 /* 'Bus Out Parity Check' */
1504 if ((erp_filled == NULL) && (sense[0] & SNS0_BUS_OUT_CHECK)) {
1505 erp_filled = dasd_3990_erp_bus_out(erp);
1506 }
1507 /* 'Equipment Check' */
1508 if ((erp_filled == NULL) && (sense[0] & SNS0_EQUIPMENT_CHECK)) {
1509 erp_filled = dasd_3990_erp_equip_check(erp, sense);
1510 }
1511 /* 'Data Check' */
1512 if ((erp_filled == NULL) && (sense[0] & SNS0_DATA_CHECK)) {
1513 erp_filled = dasd_3990_erp_data_check(erp, sense);
1514 }
1515 /* 'Overrun' */
1516 if ((erp_filled == NULL) && (sense[0] & SNS0_OVERRUN)) {
1517 erp_filled = dasd_3990_erp_overrun(erp, sense);
1518 }
1519 /* 'Invalid Track Format' */
1520 if ((erp_filled == NULL) && (sense[1] & SNS1_INV_TRACK_FORMAT)) {
1521 erp_filled = dasd_3990_erp_inv_format(erp, sense);
1522 }
1523 /* 'End-of-Cylinder' */
1524 if ((erp_filled == NULL) && (sense[1] & SNS1_EOC)) {
1525 erp_filled = dasd_3990_erp_EOC(erp, sense);
1526 }
1527 /* 'Environmental Data' */
1528 if ((erp_filled == NULL) && (sense[2] & SNS2_ENV_DATA_PRESENT)) {
1529 erp_filled = dasd_3990_erp_env_data(erp, sense);
1530 }
1531 /* 'No Record Found' */
1532 if ((erp_filled == NULL) && (sense[1] & SNS1_NO_REC_FOUND)) {
1533 erp_filled = dasd_3990_erp_no_rec(erp, sense);
1534 }
1535 /* 'File Protected' */
1536 if ((erp_filled == NULL) && (sense[1] & SNS1_FILE_PROTECTED)) {
1537 erp_filled = dasd_3990_erp_file_prot(erp);
1538 }
1539 /* other (unknown) error - do default ERP */
1540 if (erp_filled == NULL) {
1541
1542 erp_filled = erp;
1543 }
1544
1545 return erp_filled;
1546
1547} /* END dasd_3990_erp_inspect_24 */
1548
1549/*
Horst Hummel138c0142006-06-29 14:58:12 +02001550 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 * 32 byte sense ERP functions (only)
Horst Hummel138c0142006-06-29 14:58:12 +02001552 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 */
1554
1555/*
Horst Hummel138c0142006-06-29 14:58:12 +02001556 * DASD_3990_ERPACTION_10_32
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 *
1558 * DESCRIPTION
1559 * Handles 32 byte 'Action 10' of Single Program Action Codes.
1560 * Just retry and if retry doesn't work, return with error.
1561 *
1562 * PARAMETER
1563 * erp current erp_head
Horst Hummel138c0142006-06-29 14:58:12 +02001564 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 * RETURN VALUES
1566 * erp modified erp_head
1567 */
1568static struct dasd_ccw_req *
1569dasd_3990_erp_action_10_32(struct dasd_ccw_req * erp, char *sense)
1570{
1571
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001572 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573
1574 erp->retries = 256;
1575 erp->function = dasd_3990_erp_action_10_32;
1576
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001577 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "Perform logging requested");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578
1579 return erp;
1580
1581} /* end dasd_3990_erp_action_10_32 */
1582
1583/*
1584 * DASD_3990_ERP_ACTION_1B_32
1585 *
1586 * DESCRIPTION
1587 * Handles 32 byte 'Action 1B' of Single Program Action Codes.
Horst Hummel138c0142006-06-29 14:58:12 +02001588 * A write operation could not be finished because of an unexpected
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 * condition.
Horst Hummel138c0142006-06-29 14:58:12 +02001590 * The already created 'default erp' is used to get the link to
1591 * the erp chain, but it can not be used for this recovery
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 * action because it contains no DE/LO data space.
1593 *
1594 * PARAMETER
1595 * default_erp already added default erp.
Horst Hummel138c0142006-06-29 14:58:12 +02001596 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597 *
1598 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001599 * erp new erp or
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600 * default_erp in case of imprecise ending or error
1601 */
1602static struct dasd_ccw_req *
1603dasd_3990_erp_action_1B_32(struct dasd_ccw_req * default_erp, char *sense)
1604{
1605
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001606 struct dasd_device *device = default_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607 __u32 cpa = 0;
1608 struct dasd_ccw_req *cqr;
1609 struct dasd_ccw_req *erp;
1610 struct DE_eckd_data *DE_data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001611 struct PFX_eckd_data *PFX_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001612 char *LO_data; /* LO_eckd_data_t */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001613 struct ccw1 *ccw, *oldccw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001614
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001615 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001616 "Write not finished because of unexpected condition");
1617
1618 default_erp->function = dasd_3990_erp_action_1B_32;
1619
1620 /* determine the original cqr */
1621 cqr = default_erp;
1622
1623 while (cqr->refers != NULL) {
1624 cqr = cqr->refers;
1625 }
1626
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001627 if (scsw_is_tm(&cqr->irb.scsw)) {
1628 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1629 "32 bit sense, action 1B is not defined"
1630 " in transport mode - just retry");
1631 return default_erp;
1632 }
1633
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 /* for imprecise ending just do default erp */
1635 if (sense[1] & 0x01) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001636 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637 "Imprecise ending is set - just retry");
1638
1639 return default_erp;
1640 }
1641
1642 /* determine the address of the CCW to be restarted */
1643 /* Imprecise ending is not set -> addr from IRB-SCSW */
Peter Oberparleiter23d805b62008-07-14 09:58:50 +02001644 cpa = default_erp->refers->irb.scsw.cmd.cpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645
1646 if (cpa == 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001647 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648 "Unable to determine address of the CCW "
1649 "to be restarted");
1650
1651 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1652 }
1653
1654 /* Build new ERP request including DE/LO */
Heiko Carstens169bbda2021-10-20 13:51:18 +02001655 erp = dasd_alloc_erp_request(cqr->magic,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656 2 + 1,/* DE/LO + TIC */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001657 sizeof(struct DE_eckd_data) +
1658 sizeof(struct LO_eckd_data), device);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659
1660 if (IS_ERR(erp)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001661 /* internal error 01 - Unable to allocate ERP */
1662 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1663 "device driver, reason=%s\n", "01");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1665 }
1666
1667 /* use original DE */
1668 DE_data = erp->data;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001669 oldccw = cqr->cpaddr;
1670 if (oldccw->cmd_code == DASD_ECKD_CCW_PFX) {
1671 PFX_data = cqr->data;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001672 memcpy(DE_data, &PFX_data->define_extent,
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001673 sizeof(struct DE_eckd_data));
1674 } else
1675 memcpy(DE_data, cqr->data, sizeof(struct DE_eckd_data));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676
1677 /* create LO */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001678 LO_data = erp->data + sizeof(struct DE_eckd_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679
1680 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001681 /* should not */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 return dasd_3990_erp_cleanup(default_erp, DASD_CQR_FAILED);
1683 }
1684
1685 if ((sense[7] & 0x3F) == 0x01) {
1686 /* operation code is WRITE DATA -> data area orientation */
1687 LO_data[0] = 0x81;
1688
1689 } else if ((sense[7] & 0x3F) == 0x03) {
1690 /* operation code is FORMAT WRITE -> index orientation */
1691 LO_data[0] = 0xC3;
1692
1693 } else {
1694 LO_data[0] = sense[7]; /* operation */
1695 }
1696
1697 LO_data[1] = sense[8]; /* auxiliary */
1698 LO_data[2] = sense[9];
1699 LO_data[3] = sense[3]; /* count */
1700 LO_data[4] = sense[29]; /* seek_addr.cyl */
1701 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1702 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1703
1704 memcpy(&(LO_data[8]), &(sense[11]), 8);
1705
1706 /* create DE ccw */
1707 ccw = erp->cpaddr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001708 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
1710 ccw->flags = CCW_FLAG_CC;
1711 ccw->count = 16;
1712 ccw->cda = (__u32)(addr_t) DE_data;
1713
1714 /* create LO ccw */
1715 ccw++;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001716 memset(ccw, 0, sizeof(struct ccw1));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
1718 ccw->flags = CCW_FLAG_CC;
1719 ccw->count = 16;
1720 ccw->cda = (__u32)(addr_t) LO_data;
1721
1722 /* TIC to the failed ccw */
1723 ccw++;
1724 ccw->cmd_code = CCW_CMD_TIC;
1725 ccw->cda = cpa;
1726
1727 /* fill erp related fields */
Stefan Weinhuber7ea8d322010-10-25 16:10:08 +02001728 erp->flags = default_erp->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 erp->function = dasd_3990_erp_action_1B_32;
1730 erp->refers = default_erp->refers;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001731 erp->startdev = device;
1732 erp->memdev = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 erp->magic = default_erp->magic;
Stefan Weinhuber1afcfd592011-12-27 11:27:23 +01001734 erp->expires = default_erp->expires;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 erp->retries = 256;
Heiko Carstens1aae0562013-01-30 09:49:40 +01001736 erp->buildclk = get_tod_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 erp->status = DASD_CQR_FILLED;
1738
1739 /* remove the default erp */
1740 dasd_free_erp_request(default_erp, device);
1741
1742 return erp;
1743
1744} /* end dasd_3990_erp_action_1B_32 */
1745
1746/*
1747 * DASD_3990_UPDATE_1B
1748 *
1749 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02001750 * Handles the update to the 32 byte 'Action 1B' of Single Program
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751 * Action Codes in case the first action was not successful.
1752 * The already created 'previous_erp' is the currently not successful
Horst Hummel138c0142006-06-29 14:58:12 +02001753 * ERP.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 *
1755 * PARAMETER
1756 * previous_erp already created previous erp.
Horst Hummel138c0142006-06-29 14:58:12 +02001757 * sense current sense data
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02001759 * erp modified erp
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 */
1761static struct dasd_ccw_req *
1762dasd_3990_update_1B(struct dasd_ccw_req * previous_erp, char *sense)
1763{
1764
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001765 struct dasd_device *device = previous_erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766 __u32 cpa = 0;
1767 struct dasd_ccw_req *cqr;
1768 struct dasd_ccw_req *erp;
1769 char *LO_data; /* struct LO_eckd_data */
1770 struct ccw1 *ccw;
1771
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001772 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001773 "Write not finished because of unexpected condition"
1774 " - follow on");
1775
1776 /* determine the original cqr */
1777 cqr = previous_erp;
1778
1779 while (cqr->refers != NULL) {
1780 cqr = cqr->refers;
1781 }
1782
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01001783 if (scsw_is_tm(&cqr->irb.scsw)) {
1784 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1785 "32 bit sense, action 1B, update,"
1786 " in transport mode - just retry");
1787 return previous_erp;
1788 }
1789
Linus Torvalds1da177e2005-04-16 15:20:36 -07001790 /* for imprecise ending just do default erp */
1791 if (sense[1] & 0x01) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001792 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793 "Imprecise ending is set - just retry");
1794
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001795 previous_erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796
1797 return previous_erp;
1798 }
1799
1800 /* determine the address of the CCW to be restarted */
1801 /* Imprecise ending is not set -> addr from IRB-SCSW */
Peter Oberparleiter23d805b62008-07-14 09:58:50 +02001802 cpa = previous_erp->irb.scsw.cmd.cpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803
1804 if (cpa == 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001805 /* internal error 02 -
1806 Unable to determine address of the CCW to be restarted */
1807 dev_err(&device->cdev->dev, "An error occurred in the DASD "
1808 "device driver, reason=%s\n", "02");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809
1810 previous_erp->status = DASD_CQR_FAILED;
1811
1812 return previous_erp;
1813 }
1814
1815 erp = previous_erp;
1816
1817 /* update the LO with the new returned sense data */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001818 LO_data = erp->data + sizeof(struct DE_eckd_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819
1820 if ((sense[3] == 0x01) && (LO_data[1] & 0x01)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01001821 /* should not happen */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 previous_erp->status = DASD_CQR_FAILED;
1823
1824 return previous_erp;
1825 }
1826
1827 if ((sense[7] & 0x3F) == 0x01) {
1828 /* operation code is WRITE DATA -> data area orientation */
1829 LO_data[0] = 0x81;
1830
1831 } else if ((sense[7] & 0x3F) == 0x03) {
1832 /* operation code is FORMAT WRITE -> index orientation */
1833 LO_data[0] = 0xC3;
1834
1835 } else {
1836 LO_data[0] = sense[7]; /* operation */
1837 }
1838
1839 LO_data[1] = sense[8]; /* auxiliary */
1840 LO_data[2] = sense[9];
1841 LO_data[3] = sense[3]; /* count */
1842 LO_data[4] = sense[29]; /* seek_addr.cyl */
1843 LO_data[5] = sense[30]; /* seek_addr.cyl 2nd byte */
1844 LO_data[7] = sense[31]; /* seek_addr.head 2nd byte */
1845
1846 memcpy(&(LO_data[8]), &(sense[11]), 8);
1847
1848 /* TIC to the failed ccw */
1849 ccw = erp->cpaddr; /* addr of DE ccw */
1850 ccw++; /* addr of LE ccw */
1851 ccw++; /* addr of TIC ccw */
1852 ccw->cda = cpa;
1853
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001854 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001855
1856 return erp;
1857
1858} /* end dasd_3990_update_1B */
1859
1860/*
Horst Hummel138c0142006-06-29 14:58:12 +02001861 * DASD_3990_ERP_COMPOUND_RETRY
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 *
1863 * DESCRIPTION
1864 * Handles the compound ERP action retry code.
1865 * NOTE: At least one retry is done even if zero is specified
1866 * by the sense data. This makes enqueueing of the request
1867 * easier.
1868 *
1869 * PARAMETER
1870 * sense sense data of the actual error
1871 * erp pointer to the currently created ERP
1872 *
1873 * RETURN VALUES
1874 * erp modified ERP pointer
1875 *
1876 */
1877static void
1878dasd_3990_erp_compound_retry(struct dasd_ccw_req * erp, char *sense)
1879{
1880
1881 switch (sense[25] & 0x03) {
1882 case 0x00: /* no not retry */
1883 erp->retries = 1;
1884 break;
1885
1886 case 0x01: /* retry 2 times */
1887 erp->retries = 2;
1888 break;
1889
1890 case 0x02: /* retry 10 times */
1891 erp->retries = 10;
1892 break;
1893
1894 case 0x03: /* retry 256 times */
1895 erp->retries = 256;
1896 break;
1897
1898 default:
1899 BUG();
1900 }
1901
1902 erp->function = dasd_3990_erp_compound_retry;
1903
1904} /* end dasd_3990_erp_compound_retry */
1905
1906/*
Horst Hummel138c0142006-06-29 14:58:12 +02001907 * DASD_3990_ERP_COMPOUND_PATH
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908 *
1909 * DESCRIPTION
1910 * Handles the compound ERP action for retry on alternate
1911 * channel path.
1912 *
1913 * PARAMETER
1914 * sense sense data of the actual error
1915 * erp pointer to the currently created ERP
1916 *
1917 * RETURN VALUES
1918 * erp modified ERP pointer
1919 *
1920 */
1921static void
1922dasd_3990_erp_compound_path(struct dasd_ccw_req * erp, char *sense)
1923{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 if (sense[25] & DASD_SENSE_BIT_3) {
1925 dasd_3990_erp_alternate_path(erp);
1926
Stefan Weinhubera4d26c62011-01-05 12:48:03 +01001927 if (erp->status == DASD_CQR_FAILED &&
1928 !test_bit(DASD_CQR_VERIFY_PATH, &erp->flags)) {
Horst Hummel138c0142006-06-29 14:58:12 +02001929 /* reset the lpm and the status to be able to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 * try further actions. */
Stefan Haberlandc9346152016-08-08 15:53:54 +02001931 erp->lpm = dasd_path_get_opm(erp->startdev);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01001932 erp->status = DASD_CQR_NEED_ERP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 }
1934 }
1935
1936 erp->function = dasd_3990_erp_compound_path;
1937
1938} /* end dasd_3990_erp_compound_path */
1939
1940/*
Horst Hummel138c0142006-06-29 14:58:12 +02001941 * DASD_3990_ERP_COMPOUND_CODE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 *
1943 * DESCRIPTION
1944 * Handles the compound ERP action for retry code.
1945 *
1946 * PARAMETER
1947 * sense sense data of the actual error
1948 * erp pointer to the currently created ERP
1949 *
1950 * RETURN VALUES
1951 * erp NEW ERP pointer
1952 *
1953 */
1954static struct dasd_ccw_req *
1955dasd_3990_erp_compound_code(struct dasd_ccw_req * erp, char *sense)
1956{
1957
1958 if (sense[25] & DASD_SENSE_BIT_2) {
1959
1960 switch (sense[28]) {
1961 case 0x17:
Horst Hummel138c0142006-06-29 14:58:12 +02001962 /* issue a Diagnostic Control command with an
Robert P. J. Day3a4fa0a2007-10-19 23:10:43 +02001963 * Inhibit Write subcommand and controller modifier */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964 erp = dasd_3990_erp_DCTL(erp, 0x20);
1965 break;
Horst Hummel138c0142006-06-29 14:58:12 +02001966
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967 case 0x25:
1968 /* wait for 5 seconds and retry again */
1969 erp->retries = 1;
Horst Hummel138c0142006-06-29 14:58:12 +02001970
Linus Torvalds1da177e2005-04-16 15:20:36 -07001971 dasd_3990_erp_block_queue (erp, 5*HZ);
1972 break;
Horst Hummel138c0142006-06-29 14:58:12 +02001973
Linus Torvalds1da177e2005-04-16 15:20:36 -07001974 default:
1975 /* should not happen - continue */
1976 break;
1977 }
1978 }
1979
1980 erp->function = dasd_3990_erp_compound_code;
1981
1982 return erp;
1983
1984} /* end dasd_3990_erp_compound_code */
1985
1986/*
Horst Hummel138c0142006-06-29 14:58:12 +02001987 * DASD_3990_ERP_COMPOUND_CONFIG
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988 *
1989 * DESCRIPTION
Geert Uytterhoeven816dddc2019-10-24 17:24:33 +02001990 * Handles the compound ERP action for configuration
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991 * dependent error.
1992 * Note: duplex handling is not implemented (yet).
1993 *
1994 * PARAMETER
1995 * sense sense data of the actual error
1996 * erp pointer to the currently created ERP
1997 *
1998 * RETURN VALUES
1999 * erp modified ERP pointer
2000 *
2001 */
2002static void
2003dasd_3990_erp_compound_config(struct dasd_ccw_req * erp, char *sense)
2004{
2005
2006 if ((sense[25] & DASD_SENSE_BIT_1) && (sense[26] & DASD_SENSE_BIT_2)) {
2007
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002008 /* set to suspended duplex state then restart
2009 internal error 05 - Set device to suspended duplex state
2010 should be done */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002011 struct dasd_device *device = erp->startdev;
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002012 dev_err(&device->cdev->dev,
2013 "An error occurred in the DASD device driver, "
2014 "reason=%s\n", "05");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015
2016 }
2017
2018 erp->function = dasd_3990_erp_compound_config;
2019
2020} /* end dasd_3990_erp_compound_config */
2021
2022/*
Horst Hummel138c0142006-06-29 14:58:12 +02002023 * DASD_3990_ERP_COMPOUND
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024 *
2025 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02002026 * Does the further compound program action if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 * compound retry was not successful.
2028 *
2029 * PARAMETER
2030 * sense sense data of the actual error
2031 * erp pointer to the current (failed) ERP
2032 *
2033 * RETURN VALUES
2034 * erp (additional) ERP pointer
2035 *
2036 */
2037static struct dasd_ccw_req *
2038dasd_3990_erp_compound(struct dasd_ccw_req * erp, char *sense)
2039{
2040
2041 if ((erp->function == dasd_3990_erp_compound_retry) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002042 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043
2044 dasd_3990_erp_compound_path(erp, sense);
2045 }
2046
2047 if ((erp->function == dasd_3990_erp_compound_path) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002048 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049
2050 erp = dasd_3990_erp_compound_code(erp, sense);
2051 }
2052
2053 if ((erp->function == dasd_3990_erp_compound_code) &&
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002054 (erp->status == DASD_CQR_NEED_ERP)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055
2056 dasd_3990_erp_compound_config(erp, sense);
2057 }
2058
2059 /* if no compound action ERP specified, the request failed */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002060 if (erp->status == DASD_CQR_NEED_ERP)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002061 erp->status = DASD_CQR_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062
2063 return erp;
2064
2065} /* end dasd_3990_erp_compound */
2066
2067/*
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002068 *DASD_3990_ERP_HANDLE_SIM
2069 *
2070 *DESCRIPTION
2071 * inspects the SIM SENSE data and starts an appropriate action
2072 *
2073 * PARAMETER
2074 * sense sense data of the actual error
2075 *
2076 * RETURN VALUES
2077 * none
2078 */
2079void
2080dasd_3990_erp_handle_sim(struct dasd_device *device, char *sense)
2081{
2082 /* print message according to log or message to operator mode */
2083 if ((sense[24] & DASD_SIM_MSG_TO_OP) || (sense[1] & 0x10)) {
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002084 /* print SIM SRC from RefCode */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002085 dev_err(&device->cdev->dev, "SIM - SRC: "
2086 "%02x%02x%02x%02x\n", sense[22],
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002087 sense[23], sense[11], sense[12]);
2088 } else if (sense[24] & DASD_SIM_LOG) {
2089 /* print SIM SRC Refcode */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002090 dev_warn(&device->cdev->dev, "log SIM - SRC: "
2091 "%02x%02x%02x%02x\n", sense[22],
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002092 sense[23], sense[11], sense[12]);
2093 }
2094}
2095
2096/*
Horst Hummel138c0142006-06-29 14:58:12 +02002097 * DASD_3990_ERP_INSPECT_32
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 *
2099 * DESCRIPTION
2100 * Does a detailed inspection of the 32 byte sense data
Horst Hummel138c0142006-06-29 14:58:12 +02002101 * and sets up a related error recovery action.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 *
2103 * PARAMETER
2104 * sense sense data of the actual error
2105 * erp pointer to the currently created default ERP
2106 *
2107 * RETURN VALUES
2108 * erp_filled pointer to the ERP
2109 *
2110 */
2111static struct dasd_ccw_req *
2112dasd_3990_erp_inspect_32(struct dasd_ccw_req * erp, char *sense)
2113{
2114
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002115 struct dasd_device *device = erp->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116
2117 erp->function = dasd_3990_erp_inspect_32;
2118
Stefan Haberlandf60c7682008-04-17 07:46:08 +02002119 /* check for SIM sense data */
2120 if ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)
2121 dasd_3990_erp_handle_sim(device, sense);
2122
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 if (sense[25] & DASD_SENSE_BIT_0) {
2124
2125 /* compound program action codes (byte25 bit 0 == '1') */
2126 dasd_3990_erp_compound_retry(erp, sense);
2127
2128 } else {
2129
2130 /* single program action codes (byte25 bit 0 == '0') */
2131 switch (sense[25]) {
2132
2133 case 0x00: /* success - use default ERP for retries */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002134 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135 "ERP called for successful request"
2136 " - just retry");
2137 break;
2138
2139 case 0x01: /* fatal error */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002140 dev_err(&device->cdev->dev,
2141 "ERP failed for the DASD\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142
2143 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2144 break;
2145
2146 case 0x02: /* intervention required */
2147 case 0x03: /* intervention required during dual copy */
2148 erp = dasd_3990_erp_int_req(erp);
2149 break;
2150
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002151 case 0x0F: /* length mismatch during update write command
2152 internal error 08 - update write command error*/
2153 dev_err(&device->cdev->dev, "An error occurred in the "
2154 "DASD device driver, reason=%s\n", "08");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155
2156 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2157 break;
2158
2159 case 0x10: /* logging required for other channel program */
2160 erp = dasd_3990_erp_action_10_32(erp, sense);
2161 break;
2162
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002163 case 0x15: /* next track outside defined extend
2164 internal error 07 - The next track is not
2165 within the defined storage extent */
2166 dev_err(&device->cdev->dev,
2167 "An error occurred in the DASD device driver, "
2168 "reason=%s\n", "07");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169
2170 erp = dasd_3990_erp_cleanup(erp, DASD_CQR_FAILED);
2171 break;
2172
2173 case 0x1B: /* unexpected condition during write */
2174
2175 erp = dasd_3990_erp_action_1B_32(erp, sense);
2176 break;
2177
2178 case 0x1C: /* invalid data */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002179 dev_emerg(&device->cdev->dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 "Data recovered during retry with PCI "
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002181 "fetch mode active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182
2183 /* not possible to handle this situation in Linux */
2184 panic
2185 ("Invalid data - No way to inform application "
2186 "about the possibly incorrect data");
2187 break;
2188
2189 case 0x1D: /* state-change pending */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002190 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 "A State change pending condition exists "
2192 "for the subsystem or device");
2193
2194 erp = dasd_3990_erp_action_4(erp, sense);
2195 break;
2196
2197 case 0x1E: /* busy */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002198 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 "Busy condition exists "
2200 "for the subsystem or device");
2201 erp = dasd_3990_erp_action_4(erp, sense);
2202 break;
2203
2204 default: /* all others errors - default erp */
2205 break;
2206 }
2207 }
2208
2209 return erp;
2210
2211} /* end dasd_3990_erp_inspect_32 */
2212
Stefan Haberlanda521b042016-08-08 15:56:54 +02002213static void dasd_3990_erp_disable_path(struct dasd_device *device, __u8 lpum)
2214{
2215 int pos = pathmask_to_pos(lpum);
2216
Stefan Haberlandddc1c942017-12-19 16:18:38 +01002217 if (!(device->features & DASD_FEATURE_PATH_AUTODISABLE)) {
2218 dev_err(&device->cdev->dev,
2219 "Path %x.%02x (pathmask %02x) is operational despite excessive IFCCs\n",
2220 device->path[pos].cssid, device->path[pos].chpid, lpum);
2221 goto out;
2222 }
2223
Stefan Haberlanda521b042016-08-08 15:56:54 +02002224 /* no remaining path, cannot disable */
Stefan Haberlandddc1c942017-12-19 16:18:38 +01002225 if (!(dasd_path_get_opm(device) & ~lpum)) {
2226 dev_err(&device->cdev->dev,
2227 "Last path %x.%02x (pathmask %02x) is operational despite excessive IFCCs\n",
2228 device->path[pos].cssid, device->path[pos].chpid, lpum);
2229 goto out;
2230 }
Stefan Haberlanda521b042016-08-08 15:56:54 +02002231
2232 dev_err(&device->cdev->dev,
2233 "Path %x.%02x (pathmask %02x) is disabled - IFCC threshold exceeded\n",
2234 device->path[pos].cssid, device->path[pos].chpid, lpum);
2235 dasd_path_remove_opm(device, lpum);
2236 dasd_path_add_ifccpm(device, lpum);
Stefan Haberlandddc1c942017-12-19 16:18:38 +01002237
2238out:
Stefan Haberlanda521b042016-08-08 15:56:54 +02002239 device->path[pos].errorclk = 0;
2240 atomic_set(&device->path[pos].error_count, 0);
2241}
2242
2243static void dasd_3990_erp_account_error(struct dasd_ccw_req *erp)
2244{
2245 struct dasd_device *device = erp->startdev;
2246 __u8 lpum = erp->refers->irb.esw.esw1.lpum;
2247 int pos = pathmask_to_pos(lpum);
Jan Höppner7bf76f012017-08-15 16:40:18 +02002248 unsigned long clk;
Stefan Haberlanda521b042016-08-08 15:56:54 +02002249
2250 if (!device->path_thrhld)
2251 return;
2252
2253 clk = get_tod_clock();
2254 /*
2255 * check if the last error is longer ago than the timeout,
2256 * if so reset error state
2257 */
2258 if ((tod_to_ns(clk - device->path[pos].errorclk) / NSEC_PER_SEC)
2259 >= device->path_interval) {
2260 atomic_set(&device->path[pos].error_count, 0);
2261 device->path[pos].errorclk = 0;
2262 }
2263 atomic_inc(&device->path[pos].error_count);
2264 device->path[pos].errorclk = clk;
2265 /* threshold exceeded disable path if possible */
2266 if (atomic_read(&device->path[pos].error_count) >=
2267 device->path_thrhld)
2268 dasd_3990_erp_disable_path(device, lpum);
2269}
2270
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271/*
Horst Hummel138c0142006-06-29 14:58:12 +02002272 *****************************************************************************
Stefan Weileef35c22010-08-06 21:11:15 +02002273 * main ERP control functions (24 and 32 byte sense)
Horst Hummel138c0142006-06-29 14:58:12 +02002274 *****************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 */
2276
2277/*
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002278 * DASD_3990_ERP_CONTROL_CHECK
2279 *
2280 * DESCRIPTION
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002281 * Does a generic inspection if a control check occurred and sets up
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002282 * the related error recovery procedure
2283 *
2284 * PARAMETER
2285 * erp pointer to the currently created default ERP
2286 *
2287 * RETURN VALUES
2288 * erp_filled pointer to the erp
2289 */
2290
2291static struct dasd_ccw_req *
2292dasd_3990_erp_control_check(struct dasd_ccw_req *erp)
2293{
2294 struct dasd_device *device = erp->startdev;
2295
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002296 if (scsw_cstat(&erp->refers->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002297 | SCHN_STAT_CHN_CTRL_CHK)) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002298 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002299 "channel or interface control check");
Stefan Haberlanda521b042016-08-08 15:56:54 +02002300 dasd_3990_erp_account_error(erp);
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002301 erp = dasd_3990_erp_action_4(erp, NULL);
2302 }
2303 return erp;
2304}
2305
2306/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 * DASD_3990_ERP_INSPECT
2308 *
2309 * DESCRIPTION
2310 * Does a detailed inspection for sense data by calling either
2311 * the 24-byte or the 32-byte inspection routine.
2312 *
2313 * PARAMETER
2314 * erp pointer to the currently created default ERP
2315 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02002316 * erp_new contens was possibly modified
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 */
2318static struct dasd_ccw_req *
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002319dasd_3990_erp_inspect(struct dasd_ccw_req *erp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320{
2321
2322 struct dasd_ccw_req *erp_new = NULL;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002323 char *sense;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002325 /* if this problem occurred on an alias retry on base */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002326 erp_new = dasd_3990_erp_inspect_alias(erp);
2327 if (erp_new)
2328 return erp_new;
2329
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002330 /* sense data are located in the refers record of the
2331 * already set up new ERP !
2332 * check if concurrent sens is available
2333 */
2334 sense = dasd_get_sense(&erp->refers->irb);
2335 if (!sense)
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002336 erp_new = dasd_3990_erp_control_check(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 /* distinguish between 24 and 32 byte sense data */
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002338 else if (sense[27] & DASD_SENSE_BIT_0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339
2340 /* inspect the 24 byte sense data */
2341 erp_new = dasd_3990_erp_inspect_24(erp, sense);
2342
2343 } else {
2344
2345 /* inspect the 32 byte sense data */
2346 erp_new = dasd_3990_erp_inspect_32(erp, sense);
2347
2348 } /* end distinguish between 24 and 32 byte sense data */
2349
2350 return erp_new;
2351}
2352
2353/*
2354 * DASD_3990_ERP_ADD_ERP
Horst Hummel138c0142006-06-29 14:58:12 +02002355 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 * DESCRIPTION
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002357 * This function adds an additional request block (ERP) to the head of
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 * the given cqr (or erp).
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002359 * For a command mode cqr the erp is initialized as an default erp
2360 * (retry TIC).
2361 * For transport mode we make a copy of the original TCW (points to
2362 * the original TCCB, TIDALs, etc.) but give it a fresh
2363 * TSB so the original sense data will not be changed.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 *
2365 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002366 * cqr head of the current ERP-chain (or single cqr if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 * first error)
2368 * RETURN VALUES
2369 * erp pointer to new ERP-chain head
2370 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002371static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372{
2373
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002374 struct dasd_device *device = cqr->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375 struct ccw1 *ccw;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002376 struct dasd_ccw_req *erp;
2377 int cplength, datasize;
2378 struct tcw *tcw;
2379 struct tsb *tsb;
2380
2381 if (cqr->cpmode == 1) {
2382 cplength = 0;
Stefan Weinhuber4a31ba52010-03-24 11:49:53 +01002383 /* TCW needs to be 64 byte aligned, so leave enough room */
2384 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002385 } else {
2386 cplength = 2;
2387 datasize = 0;
2388 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389
2390 /* allocate additional request block */
Heiko Carstens169bbda2021-10-20 13:51:18 +02002391 erp = dasd_alloc_erp_request(cqr->magic,
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002392 cplength, datasize, device);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 if (IS_ERR(erp)) {
2394 if (cqr->retries <= 0) {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002395 DBF_DEV_EVENT(DBF_ERR, device, "%s",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 "Unable to allocate ERP request");
2397 cqr->status = DASD_CQR_FAILED;
Heiko Carstens1aae0562013-01-30 09:49:40 +01002398 cqr->stopclk = get_tod_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002400 DBF_DEV_EVENT(DBF_ERR, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 "Unable to allocate ERP request "
2402 "(%i retries left)",
2403 cqr->retries);
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002404 dasd_block_set_timer(device->block, (HZ << 3));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 }
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002406 return erp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 }
2408
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002409 ccw = cqr->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002410 if (cqr->cpmode == 1) {
2411 /* make a shallow copy of the original tcw but set new tsb */
2412 erp->cpmode = 1;
Stefan Weinhuber4a31ba52010-03-24 11:49:53 +01002413 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2414 tcw = erp->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002415 tsb = (struct tsb *) &tcw[1];
2416 *tcw = *((struct tcw *)cqr->cpaddr);
2417 tcw->tsb = (long)tsb;
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002418 } else if (ccw->cmd_code == DASD_ECKD_CCW_PSF) {
2419 /* PSF cannot be chained from NOOP/TIC */
2420 erp->cpaddr = cqr->cpaddr;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002421 } else {
2422 /* initialize request with default TIC to current ERP/CQR */
2423 ccw = erp->cpaddr;
2424 ccw->cmd_code = CCW_CMD_NOOP;
2425 ccw->flags = CCW_FLAG_CC;
2426 ccw++;
2427 ccw->cmd_code = CCW_CMD_TIC;
2428 ccw->cda = (long)(cqr->cpaddr);
2429 }
2430
Stefan Weinhuber7ea8d322010-10-25 16:10:08 +02002431 erp->flags = cqr->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 erp->function = dasd_3990_erp_add_erp;
2433 erp->refers = cqr;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002434 erp->startdev = device;
2435 erp->memdev = device;
2436 erp->block = cqr->block;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 erp->magic = cqr->magic;
Stefan Weinhuber1afcfd592011-12-27 11:27:23 +01002438 erp->expires = cqr->expires;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 erp->retries = 256;
Heiko Carstens1aae0562013-01-30 09:49:40 +01002440 erp->buildclk = get_tod_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 erp->status = DASD_CQR_FILLED;
2442
2443 return erp;
2444}
2445
2446/*
Horst Hummel138c0142006-06-29 14:58:12 +02002447 * DASD_3990_ERP_ADDITIONAL_ERP
2448 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 * DESCRIPTION
2450 * An additional ERP is needed to handle the current error.
2451 * Add ERP to the head of the ERP-chain containing the ERP processing
2452 * determined based on the sense data.
2453 *
2454 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002455 * cqr head of the current ERP-chain (or single cqr if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 * first error)
2457 *
2458 * RETURN VALUES
2459 * erp pointer to new ERP-chain head
2460 */
2461static struct dasd_ccw_req *
2462dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2463{
2464
2465 struct dasd_ccw_req *erp = NULL;
2466
2467 /* add erp and initialize with default TIC */
2468 erp = dasd_3990_erp_add_erp(cqr);
2469
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002470 if (IS_ERR(erp))
2471 return erp;
2472
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 /* inspect sense, determine specific ERP if possible */
2474 if (erp != cqr) {
2475
2476 erp = dasd_3990_erp_inspect(erp);
2477 }
2478
2479 return erp;
2480
2481} /* end dasd_3990_erp_additional_erp */
2482
2483/*
2484 * DASD_3990_ERP_ERROR_MATCH
2485 *
2486 * DESCRIPTION
2487 * Check if the device status of the given cqr is the same.
2488 * This means that the failed CCW and the relevant sense data
2489 * must match.
2490 * I don't distinguish between 24 and 32 byte sense because in case of
2491 * 24 byte sense byte 25 and 27 is set as well.
2492 *
2493 * PARAMETER
Horst Hummel138c0142006-06-29 14:58:12 +02002494 * cqr1 first cqr, which will be compared with the
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495 * cqr2 second cqr.
2496 *
2497 * RETURN VALUES
2498 * match 'boolean' for match found
2499 * returns 1 if match found, otherwise 0.
2500 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002501static int dasd_3990_erp_error_match(struct dasd_ccw_req *cqr1,
2502 struct dasd_ccw_req *cqr2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503{
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002504 char *sense1, *sense2;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505
Stefan Weinhuber5c12f242008-03-05 12:37:10 +01002506 if (cqr1->startdev != cqr2->startdev)
2507 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002509 sense1 = dasd_get_sense(&cqr1->irb);
2510 sense2 = dasd_get_sense(&cqr2->irb);
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002511
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002512 /* one request has sense data, the other not -> no match, return 0 */
2513 if (!sense1 != !sense2)
2514 return 0;
2515 /* no sense data in both cases -> check cstat for IFCC */
2516 if (!sense1 && !sense2) {
2517 if ((scsw_cstat(&cqr1->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2518 SCHN_STAT_CHN_CTRL_CHK)) ==
2519 (scsw_cstat(&cqr2->irb.scsw) & (SCHN_STAT_INTF_CTRL_CHK |
2520 SCHN_STAT_CHN_CTRL_CHK)))
Stefan Haberland6c5f57c2008-02-05 16:50:46 +01002521 return 1; /* match with ifcc*/
2522 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523 /* check sense data; byte 0-2,25,27 */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002524 if (!(sense1 && sense2 &&
2525 (memcmp(sense1, sense2, 3) == 0) &&
2526 (sense1[27] == sense2[27]) &&
2527 (sense1[25] == sense2[25]))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528
2529 return 0; /* sense doesn't match */
2530 }
2531
2532 return 1; /* match */
2533
2534} /* end dasd_3990_erp_error_match */
2535
2536/*
2537 * DASD_3990_ERP_IN_ERP
2538 *
2539 * DESCRIPTION
2540 * check if the current error already happened before.
2541 * quick exit if current cqr is not an ERP (cqr->refers=NULL)
2542 *
2543 * PARAMETER
2544 * cqr failed cqr (either original cqr or already an erp)
2545 *
2546 * RETURN VALUES
Horst Hummel138c0142006-06-29 14:58:12 +02002547 * erp erp-pointer to the already defined error
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 * recovery procedure OR
2549 * NULL if a 'new' error occurred.
2550 */
2551static struct dasd_ccw_req *
2552dasd_3990_erp_in_erp(struct dasd_ccw_req *cqr)
2553{
2554
2555 struct dasd_ccw_req *erp_head = cqr, /* save erp chain head */
2556 *erp_match = NULL; /* save erp chain head */
2557 int match = 0; /* 'boolean' for matching error found */
2558
2559 if (cqr->refers == NULL) { /* return if not in erp */
2560 return NULL;
2561 }
2562
2563 /* check the erp/cqr chain for current error */
2564 do {
2565 match = dasd_3990_erp_error_match(erp_head, cqr->refers);
2566 erp_match = cqr; /* save possible matching erp */
2567 cqr = cqr->refers; /* check next erp/cqr in queue */
2568
2569 } while ((cqr->refers != NULL) && (!match));
2570
2571 if (!match) {
2572 return NULL; /* no match was found */
2573 }
2574
2575 return erp_match; /* return address of matching erp */
2576
2577} /* END dasd_3990_erp_in_erp */
2578
2579/*
2580 * DASD_3990_ERP_FURTHER_ERP (24 & 32 byte sense)
2581 *
2582 * DESCRIPTION
Horst Hummel138c0142006-06-29 14:58:12 +02002583 * No retry is left for the current ERP. Check what has to be done
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 * with the ERP.
2585 * - do further defined ERP action or
Horst Hummel138c0142006-06-29 14:58:12 +02002586 * - wait for interrupt or
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587 * - exit with permanent error
2588 *
2589 * PARAMETER
2590 * erp ERP which is in progress with no retry left
2591 *
2592 * RETURN VALUES
2593 * erp modified/additional ERP
2594 */
2595static struct dasd_ccw_req *
2596dasd_3990_erp_further_erp(struct dasd_ccw_req *erp)
2597{
2598
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002599 struct dasd_device *device = erp->startdev;
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002600 char *sense = dasd_get_sense(&erp->irb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601
2602 /* check for 24 byte sense ERP */
2603 if ((erp->function == dasd_3990_erp_bus_out) ||
2604 (erp->function == dasd_3990_erp_action_1) ||
2605 (erp->function == dasd_3990_erp_action_4)) {
2606
2607 erp = dasd_3990_erp_action_1(erp);
2608
Stefan Weinhubereb6e1992009-12-07 12:51:51 +01002609 } else if (erp->function == dasd_3990_erp_action_1_sec) {
2610 erp = dasd_3990_erp_action_1_sec(erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 } else if (erp->function == dasd_3990_erp_action_5) {
2612
2613 /* retries have not been successful */
2614 /* prepare erp for retry on different channel path */
2615 erp = dasd_3990_erp_action_1(erp);
2616
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002617 if (sense && !(sense[2] & DASD_SENSE_BIT_0)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618
Horst Hummel138c0142006-06-29 14:58:12 +02002619 /* issue a Diagnostic Control command with an
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 * Inhibit Write subcommand */
2621
2622 switch (sense[25]) {
2623 case 0x17:
2624 case 0x57:{ /* controller */
2625 erp = dasd_3990_erp_DCTL(erp, 0x20);
2626 break;
2627 }
2628 case 0x18:
2629 case 0x58:{ /* channel path */
2630 erp = dasd_3990_erp_DCTL(erp, 0x40);
2631 break;
2632 }
2633 case 0x19:
2634 case 0x59:{ /* storage director */
2635 erp = dasd_3990_erp_DCTL(erp, 0x80);
2636 break;
2637 }
2638 default:
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002639 DBF_DEV_EVENT(DBF_WARNING, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 "invalid subcommand modifier 0x%x "
2641 "for Diagnostic Control Command",
2642 sense[25]);
2643 }
2644 }
2645
2646 /* check for 32 byte sense ERP */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002647 } else if (sense &&
2648 ((erp->function == dasd_3990_erp_compound_retry) ||
2649 (erp->function == dasd_3990_erp_compound_path) ||
2650 (erp->function == dasd_3990_erp_compound_code) ||
2651 (erp->function == dasd_3990_erp_compound_config))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652
2653 erp = dasd_3990_erp_compound(erp, sense);
2654
2655 } else {
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002656 /*
2657 * No retry left and no additional special handling
2658 * necessary
2659 */
2660 dev_err(&device->cdev->dev,
2661 "ERP %p has run out of retries and failed\n", erp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662
2663 erp->status = DASD_CQR_FAILED;
2664 }
2665
2666 return erp;
2667
2668} /* end dasd_3990_erp_further_erp */
2669
2670/*
Horst Hummel138c0142006-06-29 14:58:12 +02002671 * DASD_3990_ERP_HANDLE_MATCH_ERP
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672 *
2673 * DESCRIPTION
2674 * An error occurred again and an ERP has been detected which is already
Horst Hummel138c0142006-06-29 14:58:12 +02002675 * used to handle this error (e.g. retries).
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 * All prior ERP's are asumed to be successful and therefore removed
2677 * from queue.
Horst Hummel138c0142006-06-29 14:58:12 +02002678 * If retry counter of matching erp is already 0, it is checked if further
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 * action is needed (besides retry) or if the ERP has failed.
2680 *
2681 * PARAMETER
2682 * erp_head first ERP in ERP-chain
2683 * erp ERP that handles the actual error.
2684 * (matching erp)
2685 *
2686 * RETURN VALUES
2687 * erp modified/additional ERP
2688 */
2689static struct dasd_ccw_req *
2690dasd_3990_erp_handle_match_erp(struct dasd_ccw_req *erp_head,
2691 struct dasd_ccw_req *erp)
2692{
2693
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002694 struct dasd_device *device = erp_head->startdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002695 struct dasd_ccw_req *erp_done = erp_head; /* finished req */
2696 struct dasd_ccw_req *erp_free = NULL; /* req to be freed */
2697
2698 /* loop over successful ERPs and remove them from chanq */
2699 while (erp_done != erp) {
2700
2701 if (erp_done == NULL) /* end of chain reached */
2702 panic(PRINTK_HEADER "Programming error in ERP! The "
2703 "original request was lost\n");
2704
2705 /* remove the request from the device queue */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002706 list_del(&erp_done->blocklist);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002707
2708 erp_free = erp_done;
2709 erp_done = erp_done->refers;
2710
2711 /* free the finished erp request */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002712 dasd_free_erp_request(erp_free, erp_free->memdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713
2714 } /* end while */
2715
2716 if (erp->retries > 0) {
2717
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002718 char *sense = dasd_get_sense(&erp->refers->irb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719
2720 /* check for special retries */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002721 if (sense && erp->function == dasd_3990_erp_action_4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722
2723 erp = dasd_3990_erp_action_4(erp, sense);
2724
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002725 } else if (sense &&
2726 erp->function == dasd_3990_erp_action_1B_32) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727
2728 erp = dasd_3990_update_1B(erp, sense);
2729
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002730 } else if (sense && erp->function == dasd_3990_erp_int_req) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002731
2732 erp = dasd_3990_erp_int_req(erp);
2733
2734 } else {
2735 /* simple retry */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002736 DBF_DEV_EVENT(DBF_DEBUG, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 "%i retries left for erp %p",
2738 erp->retries, erp);
2739
2740 /* handle the request again... */
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002741 erp->status = DASD_CQR_FILLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 }
2743
2744 } else {
2745 /* no retry left - check for further necessary action */
2746 /* if no further actions, handle rest as permanent error */
2747 erp = dasd_3990_erp_further_erp(erp);
2748 }
2749
2750 return erp;
2751
2752} /* end dasd_3990_erp_handle_match_erp */
2753
2754/*
2755 * DASD_3990_ERP_ACTION
2756 *
2757 * DESCRIPTION
Joe Perches5d67d162008-01-26 14:11:20 +01002758 * control routine for 3990 erp actions.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759 * Has to be called with the queue lock (namely the s390_irq_lock) acquired.
2760 *
2761 * PARAMETER
2762 * cqr failed cqr (either original cqr or already an erp)
2763 *
2764 * RETURN VALUES
2765 * erp erp-pointer to the head of the ERP action chain.
2766 * This means:
2767 * - either a ptr to an additional ERP cqr or
Horst Hummel138c0142006-06-29 14:58:12 +02002768 * - the original given cqr (which's status might
Linus Torvalds1da177e2005-04-16 15:20:36 -07002769 * be modified)
2770 */
2771struct dasd_ccw_req *
2772dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2773{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002774 struct dasd_ccw_req *erp = NULL;
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002775 struct dasd_device *device = cqr->startdev;
Horst Hummel9575bf22006-12-08 15:54:15 +01002776 struct dasd_ccw_req *temp_erp = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002777
Horst Hummel9575bf22006-12-08 15:54:15 +01002778 if (device->features & DASD_FEATURE_ERPLOG) {
2779 /* print current erp_chain */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002780 dev_err(&device->cdev->dev,
2781 "ERP chain at BEGINNING of ERP-ACTION\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002782 for (temp_erp = cqr;
2783 temp_erp != NULL; temp_erp = temp_erp->refers) {
2784
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002785 dev_err(&device->cdev->dev,
2786 "ERP %p (%02x) refers to %p\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 temp_erp, temp_erp->status,
2788 temp_erp->refers);
2789 }
2790 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002791
Coly Li73ac36e2009-01-07 18:09:16 -08002792 /* double-check if current erp/cqr was successful */
Stefan Weinhuberf3eb5382009-03-26 15:23:48 +01002793 if ((scsw_cstat(&cqr->irb.scsw) == 0x00) &&
2794 (scsw_dstat(&cqr->irb.scsw) ==
Peter Oberparleiter23d805b62008-07-14 09:58:50 +02002795 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002796
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002797 DBF_DEV_EVENT(DBF_DEBUG, device,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798 "ERP called for successful request %p"
2799 " - NO ERP necessary", cqr);
2800
2801 cqr->status = DASD_CQR_DONE;
2802
2803 return cqr;
2804 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002805
2806 /* check if error happened before */
2807 erp = dasd_3990_erp_in_erp(cqr);
2808
2809 if (erp == NULL) {
2810 /* no matching erp found - set up erp */
2811 erp = dasd_3990_erp_additional_erp(cqr);
Stefan Haberland6a5176c2010-04-22 17:17:02 +02002812 if (IS_ERR(erp))
2813 return erp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002814 } else {
2815 /* matching erp found - set all leading erp's to DONE */
2816 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
2817 }
2818
Stefan Haberland8a9bd4f2017-12-06 10:30:39 +01002819
2820 /*
2821 * For path verification work we need to stick with the path that was
2822 * originally chosen so that the per path configuration data is
2823 * assigned correctly.
2824 */
2825 if (test_bit(DASD_CQR_VERIFY_PATH, &erp->flags) && cqr->lpm) {
2826 erp->lpm = cqr->lpm;
2827 }
2828
Horst Hummel9575bf22006-12-08 15:54:15 +01002829 if (device->features & DASD_FEATURE_ERPLOG) {
2830 /* print current erp_chain */
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002831 dev_err(&device->cdev->dev,
2832 "ERP chain at END of ERP-ACTION\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07002833 for (temp_erp = erp;
2834 temp_erp != NULL; temp_erp = temp_erp->refers) {
2835
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002836 dev_err(&device->cdev->dev,
2837 "ERP %p (%02x) refers to %p\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838 temp_erp, temp_erp->status,
2839 temp_erp->refers);
2840 }
2841 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002842
Stefan Weinhuber8e09f212008-01-26 14:11:23 +01002843 /* enqueue ERP request if it's a new one */
2844 if (list_empty(&erp->blocklist)) {
2845 cqr->status = DASD_CQR_IN_ERP;
2846 /* add erp request before the cqr */
2847 list_add_tail(&erp->blocklist, &cqr->blocklist);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002848 }
2849
Stefan Haberlandfc19f382009-03-26 15:23:49 +01002850
2851
Linus Torvalds1da177e2005-04-16 15:20:36 -07002852 return erp;
2853
2854} /* end dasd_3990_erp_action */