summaryrefslogtreecommitdiff
path: root/sys/scsi/scsi_base.c
AgeCommit message (Collapse)Author
2013-10-07typoMiod Vallat
2013-09-27scsi_size() is now used only by cd(4). So move it from scsi_base.cKenneth R Westerback
to cd.c and call it cd_size(), like sd_size() lives in sd.c. Tweak some daddr_t variables to u_int64_t on the way, when they are for disk sector numbers, not 512-byte block numbers.
2013-08-29rename scsi_sem_{enter,leave} to scsi_pending_{start,finish}. these areDavid Gwynne
the wrappers around handling of pending work, theyre not semaphores. names from tedu@ ok krw@ guenther@
2013-08-27make scsi_sem_leave only run again once, no matter how many timesDavid Gwynne
other things scsi_sem_enter. the things protected by this do as much work as they can, so they only need to be told to try again once. this isnt a semaphore anymore (and probably never was) so there's a name change coming too.
2013-08-26make scsi_{xsh,ioh}_{add,del} return whether they moved somethingDavid Gwynne
on or off the queues so things calling them can tell if something is or isnt going to happen.
2013-08-25move the prototypes of scsi_sem_{enter,leave} into a header so thingsDavid Gwynne
other than scsi_base.c can use them.
2013-06-11final removal of daddr64_t. daddr_t has been 64 bit for a long enoughTheo de Raadt
test period; i think 3 years ago the last bugs fell out. ok otto beck others
2012-07-01Do not try to send a 10 byte MODE_SENSE request to non-ATAPI non-UMASSMiod Vallat
devices which advertize themselves as non-SCSI2-aware, since this command appeared in the SCSI-2 specification. This makes the Insite Floptical work when connected to a controller which correctly handles spontaneous deselection (which happens when a non-zero lun on said floptical device is addressed), such an esp(4) but not wdsc(4). This is step one of getting Floptical devices working on SGI systems. feedback and ok krw@
2011-06-15factor the common bits out of code that builds scsi inquiry commands intoDavid Gwynne
scsi_init_inquiry(). cut the compiled INQUIRY code over to it. ok and tweaks from krw@ ok matthew@
2011-03-17use dma_alloc/dma_free instead of malloc to allocate buffers which needTheo de Raadt
to be in the right address space. help from matthew and krw
2011-03-02Sync ASC/ASCQ errors with www.t10.org/lists/asc-num.txt of 11/15/10.Kenneth R Westerback
Prompted by dlg@'s tape library trying to report a failure to thread a media (0x53, 0x04).
2010-09-20bring back scsi_base.c r1.195 and scsiconf.h r1.138 now thatDavid Gwynne
src/sys/dev/ata/atascsi.c r1.92 solves the problem that my scsi_link change tickled. tested by josh elsasser who reported the problem in pr6470 deraadt@ is letting it in again so it can get widespread testing
2010-09-17revert scsi_base.c r1.195 and scsiconf.h r1.138 as it screws up with someDavid Gwynne
disks in atascsi. as reported in pr6470
2010-09-14the openings member of scsi_link is the maximum number of commands that aDavid Gwynne
scsi device can have in flight. instead of counting users of openings on the bus by taking away from the openings value, count the number of pending commands on the bus in a new pending variable. this lets us know how many outstanding commands there are. we can then use that to make sure that all commands a device has generated get completed before detaching the device. this helps avoid resource leaks and use after frees. tested by me on pci ehci/umass, fc mpi, and sas mpi. tested by jakemsr on cardbus ohci umass. it found issues in sas mpi which were fixed as a result of this diff. ok krw@
2010-09-08let things request the detach of everything on the whole bus, rather thanDavid Gwynne
just a target/lun.
2010-08-30Avoid possible aliasing-related compiler issues by always writing toMatthew Dempsky
cmd->opcode through the type casted command pointer rather than through xs->cmd->opcode. Requested by deraadt@; ok krw@.
2010-08-25add scsi_iopool_destroy and scsi_link_shutdown. when a link orDavid Gwynne
device are going away, this will walk the pool and link queues and wake up processes that are sleeping while waiting for an io or xs. they will return NULL to the scsi_{xs,io}_get callers, which should then check if they device is still alive. all other handlers that are registered on the queues should be removed by their owners before the destroy/shutdown funcs are called. lots of help and discussion with matthew@ ok matthew@
2010-08-07No "\n" needed at the end of panic() strings.Kenneth R Westerback
Bogus chunks pointed out by matthew@ and miod@. No cookies for marco@ and jasper@. ok deraadt@ miod@ matthew@ jasper@ macro@
2010-07-28No need to bzero() malloc'd memory if we used M_ZERO.Kenneth R Westerback
ok matthew@
2010-07-27Add scsi_cmd_rw_decode() for decoding any SCSI READ or WRITE command,Matthew Dempsky
and update atascsi(4) to make use of it. (Other HBAs will be updated post-release.) Should allow for use of SATA drives with >2^32 LBAs. ok deraadt@, dlg@, krw@
2010-07-27the queue entry and state variables in the xsh and ioh structs are partDavid Gwynne
of a separate struct which the ioh struct includes for no good reason anymore. just put the vars directly in the ioh. this removes this useless abstraction. ok krw@ matthew@
2010-07-25Restore previous behaviour of always bzero()'ing the buf passed toKenneth R Westerback
scsi_inquire_vpd(). scsi_inquire_vpd() oddness noted by jsg@ after report of macppc problems by kili@.
2010-07-24Get rid of scsi_deinit(), and change scsi_init() back to a one-timeMatthew Dempsky
initialization strategy, rather than pretending to do user reference counting. Previously, we would re-initialize the SCSI pool(9)s, which had the fun consequence of causing sysctl(kern.pool.npools) to infinite loop at IPL_VM. ok krw@
2010-07-22In scsi_inquire_vpd(), actually just return EJUSTRETURN when dealingMatthew Dempsky
with UMASS devices. Fixes scsi_scsi_cmd() removal regression. ok dlg@
2010-07-22Eliminate scsi_scsi_cmd() now that ss(4) is gone and with it theKenneth R Westerback
last bastardized sync and buf call through scsi_scsi_cmd(). Flatten code to call scsi_xs_sync() directly for all commands. Airplane typos shaken out by various. ok dlg@ matthew@ deraadt@
2010-07-06Fix monumental cock-up with SCSI_SILENT and SCSI_IGNORE_ILLEGAL_REQUESTKenneth R Westerback
flags which I perpetrated when I paid insufficient attention to dlg@'s original diff. Belatedly tested by marco@ and myself. Bad marco@. Bad krw@. ok marco@
2010-07-03Get rid of EAGAIN, retry scsi_xs_sync() commands (after a scsi_delay())Kenneth R Westerback
that get XS_NO_CCB until retry limit exceeded. On to getting rid of XS_NO_CCB. ok matthew@ "so be it" dlg@
2010-07-02Always try READ CAPACITY(16) on SCSI-3 devices. If it fails, returnKenneth R Westerback
the READ CAPACITY(10) values already retrieved. Creates the possibility to look at other interesting READ CAPACITY(16) data for future consideration. ok matthew@ marco@ deraadt@
2010-07-02Use M_NOWAIT only if SCSI_NOSLEEP is set, as is the usual idiom. FromKenneth R Westerback
matthew@ who won't be home until late. ok matthew@ & tedu@.
2010-07-01Move rdcap/rdcap16 structs used to get info about disk size off ofKenneth R Westerback
stack and malloc/free them instead. First stirrings of the tide of de-stacking to come. Feedback, fixes and ok matthew@ & tedu@.
2010-07-01Die struct scsi_device! Die! Instead, save a pointer to the routineKenneth R Westerback
to interpret sense errors. This is initialized to the basic interpretation routine, and specific scsi drivers (sd/st/cd) can replace this with their own. While here kill EJUSTRETURN dance and make more specialized interpretation routines directly call the basic routine if desired. Fixes by matthew@ to my first diff. Most original work by dlg@. ok matthew@ marco@ dlg@
2010-07-01Restore setting xs->bp; fixes ncr(4) on VAX.Matthew Dempsky
ok miod@, krw@
2010-06-28remove a lonely remnant from some debug code that snuck in.David Gwynne
2010-06-14remove the scsi_buf_* functions as these have beenThordur I. Bjornsson
replaced by BUFQ's. OK krw@, dlg@
2010-06-01if we're going to set ITSDONE when an xfer is done cos the adapter expectsDavid Gwynne
it, we should clear it before we issue it to the adapter too. retried commands would have ITSDONE still set otherwise.
2010-05-24"scsi_ioh_add:" -> "scsi_ioh_del:" in scsi_ioh_del() panic msg.Kenneth R Westerback
Spotted by Matthew Dempsky. Thanks!
2010-04-17ramdisks need to compile; ok dlgTheo de Raadt
2010-04-17use the iopools mutex to protect the semaphore wrapping the openingsDavid Gwynne
runqueue. less is more sometimes.
2010-04-16fix an fatal flaw with iopools.David Gwynne
an xshandler gets put on a series of lists as it allocates different resources, and uses the same tailq entry on each of these lists as its only supposed to be on one of them at a time. however, it was possible for the xshandler to be added to both at the same time, therefore corrupting the lists and leading to a panic. this diff moves from using separate flags for each queue an xshandler could be on to having a single state variable that shows which one it is on (or not on). this prevents an xshandler on the io runqueue from being added to the openings runqueue, which in turn prevents the list corruption. some operations have been reordered to avoid races and complexity in this little state machine.
2010-04-12i snuck fine grained locking into the midlayer as part of all theDavid Gwynne
other stuff ive been doing in here. everything that needs protection inside the midlayer and the scsi device drivers (sd, cd, etc) uses mutexes now. this pushes splbio out of the midlayer. splbio is only taken before biodone is called now. ok beck@ marco@ krw@ deraadt@. theyre all terrified, but they all say if we're going to do then now is the right stage of the dev cycle.
2010-04-06implement a new mechanism for allocating resources on the bus.David Gwynne
instead of optimistically trying to use a resource by executing an xs and then failing when there's no room for it, this puts things that want to use the hardware on a runqueue. as resources become available on the bus then consumers on the runqueue are popped off and guaranteed access to the resource. the resources are generally "ccbs" in adapter drivers, so this abstracts a way for the midlayer to get access to them into something called iopools. it also provides a callback api for consumers of resources to use: the scsi_ioh api for things that want direct access to the ccbs, and the scsi_xsh api for things that want to issue a scsi_xfer on the bus. these apis have been modelled on the timeout api. scsi_xs_get and therefore scsi_scs_cmd have been cut over to using these apis internally, so if they are allowed to sleep then can wait on the runqueue for a resource to become available and therefore guarantee that when executed on an adapter providing an iopool that they will succeed. ok krw@ beck@ marco@ tested by many including krw@ beck@ mk@ okan@ todd@
2010-03-23Change the scsi_cmd function member of scsi_adapter from int toKenneth R Westerback
void. Use XS_NO_CCB error in the scsi command (xs) to report the NO_CCB condition. Eliminates all SUCCESSFULLY_QUEUED and COMPLETE confusion and untangles the midlayer from the adapter a bit more. Eyes and some fixes by miod@ There may be some compile issues on little used (i.e. I don't have any) drivers but the change is mechanical and thus easy to remedy. ok dlg@
2010-01-15Oops. Respect the various IGNORE flags when not in SCSIDEBUG mode.Kenneth R Westerback
Should quieten booting again. And thus ends n2k10.
2010-01-15Abstract and merge the manual buf queue manipulating functions intoKenneth R Westerback
one place for easier debugging and maintenance. No intended functional changes. ok dlg@
2010-01-14Print sense data during SCSIDEBUG again. Always print the decodedKenneth R Westerback
data when SCSIDEBUG is set, irrespective of SCSI_SILENT. Tweak output a bit. Noticed in output generated by todd@.
2010-01-14Tweak names a bit. show_mem -> scsi_show_mem, show_scsi_xs ->Kenneth R Westerback
scsi_xs_show. No functional change.
2010-01-13Get new xs's with PR_ZERO to ensure all shiny new fields getKenneth R Westerback
initialized. Bring back panics on non-NULL done and cookie fields, but put inside DIAGNOSTIC. ok dlg@
2010-01-13Cookie or done is set on entry to scsi_xs_sync(). Take panic() outKenneth R Westerback
until we figure out why.
2010-01-13when checking an xs for errors, first check if the device the xs is forDavid Gwynne
is dying. if so, return ENXIO. this should make detach of devices during scsi attaches less dangerous. idea (and the first version of this diff) ok deraadt@ ok krw@
2010-01-13scsi_xs_sync uses the xs cookie and done pointers, so users of scsi_xs_syncDavid Gwynne
cannot. panic if theyre set before scsi_xs_sync is called. question raised by and ok krw@