summaryrefslogtreecommitdiff
path: root/sys/scsi/scsi_base.c
AgeCommit message (Collapse)Author
2006-08-04Add ENOMEDIUM and EMEDIUMTYPE to report medium errors to userland programsBob Beck
when using removable media devices, along with changes to scsi_base to detect such cases in tapes other devices. This makes tar, dd, and friends report a semi useful error message instead of nonsense when there is nothing in the device. Includes libc minor bump, and will require the corresponding sets change. ok krw@ deraadt@
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-23Use REPORT LUNS to get the list of LUNs to probe. If such a list isKenneth R Westerback
obtained probe the LUNs given without checking for duplicate INQUIRY data. For non-USB, non-ATAPI, devices claiming to be SCSI-3 compliant. And the target must have something attached at LUN 0. If REPORT LUNS can't be used or isn't supported, the old scan process is used. Fixes Fibre Channel and SCSI enclosure devices that provide identical INQUIRY data for all LUNs and were thus being misprobed as having only LUN 0. Tested by Bob Kitella, dlg@, beck@. Suggestions from deraadt@. ok dlg@ beck@
2006-07-22If the LUN is > 7, don't try to stuff it into the three bits availableKenneth R Westerback
in the CDB for pre-IDENTIFY device LUNs.
2006-07-15catch "Media Removal Prevented" for devices that are capable of telling usBob Beck
when we're not allowed to yank things out of them. Instead of returning a generic EIO and having the kernel printf a scsi sense to the console, we now return EBUSY to userland and avoid the dmesg spewing. 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-11scsi_get_xs raises splbio, but didnt lower it on error. tsk tsk.David Gwynne
ok krw@
2006-07-11knf and ansi. no binary changeDavid Gwynne
2006-05-28Add PCATCH to tsleep flags when a scsi command is waiting for an openingBob Beck
or is waiting to be retried, abort it when a signal interrupts the tsleep(). This fixes what was commited in version 1.92 to work properly. ok krw@
2006-05-13When SCSIDEBUG'ing, display the return value of scsi_interpret_sense()Kenneth R Westerback
in hex. This makes it consistant with the display of the same value in other messages.
2006-05-11Zap trailing whitespace.Kenneth R Westerback
2006-05-07If a device says a MODE SENSE command worked fine, do *not* try a MODEKenneth R Westerback
SENSE BIG command even if no page data was returned. Just accept the fact that the device does not have any such page data. This is more in line with the spec, and unbreaks devices (like the Neodio 8-in-1 USB Card Reader donated by Manuel Pata) which freak out when getting a MODE SENSE BIG. Should not break any 'working' device. ok pedro@ dlg@ marco@ 'Looks correct.' miod@
2006-05-07Zap a bunch of trailing whitespace.Kenneth R Westerback
2006-02-06typos from alexey dobriyan;Jason McIntyre
2005-11-28fix month-old breakage found by genududes (after henning's breakage)Michael Shalayeff
2005-11-13ATAPI Tape drives need 6 byte MODE SENSE commands according to atKenneth R Westerback
least one spec. Unlike other ATAPI devices. Fixes PR #4611.
2005-11-13Use SCSI_DELAY only once. Document it. Default to no delay.Kenneth R Westerback
Fixes two second system 'freeze' when umass device plugged in. Speeds up boot by not waiting for a minimum of 2 seconds at each scsi bus. ok jmc@ pedro@ deraadt@
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-11-02Abstract delay code out and call it directly from XX_interpret_sense.Kenneth R Westerback
Makes the logic simpler by eliminating the XS_BUSY dance in xs->error, and will allow individual device types to delay different lengths on certain conditions. Allow SCSI_NOSLEEP commands to be retried without waiting. Who knows, they may work even without a delay. ok marco@
2005-10-22When a scsi command is waiting for an opening or is waiting to be retried,Kenneth R Westerback
abort it when a signal interrupts the tsleep(). Suggested by deraadt@. "I really like this" deraadt@ "I like this" marco@
2005-10-16Don't pound UNIT ATTENTION retries in as fast as possible. If we areKenneth R Westerback
going to retry the command, pause for a second to let the condition clear. Just as we do for certain NOT READY conditions. Found with the help of, and fixes Ed Wandasiewicz's IBM USB Memory key. ok deraadt@
2005-10-10Make some panic messages more useful.Kenneth R Westerback
2005-10-04shorter name for wait channelTheo de Raadt
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-29If a buffer larger than the max allowed is offered to scsi_mode_sense()Kenneth R Westerback
or scsi_mode_sense_big(), use as much of it as is allowed. Don't justi mask off the higher bits and possibly leave yourself with 0 space. Fixes problem aoyama@ found on luna88k tape drive. ok deraadt@.
2005-08-01Return 0 as the block size when READ_CAPACITY fails in scsi_size().Kenneth R Westerback
Prevents garbage being used as ssblksize in sd_get_parms(). Perhaps another nail in the coffin for PR4313.
2005-06-23Don't discard the blocksize information provided by the READ CAPACITYKenneth R Westerback
command. Return it in a new parameter to scsi_size.
2005-06-18Shorten a couple of structure names:Kenneth R Westerback
scsi_mode_direct_blk_desc -> scsi_direct_blk_desc scsi_mode_blk_desc_big -> scsi_blk_desc_big
2005-06-18Switch to trying 6 byte MODE SENSE commands (for non ATAPI devices atKenneth R Westerback
least) before 10 byte MODE SENSE. Some older devices can't/won't distinguish between the two and return 6 byte MODE SENSE data for 10 byte requests. Check that at least a full header was returned. Tested by miod@ hshoexer@ and Ed Wandasiewisz on troublesome devices.
2005-06-12It turns out you need to ask for 16 byte block descriptors. We don't,Kenneth R Westerback
so eliminate code dealing with 16 byte block descriptors. No one else seems to use them anyway. Add define for appropriate permission bit in case we ever need it. Simplify and clean up scsi_do_mode_sense() code as a result. Strengthen check to ensure block descriptor data is a valid by checking if it is a multiple of 8 bytes rather than just > 8 bytes. Moves code to closer to what it was before scsi_do_mode_sense().
2005-06-09Fix typo in ASC/ASQ messages: DEnied -> Denied.Kenneth R Westerback
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-06-04Make scsi_do_mode_sense() aware of the difference between the 8 byteKenneth R Westerback
general block descriptor and the 8 byte direct block descriptor, and return the correct values for density, block_count and block_size based on the type of the device. First cut has T_SEQUENTIAL (i.e. tape devices) as the only device type using general block descriptors, so the behaviour change is minimal.
2005-06-03Tweak scsi_do_mode_sense(). NetBSD was right and I was wrong. Sigh.Kenneth R Westerback
Add 'big' parameter to report which mode sense header type is being returned. Eliminate icky pointer arithmetic, since it won't work if only block descriptors are returned by the device. No functional change.
2005-06-02Fix pasto - use correct pointer to extract block count from 8 byteKenneth R Westerback
block descriptors. Not that we actually use this information anywhere.
2005-05-31Remove unused sc_err1() parameter 'async'. Lint.Kenneth R Westerback
2005-05-28Sprinkle some /* FALLTHROUGH */'s as suggested by lint.Kenneth R Westerback
2005-05-28'openings' is u_int16_t, so 'openings <= 0' is wrong. Lint.Kenneth R Westerback
2005-05-28Forgot to specify parameter type. Lint.Kenneth R Westerback
2005-05-28snprintf returns int not size_t. Thank you lint.Kenneth R Westerback
2005-05-28Add _lto8b() and _8btol() to decode nblocks field ofKenneth R Westerback
scsi_mode_blk_desc_big. Will be needed to move st to new mode sense function. Be a bit more careful with types of parameters to scsi_do_mode_sense, using u_int32_t instead of int. No functional change.
2005-05-25Introduce safer, more general mode sense capability. Transparently useKenneth R Westerback
both 10 byte and 6 byte MODE SENSE commands and just return error checked values. Convert sd_scsi.c to use new mechanism for non-optical drives. USB umass devices will now display actual mode sense info if it is available via a 10 byte MODE SENSE. Which may mean 0 heads, etc. is shown until cosmetics are finalized. ok marco@ 'that is pretty cool' deraadt@
2005-05-22Check if the scsi_request has been released in the COMPLETE case asKenneth R Westerback
was already done in the SUCCESSFULLY_QUEUED case. Shouldn't happen, but better safe than sorry if some driver completes it's io immediately. Also don't recompute saved flags if the request is retried. ok marco@
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-28more snprintf error checking. ok krw@Moritz Jodeit
2005-04-17Fix typoTom Cosgrove
ok krw@
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@
2005-04-01Cleanup SKEY_NOT_READY logic. Only retry command if it's likely theKenneth R Westerback
condition is going to clear up, which speeds up boot by avoiding delays in disk matching. Return ENODEV if media is not present, which avoids trying to spin up disks that are not present. Use ENODEV in amd64/i386 dkcsum.c to filter failure reports. Mostly from NetBSD. ok marco@
2005-03-24If READ CAPACITY(10) says there are more than 0xffffffff sectors,Kenneth R Westerback
report 0xffffffff and print a message. READ CAPACITY(16) is needed to get the actual size in this case. ok tdeval@ (a while ago) marco@