spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / drivers / ide / ide-cd_verbose.c
blob6490a2dea96b01526657615ceb7139d9b1603a55
1 /*
2 * Verbose error logging for ATAPI CD/DVD devices.
4 * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov>
5 * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org>
6 * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de>
7 */
9 #include <linux/kernel.h>
10 #include <linux/blkdev.h>
11 #include <linux/cdrom.h>
12 #include <scsi/scsi.h>
14 #ifndef CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS
15 void ide_cd_log_error(const char *name, struct request *failed_command,
16 struct request_sense *sense)
18 /* Suppress printing unit attention and `in progress of becoming ready'
19 errors when we're not being verbose. */
20 if (sense->sense_key == UNIT_ATTENTION ||
21 (sense->sense_key == NOT_READY && (sense->asc == 4 ||
22 sense->asc == 0x3a)))
23 return;
25 printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x "
26 "asc: 0x%02x ascq: 0x%02x\n",
27 name, sense->error_code, sense->sense_key,
28 sense->asc, sense->ascq);
30 #else
31 /* The generic packet command opcodes for CD/DVD Logical Units,
32 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
33 static const struct {
34 unsigned short packet_command;
35 const char * const text;
36 } packet_command_texts[] = {
37 { GPCMD_TEST_UNIT_READY, "Test Unit Ready" },
38 { GPCMD_REQUEST_SENSE, "Request Sense" },
39 { GPCMD_FORMAT_UNIT, "Format Unit" },
40 { GPCMD_INQUIRY, "Inquiry" },
41 { GPCMD_START_STOP_UNIT, "Start/Stop Unit" },
42 { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" },
43 { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" },
44 { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" },
45 { GPCMD_READ_10, "Read 10" },
46 { GPCMD_WRITE_10, "Write 10" },
47 { GPCMD_SEEK, "Seek" },
48 { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" },
49 { GPCMD_VERIFY_10, "Verify 10" },
50 { GPCMD_FLUSH_CACHE, "Flush Cache" },
51 { GPCMD_READ_SUBCHANNEL, "Read Subchannel" },
52 { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" },
53 { GPCMD_READ_HEADER, "Read Header" },
54 { GPCMD_PLAY_AUDIO_10, "Play Audio 10" },
55 { GPCMD_GET_CONFIGURATION, "Get Configuration" },
56 { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" },
57 { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" },
58 { GPCMD_GET_EVENT_STATUS_NOTIFICATION,
59 "Get Event Status Notification" },
60 { GPCMD_PAUSE_RESUME, "Pause/Resume" },
61 { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" },
62 { GPCMD_READ_DISC_INFO, "Read Disc Info" },
63 { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" },
64 { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" },
65 { GPCMD_SEND_OPC, "Send OPC" },
66 { GPCMD_MODE_SELECT_10, "Mode Select 10" },
67 { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" },
68 { GPCMD_MODE_SENSE_10, "Mode Sense 10" },
69 { GPCMD_CLOSE_TRACK, "Close Track" },
70 { GPCMD_BLANK, "Blank" },
71 { GPCMD_SEND_EVENT, "Send Event" },
72 { GPCMD_SEND_KEY, "Send Key" },
73 { GPCMD_REPORT_KEY, "Report Key" },
74 { GPCMD_LOAD_UNLOAD, "Load/Unload" },
75 { GPCMD_SET_READ_AHEAD, "Set Read-ahead" },
76 { GPCMD_READ_12, "Read 12" },
77 { GPCMD_GET_PERFORMANCE, "Get Performance" },
78 { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" },
79 { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" },
80 { GPCMD_SET_STREAMING, "Set Streaming" },
81 { GPCMD_READ_CD_MSF, "Read CD MSF" },
82 { GPCMD_SCAN, "Scan" },
83 { GPCMD_SET_SPEED, "Set Speed" },
84 { GPCMD_PLAY_CD, "Play CD" },
85 { GPCMD_MECHANISM_STATUS, "Mechanism Status" },
86 { GPCMD_READ_CD, "Read CD" },
89 /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
90 static const char * const sense_key_texts[16] = {
91 "No sense data",
92 "Recovered error",
93 "Not ready",
94 "Medium error",
95 "Hardware error",
96 "Illegal request",
97 "Unit attention",
98 "Data protect",
99 "Blank check",
100 "(reserved)",
101 "(reserved)",
102 "Aborted command",
103 "(reserved)",
104 "(reserved)",
105 "Miscompare",
106 "(reserved)",
109 /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
110 static const struct {
111 unsigned long asc_ascq;
112 const char * const text;
113 } sense_data_texts[] = {
114 { 0x000000, "No additional sense information" },
115 { 0x000011, "Play operation in progress" },
116 { 0x000012, "Play operation paused" },
117 { 0x000013, "Play operation successfully completed" },
118 { 0x000014, "Play operation stopped due to error" },
119 { 0x000015, "No current audio status to return" },
120 { 0x010c0a, "Write error - padding blocks added" },
121 { 0x011700, "Recovered data with no error correction applied" },
122 { 0x011701, "Recovered data with retries" },
123 { 0x011702, "Recovered data with positive head offset" },
124 { 0x011703, "Recovered data with negative head offset" },
125 { 0x011704, "Recovered data with retries and/or CIRC applied" },
126 { 0x011705, "Recovered data using previous sector ID" },
127 { 0x011800, "Recovered data with error correction applied" },
128 { 0x011801, "Recovered data with error correction and retries applied"},
129 { 0x011802, "Recovered data - the data was auto-reallocated" },
130 { 0x011803, "Recovered data with CIRC" },
131 { 0x011804, "Recovered data with L-EC" },
132 { 0x015d00, "Failure prediction threshold exceeded"
133 " - Predicted logical unit failure" },
134 { 0x015d01, "Failure prediction threshold exceeded"
135 " - Predicted media failure" },
136 { 0x015dff, "Failure prediction threshold exceeded - False" },
137 { 0x017301, "Power calibration area almost full" },
138 { 0x020400, "Logical unit not ready - cause not reportable" },
139 /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */
140 { 0x020401, "Logical unit not ready"
141 " - in progress [sic] of becoming ready" },
142 { 0x020402, "Logical unit not ready - initializing command required" },
143 { 0x020403, "Logical unit not ready - manual intervention required" },
144 { 0x020404, "Logical unit not ready - format in progress" },
145 { 0x020407, "Logical unit not ready - operation in progress" },
146 { 0x020408, "Logical unit not ready - long write in progress" },
147 { 0x020600, "No reference position found (media may be upside down)" },
148 { 0x023000, "Incompatible medium installed" },
149 { 0x023a00, "Medium not present" },
150 { 0x025300, "Media load or eject failed" },
151 { 0x025700, "Unable to recover table of contents" },
152 { 0x030300, "Peripheral device write fault" },
153 { 0x030301, "No write current" },
154 { 0x030302, "Excessive write errors" },
155 { 0x030c00, "Write error" },
156 { 0x030c01, "Write error - Recovered with auto reallocation" },
157 { 0x030c02, "Write error - auto reallocation failed" },
158 { 0x030c03, "Write error - recommend reassignment" },
159 { 0x030c04, "Compression check miscompare error" },
160 { 0x030c05, "Data expansion occurred during compress" },
161 { 0x030c06, "Block not compressible" },
162 { 0x030c07, "Write error - recovery needed" },
163 { 0x030c08, "Write error - recovery failed" },
164 { 0x030c09, "Write error - loss of streaming" },
165 { 0x031100, "Unrecovered read error" },
166 { 0x031106, "CIRC unrecovered error" },
167 { 0x033101, "Format command failed" },
168 { 0x033200, "No defect spare location available" },
169 { 0x033201, "Defect list update failure" },
170 { 0x035100, "Erase failure" },
171 { 0x037200, "Session fixation error" },
172 { 0x037201, "Session fixation error writin lead-in" },
173 { 0x037202, "Session fixation error writin lead-out" },
174 { 0x037300, "CD control error" },
175 { 0x037302, "Power calibration area is full" },
176 { 0x037303, "Power calibration area error" },
177 { 0x037304, "Program memory area / RMA update failure" },
178 { 0x037305, "Program memory area / RMA is full" },
179 { 0x037306, "Program memory area / RMA is (almost) full" },
180 { 0x040200, "No seek complete" },
181 { 0x040300, "Write fault" },
182 { 0x040900, "Track following error" },
183 { 0x040901, "Tracking servo failure" },
184 { 0x040902, "Focus servo failure" },
185 { 0x040903, "Spindle servo failure" },
186 { 0x041500, "Random positioning error" },
187 { 0x041501, "Mechanical positioning or changer error" },
188 { 0x041502, "Positioning error detected by read of medium" },
189 { 0x043c00, "Mechanical positioning or changer error" },
190 { 0x044000, "Diagnostic failure on component (ASCQ)" },
191 { 0x044400, "Internal CD/DVD logical unit failure" },
192 { 0x04b600, "Media load mechanism failed" },
193 { 0x051a00, "Parameter list length error" },
194 { 0x052000, "Invalid command operation code" },
195 { 0x052100, "Logical block address out of range" },
196 { 0x052102, "Invalid address for write" },
197 { 0x052400, "Invalid field in command packet" },
198 { 0x052600, "Invalid field in parameter list" },
199 { 0x052601, "Parameter not supported" },
200 { 0x052602, "Parameter value invalid" },
201 { 0x052700, "Write protected media" },
202 { 0x052c00, "Command sequence error" },
203 { 0x052c03, "Current program area is not empty" },
204 { 0x052c04, "Current program area is empty" },
205 { 0x053001, "Cannot read medium - unknown format" },
206 { 0x053002, "Cannot read medium - incompatible format" },
207 { 0x053900, "Saving parameters not supported" },
208 { 0x054e00, "Overlapped commands attempted" },
209 { 0x055302, "Medium removal prevented" },
210 { 0x055500, "System resource failure" },
211 { 0x056300, "End of user area encountered on this track" },
212 { 0x056400, "Illegal mode for this track or incompatible medium" },
213 { 0x056f00, "Copy protection key exchange failure"
214 " - Authentication failure" },
215 { 0x056f01, "Copy protection key exchange failure - Key not present" },
216 { 0x056f02, "Copy protection key exchange failure"
217 " - Key not established" },
218 { 0x056f03, "Read of scrambled sector without authentication" },
219 { 0x056f04, "Media region code is mismatched to logical unit" },
220 { 0x056f05, "Drive region must be permanent"
221 " / region reset count error" },
222 { 0x057203, "Session fixation error - incomplete track in session" },
223 { 0x057204, "Empty or partially written reserved track" },
224 { 0x057205, "No more RZONE reservations are allowed" },
225 { 0x05bf00, "Loss of streaming" },
226 { 0x062800, "Not ready to ready transition, medium may have changed" },
227 { 0x062900, "Power on, reset or hardware reset occurred" },
228 { 0x062a00, "Parameters changed" },
229 { 0x062a01, "Mode parameters changed" },
230 { 0x062e00, "Insufficient time for operation" },
231 { 0x063f00, "Logical unit operating conditions have changed" },
232 { 0x063f01, "Microcode has been changed" },
233 { 0x065a00, "Operator request or state change input (unspecified)" },
234 { 0x065a01, "Operator medium removal request" },
235 { 0x0bb900, "Play operation aborted" },
236 /* Here we use 0xff for the key (not a valid key) to signify
237 * that these can have _any_ key value associated with them... */
238 { 0xff0401, "Logical unit is in process of becoming ready" },
239 { 0xff0400, "Logical unit not ready, cause not reportable" },
240 { 0xff0402, "Logical unit not ready, initializing command required" },
241 { 0xff0403, "Logical unit not ready, manual intervention required" },
242 { 0xff0500, "Logical unit does not respond to selection" },
243 { 0xff0800, "Logical unit communication failure" },
244 { 0xff0802, "Logical unit communication parity error" },
245 { 0xff0801, "Logical unit communication time-out" },
246 { 0xff2500, "Logical unit not supported" },
247 { 0xff4c00, "Logical unit failed self-configuration" },
248 { 0xff3e00, "Logical unit has not self-configured yet" },
251 void ide_cd_log_error(const char *name, struct request *failed_command,
252 struct request_sense *sense)
254 int i;
255 const char *s = "bad sense key!";
256 char buf[80];
258 printk(KERN_ERR "ATAPI device %s:\n", name);
259 if (sense->error_code == 0x70)
260 printk(KERN_CONT " Error: ");
261 else if (sense->error_code == 0x71)
262 printk(" Deferred Error: ");
263 else if (sense->error_code == 0x7f)
264 printk(KERN_CONT " Vendor-specific Error: ");
265 else
266 printk(KERN_CONT " Unknown Error Type: ");
268 if (sense->sense_key < ARRAY_SIZE(sense_key_texts))
269 s = sense_key_texts[sense->sense_key];
271 printk(KERN_CONT "%s -- (Sense key=0x%02x)\n", s, sense->sense_key);
273 if (sense->asc == 0x40) {
274 sprintf(buf, "Diagnostic failure on component 0x%02x",
275 sense->ascq);
276 s = buf;
277 } else {
278 int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts);
279 unsigned long key = (sense->sense_key << 16);
281 key |= (sense->asc << 8);
282 if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd))
283 key |= sense->ascq;
284 s = NULL;
286 while (hi > lo) {
287 mid = (lo + hi) / 2;
288 if (sense_data_texts[mid].asc_ascq == key ||
289 sense_data_texts[mid].asc_ascq == (0xff0000|key)) {
290 s = sense_data_texts[mid].text;
291 break;
292 } else if (sense_data_texts[mid].asc_ascq > key)
293 hi = mid;
294 else
295 lo = mid + 1;
299 if (s == NULL) {
300 if (sense->asc > 0x80)
301 s = "(vendor-specific error)";
302 else
303 s = "(reserved error code)";
306 printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n",
307 s, sense->asc, sense->ascq);
309 if (failed_command != NULL) {
310 int lo = 0, mid, hi = ARRAY_SIZE(packet_command_texts);
311 s = NULL;
313 while (hi > lo) {
314 mid = (lo + hi) / 2;
315 if (packet_command_texts[mid].packet_command ==
316 failed_command->cmd[0]) {
317 s = packet_command_texts[mid].text;
318 break;
320 if (packet_command_texts[mid].packet_command >
321 failed_command->cmd[0])
322 hi = mid;
323 else
324 lo = mid + 1;
327 printk(KERN_ERR " The failed \"%s\" packet command "
328 "was: \n \"", s);
329 for (i = 0; i < BLK_MAX_CDB; i++)
330 printk(KERN_CONT "%02x ", failed_command->cmd[i]);
331 printk(KERN_CONT "\"\n");
334 /* The SKSV bit specifies validity of the sense_key_specific
335 * in the next two commands. It is bit 7 of the first byte.
336 * In the case of NOT_READY, if SKSV is set the drive can
337 * give us nice ETA readings.
339 if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) {
340 int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100;
342 printk(KERN_ERR " Command is %02d%% complete\n",
343 progress / 0xffff);
346 if (sense->sense_key == ILLEGAL_REQUEST &&
347 (sense->sks[0] & 0x80) != 0) {
348 printk(KERN_ERR " Error in %s byte %d",
349 (sense->sks[0] & 0x40) != 0 ?
350 "command packet" : "command data",
351 (sense->sks[1] << 8) + sense->sks[2]);
353 if ((sense->sks[0] & 0x40) != 0)
354 printk(KERN_CONT " bit %d", sense->sks[0] & 0x07);
356 printk(KERN_CONT "\n");
359 #endif