Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/atapiconf.c
RevisionDateAuthorComments
 1.95  09-Apr-2022  riastradh sys: Use membar_release/acquire around reference drop.

This just goes through my recent reference count membar audit and
changes membar_exit to membar_release and membar_enter to
membar_acquire -- this should make everything cheaper on most CPUs
without hurting correctness, because membar_acquire is generally
cheaper than membar_enter.
 1.94  12-Mar-2022  riastradh sys: Membar audit around reference count releases.

If two threads are using an object that is freed when the reference
count goes to zero, we need to ensure that all memory operations
related to the object happen before freeing the object.

Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one
thread takes responsibility for freeing, but it's not enough to
ensure that the other thread's memory operations happen before the
freeing.

Consider:

Thread A Thread B
obj->foo = 42; obj->baz = 73;
mumble(&obj->bar); grumble(&obj->quux);
/* membar_exit(); */ /* membar_exit(); */
atomic_dec -- not last atomic_dec -- last
/* membar_enter(); */
KASSERT(invariant(obj->foo,
obj->bar));
free_stuff(obj);

The memory barriers ensure that

obj->foo = 42;
mumble(&obj->bar);

in thread A happens before

KASSERT(invariant(obj->foo, obj->bar));
free_stuff(obj);

in thread B. Without them, this ordering is not guaranteed.

So in general it is necessary to do

membar_exit();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_enter();

to release a reference, for the `last one out hit the lights' style
of reference counting. (This is in contrast to the style where one
thread blocks new references and then waits under a lock for existing
ones to drain with a condvar -- no membar needed thanks to mutex(9).)

I searched for atomic_dec to find all these. Obviously we ought to
have a better abstraction for this because there's so much copypasta.
This is a stop-gap measure to fix actual bugs until we have that. It
would be nice if an abstraction could gracefully handle the different
styles of reference counting in use -- some years ago I drafted an
API for this, but making it cover everything got a little out of hand
(particularly with struct vnode::v_usecount) and I ended up setting
it aside to work on psref/localcount instead for better scalability.

I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I
only put it on things that look performance-critical on 5sec review.
We should really adopt membar_enter_preatomic/membar_exit_postatomic
or something (except they are applicable only to atomic r/m/w, not to
atomic_load/store_*, making the naming annoying) and get rid of all
the ifdefs.
 1.93  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.92  24-Apr-2021  thorpej branches: 1.92.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?).
 1.91  17-Jun-2017  mlelstv branches: 1.91.22;
The atapibus detach path did hold the channel mutex while calling into autoconf,
which would trigger a panic when unplugging a USB ATAPI CDROM.

Align detach code for scsibus and atapibus to fix this.

Also avoid races when detaching devices by replacing callout_stop with
callout_halt.
 1.90  29-Nov-2016  mlelstv branches: 1.90.8;
reference count adapter mutex possibly shared by multiple channels.

fix error in atapibusdetach, when a child device cannot be detached,
keep atapibus instance alive.
 1.89  20-Nov-2016  mlelstv Make scsipi framework MPSAFE.

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

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

TODO: refactor sd and cd to use dksubr.
 1.88  13-Mar-2016  tsutsui branches: 1.88.2;
Sync with scsiconf.c. (use aprint_normal(9) for "not configured")
 1.87  05-Mar-2014  skrll branches: 1.87.6;
Don't probe beyond chan_ntargets in atapi_probe_bus in the "all" case.

PR/48626: ahci_atapi_probe_device panic with kmemguard
 1.86  24-Jun-2012  riastradh branches: 1.86.2; 1.86.4;
Take the kernel lock in atapibusdetach just like atapibuschilddet.

Fixes kassert in scsipi_lookup_periph when I press the power button
on one of my laptops (and maybe another one) to power it off.

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

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

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

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
 1.84  06-Apr-2012  chs take the kernel lock during detach of atapibus as well.
 1.83  07-Jun-2010  pgoyette branches: 1.83.8; 1.83.12; 1.83.14;
Update scsiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.82  30-May-2010  pgoyette Extract SCSIVERBOSE into a kernel module. The module can be builtin
by defining 'options SCSIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

The module is built for all architectures, whether or not SCSI or
atapi support exists.
 1.81  12-Nov-2009  dyoung Remove superfluous activation hooks.
 1.80  19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.79  12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.78  07-Apr-2009  dyoung Detach atapibus(4), scsibus(4), cd(4), and sd(4) during shutdown.
Destroy sd->sc_callout in sddetach(). Delete some dead code in
cddetach().
 1.77  24-Mar-2008  cube branches: 1.77.4; 1.77.12; 1.77.18;
Split device_t and softc for atapibus(4).
 1.76  08-Mar-2008  yamt fix a double-free bug introduced by the following change. PR/38179.

revision 1.75
date: 2008/01/29 17:26:57; author: dyoung; state: Exp; lines: +34 -15
Use device_t. Add a handler for child detachment. Now I can detach
cd0 at atapibus0 without getting a panic when atapibus0 detaches,
later.
 1.75  29-Jan-2008  dyoung branches: 1.75.2; 1.75.6;
Use device_t. Add a handler for child detachment. Now I can detach
cd0 at atapibus0 without getting a panic when atapibus0 detaches,
later.
 1.74  09-Dec-2007  jmcneill Merge jmcneill-pm branch.
 1.73  01-Dec-2007  jmcneill branches: 1.73.2; 1.73.4;
aprintify
 1.72  16-Nov-2006  christos branches: 1.72.22; 1.72.24; 1.72.30;
__unused removal on arguments; approved by core.
 1.71  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.70  30-Mar-2006  thorpej branches: 1.70.8; 1.70.10;
Use device_private().
 1.69  11-Dec-2005  christos branches: 1.69.4; 1.69.6; 1.69.8; 1.69.10; 1.69.12;
merge ktrace-lwp.
 1.68  26-Aug-2005  drochner s/locdesc_t/int/g
 1.67  29-May-2005  christos branches: 1.67.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
 1.66  13-Sep-2004  drochner a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.65  21-Aug-2004  thorpej Const poison scsipi_dtype().
 1.64  21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.63  17-Oct-2003  mycroft Remove the Fuji quirk from here, too.
 1.62  08-Oct-2003  bouyer Make the ATA mid-layer appears as atabus, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0006.html
This adds a device (atabus) between IDE controllers and wd or atapibus, to
have each ATA channel show up in the device tree. Later there will be atabus
devices in /dev, so that we can do IOCTL on them.
Each atabus has its own kernel thread, to handle operations that needs polling,
e.g. reset and others.

Device probing on each bus it defered to the atabus thread creation.
This allows to do the reset and basic device probes in parallel, which reduce
boot time on systems with several pciide controllers.
 1.61  18-Sep-2003  mycroft Merge the geometry and cache handling code for all direct access and optical
devices, as it's general to all SCSI MMC devices. In the process, remove
PQUIRK_NO_FLEX_PAGE.
 1.60  17-Sep-2003  mycroft Remove PQUIRK_BYTE5_ZERO.
 1.59  09-Sep-2003  mycroft Exorcise PQUIRK_NODOORLOCK.
 1.58  08-Sep-2003  mycroft Do a START UNIT only if the TEST UNIT READY reports that the device is not
ready. This avoids gratuitously starting the motor on floppy and CD-ROM
drives, and eliminates the need for the audio playing test in cdopen().

Therefore, also remove PQUIRK_NOSTARTUNIT.
 1.57  03-Apr-2003  erh branches: 1.57.2;
Add a quirk to allow my NEO Jukebox to work again.
 1.56  19-Feb-2003  hannken Add PQUIRK_NO_FLEX_PAGE for Fujitsu MO MCJ3230AP.
This drive returns bogus geometry (0 heads, 0 sectors).
 1.55  01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.54  04-Oct-2002  soren As in scsiconf.c, don't print the numberic device type in the attach message.
 1.53  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.52  30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.51  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.50  27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.49  19-Sep-2002  jmc Force the initial probes to happen within the newly forked off kthread.
This eliminates problems where the underlying interrupt handler isn't the
specific layer calling scsipi_complete() for a given scsi transaction.
This avoids deadlocks where the kthread that called the autoconf routines
to configure a scsibus shouldn't be the one put to sleep waiting on a
scsipi_complete (only the scsibus's kthread should be doing that).

To avoid jitter this will force the scsibus's to probe in the order they
run through autoconf (so machines with multiple bus's don't move sd* devices
around on every reboot).
 1.48  01-Apr-2002  bouyer Add a chan_name to struct scsipi_channel, holding the channel's name.
Set this to dv_xname for scsibus and atapibus.
Set the name of the kernel thread to chan_name instead of controller's
name:channel number (so that we can use this name for controller-specific
threads).
 1.47  22-Dec-2001  gehenna The FujiFilm USB storage drive doesn't have a flex geom page and
doesn't know REQUEST SENSE.
 1.46  03-Dec-2001  bouyer Update my copyrigth.
 1.45  02-Dec-2001  bouyer No need to include atavar.h here.
 1.44  02-Dec-2001  bouyer Clean up attach of wd/atapibus:
kill ata_atapi_attach. Change atapibus to use a struct scsipi_channel instead
of ata_atapi_attach as attach arch. Create a ata_device, compatible with
scsipi_channel, to attach wd.
 1.43  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.42  13-Nov-2001  lukem add RCSIDs
 1.41  13-Sep-2001  enami Pass the correct pointer to atapibusprint().
 1.40  14-May-2001  bouyer branches: 1.40.2; 1.40.4;
Use SCSI/ATAPI common definition for MODE_{SELECT,SENSE}{,_BIG}. Define
functions to send theses commands in scsipi_base.c and use them instead
of ad-hoc commands setups.
 1.39  25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.38  01-Apr-2001  augustss The ZiO! MMC adapter doesn't have a flex geometry page.
 1.37  20-Mar-2001  augustss Add quirks for Panasonic MultiMediaCard adapter (attaches via USB).
 1.36  18-Jan-2001  jdolecek branches: 1.36.2;
constify
 1.35  02-Apr-2000  augustss Let the device thet gets an atapibus attached specify how to kill pending
transfers by giving a function pointer.
The old method always called wdc specific code.
 1.34  01-Apr-2000  bouyer - DMA code cleanup: pciide_dma_finish() doesn't stop/unload the current DMA op
if an IRQ was not detected, unless the force flag was given. Use this to
detect if the IRQ was for us (closer to shared IRQ for controllers which
don't have their own IRQ handler in pciide.c) and to poll for DMA xfer.
Also makes the timeout recovery code simpler.
- ATAPI cleanup: don't call controller-specific functions from atapiconf.c
(wdc_*), so that it's possible to attach an atapibus to something else
than a wdc/pciide (Hi Lennart :).
Overload struct scsi_adapter with struct atapi_adapter, defined
as struct scsi_adapter + atapi-specific callbacks. scsipi_link still points
to an scsi_adapter, atapi code casts it to atapi_adapter if needed.
Move atapi_softc to atapiconf.h so that it can be used by the underlying
controller code (e.g. atapi_wdc.c).
Add an atapi-specific callback *atapi_probedev(), which probe a drive
in a controller-specific way, allocate the sc_link and fills in the
ataparams if needed. It then calls atapi_probedev() (from atapiconf.c)
to do the generic initialisations and attach the device.
- While I'm there merge and centralise the state definitions in atavar.h.
It should now be possible to use a common ata/atapi routine to set the
drive's modes (will do later).
 1.33  28-Mar-2000  augustss Change a printf() to a panic() since the kernel is going to die on the next
line anyway.
 1.32  17-Mar-2000  soren atapiprint() does not exist.
 1.31  28-Feb-2000  jdolecek Add ADEV_NOSENSE quirk for HITACHI CDR-7730.

Patch sent by Hume Smith in kern/9489.
 1.30  20-Jan-2000  mjacob Nobody said no to adding a pointer to original scsi inquiry data
to the scsibus attach args. Make sure it's nulled for ATAPI. Also,
for scsiconf.c, modify SENA's quirk entry.
 1.29  20-Oct-1999  enami Cancel active transfers on aic/wdc detach.
Also makes LS-120 drive works for me again.
 1.28  30-Sep-1999  thorpej branches: 1.28.2; 1.28.4; 1.28.6;
Cleanup the scsipi_xfer flags:
- `flags' is now gone, replaced with `xs_control' and `xs_status'.
- Massive cleanup of the control flags. Now we explicitly say that
a job is to complete asynchronously, rather than relying on side-effects,
and use a new flag to now that device discovery is being performed.
- Do SCSI device discovery interrupt-driven.
 1.27  23-Sep-1999  enami Allow to detach wdc, atapibus, wd and cd.
 1.26  08-Jul-1999  bouyer Add another CD to the quirk table.
 1.25  15-Feb-1999  bouyer branches: 1.25.2; 1.25.4; 1.25.6;
Revert to 1.23, this was not supposed to be checked in yet.
 1.24  15-Feb-1999  bouyer For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.
 1.23  26-Jan-1999  bouyer Another CD drive that doesn't support REQUEST SENSE, from Patrick Welche.
 1.22  21-Jan-1999  bouyer Add a mitsumi CD that can't handle REQUEST SENSE command. From
Johan Danielsson <joda@pdc.kth.se>.
 1.21  19-Jan-1999  bouyer Move test for SDEV_NOSTARTUNIT quirk from sd.c to scsipi_start().
Add a SDEV_NOSTARTUNIT quirk entry for BCD-16X 1997-04-25", "", "VER 2.2"
CD-rom (from Michael Santos).
 1.20  19-Jan-1999  bouyer "Memorex CRW-2642" CD-R can't properly handle REQUEST SENSE command.
Add it to the quick table, per PR kern/6844.
 1.19  21-Dec-1998  leo Change quirk entry: "FX320S", "", " q01" to: "FX320S", "", "q01". This
space does seem to matter...
 1.18  17-Dec-1998  bouyer Add a new quirk flags, "ADEV_NOSENSE", for devices that don't
handle properly the request sense command. Add <FX320S, , q01> as being
sense-unfriendly in the quirk table.
 1.17  16-Dec-1998  bouyer Leave some room for the string-terminating char in temp. buffers.
Pointed out by Scott Presnell (thanks !).
 1.16  08-Dec-1998  thorpej When allocating a device's scsipi_link, initialize the pending_xfers
queue.
 1.15  19-Nov-1998  thorpej Add a reference to the adapter before probing the bus, and delete it
once we are done probing.
 1.14  13-Oct-1998  enami Make this file compile again with -DATAPI_DEBUG_PROBE.
 1.13  12-Oct-1998  bouyer Merge bouyer-ide
 1.12  31-Aug-1998  cgd kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port
used it, and it's non-working and apparently slated for replacement.)
 1.11  05-Aug-1998  drochner Improve generation of default disklabels:
-store printable product ID in cd's and sd's softc, use it as "typename"
-for this, add a "destination buffer length" argument to scsipi_strvis()
-return ATAPI device type for ATAPI devices
 1.10  31-Jul-1998  thorpej Use the pool allocator for scsipi_xfer structures.
 1.9  15-Jan-1998  cgd branches: 1.9.2; 1.9.4;
add support for an ATAPI attachment for 'sd'.
fix 'cd' driver's NCD_SCSI bogosity (was using testing wrong macro!)
clean up in various ways:
* make common atapi_mode_{sense,select}() functions.
* put ATAPI data structures in more sensible headers, split up by
device type.
* include headers a bit more carefully.
* pass flags to attachment-specific cd functions, and use them.
* get rid of SCSI bits in scsipi_base.h's scsipi_make_xs(), move
them into the correct place in scsi_base.c.
* fix minor typo in struct name in scsipiconf.h (which was apparently
never used except in a #define later in the same file).
* use __attribute__ to force 4-byte alignment for xs command store,
so that architectures trying to bus_space_write_multi_N() (where
N > 1) that data to a controller won't lose.
* clean up a few comments in typos, and make a few #defines easier to
understand/maintain.
* rename cd_link.h to cdvar.h (via repository copy). This is exactly
what a 'var' file is supposed to be.
 1.8  12-Jan-1998  thorpej Adjust for changes to config.
 1.7  06-Jan-1998  bouyer Add a few quirk entries from OpenBSD.
 1.6  05-Nov-1997  bouyer Add a quirk for a sanyo CD (From OpenBSD).
 1.5  31-Oct-1997  bouyer Add NOCAPACITY quirk entry for MATSHITA CR-574, rev 1.02.
 1.4  01-Oct-1997  enami branches: 1.4.2;
Cosmetic changes to keep coding style consistency in this directory;

- Indent with tab of width 8.
- Use four column to indent continuation line.
- Fold long line if possible.
- Use return (xx) instead of return xx.
- Compare pointer against NULL instead of testing like boolean.
- Delete whitespace at the end of line.
- Delete whitespace in front of function call operator.
- Delete whitespace after cast.
- Dereference a pointer to function explicitly.
- Add an empty line after local variable declaration.
- Use NULL instead of (char *)0.
- Dont use block for single statement.
 1.3  28-Aug-1997  bouyer Added a quirk entry for the SANYO CRD-254P (from OpenBSD), and
one for the MATSHITA CR-574 (from Josef Wulf <wulf@ping.net.au> via OpenBSD).
 1.2  27-Aug-1997  bouyer branches: 1.2.2;
Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.1  01-Jul-1997  bouyer branches: 1.1.2;
file atapiconf.c was initially added on branch bouyer-scsipi.
 1.1.2.3  17-Jul-1997  bouyer Use "locator.h".
 1.1.2.2  01-Jul-1997  thorpej Purely cosmetic formatting changes: spaces -> tabs in a few places, and
a general KNF sweep.
 1.1.2.1  01-Jul-1997  bouyer New merged scsi/atapi code. Tested on i386 and sparc. Commiting to a branch
for now, so that it can be tested on other ports too.
The config sheme is as follow:
New merged scsi/atapi code. Tested on i386 and sparc. Commiting to a branch
for now, so that it can be tested on other ports too.
The config sheme is as follow:
scsibus at aha
sd at scsibus
cd at scsibus
atapibus at wdc
cd at atapibus
cd has bus-specific config and function front-end in scsicd.c and atapicd.c
The call to theses functions from cd.c is conditionned to
NSCSICD and NATAPICD (all defined in cd.h by config).
 1.2.2.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.3  01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1  27-Aug-1997  thorpej file atapiconf.c was added on branch marc-pcmcia on 1997-08-27 23:32:56 +0000
 1.4.2.3  05-Feb-1999  cgd pull up rev 1.7 from trunk (bouyer)
 1.4.2.2  06-Nov-1997  mellon Pull rev 1.6 up from trunk (bouyer)
 1.4.2.1  31-Oct-1997  mellon Pull rev 1.5 up from trunk (bouyer)
 1.9.4.1  08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.9.2.4  20-Sep-1998  bouyer Remove a stale 'XXX'.
 1.9.2.3  11-Sep-1998  bouyer Sync with HEAD.
 1.9.2.2  13-Aug-1998  bouyer - sync with HEAD
- better error detection and report for wd drives
- better wddump() support
- wdcwait() now takes a timout argument, so that we can honnor the
timeout argument of scsipi cmds.
 1.9.2.1  04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.25.6.1  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.25.4.1  02-Aug-1999  thorpej Update from trunk.
 1.25.2.2  14-Dec-2000  he Pull up revision 1.31 (requested by bouyer):
Add a quirk entry for Hitachi CDR-7730. Fixes PR#11654.
 1.25.2.1  08-Jul-1999  perry pullup 1.25->1.26 (bouyer); last minute but it looked okay
 1.28.6.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.28.4.1  15-Nov-1999  fvdl Sync with -current
 1.28.2.10  21-Apr-2001  bouyer Sync with HEAD
 1.28.2.9  27-Mar-2001  bouyer Sync with HEAD.
 1.28.2.8  18-Feb-2001  bouyer Move atapiprint() to ic/wdc.c so that we can compile a kernel with IDE
controller but without atapibus.
 1.28.2.7  11-Feb-2001  bouyer Sync with HEAD.
 1.28.2.6  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.

Main changes to the scsipi code itself:
- add a scsipi_channel->type to allow umass to attach to both atapibus and
scsibus. Will die when IDE is converted from ata_atapi_attach to
scsipi_channel/scsipi_adapter
- Add a chan_defquirks to scsipi_channel so that adapters can pass a default
set of quirks to be set for each device attached
- add adapt_getgeom and adapt_accesschk callbacks
 1.28.2.5  04-Feb-2000  thorpej Make sure the channel's completion thread exits when the channel
is detached, and completely encapsulate the way periph's are stored
by the channel.
 1.28.2.4  01-Nov-1999  thorpej Fixup the SC_DEBUG() stuff for the new world order.
 1.28.2.3  20-Oct-1999  thorpej Sync w/ trunk.
 1.28.2.2  20-Oct-1999  enami Fix compilation error when ATAPI_DEBUG_PROBE is defined.
 1.28.2.1  19-Oct-1999  thorpej Completely rewritten scsipi_xfer execution engine:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).

There is a lot more work to do, but this correctly functions for the most
part on several file servers I run.
 1.36.2.8  03-Jan-2003  thorpej Sync with HEAD.
 1.36.2.7  18-Oct-2002  nathanw Catch up to -current.
 1.36.2.6  17-Apr-2002  nathanw Catch up to -current.
 1.36.2.5  08-Jan-2002  nathanw Catch up to -current.
 1.36.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.36.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.36.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.36.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.40.4.1  01-Oct-2001  fvdl Catch up with -current.
 1.40.2.3  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.40.2.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.40.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.57.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.57.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.57.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.57.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.57.2.1  03-Aug-2004  skrll Sync with HEAD
 1.67.2.6  17-Mar-2008  yamt sync with head.
 1.67.2.5  04-Feb-2008  yamt sync with head.
 1.67.2.4  21-Jan-2008  yamt sync with head
 1.67.2.3  07-Dec-2007  yamt sync with head
 1.67.2.2  30-Dec-2006  yamt sync with head.
 1.67.2.1  21-Jun-2006  yamt sync with head.
 1.69.12.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.69.10.1  19-Apr-2006  elad sync with head.
 1.69.8.1  01-Apr-2006  yamt sync with head.
 1.69.6.1  22-Apr-2006  simonb Sync with head.
 1.69.4.1  09-Sep-2006  rpaulo sync with head
 1.70.10.2  10-Dec-2006  yamt sync with head.
 1.70.10.1  22-Oct-2006  yamt sync with head
 1.70.8.1  18-Nov-2006  ad Sync with head.
 1.72.30.3  18-Feb-2008  mjf Sync with HEAD.
 1.72.30.2  27-Dec-2007  mjf Sync with HEAD.
 1.72.30.1  08-Dec-2007  mjf Sync with HEAD.
 1.72.24.2  23-Mar-2008  matt sync with HEAD
 1.72.24.1  09-Jan-2008  matt sync with HEAD
 1.72.22.3  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.72.22.2  01-Dec-2007  jmcneill Sync with HEAD.
 1.72.22.1  12-Nov-2007  joerg Add null handlers for atapibus, it doesn't seem to need any magic.
 1.73.4.1  11-Dec-2007  yamt sync with head.
 1.73.2.1  26-Dec-2007  ad Sync with head.
 1.75.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.75.2.1  24-Mar-2008  keiichi sync with head.
 1.77.18.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.77.12.1  28-Apr-2009  skrll Sync with HEAD.
 1.77.4.3  11-Mar-2010  yamt sync with head
 1.77.4.2  16-May-2009  yamt sync with head
 1.77.4.1  04-May-2009  yamt sync with head.
 1.83.14.3  02-Jul-2012  jdc Pull up revision 1.86 (requested by riastradh in ticket #373).

Take the kernel lock in atapibusdetach just like atapibuschilddet.

Fixes kassert in scsipi_lookup_periph when I press the power button
on one of my laptops (and maybe another one) to power it off.

ok mrg
 1.83.14.2  23-Apr-2012  riz Pull up following revision(s) (requested by bouyer in ticket #192):
sys/dev/scsipi/cd.c: revision 1.307
sys/dev/scsipi/scsiconf.c: revision 1.266
sys/dev/scsipi/sd.c: revision 1.298
sys/dev/scsipi/st_scsi.c: revision 1.35
sys/dev/scsipi/atapiconf.c: revision 1.85
sys/dev/scsipi/scsipiconf.h: revision 1.120
sys/dev/usb/umass_scsipi.c: revision 1.44
sys/dev/scsipi/scsiconf.h: revision 1.57
sys/dev/scsipi/st_atapi.c: revision 1.29
sys/dev/scsipi/scsipi_base.c: revision 1.158
sys/dev/scsipi/st.c: revision 1.221
sys/dev/scsipi/scsipi_ioctl.c: revision 1.67
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
sync/wide parameters only make sense for parallel SCSI.
For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
tagged queing status if enabled. Just be silent for other
bustypes.
This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
appropriate parameters is enough to enable tagged queuing,
but then scsipi will print:
sd0: async, 8-bit transfers, tagged queueing
which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
but will confuse users. With this change scsipi will only print:
sd0: tagged queueing
which is correct.
In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.
Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
 1.83.14.1  09-Apr-2012  riz Pull up following revision(s) (requested by chs in ticket #166):
sys/dev/scsipi/atapiconf.c: revision 1.84
take the kernel lock during detach of atapibus as well.
 1.83.12.1  29-Apr-2012  mrg sync to latest -current.
 1.83.8.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.83.8.3  30-Oct-2012  yamt sync with head
 1.83.8.2  23-May-2012  yamt sync with head.
 1.83.8.1  17-Apr-2012  yamt sync with head
 1.86.4.1  18-May-2014  rmind sync with head
 1.86.2.2  03-Dec-2017  jdolecek update from HEAD
 1.86.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.87.6.3  28-Aug-2017  skrll Sync with HEAD
 1.87.6.2  05-Dec-2016  skrll Sync with HEAD
 1.87.6.1  19-Mar-2016  skrll Sync with HEAD
 1.88.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.90.8.1  21-Jun-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #53):
sys/dev/scsipi/atapiconf.c: revision 1.91
sys/dev/scsipi/cd.c: revision 1.341
sys/dev/scsipi/scsi_base.c: revision 1.92
sys/dev/scsipi/scsiconf.c: revision 1.280
sys/dev/scsipi/scsipi_base.c: revisions 1.176, 1.177
sys/dev/scsipi/sd.c: revision 1.325
sys/dev/scsipi/ss.c: revision 1.89
sys/dev/scsipi/st.c: revision 1.231
The atapibus detach path did hold the channel mutex while calling into autoconf,
which would trigger a panic when unplugging a USB ATAPI CDROM.
Align detach code for scsibus and atapibus to fix this.
Also avoid races when detaching devices by replacing callout_stop with
callout_halt.
--
pass config_detach error to caller.
 1.91.22.3  03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.91.22.2  21-Mar-2021  thorpej CFARG_IATTR usage audit:

If a device carries only one interface attribute, there is no need
to specify it when calling config_search(); that specification is
meant only to disambiguate which interface attribute (which is a
proxy for "what kind of attach args are being used") is having
children attached. cfparent_match() will take care of ensuring that
any potential children can attach to one of the parent's iterface
attributes, and if the parent only carries one, no disambiguation is
necessary.
 1.91.22.1  20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.92.8.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed