summaryrefslogtreecommitdiff
path: root/sys/scsi/sd.c
AgeCommit message (Collapse)Author
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-27get rid of the rest of the asc/ascq magic codes in scsiBob Beck
ok marco@, deraadt@
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-07-29The version field of scsi_inquiry_data is not a simple numeric valueKenneth R Westerback
that specifies the version of SCSI being supported. Even the ANSI part that we use is complex. 4 means 2, 5 means 3 and 6 means 4. Translate and use the value correctly. Fixes SCSI5 and SCSI6 in dmesg. And properly protects SCSI2 devices from getting SCSI3 commands. "seems like an elegant solution to me" millert@ ok dlg@ marco@
2006-07-23remove some scsi ioctls, most importantly the ones that can reprobe theDavid Gwynne
bus. supporting these complicates the midlayer unnecessarily. ok krw@
2006-07-13Eliminate scsi_link field 'scsi_version' and just use the INQUIRY dataKenneth R Westerback
stored in scsi_link. That's where the value came from anyway. Move 'luns' field to where 'scsi_version' used to be to preserve alignment. ok dlg@
2006-07-11the scsi_link structure contained a copy of the inquiry flags and the wholeDavid Gwynne
inquiry. this removes the flags member and makes all its users refer to the whole inquiry now. ok miod@ krw@
2006-05-18Test the state of a disk *after* spinning it up and not before. ThisKenneth R Westerback
prevents the issuing of sizing inquiries to non-existant or non-responsive devices like empty slots on a USB card reader. Also try to avoid *extremely* unlikely loop of scsi_start() commands, by not using sd_interpret_sense() until after the disk is spinning. ok dlg@
2006-05-11Zap trailing whitespace.Kenneth R Westerback
2006-03-15Nuke dk_establish(), no longer used.Miod Vallat
2006-03-05Remove NetBSDism NRND. Pointed out by Mickey.Kenneth R Westerback
ok miod@ marco@
2006-03-04Typos grab bag of the month, eyeballed by jmc@Miod Vallat
2006-01-21Invoke disk_detach() and related cleanup work in detach(), rather thanMiod Vallat
zeroref() - just to be on the safe side, should we mess up our ref count.
2005-11-17Don't forget to device_unref() in sdclose() if sdlock() fails; ok krw@Miod Vallat
2005-11-17Use sectors as the size units for the RAW_PART (i.e. 'c') partition inKenneth R Westerback
spoofed sd disklabels. Sectors are the partition size units used and documented everywhere else in the tree. sd ensures a sector will always be a multiple of 512. Fixes disklabel(8) error messages and partition size display for sd devices that have no OpenBSD disklabel and a sectorsize > 512. Noted by Robert Szasz on his Sony Hi-MD device. ok pedro@ marco@
2005-11-13Allow removable disks to be spun up if they ask for initializationKenneth R Westerback
after being opened. Use SC_DEBUG() to suppress some verbiage during spin up. Return actual errors encountered during attempt to spin up, rather than always returning EIO. ok dlg@
2005-11-13Use scsi_delay() instead of delay() when waiting for scsi disk toKenneth R Westerback
become ready. Make verbiage SC_DEBUG(). ok dlg@
2005-11-07Death to superfluous verbiage. Suppress errors when getting the parametersKenneth R Westerback
for a raw partition like we suppress errors for the other operations on raw partitions. Replace 'could not get size' with more specific and informative SC_DEBUG() output. Silences a usb card reader that fgsch@ found. Now attach message is only 'sdX: drive offline'. Tested & ok fgsch@
2005-10-10Make some panic messages more useful.Kenneth R Westerback
2005-09-19Use variable to eliminate repeated calculation. More readable. NoKenneth R Westerback
functional change. ok dlg@
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-09-11Some UMASS devices blow up if MODE SENSE buffer length is 0 (aka 256).Kenneth R Westerback
Some blow up if buffer length is not 0. Just fake geometry for all UMASS devices since it's almost always fictitious anyway. One step on the road to eliminate geometry entirely. Fixes Ed Wandasiewicz's 2nd gen iPod mini and Sebastiaan Indesteege's UBest Technology device. ok marco@
2005-09-08free(NULL, ...) is not safe in the kernel. So check for NULL'nessKenneth R Westerback
before free()'ing buf in sd_get_parms(). Tweak code so there is only one free(buf, ...) to worry about. ok deraadt@.
2005-08-27Put in missing parenthesis and thus always passKenneth R Westerback
SCSI_IGNORE_ILLEGAL_REQUEST and SCSI_IGNORE_MEDIA_CHANGE flags to scsi_test_unit_ready() and scsi_start() during sdopen(). Re-enables use of devices that don't support START_STOP or TEST_UNIT_READY commands. Noted by and fix tested by Jason Crawford on VMWare disks. ok dlg@ henning@, supportive comments from miod@.
2005-08-24Test xs->bp before de-referencing it. Initialize it to NULL, not 0.Kenneth R Westerback
ok deraadt@
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-08-23Spin up sd units even if TEST_UNIT_READY says they're ready.Kenneth R Westerback
Use consistant scsi_autoconf and SCSI_SILENT flags in scsi_test_unit()/scsi_start() pairs. Fixes some hppa, vax, sparc systems that do not spin up disks automatically. Keeps USB card readers and such reasonably quiet. Noted by millert@ (hppa), henning@ (sparc) and hshoexer@ (vax). ok deraadt@
2005-08-21Some devices go berserk when asked for mode sense pages they don'tKenneth R Westerback
have. Some devices return four bytes less information than requested for the PAGE_RIGID_GEOMETRY page. Put the two together and older Conner drives don't work because we rejected the short page and asked for the PAGE_FLEX_GEOMETY page. Noted by hshoexer@ and kettenis@. Also should fix the problems with a device miod@ reported that did a similar short PAGE_FLEX_GEOMETRY. ok deraadt@
2005-08-18Only allow blocksizes that are powers of 2 between 512 and 64K. An sdKenneth R Westerback
device that returns any other value via READ CAPACITY or MODE SENSE will be marked 'drive offline'. Prevents divide by zero when calculating disk size in MB, amoung other interesting possibilities. ok mickey@ dlg@ deraadt@ millert@ marco@
2005-08-17Use defines for disk mode page codes. Check returned mode pages toKenneth R Westerback
ensure they are the ones requested. No functional change unless garbage was being returned. ok marco@
2005-08-12Move disk mode page structure declarations out of scsi_disk_pagesKenneth R Westerback
union declaration to allow pointers to individual page types. Simplify sd.c code by using individual page type pointers. No functional change. ok tdeval@
2005-07-30Use the blocksize returned from scsi_size() in preference to allKenneth R Westerback
other values as was intended. As opposed to overwriting it with scsi_do_mode_sense() calls. May help PR4313. ok tdeval@
2005-07-05Since scsi_link now includes a copy of the INQUIRY data, don't keep aKenneth R Westerback
copy of the vendor/product/revision fields in sd_softc. Just use the INQUIRY data to build the disklabel 'label' when required. No functional change.
2005-07-02Remove unused cd_softc.name field. Use the saved INQUIRY data inKenneth R Westerback
scsi_link to determine device type, rather than keeping a copy in sd_softc.type. Remove unused sd_softc.type field.
2005-07-02Remove unused struct sd_ops.Kenneth R Westerback
2005-07-02Don't use READ FORMAT CAPACITIES to determine the size of ATAPI sdKenneth R Westerback
devices. Use READ CAPACITY like NetBSD, FreeBSD, Linux and OpenSolaris do. Well, NetBSD keeps READ FORMAT CAPACITIES as a backup. Fixes problems with devices (such as my IBM USB Memory Key) which return block counts that are off by one for READ FORMAT CAPACITIES. This eliminates the significant difference between sd_atapi.c and sd_scsi.c so merge sd_scsi.c into sd.c and just be careful to mark ATAPI removable devices as both SDEV_NOSYNCCACHE and unable to return MODE SENSE page 4 info. All geometry faking is now in one place. Where it can be 'improved'. sd_scsi.c, sd_atapi.c and atapi_disk.h will be removed as a result.
2005-05-03sdstrategy() shouldn't use values in disklabel until SDEV_MEDIA_LOADEDKenneth R Westerback
is checked. Fixes crash during boot when a device has no media loaded. e.g. a usb card reader with empty slots. From NetBSD. Problem was introduced by last commit to allow RAW_PART+S_IFCHAR opens to always succeed. ok millert@ marco@
2005-05-01Allow RAW_PART+S_IFCHR device opens to succeed even if media notKenneth R Westerback
present. A successful open is required for ioctl's to work. Mostly from NetBSD, partly correcting previous code cleanup error. From deraadt@, treat MTIOCTOP+MTRETEN as CDIOCCLOSE for cd devices (i.e. close the cd drawer). ok deraadt@.
2005-04-06De-register scsi.Kenneth R Westerback
2005-04-05Clean up some logic. Use better error handling for sd devices. BeKenneth R Westerback
quiet if raw partition access tried. Be more careful with SDEV_MEDIA_LOADED. Inspired by some NetBSD changes. ok marco@
2005-03-30Comment typo, minor knf. No code change.Kenneth R Westerback
2005-03-25Since START_STOP is an optional command that a device need notKenneth R Westerback
support, don't penalize devices that don't support it. May help some usb devices. ok marco@
2005-02-27If test_unit_ready() in sdattach() returns EIO, try to spin up unitKenneth R Westerback
exactly as is done in sdopen(). This improves the chances of getting valid geometry/size and avoiding 'drive offline' errors, without subjecting the device to anything it won't see anyway. No impact on devices that already work. Fixes problem with Jim Rees' Hitachi DK23DA in an Archos Multimedia Jukebox. Without adding quirks! Tested by Jim Rees. ok marco@.
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-09Add missing <cr>'s to various SC_DEBUG() calls, along with a few otherKenneth R Westerback
SC_DEBUG() spacing tweaks. ok deraadt@
2004-02-21Eliminate the quirks SDEV_NOSTARTUNIT, UMASS_QUIRK_NO_START_STOP, andKenneth R Westerback
UMASS_QUIRK_FORCE_SHORT_INQUIRY. Fixes a bunch of USB devices. Based on work by Mycroft in NetBSD. ok tdeval@ deraadt@.