1*4882a593Smuzhiyun/* 2*4882a593Smuzhiyun * Ver 0.1 Nov 1 95 Pre-working code :-) 3*4882a593Smuzhiyun * Ver 0.2 Nov 23 95 A short backup (few megabytes) and restore procedure 4*4882a593Smuzhiyun * was successful ! (Using tar cvf ... on the block 5*4882a593Smuzhiyun * device interface). 6*4882a593Smuzhiyun * A longer backup resulted in major swapping, bad 7*4882a593Smuzhiyun * overall Linux performance and eventually failed as 8*4882a593Smuzhiyun * we received non serial read-ahead requests from the 9*4882a593Smuzhiyun * buffer cache. 10*4882a593Smuzhiyun * Ver 0.3 Nov 28 95 Long backups are now possible, thanks to the 11*4882a593Smuzhiyun * character device interface. Linux's responsiveness 12*4882a593Smuzhiyun * and performance doesn't seem to be much affected 13*4882a593Smuzhiyun * from the background backup procedure. 14*4882a593Smuzhiyun * Some general mtio.h magnetic tape operations are 15*4882a593Smuzhiyun * now supported by our character device. As a result, 16*4882a593Smuzhiyun * popular tape utilities are starting to work with 17*4882a593Smuzhiyun * ide tapes :-) 18*4882a593Smuzhiyun * The following configurations were tested: 19*4882a593Smuzhiyun * 1. An IDE ATAPI TAPE shares the same interface 20*4882a593Smuzhiyun * and irq with an IDE ATAPI CDROM. 21*4882a593Smuzhiyun * 2. An IDE ATAPI TAPE shares the same interface 22*4882a593Smuzhiyun * and irq with a normal IDE disk. 23*4882a593Smuzhiyun * Both configurations seemed to work just fine ! 24*4882a593Smuzhiyun * However, to be on the safe side, it is meanwhile 25*4882a593Smuzhiyun * recommended to give the IDE TAPE its own interface 26*4882a593Smuzhiyun * and irq. 27*4882a593Smuzhiyun * The one thing which needs to be done here is to 28*4882a593Smuzhiyun * add a "request postpone" feature to ide.c, 29*4882a593Smuzhiyun * so that we won't have to wait for the tape to finish 30*4882a593Smuzhiyun * performing a long media access (DSC) request (such 31*4882a593Smuzhiyun * as a rewind) before we can access the other device 32*4882a593Smuzhiyun * on the same interface. This effect doesn't disturb 33*4882a593Smuzhiyun * normal operation most of the time because read/write 34*4882a593Smuzhiyun * requests are relatively fast, and once we are 35*4882a593Smuzhiyun * performing one tape r/w request, a lot of requests 36*4882a593Smuzhiyun * from the other device can be queued and ide.c will 37*4882a593Smuzhiyun * service all of them after this single tape request. 38*4882a593Smuzhiyun * Ver 1.0 Dec 11 95 Integrated into Linux 1.3.46 development tree. 39*4882a593Smuzhiyun * On each read / write request, we now ask the drive 40*4882a593Smuzhiyun * if we can transfer a constant number of bytes 41*4882a593Smuzhiyun * (a parameter of the drive) only to its buffers, 42*4882a593Smuzhiyun * without causing actual media access. If we can't, 43*4882a593Smuzhiyun * we just wait until we can by polling the DSC bit. 44*4882a593Smuzhiyun * This ensures that while we are not transferring 45*4882a593Smuzhiyun * more bytes than the constant referred to above, the 46*4882a593Smuzhiyun * interrupt latency will not become too high and 47*4882a593Smuzhiyun * we won't cause an interrupt timeout, as happened 48*4882a593Smuzhiyun * occasionally in the previous version. 49*4882a593Smuzhiyun * While polling for DSC, the current request is 50*4882a593Smuzhiyun * postponed and ide.c is free to handle requests from 51*4882a593Smuzhiyun * the other device. This is handled transparently to 52*4882a593Smuzhiyun * ide.c. The hwgroup locking method which was used 53*4882a593Smuzhiyun * in the previous version was removed. 54*4882a593Smuzhiyun * Use of new general features which are provided by 55*4882a593Smuzhiyun * ide.c for use with atapi devices. 56*4882a593Smuzhiyun * (Programming done by Mark Lord) 57*4882a593Smuzhiyun * Few potential bug fixes (Again, suggested by Mark) 58*4882a593Smuzhiyun * Single character device data transfers are now 59*4882a593Smuzhiyun * not limited in size, as they were before. 60*4882a593Smuzhiyun * We are asking the tape about its recommended 61*4882a593Smuzhiyun * transfer unit and send a larger data transfer 62*4882a593Smuzhiyun * as several transfers of the above size. 63*4882a593Smuzhiyun * For best results, use an integral number of this 64*4882a593Smuzhiyun * basic unit (which is shown during driver 65*4882a593Smuzhiyun * initialization). I will soon add an ioctl to get 66*4882a593Smuzhiyun * this important parameter. 67*4882a593Smuzhiyun * Our data transfer buffer is allocated on startup, 68*4882a593Smuzhiyun * rather than before each data transfer. This should 69*4882a593Smuzhiyun * ensure that we will indeed have a data buffer. 70*4882a593Smuzhiyun * Ver 1.1 Dec 14 95 Fixed random problems which occurred when the tape 71*4882a593Smuzhiyun * shared an interface with another device. 72*4882a593Smuzhiyun * (poll_for_dsc was a complete mess). 73*4882a593Smuzhiyun * Removed some old (non-active) code which had 74*4882a593Smuzhiyun * to do with supporting buffer cache originated 75*4882a593Smuzhiyun * requests. 76*4882a593Smuzhiyun * The block device interface can now be opened, so 77*4882a593Smuzhiyun * that general ide driver features like the unmask 78*4882a593Smuzhiyun * interrupts flag can be selected with an ioctl. 79*4882a593Smuzhiyun * This is the only use of the block device interface. 80*4882a593Smuzhiyun * New fast pipelined operation mode (currently only on 81*4882a593Smuzhiyun * writes). When using the pipelined mode, the 82*4882a593Smuzhiyun * throughput can potentially reach the maximum 83*4882a593Smuzhiyun * tape supported throughput, regardless of the 84*4882a593Smuzhiyun * user backup program. On my tape drive, it sometimes 85*4882a593Smuzhiyun * boosted performance by a factor of 2. Pipelined 86*4882a593Smuzhiyun * mode is enabled by default, but since it has a few 87*4882a593Smuzhiyun * downfalls as well, you may want to disable it. 88*4882a593Smuzhiyun * A short explanation of the pipelined operation mode 89*4882a593Smuzhiyun * is available below. 90*4882a593Smuzhiyun * Ver 1.2 Jan 1 96 Eliminated pipelined mode race condition. 91*4882a593Smuzhiyun * Added pipeline read mode. As a result, restores 92*4882a593Smuzhiyun * are now as fast as backups. 93*4882a593Smuzhiyun * Optimized shared interface behavior. The new behavior 94*4882a593Smuzhiyun * typically results in better IDE bus efficiency and 95*4882a593Smuzhiyun * higher tape throughput. 96*4882a593Smuzhiyun * Pre-calculation of the expected read/write request 97*4882a593Smuzhiyun * service time, based on the tape's parameters. In 98*4882a593Smuzhiyun * the pipelined operation mode, this allows us to 99*4882a593Smuzhiyun * adjust our polling frequency to a much lower value, 100*4882a593Smuzhiyun * and thus to dramatically reduce our load on Linux, 101*4882a593Smuzhiyun * without any decrease in performance. 102*4882a593Smuzhiyun * Implemented additional mtio.h operations. 103*4882a593Smuzhiyun * The recommended user block size is returned by 104*4882a593Smuzhiyun * the MTIOCGET ioctl. 105*4882a593Smuzhiyun * Additional minor changes. 106*4882a593Smuzhiyun * Ver 1.3 Feb 9 96 Fixed pipelined read mode bug which prevented the 107*4882a593Smuzhiyun * use of some block sizes during a restore procedure. 108*4882a593Smuzhiyun * The character device interface will now present a 109*4882a593Smuzhiyun * continuous view of the media - any mix of block sizes 110*4882a593Smuzhiyun * during a backup/restore procedure is supported. The 111*4882a593Smuzhiyun * driver will buffer the requests internally and 112*4882a593Smuzhiyun * convert them to the tape's recommended transfer 113*4882a593Smuzhiyun * unit, making performance almost independent of the 114*4882a593Smuzhiyun * chosen user block size. 115*4882a593Smuzhiyun * Some improvements in error recovery. 116*4882a593Smuzhiyun * By cooperating with ide-dma.c, bus mastering DMA can 117*4882a593Smuzhiyun * now sometimes be used with IDE tape drives as well. 118*4882a593Smuzhiyun * Bus mastering DMA has the potential to dramatically 119*4882a593Smuzhiyun * reduce the CPU's overhead when accessing the device, 120*4882a593Smuzhiyun * and can be enabled by using hdparm -d1 on the tape's 121*4882a593Smuzhiyun * block device interface. For more info, read the 122*4882a593Smuzhiyun * comments in ide-dma.c. 123*4882a593Smuzhiyun * Ver 1.4 Mar 13 96 Fixed serialize support. 124*4882a593Smuzhiyun * Ver 1.5 Apr 12 96 Fixed shared interface operation, broken in 1.3.85. 125*4882a593Smuzhiyun * Fixed pipelined read mode inefficiency. 126*4882a593Smuzhiyun * Fixed nasty null dereferencing bug. 127*4882a593Smuzhiyun * Ver 1.6 Aug 16 96 Fixed FPU usage in the driver. 128*4882a593Smuzhiyun * Fixed end of media bug. 129*4882a593Smuzhiyun * Ver 1.7 Sep 10 96 Minor changes for the CONNER CTT8000-A model. 130*4882a593Smuzhiyun * Ver 1.8 Sep 26 96 Attempt to find a better balance between good 131*4882a593Smuzhiyun * interactive response and high system throughput. 132*4882a593Smuzhiyun * Ver 1.9 Nov 5 96 Automatically cross encountered filemarks rather 133*4882a593Smuzhiyun * than requiring an explicit FSF command. 134*4882a593Smuzhiyun * Abort pending requests at end of media. 135*4882a593Smuzhiyun * MTTELL was sometimes returning incorrect results. 136*4882a593Smuzhiyun * Return the real block size in the MTIOCGET ioctl. 137*4882a593Smuzhiyun * Some error recovery bug fixes. 138*4882a593Smuzhiyun * Ver 1.10 Nov 5 96 Major reorganization. 139*4882a593Smuzhiyun * Reduced CPU overhead a bit by eliminating internal 140*4882a593Smuzhiyun * bounce buffers. 141*4882a593Smuzhiyun * Added module support. 142*4882a593Smuzhiyun * Added multiple tape drives support. 143*4882a593Smuzhiyun * Added partition support. 144*4882a593Smuzhiyun * Rewrote DSC handling. 145*4882a593Smuzhiyun * Some portability fixes. 146*4882a593Smuzhiyun * Removed ide-tape.h. 147*4882a593Smuzhiyun * Additional minor changes. 148*4882a593Smuzhiyun * Ver 1.11 Dec 2 96 Bug fix in previous DSC timeout handling. 149*4882a593Smuzhiyun * Use ide_stall_queue() for DSC overlap. 150*4882a593Smuzhiyun * Use the maximum speed rather than the current speed 151*4882a593Smuzhiyun * to compute the request service time. 152*4882a593Smuzhiyun * Ver 1.12 Dec 7 97 Fix random memory overwriting and/or last block data 153*4882a593Smuzhiyun * corruption, which could occur if the total number 154*4882a593Smuzhiyun * of bytes written to the tape was not an integral 155*4882a593Smuzhiyun * number of tape blocks. 156*4882a593Smuzhiyun * Add support for INTERRUPT DRQ devices. 157*4882a593Smuzhiyun * Ver 1.13 Jan 2 98 Add "speed == 0" work-around for HP COLORADO 5GB 158*4882a593Smuzhiyun * Ver 1.14 Dec 30 98 Partial fixes for the Sony/AIWA tape drives. 159*4882a593Smuzhiyun * Replace cli()/sti() with hwgroup spinlocks. 160*4882a593Smuzhiyun * Ver 1.15 Mar 25 99 Fix SMP race condition by replacing hwgroup 161*4882a593Smuzhiyun * spinlock with private per-tape spinlock. 162*4882a593Smuzhiyun * Ver 1.16 Sep 1 99 Add OnStream tape support. 163*4882a593Smuzhiyun * Abort read pipeline on EOD. 164*4882a593Smuzhiyun * Wait for the tape to become ready in case it returns 165*4882a593Smuzhiyun * "in the process of becoming ready" on open(). 166*4882a593Smuzhiyun * Fix zero padding of the last written block in 167*4882a593Smuzhiyun * case the tape block size is larger than PAGE_SIZE. 168*4882a593Smuzhiyun * Decrease the default disconnection time to tn. 169*4882a593Smuzhiyun * Ver 1.16e Oct 3 99 Minor fixes. 170*4882a593Smuzhiyun * Ver 1.16e1 Oct 13 99 Patches by Arnold Niessen, 171*4882a593Smuzhiyun * niessen@iae.nl / arnold.niessen@philips.com 172*4882a593Smuzhiyun * GO-1) Undefined code in idetape_read_position 173*4882a593Smuzhiyun * according to Gadi's email 174*4882a593Smuzhiyun * AJN-1) Minor fix asc == 11 should be asc == 0x11 175*4882a593Smuzhiyun * in idetape_issue_packet_command (did effect 176*4882a593Smuzhiyun * debugging output only) 177*4882a593Smuzhiyun * AJN-2) Added more debugging output, and 178*4882a593Smuzhiyun * added ide-tape: where missing. I would also 179*4882a593Smuzhiyun * like to add tape->name where possible 180*4882a593Smuzhiyun * AJN-3) Added different debug_level's 181*4882a593Smuzhiyun * via /proc/ide/hdc/settings 182*4882a593Smuzhiyun * "debug_level" determines amount of debugging output; 183*4882a593Smuzhiyun * can be changed using /proc/ide/hdx/settings 184*4882a593Smuzhiyun * 0 : almost no debugging output 185*4882a593Smuzhiyun * 1 : 0+output errors only 186*4882a593Smuzhiyun * 2 : 1+output all sensekey/asc 187*4882a593Smuzhiyun * 3 : 2+follow all chrdev related procedures 188*4882a593Smuzhiyun * 4 : 3+follow all procedures 189*4882a593Smuzhiyun * 5 : 4+include pc_stack rq_stack info 190*4882a593Smuzhiyun * 6 : 5+USE_COUNT updates 191*4882a593Smuzhiyun * AJN-4) Fixed timeout for retension in idetape_queue_pc_tail 192*4882a593Smuzhiyun * from 5 to 10 minutes 193*4882a593Smuzhiyun * AJN-5) Changed maximum number of blocks to skip when 194*4882a593Smuzhiyun * reading tapes with multiple consecutive write 195*4882a593Smuzhiyun * errors from 100 to 1000 in idetape_get_logical_blk 196*4882a593Smuzhiyun * Proposed changes to code: 197*4882a593Smuzhiyun * 1) output "logical_blk_num" via /proc 198*4882a593Smuzhiyun * 2) output "current_operation" via /proc 199*4882a593Smuzhiyun * 3) Either solve or document the fact that `mt rewind' is 200*4882a593Smuzhiyun * required after reading from /dev/nhtx to be 201*4882a593Smuzhiyun * able to rmmod the idetape module; 202*4882a593Smuzhiyun * Also, sometimes an application finishes but the 203*4882a593Smuzhiyun * device remains `busy' for some time. Same cause ? 204*4882a593Smuzhiyun * Proposed changes to release-notes: 205*4882a593Smuzhiyun * 4) write a simple `quickstart' section in the 206*4882a593Smuzhiyun * release notes; I volunteer if you don't want to 207*4882a593Smuzhiyun * 5) include a pointer to video4linux in the doc 208*4882a593Smuzhiyun * to stimulate video applications 209*4882a593Smuzhiyun * 6) release notes lines 331 and 362: explain what happens 210*4882a593Smuzhiyun * if the application data rate is higher than 1100 KB/s; 211*4882a593Smuzhiyun * similar approach to lower-than-500 kB/s ? 212*4882a593Smuzhiyun * 7) 6.6 Comparison; wouldn't it be better to allow different 213*4882a593Smuzhiyun * strategies for read and write ? 214*4882a593Smuzhiyun * Wouldn't it be better to control the tape buffer 215*4882a593Smuzhiyun * contents instead of the bandwidth ? 216*4882a593Smuzhiyun * 8) line 536: replace will by would (if I understand 217*4882a593Smuzhiyun * this section correctly, a hypothetical and unwanted situation 218*4882a593Smuzhiyun * is being described) 219*4882a593Smuzhiyun * Ver 1.16f Dec 15 99 Change place of the secondary OnStream header frames. 220*4882a593Smuzhiyun * Ver 1.17 Nov 2000 / Jan 2001 Marcel Mol, marcel@mesa.nl 221*4882a593Smuzhiyun * - Add idetape_onstream_mode_sense_tape_parameter_page 222*4882a593Smuzhiyun * function to get tape capacity in frames: tape->capacity. 223*4882a593Smuzhiyun * - Add support for DI-50 drives( or any DI- drive). 224*4882a593Smuzhiyun * - 'workaround' for read error/blank block around block 3000. 225*4882a593Smuzhiyun * - Implement Early warning for end of media for Onstream. 226*4882a593Smuzhiyun * - Cosmetic code changes for readability. 227*4882a593Smuzhiyun * - Idetape_position_tape should not use SKIP bit during 228*4882a593Smuzhiyun * Onstream read recovery. 229*4882a593Smuzhiyun * - Add capacity, logical_blk_num and first/last_frame_position 230*4882a593Smuzhiyun * to /proc/ide/hd?/settings. 231*4882a593Smuzhiyun * - Module use count was gone in the Linux 2.4 driver. 232*4882a593Smuzhiyun * Ver 1.17a Apr 2001 Willem Riede osst@riede.org 233*4882a593Smuzhiyun * - Get drive's actual block size from mode sense block descriptor 234*4882a593Smuzhiyun * - Limit size of pipeline 235*4882a593Smuzhiyun * Ver 1.17b Oct 2002 Alan Stern <stern@rowland.harvard.edu> 236*4882a593Smuzhiyun * Changed IDETAPE_MIN_PIPELINE_STAGES to 1 and actually used 237*4882a593Smuzhiyun * it in the code! 238*4882a593Smuzhiyun * Actually removed aborted stages in idetape_abort_pipeline 239*4882a593Smuzhiyun * instead of just changing the command code. 240*4882a593Smuzhiyun * Made the transfer byte count for Request Sense equal to the 241*4882a593Smuzhiyun * actual length of the data transfer. 242*4882a593Smuzhiyun * Changed handling of partial data transfers: they do not 243*4882a593Smuzhiyun * cause DMA errors. 244*4882a593Smuzhiyun * Moved initiation of DMA transfers to the correct place. 245*4882a593Smuzhiyun * Removed reference to unallocated memory. 246*4882a593Smuzhiyun * Made __idetape_discard_read_pipeline return the number of 247*4882a593Smuzhiyun * sectors skipped, not the number of stages. 248*4882a593Smuzhiyun * Replaced errant kfree() calls with __idetape_kfree_stage(). 249*4882a593Smuzhiyun * Fixed off-by-one error in testing the pipeline length. 250*4882a593Smuzhiyun * Fixed handling of filemarks in the read pipeline. 251*4882a593Smuzhiyun * Small code optimization for MTBSF and MTBSFM ioctls. 252*4882a593Smuzhiyun * Don't try to unlock the door during device close if is 253*4882a593Smuzhiyun * already unlocked! 254*4882a593Smuzhiyun * Cosmetic fixes to miscellaneous debugging output messages. 255*4882a593Smuzhiyun * Set the minimum /proc/ide/hd?/settings values for "pipeline", 256*4882a593Smuzhiyun * "pipeline_min", and "pipeline_max" to 1. 257*4882a593Smuzhiyun */ 258