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