summaryrefslogtreecommitdiff
path: root/sys/scsi/scsi_base.c
AgeCommit message (Collapse)Author
2017-09-08If you use sys/param.h, you don't need sys/types.hTheo de Raadt
2017-05-29To prevent anyone else from stumbling on this (now) archaic bit ofKenneth R Westerback
history, nuke all mentions of XS_NO_CCB and the #define. 2006 - 2017. R.I.P. ok kettenis@ inferred ok dlg@
2016-09-15all pools have their ipl set via pool_setipl, so fold it into pool_init.David Gwynne
the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
2016-03-12Standardize on calling local scsi_link variables 'link' instead ofKenneth R Westerback
'sc_link'. 'sc_link' is a field in the various device *_softc structures, where the sc_ prefix was for 'softc'. Reduces potential mental confusion. Newer code from down under was already using 'link'. No functional change. Prompted by bluhm@'s adventures in scsi. ok dlg@ jmatthew@
2016-03-10Enforce some naming sanity. Stop using 'sc_link' to mean two differentKenneth R Westerback
things by renaming the field 'SLIST_HEAD(, scsi_link) sc_link' to 'sc_link_list' in struct scsibus_softc. Use 'sb' as the short name for scsibus_softc variables. Impetus from & ok bluhm@
2016-03-07Sync no-argument function declaration and definition by adding (void).Christian Weisgerber
ok mpi@ millert@
2015-06-07More damned eye searing whitespace.Kenneth R Westerback
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-03-08Fix some format specifiers in debug code.Kenneth R Westerback
Pointed out by Kor son of Rynar (sic) when trying to test some debug code. ok matthew@
2015-01-27remove the second void * argument on tasks.David Gwynne
when workqs were introduced, we provided a second argument so you could pass a thing and some context to work on it in. there were very few things that took advantage of the second argument, so when i introduced pools i suggested removing it. since tasks were meant to replace workqs, it was requested that we keep the second argument to make porting from workqs to tasks easier. now that workqs are gone, i had a look at the use of the second argument again and found only one good use of it (vdsp(4) on sparc64 if you're interested) and a tiny handful of questionable uses. the vast majority of tasks only used a single argument. i have since modified all tasks that used two args to only use one, so now we can remove the second argument. so this is a mechanical change. all tasks only passed NULL as their second argument, so we can just remove it. ok krw@
2014-09-20Fix bug in taskq conversion that would lead to a null pointer dereference.Mark Kettenis
ok krw@, jsg@
2014-09-14remove uneeded proc.h includesJonathan Gray
ok mpi@ kspillner@
2014-09-09rework the hotplug requests to use tasks rather than workqs.David Gwynne
tested on mpi(4) sas.
2014-07-01take the biglock before calling the xs completion handler.David Gwynne
should be safe to call the midlayer io path without the biglock now.
2014-07-01take the biglock when calling an adapters scsi_cmd handler.David Gwynne
2014-07-01start on being able to safely run io through the midlayer withoutDavid Gwynne
the kernel biglock. the plan is to have the midlayer assume its running without the biglock, but that it cant call adapters or devices without taking the biglock first. this diff just wraps the calls to the adapter iopool get and put handlers up in the biglock. this is safe now because of kettenis' commit to src/sys/kern/init_main.c r1.120. ive been running this in various places since early 2011.
2014-04-22factor out the code that figures out whether you're probing or detachingDavid Gwynne
a whole bus, a target, or a specific lun on a target from the bioctl and scsi_req paths. i want to reuse this factored code for something claudio wants.
2014-01-27poison the io "allocated" by the default pool allocator so any attempt toDavid Gwynne
use it should cause a fault. based on discussion with miod@
2014-01-18rename scsi_ioh_runqueue to scsi_iopool_run, and make it availableDavid Gwynne
outside scsi_base.c. this will allow adapters to restrict access to iopool resources based on some state, and then kick the pending requests on the pool when the state comes good again. ive been avoiding this for a long time, but it is the least worst way to deal with some uses of XS_NO_CCB. discussion with kettenis@ helped me decide this was right.
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@