Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/scsipi_ioctl.c
RevisionDateAuthorComments
 1.73  27-Dec-2019  msaitoh s/transfered/transferred/
 1.72  30-May-2019  mlelstv use correct size when copying outgoing sense data.
 1.71  26-May-2019  mlelstv Add sanity checks to SCIOCCOMMAND, adapter drivers might be confused or trigger
assertions (e.g. umass).
 1.70  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.69  20-Nov-2016  mlelstv branches: 1.69.8; 1.69.14; 1.69.16;
Make scsipi framework MPSAFE.

Data structures are now protected by a per-adapter mutex at IPL_BIO
that is created by the scsibus or atapibus instance when the adapter
is configured.
The enable reference counter and the channel freeze counter which are
currently used by HBA code before the adapter is configured, are made
atomic.
The target drivers are now all tagged as D_MPSAFE.

Almost all HBA drivers still require the kernel lock to present,
so all callbacks into HBA code are still protected by kernel lock
unless the driver is tagged as SCSIPI_ADAPT_MPSAFE.

TODO: refactor sd and cd to use dksubr.
 1.68  24-Aug-2015  pooka branches: 1.68.2;
to garnish, dust with _KERNEL_OPT
 1.67  19-Apr-2012  bouyer branches: 1.67.2; 1.67.14; 1.67.16; 1.67.18; 1.67.22;
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
sync/wide parameters only make sense for parallel SCSI.
For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
tagged queing status if enabled. Just be silent for other
bustypes.

This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
appropriate parameters is enough to enable tagged queuing,
but then scsipi will print:
sd0: async, 8-bit transfers, tagged queueing
which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
but will confuse users. With this change scsipi will only print:
sd0: tagged queueing
which is correct.

In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
 1.66  14-Jul-2008  drochner branches: 1.66.28; 1.66.32; 1.66.34;
set the buffer's "resid" if a raw SCSI command fails, otherwise a
diagnostic check in kern_physio is set up
 1.65  28-Apr-2008  martin branches: 1.65.2; 1.65.4; 1.65.6;
Remove clause 3 and 4 from TNF licenses
 1.64  02-Jan-2008  ad branches: 1.64.6; 1.64.8; 1.64.10;
Merge vmlocking2 to head.
 1.63  29-Jul-2007  ad branches: 1.63.6; 1.63.12; 1.63.14; 1.63.18; 1.63.22;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.62  04-Mar-2007  christos branches: 1.62.2; 1.62.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.61  14-Apr-2006  christos branches: 1.61.14;
Coverity CID 1101: Protect against address argument being NULL.
 1.60  28-Mar-2006  thorpej Use device_unit().
 1.59  25-Mar-2006  thorpej Use device_parent().
 1.58  01-Mar-2006  yamt branches: 1.58.2; 1.58.4; 1.58.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.57  14-Dec-2005  reinoud branches: 1.57.2; 1.57.4; 1.57.6;
Allow SCIOCCOMMAND ioctl that executes a SCSI command to also be issued
within the kernel when the FKIOCTL flag is passed to the ioctl.

No code actually uses this yet but is committed for completion.
 1.56  11-Dec-2005  christos merge ktrace-lwp.
 1.55  01-Nov-2005  martin Rework the funny "user_strat: No ioctl" error messages - the functions
have not been called user_strat for quite some time and the message is
confusing if you do not know the code.
 1.54  01-Nov-2005  bouyer Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
 1.53  31-Oct-2005  yamt fix ioctl problems after the recent physio changes
in some drivers including wd and scsi.

- physio: if a caller provided a buf, stick to use it
because some drivers use it as an identifier.
- sprinkle simple_locks.
- scsistrategy: rather than issueing an async request and
waiting for its completion, simply issue a sync request.
the way to wait for the completion had an assumption that
B_CALL is never used. it isn't the case after the recent
physio() changes.

pointed/analyzed/tested by Martin Husemann.
 1.52  01-Feb-2005  reinoud branches: 1.52.4; 1.52.6; 1.52.8;
Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
 1.51  31-Jan-2005  reinoud Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
 1.50  18-Sep-2004  mycroft branches: 1.50.4;
Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.
 1.49  17-Sep-2004  mycroft Remove the "xfer" argument to scsipi_command().
 1.48  09-Sep-2004  bouyer Make the xxstart() functions reentrant again, as some drivers HBA can call
scsipi_done() from their scsipi_request().
For this, add a struct scsipi_xfer * argument to scsipi_command().
If not NULL scsipi_command() will use this to enqueue this xfer, otherwise
it'll try to allocate a new one. This scsipi_xfer has to be allocated
and initialised by scsipi_make_xs() or equivalent.
In xxstart(), allocate a scsipi_xfer using scsipi_make_xs(), and if not NULL,
dequeue the buffer before calling scsipi_command(). This makes sure that
scsipi_command() will not fail, and also makes sure that xxstart() won't
be called again between the BUFQ_PEEK() and BUFQ_GET().

Fix "dequeued wrong buf" panics reported by Juergen Hannken-Illjes in
private mail and Andreas Wrede on current-users@.
Thanks to Jason Thorpe and Chuck Silver for review, and Andreas Wrede for
testing the patch.
 1.47  21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.46  29-Jun-2003  fvdl branches: 1.46.2; 1.46.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.45  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.44  23-Feb-2003  yamt initialize b_interlock properly.
(for ioctl)
 1.43  12-Jan-2002  tsutsui branches: 1.43.10;
Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.42  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.41  13-Nov-2001  lukem add RCSIDs
 1.40  18-Jul-2001  thorpej branches: 1.40.2;
bcopy -> memcpy
 1.39  18-Jul-2001  thorpej bzero -> memset
 1.38  25-Apr-2001  bouyer branches: 1.38.2;
Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.37  30-Sep-1999  thorpej branches: 1.37.2; 1.37.8; 1.37.14;
Cleanup the scsipi_xfer flags:
- `flags' is now gone, replaced with `xs_control' and `xs_status'.
- Massive cleanup of the control flags. Now we explicitly say that
a job is to complete asynchronously, rather than relying on side-effects,
and use a new flag to now that device discovery is being performed.
- Do SCSI device discovery interrupt-driven.
 1.36  11-Jan-1999  thorpej Add missing XS_SELTIMEOUT case in user command completion path, returning
SCCMD_TIMEOUT. Based on PR #6720, Andreas Wrede.
 1.35  17-Nov-1998  bouyer Rename scsi_interpret_sense() to scsipi_interpret_sense() and move it from
scsi_base.c to scsipi_base.c. Rename the functions from scsi_verbose.c
too, and rename the file itself. Cleaup includes too (scsi_*.h should not
be #included in scsipi_*.h files, which are supposed to be
common to atapi and scsi).
 1.34  10-Oct-1998  thorpej Garbage-collect the SCIOCREPROBE and OSCIOCREPROBE ioctls. This is a
bus-oriented command. (How much sense does it make to open a device
to rescan the bus?!)
 1.33  17-Aug-1998  mycroft Assign my copyrights to TNF.
 1.32  15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.31  05-Jul-1998  jonathan * defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.
 1.30  25-Jun-1998  thorpej defopt COMPAT_FREEBSD
 1.29  15-Jun-1998  bouyer Treat OSCIOCIDENTIFY just as SCIOCIDENTIFY regarding permissions, don't
require the file descriptor to be open read/write. Fix PR kern/5592
from John F. Woods.
 1.28  18-Oct-1997  thorpej Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.
 1.27  01-Oct-1997  enami Cosmetic changes to keep coding style consistency in this directory;

- Indent with tab of width 8.
- Use four column to indent continuation line.
- Fold long line if possible.
- Use return (xx) instead of return xx.
- Compare pointer against NULL instead of testing like boolean.
- Delete whitespace at the end of line.
- Delete whitespace in front of function call operator.
- Delete whitespace after cast.
- Dereference a pointer to function explicitly.
- Add an empty line after local variable declaration.
- Use NULL instead of (char *)0.
- Dont use block for single statement.
 1.26  19-Sep-1997  enami Add new ioctl OSCIOCREPROBE and OSCIOCIDENTIFY to support binary
compatibility with NetBSD 1.2.
 1.25  27-Aug-1997  bouyer branches: 1.25.2;
Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.24  26-Apr-1997  augustss Don't require that a device is open for writing to perform a raw
SCSI command that just reads.
 1.23  12-Oct-1996  christos revert previous kprintf change
 1.22  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.21  13-Sep-1996  thorpej For ioctl commands which may change the device's state, ensure that
the caller has the device open for writing.
 1.20  14-Feb-1996  christos branches: 1.20.4;
scsi prototypes
 1.19  26-Sep-1995  thorpej Don't declare Debugger(). It's handled in <sys/systm.h>.
#include <sys/systm.h> where necessary, as suggested by Jonathan Stone.
Fixes PR #1511.
 1.18  30-Jan-1995  mycroft Fix invocation of scsi_scsi_cmd(), per John Kohl.
 1.17  23-Jan-1995  mycroft Remove old, misleading comment.
 1.16  28-Dec-1994  mycroft Numerous changes. Many bugs fixed, better autoconfig, a few new features.
 1.15  01-Dec-1994  mycroft Set UIO residual count.
 1.14  01-Dec-1994  mycroft Always set the device number correctly, even though we don't need it.
 1.13  01-Dec-1994  mycroft Redux.
 1.12  01-Dec-1994  mycroft Uncomment call to scsi_user_done(), and remove a duplicate biodone() (and
another si_free()).
 1.11  01-Dec-1994  mycroft Remove the silly statically allocated array, and simply malloc the data
structures as needed. Also, put the buf in the malloc()ed area. Remove a
duplicate si_free() (though this was harmless before).
 1.10  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.9  23-Oct-1994  mycroft Make this more likely to work.
 1.8  20-Oct-1994  mycroft First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.
 1.7  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.6  16-Jun-1994  mycroft b_un.b_addr -> b_data
 1.5  11-Apr-1994  mycroft Fix various types. Remove some outdated flags.
 1.4  29-Mar-1994  mycroft New SCSI system, based on Julian's more recent work.
 1.3  29-Nov-1993  mycroft Use new struct buf fields.
 1.2  24-Nov-1993  mycroft Still under construction...
 1.1  24-Nov-1993  mycroft Under construction...
 1.20.4.1  14-Nov-1996  thorpej Pull up from trunk:

> For ioctl commands which may change the device's state, ensure that
> the caller has the device open for writing.
 1.25.2.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.3  22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.1  27-Aug-1997  thorpej file scsipi_ioctl.c was added on branch marc-pcmcia on 1997-08-27 23:33:28 +0000
 1.37.14.5  28-Feb-2002  nathanw Catch up to -current.
 1.37.14.4  08-Jan-2002  nathanw Catch up to -current.
 1.37.14.3  14-Nov-2001  nathanw Catch up to -current.
 1.37.14.2  24-Aug-2001  nathanw Catch up with -current.
 1.37.14.1  21-Jun-2001  nathanw Catch up to -current.
 1.37.8.1  21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.37.2.2  01-Nov-1999  thorpej Fixup the SC_DEBUG() stuff for the new world order.
 1.37.2.1  19-Oct-1999  thorpej Completely rewritten scsipi_xfer execution engine:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).

There is a lot more work to do, but this correctly functions for the most
part on several file servers I run.
 1.38.2.3  11-Feb-2002  jdolecek Sync w/ -current.
 1.38.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.38.2.1  03-Aug-2001  lukem update to -current
 1.40.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.43.10.1  03-Nov-2005  riz Pull up following revision(s) (requested by bouyer in ticket #5929):
sys/dev/scsipi/scsipi_ioctl.c: revision 1.54
Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
 1.46.4.2  03-Nov-2005  riz Pull up following revision(s) (requested by bouyer in ticket #5961):
sys/dev/scsipi/scsipi_ioctl.c: revision 1.54
Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
 1.46.4.1  11-Sep-2004  he branches: 1.46.4.1.2; 1.46.4.1.4;
Pull up revision 1.48 (via patch, requested by bouyer in ticket #837):
Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
The theory is that other consumers of pool memory is causing
this memory shortage in certain somewhat hard to reproduce
situations.
This is done by giving scsipi_command an extra argument to
optionally pass a preallocated scsipi_xfer, and allocating a
scsipi_xfer before dequeueing a buffer in the various *start()
functions. If the allocation of a scsipi_xfer fails, schedule
a callout for delayed invocation of the start function. Also
reserve one page for scsipi_xfer structs, to ensure that we will
eventually have some available once pending commands complete.
Should fix PR#25670.
 1.46.4.1.4.1  03-Nov-2005  riz Pull up following revision(s) (requested by bouyer in ticket #5961):
sys/dev/scsipi/scsipi_ioctl.c: revision 1.54
Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
 1.46.4.1.2.1  03-Nov-2005  riz Pull up following revision(s) (requested by bouyer in ticket #5961):
sys/dev/scsipi/scsipi_ioctl.c: revision 1.54
Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
 1.46.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.46.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.46.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.46.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.46.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.50.4.1  29-Apr-2005  kent sync with -current
 1.52.8.1  02-Nov-2005  yamt sync with head.
 1.52.6.3  21-Jan-2008  yamt sync with head
 1.52.6.2  03-Sep-2007  yamt sync with head.
 1.52.6.1  21-Jun-2006  yamt sync with head.
 1.52.4.1  03-Nov-2005  tron Pull up following revision(s) (requested by bouyer in ticket #928):
sys/dev/scsipi/scsipi_ioctl.c: revision 1.54
Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
 1.57.6.1  22-Apr-2006  simonb Sync with head.
 1.57.4.1  09-Sep-2006  rpaulo sync with head
 1.57.2.1  05-Feb-2006  yamt adapt scsipi.
 1.58.6.3  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.58.6.2  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.58.6.1  28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.58.4.1  19-Apr-2006  elad sync with head.
 1.58.2.2  24-May-2006  yamt sync with head.
 1.58.2.1  01-Apr-2006  yamt sync with head.
 1.61.14.1  12-Mar-2007  rmind Sync with HEAD.
 1.62.10.1  15-Aug-2007  skrll Sync with HEAD.
 1.62.2.6  09-Oct-2007  ad Sync with head.
 1.62.2.5  20-Aug-2007  ad Sync with HEAD.
 1.62.2.4  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.62.2.3  17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.62.2.2  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.62.2.1  13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.63.22.2  29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.63.22.1  29-Jul-2007  ad file scsipi_ioctl.c was added on branch matt-mips64 on 2007-07-29 12:50:24 +0000
 1.63.18.1  02-Jan-2008  bouyer Sync with HEAD
 1.63.14.1  04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.63.12.1  18-Feb-2008  mjf Sync with HEAD.
 1.63.6.1  09-Jan-2008  matt sync with HEAD
 1.64.10.2  04-May-2009  yamt sync with head.
 1.64.10.1  16-May-2008  yamt sync with head.
 1.64.8.1  18-May-2008  yamt sync with head.
 1.64.6.2  28-Sep-2008  mjf Sync with HEAD.
 1.64.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.65.6.1  19-Oct-2008  haad Sync with HEAD.
 1.65.4.1  18-Jul-2008  simonb Sync with head.
 1.65.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.66.34.1  23-Apr-2012  riz Pull up following revision(s) (requested by bouyer in ticket #192):
sys/dev/scsipi/cd.c: revision 1.307
sys/dev/scsipi/scsiconf.c: revision 1.266
sys/dev/scsipi/sd.c: revision 1.298
sys/dev/scsipi/st_scsi.c: revision 1.35
sys/dev/scsipi/atapiconf.c: revision 1.85
sys/dev/scsipi/scsipiconf.h: revision 1.120
sys/dev/usb/umass_scsipi.c: revision 1.44
sys/dev/scsipi/scsiconf.h: revision 1.57
sys/dev/scsipi/st_atapi.c: revision 1.29
sys/dev/scsipi/scsipi_base.c: revision 1.158
sys/dev/scsipi/st.c: revision 1.221
sys/dev/scsipi/scsipi_ioctl.c: revision 1.67
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
sync/wide parameters only make sense for parallel SCSI.
For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
tagged queing status if enabled. Just be silent for other
bustypes.
This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
appropriate parameters is enough to enable tagged queuing,
but then scsipi will print:
sd0: async, 8-bit transfers, tagged queueing
which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
but will confuse users. With this change scsipi will only print:
sd0: tagged queueing
which is correct.
In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.
Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
 1.66.32.1  29-Apr-2012  mrg sync to latest -current.
 1.66.28.1  23-May-2012  yamt sync with head.
 1.67.22.1  31-May-2019  martin Pull up following revision(s) (requested by mlelstv in ticket #1698):

sys/dev/scsipi/scsipi_ioctl.c: revision 1.72 (via patch)

use correct size when copying outgoing sense data.
 1.67.18.1  31-May-2019  martin Pull up following revision(s) (requested by mlelstv in ticket #1698):

sys/dev/scsipi/scsipi_ioctl.c: revision 1.72 (via patch)

use correct size when copying outgoing sense data.
 1.67.16.2  05-Dec-2016  skrll Sync with HEAD
 1.67.16.1  22-Sep-2015  skrll Sync with HEAD
 1.67.14.1  31-May-2019  martin Pull up following revision(s) (requested by mlelstv in ticket #1698):

sys/dev/scsipi/scsipi_ioctl.c: revision 1.72 (via patch)

use correct size when copying outgoing sense data.
 1.67.2.1  03-Dec-2017  jdolecek update from HEAD
 1.68.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.69.16.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.69.16.1  10-Jun-2019  christos Sync with HEAD
 1.69.14.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.69.8.1  31-May-2019  martin Pull up following revision(s) (requested by mlelstv in ticket #1278):

sys/dev/scsipi/scsipi_ioctl.c: revision 1.72 (via patch)

use correct size when copying outgoing sense data.

RSS XML Feed