History log of /netbsd-current/sys/dev/ic/esiop.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.63 08-Feb-2024 andvar

s/should't/shouldn't/ and s/mistmatch/mismatch/ in comments.


Revision tags: netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base
# 1.62 02-Nov-2022 andvar

s/ourselve/ourselves/ in comments.


Revision tags: bouyer-sunxi-drm-base
# 1.61 23-May-2022 andvar

s/beggining/beginning/ in comments.


# 1.60 23-Feb-2022 andvar

fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.59 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.58 24-Apr-2021 thorpej

branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.57 02-Nov-2013 gson

branches: 1.57.46;
Turn the "esiop_intr: I shouldn't be there !" panic into a printf
followed by a return from the interrupt handler. The condition is
triggered on some KVM virtual hosts, apparently harmlessly, and not
panicing makes it possible to boot a NetBSD GENERIC kernel on those
hosts. Also make the same change to siop to minimize divergence
between siop and esiop. Fixes PR kern/48277.


# 1.56 30-Oct-2013 gson

Fix incorrect function names in panic message strings.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.55 13-Nov-2010 uebayasi

branches: 1.55.8; 1.55.14; 1.55.18; 1.55.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.54 09-Sep-2010 jakllsch

Allow e?siop_dump_script() to work with on-chip RAM. Prefix
DUMP_SCRIPT with SIOP_. Additionally, avoid undefining DEBUG,
condition on SIOP_DEBUG instead.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.53 02-May-2010 jakllsch

Add (missing) newlines to error messages.


Revision tags: uebayasi-xip-base1
# 1.52 09-Apr-2010 jakllsch

Improve error paths in (e)siop_scsipi_request():

- When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
- Correctly indicate which bus_dma_load() failed.

Analysis and fix from Michael L. Hitch in PR/42844.


# 1.51 11-Mar-2010 mrg

branches: 1.51.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9
# 1.50 12-Feb-2010 dholland

Make ESIOP_DEBUG compile (on some platforms? depends on bus definitions...)
From Chris Ross in PR 42792.


Revision tags: uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.49 19-Oct-2009 bouyer

branches: 1.49.2;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8
# 1.48 04-Sep-2009 tsutsui

Remove unnecessary whitespace.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4
# 1.47 16-May-2009 tsutsui

Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)


# 1.46 15-May-2009 tsutsui

Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.45 15-Mar-2009 cegger

ansify function definitions


# 1.44 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.43 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base yamt-nfs-mp-base yamt-pf42-base mjf-devfs2-base
# 1.42 08-Apr-2008 cegger

branches: 1.42.4; 1.42.12; 1.42.14; 1.42.18;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.41 19-Oct-2007 ad

branches: 1.41.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.40 30-Sep-2007 martin

branches: 1.40.2;
Do not stop callouts on polled commands. Problem noticed by Chris Ross
when trying to do a kernel dump on sparc64.
Approved by Manuel Bouyer.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.39 04-Mar-2007 christos

branches: 1.39.2; 1.39.14; 1.39.16; 1.39.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.38 02-Nov-2006 garbled

branches: 1.38.4;
Comment out the debug options to siop, and change the undef to define.
This way they will be compiled by the i386 DEBUG kernel and tested.


# 1.37 02-Nov-2006 garbled

Make these compile when SIOP_DEBUG is enabled, by nuking the reference to
t_offset, which no longer seems to exist.


Revision tags: yamt-splraiseipl-base2
# 1.36 29-Sep-2006 christos

Coverity CID 3015: Check before using (from Arnaud Lacombe)


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.35 24-Dec-2005 perry

branches: 1.35.20; 1.35.22;
__inline__ -> inline


Revision tags: yamt-readahead-base3 yamt-readahead-base2 ktrace-lwp-base
# 1.34 18-Nov-2005 bouyer

Some drives disconnect after the last data phase without a save data pointer
message. In such case we would not update resid with the proper value
(eventually resid would not be updated at all if there was only one data
phase). To fix this, have the script save the offset in the data tables at
disconnect time if there was a transfer, and use this to compute the resid
if the current offset is 0.
Problem reported and patch tested by edwin, Roy Bixler and YAMAMOTO Takashi.
Fix kern/31990 by YAMAMOTO Takashi.


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 kent-audio2-base
# 1.33 23-Mar-2005 bouyer

branches: 1.33.2; 1.33.8;
Don't assume all LUNs are probed before scsipi sets the mode, and always check
if lun_tagtbl needs to be allocated. Patch from john heasley in kern/29603.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2
# 1.32 04-Feb-2005 perry

branches: 1.32.4;
de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.31 20-May-2004 bouyer

branches: 1.31.4; 1.31.6;
Rmove a redundant BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE, and fix
another one (POST -> PRE)


# 1.30 17-May-2004 bouyer

Add support for the Ignore Wide Residue SCSI message.


# 1.29 17-May-2004 bouyer

when an unexpected disconnect occurs only compute the resid; do the
real save data pointers when we get the message (or rather, at disconnect
time following the message).
Factor out code to do this, and to deal with xs->resid, in siop_common.c.


# 1.28 17-May-2004 bouyer

Properly compute xs->resid, instead of assuming it'll always be 0 when
a command is done.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 16-Mar-2004 bouyer

branches: 1.27.4;
cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.


# 1.26 15-Mar-2004 bouyer

Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.


# 1.25 10-Mar-2004 bouyer

The real value of the message is in msgin, not
esiop_cmd->cmd_tables->msg_in[0], so print the correct value.


# 1.24 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.23 29-Oct-2003 mycroft

XXX: gcc


# 1.22 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.21 04-Aug-2003 bouyer

Remove unused esiop_scsicmd() prototype.


# 1.20 03-Jul-2003 drochner

Avoid an obscure gcc3 complaint about
"dereferencing type-punned pointer" by a cast to "void *".
I don't completely understand the warning, but it helps.


# 1.19 03-May-2003 wiz

branches: 1.19.2;
DMA, not dma nor Dma.


# 1.18 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge kqueue-base gehenna-devsw-base
# 1.17 18-Jul-2002 wiz

Spell 'should' correctly.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.16 18-May-2002 bouyer

branches: 1.16.2; 1.16.4; 1.16.6;
Be more verbose when returning XS_DRIVER_STUFFUP


# 1.15 16-May-2002 thorpej

Don't access a scsipi channel's periph table directly; use
scsipi_lookup_periph().


# 1.14 04-May-2002 bouyer

branches: 1.14.2;
More debug printfs.


# 1.13 29-Apr-2002 bouyer

Add a missing esiop_script_sync(), and debug messages improvements.


# 1.12 27-Apr-2002 bouyer

Use a u_int32_t in script RAM instead of the SEM bit in ISTAT to pass flags
between script and driver. This allows more than one flag, and is easier to
manage (we almost can't read/write istat outside of the irq handler).


# 1.11 27-Apr-2002 bouyer

Implement a ring for the completed commands. This avoid a (problematic only
if error occurs after status is collected) race condition
when using the status byte to detect completed commands (a command descriptor
could be recycled before the device disconnected), and make the
interrupt routine handling completed commands more efficient (no need to
scan target * lun * tag array any more).


# 1.10 25-Apr-2002 bouyer

It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.


# 1.9 25-Apr-2002 bouyer

- We can't share the per-lun DSA entry for untagged and tag table DSA;
there may be tagged commands still running when we queue a request sense
command.
Solve this by using 2 DSA entry per LUN
- Now that we have the command DSA before select, we can load T/L/Q in
SCRATCHC. This makes the selection timeout handler simpler.
- Avoid a race condition when setting the free flag in the cmd ring (see
comment in the script)
- don't forget to update the ID in the head of LUN table after a sync/wide
negotiation. This fixes the command timeout at the first data command
after negotiation (the bus reset handler did update the ID properly,
so subsequent commands were OK).
- for DMA interrupts, clear fifo if it's not empty. Leaving the fifo dirty
would prevent subsequent interrupts from coming in.
- Various improvements in debug messages
- misc cleanups.


# 1.8 24-Apr-2002 bouyer

For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).


# 1.7 23-Apr-2002 bouyer

More copyright fixes, pointed out by Thomas. Thanks !


# 1.6 23-Apr-2002 bouyer

- factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.


# 1.5 23-Apr-2002 bouyer

Bump the space for SCSI messages from 8 to 16 octets, as 8 may not be
enouth for IDENTIFY + TAG + PPR.
Get rid of constants in C code by use of a offsetof macro.


# 1.4 23-Apr-2002 bouyer

Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.


# 1.3 22-Apr-2002 bouyer

Adapt for script "wait MSG_OUT after select" change: now, when we get
selection timeout, SCRATCHE points to the slot which triggered the timeout,
not the next one.


# 1.2 22-Apr-2002 bouyer

Add support for tagged queuing to esiop (256 tags per device).
For this add another indirecton: the DSA in the LUN table points to
a table of DSA indexed by the tag number when tagged command is in use.
For non tagged command, the LUN DSA still points to the tables describing the
xfer directly.


# 1.1 21-Apr-2002 bouyer

First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.


# 1.62 02-Nov-2022 andvar

s/ourselve/ourselves/ in comments.


Revision tags: bouyer-sunxi-drm-base
# 1.61 23-May-2022 andvar

s/beggining/beginning/ in comments.


# 1.60 23-Feb-2022 andvar

fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.59 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.58 24-Apr-2021 thorpej

branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.57 02-Nov-2013 gson

branches: 1.57.46;
Turn the "esiop_intr: I shouldn't be there !" panic into a printf
followed by a return from the interrupt handler. The condition is
triggered on some KVM virtual hosts, apparently harmlessly, and not
panicing makes it possible to boot a NetBSD GENERIC kernel on those
hosts. Also make the same change to siop to minimize divergence
between siop and esiop. Fixes PR kern/48277.


# 1.56 30-Oct-2013 gson

Fix incorrect function names in panic message strings.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.55 13-Nov-2010 uebayasi

branches: 1.55.8; 1.55.14; 1.55.18; 1.55.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.54 09-Sep-2010 jakllsch

Allow e?siop_dump_script() to work with on-chip RAM. Prefix
DUMP_SCRIPT with SIOP_. Additionally, avoid undefining DEBUG,
condition on SIOP_DEBUG instead.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.53 02-May-2010 jakllsch

Add (missing) newlines to error messages.


Revision tags: uebayasi-xip-base1
# 1.52 09-Apr-2010 jakllsch

Improve error paths in (e)siop_scsipi_request():

- When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
- Correctly indicate which bus_dma_load() failed.

Analysis and fix from Michael L. Hitch in PR/42844.


# 1.51 11-Mar-2010 mrg

branches: 1.51.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9
# 1.50 12-Feb-2010 dholland

Make ESIOP_DEBUG compile (on some platforms? depends on bus definitions...)
From Chris Ross in PR 42792.


Revision tags: uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.49 19-Oct-2009 bouyer

branches: 1.49.2;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8
# 1.48 04-Sep-2009 tsutsui

Remove unnecessary whitespace.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4
# 1.47 16-May-2009 tsutsui

Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)


# 1.46 15-May-2009 tsutsui

Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.45 15-Mar-2009 cegger

ansify function definitions


# 1.44 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.43 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base yamt-nfs-mp-base yamt-pf42-base mjf-devfs2-base
# 1.42 08-Apr-2008 cegger

branches: 1.42.4; 1.42.12; 1.42.14; 1.42.18;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.41 19-Oct-2007 ad

branches: 1.41.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.40 30-Sep-2007 martin

branches: 1.40.2;
Do not stop callouts on polled commands. Problem noticed by Chris Ross
when trying to do a kernel dump on sparc64.
Approved by Manuel Bouyer.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.39 04-Mar-2007 christos

branches: 1.39.2; 1.39.14; 1.39.16; 1.39.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.38 02-Nov-2006 garbled

branches: 1.38.4;
Comment out the debug options to siop, and change the undef to define.
This way they will be compiled by the i386 DEBUG kernel and tested.


# 1.37 02-Nov-2006 garbled

Make these compile when SIOP_DEBUG is enabled, by nuking the reference to
t_offset, which no longer seems to exist.


Revision tags: yamt-splraiseipl-base2
# 1.36 29-Sep-2006 christos

Coverity CID 3015: Check before using (from Arnaud Lacombe)


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.35 24-Dec-2005 perry

branches: 1.35.20; 1.35.22;
__inline__ -> inline


Revision tags: yamt-readahead-base3 yamt-readahead-base2 ktrace-lwp-base
# 1.34 18-Nov-2005 bouyer

Some drives disconnect after the last data phase without a save data pointer
message. In such case we would not update resid with the proper value
(eventually resid would not be updated at all if there was only one data
phase). To fix this, have the script save the offset in the data tables at
disconnect time if there was a transfer, and use this to compute the resid
if the current offset is 0.
Problem reported and patch tested by edwin, Roy Bixler and YAMAMOTO Takashi.
Fix kern/31990 by YAMAMOTO Takashi.


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 kent-audio2-base
# 1.33 23-Mar-2005 bouyer

branches: 1.33.2; 1.33.8;
Don't assume all LUNs are probed before scsipi sets the mode, and always check
if lun_tagtbl needs to be allocated. Patch from john heasley in kern/29603.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2
# 1.32 04-Feb-2005 perry

branches: 1.32.4;
de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.31 20-May-2004 bouyer

branches: 1.31.4; 1.31.6;
Rmove a redundant BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE, and fix
another one (POST -> PRE)


# 1.30 17-May-2004 bouyer

Add support for the Ignore Wide Residue SCSI message.


# 1.29 17-May-2004 bouyer

when an unexpected disconnect occurs only compute the resid; do the
real save data pointers when we get the message (or rather, at disconnect
time following the message).
Factor out code to do this, and to deal with xs->resid, in siop_common.c.


# 1.28 17-May-2004 bouyer

Properly compute xs->resid, instead of assuming it'll always be 0 when
a command is done.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 16-Mar-2004 bouyer

branches: 1.27.4;
cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.


# 1.26 15-Mar-2004 bouyer

Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.


# 1.25 10-Mar-2004 bouyer

The real value of the message is in msgin, not
esiop_cmd->cmd_tables->msg_in[0], so print the correct value.


# 1.24 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.23 29-Oct-2003 mycroft

XXX: gcc


# 1.22 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.21 04-Aug-2003 bouyer

Remove unused esiop_scsicmd() prototype.


# 1.20 03-Jul-2003 drochner

Avoid an obscure gcc3 complaint about
"dereferencing type-punned pointer" by a cast to "void *".
I don't completely understand the warning, but it helps.


# 1.19 03-May-2003 wiz

branches: 1.19.2;
DMA, not dma nor Dma.


# 1.18 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge kqueue-base gehenna-devsw-base
# 1.17 18-Jul-2002 wiz

Spell 'should' correctly.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.16 18-May-2002 bouyer

branches: 1.16.2; 1.16.4; 1.16.6;
Be more verbose when returning XS_DRIVER_STUFFUP


# 1.15 16-May-2002 thorpej

Don't access a scsipi channel's periph table directly; use
scsipi_lookup_periph().


# 1.14 04-May-2002 bouyer

branches: 1.14.2;
More debug printfs.


# 1.13 29-Apr-2002 bouyer

Add a missing esiop_script_sync(), and debug messages improvements.


# 1.12 27-Apr-2002 bouyer

Use a u_int32_t in script RAM instead of the SEM bit in ISTAT to pass flags
between script and driver. This allows more than one flag, and is easier to
manage (we almost can't read/write istat outside of the irq handler).


# 1.11 27-Apr-2002 bouyer

Implement a ring for the completed commands. This avoid a (problematic only
if error occurs after status is collected) race condition
when using the status byte to detect completed commands (a command descriptor
could be recycled before the device disconnected), and make the
interrupt routine handling completed commands more efficient (no need to
scan target * lun * tag array any more).


# 1.10 25-Apr-2002 bouyer

It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.


# 1.9 25-Apr-2002 bouyer

- We can't share the per-lun DSA entry for untagged and tag table DSA;
there may be tagged commands still running when we queue a request sense
command.
Solve this by using 2 DSA entry per LUN
- Now that we have the command DSA before select, we can load T/L/Q in
SCRATCHC. This makes the selection timeout handler simpler.
- Avoid a race condition when setting the free flag in the cmd ring (see
comment in the script)
- don't forget to update the ID in the head of LUN table after a sync/wide
negotiation. This fixes the command timeout at the first data command
after negotiation (the bus reset handler did update the ID properly,
so subsequent commands were OK).
- for DMA interrupts, clear fifo if it's not empty. Leaving the fifo dirty
would prevent subsequent interrupts from coming in.
- Various improvements in debug messages
- misc cleanups.


# 1.8 24-Apr-2002 bouyer

For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).


# 1.7 23-Apr-2002 bouyer

More copyright fixes, pointed out by Thomas. Thanks !


# 1.6 23-Apr-2002 bouyer

- factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.


# 1.5 23-Apr-2002 bouyer

Bump the space for SCSI messages from 8 to 16 octets, as 8 may not be
enouth for IDENTIFY + TAG + PPR.
Get rid of constants in C code by use of a offsetof macro.


# 1.4 23-Apr-2002 bouyer

Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.


# 1.3 22-Apr-2002 bouyer

Adapt for script "wait MSG_OUT after select" change: now, when we get
selection timeout, SCRATCHE points to the slot which triggered the timeout,
not the next one.


# 1.2 22-Apr-2002 bouyer

Add support for tagged queuing to esiop (256 tags per device).
For this add another indirecton: the DSA in the LUN table points to
a table of DSA indexed by the tag number when tagged command is in use.
For non tagged command, the LUN DSA still points to the tables describing the
xfer directly.


# 1.1 21-Apr-2002 bouyer

First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.


# 1.61 23-May-2022 andvar

s/beggining/beginning/ in comments.


# 1.60 23-Feb-2022 andvar

fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.59 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.58 24-Apr-2021 thorpej

branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: netbsd-9-2-RELEASE thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.57 02-Nov-2013 gson

branches: 1.57.46;
Turn the "esiop_intr: I shouldn't be there !" panic into a printf
followed by a return from the interrupt handler. The condition is
triggered on some KVM virtual hosts, apparently harmlessly, and not
panicing makes it possible to boot a NetBSD GENERIC kernel on those
hosts. Also make the same change to siop to minimize divergence
between siop and esiop. Fixes PR kern/48277.


# 1.56 30-Oct-2013 gson

Fix incorrect function names in panic message strings.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.55 13-Nov-2010 uebayasi

branches: 1.55.8; 1.55.14; 1.55.18; 1.55.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.54 09-Sep-2010 jakllsch

Allow e?siop_dump_script() to work with on-chip RAM. Prefix
DUMP_SCRIPT with SIOP_. Additionally, avoid undefining DEBUG,
condition on SIOP_DEBUG instead.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.53 02-May-2010 jakllsch

Add (missing) newlines to error messages.


Revision tags: uebayasi-xip-base1
# 1.52 09-Apr-2010 jakllsch

Improve error paths in (e)siop_scsipi_request():

- When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
- Correctly indicate which bus_dma_load() failed.

Analysis and fix from Michael L. Hitch in PR/42844.


# 1.51 11-Mar-2010 mrg

branches: 1.51.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9
# 1.50 12-Feb-2010 dholland

Make ESIOP_DEBUG compile (on some platforms? depends on bus definitions...)
From Chris Ross in PR 42792.


Revision tags: uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.49 19-Oct-2009 bouyer

branches: 1.49.2;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8
# 1.48 04-Sep-2009 tsutsui

Remove unnecessary whitespace.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4
# 1.47 16-May-2009 tsutsui

Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)


# 1.46 15-May-2009 tsutsui

Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.45 15-Mar-2009 cegger

ansify function definitions


# 1.44 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.43 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base yamt-nfs-mp-base yamt-pf42-base mjf-devfs2-base
# 1.42 08-Apr-2008 cegger

branches: 1.42.4; 1.42.12; 1.42.14; 1.42.18;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.41 19-Oct-2007 ad

branches: 1.41.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.40 30-Sep-2007 martin

branches: 1.40.2;
Do not stop callouts on polled commands. Problem noticed by Chris Ross
when trying to do a kernel dump on sparc64.
Approved by Manuel Bouyer.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.39 04-Mar-2007 christos

branches: 1.39.2; 1.39.14; 1.39.16; 1.39.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.38 02-Nov-2006 garbled

branches: 1.38.4;
Comment out the debug options to siop, and change the undef to define.
This way they will be compiled by the i386 DEBUG kernel and tested.


# 1.37 02-Nov-2006 garbled

Make these compile when SIOP_DEBUG is enabled, by nuking the reference to
t_offset, which no longer seems to exist.


Revision tags: yamt-splraiseipl-base2
# 1.36 29-Sep-2006 christos

Coverity CID 3015: Check before using (from Arnaud Lacombe)


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.35 24-Dec-2005 perry

branches: 1.35.20; 1.35.22;
__inline__ -> inline


Revision tags: yamt-readahead-base3 yamt-readahead-base2 ktrace-lwp-base
# 1.34 18-Nov-2005 bouyer

Some drives disconnect after the last data phase without a save data pointer
message. In such case we would not update resid with the proper value
(eventually resid would not be updated at all if there was only one data
phase). To fix this, have the script save the offset in the data tables at
disconnect time if there was a transfer, and use this to compute the resid
if the current offset is 0.
Problem reported and patch tested by edwin, Roy Bixler and YAMAMOTO Takashi.
Fix kern/31990 by YAMAMOTO Takashi.


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 kent-audio2-base
# 1.33 23-Mar-2005 bouyer

branches: 1.33.2; 1.33.8;
Don't assume all LUNs are probed before scsipi sets the mode, and always check
if lun_tagtbl needs to be allocated. Patch from john heasley in kern/29603.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2
# 1.32 04-Feb-2005 perry

branches: 1.32.4;
de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.31 20-May-2004 bouyer

branches: 1.31.4; 1.31.6;
Rmove a redundant BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE, and fix
another one (POST -> PRE)


# 1.30 17-May-2004 bouyer

Add support for the Ignore Wide Residue SCSI message.


# 1.29 17-May-2004 bouyer

when an unexpected disconnect occurs only compute the resid; do the
real save data pointers when we get the message (or rather, at disconnect
time following the message).
Factor out code to do this, and to deal with xs->resid, in siop_common.c.


# 1.28 17-May-2004 bouyer

Properly compute xs->resid, instead of assuming it'll always be 0 when
a command is done.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 16-Mar-2004 bouyer

branches: 1.27.4;
cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.


# 1.26 15-Mar-2004 bouyer

Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.


# 1.25 10-Mar-2004 bouyer

The real value of the message is in msgin, not
esiop_cmd->cmd_tables->msg_in[0], so print the correct value.


# 1.24 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.23 29-Oct-2003 mycroft

XXX: gcc


# 1.22 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.21 04-Aug-2003 bouyer

Remove unused esiop_scsicmd() prototype.


# 1.20 03-Jul-2003 drochner

Avoid an obscure gcc3 complaint about
"dereferencing type-punned pointer" by a cast to "void *".
I don't completely understand the warning, but it helps.


# 1.19 03-May-2003 wiz

branches: 1.19.2;
DMA, not dma nor Dma.


# 1.18 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge kqueue-base gehenna-devsw-base
# 1.17 18-Jul-2002 wiz

Spell 'should' correctly.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.16 18-May-2002 bouyer

branches: 1.16.2; 1.16.4; 1.16.6;
Be more verbose when returning XS_DRIVER_STUFFUP


# 1.15 16-May-2002 thorpej

Don't access a scsipi channel's periph table directly; use
scsipi_lookup_periph().


# 1.14 04-May-2002 bouyer

branches: 1.14.2;
More debug printfs.


# 1.13 29-Apr-2002 bouyer

Add a missing esiop_script_sync(), and debug messages improvements.


# 1.12 27-Apr-2002 bouyer

Use a u_int32_t in script RAM instead of the SEM bit in ISTAT to pass flags
between script and driver. This allows more than one flag, and is easier to
manage (we almost can't read/write istat outside of the irq handler).


# 1.11 27-Apr-2002 bouyer

Implement a ring for the completed commands. This avoid a (problematic only
if error occurs after status is collected) race condition
when using the status byte to detect completed commands (a command descriptor
could be recycled before the device disconnected), and make the
interrupt routine handling completed commands more efficient (no need to
scan target * lun * tag array any more).


# 1.10 25-Apr-2002 bouyer

It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.


# 1.9 25-Apr-2002 bouyer

- We can't share the per-lun DSA entry for untagged and tag table DSA;
there may be tagged commands still running when we queue a request sense
command.
Solve this by using 2 DSA entry per LUN
- Now that we have the command DSA before select, we can load T/L/Q in
SCRATCHC. This makes the selection timeout handler simpler.
- Avoid a race condition when setting the free flag in the cmd ring (see
comment in the script)
- don't forget to update the ID in the head of LUN table after a sync/wide
negotiation. This fixes the command timeout at the first data command
after negotiation (the bus reset handler did update the ID properly,
so subsequent commands were OK).
- for DMA interrupts, clear fifo if it's not empty. Leaving the fifo dirty
would prevent subsequent interrupts from coming in.
- Various improvements in debug messages
- misc cleanups.


# 1.8 24-Apr-2002 bouyer

For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).


# 1.7 23-Apr-2002 bouyer

More copyright fixes, pointed out by Thomas. Thanks !


# 1.6 23-Apr-2002 bouyer

- factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.


# 1.5 23-Apr-2002 bouyer

Bump the space for SCSI messages from 8 to 16 octets, as 8 may not be
enouth for IDENTIFY + TAG + PPR.
Get rid of constants in C code by use of a offsetof macro.


# 1.4 23-Apr-2002 bouyer

Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.


# 1.3 22-Apr-2002 bouyer

Adapt for script "wait MSG_OUT after select" change: now, when we get
selection timeout, SCRATCHE points to the slot which triggered the timeout,
not the next one.


# 1.2 22-Apr-2002 bouyer

Add support for tagged queuing to esiop (256 tags per device).
For this add another indirecton: the DSA in the LUN table points to
a table of DSA indexed by the tag number when tagged command is in use.
For non tagged command, the LUN DSA still points to the tables describing the
xfer directly.


# 1.1 21-Apr-2002 bouyer

First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.


# 1.60 23-Feb-2022 andvar

fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.59 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.58 24-Apr-2021 thorpej

branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: netbsd-9-2-RELEASE thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.57 02-Nov-2013 gson

branches: 1.57.46;
Turn the "esiop_intr: I shouldn't be there !" panic into a printf
followed by a return from the interrupt handler. The condition is
triggered on some KVM virtual hosts, apparently harmlessly, and not
panicing makes it possible to boot a NetBSD GENERIC kernel on those
hosts. Also make the same change to siop to minimize divergence
between siop and esiop. Fixes PR kern/48277.


# 1.56 30-Oct-2013 gson

Fix incorrect function names in panic message strings.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.55 13-Nov-2010 uebayasi

branches: 1.55.8; 1.55.14; 1.55.18; 1.55.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.54 09-Sep-2010 jakllsch

Allow e?siop_dump_script() to work with on-chip RAM. Prefix
DUMP_SCRIPT with SIOP_. Additionally, avoid undefining DEBUG,
condition on SIOP_DEBUG instead.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.53 02-May-2010 jakllsch

Add (missing) newlines to error messages.


Revision tags: uebayasi-xip-base1
# 1.52 09-Apr-2010 jakllsch

Improve error paths in (e)siop_scsipi_request():

- When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
- Correctly indicate which bus_dma_load() failed.

Analysis and fix from Michael L. Hitch in PR/42844.


# 1.51 11-Mar-2010 mrg

branches: 1.51.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9
# 1.50 12-Feb-2010 dholland

Make ESIOP_DEBUG compile (on some platforms? depends on bus definitions...)
From Chris Ross in PR 42792.


Revision tags: uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.49 19-Oct-2009 bouyer

branches: 1.49.2;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8
# 1.48 04-Sep-2009 tsutsui

Remove unnecessary whitespace.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4
# 1.47 16-May-2009 tsutsui

Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)


# 1.46 15-May-2009 tsutsui

Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.45 15-Mar-2009 cegger

ansify function definitions


# 1.44 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.43 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base yamt-nfs-mp-base yamt-pf42-base mjf-devfs2-base
# 1.42 08-Apr-2008 cegger

branches: 1.42.4; 1.42.12; 1.42.14; 1.42.18;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.41 19-Oct-2007 ad

branches: 1.41.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.40 30-Sep-2007 martin

branches: 1.40.2;
Do not stop callouts on polled commands. Problem noticed by Chris Ross
when trying to do a kernel dump on sparc64.
Approved by Manuel Bouyer.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.39 04-Mar-2007 christos

branches: 1.39.2; 1.39.14; 1.39.16; 1.39.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.38 02-Nov-2006 garbled

branches: 1.38.4;
Comment out the debug options to siop, and change the undef to define.
This way they will be compiled by the i386 DEBUG kernel and tested.


# 1.37 02-Nov-2006 garbled

Make these compile when SIOP_DEBUG is enabled, by nuking the reference to
t_offset, which no longer seems to exist.


Revision tags: yamt-splraiseipl-base2
# 1.36 29-Sep-2006 christos

Coverity CID 3015: Check before using (from Arnaud Lacombe)


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.35 24-Dec-2005 perry

branches: 1.35.20; 1.35.22;
__inline__ -> inline


Revision tags: yamt-readahead-base3 yamt-readahead-base2 ktrace-lwp-base
# 1.34 18-Nov-2005 bouyer

Some drives disconnect after the last data phase without a save data pointer
message. In such case we would not update resid with the proper value
(eventually resid would not be updated at all if there was only one data
phase). To fix this, have the script save the offset in the data tables at
disconnect time if there was a transfer, and use this to compute the resid
if the current offset is 0.
Problem reported and patch tested by edwin, Roy Bixler and YAMAMOTO Takashi.
Fix kern/31990 by YAMAMOTO Takashi.


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 kent-audio2-base
# 1.33 23-Mar-2005 bouyer

branches: 1.33.2; 1.33.8;
Don't assume all LUNs are probed before scsipi sets the mode, and always check
if lun_tagtbl needs to be allocated. Patch from john heasley in kern/29603.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2
# 1.32 04-Feb-2005 perry

branches: 1.32.4;
de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.31 20-May-2004 bouyer

branches: 1.31.4; 1.31.6;
Rmove a redundant BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE, and fix
another one (POST -> PRE)


# 1.30 17-May-2004 bouyer

Add support for the Ignore Wide Residue SCSI message.


# 1.29 17-May-2004 bouyer

when an unexpected disconnect occurs only compute the resid; do the
real save data pointers when we get the message (or rather, at disconnect
time following the message).
Factor out code to do this, and to deal with xs->resid, in siop_common.c.


# 1.28 17-May-2004 bouyer

Properly compute xs->resid, instead of assuming it'll always be 0 when
a command is done.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 16-Mar-2004 bouyer

branches: 1.27.4;
cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.


# 1.26 15-Mar-2004 bouyer

Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.


# 1.25 10-Mar-2004 bouyer

The real value of the message is in msgin, not
esiop_cmd->cmd_tables->msg_in[0], so print the correct value.


# 1.24 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.23 29-Oct-2003 mycroft

XXX: gcc


# 1.22 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.21 04-Aug-2003 bouyer

Remove unused esiop_scsicmd() prototype.


# 1.20 03-Jul-2003 drochner

Avoid an obscure gcc3 complaint about
"dereferencing type-punned pointer" by a cast to "void *".
I don't completely understand the warning, but it helps.


# 1.19 03-May-2003 wiz

branches: 1.19.2;
DMA, not dma nor Dma.


# 1.18 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge kqueue-base gehenna-devsw-base
# 1.17 18-Jul-2002 wiz

Spell 'should' correctly.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.16 18-May-2002 bouyer

branches: 1.16.2; 1.16.4; 1.16.6;
Be more verbose when returning XS_DRIVER_STUFFUP


# 1.15 16-May-2002 thorpej

Don't access a scsipi channel's periph table directly; use
scsipi_lookup_periph().


# 1.14 04-May-2002 bouyer

branches: 1.14.2;
More debug printfs.


# 1.13 29-Apr-2002 bouyer

Add a missing esiop_script_sync(), and debug messages improvements.


# 1.12 27-Apr-2002 bouyer

Use a u_int32_t in script RAM instead of the SEM bit in ISTAT to pass flags
between script and driver. This allows more than one flag, and is easier to
manage (we almost can't read/write istat outside of the irq handler).


# 1.11 27-Apr-2002 bouyer

Implement a ring for the completed commands. This avoid a (problematic only
if error occurs after status is collected) race condition
when using the status byte to detect completed commands (a command descriptor
could be recycled before the device disconnected), and make the
interrupt routine handling completed commands more efficient (no need to
scan target * lun * tag array any more).


# 1.10 25-Apr-2002 bouyer

It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.


# 1.9 25-Apr-2002 bouyer

- We can't share the per-lun DSA entry for untagged and tag table DSA;
there may be tagged commands still running when we queue a request sense
command.
Solve this by using 2 DSA entry per LUN
- Now that we have the command DSA before select, we can load T/L/Q in
SCRATCHC. This makes the selection timeout handler simpler.
- Avoid a race condition when setting the free flag in the cmd ring (see
comment in the script)
- don't forget to update the ID in the head of LUN table after a sync/wide
negotiation. This fixes the command timeout at the first data command
after negotiation (the bus reset handler did update the ID properly,
so subsequent commands were OK).
- for DMA interrupts, clear fifo if it's not empty. Leaving the fifo dirty
would prevent subsequent interrupts from coming in.
- Various improvements in debug messages
- misc cleanups.


# 1.8 24-Apr-2002 bouyer

For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).


# 1.7 23-Apr-2002 bouyer

More copyright fixes, pointed out by Thomas. Thanks !


# 1.6 23-Apr-2002 bouyer

- factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.


# 1.5 23-Apr-2002 bouyer

Bump the space for SCSI messages from 8 to 16 octets, as 8 may not be
enouth for IDENTIFY + TAG + PPR.
Get rid of constants in C code by use of a offsetof macro.


# 1.4 23-Apr-2002 bouyer

Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.


# 1.3 22-Apr-2002 bouyer

Adapt for script "wait MSG_OUT after select" change: now, when we get
selection timeout, SCRATCHE points to the slot which triggered the timeout,
not the next one.


# 1.2 22-Apr-2002 bouyer

Add support for tagged queuing to esiop (256 tags per device).
For this add another indirecton: the DSA in the LUN table points to
a table of DSA indexed by the tag number when tagged command is in use.
For non tagged command, the LUN DSA still points to the tables describing the
xfer directly.


# 1.1 21-Apr-2002 bouyer

First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.


# 1.59 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.58 24-Apr-2021 thorpej

branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: netbsd-9-2-RELEASE thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.57 02-Nov-2013 gson

branches: 1.57.46;
Turn the "esiop_intr: I shouldn't be there !" panic into a printf
followed by a return from the interrupt handler. The condition is
triggered on some KVM virtual hosts, apparently harmlessly, and not
panicing makes it possible to boot a NetBSD GENERIC kernel on those
hosts. Also make the same change to siop to minimize divergence
between siop and esiop. Fixes PR kern/48277.


# 1.56 30-Oct-2013 gson

Fix incorrect function names in panic message strings.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.55 13-Nov-2010 uebayasi

branches: 1.55.8; 1.55.14; 1.55.18; 1.55.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.54 09-Sep-2010 jakllsch

Allow e?siop_dump_script() to work with on-chip RAM. Prefix
DUMP_SCRIPT with SIOP_. Additionally, avoid undefining DEBUG,
condition on SIOP_DEBUG instead.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.53 02-May-2010 jakllsch

Add (missing) newlines to error messages.


Revision tags: uebayasi-xip-base1
# 1.52 09-Apr-2010 jakllsch

Improve error paths in (e)siop_scsipi_request():

- When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
- Correctly indicate which bus_dma_load() failed.

Analysis and fix from Michael L. Hitch in PR/42844.


# 1.51 11-Mar-2010 mrg

branches: 1.51.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9
# 1.50 12-Feb-2010 dholland

Make ESIOP_DEBUG compile (on some platforms? depends on bus definitions...)
From Chris Ross in PR 42792.


Revision tags: uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.49 19-Oct-2009 bouyer

branches: 1.49.2;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8
# 1.48 04-Sep-2009 tsutsui

Remove unnecessary whitespace.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4
# 1.47 16-May-2009 tsutsui

Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)


# 1.46 15-May-2009 tsutsui

Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.45 15-Mar-2009 cegger

ansify function definitions


# 1.44 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.43 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base yamt-nfs-mp-base yamt-pf42-base mjf-devfs2-base
# 1.42 08-Apr-2008 cegger

branches: 1.42.4; 1.42.12; 1.42.14; 1.42.18;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.41 19-Oct-2007 ad

branches: 1.41.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.40 30-Sep-2007 martin

branches: 1.40.2;
Do not stop callouts on polled commands. Problem noticed by Chris Ross
when trying to do a kernel dump on sparc64.
Approved by Manuel Bouyer.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.39 04-Mar-2007 christos

branches: 1.39.2; 1.39.14; 1.39.16; 1.39.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.38 02-Nov-2006 garbled

branches: 1.38.4;
Comment out the debug options to siop, and change the undef to define.
This way they will be compiled by the i386 DEBUG kernel and tested.


# 1.37 02-Nov-2006 garbled

Make these compile when SIOP_DEBUG is enabled, by nuking the reference to
t_offset, which no longer seems to exist.


Revision tags: yamt-splraiseipl-base2
# 1.36 29-Sep-2006 christos

Coverity CID 3015: Check before using (from Arnaud Lacombe)


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.35 24-Dec-2005 perry

branches: 1.35.20; 1.35.22;
__inline__ -> inline


Revision tags: yamt-readahead-base3 yamt-readahead-base2 ktrace-lwp-base
# 1.34 18-Nov-2005 bouyer

Some drives disconnect after the last data phase without a save data pointer
message. In such case we would not update resid with the proper value
(eventually resid would not be updated at all if there was only one data
phase). To fix this, have the script save the offset in the data tables at
disconnect time if there was a transfer, and use this to compute the resid
if the current offset is 0.
Problem reported and patch tested by edwin, Roy Bixler and YAMAMOTO Takashi.
Fix kern/31990 by YAMAMOTO Takashi.


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 kent-audio2-base
# 1.33 23-Mar-2005 bouyer

branches: 1.33.2; 1.33.8;
Don't assume all LUNs are probed before scsipi sets the mode, and always check
if lun_tagtbl needs to be allocated. Patch from john heasley in kern/29603.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2
# 1.32 04-Feb-2005 perry

branches: 1.32.4;
de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.31 20-May-2004 bouyer

branches: 1.31.4; 1.31.6;
Rmove a redundant BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE, and fix
another one (POST -> PRE)


# 1.30 17-May-2004 bouyer

Add support for the Ignore Wide Residue SCSI message.


# 1.29 17-May-2004 bouyer

when an unexpected disconnect occurs only compute the resid; do the
real save data pointers when we get the message (or rather, at disconnect
time following the message).
Factor out code to do this, and to deal with xs->resid, in siop_common.c.


# 1.28 17-May-2004 bouyer

Properly compute xs->resid, instead of assuming it'll always be 0 when
a command is done.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 16-Mar-2004 bouyer

branches: 1.27.4;
cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.


# 1.26 15-Mar-2004 bouyer

Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.


# 1.25 10-Mar-2004 bouyer

The real value of the message is in msgin, not
esiop_cmd->cmd_tables->msg_in[0], so print the correct value.


# 1.24 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.23 29-Oct-2003 mycroft

XXX: gcc


# 1.22 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.21 04-Aug-2003 bouyer

Remove unused esiop_scsicmd() prototype.


# 1.20 03-Jul-2003 drochner

Avoid an obscure gcc3 complaint about
"dereferencing type-punned pointer" by a cast to "void *".
I don't completely understand the warning, but it helps.


# 1.19 03-May-2003 wiz

branches: 1.19.2;
DMA, not dma nor Dma.


# 1.18 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge kqueue-base gehenna-devsw-base
# 1.17 18-Jul-2002 wiz

Spell 'should' correctly.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.16 18-May-2002 bouyer

branches: 1.16.2; 1.16.4; 1.16.6;
Be more verbose when returning XS_DRIVER_STUFFUP


# 1.15 16-May-2002 thorpej

Don't access a scsipi channel's periph table directly; use
scsipi_lookup_periph().


# 1.14 04-May-2002 bouyer

branches: 1.14.2;
More debug printfs.


# 1.13 29-Apr-2002 bouyer

Add a missing esiop_script_sync(), and debug messages improvements.


# 1.12 27-Apr-2002 bouyer

Use a u_int32_t in script RAM instead of the SEM bit in ISTAT to pass flags
between script and driver. This allows more than one flag, and is easier to
manage (we almost can't read/write istat outside of the irq handler).


# 1.11 27-Apr-2002 bouyer

Implement a ring for the completed commands. This avoid a (problematic only
if error occurs after status is collected) race condition
when using the status byte to detect completed commands (a command descriptor
could be recycled before the device disconnected), and make the
interrupt routine handling completed commands more efficient (no need to
scan target * lun * tag array any more).


# 1.10 25-Apr-2002 bouyer

It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.


# 1.9 25-Apr-2002 bouyer

- We can't share the per-lun DSA entry for untagged and tag table DSA;
there may be tagged commands still running when we queue a request sense
command.
Solve this by using 2 DSA entry per LUN
- Now that we have the command DSA before select, we can load T/L/Q in
SCRATCHC. This makes the selection timeout handler simpler.
- Avoid a race condition when setting the free flag in the cmd ring (see
comment in the script)
- don't forget to update the ID in the head of LUN table after a sync/wide
negotiation. This fixes the command timeout at the first data command
after negotiation (the bus reset handler did update the ID properly,
so subsequent commands were OK).
- for DMA interrupts, clear fifo if it's not empty. Leaving the fifo dirty
would prevent subsequent interrupts from coming in.
- Various improvements in debug messages
- misc cleanups.


# 1.8 24-Apr-2002 bouyer

For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).


# 1.7 23-Apr-2002 bouyer

More copyright fixes, pointed out by Thomas. Thanks !


# 1.6 23-Apr-2002 bouyer

- factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.


# 1.5 23-Apr-2002 bouyer

Bump the space for SCSI messages from 8 to 16 octets, as 8 may not be
enouth for IDENTIFY + TAG + PPR.
Get rid of constants in C code by use of a offsetof macro.


# 1.4 23-Apr-2002 bouyer

Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.


# 1.3 22-Apr-2002 bouyer

Adapt for script "wait MSG_OUT after select" change: now, when we get
selection timeout, SCRATCHE points to the slot which triggered the timeout,
not the next one.


# 1.2 22-Apr-2002 bouyer

Add support for tagged queuing to esiop (256 tags per device).
For this add another indirecton: the DSA in the LUN table points to
a table of DSA indexed by the tag number when tagged command is in use.
For non tagged command, the LUN DSA still points to the tables describing the
xfer directly.


# 1.1 21-Apr-2002 bouyer

First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.


# 1.58 24-Apr-2021 thorpej

Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 nick-nhusb-base-20170204 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 nick-nhusb-base-20161204 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE nick-nhusb-base-20161004 localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 netbsd-7-0-1-RELEASE nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.57 02-Nov-2013 gson

branches: 1.57.46;
Turn the "esiop_intr: I shouldn't be there !" panic into a printf
followed by a return from the interrupt handler. The condition is
triggered on some KVM virtual hosts, apparently harmlessly, and not
panicing makes it possible to boot a NetBSD GENERIC kernel on those
hosts. Also make the same change to siop to minimize divergence
between siop and esiop. Fixes PR kern/48277.


# 1.56 30-Oct-2013 gson

Fix incorrect function names in panic message strings.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.55 13-Nov-2010 uebayasi

branches: 1.55.8; 1.55.14; 1.55.18; 1.55.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.54 09-Sep-2010 jakllsch

Allow e?siop_dump_script() to work with on-chip RAM. Prefix
DUMP_SCRIPT with SIOP_. Additionally, avoid undefining DEBUG,
condition on SIOP_DEBUG instead.


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.53 02-May-2010 jakllsch

Add (missing) newlines to error messages.


Revision tags: uebayasi-xip-base1
# 1.52 09-Apr-2010 jakllsch

Improve error paths in (e)siop_scsipi_request():

- When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
- Correctly indicate which bus_dma_load() failed.

Analysis and fix from Michael L. Hitch in PR/42844.


# 1.51 11-Mar-2010 mrg

branches: 1.51.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9
# 1.50 12-Feb-2010 dholland

Make ESIOP_DEBUG compile (on some platforms? depends on bus definitions...)
From Chris Ross in PR 42792.


Revision tags: uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.49 19-Oct-2009 bouyer

branches: 1.49.2;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8
# 1.48 04-Sep-2009 tsutsui

Remove unnecessary whitespace.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4
# 1.47 16-May-2009 tsutsui

Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)


# 1.46 15-May-2009 tsutsui

Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.45 15-Mar-2009 cegger

ansify function definitions


# 1.44 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.43 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base yamt-nfs-mp-base yamt-pf42-base mjf-devfs2-base
# 1.42 08-Apr-2008 cegger

branches: 1.42.4; 1.42.12; 1.42.14; 1.42.18;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.41 19-Oct-2007 ad

branches: 1.41.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.40 30-Sep-2007 martin

branches: 1.40.2;
Do not stop callouts on polled commands. Problem noticed by Chris Ross
when trying to do a kernel dump on sparc64.
Approved by Manuel Bouyer.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.39 04-Mar-2007 christos

branches: 1.39.2; 1.39.14; 1.39.16; 1.39.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.38 02-Nov-2006 garbled

branches: 1.38.4;
Comment out the debug options to siop, and change the undef to define.
This way they will be compiled by the i386 DEBUG kernel and tested.


# 1.37 02-Nov-2006 garbled

Make these compile when SIOP_DEBUG is enabled, by nuking the reference to
t_offset, which no longer seems to exist.


Revision tags: yamt-splraiseipl-base2
# 1.36 29-Sep-2006 christos

Coverity CID 3015: Check before using (from Arnaud Lacombe)


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.35 24-Dec-2005 perry

branches: 1.35.20; 1.35.22;
__inline__ -> inline


Revision tags: yamt-readahead-base3 yamt-readahead-base2 ktrace-lwp-base
# 1.34 18-Nov-2005 bouyer

Some drives disconnect after the last data phase without a save data pointer
message. In such case we would not update resid with the proper value
(eventually resid would not be updated at all if there was only one data
phase). To fix this, have the script save the offset in the data tables at
disconnect time if there was a transfer, and use this to compute the resid
if the current offset is 0.
Problem reported and patch tested by edwin, Roy Bixler and YAMAMOTO Takashi.
Fix kern/31990 by YAMAMOTO Takashi.


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base yamt-km-base4 kent-audio2-base
# 1.33 23-Mar-2005 bouyer

branches: 1.33.2; 1.33.8;
Don't assume all LUNs are probed before scsipi sets the mode, and always check
if lun_tagtbl needs to be allocated. Patch from john heasley in kern/29603.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2
# 1.32 04-Feb-2005 perry

branches: 1.32.4;
de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.31 20-May-2004 bouyer

branches: 1.31.4; 1.31.6;
Rmove a redundant BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE, and fix
another one (POST -> PRE)


# 1.30 17-May-2004 bouyer

Add support for the Ignore Wide Residue SCSI message.


# 1.29 17-May-2004 bouyer

when an unexpected disconnect occurs only compute the resid; do the
real save data pointers when we get the message (or rather, at disconnect
time following the message).
Factor out code to do this, and to deal with xs->resid, in siop_common.c.


# 1.28 17-May-2004 bouyer

Properly compute xs->resid, instead of assuming it'll always be 0 when
a command is done.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.27 16-Mar-2004 bouyer

branches: 1.27.4;
cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.


# 1.26 15-Mar-2004 bouyer

Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.


# 1.25 10-Mar-2004 bouyer

The real value of the message is in msgin, not
esiop_cmd->cmd_tables->msg_in[0], so print the correct value.


# 1.24 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.23 29-Oct-2003 mycroft

XXX: gcc


# 1.22 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.21 04-Aug-2003 bouyer

Remove unused esiop_scsicmd() prototype.


# 1.20 03-Jul-2003 drochner

Avoid an obscure gcc3 complaint about
"dereferencing type-punned pointer" by a cast to "void *".
I don't completely understand the warning, but it helps.


# 1.19 03-May-2003 wiz

branches: 1.19.2;
DMA, not dma nor Dma.


# 1.18 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge kqueue-base gehenna-devsw-base
# 1.17 18-Jul-2002 wiz

Spell 'should' correctly.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.16 18-May-2002 bouyer

branches: 1.16.2; 1.16.4; 1.16.6;
Be more verbose when returning XS_DRIVER_STUFFUP


# 1.15 16-May-2002 thorpej

Don't access a scsipi channel's periph table directly; use
scsipi_lookup_periph().


# 1.14 04-May-2002 bouyer

branches: 1.14.2;
More debug printfs.


# 1.13 29-Apr-2002 bouyer

Add a missing esiop_script_sync(), and debug messages improvements.


# 1.12 27-Apr-2002 bouyer

Use a u_int32_t in script RAM instead of the SEM bit in ISTAT to pass flags
between script and driver. This allows more than one flag, and is easier to
manage (we almost can't read/write istat outside of the irq handler).


# 1.11 27-Apr-2002 bouyer

Implement a ring for the completed commands. This avoid a (problematic only
if error occurs after status is collected) race condition
when using the status byte to detect completed commands (a command descriptor
could be recycled before the device disconnected), and make the
interrupt routine handling completed commands more efficient (no need to
scan target * lun * tag array any more).


# 1.10 25-Apr-2002 bouyer

It's not safe to access the SCNTL1 register while the SCRIPT is running.
On the 1010 this can wedge the chip. So abort the script instead.
the abort interrupt will trigger a bus reset.


# 1.9 25-Apr-2002 bouyer

- We can't share the per-lun DSA entry for untagged and tag table DSA;
there may be tagged commands still running when we queue a request sense
command.
Solve this by using 2 DSA entry per LUN
- Now that we have the command DSA before select, we can load T/L/Q in
SCRATCHC. This makes the selection timeout handler simpler.
- Avoid a race condition when setting the free flag in the cmd ring (see
comment in the script)
- don't forget to update the ID in the head of LUN table after a sync/wide
negotiation. This fixes the command timeout at the first data command
after negotiation (the bus reset handler did update the ID properly,
so subsequent commands were OK).
- for DMA interrupts, clear fifo if it's not empty. Leaving the fifo dirty
would prevent subsequent interrupts from coming in.
- Various improvements in debug messages
- misc cleanups.


# 1.8 24-Apr-2002 bouyer

For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).


# 1.7 23-Apr-2002 bouyer

More copyright fixes, pointed out by Thomas. Thanks !


# 1.6 23-Apr-2002 bouyer

- factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.


# 1.5 23-Apr-2002 bouyer

Bump the space for SCSI messages from 8 to 16 octets, as 8 may not be
enouth for IDENTIFY + TAG + PPR.
Get rid of constants in C code by use of a offsetof macro.


# 1.4 23-Apr-2002 bouyer

Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.


# 1.3 22-Apr-2002 bouyer

Adapt for script "wait MSG_OUT after select" change: now, when we get
selection timeout, SCRATCHE points to the slot which triggered the timeout,
not the next one.


# 1.2 22-Apr-2002 bouyer

Add support for tagged queuing to esiop (256 tags per device).
For this add another indirecton: the DSA in the LUN table points to
a table of DSA indexed by the tag number when tagged command is in use.
For non tagged command, the LUN DSA still points to the tables describing the
xfer directly.


# 1.1 21-Apr-2002 bouyer

First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.