Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/mb89352.c
RevisionDateAuthorComments
 1.63  10-May-2023  riastradh spc(4): Use config_detach_children.
 1.62  28-Mar-2023  andvar s/interrput/interrupt/ and s/accesss/access/ in comments.
 1.61  01-Jan-2022  andvar fix typos in comments, mainly basicly -> basically.
 1.60  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.59  24-Apr-2021  thorpej branches: 1.59.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.58  06-Mar-2021  tsutsui branches: 1.58.2;
Fix a possible race condition in spc_msgin() in NO_MANUAL_XFER case.

To avoid the race, check SSTS and INTS after XFR command as
spc_pio_datain() does.

Reported from isaki@, observed on nono emulator.
 1.57  03-Sep-2018  riastradh branches: 1.57.4; 1.57.12;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.56  28-Oct-2017  riastradh branches: 1.56.2; 1.56.4;
Kill some more extern struct cfdriver declarations.

Down with externs in .c!
 1.55  11-Jan-2017  skrll adatper -> adapter
 1.54  04-Nov-2013  christos branches: 1.54.6; 1.54.10;
mark variables __diagused
 1.53  02-Dec-2011  tsutsui branches: 1.53.8; 1.53.12;
Define NO_MANUAL_XFER on luna68k as temporary workaround for hangup problem
during probing old drives like DK312C in OMRON LUNA machines.

I'll check this MSGIN xfer problem later.
(NO_MANUAL_XFER also caused hang on heavy load on hp300 with multiple drives)
 1.52  27-Jul-2010  jakllsch branches: 1.52.8;
printf() size_t with 'z' format modifier in debug code.
 1.51  23-Nov-2009  rmind branches: 1.51.2; 1.51.4;
Remove some unecessary includes sys/user.h header.
 1.50  12-Nov-2009  dyoung Remove superfluous activation hook.

Add a child-detachment hook.
 1.49  12-Jun-2008  cegger use device_lookup_private to get softc
 1.48  04-May-2008  martin branches: 1.48.2; 1.48.4;
Move to standard TNF 2 clause license
 1.47  31-Mar-2008  tsutsui branches: 1.47.2; 1.47.4;
Split softc/device_t for spc(4) and misc related cleanup.
 1.46  19-Oct-2007  ad branches: 1.46.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.45  16-Nov-2006  christos branches: 1.45.8; 1.45.22; 1.45.24; 1.45.28;
__unused removal on arguments; approved by core.
 1.44  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43  04-Oct-2006  christos fix empty if
 1.42  02-Sep-2006  xtraeme branches: 1.42.2; 1.42.4;
Remove unused variable to make this build again.
 1.41  02-Sep-2006  christos comment out impossible code
 1.40  24-Dec-2005  perry branches: 1.40.4; 1.40.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.39  11-Dec-2005  christos merge ktrace-lwp.
 1.38  02-Jan-2005  tsutsui branches: 1.38.10;
u_intNN_t -> uintNN_t
 1.37  25-Sep-2004  tsutsui Use ANSI function decls.
 1.36  25-Sep-2004  tsutsui Sprinkle DELAY(1)'s in several busy loops to avoid excessive bus access.
Inspired by OpenBSD.
 1.35  25-Sep-2004  tsutsui On manual xfer via TEMP register, set PCTL_BFINT_ENAB and check
bus free by INTS register. spc_intr() also checks the INTS_DISCON bit.
 1.34  25-Sep-2004  tsutsui In spc_intr(), return 0 if the interrupt is not for spc(4).
 1.33  25-Sep-2004  tsutsui Use manual xfer via TEMP register in status phase even on x68k.
Some devices do not transfer data with proper way on status phase
and it causes bus error in spc_datain_pio() which uses auto xfer
via DREG register on weird x68k hardware.
 1.32  12-Aug-2004  mycroft Close a race condition in the datain loop. If we receive another byte between
reading the FIFO status and reading the interrupt status, we could end up
leaving it in the FIFO. Force another round through the loop after reading the
interrupt status until the FIFO reads empty again.

Also, there is no point in having the extra loop to wait for the transfer
command to the controller to be acknowledged, because the transfer loop handles
that just fine -- and getting rid of it fixes another race condition.
 1.31  11-Aug-2004  mycroft Correct the overrun loop while I'm at it.
 1.30  11-Aug-2004  mycroft Recode the datain_pio loop. This improves performance substantially (almost
2x) with my spc@pcmcia.
 1.29  09-Aug-2004  mycroft Add detach support for spc@pcmcia, modeled after aic@pcmcia.
 1.28  07-Aug-2004  mycroft Fix a printf() format for Alpha.
 1.27  07-Aug-2004  tsutsui On manual transfer via TEMP register, data should be read
before asserting ACK.
 1.26  06-Jan-2004  tsutsui branches: 1.26.2;
Fix bus error trap on X68030/25MHz on-board SPC, which may have some quirk.
Problem reported by Yasushi Oshima.
 1.25  02-Nov-2003  wiz Fix some typos. From Tom Cosgrove via jmc@openbsd.
 1.24  07-Sep-2003  isaki Delete strange ifdef x68k.
Requested by tsutsui@
 1.23  29-Aug-2003  isaki Delete unnecessary #ifndef for x68k.
approved by tsutsui@
 1.22  01-Aug-2003  tsutsui - Add hooks for MD DMA transfers.
- Prepare ADAPTER_REQ_SET_XFER_MODE function.
(currently sync xfer is not supported)
 1.21  27-Jul-2003  tsutsui There is a report that x68k SCSI no longer works after the previous changes.
It seems x68k SPC SCSI has several hardware quirks, so add some (a bit ugly)
#ifdefs for workaround. (XXX - needs revisiting)
 1.20  05-Jul-2003  tsutsui More misc fixes for forthcoming hp300 MI SCSI support:
- Don't use SCMD_XFR command in message-in phase and status phase.
It causes unexpected hangs on heavy load. Instead transfer data
manually via TEMP register by SCMD_SET_ACK and SCMD_RST_ACK.
- Don't set SCMD_ICPT_XFR in spc_dataout_pio() and spc_msgout().
- Rewrite spc_datain_pio() to handle FIFO more properly.
 1.19  05-Jul-2003  tsutsui Misc cleanup:
- disable debug code by default
- use MI minphys()
- add proper delay in spc_find()
- initialize TMOD register in spc_reset()
- wrap a sanity check with #ifdef DIAGNOSTIC (sync with aic6360.c)
- no need to set LUN bits in SCSI command which should be done in mid-layer
- set proper resid even in error case
- fix/remove some bogus comments
 1.18  05-Jul-2003  tsutsui Use bus_space_{read,write}_multi_1() for PIO data transfers.
 1.17  05-Jul-2003  tsutsui Rename some MI mb89352 functions for consistency:
spcintr() -> spc_intr()
spcattach() -> spc_attach()
 1.16  05-Jul-2003  tsutsui Some cosmetics:
- Remove useless macro.
- Remove ^L characters.
- KNF a comment.
 1.15  19-May-2003  tsutsui branches: 1.15.2;
Misc cosmetics:
- some KNF and wrap long lines
- use TAILQ macro
- replace some magic numbers with macro
- use #if 0/#endif pair to disable code
 1.14  21-Feb-2003  tsutsui hz -> Hz
 1.13  30-May-2002  thorpej Statements must follow labels.
 1.12  05-Apr-2002  bouyer branches: 1.12.2;
Implement mstohz() as discussed on tech-kern, and use it in SCSI drivers
to convert xs->timeout to callout() parameter.
 1.11  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.10  13-Nov-2001  lukem add/cleanup RCSID
 1.9  04-Nov-2001  tsutsui Use common macro to check message length.
 1.8  07-Jul-2001  thorpej branches: 1.8.2; 1.8.6;
bzero -> memset
 1.7  07-Jul-2001  thorpej bcopy -> memcpy
 1.6  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.5  23-Mar-2000  thorpej branches: 1.5.6;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.4  30-Sep-1999  thorpej branches: 1.4.2;
Update for SCSPI changes.
 1.3  14-Mar-1999  minoura Some x68k conditionals (I don't know why these are needed...).
 1.2  19-Feb-1999  minoura Translated Japanese comments.
 1.1  13-Feb-1999  minoura MI version of the Fujitsu MB89352 SCSI Protocol Controler (SPC) driver.
Based on experimental NetBSD/pc98 ISA/PISA version, which was derived
from the MD /sys/arch/x68k/dev/spc.c.
 1.4.2.3  27-Mar-2001  bouyer Convert these drivers to thorpej_scsipi (untested).
 1.4.2.2  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.
 1.4.2.1  19-Oct-1999  thorpej Don't sleep waiting for a CCB; if we get to the CCB allocation phase, we're
guaranteed to have one.
 1.5.6.6  20-Jun-2002  nathanw Catch up to -current.
 1.5.6.5  17-Apr-2002  nathanw Catch up to -current.
 1.5.6.4  08-Jan-2002  nathanw Catch up to -current.
 1.5.6.3  14-Nov-2001  nathanw Catch up to -current.
 1.5.6.2  24-Aug-2001  nathanw Catch up with -current.
 1.5.6.1  21-Jun-2001  nathanw Catch up to -current.
 1.8.6.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.8.2.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.1  20-Jun-2002  gehenna catch up with -current.
 1.15.2.6  17-Jan-2005  skrll Sync with HEAD.
 1.15.2.5  19-Oct-2004  skrll Sync with HEAD
 1.15.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.15.2.2  12-Aug-2004  skrll Sync with HEAD.
 1.15.2.1  03-Aug-2004  skrll Sync with HEAD
 1.26.2.1  12-Aug-2004  jmc Pullup rev 1.27 (requested by tsutsui in ticket #747)

On manual transfer via TEMP register, data should be read before asserting ACK.
 1.38.10.3  27-Oct-2007  yamt sync with head.
 1.38.10.2  30-Dec-2006  yamt sync with head.
 1.38.10.1  21-Jun-2006  yamt sync with head.
 1.40.8.1  03-Sep-2006  yamt sync with head.
 1.40.4.1  09-Sep-2006  rpaulo sync with head
 1.42.4.2  10-Dec-2006  yamt sync with head.
 1.42.4.1  22-Oct-2006  yamt sync with head
 1.42.2.1  18-Nov-2006  ad Sync with head.
 1.45.28.1  25-Oct-2007  bouyer Sync with HEAD.
 1.45.24.1  06-Nov-2007  matt sync with HEAD
 1.45.22.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.45.8.1  23-Oct-2007  ad Sync with head.
 1.46.16.3  29-Jun-2008  mjf Sync with HEAD.
 1.46.16.2  02-Jun-2008  mjf Sync with HEAD.
 1.46.16.1  03-Apr-2008  mjf Sync with HEAD.
 1.47.4.4  11-Aug-2010  yamt sync with head.
 1.47.4.3  11-Mar-2010  yamt sync with head
 1.47.4.2  04-May-2009  yamt sync with head.
 1.47.4.1  16-May-2008  yamt sync with head.
 1.47.2.2  17-Jun-2008  yamt sync with head.
 1.47.2.1  18-May-2008  yamt sync with head.
 1.48.4.1  18-Jun-2008  simonb Sync with head.
 1.48.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.4.1  05-Mar-2011  rmind sync with head
 1.51.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.52.8.2  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.52.8.1  17-Apr-2012  yamt sync with head
 1.53.12.1  18-May-2014  rmind sync with head
 1.53.8.2  03-Dec-2017  jdolecek update from HEAD
 1.53.8.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.10.1  20-Mar-2017  pgoyette Sync with HEAD
 1.54.6.1  05-Feb-2017  skrll Sync with HEAD
 1.56.4.1  10-Jun-2019  christos Sync with HEAD
 1.56.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.57.12.1  03-Apr-2021  thorpej Sync with HEAD.
 1.57.4.1  09-Mar-2021  martin Pull up following revision(s) (requested by tsutsui in ticket #1228):

sys/dev/ic/mb89352.c: revision 1.58

Fix a possible race condition in spc_msgin() in NO_MANUAL_XFER case.

To avoid the race, check SSTS and INTS after XFR command as
spc_pio_datain() does.

Reported from isaki@, observed on nono emulator.
 1.58.2.1  21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.59.8.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed