History log of /openbsd-current/sys/dev/ic/ciss.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.92 14-Apr-2024 jsg

with empty body loops, put final semicolon on a new line for readability
ok bluhm@ jca@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.91 16-Apr-2022 naddy

constify SCSI adapter entry points

ok krw@


Revision tags: OPENBSD_7_1_BASE
# 1.90 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.89 22-Sep-2020 krw

Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'
member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic
cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*'
from cmd. Take the address of cmd as required by the various casts.

No intentional functional change.

luna88k test by aoyama@, sparc64 test by jmatthew@

Identification of 2009's last *cmd use and ok jmatthew@


# 1.88 24-Jul-2020 krw

Turning on various scsi drivers' *DEBUG options reveals that this has
rarely (if ever) been done.

Fix many printf format errors to calm clang and gcc on amd64, i386,
hppa. Missing #include, complaints if 'option <blah>DEBUG' is used in
config files, etc. All in debug code.


# 1.87 20-Jul-2020 krw

Move remaining scsi bus initialization info from "prototype scsi link"
fields to struct scsibus_attach_args. Nuke the struct scsi_link *
(saa_sc_link) in scaibus_attach_args.

Explicitly initialize each field in scsibus_attach_args variables.


# 1.86 19-Jul-2020 krw

Move the adapter related items (luns, adapter, adapter_target,
adapter_buswidth, adapter_softc) from struct scsi_link to struct
scsibus_attach_args.

Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.91 16-Apr-2022 naddy

constify SCSI adapter entry points

ok krw@


Revision tags: OPENBSD_7_1_BASE
# 1.90 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.89 22-Sep-2020 krw

Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'
member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic
cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*'
from cmd. Take the address of cmd as required by the various casts.

No intentional functional change.

luna88k test by aoyama@, sparc64 test by jmatthew@

Identification of 2009's last *cmd use and ok jmatthew@


# 1.88 24-Jul-2020 krw

Turning on various scsi drivers' *DEBUG options reveals that this has
rarely (if ever) been done.

Fix many printf format errors to calm clang and gcc on amd64, i386,
hppa. Missing #include, complaints if 'option <blah>DEBUG' is used in
config files, etc. All in debug code.


# 1.87 20-Jul-2020 krw

Move remaining scsi bus initialization info from "prototype scsi link"
fields to struct scsibus_attach_args. Nuke the struct scsi_link *
(saa_sc_link) in scaibus_attach_args.

Explicitly initialize each field in scsibus_attach_args variables.


# 1.86 19-Jul-2020 krw

Move the adapter related items (luns, adapter, adapter_target,
adapter_buswidth, adapter_softc) from struct scsi_link to struct
scsibus_attach_args.

Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.90 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.89 22-Sep-2020 krw

Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'
member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic
cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*'
from cmd. Take the address of cmd as required by the various casts.

No intentional functional change.

luna88k test by aoyama@, sparc64 test by jmatthew@

Identification of 2009's last *cmd use and ok jmatthew@


# 1.88 24-Jul-2020 krw

Turning on various scsi drivers' *DEBUG options reveals that this has
rarely (if ever) been done.

Fix many printf format errors to calm clang and gcc on amd64, i386,
hppa. Missing #include, complaints if 'option <blah>DEBUG' is used in
config files, etc. All in debug code.


# 1.87 20-Jul-2020 krw

Move remaining scsi bus initialization info from "prototype scsi link"
fields to struct scsibus_attach_args. Nuke the struct scsi_link *
(saa_sc_link) in scaibus_attach_args.

Explicitly initialize each field in scsibus_attach_args variables.


# 1.86 19-Jul-2020 krw

Move the adapter related items (luns, adapter, adapter_target,
adapter_buswidth, adapter_softc) from struct scsi_link to struct
scsibus_attach_args.

Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.89 22-Sep-2020 krw

Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'
member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic
cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*'
from cmd. Take the address of cmd as required by the various casts.

No intentional functional change.

luna88k test by aoyama@, sparc64 test by jmatthew@

Identification of 2009's last *cmd use and ok jmatthew@


# 1.88 24-Jul-2020 krw

Turning on various scsi drivers' *DEBUG options reveals that this has
rarely (if ever) been done.

Fix many printf format errors to calm clang and gcc on amd64, i386,
hppa. Missing #include, complaints if 'option <blah>DEBUG' is used in
config files, etc. All in debug code.


# 1.87 20-Jul-2020 krw

Move remaining scsi bus initialization info from "prototype scsi link"
fields to struct scsibus_attach_args. Nuke the struct scsi_link *
(saa_sc_link) in scaibus_attach_args.

Explicitly initialize each field in scsibus_attach_args variables.


# 1.86 19-Jul-2020 krw

Move the adapter related items (luns, adapter, adapter_target,
adapter_buswidth, adapter_softc) from struct scsi_link to struct
scsibus_attach_args.

Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.88 24-Jul-2020 krw

Turning on various scsi drivers' *DEBUG options reveals that this has
rarely (if ever) been done.

Fix many printf format errors to calm clang and gcc on amd64, i386,
hppa. Missing #include, complaints if 'option <blah>DEBUG' is used in
config files, etc. All in debug code.


# 1.87 20-Jul-2020 krw

Move remaining scsi bus initialization info from "prototype scsi link"
fields to struct scsibus_attach_args. Nuke the struct scsi_link *
(saa_sc_link) in scaibus_attach_args.

Explicitly initialize each field in scsibus_attach_args variables.


# 1.86 19-Jul-2020 krw

Move the adapter related items (luns, adapter, adapter_target,
adapter_buswidth, adapter_softc) from struct scsi_link to struct
scsibus_attach_args.

Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.87 20-Jul-2020 krw

Move remaining scsi bus initialization info from "prototype scsi link"
fields to struct scsibus_attach_args. Nuke the struct scsi_link *
(saa_sc_link) in scaibus_attach_args.

Explicitly initialize each field in scsibus_attach_args variables.


# 1.86 19-Jul-2020 krw

Move the adapter related items (luns, adapter, adapter_target,
adapter_buswidth, adapter_softc) from struct scsi_link to struct
scsibus_attach_args.

Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.85 16-Jul-2020 krw

Access adapter softc via link->bus->sb_adapter_softc.

In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth'
via sb_adapter_buswidth.

Removes last post-config uses of the copies of bus related
information in scsi_link.


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.84 11-Jul-2020 krw

Expunge some Captain Obvious comments, tweak whitespace a bit, move a debug
statement. All to make upcoming diff(s) smaller and easier to read.


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.83 27-Jun-2020 krw

No need to bzero()/memset() 'struct scsibus_attach_args' variables
immediately before initializing the only field in the struct.


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.82 24-Jun-2020 krw

Use SDEV_NO_ADAPTER_TARGET instead of the value that is being
aassigned to adapter_buswidth to indicate the adapter is not a target
on the bus.

ok dlg@ as part of a larger diff.


Revision tags: OPENBSD_6_7_BASE
# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.81 13-Feb-2020 krw

Nuke *_minphys() functions that either simply apply MAXPHYS or do
nothing at all. MAXPHYS will be applied in minphys() and nothing at
all, well, doesn't do anything.

Also remove any '#define <blah> MAXPHYS' statements used solely to
disguise MAXPHYS in said functions.


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.80 26-Jan-2020 krw

Shuffle some names around to make reading the code less headache
inducing. Rename scsi_adapter member 'scsi_minphys' to 'dev_minphys'
to reflect what it is supposed to do. Use consistent naming convention
(<dev>_minphys) for the actual device functions.

No functional change.


# 1.79 25-Jan-2020 krw

Drivers that implement their own *minphys() don't need to call the
system minphys(). scsi_minphys() will do that and cd/sd/st will call
scsi_minphys().

ok jmatthew@ as part of larger diff


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.78 23-Jan-2020 cheloha

ciss(4): tsleep(9) -> tsleep_nsec(9)

"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.

This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.

ok krw@


# 1.77 23-Jan-2020 cheloha

ciss(4): ciss_cmd: split polling loop into two loops

There are really two loops here. One for SCSI_NOSLEEP and delay(9),
the other for tsleep(9). The paths share a loop in the code but they
shouldn't. They have different termination conditions and share little
code.

If we pull the conditional clause out of the for-loop and then give each
path its own polling loop the logic should be easier to follow.

ok krw@


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


# 1.76 20-Jan-2020 cheloha

ciss(4): de-indent polling logic

Should make untangling the polling logic simpler.

"Sure." krw@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.75 14-Aug-2016 dlg

change some types in bio from u_quad_t to uint64_t, and fix casts in
drivers that fill that field in too.

quad types are going away.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.74 09-Sep-2015 deraadt

sizes for free(); ok sthen


Revision tags: OPENBSD_5_8_BASE
# 1.73 03-May-2015 jsg

add missing CISS_UNLOCK_SCRATCH/splx calls
ok krw@


# 1.72 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.71 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.70 13-Jul-2014 deraadt

Some reallocarray() use; review Jean-Philippe Ouellet, patrick keshishian
ok tedu


# 1.69 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.68 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.67 10-Nov-2011 krw

Death to inappropriate whitespace. First one pointed out by Brad.


Revision tags: OPENBSD_5_0_BASE
# 1.66 17-Jul-2011 matthew

Backout a bunch of my SCSI commits from c2k11. At least one of these
is causing problems when trying to boot sparc64 from an isp(4).

Verified to fix the sparc64/isp(4) regression by krw@; ok deraadt@


# 1.65 08-Jul-2011 matthew

First batch of converting SCSI HBAs from setting saa_targets and
saa_luns instead of adapter_buswidth and luns in the prototype link.

ok dlg@, miod@


# 1.64 05-Apr-2011 jasper

- use nitems() no binary change on amd64

"reads OK" claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.63 20-Sep-2010 krw

Use SSD_ERRCODE_CURRENT instead of magic 0x70.

ok dlg@ matthew@


# 1.62 20-Sep-2010 dlg

bus_dmamap_sync was using xs->flags to determine which direction
to sync the map. unfortunately xs is not set for internal ciss
commands, so this is a null deref. it wasnt until kettenis made
bus_dmamap_sync a real function which needed its arguments evaluated
that this became a real problem though.

hit by mcbride@ and sakurai-san. fixed by krw@ over my shoulder
when we figured out which specific chunk of code was faulting.
tested by sakurai-san
ok krw@ deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.61 07-Jul-2010 dlg

set each disks openings to the maximum number the controller can handle.
iopools make sure resources arent overallocated, while scheduling them
evenly between devices.

tested by and ok jsg@


# 1.60 02-Jul-2010 matthew

Make the sensor setup loop less awkward by moving the call to
sensor_attach() out of the for loop header.

ok marco@


# 1.59 01-Jul-2010 deraadt

compile when SMALL_KERNEL is set


# 1.58 01-Jul-2010 matthew

Change scsibus(4)'s scsi_link array to an SLIST to save memory on
sparsely populated buses.

ok dlg@, krw@


# 1.57 28-Jun-2010 krw

Remove all adapter-specific 'struct scsi_device's. They are never used. First
step in elminating 'struct scsi_device' entirely.

Spotted and initial diff from matthew@.

ok matthew@ dlg@ deraadt@ marco@ miod@


# 1.56 26-Jun-2010 krw

If you put CISS_LOCK()/CISS_UNLOCK() around a switch statement, you
must break out of the cases, not directly 'return' error codes. I
think the error case is currently impossible, but why leave an armed
bear trap lying about?


# 1.55 15-Jun-2010 dlg

dont pass the dev_t from the scsi device drivers into the midlayer for
ioctl requests, and dont pass the proc pointers around for any ioctl
requests in scsi land at all. neither were used, so trim the fat.

ok krw@ marco@


# 1.54 03-Jun-2010 dlg

get rid of the kthread. it is unused and just bloats the kernel.

pointed out by brad.


# 1.53 03-Jun-2010 dlg

replace TAILQs with SLISTs for managing the ccb free list. theyre smaller.


# 1.52 03-Jun-2010 dlg

useless abstraction is, by definition, useless.

dont typedef the tailq head struct.


# 1.51 02-Jun-2010 dlg

convert ciss(4) over to using iopools. this is fairly easy after the recent
tweaks ive made.

this provides better concurrent access to multiple volumes on the same hba,
while improving the reliability of the ioctl and sensor codepaths.

tested by okan@ halex@
ok krw@ okan@ halex@


# 1.50 02-Jun-2010 dlg

its pretty obvious that ciss_cmd should be called with splbio being held,
especially if you're passing it SCSI_POLL too.


# 1.49 02-Jun-2010 dlg

call scsi_done before put_ccb, rather than have put_ccb call scsi_done
for us.


# 1.48 02-Jun-2010 dlg

push the "locking" in ciss_scsi_cmd down. we dont need splbio to call
scsi_done or to get or put ccbs anymore.


# 1.47 02-Jun-2010 dlg

protect the ccb free queue with its own mutex


# 1.46 02-Jun-2010 dlg

get rid of useless ccb queues. when the ccb is on the chip, we mark its
state as such, putting it on a queue is silly. one of the queues was
initted by never used.


# 1.45 02-Jun-2010 dlg

get rid of the code for the passthru bus support. it was never enabled and
confuses the code and bloats the kernel.


# 1.44 02-Jun-2010 dlg

interrupt handlers are run at their IPL, so there's no need to go splbio
in a disk controllers handler, even if it has a useless bunch of macros
around it.


# 1.43 31-May-2010 halex

do not immediately panic if we find a non-increasing heartbeat counter but
keep count for at least 33 seconds. then panic.

ok marco@, moral support johan@


# 1.42 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


# 1.41 23-Mar-2010 krw

Change the scsi_cmd function member of scsi_adapter from int to
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@


Revision tags: OPENBSD_4_7_BASE
# 1.40 09-Jan-2010 krw

Zap all setting of ITSDONE in drivers that don't look at it. Nobody
else cares so it's just noise. Drivers that actually look at ITSDONE
are unchanged.

ok marco@ (for his files) dlg@ beck@


# 1.39 09-Jan-2010 krw

Avoid mulitple calls to scsi_done() on the same xs by having
ciss_cmd() call scsi_done() in the one case where ciss_done() was
not calling ciss_done() before erroring out, and not calling
scsi_done() after ciss_cmd() errors out.

Okan's box can now boot. And work fine afterwards.

Tested by okan@. ok dlg@ beck@


# 1.38 07-Jan-2010 dlg

dont use the xs in the scsi_cmd routines after calling ciss_cmd, it might
have been completed. the xs was used to figure out if we should return
COMPLETED or SUCCESFULLY_QUEUED. the return value doesnt mean anything
anymore, so just return COMPLETE.


# 1.37 07-Jan-2010 dlg

CISS_UNLOCK before returning from the scsi_cmd handler when we hit NO_CCB.
this should solve problems like this:

WARNING: SPL NOT LOWERED ON SYSCALL 16384 8 EXIT dae4560 6
Stopped at Xsyscall+0x1eb: movl $0,%gs:0x3d4
ddb{3}>


# 1.36 17-Dec-2009 krw

Initialize ccb_xs to NULL when taking a ccb off the free list. This
prevents calling xs->done() for internal commands that don't have an
xs associated with them. In turn, this prevents crashes when calling
ciss_sync(), e.g. when rebooting.

Reported on misc@ by Peter Huncar.

Prodded by kettenis@, halex@ and johan@. Fix tested by halex@.


# 1.35 15-Nov-2009 krw

Move ciss(4) to NO_CCB. Add some extra paranoia by always testing
the results of attempting to get a ccb. Eliminates manual reservation
of ccb's for bioctl and sensors. Tested by johan@ and okan@.

Eyes from brad@, dlg@ and marco@. tech@ did its Thomas More thing.


Revision tags: OPENBSD_4_6_BASE
# 1.34 29-Apr-2009 reyk

Implement the 64bit FIFO modes (based on the OpenCISS Specification
1.06). It is required to run ciss(4) with amd64 bigmem, even when
using the iommu.

Tested by many on 32bit and 64bit low- and bigmem systems
With feedback from mk@ deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.33 16-Feb-2009 miod

Extend the scsi_adapter minphys() callback to take a struct scsi_link *
as additional argument. This will allow intermediate layers between
scsi devices such as sd and scsi host adapters to take appropriate
action if necessary.


# 1.32 10-Nov-2008 cnst

remove unused variable 'error' from two functions; llvm/clang; ok dlg


# 1.31 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.30 24-Apr-2008 jakob

some ciss(4) firmwares use different physical drive addressing, resulting
in bioctl(8) functions not available; pr#5682.
code from mickey. tested by several people.
ok dlg@ krw@


Revision tags: OPENBSD_4_3_BASE
# 1.29 20-Oct-2007 krw

Call scsi_done() at SPLBIO. 'looks olright' says mickey.


# 1.28 18-Sep-2007 krw

Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().


Revision tags: OPENBSD_4_2_BASE
# 1.27 24-Jun-2007 dlg

rework sensor tasks to use the kernels generic workq rather than a special
kernel thread of its own. the api has changed (which will be fixed in the
manpage shortly) so all the users of sensor tasks that i can find have
been fixed too.

noone tested, so its going in to force people to run with it.
"put it in" deraadt@


# 1.26 29-May-2007 todd

sprinkle some SMALL_KERNEL to permit bio/softraid to run on boot media
ok marco@ then suggested deraadt@


# 1.25 22-Mar-2007 deraadt

split userland & kernel struct sensor/sensordev so that the addition
of new fields in the future is less disruptive. This is done similar
to how struct proc is handled for ps(1). ok jmc (man page changes)
tested fkr simon, and more suggestions from millert


Revision tags: OPENBSD_4_1_BASE
# 1.24 18-Jan-2007 mickey

do not freak out if cannot map physdrives into volumes and handle it proper everywhere


# 1.23 23-Dec-2006 deraadt

adapt to new two-level sensor api; Constantine A. Murenin


# 1.22 28-Nov-2006 dlg

give scsi controllers a real attach args to fill in when attaching scsibus.

ok miod@ marco@ deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.21 15-Sep-2006 krw

branches: 1.21.2;
Reserve some commands slot for bioctl/sensorsd so ciss doesn't crash
under load when bioctl/sensorsd are active. Better fix post-4.0.

Problem found, fix tested by Johan Mson Lindman.

ok dlg@ marco@ mickey@ deraadt@


# 1.20 31-Aug-2006 krw

ciss can't do bio ioctl's when >1 logical device is defined. Bail out
of ciss_ioctl if >1 logical device is present. Fixes dereferencing of
uninitialized pointer.

From mickey@ ok deraadt@


# 1.19 28-Aug-2006 mickey

make a define for dealing w/ the big bit (0x80); no func change


# 1.18 28-Aug-2006 mickey

properly detect failed drives and do not crash bioctl; krw@ testing


# 1.17 28-Aug-2006 mickey

set error and break -- not return an error before spl is set back in ioctl! found by krw@


# 1.16 27-Aug-2006 mickey

display proper volume device name in the volume line (; krw@ testing


# 1.15 27-Aug-2006 mickey

basic monitoring and management support. there are a few more things to fix but fetching array status and rebuild/blinking works on compaq/hp boxen; testing and some fixes by krw@


# 1.14 13-Mar-2006 mickey

repair commands w/ no scsi_xfer but the affected code was currently dead anyway; pointed out by Tonnerre LOMBARD <tonnerre@thebsh.sygroup.ch>


Revision tags: OPENBSD_3_9_BASE
# 1.13 02-Feb-2006 brad

make an exposed printf for debugging a debug printf and add a few commas
in the dmesg printing to make the dmesg entry look a little nicer.

ok mickey@


# 1.12 13-Dec-2005 brad

- Add a whole bunch of new PCI ids.
- Remove the version ("valance") check as it is not necessary.

From FreeBSD

ok mickey@


# 1.11 12-Dec-2005 mickey

make printf debug-only so some people would just shuddup


# 1.10 02-Dec-2005 mickey

only poll if scsi_poll was requested


# 1.9 23-Nov-2005 mickey

hp sa p600 sas; from Srebrenko Sehic <haver@insecure.dk>


# 1.8 18-Nov-2005 mickey

do not devide by zero


# 1.7 07-Sep-2005 mickey

sync on shutdown


Revision tags: OPENBSD_3_8_BASE
# 1.6 20-Aug-2005 mickey

branches: 1.6.2;
handle timeouts and errors better


# 1.5 03-Aug-2005 mickey

if fw provides no max sgl len -- suggest some of our own


# 1.4 03-Aug-2005 mickey

in config loop: make delay longer and less iterations to make it run in a better second


# 1.3 02-Aug-2005 mickey

apparently reading idb sometimes produces better results if prepend
w/ a read from the next register (hell knows what's in it).
this whole driver work is done w/ help of genua.de and
also a card donated earlier.


# 1.2 01-Aug-2005 mickey

make compile again


# 1.1 06-Jul-2005 mickey

smartarray 5* raid controller; does io but needs more work; commented out in configs for now