diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 1240 |
1 files changed, 192 insertions, 1048 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 5aef63acf1e8..bf40d8c824ad 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -1,424 +1,18 @@ | |||
1 | /* | 1 | /* |
2 | * IDE ATAPI streaming tape driver. | ||
3 | * | ||
2 | * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> | 4 | * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> |
3 | * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz | 5 | * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz |
4 | * | 6 | * |
5 | * $Header$ | ||
6 | * | ||
7 | * This driver was constructed as a student project in the software laboratory | 7 | * This driver was constructed as a student project in the software laboratory |
8 | * of the faculty of electrical engineering in the Technion - Israel's | 8 | * of the faculty of electrical engineering in the Technion - Israel's |
9 | * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. | 9 | * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. |
10 | * | 10 | * |
11 | * It is hereby placed under the terms of the GNU general public license. | 11 | * It is hereby placed under the terms of the GNU general public license. |
12 | * (See linux/COPYING). | 12 | * (See linux/COPYING). |
13 | */ | ||
14 | |||
15 | /* | ||
16 | * IDE ATAPI streaming tape driver. | ||
17 | * | ||
18 | * This driver is a part of the Linux ide driver and works in co-operation | ||
19 | * with linux/drivers/block/ide.c. | ||
20 | * | ||
21 | * The driver, in co-operation with ide.c, basically traverses the | ||
22 | * request-list for the block device interface. The character device | ||
23 | * interface, on the other hand, creates new requests, adds them | ||
24 | * to the request-list of the block device, and waits for their completion. | ||
25 | * | ||
26 | * Pipelined operation mode is now supported on both reads and writes. | ||
27 | * | ||
28 | * The block device major and minor numbers are determined from the | ||
29 | * tape's relative position in the ide interfaces, as explained in ide.c. | ||
30 | * | ||
31 | * The character device interface consists of the following devices: | ||
32 | * | ||
33 | * ht0 major 37, minor 0 first IDE tape, rewind on close. | ||
34 | * ht1 major 37, minor 1 second IDE tape, rewind on close. | ||
35 | * ... | ||
36 | * nht0 major 37, minor 128 first IDE tape, no rewind on close. | ||
37 | * nht1 major 37, minor 129 second IDE tape, no rewind on close. | ||
38 | * ... | ||
39 | * | ||
40 | * Run linux/scripts/MAKEDEV.ide to create the above entries. | ||
41 | * | ||
42 | * The general magnetic tape commands compatible interface, as defined by | ||
43 | * include/linux/mtio.h, is accessible through the character device. | ||
44 | * | ||
45 | * General ide driver configuration options, such as the interrupt-unmask | ||
46 | * flag, can be configured by issuing an ioctl to the block device interface, | ||
47 | * as any other ide device. | ||
48 | * | ||
49 | * Our own ide-tape ioctl's can be issued to either the block device or | ||
50 | * the character device interface. | ||
51 | * | ||
52 | * Maximal throughput with minimal bus load will usually be achieved in the | ||
53 | * following scenario: | ||
54 | * | ||
55 | * 1. ide-tape is operating in the pipelined operation mode. | ||
56 | * 2. No buffering is performed by the user backup program. | ||
57 | * | ||
58 | * Testing was done with a 2 GB CONNER CTMA 4000 IDE ATAPI Streaming Tape Drive. | ||
59 | * | ||
60 | * Ver 0.1 Nov 1 95 Pre-working code :-) | ||
61 | * Ver 0.2 Nov 23 95 A short backup (few megabytes) and restore procedure | ||
62 | * was successful ! (Using tar cvf ... on the block | ||
63 | * device interface). | ||
64 | * A longer backup resulted in major swapping, bad | ||
65 | * overall Linux performance and eventually failed as | ||
66 | * we received non serial read-ahead requests from the | ||
67 | * buffer cache. | ||
68 | * Ver 0.3 Nov 28 95 Long backups are now possible, thanks to the | ||
69 | * character device interface. Linux's responsiveness | ||
70 | * and performance doesn't seem to be much affected | ||
71 | * from the background backup procedure. | ||
72 | * Some general mtio.h magnetic tape operations are | ||
73 | * now supported by our character device. As a result, | ||
74 | * popular tape utilities are starting to work with | ||
75 | * ide tapes :-) | ||
76 | * The following configurations were tested: | ||
77 | * 1. An IDE ATAPI TAPE shares the same interface | ||
78 | * and irq with an IDE ATAPI CDROM. | ||
79 | * 2. An IDE ATAPI TAPE shares the same interface | ||
80 | * and irq with a normal IDE disk. | ||
81 | * Both configurations seemed to work just fine ! | ||
82 | * However, to be on the safe side, it is meanwhile | ||
83 | * recommended to give the IDE TAPE its own interface | ||
84 | * and irq. | ||
85 | * The one thing which needs to be done here is to | ||
86 | * add a "request postpone" feature to ide.c, | ||
87 | * so that we won't have to wait for the tape to finish | ||
88 | * performing a long media access (DSC) request (such | ||
89 | * as a rewind) before we can access the other device | ||
90 | * on the same interface. This effect doesn't disturb | ||
91 | * normal operation most of the time because read/write | ||
92 | * requests are relatively fast, and once we are | ||
93 | * performing one tape r/w request, a lot of requests | ||
94 | * from the other device can be queued and ide.c will | ||
95 | * service all of them after this single tape request. | ||
96 | * Ver 1.0 Dec 11 95 Integrated into Linux 1.3.46 development tree. | ||
97 | * On each read / write request, we now ask the drive | ||
98 | * if we can transfer a constant number of bytes | ||
99 | * (a parameter of the drive) only to its buffers, | ||
100 | * without causing actual media access. If we can't, | ||
101 | * we just wait until we can by polling the DSC bit. | ||
102 | * This ensures that while we are not transferring | ||
103 | * more bytes than the constant referred to above, the | ||
104 | * interrupt latency will not become too high and | ||
105 | * we won't cause an interrupt timeout, as happened | ||
106 | * occasionally in the previous version. | ||
107 | * While polling for DSC, the current request is | ||
108 | * postponed and ide.c is free to handle requests from | ||
109 | * the other device. This is handled transparently to | ||
110 | * ide.c. The hwgroup locking method which was used | ||
111 | * in the previous version was removed. | ||
112 | * Use of new general features which are provided by | ||
113 | * ide.c for use with atapi devices. | ||
114 | * (Programming done by Mark Lord) | ||
115 | * Few potential bug fixes (Again, suggested by Mark) | ||
116 | * Single character device data transfers are now | ||
117 | * not limited in size, as they were before. | ||
118 | * We are asking the tape about its recommended | ||
119 | * transfer unit and send a larger data transfer | ||
120 | * as several transfers of the above size. | ||
121 | * For best results, use an integral number of this | ||
122 | * basic unit (which is shown during driver | ||
123 | * initialization). I will soon add an ioctl to get | ||
124 | * this important parameter. | ||
125 | * Our data transfer buffer is allocated on startup, | ||
126 | * rather than before each data transfer. This should | ||
127 | * ensure that we will indeed have a data buffer. | ||
128 | * Ver 1.1 Dec 14 95 Fixed random problems which occurred when the tape | ||
129 | * shared an interface with another device. | ||
130 | * (poll_for_dsc was a complete mess). | ||
131 | * Removed some old (non-active) code which had | ||
132 | * to do with supporting buffer cache originated | ||
133 | * requests. | ||
134 | * The block device interface can now be opened, so | ||
135 | * that general ide driver features like the unmask | ||
136 | * interrupts flag can be selected with an ioctl. | ||
137 | * This is the only use of the block device interface. | ||
138 | * New fast pipelined operation mode (currently only on | ||
139 | * writes). When using the pipelined mode, the | ||
140 | * throughput can potentially reach the maximum | ||
141 | * tape supported throughput, regardless of the | ||
142 | * user backup program. On my tape drive, it sometimes | ||
143 | * boosted performance by a factor of 2. Pipelined | ||
144 | * mode is enabled by default, but since it has a few | ||
145 | * downfalls as well, you may want to disable it. | ||
146 | * A short explanation of the pipelined operation mode | ||
147 | * is available below. | ||
148 | * Ver 1.2 Jan 1 96 Eliminated pipelined mode race condition. | ||
149 | * Added pipeline read mode. As a result, restores | ||
150 | * are now as fast as backups. | ||
151 | * Optimized shared interface behavior. The new behavior | ||
152 | * typically results in better IDE bus efficiency and | ||
153 | * higher tape throughput. | ||
154 | * Pre-calculation of the expected read/write request | ||
155 | * service time, based on the tape's parameters. In | ||
156 | * the pipelined operation mode, this allows us to | ||
157 | * adjust our polling frequency to a much lower value, | ||
158 | * and thus to dramatically reduce our load on Linux, | ||
159 | * without any decrease in performance. | ||
160 | * Implemented additional mtio.h operations. | ||
161 | * The recommended user block size is returned by | ||
162 | * the MTIOCGET ioctl. | ||
163 | * Additional minor changes. | ||
164 | * Ver 1.3 Feb 9 96 Fixed pipelined read mode bug which prevented the | ||
165 | * use of some block sizes during a restore procedure. | ||
166 | * The character device interface will now present a | ||
167 | * continuous view of the media - any mix of block sizes | ||
168 | * during a backup/restore procedure is supported. The | ||
169 | * driver will buffer the requests internally and | ||
170 | * convert them to the tape's recommended transfer | ||
171 | * unit, making performance almost independent of the | ||
172 | * chosen user block size. | ||
173 | * Some improvements in error recovery. | ||
174 | * By cooperating with ide-dma.c, bus mastering DMA can | ||
175 | * now sometimes be used with IDE tape drives as well. | ||
176 | * Bus mastering DMA has the potential to dramatically | ||
177 | * reduce the CPU's overhead when accessing the device, | ||
178 | * and can be enabled by using hdparm -d1 on the tape's | ||
179 | * block device interface. For more info, read the | ||
180 | * comments in ide-dma.c. | ||
181 | * Ver 1.4 Mar 13 96 Fixed serialize support. | ||
182 | * Ver 1.5 Apr 12 96 Fixed shared interface operation, broken in 1.3.85. | ||
183 | * Fixed pipelined read mode inefficiency. | ||
184 | * Fixed nasty null dereferencing bug. | ||
185 | * Ver 1.6 Aug 16 96 Fixed FPU usage in the driver. | ||
186 | * Fixed end of media bug. | ||
187 | * Ver 1.7 Sep 10 96 Minor changes for the CONNER CTT8000-A model. | ||
188 | * Ver 1.8 Sep 26 96 Attempt to find a better balance between good | ||
189 | * interactive response and high system throughput. | ||
190 | * Ver 1.9 Nov 5 96 Automatically cross encountered filemarks rather | ||
191 | * than requiring an explicit FSF command. | ||
192 | * Abort pending requests at end of media. | ||
193 | * MTTELL was sometimes returning incorrect results. | ||
194 | * Return the real block size in the MTIOCGET ioctl. | ||
195 | * Some error recovery bug fixes. | ||
196 | * Ver 1.10 Nov 5 96 Major reorganization. | ||
197 | * Reduced CPU overhead a bit by eliminating internal | ||
198 | * bounce buffers. | ||
199 | * Added module support. | ||
200 | * Added multiple tape drives support. | ||
201 | * Added partition support. | ||
202 | * Rewrote DSC handling. | ||
203 | * Some portability fixes. | ||
204 | * Removed ide-tape.h. | ||
205 | * Additional minor changes. | ||
206 | * Ver 1.11 Dec 2 96 Bug fix in previous DSC timeout handling. | ||
207 | * Use ide_stall_queue() for DSC overlap. | ||
208 | * Use the maximum speed rather than the current speed | ||
209 | * to compute the request service time. | ||
210 | * Ver 1.12 Dec 7 97 Fix random memory overwriting and/or last block data | ||
211 | * corruption, which could occur if the total number | ||
212 | * of bytes written to the tape was not an integral | ||
213 | * number of tape blocks. | ||
214 | * Add support for INTERRUPT DRQ devices. | ||
215 | * Ver 1.13 Jan 2 98 Add "speed == 0" work-around for HP COLORADO 5GB | ||
216 | * Ver 1.14 Dec 30 98 Partial fixes for the Sony/AIWA tape drives. | ||
217 | * Replace cli()/sti() with hwgroup spinlocks. | ||
218 | * Ver 1.15 Mar 25 99 Fix SMP race condition by replacing hwgroup | ||
219 | * spinlock with private per-tape spinlock. | ||
220 | * Ver 1.16 Sep 1 99 Add OnStream tape support. | ||
221 | * Abort read pipeline on EOD. | ||
222 | * Wait for the tape to become ready in case it returns | ||
223 | * "in the process of becoming ready" on open(). | ||
224 | * Fix zero padding of the last written block in | ||
225 | * case the tape block size is larger than PAGE_SIZE. | ||
226 | * Decrease the default disconnection time to tn. | ||
227 | * Ver 1.16e Oct 3 99 Minor fixes. | ||
228 | * Ver 1.16e1 Oct 13 99 Patches by Arnold Niessen, | ||
229 | * niessen@iae.nl / arnold.niessen@philips.com | ||
230 | * GO-1) Undefined code in idetape_read_position | ||
231 | * according to Gadi's email | ||
232 | * AJN-1) Minor fix asc == 11 should be asc == 0x11 | ||
233 | * in idetape_issue_packet_command (did effect | ||
234 | * debugging output only) | ||
235 | * AJN-2) Added more debugging output, and | ||
236 | * added ide-tape: where missing. I would also | ||
237 | * like to add tape->name where possible | ||
238 | * AJN-3) Added different debug_level's | ||
239 | * via /proc/ide/hdc/settings | ||
240 | * "debug_level" determines amount of debugging output; | ||
241 | * can be changed using /proc/ide/hdx/settings | ||
242 | * 0 : almost no debugging output | ||
243 | * 1 : 0+output errors only | ||
244 | * 2 : 1+output all sensekey/asc | ||
245 | * 3 : 2+follow all chrdev related procedures | ||
246 | * 4 : 3+follow all procedures | ||
247 | * 5 : 4+include pc_stack rq_stack info | ||
248 | * 6 : 5+USE_COUNT updates | ||
249 | * AJN-4) Fixed timeout for retension in idetape_queue_pc_tail | ||
250 | * from 5 to 10 minutes | ||
251 | * AJN-5) Changed maximum number of blocks to skip when | ||
252 | * reading tapes with multiple consecutive write | ||
253 | * errors from 100 to 1000 in idetape_get_logical_blk | ||
254 | * Proposed changes to code: | ||
255 | * 1) output "logical_blk_num" via /proc | ||
256 | * 2) output "current_operation" via /proc | ||
257 | * 3) Either solve or document the fact that `mt rewind' is | ||
258 | * required after reading from /dev/nhtx to be | ||
259 | * able to rmmod the idetape module; | ||
260 | * Also, sometimes an application finishes but the | ||
261 | * device remains `busy' for some time. Same cause ? | ||
262 | * Proposed changes to release-notes: | ||
263 | * 4) write a simple `quickstart' section in the | ||
264 | * release notes; I volunteer if you don't want to | ||
265 | * 5) include a pointer to video4linux in the doc | ||
266 | * to stimulate video applications | ||
267 | * 6) release notes lines 331 and 362: explain what happens | ||
268 | * if the application data rate is higher than 1100 KB/s; | ||
269 | * similar approach to lower-than-500 kB/s ? | ||
270 | * 7) 6.6 Comparison; wouldn't it be better to allow different | ||
271 | * strategies for read and write ? | ||
272 | * Wouldn't it be better to control the tape buffer | ||
273 | * contents instead of the bandwidth ? | ||
274 | * 8) line 536: replace will by would (if I understand | ||
275 | * this section correctly, a hypothetical and unwanted situation | ||
276 | * is being described) | ||
277 | * Ver 1.16f Dec 15 99 Change place of the secondary OnStream header frames. | ||
278 | * Ver 1.17 Nov 2000 / Jan 2001 Marcel Mol, marcel@mesa.nl | ||
279 | * - Add idetape_onstream_mode_sense_tape_parameter_page | ||
280 | * function to get tape capacity in frames: tape->capacity. | ||
281 | * - Add support for DI-50 drives( or any DI- drive). | ||
282 | * - 'workaround' for read error/blank block around block 3000. | ||
283 | * - Implement Early warning for end of media for Onstream. | ||
284 | * - Cosmetic code changes for readability. | ||
285 | * - Idetape_position_tape should not use SKIP bit during | ||
286 | * Onstream read recovery. | ||
287 | * - Add capacity, logical_blk_num and first/last_frame_position | ||
288 | * to /proc/ide/hd?/settings. | ||
289 | * - Module use count was gone in the Linux 2.4 driver. | ||
290 | * Ver 1.17a Apr 2001 Willem Riede osst@riede.org | ||
291 | * - Get drive's actual block size from mode sense block descriptor | ||
292 | * - Limit size of pipeline | ||
293 | * Ver 1.17b Oct 2002 Alan Stern <stern@rowland.harvard.edu> | ||
294 | * Changed IDETAPE_MIN_PIPELINE_STAGES to 1 and actually used | ||
295 | * it in the code! | ||
296 | * Actually removed aborted stages in idetape_abort_pipeline | ||
297 | * instead of just changing the command code. | ||
298 | * Made the transfer byte count for Request Sense equal to the | ||
299 | * actual length of the data transfer. | ||
300 | * Changed handling of partial data transfers: they do not | ||
301 | * cause DMA errors. | ||
302 | * Moved initiation of DMA transfers to the correct place. | ||
303 | * Removed reference to unallocated memory. | ||
304 | * Made __idetape_discard_read_pipeline return the number of | ||
305 | * sectors skipped, not the number of stages. | ||
306 | * Replaced errant kfree() calls with __idetape_kfree_stage(). | ||
307 | * Fixed off-by-one error in testing the pipeline length. | ||
308 | * Fixed handling of filemarks in the read pipeline. | ||
309 | * Small code optimization for MTBSF and MTBSFM ioctls. | ||
310 | * Don't try to unlock the door during device close if is | ||
311 | * already unlocked! | ||
312 | * Cosmetic fixes to miscellaneous debugging output messages. | ||
313 | * Set the minimum /proc/ide/hd?/settings values for "pipeline", | ||
314 | * "pipeline_min", and "pipeline_max" to 1. | ||
315 | * | ||
316 | * Here are some words from the first releases of hd.c, which are quoted | ||
317 | * in ide.c and apply here as well: | ||
318 | * | ||
319 | * | Special care is recommended. Have Fun! | ||
320 | * | 13 | * |
321 | */ | 14 | * For a historical changelog see |
322 | 15 | * Documentation/ide/ChangeLog.ide-tape.1995-2002 | |
323 | /* | ||
324 | * An overview of the pipelined operation mode. | ||
325 | * | ||
326 | * In the pipelined write mode, we will usually just add requests to our | ||
327 | * pipeline and return immediately, before we even start to service them. The | ||
328 | * user program will then have enough time to prepare the next request while | ||
329 | * we are still busy servicing previous requests. In the pipelined read mode, | ||
330 | * the situation is similar - we add read-ahead requests into the pipeline, | ||
331 | * before the user even requested them. | ||
332 | * | ||
333 | * The pipeline can be viewed as a "safety net" which will be activated when | ||
334 | * the system load is high and prevents the user backup program from keeping up | ||
335 | * with the current tape speed. At this point, the pipeline will get | ||
336 | * shorter and shorter but the tape will still be streaming at the same speed. | ||
337 | * Assuming we have enough pipeline stages, the system load will hopefully | ||
338 | * decrease before the pipeline is completely empty, and the backup program | ||
339 | * will be able to "catch up" and refill the pipeline again. | ||
340 | * | ||
341 | * When using the pipelined mode, it would be best to disable any type of | ||
342 | * buffering done by the user program, as ide-tape already provides all the | ||
343 | * benefits in the kernel, where it can be done in a more efficient way. | ||
344 | * As we will usually not block the user program on a request, the most | ||
345 | * efficient user code will then be a simple read-write-read-... cycle. | ||
346 | * Any additional logic will usually just slow down the backup process. | ||
347 | * | ||
348 | * Using the pipelined mode, I get a constant over 400 KBps throughput, | ||
349 | * which seems to be the maximum throughput supported by my tape. | ||
350 | * | ||
351 | * However, there are some downfalls: | ||
352 | * | ||
353 | * 1. We use memory (for data buffers) in proportional to the number | ||
354 | * of pipeline stages (each stage is about 26 KB with my tape). | ||
355 | * 2. In the pipelined write mode, we cheat and postpone error codes | ||
356 | * to the user task. In read mode, the actual tape position | ||
357 | * will be a bit further than the last requested block. | ||
358 | * | ||
359 | * Concerning (1): | ||
360 | * | ||
361 | * 1. We allocate stages dynamically only when we need them. When | ||
362 | * we don't need them, we don't consume additional memory. In | ||
363 | * case we can't allocate stages, we just manage without them | ||
364 | * (at the expense of decreased throughput) so when Linux is | ||
365 | * tight in memory, we will not pose additional difficulties. | ||
366 | * | ||
367 | * 2. The maximum number of stages (which is, in fact, the maximum | ||
368 | * amount of memory) which we allocate is limited by the compile | ||
369 | * time parameter IDETAPE_MAX_PIPELINE_STAGES. | ||
370 | * | ||
371 | * 3. The maximum number of stages is a controlled parameter - We | ||
372 | * don't start from the user defined maximum number of stages | ||
373 | * but from the lower IDETAPE_MIN_PIPELINE_STAGES (again, we | ||
374 | * will not even allocate this amount of stages if the user | ||
375 | * program can't handle the speed). We then implement a feedback | ||
376 | * loop which checks if the pipeline is empty, and if it is, we | ||
377 | * increase the maximum number of stages as necessary until we | ||
378 | * reach the optimum value which just manages to keep the tape | ||
379 | * busy with minimum allocated memory or until we reach | ||
380 | * IDETAPE_MAX_PIPELINE_STAGES. | ||
381 | * | ||
382 | * Concerning (2): | ||
383 | * | ||
384 | * In pipelined write mode, ide-tape can not return accurate error codes | ||
385 | * to the user program since we usually just add the request to the | ||
386 | * pipeline without waiting for it to be serviced. In case an error | ||
387 | * occurs, I will report it on the next user request. | ||
388 | * | ||
389 | * In the pipelined read mode, subsequent read requests or forward | ||
390 | * filemark spacing will perform correctly, as we preserve all blocks | ||
391 | * and filemarks which we encountered during our excess read-ahead. | ||
392 | * | ||
393 | * For accurate tape positioning and error reporting, disabling | ||
394 | * pipelined mode might be the best option. | ||
395 | * | ||
396 | * You can enable/disable/tune the pipelined operation mode by adjusting | ||
397 | * the compile time parameters below. | ||
398 | */ | ||
399 | |||
400 | /* | ||
401 | * Possible improvements. | ||
402 | * | ||
403 | * 1. Support for the ATAPI overlap protocol. | ||
404 | * | ||
405 | * In order to maximize bus throughput, we currently use the DSC | ||
406 | * overlap method which enables ide.c to service requests from the | ||
407 | * other device while the tape is busy executing a command. The | ||
408 | * DSC overlap method involves polling the tape's status register | ||
409 | * for the DSC bit, and servicing the other device while the tape | ||
410 | * isn't ready. | ||
411 | * | ||
412 | * In the current QIC development standard (December 1995), | ||
413 | * it is recommended that new tape drives will *in addition* | ||
414 | * implement the ATAPI overlap protocol, which is used for the | ||
415 | * same purpose - efficient use of the IDE bus, but is interrupt | ||
416 | * driven and thus has much less CPU overhead. | ||
417 | * | ||
418 | * ATAPI overlap is likely to be supported in most new ATAPI | ||
419 | * devices, including new ATAPI cdroms, and thus provides us | ||
420 | * a method by which we can achieve higher throughput when | ||
421 | * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. | ||
422 | */ | 16 | */ |
423 | 17 | ||
424 | #define IDETAPE_VERSION "1.19" | 18 | #define IDETAPE_VERSION "1.19" |
@@ -442,49 +36,13 @@ | |||
442 | #include <linux/completion.h> | 36 | #include <linux/completion.h> |
443 | #include <linux/bitops.h> | 37 | #include <linux/bitops.h> |
444 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | #include <scsi/scsi.h> | ||
445 | 40 | ||
446 | #include <asm/byteorder.h> | 41 | #include <asm/byteorder.h> |
447 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
448 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
449 | #include <asm/io.h> | 44 | #include <asm/io.h> |
450 | #include <asm/unaligned.h> | 45 | #include <asm/unaligned.h> |
451 | |||
452 | /* | ||
453 | * partition | ||
454 | */ | ||
455 | typedef struct os_partition_s { | ||
456 | __u8 partition_num; | ||
457 | __u8 par_desc_ver; | ||
458 | __u16 wrt_pass_cntr; | ||
459 | __u32 first_frame_addr; | ||
460 | __u32 last_frame_addr; | ||
461 | __u32 eod_frame_addr; | ||
462 | } os_partition_t; | ||
463 | |||
464 | /* | ||
465 | * DAT entry | ||
466 | */ | ||
467 | typedef struct os_dat_entry_s { | ||
468 | __u32 blk_sz; | ||
469 | __u16 blk_cnt; | ||
470 | __u8 flags; | ||
471 | __u8 reserved; | ||
472 | } os_dat_entry_t; | ||
473 | |||
474 | /* | ||
475 | * DAT | ||
476 | */ | ||
477 | #define OS_DAT_FLAGS_DATA (0xc) | ||
478 | #define OS_DAT_FLAGS_MARK (0x1) | ||
479 | |||
480 | typedef struct os_dat_s { | ||
481 | __u8 dat_sz; | ||
482 | __u8 reserved1; | ||
483 | __u8 entry_cnt; | ||
484 | __u8 reserved3; | ||
485 | os_dat_entry_t dat_list[16]; | ||
486 | } os_dat_t; | ||
487 | |||
488 | #include <linux/mtio.h> | 46 | #include <linux/mtio.h> |
489 | 47 | ||
490 | /**************************** Tunable parameters *****************************/ | 48 | /**************************** Tunable parameters *****************************/ |
@@ -512,10 +70,7 @@ typedef struct os_dat_s { | |||
512 | /* | 70 | /* |
513 | * The following are used to debug the driver: | 71 | * The following are used to debug the driver: |
514 | * | 72 | * |
515 | * Setting IDETAPE_DEBUG_INFO to 1 will report device capabilities. | ||
516 | * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control. | 73 | * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control. |
517 | * Setting IDETAPE_DEBUG_BUGS to 1 will enable self-sanity checks in | ||
518 | * some places. | ||
519 | * | 74 | * |
520 | * Setting them to 0 will restore normal operation mode: | 75 | * Setting them to 0 will restore normal operation mode: |
521 | * | 76 | * |
@@ -527,9 +82,7 @@ typedef struct os_dat_s { | |||
527 | * is verified to be stable enough. This will make it much more | 82 | * is verified to be stable enough. This will make it much more |
528 | * esthetic. | 83 | * esthetic. |
529 | */ | 84 | */ |
530 | #define IDETAPE_DEBUG_INFO 0 | ||
531 | #define IDETAPE_DEBUG_LOG 0 | 85 | #define IDETAPE_DEBUG_LOG 0 |
532 | #define IDETAPE_DEBUG_BUGS 1 | ||
533 | 86 | ||
534 | /* | 87 | /* |
535 | * After each failed packet command we issue a request sense command | 88 | * After each failed packet command we issue a request sense command |
@@ -671,65 +224,6 @@ typedef struct idetape_packet_command_s { | |||
671 | #define PC_WRITING 5 | 224 | #define PC_WRITING 5 |
672 | 225 | ||
673 | /* | 226 | /* |
674 | * Capabilities and Mechanical Status Page | ||
675 | */ | ||
676 | typedef struct { | ||
677 | unsigned page_code :6; /* Page code - Should be 0x2a */ | ||
678 | __u8 reserved0_6 :1; | ||
679 | __u8 ps :1; /* parameters saveable */ | ||
680 | __u8 page_length; /* Page Length - Should be 0x12 */ | ||
681 | __u8 reserved2, reserved3; | ||
682 | unsigned ro :1; /* Read Only Mode */ | ||
683 | unsigned reserved4_1234 :4; | ||
684 | unsigned sprev :1; /* Supports SPACE in the reverse direction */ | ||
685 | unsigned reserved4_67 :2; | ||
686 | unsigned reserved5_012 :3; | ||
687 | unsigned efmt :1; /* Supports ERASE command initiated formatting */ | ||
688 | unsigned reserved5_4 :1; | ||
689 | unsigned qfa :1; /* Supports the QFA two partition formats */ | ||
690 | unsigned reserved5_67 :2; | ||
691 | unsigned lock :1; /* Supports locking the volume */ | ||
692 | unsigned locked :1; /* The volume is locked */ | ||
693 | unsigned prevent :1; /* The device defaults in the prevent state after power up */ | ||
694 | unsigned eject :1; /* The device can eject the volume */ | ||
695 | __u8 disconnect :1; /* The device can break request > ctl */ | ||
696 | __u8 reserved6_5 :1; | ||
697 | unsigned ecc :1; /* Supports error correction */ | ||
698 | unsigned cmprs :1; /* Supports data compression */ | ||
699 | unsigned reserved7_0 :1; | ||
700 | unsigned blk512 :1; /* Supports 512 bytes block size */ | ||
701 | unsigned blk1024 :1; /* Supports 1024 bytes block size */ | ||
702 | unsigned reserved7_3_6 :4; | ||
703 | unsigned blk32768 :1; /* slowb - the device restricts the byte count for PIO */ | ||
704 | /* transfers for slow buffer memory ??? */ | ||
705 | /* Also 32768 block size in some cases */ | ||
706 | __u16 max_speed; /* Maximum speed supported in KBps */ | ||
707 | __u8 reserved10, reserved11; | ||
708 | __u16 ctl; /* Continuous Transfer Limit in blocks */ | ||
709 | __u16 speed; /* Current Speed, in KBps */ | ||
710 | __u16 buffer_size; /* Buffer Size, in 512 bytes */ | ||
711 | __u8 reserved18, reserved19; | ||
712 | } idetape_capabilities_page_t; | ||
713 | |||
714 | /* | ||
715 | * Block Size Page | ||
716 | */ | ||
717 | typedef struct { | ||
718 | unsigned page_code :6; /* Page code - Should be 0x30 */ | ||
719 | unsigned reserved1_6 :1; | ||
720 | unsigned ps :1; | ||
721 | __u8 page_length; /* Page Length - Should be 2 */ | ||
722 | __u8 reserved2; | ||
723 | unsigned play32 :1; | ||
724 | unsigned play32_5 :1; | ||
725 | unsigned reserved2_23 :2; | ||
726 | unsigned record32 :1; | ||
727 | unsigned record32_5 :1; | ||
728 | unsigned reserved2_6 :1; | ||
729 | unsigned one :1; | ||
730 | } idetape_block_size_page_t; | ||
731 | |||
732 | /* | ||
733 | * A pipeline stage. | 227 | * A pipeline stage. |
734 | */ | 228 | */ |
735 | typedef struct idetape_stage_s { | 229 | typedef struct idetape_stage_s { |
@@ -739,32 +233,6 @@ typedef struct idetape_stage_s { | |||
739 | } idetape_stage_t; | 233 | } idetape_stage_t; |
740 | 234 | ||
741 | /* | 235 | /* |
742 | * REQUEST SENSE packet command result - Data Format. | ||
743 | */ | ||
744 | typedef struct { | ||
745 | unsigned error_code :7; /* Current of deferred errors */ | ||
746 | unsigned valid :1; /* The information field conforms to QIC-157C */ | ||
747 | __u8 reserved1 :8; /* Segment Number - Reserved */ | ||
748 | unsigned sense_key :4; /* Sense Key */ | ||
749 | unsigned reserved2_4 :1; /* Reserved */ | ||
750 | unsigned ili :1; /* Incorrect Length Indicator */ | ||
751 | unsigned eom :1; /* End Of Medium */ | ||
752 | unsigned filemark :1; /* Filemark */ | ||
753 | __u32 information __attribute__ ((packed)); | ||
754 | __u8 asl; /* Additional sense length (n-7) */ | ||
755 | __u32 command_specific; /* Additional command specific information */ | ||
756 | __u8 asc; /* Additional Sense Code */ | ||
757 | __u8 ascq; /* Additional Sense Code Qualifier */ | ||
758 | __u8 replaceable_unit_code; /* Field Replaceable Unit Code */ | ||
759 | unsigned sk_specific1 :7; /* Sense Key Specific */ | ||
760 | unsigned sksv :1; /* Sense Key Specific information is valid */ | ||
761 | __u8 sk_specific2; /* Sense Key Specific */ | ||
762 | __u8 sk_specific3; /* Sense Key Specific */ | ||
763 | __u8 pad[2]; /* Padding to 20 bytes */ | ||
764 | } idetape_request_sense_result_t; | ||
765 | |||
766 | |||
767 | /* | ||
768 | * Most of our global data which we need to save even as we leave the | 236 | * Most of our global data which we need to save even as we leave the |
769 | * driver due to an interrupt or a timer event is stored in a variable | 237 | * driver due to an interrupt or a timer event is stored in a variable |
770 | * of type idetape_tape_t, defined below. | 238 | * of type idetape_tape_t, defined below. |
@@ -854,8 +322,9 @@ typedef struct ide_tape_obj { | |||
854 | /* Usually 512 or 1024 bytes */ | 322 | /* Usually 512 or 1024 bytes */ |
855 | unsigned short tape_block_size; | 323 | unsigned short tape_block_size; |
856 | int user_bs_factor; | 324 | int user_bs_factor; |
325 | |||
857 | /* Copy of the tape's Capabilities and Mechanical Page */ | 326 | /* Copy of the tape's Capabilities and Mechanical Page */ |
858 | idetape_capabilities_page_t capabilities; | 327 | u8 caps[20]; |
859 | 328 | ||
860 | /* | 329 | /* |
861 | * Active data transfer request parameters. | 330 | * Active data transfer request parameters. |
@@ -918,9 +387,6 @@ typedef struct ide_tape_obj { | |||
918 | int avg_size; | 387 | int avg_size; |
919 | int avg_speed; | 388 | int avg_speed; |
920 | 389 | ||
921 | /* last sense information */ | ||
922 | idetape_request_sense_result_t sense; | ||
923 | |||
924 | char vendor_id[10]; | 390 | char vendor_id[10]; |
925 | char product_id[18]; | 391 | char product_id[18]; |
926 | char firmware_revision[6]; | 392 | char firmware_revision[6]; |
@@ -1052,27 +518,6 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
1052 | #define IDETAPE_MEDIUM_PRESENT 9 | 518 | #define IDETAPE_MEDIUM_PRESENT 9 |
1053 | 519 | ||
1054 | /* | 520 | /* |
1055 | * Supported ATAPI tape drives packet commands | ||
1056 | */ | ||
1057 | #define IDETAPE_TEST_UNIT_READY_CMD 0x00 | ||
1058 | #define IDETAPE_REWIND_CMD 0x01 | ||
1059 | #define IDETAPE_REQUEST_SENSE_CMD 0x03 | ||
1060 | #define IDETAPE_READ_CMD 0x08 | ||
1061 | #define IDETAPE_WRITE_CMD 0x0a | ||
1062 | #define IDETAPE_WRITE_FILEMARK_CMD 0x10 | ||
1063 | #define IDETAPE_SPACE_CMD 0x11 | ||
1064 | #define IDETAPE_INQUIRY_CMD 0x12 | ||
1065 | #define IDETAPE_ERASE_CMD 0x19 | ||
1066 | #define IDETAPE_MODE_SENSE_CMD 0x1a | ||
1067 | #define IDETAPE_MODE_SELECT_CMD 0x15 | ||
1068 | #define IDETAPE_LOAD_UNLOAD_CMD 0x1b | ||
1069 | #define IDETAPE_PREVENT_CMD 0x1e | ||
1070 | #define IDETAPE_LOCATE_CMD 0x2b | ||
1071 | #define IDETAPE_READ_POSITION_CMD 0x34 | ||
1072 | #define IDETAPE_READ_BUFFER_CMD 0x3c | ||
1073 | #define IDETAPE_SET_SPEED_CMD 0xbb | ||
1074 | |||
1075 | /* | ||
1076 | * Some defines for the READ BUFFER command | 521 | * Some defines for the READ BUFFER command |
1077 | */ | 522 | */ |
1078 | #define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 | 523 | #define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 |
@@ -1129,31 +574,6 @@ struct idetape_id_gcw { | |||
1129 | }; | 574 | }; |
1130 | 575 | ||
1131 | /* | 576 | /* |
1132 | * INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C) | ||
1133 | */ | ||
1134 | typedef struct { | ||
1135 | unsigned device_type :5; /* Peripheral Device Type */ | ||
1136 | unsigned reserved0_765 :3; /* Peripheral Qualifier - Reserved */ | ||
1137 | unsigned reserved1_6t0 :7; /* Reserved */ | ||
1138 | unsigned rmb :1; /* Removable Medium Bit */ | ||
1139 | unsigned ansi_version :3; /* ANSI Version */ | ||
1140 | unsigned ecma_version :3; /* ECMA Version */ | ||
1141 | unsigned iso_version :2; /* ISO Version */ | ||
1142 | unsigned response_format :4; /* Response Data Format */ | ||
1143 | unsigned reserved3_45 :2; /* Reserved */ | ||
1144 | unsigned reserved3_6 :1; /* TrmIOP - Reserved */ | ||
1145 | unsigned reserved3_7 :1; /* AENC - Reserved */ | ||
1146 | __u8 additional_length; /* Additional Length (total_length-4) */ | ||
1147 | __u8 rsv5, rsv6, rsv7; /* Reserved */ | ||
1148 | __u8 vendor_id[8]; /* Vendor Identification */ | ||
1149 | __u8 product_id[16]; /* Product Identification */ | ||
1150 | __u8 revision_level[4]; /* Revision Level */ | ||
1151 | __u8 vendor_specific[20]; /* Vendor Specific - Optional */ | ||
1152 | __u8 reserved56t95[40]; /* Reserved - Optional */ | ||
1153 | /* Additional information may be returned */ | ||
1154 | } idetape_inquiry_result_t; | ||
1155 | |||
1156 | /* | ||
1157 | * READ POSITION packet command - Data Format (From Table 6-57) | 577 | * READ POSITION packet command - Data Format (From Table 6-57) |
1158 | */ | 578 | */ |
1159 | typedef struct { | 579 | typedef struct { |
@@ -1171,100 +591,9 @@ typedef struct { | |||
1171 | u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */ | 591 | u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */ |
1172 | } idetape_read_position_result_t; | 592 | } idetape_read_position_result_t; |
1173 | 593 | ||
1174 | /* | 594 | /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ |
1175 | * Follows structures which are related to the SELECT SENSE / MODE SENSE | ||
1176 | * packet commands. Those packet commands are still not supported | ||
1177 | * by ide-tape. | ||
1178 | */ | ||
1179 | #define IDETAPE_BLOCK_DESCRIPTOR 0 | 595 | #define IDETAPE_BLOCK_DESCRIPTOR 0 |
1180 | #define IDETAPE_CAPABILITIES_PAGE 0x2a | 596 | #define IDETAPE_CAPABILITIES_PAGE 0x2a |
1181 | #define IDETAPE_PARAMTR_PAGE 0x2b /* Onstream DI-x0 only */ | ||
1182 | #define IDETAPE_BLOCK_SIZE_PAGE 0x30 | ||
1183 | #define IDETAPE_BUFFER_FILLING_PAGE 0x33 | ||
1184 | |||
1185 | /* | ||
1186 | * Mode Parameter Header for the MODE SENSE packet command | ||
1187 | */ | ||
1188 | typedef struct { | ||
1189 | __u8 mode_data_length; /* Length of the following data transfer */ | ||
1190 | __u8 medium_type; /* Medium Type */ | ||
1191 | __u8 dsp; /* Device Specific Parameter */ | ||
1192 | __u8 bdl; /* Block Descriptor Length */ | ||
1193 | #if 0 | ||
1194 | /* data transfer page */ | ||
1195 | __u8 page_code :6; | ||
1196 | __u8 reserved0_6 :1; | ||
1197 | __u8 ps :1; /* parameters saveable */ | ||
1198 | __u8 page_length; /* page Length == 0x02 */ | ||
1199 | __u8 reserved2; | ||
1200 | __u8 read32k :1; /* 32k blk size (data only) */ | ||
1201 | __u8 read32k5 :1; /* 32.5k blk size (data&AUX) */ | ||
1202 | __u8 reserved3_23 :2; | ||
1203 | __u8 write32k :1; /* 32k blk size (data only) */ | ||
1204 | __u8 write32k5 :1; /* 32.5k blk size (data&AUX) */ | ||
1205 | __u8 reserved3_6 :1; | ||
1206 | __u8 streaming :1; /* streaming mode enable */ | ||
1207 | #endif | ||
1208 | } idetape_mode_parameter_header_t; | ||
1209 | |||
1210 | /* | ||
1211 | * Mode Parameter Block Descriptor the MODE SENSE packet command | ||
1212 | * | ||
1213 | * Support for block descriptors is optional. | ||
1214 | */ | ||
1215 | typedef struct { | ||
1216 | __u8 density_code; /* Medium density code */ | ||
1217 | __u8 blocks[3]; /* Number of blocks */ | ||
1218 | __u8 reserved4; /* Reserved */ | ||
1219 | __u8 length[3]; /* Block Length */ | ||
1220 | } idetape_parameter_block_descriptor_t; | ||
1221 | |||
1222 | /* | ||
1223 | * The Data Compression Page, as returned by the MODE SENSE packet command. | ||
1224 | */ | ||
1225 | typedef struct { | ||
1226 | unsigned page_code :6; /* Page Code - Should be 0xf */ | ||
1227 | unsigned reserved0 :1; /* Reserved */ | ||
1228 | unsigned ps :1; | ||
1229 | __u8 page_length; /* Page Length - Should be 14 */ | ||
1230 | unsigned reserved2 :6; /* Reserved */ | ||
1231 | unsigned dcc :1; /* Data Compression Capable */ | ||
1232 | unsigned dce :1; /* Data Compression Enable */ | ||
1233 | unsigned reserved3 :5; /* Reserved */ | ||
1234 | unsigned red :2; /* Report Exception on Decompression */ | ||
1235 | unsigned dde :1; /* Data Decompression Enable */ | ||
1236 | __u32 ca; /* Compression Algorithm */ | ||
1237 | __u32 da; /* Decompression Algorithm */ | ||
1238 | __u8 reserved[4]; /* Reserved */ | ||
1239 | } idetape_data_compression_page_t; | ||
1240 | |||
1241 | /* | ||
1242 | * The Medium Partition Page, as returned by the MODE SENSE packet command. | ||
1243 | */ | ||
1244 | typedef struct { | ||
1245 | unsigned page_code :6; /* Page Code - Should be 0x11 */ | ||
1246 | unsigned reserved1_6 :1; /* Reserved */ | ||
1247 | unsigned ps :1; | ||
1248 | __u8 page_length; /* Page Length - Should be 6 */ | ||
1249 | __u8 map; /* Maximum Additional Partitions - Should be 0 */ | ||
1250 | __u8 apd; /* Additional Partitions Defined - Should be 0 */ | ||
1251 | unsigned reserved4_012 :3; /* Reserved */ | ||
1252 | unsigned psum :2; /* Should be 0 */ | ||
1253 | unsigned idp :1; /* Should be 0 */ | ||
1254 | unsigned sdp :1; /* Should be 0 */ | ||
1255 | unsigned fdp :1; /* Fixed Data Partitions */ | ||
1256 | __u8 mfr; /* Medium Format Recognition */ | ||
1257 | __u8 reserved[2]; /* Reserved */ | ||
1258 | } idetape_medium_partition_page_t; | ||
1259 | |||
1260 | /* | ||
1261 | * Run time configurable parameters. | ||
1262 | */ | ||
1263 | typedef struct { | ||
1264 | int dsc_rw_frequency; | ||
1265 | int dsc_media_access_frequency; | ||
1266 | int nr_stages; | ||
1267 | } idetape_config_t; | ||
1268 | 597 | ||
1269 | /* | 598 | /* |
1270 | * The variables below are used for the character device interface. | 599 | * The variables below are used for the character device interface. |
@@ -1309,14 +638,12 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne | |||
1309 | int count; | 638 | int count; |
1310 | 639 | ||
1311 | while (bcount) { | 640 | while (bcount) { |
1312 | #if IDETAPE_DEBUG_BUGS | ||
1313 | if (bh == NULL) { | 641 | if (bh == NULL) { |
1314 | printk(KERN_ERR "ide-tape: bh == NULL in " | 642 | printk(KERN_ERR "ide-tape: bh == NULL in " |
1315 | "idetape_input_buffers\n"); | 643 | "idetape_input_buffers\n"); |
1316 | idetape_discard_data(drive, bcount); | 644 | idetape_discard_data(drive, bcount); |
1317 | return; | 645 | return; |
1318 | } | 646 | } |
1319 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
1320 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), bcount); | 647 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), bcount); |
1321 | HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count); | 648 | HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count); |
1322 | bcount -= count; | 649 | bcount -= count; |
@@ -1336,13 +663,11 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign | |||
1336 | int count; | 663 | int count; |
1337 | 664 | ||
1338 | while (bcount) { | 665 | while (bcount) { |
1339 | #if IDETAPE_DEBUG_BUGS | ||
1340 | if (bh == NULL) { | 666 | if (bh == NULL) { |
1341 | printk(KERN_ERR "ide-tape: bh == NULL in " | 667 | printk(KERN_ERR "ide-tape: bh == NULL in " |
1342 | "idetape_output_buffers\n"); | 668 | "idetape_output_buffers\n"); |
1343 | return; | 669 | return; |
1344 | } | 670 | } |
1345 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
1346 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); | 671 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); |
1347 | HWIF(drive)->atapi_output_bytes(drive, pc->b_data, count); | 672 | HWIF(drive)->atapi_output_bytes(drive, pc->b_data, count); |
1348 | bcount -= count; | 673 | bcount -= count; |
@@ -1367,13 +692,11 @@ static void idetape_update_buffers (idetape_pc_t *pc) | |||
1367 | if (test_bit(PC_WRITING, &pc->flags)) | 692 | if (test_bit(PC_WRITING, &pc->flags)) |
1368 | return; | 693 | return; |
1369 | while (bcount) { | 694 | while (bcount) { |
1370 | #if IDETAPE_DEBUG_BUGS | ||
1371 | if (bh == NULL) { | 695 | if (bh == NULL) { |
1372 | printk(KERN_ERR "ide-tape: bh == NULL in " | 696 | printk(KERN_ERR "ide-tape: bh == NULL in " |
1373 | "idetape_update_buffers\n"); | 697 | "idetape_update_buffers\n"); |
1374 | return; | 698 | return; |
1375 | } | 699 | } |
1376 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
1377 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); | 700 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); |
1378 | atomic_set(&bh->b_count, count); | 701 | atomic_set(&bh->b_count, count); |
1379 | if (atomic_read(&bh->b_count) == bh->b_size) | 702 | if (atomic_read(&bh->b_count) == bh->b_size) |
@@ -1446,36 +769,34 @@ static void idetape_init_pc (idetape_pc_t *pc) | |||
1446 | } | 769 | } |
1447 | 770 | ||
1448 | /* | 771 | /* |
1449 | * idetape_analyze_error is called on each failed packet command retry | 772 | * called on each failed packet command retry to analyze the request sense. We |
1450 | * to analyze the request sense. We currently do not utilize this | 773 | * currently do not utilize this information. |
1451 | * information. | ||
1452 | */ | 774 | */ |
1453 | static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_result_t *result) | 775 | static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) |
1454 | { | 776 | { |
1455 | idetape_tape_t *tape = drive->driver_data; | 777 | idetape_tape_t *tape = drive->driver_data; |
1456 | idetape_pc_t *pc = tape->failed_pc; | 778 | idetape_pc_t *pc = tape->failed_pc; |
1457 | 779 | ||
1458 | tape->sense = *result; | 780 | tape->sense_key = sense[2] & 0xF; |
1459 | tape->sense_key = result->sense_key; | 781 | tape->asc = sense[12]; |
1460 | tape->asc = result->asc; | 782 | tape->ascq = sense[13]; |
1461 | tape->ascq = result->ascq; | ||
1462 | #if IDETAPE_DEBUG_LOG | 783 | #if IDETAPE_DEBUG_LOG |
1463 | /* | 784 | /* |
1464 | * Without debugging, we only log an error if we decided to | 785 | * Without debugging, we only log an error if we decided to give up |
1465 | * give up retrying. | 786 | * retrying. |
1466 | */ | 787 | */ |
1467 | if (tape->debug_level >= 1) | 788 | if (tape->debug_level >= 1) |
1468 | printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, " | 789 | printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, " |
1469 | "asc = %x, ascq = %x\n", | 790 | "asc = %x, ascq = %x\n", |
1470 | pc->c[0], result->sense_key, | 791 | pc->c[0], tape->sense_key, |
1471 | result->asc, result->ascq); | 792 | tape->asc, tape->ascq); |
1472 | #endif /* IDETAPE_DEBUG_LOG */ | 793 | #endif /* IDETAPE_DEBUG_LOG */ |
1473 | 794 | ||
1474 | /* | 795 | /* Correct pc->actually_transferred by asking the tape. */ |
1475 | * Correct pc->actually_transferred by asking the tape. | ||
1476 | */ | ||
1477 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { | 796 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { |
1478 | pc->actually_transferred = pc->request_transfer - tape->tape_block_size * ntohl(get_unaligned(&result->information)); | 797 | pc->actually_transferred = pc->request_transfer - |
798 | tape->tape_block_size * | ||
799 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); | ||
1479 | idetape_update_buffers(pc); | 800 | idetape_update_buffers(pc); |
1480 | } | 801 | } |
1481 | 802 | ||
@@ -1484,29 +805,29 @@ static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_res | |||
1484 | * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives | 805 | * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives |
1485 | * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. | 806 | * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. |
1486 | */ | 807 | */ |
1487 | if ((pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) | 808 | if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6) |
1488 | && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { /* length==0 */ | 809 | /* length == 0 */ |
1489 | if (result->sense_key == 5) { | 810 | && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { |
811 | if (tape->sense_key == 5) { | ||
1490 | /* don't report an error, everything's ok */ | 812 | /* don't report an error, everything's ok */ |
1491 | pc->error = 0; | 813 | pc->error = 0; |
1492 | /* don't retry read/write */ | 814 | /* don't retry read/write */ |
1493 | set_bit(PC_ABORT, &pc->flags); | 815 | set_bit(PC_ABORT, &pc->flags); |
1494 | } | 816 | } |
1495 | } | 817 | } |
1496 | if (pc->c[0] == IDETAPE_READ_CMD && result->filemark) { | 818 | if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { |
1497 | pc->error = IDETAPE_ERROR_FILEMARK; | 819 | pc->error = IDETAPE_ERROR_FILEMARK; |
1498 | set_bit(PC_ABORT, &pc->flags); | 820 | set_bit(PC_ABORT, &pc->flags); |
1499 | } | 821 | } |
1500 | if (pc->c[0] == IDETAPE_WRITE_CMD) { | 822 | if (pc->c[0] == WRITE_6) { |
1501 | if (result->eom || | 823 | if ((sense[2] & 0x40) || (tape->sense_key == 0xd |
1502 | (result->sense_key == 0xd && result->asc == 0x0 && | 824 | && tape->asc == 0x0 && tape->ascq == 0x2)) { |
1503 | result->ascq == 0x2)) { | ||
1504 | pc->error = IDETAPE_ERROR_EOD; | 825 | pc->error = IDETAPE_ERROR_EOD; |
1505 | set_bit(PC_ABORT, &pc->flags); | 826 | set_bit(PC_ABORT, &pc->flags); |
1506 | } | 827 | } |
1507 | } | 828 | } |
1508 | if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) { | 829 | if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
1509 | if (result->sense_key == 8) { | 830 | if (tape->sense_key == 8) { |
1510 | pc->error = IDETAPE_ERROR_EOD; | 831 | pc->error = IDETAPE_ERROR_EOD; |
1511 | set_bit(PC_ABORT, &pc->flags); | 832 | set_bit(PC_ABORT, &pc->flags); |
1512 | } | 833 | } |
@@ -1516,10 +837,7 @@ static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_res | |||
1516 | } | 837 | } |
1517 | } | 838 | } |
1518 | 839 | ||
1519 | /* | 840 | static void idetape_activate_next_stage(ide_drive_t *drive) |
1520 | * idetape_active_next_stage will declare the next stage as "active". | ||
1521 | */ | ||
1522 | static void idetape_active_next_stage (ide_drive_t *drive) | ||
1523 | { | 841 | { |
1524 | idetape_tape_t *tape = drive->driver_data; | 842 | idetape_tape_t *tape = drive->driver_data; |
1525 | idetape_stage_t *stage = tape->next_stage; | 843 | idetape_stage_t *stage = tape->next_stage; |
@@ -1529,12 +847,10 @@ static void idetape_active_next_stage (ide_drive_t *drive) | |||
1529 | if (tape->debug_level >= 4) | 847 | if (tape->debug_level >= 4) |
1530 | printk(KERN_INFO "ide-tape: Reached idetape_active_next_stage\n"); | 848 | printk(KERN_INFO "ide-tape: Reached idetape_active_next_stage\n"); |
1531 | #endif /* IDETAPE_DEBUG_LOG */ | 849 | #endif /* IDETAPE_DEBUG_LOG */ |
1532 | #if IDETAPE_DEBUG_BUGS | ||
1533 | if (stage == NULL) { | 850 | if (stage == NULL) { |
1534 | printk(KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n"); | 851 | printk(KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n"); |
1535 | return; | 852 | return; |
1536 | } | 853 | } |
1537 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
1538 | 854 | ||
1539 | rq->rq_disk = tape->disk; | 855 | rq->rq_disk = tape->disk; |
1540 | rq->buffer = NULL; | 856 | rq->buffer = NULL; |
@@ -1609,28 +925,24 @@ static void idetape_remove_stage_head (ide_drive_t *drive) | |||
1609 | if (tape->debug_level >= 4) | 925 | if (tape->debug_level >= 4) |
1610 | printk(KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n"); | 926 | printk(KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n"); |
1611 | #endif /* IDETAPE_DEBUG_LOG */ | 927 | #endif /* IDETAPE_DEBUG_LOG */ |
1612 | #if IDETAPE_DEBUG_BUGS | ||
1613 | if (tape->first_stage == NULL) { | 928 | if (tape->first_stage == NULL) { |
1614 | printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); | 929 | printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); |
1615 | return; | 930 | return; |
1616 | } | 931 | } |
1617 | if (tape->active_stage == tape->first_stage) { | 932 | if (tape->active_stage == tape->first_stage) { |
1618 | printk(KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n"); | 933 | printk(KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n"); |
1619 | return; | 934 | return; |
1620 | } | 935 | } |
1621 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
1622 | stage = tape->first_stage; | 936 | stage = tape->first_stage; |
1623 | tape->first_stage = stage->next; | 937 | tape->first_stage = stage->next; |
1624 | idetape_kfree_stage(tape, stage); | 938 | idetape_kfree_stage(tape, stage); |
1625 | tape->nr_stages--; | 939 | tape->nr_stages--; |
1626 | if (tape->first_stage == NULL) { | 940 | if (tape->first_stage == NULL) { |
1627 | tape->last_stage = NULL; | 941 | tape->last_stage = NULL; |
1628 | #if IDETAPE_DEBUG_BUGS | ||
1629 | if (tape->next_stage != NULL) | 942 | if (tape->next_stage != NULL) |
1630 | printk(KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n"); | 943 | printk(KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n"); |
1631 | if (tape->nr_stages) | 944 | if (tape->nr_stages) |
1632 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n"); | 945 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n"); |
1633 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
1634 | } | 946 | } |
1635 | } | 947 | } |
1636 | 948 | ||
@@ -1716,7 +1028,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
1716 | } | 1028 | } |
1717 | } | 1029 | } |
1718 | if (tape->next_stage != NULL) { | 1030 | if (tape->next_stage != NULL) { |
1719 | idetape_active_next_stage(drive); | 1031 | idetape_activate_next_stage(drive); |
1720 | 1032 | ||
1721 | /* | 1033 | /* |
1722 | * Insert the next request into the request queue. | 1034 | * Insert the next request into the request queue. |
@@ -1748,7 +1060,7 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) | |||
1748 | printk(KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n"); | 1060 | printk(KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n"); |
1749 | #endif /* IDETAPE_DEBUG_LOG */ | 1061 | #endif /* IDETAPE_DEBUG_LOG */ |
1750 | if (!tape->pc->error) { | 1062 | if (!tape->pc->error) { |
1751 | idetape_analyze_error(drive, (idetape_request_sense_result_t *) tape->pc->buffer); | 1063 | idetape_analyze_error(drive, tape->pc->buffer); |
1752 | idetape_end_request(drive, 1, 0); | 1064 | idetape_end_request(drive, 1, 0); |
1753 | } else { | 1065 | } else { |
1754 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); | 1066 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); |
@@ -1760,7 +1072,7 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) | |||
1760 | static void idetape_create_request_sense_cmd (idetape_pc_t *pc) | 1072 | static void idetape_create_request_sense_cmd (idetape_pc_t *pc) |
1761 | { | 1073 | { |
1762 | idetape_init_pc(pc); | 1074 | idetape_init_pc(pc); |
1763 | pc->c[0] = IDETAPE_REQUEST_SENSE_CMD; | 1075 | pc->c[0] = REQUEST_SENSE; |
1764 | pc->c[4] = 20; | 1076 | pc->c[4] = 20; |
1765 | pc->request_transfer = 20; | 1077 | pc->request_transfer = 20; |
1766 | pc->callback = &idetape_request_sense_callback; | 1078 | pc->callback = &idetape_request_sense_callback; |
@@ -1913,15 +1225,14 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) | |||
1913 | local_irq_enable(); | 1225 | local_irq_enable(); |
1914 | 1226 | ||
1915 | #if SIMULATE_ERRORS | 1227 | #if SIMULATE_ERRORS |
1916 | if ((pc->c[0] == IDETAPE_WRITE_CMD || | 1228 | if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) && |
1917 | pc->c[0] == IDETAPE_READ_CMD) && | ||
1918 | (++error_sim_count % 100) == 0) { | 1229 | (++error_sim_count % 100) == 0) { |
1919 | printk(KERN_INFO "ide-tape: %s: simulating error\n", | 1230 | printk(KERN_INFO "ide-tape: %s: simulating error\n", |
1920 | tape->name); | 1231 | tape->name); |
1921 | stat |= ERR_STAT; | 1232 | stat |= ERR_STAT; |
1922 | } | 1233 | } |
1923 | #endif | 1234 | #endif |
1924 | if ((stat & ERR_STAT) && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) | 1235 | if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) |
1925 | stat &= ~ERR_STAT; | 1236 | stat &= ~ERR_STAT; |
1926 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { | 1237 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { |
1927 | /* Error detected */ | 1238 | /* Error detected */ |
@@ -1930,7 +1241,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) | |||
1930 | printk(KERN_INFO "ide-tape: %s: I/O error\n", | 1241 | printk(KERN_INFO "ide-tape: %s: I/O error\n", |
1931 | tape->name); | 1242 | tape->name); |
1932 | #endif /* IDETAPE_DEBUG_LOG */ | 1243 | #endif /* IDETAPE_DEBUG_LOG */ |
1933 | if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { | 1244 | if (pc->c[0] == REQUEST_SENSE) { |
1934 | printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); | 1245 | printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); |
1935 | return ide_do_reset(drive); | 1246 | return ide_do_reset(drive); |
1936 | } | 1247 | } |
@@ -2118,15 +1429,13 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape | |||
2118 | int dma_ok = 0; | 1429 | int dma_ok = 0; |
2119 | u16 bcount; | 1430 | u16 bcount; |
2120 | 1431 | ||
2121 | #if IDETAPE_DEBUG_BUGS | 1432 | if (tape->pc->c[0] == REQUEST_SENSE && |
2122 | if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD && | 1433 | pc->c[0] == REQUEST_SENSE) { |
2123 | pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { | ||
2124 | printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " | 1434 | printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " |
2125 | "Two request sense in serial were issued\n"); | 1435 | "Two request sense in serial were issued\n"); |
2126 | } | 1436 | } |
2127 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
2128 | 1437 | ||
2129 | if (tape->failed_pc == NULL && pc->c[0] != IDETAPE_REQUEST_SENSE_CMD) | 1438 | if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) |
2130 | tape->failed_pc = pc; | 1439 | tape->failed_pc = pc; |
2131 | /* Set the current packet command */ | 1440 | /* Set the current packet command */ |
2132 | tape->pc = pc; | 1441 | tape->pc = pc; |
@@ -2139,7 +1448,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape | |||
2139 | * filemark, or end of the media, for example). | 1448 | * filemark, or end of the media, for example). |
2140 | */ | 1449 | */ |
2141 | if (!test_bit(PC_ABORT, &pc->flags)) { | 1450 | if (!test_bit(PC_ABORT, &pc->flags)) { |
2142 | if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD && | 1451 | if (!(pc->c[0] == TEST_UNIT_READY && |
2143 | tape->sense_key == 2 && tape->asc == 4 && | 1452 | tape->sense_key == 2 && tape->asc == 4 && |
2144 | (tape->ascq == 1 || tape->ascq == 8))) { | 1453 | (tape->ascq == 1 || tape->ascq == 8))) { |
2145 | printk(KERN_ERR "ide-tape: %s: I/O error, " | 1454 | printk(KERN_ERR "ide-tape: %s: I/O error, " |
@@ -2181,8 +1490,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape | |||
2181 | if (dma_ok) /* Will begin DMA later */ | 1490 | if (dma_ok) /* Will begin DMA later */ |
2182 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 1491 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); |
2183 | if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { | 1492 | if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { |
2184 | ide_set_handler(drive, &idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL); | 1493 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, |
2185 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); | 1494 | IDETAPE_WAIT_CMD, NULL); |
2186 | return ide_started; | 1495 | return ide_started; |
2187 | } else { | 1496 | } else { |
2188 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); | 1497 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); |
@@ -2212,7 +1521,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) | |||
2212 | static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) | 1521 | static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) |
2213 | { | 1522 | { |
2214 | idetape_init_pc(pc); | 1523 | idetape_init_pc(pc); |
2215 | pc->c[0] = IDETAPE_MODE_SENSE_CMD; | 1524 | pc->c[0] = MODE_SENSE; |
2216 | if (page_code != IDETAPE_BLOCK_DESCRIPTOR) | 1525 | if (page_code != IDETAPE_BLOCK_DESCRIPTOR) |
2217 | pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ | 1526 | pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ |
2218 | pc->c[2] = page_code; | 1527 | pc->c[2] = page_code; |
@@ -2293,7 +1602,7 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) | |||
2293 | if (stat & SEEK_STAT) { | 1602 | if (stat & SEEK_STAT) { |
2294 | if (stat & ERR_STAT) { | 1603 | if (stat & ERR_STAT) { |
2295 | /* Error detected */ | 1604 | /* Error detected */ |
2296 | if (pc->c[0] != IDETAPE_TEST_UNIT_READY_CMD) | 1605 | if (pc->c[0] != TEST_UNIT_READY) |
2297 | printk(KERN_ERR "ide-tape: %s: I/O error, ", | 1606 | printk(KERN_ERR "ide-tape: %s: I/O error, ", |
2298 | tape->name); | 1607 | tape->name); |
2299 | /* Retry operation */ | 1608 | /* Retry operation */ |
@@ -2350,8 +1659,8 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | |||
2350 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) | 1659 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) |
2351 | { | 1660 | { |
2352 | idetape_init_pc(pc); | 1661 | idetape_init_pc(pc); |
2353 | pc->c[0] = IDETAPE_READ_CMD; | 1662 | pc->c[0] = READ_6; |
2354 | put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); | 1663 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
2355 | pc->c[1] = 1; | 1664 | pc->c[1] = 1; |
2356 | pc->callback = &idetape_rw_callback; | 1665 | pc->callback = &idetape_rw_callback; |
2357 | pc->bh = bh; | 1666 | pc->bh = bh; |
@@ -2368,7 +1677,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p | |||
2368 | struct idetape_bh *p = bh; | 1677 | struct idetape_bh *p = bh; |
2369 | 1678 | ||
2370 | idetape_init_pc(pc); | 1679 | idetape_init_pc(pc); |
2371 | pc->c[0] = IDETAPE_READ_BUFFER_CMD; | 1680 | pc->c[0] = READ_BUFFER; |
2372 | pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK; | 1681 | pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK; |
2373 | pc->c[7] = size >> 8; | 1682 | pc->c[7] = size >> 8; |
2374 | pc->c[8] = size & 0xff; | 1683 | pc->c[8] = size & 0xff; |
@@ -2386,8 +1695,8 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p | |||
2386 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) | 1695 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) |
2387 | { | 1696 | { |
2388 | idetape_init_pc(pc); | 1697 | idetape_init_pc(pc); |
2389 | pc->c[0] = IDETAPE_WRITE_CMD; | 1698 | pc->c[0] = WRITE_6; |
2390 | put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); | 1699 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
2391 | pc->c[1] = 1; | 1700 | pc->c[1] = 1; |
2392 | pc->callback = &idetape_rw_callback; | 1701 | pc->callback = &idetape_rw_callback; |
2393 | set_bit(PC_WRITING, &pc->flags); | 1702 | set_bit(PC_WRITING, &pc->flags); |
@@ -2412,12 +1721,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
2412 | u8 stat; | 1721 | u8 stat; |
2413 | 1722 | ||
2414 | #if IDETAPE_DEBUG_LOG | 1723 | #if IDETAPE_DEBUG_LOG |
2415 | #if 0 | ||
2416 | if (tape->debug_level >= 5) | ||
2417 | printk(KERN_INFO "ide-tape: %d, " | ||
2418 | "dev: %s, cmd: %ld, errors: %d\n", | ||
2419 | rq->rq_disk->disk_name, rq->cmd[0], rq->errors); | ||
2420 | #endif | ||
2421 | if (tape->debug_level >= 2) | 1724 | if (tape->debug_level >= 2) |
2422 | printk(KERN_INFO "ide-tape: sector: %ld, " | 1725 | printk(KERN_INFO "ide-tape: sector: %ld, " |
2423 | "nr_sectors: %ld, current_nr_sectors: %d\n", | 1726 | "nr_sectors: %ld, current_nr_sectors: %d\n", |
@@ -2438,10 +1741,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
2438 | * Retry a failed packet command | 1741 | * Retry a failed packet command |
2439 | */ | 1742 | */ |
2440 | if (tape->failed_pc != NULL && | 1743 | if (tape->failed_pc != NULL && |
2441 | tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { | 1744 | tape->pc->c[0] == REQUEST_SENSE) { |
2442 | return idetape_issue_packet_command(drive, tape->failed_pc); | 1745 | return idetape_issue_packet_command(drive, tape->failed_pc); |
2443 | } | 1746 | } |
2444 | #if IDETAPE_DEBUG_BUGS | ||
2445 | if (postponed_rq != NULL) | 1747 | if (postponed_rq != NULL) |
2446 | if (rq != postponed_rq) { | 1748 | if (rq != postponed_rq) { |
2447 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " | 1749 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " |
@@ -2449,7 +1751,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
2449 | idetape_end_request(drive, 0, 0); | 1751 | idetape_end_request(drive, 0, 0); |
2450 | return ide_stopped; | 1752 | return ide_stopped; |
2451 | } | 1753 | } |
2452 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
2453 | 1754 | ||
2454 | tape->postponed_rq = NULL; | 1755 | tape->postponed_rq = NULL; |
2455 | 1756 | ||
@@ -2636,13 +1937,11 @@ static int idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t * | |||
2636 | int ret = 0; | 1937 | int ret = 0; |
2637 | 1938 | ||
2638 | while (n) { | 1939 | while (n) { |
2639 | #if IDETAPE_DEBUG_BUGS | ||
2640 | if (bh == NULL) { | 1940 | if (bh == NULL) { |
2641 | printk(KERN_ERR "ide-tape: bh == NULL in " | 1941 | printk(KERN_ERR "ide-tape: bh == NULL in " |
2642 | "idetape_copy_stage_from_user\n"); | 1942 | "idetape_copy_stage_from_user\n"); |
2643 | return 1; | 1943 | return 1; |
2644 | } | 1944 | } |
2645 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
2646 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n); | 1945 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n); |
2647 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count)) | 1946 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count)) |
2648 | ret = 1; | 1947 | ret = 1; |
@@ -2666,13 +1965,11 @@ static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, i | |||
2666 | int ret = 0; | 1965 | int ret = 0; |
2667 | 1966 | ||
2668 | while (n) { | 1967 | while (n) { |
2669 | #if IDETAPE_DEBUG_BUGS | ||
2670 | if (bh == NULL) { | 1968 | if (bh == NULL) { |
2671 | printk(KERN_ERR "ide-tape: bh == NULL in " | 1969 | printk(KERN_ERR "ide-tape: bh == NULL in " |
2672 | "idetape_copy_stage_to_user\n"); | 1970 | "idetape_copy_stage_to_user\n"); |
2673 | return 1; | 1971 | return 1; |
2674 | } | 1972 | } |
2675 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
2676 | count = min(tape->b_count, n); | 1973 | count = min(tape->b_count, n); |
2677 | if (copy_to_user(buf, tape->b_data, count)) | 1974 | if (copy_to_user(buf, tape->b_data, count)) |
2678 | ret = 1; | 1975 | ret = 1; |
@@ -2752,12 +2049,10 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) | |||
2752 | DECLARE_COMPLETION_ONSTACK(wait); | 2049 | DECLARE_COMPLETION_ONSTACK(wait); |
2753 | idetape_tape_t *tape = drive->driver_data; | 2050 | idetape_tape_t *tape = drive->driver_data; |
2754 | 2051 | ||
2755 | #if IDETAPE_DEBUG_BUGS | ||
2756 | if (rq == NULL || !blk_special_request(rq)) { | 2052 | if (rq == NULL || !blk_special_request(rq)) { |
2757 | printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); | 2053 | printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); |
2758 | return; | 2054 | return; |
2759 | } | 2055 | } |
2760 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
2761 | rq->end_io_data = &wait; | 2056 | rq->end_io_data = &wait; |
2762 | rq->end_io = blk_end_sync_rq; | 2057 | rq->end_io = blk_end_sync_rq; |
2763 | spin_unlock_irq(&tape->spinlock); | 2058 | spin_unlock_irq(&tape->spinlock); |
@@ -2817,7 +2112,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) | |||
2817 | static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) | 2112 | static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) |
2818 | { | 2113 | { |
2819 | idetape_init_pc(pc); | 2114 | idetape_init_pc(pc); |
2820 | pc->c[0] = IDETAPE_WRITE_FILEMARK_CMD; | 2115 | pc->c[0] = WRITE_FILEMARKS; |
2821 | pc->c[4] = write_filemark; | 2116 | pc->c[4] = write_filemark; |
2822 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2117 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
2823 | pc->callback = &idetape_pc_callback; | 2118 | pc->callback = &idetape_pc_callback; |
@@ -2826,7 +2121,7 @@ static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t | |||
2826 | static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) | 2121 | static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) |
2827 | { | 2122 | { |
2828 | idetape_init_pc(pc); | 2123 | idetape_init_pc(pc); |
2829 | pc->c[0] = IDETAPE_TEST_UNIT_READY_CMD; | 2124 | pc->c[0] = TEST_UNIT_READY; |
2830 | pc->callback = &idetape_pc_callback; | 2125 | pc->callback = &idetape_pc_callback; |
2831 | } | 2126 | } |
2832 | 2127 | ||
@@ -2864,7 +2159,7 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) | |||
2864 | static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) | 2159 | static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) |
2865 | { | 2160 | { |
2866 | idetape_init_pc(pc); | 2161 | idetape_init_pc(pc); |
2867 | pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD; | 2162 | pc->c[0] = START_STOP; |
2868 | pc->c[4] = cmd; | 2163 | pc->c[4] = cmd; |
2869 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2164 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
2870 | pc->callback = &idetape_pc_callback; | 2165 | pc->callback = &idetape_pc_callback; |
@@ -2921,7 +2216,7 @@ static int idetape_flush_tape_buffers (ide_drive_t *drive) | |||
2921 | static void idetape_create_read_position_cmd (idetape_pc_t *pc) | 2216 | static void idetape_create_read_position_cmd (idetape_pc_t *pc) |
2922 | { | 2217 | { |
2923 | idetape_init_pc(pc); | 2218 | idetape_init_pc(pc); |
2924 | pc->c[0] = IDETAPE_READ_POSITION_CMD; | 2219 | pc->c[0] = READ_POSITION; |
2925 | pc->request_transfer = 20; | 2220 | pc->request_transfer = 20; |
2926 | pc->callback = &idetape_read_position_callback; | 2221 | pc->callback = &idetape_read_position_callback; |
2927 | } | 2222 | } |
@@ -2947,9 +2242,9 @@ static int idetape_read_position (ide_drive_t *drive) | |||
2947 | static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) | 2242 | static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) |
2948 | { | 2243 | { |
2949 | idetape_init_pc(pc); | 2244 | idetape_init_pc(pc); |
2950 | pc->c[0] = IDETAPE_LOCATE_CMD; | 2245 | pc->c[0] = POSITION_TO_ELEMENT; |
2951 | pc->c[1] = 2; | 2246 | pc->c[1] = 2; |
2952 | put_unaligned(htonl(block), (unsigned int *) &pc->c[3]); | 2247 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); |
2953 | pc->c[8] = partition; | 2248 | pc->c[8] = partition; |
2954 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2249 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
2955 | pc->callback = &idetape_pc_callback; | 2250 | pc->callback = &idetape_pc_callback; |
@@ -2959,11 +2254,12 @@ static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int | |||
2959 | { | 2254 | { |
2960 | idetape_tape_t *tape = drive->driver_data; | 2255 | idetape_tape_t *tape = drive->driver_data; |
2961 | 2256 | ||
2962 | if (!tape->capabilities.lock) | 2257 | /* device supports locking according to capabilities page */ |
2258 | if (!(tape->caps[6] & 0x01)) | ||
2963 | return 0; | 2259 | return 0; |
2964 | 2260 | ||
2965 | idetape_init_pc(pc); | 2261 | idetape_init_pc(pc); |
2966 | pc->c[0] = IDETAPE_PREVENT_CMD; | 2262 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; |
2967 | pc->c[4] = prevent; | 2263 | pc->c[4] = prevent; |
2968 | pc->callback = &idetape_pc_callback; | 2264 | pc->callback = &idetape_pc_callback; |
2969 | return 1; | 2265 | return 1; |
@@ -3072,12 +2368,10 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct | |||
3072 | if (tape->debug_level >= 2) | 2368 | if (tape->debug_level >= 2) |
3073 | printk(KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd); | 2369 | printk(KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd); |
3074 | #endif /* IDETAPE_DEBUG_LOG */ | 2370 | #endif /* IDETAPE_DEBUG_LOG */ |
3075 | #if IDETAPE_DEBUG_BUGS | ||
3076 | if (idetape_pipeline_active(tape)) { | 2371 | if (idetape_pipeline_active(tape)) { |
3077 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n"); | 2372 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n"); |
3078 | return (0); | 2373 | return (0); |
3079 | } | 2374 | } |
3080 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3081 | 2375 | ||
3082 | idetape_init_rq(&rq, cmd); | 2376 | idetape_init_rq(&rq, cmd); |
3083 | rq.rq_disk = tape->disk; | 2377 | rq.rq_disk = tape->disk; |
@@ -3108,7 +2402,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) | |||
3108 | return; | 2402 | return; |
3109 | if (!idetape_pipeline_active(tape)) { | 2403 | if (!idetape_pipeline_active(tape)) { |
3110 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 2404 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); |
3111 | idetape_active_next_stage(drive); | 2405 | idetape_activate_next_stage(drive); |
3112 | (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); | 2406 | (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); |
3113 | } | 2407 | } |
3114 | } | 2408 | } |
@@ -3116,7 +2410,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) | |||
3116 | static void idetape_create_inquiry_cmd (idetape_pc_t *pc) | 2410 | static void idetape_create_inquiry_cmd (idetape_pc_t *pc) |
3117 | { | 2411 | { |
3118 | idetape_init_pc(pc); | 2412 | idetape_init_pc(pc); |
3119 | pc->c[0] = IDETAPE_INQUIRY_CMD; | 2413 | pc->c[0] = INQUIRY; |
3120 | pc->c[4] = pc->request_transfer = 254; | 2414 | pc->c[4] = pc->request_transfer = 254; |
3121 | pc->callback = &idetape_pc_callback; | 2415 | pc->callback = &idetape_pc_callback; |
3122 | } | 2416 | } |
@@ -3124,28 +2418,15 @@ static void idetape_create_inquiry_cmd (idetape_pc_t *pc) | |||
3124 | static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) | 2418 | static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) |
3125 | { | 2419 | { |
3126 | idetape_init_pc(pc); | 2420 | idetape_init_pc(pc); |
3127 | pc->c[0] = IDETAPE_REWIND_CMD; | 2421 | pc->c[0] = REZERO_UNIT; |
3128 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2422 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
3129 | pc->callback = &idetape_pc_callback; | 2423 | pc->callback = &idetape_pc_callback; |
3130 | } | 2424 | } |
3131 | 2425 | ||
3132 | #if 0 | ||
3133 | static void idetape_create_mode_select_cmd (idetape_pc_t *pc, int length) | ||
3134 | { | ||
3135 | idetape_init_pc(pc); | ||
3136 | set_bit(PC_WRITING, &pc->flags); | ||
3137 | pc->c[0] = IDETAPE_MODE_SELECT_CMD; | ||
3138 | pc->c[1] = 0x10; | ||
3139 | put_unaligned(htons(length), (unsigned short *) &pc->c[3]); | ||
3140 | pc->request_transfer = 255; | ||
3141 | pc->callback = &idetape_pc_callback; | ||
3142 | } | ||
3143 | #endif | ||
3144 | |||
3145 | static void idetape_create_erase_cmd (idetape_pc_t *pc) | 2426 | static void idetape_create_erase_cmd (idetape_pc_t *pc) |
3146 | { | 2427 | { |
3147 | idetape_init_pc(pc); | 2428 | idetape_init_pc(pc); |
3148 | pc->c[0] = IDETAPE_ERASE_CMD; | 2429 | pc->c[0] = ERASE; |
3149 | pc->c[1] = 1; | 2430 | pc->c[1] = 1; |
3150 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2431 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
3151 | pc->callback = &idetape_pc_callback; | 2432 | pc->callback = &idetape_pc_callback; |
@@ -3154,8 +2435,8 @@ static void idetape_create_erase_cmd (idetape_pc_t *pc) | |||
3154 | static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) | 2435 | static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) |
3155 | { | 2436 | { |
3156 | idetape_init_pc(pc); | 2437 | idetape_init_pc(pc); |
3157 | pc->c[0] = IDETAPE_SPACE_CMD; | 2438 | pc->c[0] = SPACE; |
3158 | put_unaligned(htonl(count), (unsigned int *) &pc->c[1]); | 2439 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); |
3159 | pc->c[1] = cmd; | 2440 | pc->c[1] = cmd; |
3160 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2441 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
3161 | pc->callback = &idetape_pc_callback; | 2442 | pc->callback = &idetape_pc_callback; |
@@ -3275,8 +2556,7 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
3275 | idetape_tape_t *tape = drive->driver_data; | 2556 | idetape_tape_t *tape = drive->driver_data; |
3276 | int blocks, min; | 2557 | int blocks, min; |
3277 | struct idetape_bh *bh; | 2558 | struct idetape_bh *bh; |
3278 | 2559 | ||
3279 | #if IDETAPE_DEBUG_BUGS | ||
3280 | if (tape->chrdev_direction != idetape_direction_write) { | 2560 | if (tape->chrdev_direction != idetape_direction_write) { |
3281 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); | 2561 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); |
3282 | return; | 2562 | return; |
@@ -3285,7 +2565,6 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
3285 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); | 2565 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); |
3286 | tape->merge_stage_size = tape->stage_size; | 2566 | tape->merge_stage_size = tape->stage_size; |
3287 | } | 2567 | } |
3288 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3289 | if (tape->merge_stage_size) { | 2568 | if (tape->merge_stage_size) { |
3290 | blocks = tape->merge_stage_size / tape->tape_block_size; | 2569 | blocks = tape->merge_stage_size / tape->tape_block_size; |
3291 | if (tape->merge_stage_size % tape->tape_block_size) { | 2570 | if (tape->merge_stage_size % tape->tape_block_size) { |
@@ -3330,7 +2609,6 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
3330 | * can be totally different on the next backup). | 2609 | * can be totally different on the next backup). |
3331 | */ | 2610 | */ |
3332 | tape->max_stages = tape->min_pipeline; | 2611 | tape->max_stages = tape->min_pipeline; |
3333 | #if IDETAPE_DEBUG_BUGS | ||
3334 | if (tape->first_stage != NULL || | 2612 | if (tape->first_stage != NULL || |
3335 | tape->next_stage != NULL || | 2613 | tape->next_stage != NULL || |
3336 | tape->last_stage != NULL || | 2614 | tape->last_stage != NULL || |
@@ -3341,7 +2619,6 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
3341 | tape->first_stage, tape->next_stage, | 2619 | tape->first_stage, tape->next_stage, |
3342 | tape->last_stage, tape->nr_stages); | 2620 | tape->last_stage, tape->nr_stages); |
3343 | } | 2621 | } |
3344 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3345 | } | 2622 | } |
3346 | 2623 | ||
3347 | static void idetape_restart_speed_control (ide_drive_t *drive) | 2624 | static void idetape_restart_speed_control (ide_drive_t *drive) |
@@ -3364,7 +2641,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) | |||
3364 | idetape_stage_t *new_stage; | 2641 | idetape_stage_t *new_stage; |
3365 | struct request rq; | 2642 | struct request rq; |
3366 | int bytes_read; | 2643 | int bytes_read; |
3367 | int blocks = tape->capabilities.ctl; | 2644 | u16 blocks = *(u16 *)&tape->caps[12]; |
3368 | 2645 | ||
3369 | /* Initialize read operation */ | 2646 | /* Initialize read operation */ |
3370 | if (tape->chrdev_direction != idetape_direction_read) { | 2647 | if (tape->chrdev_direction != idetape_direction_read) { |
@@ -3372,12 +2649,10 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) | |||
3372 | idetape_empty_write_pipeline(drive); | 2649 | idetape_empty_write_pipeline(drive); |
3373 | idetape_flush_tape_buffers(drive); | 2650 | idetape_flush_tape_buffers(drive); |
3374 | } | 2651 | } |
3375 | #if IDETAPE_DEBUG_BUGS | ||
3376 | if (tape->merge_stage || tape->merge_stage_size) { | 2652 | if (tape->merge_stage || tape->merge_stage_size) { |
3377 | printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n"); | 2653 | printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n"); |
3378 | tape->merge_stage_size = 0; | 2654 | tape->merge_stage_size = 0; |
3379 | } | 2655 | } |
3380 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3381 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) | 2656 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) |
3382 | return -ENOMEM; | 2657 | return -ENOMEM; |
3383 | tape->chrdev_direction = idetape_direction_read; | 2658 | tape->chrdev_direction = idetape_direction_read; |
@@ -3478,12 +2753,10 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | |||
3478 | tape->pipeline_head++; | 2753 | tape->pipeline_head++; |
3479 | calculate_speeds(drive); | 2754 | calculate_speeds(drive); |
3480 | } | 2755 | } |
3481 | #if IDETAPE_DEBUG_BUGS | ||
3482 | if (bytes_read > blocks * tape->tape_block_size) { | 2756 | if (bytes_read > blocks * tape->tape_block_size) { |
3483 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); | 2757 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); |
3484 | bytes_read = blocks * tape->tape_block_size; | 2758 | bytes_read = blocks * tape->tape_block_size; |
3485 | } | 2759 | } |
3486 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3487 | return (bytes_read); | 2760 | return (bytes_read); |
3488 | } | 2761 | } |
3489 | 2762 | ||
@@ -3567,16 +2840,21 @@ static int idetape_rewind_tape (ide_drive_t *drive) | |||
3567 | static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) | 2840 | static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) |
3568 | { | 2841 | { |
3569 | idetape_tape_t *tape = drive->driver_data; | 2842 | idetape_tape_t *tape = drive->driver_data; |
3570 | idetape_config_t config; | ||
3571 | void __user *argp = (void __user *)arg; | 2843 | void __user *argp = (void __user *)arg; |
3572 | 2844 | ||
2845 | struct idetape_config { | ||
2846 | int dsc_rw_frequency; | ||
2847 | int dsc_media_access_frequency; | ||
2848 | int nr_stages; | ||
2849 | } config; | ||
2850 | |||
3573 | #if IDETAPE_DEBUG_LOG | 2851 | #if IDETAPE_DEBUG_LOG |
3574 | if (tape->debug_level >= 4) | 2852 | if (tape->debug_level >= 4) |
3575 | printk(KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n"); | 2853 | printk(KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n"); |
3576 | #endif /* IDETAPE_DEBUG_LOG */ | 2854 | #endif /* IDETAPE_DEBUG_LOG */ |
3577 | switch (cmd) { | 2855 | switch (cmd) { |
3578 | case 0x0340: | 2856 | case 0x0340: |
3579 | if (copy_from_user(&config, argp, sizeof (idetape_config_t))) | 2857 | if (copy_from_user(&config, argp, sizeof(config))) |
3580 | return -EFAULT; | 2858 | return -EFAULT; |
3581 | tape->best_dsc_rw_frequency = config.dsc_rw_frequency; | 2859 | tape->best_dsc_rw_frequency = config.dsc_rw_frequency; |
3582 | tape->max_stages = config.nr_stages; | 2860 | tape->max_stages = config.nr_stages; |
@@ -3584,7 +2862,7 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned l | |||
3584 | case 0x0350: | 2862 | case 0x0350: |
3585 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency; | 2863 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency; |
3586 | config.nr_stages = tape->max_stages; | 2864 | config.nr_stages = tape->max_stages; |
3587 | if (copy_to_user(argp, &config, sizeof (idetape_config_t))) | 2865 | if (copy_to_user(argp, &config, sizeof(config))) |
3588 | return -EFAULT; | 2866 | return -EFAULT; |
3589 | break; | 2867 | break; |
3590 | default: | 2868 | default: |
@@ -3608,11 +2886,12 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
3608 | idetape_pc_t pc; | 2886 | idetape_pc_t pc; |
3609 | unsigned long flags; | 2887 | unsigned long flags; |
3610 | int retval,count=0; | 2888 | int retval,count=0; |
2889 | int sprev = !!(tape->caps[4] & 0x20); | ||
3611 | 2890 | ||
3612 | if (mt_count == 0) | 2891 | if (mt_count == 0) |
3613 | return 0; | 2892 | return 0; |
3614 | if (MTBSF == mt_op || MTBSFM == mt_op) { | 2893 | if (MTBSF == mt_op || MTBSFM == mt_op) { |
3615 | if (!tape->capabilities.sprev) | 2894 | if (!sprev) |
3616 | return -EIO; | 2895 | return -EIO; |
3617 | mt_count = - mt_count; | 2896 | mt_count = - mt_count; |
3618 | } | 2897 | } |
@@ -3666,7 +2945,7 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
3666 | return (idetape_queue_pc_tail(drive, &pc)); | 2945 | return (idetape_queue_pc_tail(drive, &pc)); |
3667 | case MTFSFM: | 2946 | case MTFSFM: |
3668 | case MTBSFM: | 2947 | case MTBSFM: |
3669 | if (!tape->capabilities.sprev) | 2948 | if (!sprev) |
3670 | return (-EIO); | 2949 | return (-EIO); |
3671 | retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); | 2950 | retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); |
3672 | if (retval) return (retval); | 2951 | if (retval) return (retval); |
@@ -3703,6 +2982,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
3703 | ide_drive_t *drive = tape->drive; | 2982 | ide_drive_t *drive = tape->drive; |
3704 | ssize_t bytes_read,temp, actually_read = 0, rc; | 2983 | ssize_t bytes_read,temp, actually_read = 0, rc; |
3705 | ssize_t ret = 0; | 2984 | ssize_t ret = 0; |
2985 | u16 ctl = *(u16 *)&tape->caps[12]; | ||
3706 | 2986 | ||
3707 | #if IDETAPE_DEBUG_LOG | 2987 | #if IDETAPE_DEBUG_LOG |
3708 | if (tape->debug_level >= 3) | 2988 | if (tape->debug_level >= 3) |
@@ -3728,7 +3008,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
3728 | count -= actually_read; | 3008 | count -= actually_read; |
3729 | } | 3009 | } |
3730 | while (count >= tape->stage_size) { | 3010 | while (count >= tape->stage_size) { |
3731 | bytes_read = idetape_add_chrdev_read_request(drive, tape->capabilities.ctl); | 3011 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); |
3732 | if (bytes_read <= 0) | 3012 | if (bytes_read <= 0) |
3733 | goto finish; | 3013 | goto finish; |
3734 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read)) | 3014 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read)) |
@@ -3738,7 +3018,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
3738 | actually_read += bytes_read; | 3018 | actually_read += bytes_read; |
3739 | } | 3019 | } |
3740 | if (count) { | 3020 | if (count) { |
3741 | bytes_read = idetape_add_chrdev_read_request(drive, tape->capabilities.ctl); | 3021 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); |
3742 | if (bytes_read <= 0) | 3022 | if (bytes_read <= 0) |
3743 | goto finish; | 3023 | goto finish; |
3744 | temp = min((unsigned long)count, (unsigned long)bytes_read); | 3024 | temp = min((unsigned long)count, (unsigned long)bytes_read); |
@@ -3767,6 +3047,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
3767 | ide_drive_t *drive = tape->drive; | 3047 | ide_drive_t *drive = tape->drive; |
3768 | ssize_t actually_written = 0; | 3048 | ssize_t actually_written = 0; |
3769 | ssize_t ret = 0; | 3049 | ssize_t ret = 0; |
3050 | u16 ctl = *(u16 *)&tape->caps[12]; | ||
3770 | 3051 | ||
3771 | /* The drive is write protected. */ | 3052 | /* The drive is write protected. */ |
3772 | if (tape->write_prot) | 3053 | if (tape->write_prot) |
@@ -3782,13 +3063,11 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
3782 | if (tape->chrdev_direction != idetape_direction_write) { | 3063 | if (tape->chrdev_direction != idetape_direction_write) { |
3783 | if (tape->chrdev_direction == idetape_direction_read) | 3064 | if (tape->chrdev_direction == idetape_direction_read) |
3784 | idetape_discard_read_pipeline(drive, 1); | 3065 | idetape_discard_read_pipeline(drive, 1); |
3785 | #if IDETAPE_DEBUG_BUGS | ||
3786 | if (tape->merge_stage || tape->merge_stage_size) { | 3066 | if (tape->merge_stage || tape->merge_stage_size) { |
3787 | printk(KERN_ERR "ide-tape: merge_stage_size " | 3067 | printk(KERN_ERR "ide-tape: merge_stage_size " |
3788 | "should be 0 now\n"); | 3068 | "should be 0 now\n"); |
3789 | tape->merge_stage_size = 0; | 3069 | tape->merge_stage_size = 0; |
3790 | } | 3070 | } |
3791 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3792 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) | 3071 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) |
3793 | return -ENOMEM; | 3072 | return -ENOMEM; |
3794 | tape->chrdev_direction = idetape_direction_write; | 3073 | tape->chrdev_direction = idetape_direction_write; |
@@ -3816,12 +3095,10 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
3816 | if (tape->restart_speed_control_req) | 3095 | if (tape->restart_speed_control_req) |
3817 | idetape_restart_speed_control(drive); | 3096 | idetape_restart_speed_control(drive); |
3818 | if (tape->merge_stage_size) { | 3097 | if (tape->merge_stage_size) { |
3819 | #if IDETAPE_DEBUG_BUGS | ||
3820 | if (tape->merge_stage_size >= tape->stage_size) { | 3098 | if (tape->merge_stage_size >= tape->stage_size) { |
3821 | printk(KERN_ERR "ide-tape: bug: merge buffer too big\n"); | 3099 | printk(KERN_ERR "ide-tape: bug: merge buffer too big\n"); |
3822 | tape->merge_stage_size = 0; | 3100 | tape->merge_stage_size = 0; |
3823 | } | 3101 | } |
3824 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
3825 | actually_written = min((unsigned int)(tape->stage_size - tape->merge_stage_size), (unsigned int)count); | 3102 | actually_written = min((unsigned int)(tape->stage_size - tape->merge_stage_size), (unsigned int)count); |
3826 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written)) | 3103 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written)) |
3827 | ret = -EFAULT; | 3104 | ret = -EFAULT; |
@@ -3832,7 +3109,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
3832 | if (tape->merge_stage_size == tape->stage_size) { | 3109 | if (tape->merge_stage_size == tape->stage_size) { |
3833 | ssize_t retval; | 3110 | ssize_t retval; |
3834 | tape->merge_stage_size = 0; | 3111 | tape->merge_stage_size = 0; |
3835 | retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl); | 3112 | retval = idetape_add_chrdev_write_request(drive, ctl); |
3836 | if (retval <= 0) | 3113 | if (retval <= 0) |
3837 | return (retval); | 3114 | return (retval); |
3838 | } | 3115 | } |
@@ -3843,7 +3120,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
3843 | ret = -EFAULT; | 3120 | ret = -EFAULT; |
3844 | buf += tape->stage_size; | 3121 | buf += tape->stage_size; |
3845 | count -= tape->stage_size; | 3122 | count -= tape->stage_size; |
3846 | retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl); | 3123 | retval = idetape_add_chrdev_write_request(drive, ctl); |
3847 | actually_written += tape->stage_size; | 3124 | actually_written += tape->stage_size; |
3848 | if (retval <= 0) | 3125 | if (retval <= 0) |
3849 | return (retval); | 3126 | return (retval); |
@@ -3871,69 +3148,20 @@ static int idetape_write_filemark (ide_drive_t *drive) | |||
3871 | } | 3148 | } |
3872 | 3149 | ||
3873 | /* | 3150 | /* |
3874 | * idetape_mtioctop is called from idetape_chrdev_ioctl when | 3151 | * Called from idetape_chrdev_ioctl when the general mtio MTIOCTOP ioctl is |
3875 | * the general mtio MTIOCTOP ioctl is requested. | 3152 | * requested. |
3876 | * | ||
3877 | * We currently support the following mtio.h operations: | ||
3878 | * | 3153 | * |
3879 | * MTFSF - Space over mt_count filemarks in the positive direction. | 3154 | * Note: MTBSF and MTBSFM are not supported when the tape doesn't support |
3880 | * The tape is positioned after the last spaced filemark. | 3155 | * spacing over filemarks in the reverse direction. In this case, MTFSFM is also |
3156 | * usually not supported (it is supported in the rare case in which we crossed | ||
3157 | * the filemark during our read-ahead pipelined operation mode). | ||
3881 | * | 3158 | * |
3882 | * MTFSFM - Same as MTFSF, but the tape is positioned before the | 3159 | * The following commands are currently not supported: |
3883 | * last filemark. | ||
3884 | * | 3160 | * |
3885 | * MTBSF - Steps background over mt_count filemarks, tape is | 3161 | * MTFSS, MTBSS, MTWSM, MTSETDENSITY, MTSETDRVBUFFER, MT_ST_BOOLEANS, |
3886 | * positioned before the last filemark. | 3162 | * MT_ST_WRITE_THRESHOLD. |
3887 | * | ||
3888 | * MTBSFM - Like MTBSF, only tape is positioned after the last filemark. | ||
3889 | * | ||
3890 | * Note: | ||
3891 | * | ||
3892 | * MTBSF and MTBSFM are not supported when the tape doesn't | ||
3893 | * support spacing over filemarks in the reverse direction. | ||
3894 | * In this case, MTFSFM is also usually not supported (it is | ||
3895 | * supported in the rare case in which we crossed the filemark | ||
3896 | * during our read-ahead pipelined operation mode). | ||
3897 | * | ||
3898 | * MTWEOF - Writes mt_count filemarks. Tape is positioned after | ||
3899 | * the last written filemark. | ||
3900 | * | ||
3901 | * MTREW - Rewinds tape. | ||
3902 | * | ||
3903 | * MTLOAD - Loads the tape. | ||
3904 | * | ||
3905 | * MTOFFL - Puts the tape drive "Offline": Rewinds the tape and | ||
3906 | * MTUNLOAD prevents further access until the media is replaced. | ||
3907 | * | ||
3908 | * MTNOP - Flushes tape buffers. | ||
3909 | * | ||
3910 | * MTRETEN - Retension media. This typically consists of one end | ||
3911 | * to end pass on the media. | ||
3912 | * | ||
3913 | * MTEOM - Moves to the end of recorded data. | ||
3914 | * | ||
3915 | * MTERASE - Erases tape. | ||
3916 | * | ||
3917 | * MTSETBLK - Sets the user block size to mt_count bytes. If | ||
3918 | * mt_count is 0, we will attempt to autodetect | ||
3919 | * the block size. | ||
3920 | * | ||
3921 | * MTSEEK - Positions the tape in a specific block number, where | ||
3922 | * each block is assumed to contain which user_block_size | ||
3923 | * bytes. | ||
3924 | * | ||
3925 | * MTSETPART - Switches to another tape partition. | ||
3926 | * | ||
3927 | * MTLOCK - Locks the tape door. | ||
3928 | * | ||
3929 | * MTUNLOCK - Unlocks the tape door. | ||
3930 | * | ||
3931 | * The following commands are currently not supported: | ||
3932 | * | ||
3933 | * MTFSS, MTBSS, MTWSM, MTSETDENSITY, | ||
3934 | * MTSETDRVBUFFER, MT_ST_BOOLEANS, MT_ST_WRITE_THRESHOLD. | ||
3935 | */ | 3163 | */ |
3936 | static int idetape_mtioctop (ide_drive_t *drive,short mt_op,int mt_count) | 3164 | static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) |
3937 | { | 3165 | { |
3938 | idetape_tape_t *tape = drive->driver_data; | 3166 | idetape_tape_t *tape = drive->driver_data; |
3939 | idetape_pc_t pc; | 3167 | idetape_pc_t pc; |
@@ -4048,29 +3276,12 @@ static int idetape_mtioctop (ide_drive_t *drive,short mt_op,int mt_count) | |||
4048 | } | 3276 | } |
4049 | 3277 | ||
4050 | /* | 3278 | /* |
4051 | * Our character device ioctls. | 3279 | * Our character device ioctls. General mtio.h magnetic io commands are |
4052 | * | 3280 | * supported here, and not in the corresponding block interface. Our own |
4053 | * General mtio.h magnetic io commands are supported here, and not in | 3281 | * ide-tape ioctls are supported on both interfaces. |
4054 | * the corresponding block interface. | ||
4055 | * | ||
4056 | * The following ioctls are supported: | ||
4057 | * | ||
4058 | * MTIOCTOP - Refer to idetape_mtioctop for detailed description. | ||
4059 | * | ||
4060 | * MTIOCGET - The mt_dsreg field in the returned mtget structure | ||
4061 | * will be set to (user block size in bytes << | ||
4062 | * MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK. | ||
4063 | * | ||
4064 | * The mt_blkno is set to the current user block number. | ||
4065 | * The other mtget fields are not supported. | ||
4066 | * | ||
4067 | * MTIOCPOS - The current tape "block position" is returned. We | ||
4068 | * assume that each block contains user_block_size | ||
4069 | * bytes. | ||
4070 | * | ||
4071 | * Our own ide-tape ioctls are supported on both interfaces. | ||
4072 | */ | 3282 | */ |
4073 | static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 3283 | static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, |
3284 | unsigned int cmd, unsigned long arg) | ||
4074 | { | 3285 | { |
4075 | struct ide_tape_obj *tape = ide_tape_f(file); | 3286 | struct ide_tape_obj *tape = ide_tape_f(file); |
4076 | ide_drive_t *drive = tape->drive; | 3287 | ide_drive_t *drive = tape->drive; |
@@ -4124,7 +3335,30 @@ static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigne | |||
4124 | } | 3335 | } |
4125 | } | 3336 | } |
4126 | 3337 | ||
4127 | static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive); | 3338 | /* |
3339 | * Do a mode sense page 0 with block descriptor and if it succeeds set the tape | ||
3340 | * block size with the reported value. | ||
3341 | */ | ||
3342 | static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | ||
3343 | { | ||
3344 | idetape_tape_t *tape = drive->driver_data; | ||
3345 | idetape_pc_t pc; | ||
3346 | |||
3347 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | ||
3348 | if (idetape_queue_pc_tail(drive, &pc)) { | ||
3349 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | ||
3350 | if (tape->tape_block_size == 0) { | ||
3351 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | ||
3352 | "block size, assuming 32k\n"); | ||
3353 | tape->tape_block_size = 32768; | ||
3354 | } | ||
3355 | return; | ||
3356 | } | ||
3357 | tape->tape_block_size = (pc.buffer[4 + 5] << 16) + | ||
3358 | (pc.buffer[4 + 6] << 8) + | ||
3359 | pc.buffer[4 + 7]; | ||
3360 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | ||
3361 | } | ||
4128 | 3362 | ||
4129 | /* | 3363 | /* |
4130 | * Our character device open function. | 3364 | * Our character device open function. |
@@ -4178,7 +3412,7 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp) | |||
4178 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 3412 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); |
4179 | 3413 | ||
4180 | /* Read block size and write protect status from drive. */ | 3414 | /* Read block size and write protect status from drive. */ |
4181 | idetape_get_blocksize_from_block_descriptor(drive); | 3415 | ide_tape_get_bsize_from_bdesc(drive); |
4182 | 3416 | ||
4183 | /* Set write protect flag if device is opened as read-only. */ | 3417 | /* Set write protect flag if device is opened as read-only. */ |
4184 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) | 3418 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) |
@@ -4296,190 +3530,100 @@ static int idetape_identify_device (ide_drive_t *drive) | |||
4296 | 3530 | ||
4297 | *((unsigned short *) &gcw) = id->config; | 3531 | *((unsigned short *) &gcw) = id->config; |
4298 | 3532 | ||
4299 | #if IDETAPE_DEBUG_INFO | ||
4300 | printk(KERN_INFO "ide-tape: Dumping ATAPI Identify Device tape parameters\n"); | ||
4301 | printk(KERN_INFO "ide-tape: Protocol Type: "); | ||
4302 | switch (gcw.protocol) { | ||
4303 | case 0: case 1: printk("ATA\n");break; | ||
4304 | case 2: printk("ATAPI\n");break; | ||
4305 | case 3: printk("Reserved (Unknown to ide-tape)\n");break; | ||
4306 | } | ||
4307 | printk(KERN_INFO "ide-tape: Device Type: %x - ",gcw.device_type); | ||
4308 | switch (gcw.device_type) { | ||
4309 | case 0: printk("Direct-access Device\n");break; | ||
4310 | case 1: printk("Streaming Tape Device\n");break; | ||
4311 | case 2: case 3: case 4: printk("Reserved\n");break; | ||
4312 | case 5: printk("CD-ROM Device\n");break; | ||
4313 | case 6: printk("Reserved\n"); | ||
4314 | case 7: printk("Optical memory Device\n");break; | ||
4315 | case 0x1f: printk("Unknown or no Device type\n");break; | ||
4316 | default: printk("Reserved\n"); | ||
4317 | } | ||
4318 | printk(KERN_INFO "ide-tape: Removable: %s",gcw.removable ? "Yes\n":"No\n"); | ||
4319 | printk(KERN_INFO "ide-tape: Command Packet DRQ Type: "); | ||
4320 | switch (gcw.drq_type) { | ||
4321 | case 0: printk("Microprocessor DRQ\n");break; | ||
4322 | case 1: printk("Interrupt DRQ\n");break; | ||
4323 | case 2: printk("Accelerated DRQ\n");break; | ||
4324 | case 3: printk("Reserved\n");break; | ||
4325 | } | ||
4326 | printk(KERN_INFO "ide-tape: Command Packet Size: "); | ||
4327 | switch (gcw.packet_size) { | ||
4328 | case 0: printk("12 bytes\n");break; | ||
4329 | case 1: printk("16 bytes\n");break; | ||
4330 | default: printk("Reserved\n");break; | ||
4331 | } | ||
4332 | #endif /* IDETAPE_DEBUG_INFO */ | ||
4333 | |||
4334 | /* Check that we can support this device */ | 3533 | /* Check that we can support this device */ |
4335 | 3534 | ||
4336 | if (gcw.protocol !=2 ) | 3535 | if (gcw.protocol != 2) |
4337 | printk(KERN_ERR "ide-tape: Protocol is not ATAPI\n"); | 3536 | printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n", |
3537 | gcw.protocol); | ||
4338 | else if (gcw.device_type != 1) | 3538 | else if (gcw.device_type != 1) |
4339 | printk(KERN_ERR "ide-tape: Device type is not set to tape\n"); | 3539 | printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set " |
3540 | "to tape\n", gcw.device_type); | ||
4340 | else if (!gcw.removable) | 3541 | else if (!gcw.removable) |
4341 | printk(KERN_ERR "ide-tape: The removable flag is not set\n"); | 3542 | printk(KERN_ERR "ide-tape: The removable flag is not set\n"); |
4342 | else if (gcw.packet_size != 0) { | 3543 | else if (gcw.packet_size != 0) { |
4343 | printk(KERN_ERR "ide-tape: Packet size is not 12 bytes long\n"); | 3544 | printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 " |
4344 | if (gcw.packet_size == 1) | 3545 | "bytes long\n", gcw.packet_size); |
4345 | printk(KERN_ERR "ide-tape: Sorry, padding to 16 bytes is still not supported\n"); | ||
4346 | } else | 3546 | } else |
4347 | return 1; | 3547 | return 1; |
4348 | return 0; | 3548 | return 0; |
4349 | } | 3549 | } |
4350 | 3550 | ||
4351 | /* | 3551 | static void idetape_get_inquiry_results(ide_drive_t *drive) |
4352 | * Use INQUIRY to get the firmware revision | ||
4353 | */ | ||
4354 | static void idetape_get_inquiry_results (ide_drive_t *drive) | ||
4355 | { | 3552 | { |
4356 | char *r; | 3553 | char *r; |
4357 | idetape_tape_t *tape = drive->driver_data; | 3554 | idetape_tape_t *tape = drive->driver_data; |
4358 | idetape_pc_t pc; | 3555 | idetape_pc_t pc; |
4359 | idetape_inquiry_result_t *inquiry; | 3556 | |
4360 | |||
4361 | idetape_create_inquiry_cmd(&pc); | 3557 | idetape_create_inquiry_cmd(&pc); |
4362 | if (idetape_queue_pc_tail(drive, &pc)) { | 3558 | if (idetape_queue_pc_tail(drive, &pc)) { |
4363 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", tape->name); | 3559 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", |
3560 | tape->name); | ||
4364 | return; | 3561 | return; |
4365 | } | 3562 | } |
4366 | inquiry = (idetape_inquiry_result_t *) pc.buffer; | 3563 | memcpy(tape->vendor_id, &pc.buffer[8], 8); |
4367 | memcpy(tape->vendor_id, inquiry->vendor_id, 8); | 3564 | memcpy(tape->product_id, &pc.buffer[16], 16); |
4368 | memcpy(tape->product_id, inquiry->product_id, 16); | 3565 | memcpy(tape->firmware_revision, &pc.buffer[32], 4); |
4369 | memcpy(tape->firmware_revision, inquiry->revision_level, 4); | 3566 | |
4370 | ide_fixstring(tape->vendor_id, 10, 0); | 3567 | ide_fixstring(tape->vendor_id, 10, 0); |
4371 | ide_fixstring(tape->product_id, 18, 0); | 3568 | ide_fixstring(tape->product_id, 18, 0); |
4372 | ide_fixstring(tape->firmware_revision, 6, 0); | 3569 | ide_fixstring(tape->firmware_revision, 6, 0); |
4373 | r = tape->firmware_revision; | 3570 | r = tape->firmware_revision; |
4374 | if (*(r + 1) == '.') | 3571 | if (*(r + 1) == '.') |
4375 | tape->firmware_revision_num = (*r - '0') * 100 + (*(r + 2) - '0') * 10 + *(r + 3) - '0'; | 3572 | tape->firmware_revision_num = (*r - '0') * 100 + |
4376 | printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", drive->name, tape->name, tape->vendor_id, tape->product_id, tape->firmware_revision); | 3573 | (*(r + 2) - '0') * 10 + *(r + 3) - '0'; |
3574 | printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", | ||
3575 | drive->name, tape->name, tape->vendor_id, | ||
3576 | tape->product_id, tape->firmware_revision); | ||
4377 | } | 3577 | } |
4378 | 3578 | ||
4379 | /* | 3579 | /* |
4380 | * idetape_get_mode_sense_results asks the tape about its various | 3580 | * Ask the tape about its various parameters. In particular, we will adjust our |
4381 | * parameters. In particular, we will adjust our data transfer buffer | 3581 | * data transfer buffer size to the recommended value as returned by the tape. |
4382 | * size to the recommended value as returned by the tape. | ||
4383 | */ | 3582 | */ |
4384 | static void idetape_get_mode_sense_results (ide_drive_t *drive) | 3583 | static void idetape_get_mode_sense_results (ide_drive_t *drive) |
4385 | { | 3584 | { |
4386 | idetape_tape_t *tape = drive->driver_data; | 3585 | idetape_tape_t *tape = drive->driver_data; |
4387 | idetape_pc_t pc; | 3586 | idetape_pc_t pc; |
4388 | idetape_mode_parameter_header_t *header; | 3587 | u8 *caps; |
4389 | idetape_capabilities_page_t *capabilities; | 3588 | u8 speed, max_speed; |
4390 | 3589 | ||
4391 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); | 3590 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); |
4392 | if (idetape_queue_pc_tail(drive, &pc)) { | 3591 | if (idetape_queue_pc_tail(drive, &pc)) { |
4393 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming some default values\n"); | 3592 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" |
3593 | " some default values\n"); | ||
4394 | tape->tape_block_size = 512; | 3594 | tape->tape_block_size = 512; |
4395 | tape->capabilities.ctl = 52; | 3595 | put_unaligned(52, (u16 *)&tape->caps[12]); |
4396 | tape->capabilities.speed = 450; | 3596 | put_unaligned(540, (u16 *)&tape->caps[14]); |
4397 | tape->capabilities.buffer_size = 6 * 52; | 3597 | put_unaligned(6*52, (u16 *)&tape->caps[16]); |
4398 | return; | 3598 | return; |
4399 | } | 3599 | } |
4400 | header = (idetape_mode_parameter_header_t *) pc.buffer; | 3600 | caps = pc.buffer + 4 + pc.buffer[3]; |
4401 | capabilities = (idetape_capabilities_page_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t) + header->bdl); | ||
4402 | 3601 | ||
4403 | capabilities->max_speed = ntohs(capabilities->max_speed); | 3602 | /* convert to host order and save for later use */ |
4404 | capabilities->ctl = ntohs(capabilities->ctl); | 3603 | speed = be16_to_cpu(*(u16 *)&caps[14]); |
4405 | capabilities->speed = ntohs(capabilities->speed); | 3604 | max_speed = be16_to_cpu(*(u16 *)&caps[8]); |
4406 | capabilities->buffer_size = ntohs(capabilities->buffer_size); | ||
4407 | 3605 | ||
4408 | if (!capabilities->speed) { | 3606 | put_unaligned(max_speed, (u16 *)&caps[8]); |
4409 | printk(KERN_INFO "ide-tape: %s: overriding capabilities->speed (assuming 650KB/sec)\n", drive->name); | 3607 | put_unaligned(be16_to_cpu(*(u16 *)&caps[12]), (u16 *)&caps[12]); |
4410 | capabilities->speed = 650; | 3608 | put_unaligned(speed, (u16 *)&caps[14]); |
3609 | put_unaligned(be16_to_cpu(*(u16 *)&caps[16]), (u16 *)&caps[16]); | ||
3610 | |||
3611 | if (!speed) { | ||
3612 | printk(KERN_INFO "ide-tape: %s: invalid tape speed " | ||
3613 | "(assuming 650KB/sec)\n", drive->name); | ||
3614 | put_unaligned(650, (u16 *)&caps[14]); | ||
4411 | } | 3615 | } |
4412 | if (!capabilities->max_speed) { | 3616 | if (!max_speed) { |
4413 | printk(KERN_INFO "ide-tape: %s: overriding capabilities->max_speed (assuming 650KB/sec)\n", drive->name); | 3617 | printk(KERN_INFO "ide-tape: %s: invalid max_speed " |
4414 | capabilities->max_speed = 650; | 3618 | "(assuming 650KB/sec)\n", drive->name); |
3619 | put_unaligned(650, (u16 *)&caps[8]); | ||
4415 | } | 3620 | } |
4416 | 3621 | ||
4417 | tape->capabilities = *capabilities; /* Save us a copy */ | 3622 | memcpy(&tape->caps, caps, 20); |
4418 | if (capabilities->blk512) | 3623 | if (caps[7] & 0x02) |
4419 | tape->tape_block_size = 512; | 3624 | tape->tape_block_size = 512; |
4420 | else if (capabilities->blk1024) | 3625 | else if (caps[7] & 0x04) |
4421 | tape->tape_block_size = 1024; | 3626 | tape->tape_block_size = 1024; |
4422 | |||
4423 | #if IDETAPE_DEBUG_INFO | ||
4424 | printk(KERN_INFO "ide-tape: Dumping the results of the MODE SENSE packet command\n"); | ||
4425 | printk(KERN_INFO "ide-tape: Mode Parameter Header:\n"); | ||
4426 | printk(KERN_INFO "ide-tape: Mode Data Length - %d\n",header->mode_data_length); | ||
4427 | printk(KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type); | ||
4428 | printk(KERN_INFO "ide-tape: Device Specific Parameter - %d\n",header->dsp); | ||
4429 | printk(KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl); | ||
4430 | |||
4431 | printk(KERN_INFO "ide-tape: Capabilities and Mechanical Status Page:\n"); | ||
4432 | printk(KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code); | ||
4433 | printk(KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length); | ||
4434 | printk(KERN_INFO "ide-tape: Read only - %s\n",capabilities->ro ? "Yes":"No"); | ||
4435 | printk(KERN_INFO "ide-tape: Supports reverse space - %s\n",capabilities->sprev ? "Yes":"No"); | ||
4436 | printk(KERN_INFO "ide-tape: Supports erase initiated formatting - %s\n",capabilities->efmt ? "Yes":"No"); | ||
4437 | printk(KERN_INFO "ide-tape: Supports QFA two Partition format - %s\n",capabilities->qfa ? "Yes":"No"); | ||
4438 | printk(KERN_INFO "ide-tape: Supports locking the medium - %s\n",capabilities->lock ? "Yes":"No"); | ||
4439 | printk(KERN_INFO "ide-tape: The volume is currently locked - %s\n",capabilities->locked ? "Yes":"No"); | ||
4440 | printk(KERN_INFO "ide-tape: The device defaults in the prevent state - %s\n",capabilities->prevent ? "Yes":"No"); | ||
4441 | printk(KERN_INFO "ide-tape: Supports ejecting the medium - %s\n",capabilities->eject ? "Yes":"No"); | ||
4442 | printk(KERN_INFO "ide-tape: Supports error correction - %s\n",capabilities->ecc ? "Yes":"No"); | ||
4443 | printk(KERN_INFO "ide-tape: Supports data compression - %s\n",capabilities->cmprs ? "Yes":"No"); | ||
4444 | printk(KERN_INFO "ide-tape: Supports 512 bytes block size - %s\n",capabilities->blk512 ? "Yes":"No"); | ||
4445 | printk(KERN_INFO "ide-tape: Supports 1024 bytes block size - %s\n",capabilities->blk1024 ? "Yes":"No"); | ||
4446 | printk(KERN_INFO "ide-tape: Supports 32768 bytes block size / Restricted byte count for PIO transfers - %s\n",capabilities->blk32768 ? "Yes":"No"); | ||
4447 | printk(KERN_INFO "ide-tape: Maximum supported speed in KBps - %d\n",capabilities->max_speed); | ||
4448 | printk(KERN_INFO "ide-tape: Continuous transfer limits in blocks - %d\n",capabilities->ctl); | ||
4449 | printk(KERN_INFO "ide-tape: Current speed in KBps - %d\n",capabilities->speed); | ||
4450 | printk(KERN_INFO "ide-tape: Buffer size - %d\n",capabilities->buffer_size*512); | ||
4451 | #endif /* IDETAPE_DEBUG_INFO */ | ||
4452 | } | ||
4453 | |||
4454 | /* | ||
4455 | * ide_get_blocksize_from_block_descriptor does a mode sense page 0 with block descriptor | ||
4456 | * and if it succeeds sets the tape block size with the reported value | ||
4457 | */ | ||
4458 | static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive) | ||
4459 | { | ||
4460 | |||
4461 | idetape_tape_t *tape = drive->driver_data; | ||
4462 | idetape_pc_t pc; | ||
4463 | idetape_mode_parameter_header_t *header; | ||
4464 | idetape_parameter_block_descriptor_t *block_descrp; | ||
4465 | |||
4466 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | ||
4467 | if (idetape_queue_pc_tail(drive, &pc)) { | ||
4468 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | ||
4469 | if (tape->tape_block_size == 0) { | ||
4470 | printk(KERN_WARNING "ide-tape: Cannot deal with zero block size, assume 32k\n"); | ||
4471 | tape->tape_block_size = 32768; | ||
4472 | } | ||
4473 | return; | ||
4474 | } | ||
4475 | header = (idetape_mode_parameter_header_t *) pc.buffer; | ||
4476 | block_descrp = (idetape_parameter_block_descriptor_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t)); | ||
4477 | tape->tape_block_size =( block_descrp->length[0]<<16) + (block_descrp->length[1]<<8) + block_descrp->length[2]; | ||
4478 | tape->drv_write_prot = (header->dsp & 0x80) >> 7; | ||
4479 | |||
4480 | #if IDETAPE_DEBUG_INFO | ||
4481 | printk(KERN_INFO "ide-tape: Adjusted block size - %d\n", tape->tape_block_size); | ||
4482 | #endif /* IDETAPE_DEBUG_INFO */ | ||
4483 | } | 3627 | } |
4484 | 3628 | ||
4485 | #ifdef CONFIG_IDE_PROC_FS | 3629 | #ifdef CONFIG_IDE_PROC_FS |
@@ -4490,13 +3634,15 @@ static void idetape_add_settings (ide_drive_t *drive) | |||
4490 | /* | 3634 | /* |
4491 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function | 3635 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function |
4492 | */ | 3636 | */ |
4493 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, 1, 2, &tape->capabilities.buffer_size, NULL); | 3637 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3638 | 1, 2, (u16 *)&tape->caps[16], NULL); | ||
4494 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); | 3639 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); |
4495 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); | 3640 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); |
4496 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); | 3641 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); |
4497 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); | 3642 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); |
4498 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); | 3643 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); |
4499 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, 1, 1, &tape->capabilities.speed, NULL); | 3644 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3645 | 1, 1, (u16 *)&tape->caps[14], NULL); | ||
4500 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); | 3646 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); |
4501 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); | 3647 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); |
4502 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); | 3648 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); |
@@ -4528,6 +3674,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
4528 | struct idetape_id_gcw gcw; | 3674 | struct idetape_id_gcw gcw; |
4529 | int stage_size; | 3675 | int stage_size; |
4530 | struct sysinfo si; | 3676 | struct sysinfo si; |
3677 | u16 *ctl = (u16 *)&tape->caps[12]; | ||
4531 | 3678 | ||
4532 | spin_lock_init(&tape->spinlock); | 3679 | spin_lock_init(&tape->spinlock); |
4533 | drive->dsc_overlap = 1; | 3680 | drive->dsc_overlap = 1; |
@@ -4555,13 +3702,13 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
4555 | 3702 | ||
4556 | idetape_get_inquiry_results(drive); | 3703 | idetape_get_inquiry_results(drive); |
4557 | idetape_get_mode_sense_results(drive); | 3704 | idetape_get_mode_sense_results(drive); |
4558 | idetape_get_blocksize_from_block_descriptor(drive); | 3705 | ide_tape_get_bsize_from_bdesc(drive); |
4559 | tape->user_bs_factor = 1; | 3706 | tape->user_bs_factor = 1; |
4560 | tape->stage_size = tape->capabilities.ctl * tape->tape_block_size; | 3707 | tape->stage_size = *ctl * tape->tape_block_size; |
4561 | while (tape->stage_size > 0xffff) { | 3708 | while (tape->stage_size > 0xffff) { |
4562 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); | 3709 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); |
4563 | tape->capabilities.ctl /= 2; | 3710 | *ctl /= 2; |
4564 | tape->stage_size = tape->capabilities.ctl * tape->tape_block_size; | 3711 | tape->stage_size = *ctl * tape->tape_block_size; |
4565 | } | 3712 | } |
4566 | stage_size = tape->stage_size; | 3713 | stage_size = tape->stage_size; |
4567 | tape->pages_per_stage = stage_size / PAGE_SIZE; | 3714 | tape->pages_per_stage = stage_size / PAGE_SIZE; |
@@ -4570,11 +3717,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
4570 | tape->excess_bh_size = PAGE_SIZE - stage_size % PAGE_SIZE; | 3717 | tape->excess_bh_size = PAGE_SIZE - stage_size % PAGE_SIZE; |
4571 | } | 3718 | } |
4572 | 3719 | ||
4573 | /* | 3720 | /* Select the "best" DSC read/write polling freq and pipeline size. */ |
4574 | * Select the "best" DSC read/write polling frequency | 3721 | speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); |
4575 | * and pipeline size. | ||
4576 | */ | ||
4577 | speed = max(tape->capabilities.speed, tape->capabilities.max_speed); | ||
4578 | 3722 | ||
4579 | tape->max_stages = speed * 1000 * 10 / tape->stage_size; | 3723 | tape->max_stages = speed * 1000 * 10 / tape->stage_size; |
4580 | 3724 | ||
@@ -4591,7 +3735,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
4591 | tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; | 3735 | tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; |
4592 | 3736 | ||
4593 | t1 = (tape->stage_size * HZ) / (speed * 1000); | 3737 | t1 = (tape->stage_size * HZ) / (speed * 1000); |
4594 | tmid = (tape->capabilities.buffer_size * 32 * HZ) / (speed * 125); | 3738 | tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125); |
4595 | tn = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000); | 3739 | tn = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000); |
4596 | 3740 | ||
4597 | if (tape->max_stages) | 3741 | if (tape->max_stages) |
@@ -4606,8 +3750,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
4606 | tape->best_dsc_rw_frequency = max_t(unsigned long, min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN); | 3750 | tape->best_dsc_rw_frequency = max_t(unsigned long, min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN); |
4607 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " | 3751 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " |
4608 | "%dkB pipeline, %lums tDSC%s\n", | 3752 | "%dkB pipeline, %lums tDSC%s\n", |
4609 | drive->name, tape->name, tape->capabilities.speed, | 3753 | drive->name, tape->name, *(u16 *)&tape->caps[14], |
4610 | (tape->capabilities.buffer_size * 512) / tape->stage_size, | 3754 | (*(u16 *)&tape->caps[16] * 512) / tape->stage_size, |
4611 | tape->stage_size / 1024, | 3755 | tape->stage_size / 1024, |
4612 | tape->max_stages * tape->stage_size / 1024, | 3756 | tape->max_stages * tape->stage_size / 1024, |
4613 | tape->best_dsc_rw_frequency * 1000 / HZ, | 3757 | tape->best_dsc_rw_frequency * 1000 / HZ, |