aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
authorBorislav Petkov <bbpetkov@yahoo.de>2008-02-02 13:56:48 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:48 -0500
commit5ce78af4beeca6c80d8a4834f74297a8fa2e2253 (patch)
treeca3af7db59981109475ba2dec4d0ea7e8250c742 /drivers/ide/ide-tape.c
parentdcb425f557eb01e73614f2292f0a92ce02e40e2a (diff)
ide-tape: move historical changelog to Documentation/ide/ChangeLog.ide-tape.1995-2002
Also, cleanup whitespace and update comments. Bart: - remove reference to drivers/block/ide.c - move driver documentation to Documentation/ide/ide-tape.txt Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r--drivers/ide/ide-tape.c414
1 files changed, 4 insertions, 410 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index eff118ba217c..045bd2ae0c0f 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 *
321 */
322
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 * 13 *
418 * ATAPI overlap is likely to be supported in most new ATAPI 14 * For a historical changelog see
419 * devices, including new ATAPI cdroms, and thus provides us 15 * Documentation/ide/ChangeLog.ide-tape.1995-2002
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"