summaryrefslogtreecommitdiff
path: root/sys/scsi/st.c
AgeCommit message (Collapse)Author
2008-05-12Fix device reference counting. Now that we try to support detachableKenneth R Westerback
tape drives it is nice not to crash if one is detached. Basically use a consistant mechanism modelled on sd to lookup devices and do the device reference increments and decrements. Problem reported (PR#5811) and fix tested by Jozef Hatala. Still some corner cases Jozef is looking for but we'll fix those as discovered.
2008-05-09Oops. When detaching tape drives look for devices using 'stopen' notKenneth R Westerback
devices using 'sdopen'. PR#5810 from Jozef Hatala. ok beck@
2007-11-27typos; ok jmc@Martynas Venckus
sys/dev/pci/pciide.c from naddy@
2007-11-22Ansi-fy.Kenneth R Westerback
2007-11-22Ooops. Don't de-reference st until after it has been pointed at theKenneth R Westerback
correct st_softc. Fixes 'mt rewoffl' panics, as reported on misc@ by Jeff Ross and reproduced on my tape machine.
2007-11-16convert code over from sd.c, to let tapes discollect. Lucas StefanuttiTheo de Raadt
of pr 5635 confirms this works for him. similar diff authored by krw who was unaware i wrote this and mailed it to Lucas...
2007-09-16A couple of obvious bzero() -> M_ZERO changes I missed.Kenneth R Westerback
2007-06-06now that all partition size/offsets are potentially 64-bit, change theTheo de Raadt
type of all variables to daddr64_t. this includes the APIs for XXsize() and XXdump(), all range checks inside bio drivers, internal variables for disklabel handling, and even uvm's swap offsets. re-read numerous times by otto, miod, krw, thib to look for errors
2007-06-01No need for tape fields to be daddr_t. int will do.Kenneth R Westerback
ok beck@ deraadt@
2007-04-10``it's'' -> ``its'' when the grammar gods require this change.Miod Vallat
2007-01-20Add media_fileno, media_blkno into st_softc and report their valuesKenneth R Westerback
back via MTIOCGET ioctl, rather than always reporting -1 (unknown). Simple 'Set to 0 on rewind, increment on file marks and positioning, and set back to -1 on any ambiguity' logic. No functional impact on current operation. Should allow things like Bacula to work much faster by keeping track of the current media position. Adapted from FreeBSD code. ok beck@
2007-01-05As first brought to my attention by Russel Sutherland, our deletion ofKenneth R Westerback
the mt_fileno and mt_blkno fields from the mtget struct was too hasty. Subsequent discussions with Kern Sibbold of the Bacula project revealed these are widely used by tape backup software on many unicies. The de facto standard is to return -1 if you can't determine the value. So add them back and always return -1 as their value. Should allow Bacula and similar software to at least compile while we investigate providing meaningful values. ok beck@
2006-12-21Fix some comment typos. 'immediatly' -> 'immediately', 'tranfer' ->Kenneth R Westerback
'transfer', 'tranfered' -> 'transferred'.
2006-12-12Give the SCSI layer the ability to requeue i/o's rejected by a driverKenneth R Westerback
using the new NO_CCB result. Currently a no-op since no driver produces that result. ok dlg@ marco@ deraadt@
2006-11-28rename scsibus_attach_args to scsi_attach_args. this can help avoidDavid Gwynne
confusing when trying to attach scsibus to a hba, since it is really meant for attaching scsi devices to scsibus. ok deraadt@ marco@
2006-11-27more magic removalBob Beck
ok miod@, deraadt@
2006-11-27rework asc/ascq handling to get rid of "magic" 0x values in the code, changesBob Beck
asc/ascq handling to deal with the pair together rather than seperately, since modern scsi has long since polluted the "categories" of asc enough that you pretty much need to always look as ascq. ok krw@ deraadt@, dlg@
2006-10-07make cd-roms retry forever while the device indicates that it isBob Beck
"becoming ready" - this is done in the exact same way that it was done for tape in st.c. This commit adds a cd specific interpret_sense routine to cd.c that will catch the becoming ready case and handle it. This also removes the need to use crazy timeouts to catch this case. ok krw@
2006-10-02get rid of a boolean typedef. this is c, we have ints, deal with it.David Gwynne
ok marco@ krw@
2006-06-11Don't spew sense informaton from the test unit ready command issued byKenneth R Westerback
stopen(). This change was misplaced in the st roto-tilling at c2k6. Noticed by deraadt@.
2006-06-01We do not create st devices with different density modes. i.e. with deviceKenneth R Westerback
minor numbers having bits 2 or 3 set. Eliminate the quirks, etc. used to store info on these non-existant modes. Also eliminate a couple of 'unimplemented' fields in the ioctl request structure. ok beck@ deraadt@
2006-05-28Miscellaneous fixes.Kenneth R Westerback
1) Check the return value from st_mount_tape(). 2) Always call st_unmount() if the media goes missing. 3) Use the special handling for 'Unit in the process of becoming ready' for the TEST UNIT READY command in stopen(). 4) Don't unmount a tape during stopen() just because it doesn't have the current default density. Eliminate now unused last_dsty member of st_softc. tested & ok beck@
2006-05-28This commit changes the interpret_sense routine for st to catch theBob Beck
"Unit Becoming Ready" case, and just like ch, allow the driver to continue waiting, as long as the unit continues to promise us that the unit is becoming ready. This avoids the case of slow tape drives taking forever to bring media online requiring a huge retry count being set for all commands, and like ch, will wait indefinately only in this case. All other cases are handled as before. ok krw@
2006-05-28In the absence of a coherent concept of 'RAW' tape devices, pass allKenneth R Westerback
unhandled ioctl requests to scsi_do_ioctl() like ch.c does. Previously only the mythical 'control devices' with certain minor numbers would pass the requests along. ok beck@
2006-05-28Whack a 'control device' leftover. Actually save the new density, etc.Kenneth R Westerback
that was just accepted by the device, no matter what the minor is. ok beck@
2006-05-28We don't have 'control devices' for st. Nor are we likely to get anyKenneth R Westerback
in the foreseeable future. Eliminate half-baked, semi-operational code that tried to handle such devices. People who had stumbled across the previous control-like behaviour of erstX devices should not be relying on these semantics. Suggested by deraadt@. ok beck@
2006-05-28ST_NEW_MOUNT was set/reset in a number of places but only examined insideKenneth R Westerback
a #if notyet/#endif block. It's been 'notyet' since 1995. Eliminate it. 'flense!' beck@
2006-05-28Use TEST_READY_RETRIES_TAPE instead of TEST_READY_RETRIES_DEFAULT,Kenneth R Westerback
thus allowing tape drives more time to become ready. ok beck@
2006-05-28Use bit 23 of the device minor to indicate a control mode device. AKenneth R Westerback
control mode device can be opened but does not permit any i/o. Currently no such devices are created by MAKEDEV. However the previous code used bits 0 and 1 of the minor being set to indicate a control device. This conflicted with other uses of device minors to indicate things like rewind and eject. This behaviour would result in an open of a newly loaded tape drive failing until the tape was successfully mounted as a side effect of another command like 'mt status'. ok beck@
2006-05-28Always allow ioctl's to work, even if there is no media loaded.Kenneth R Westerback
Analogous to what sd does for the raw partition. Eliminates useless error messages and premature command completion. e.g. 'mt status' will wait for media to to finish loading. ok beck@
2006-05-28Don't print tape media information during probe. This is transitoryKenneth R Westerback
information that doesn't have anything to do with the device. We don't say 'cd drive empty or not ready." ok beck@
2006-05-11Zap trailing whitespace.Kenneth R Westerback
2005-09-11Simplify code by changing struct scsi_mode_sense_buf{ union {}Kenneth R Westerback
headers; } to just union scsi_mode_sense_buf {}. No functional change. ok marco@
2005-08-23Move uses of struct scsi_mode_sense_buf (255 bytes each) from theKenneth R Westerback
stack into malloc'd memory. ok deraadt@
2005-06-24Move st.c to new mode sense mechanism. Don't save page0 data (if any), justKenneth R Westerback
ask for it when needed. Eliminate the page_0_size quirk. Tested on various tape drives by myself, hshoexer@ and henning@.
2005-06-05Fix scsi_mode_select() and scsi_mode_select_big() to send just theKenneth R Westerback
required number of bytes, rather than a full scsi_mode_sense_buf. Some devices (e.g. my HP SureStore DAT/24) decline to accept such oversized transfers. Instead, force callers to fill in the data_length field in the header and use that information to set the size of the transfer.
2005-05-14Add scsi_mode_[sense|select]_big() and use it instead ofKenneth R Westerback
atapi_mode_[sense|select](). This will allow the removal of atapi_base.c and atapi_all.h files, and sets the stage for better usb mode sense handling amoung other things. Remove cd_scsibus_[get|set]_mode() and sd_scsibus_mode_sense() shims in favour of scsi_mode_[sense|select](). Add zero'ing of reserved length field in scsi_mode_select(). Change some uchar * type parameters to scsi_mode_header *. No functional changes. Mostly from NetBSD. ok dlg@.
2005-04-06De-register scsi.Kenneth R Westerback
2005-04-05Factor out scsi_mode_sense() and scsi_mode_select() like NetBSD does.Kenneth R Westerback
Eliminate some duplicate structures and defines along the way. SCSI CD drives will now pay attention to the 'flags' parameter for MODE SENSE and MODE SELECT commands. No other functional change. ok tdeval@
2004-11-30No longer require write permission for read-only SCSI commandsKenneth R Westerback
submitted via ioctl. Eliminate scsi_do_safeioctl(), thus permitting ch, ss and st devices to submit SCSI commands. Return EPERM rather than EBADF when permissions are inadequate. Allows more programs to run with fewer permissions. Problem diagnosed by Nikolay Sturm in mplayer port. Tested by Nikolay, ok deraadt@.
2004-10-16Fix 'Tape block size (32754) not a multiple of dump block sizeKenneth R Westerback
(1024).' errors in restore(1). Check for SDEV_OPEN in sc_link->flags (where it lives) rather than sense->flags (where it doesn't). Problem noted by John Danks on misc@ and reinforced by Otto & Hugh. ok marco@ hugh@.
2004-08-01Remove openings = 1 and inherit the value from the HBA instead. This keeps ↵Marco Peereboom
the tape device stuffed with data and therefore it rewinds less often to reposition. ok krw@
2004-06-22Add additional retries in TUR to allow for tape devices to settle after a reset.Marco Peereboom
More informative failure message and silence "already open" message. ok krw@
2004-05-28Clean up sense error logic and printing a bit, partly inspired byKenneth R Westerback
NetBSD. Try to limit special handling of sense errors in sd and st to a minimum. ok marco@
2004-05-17Elminate SCSIRET_* synonyms for EJUSTRETURN and ERESTART by usingKenneth R Westerback
EJUSTRETURN and ERESTART instead. Delete unused SCSIRET_RETRY define. From NetBSD. ok marco@
2004-05-17Add a quirk entry for TEAC compact cassette tape drive, taken from NetBSD.Kenji Aoyama
ok miod@ tdeval@ marco@ krw@
2004-05-09Add missing <cr>'s to various SC_DEBUG() calls, along with a few otherKenneth R Westerback
SC_DEBUG() spacing tweaks. ok deraadt@
2003-05-18constify the quirck tables and fix the scsi_inqmatch() proto accordingly; ↵Michael Shalayeff
krw@ ok
2003-03-11Fix incorrect restriction on valid scsi tape density code values, allowing allKenneth R Westerback
currently valid values (0 - 0xff) to be used in mt(1). Add sanity check to catch negative values. Minor cleanup so mt_count values are stored in daddr_t variables and not ints. Eliminate unnecessary cast of mt_op, since it is already a shot. Leave possible move of mt_count to int32_t rather than daddr_t to post-3.3. Problem found, and original diff by Joseph Bender. costa@ henning@ tdeval@ ok
2002-12-30Add new parameter to scsi_test_unit_ready(): retries number.Alexander Yurchenko
Use increased retries number and don't ignore SCSI_IGNORE_NOT_READY when call scsi_test_unit_ready() for cd-rom, this makes system wait if drive is loading media. Tested by millert@ and fgsch@; some input and ok from krw@. Problem reported by The lord of the CD-writers Igor Grabin <violent@death.kiev.ua>.