Commit Graph

263 Commits

Author SHA1 Message Date
Poul-Henning Kamp
da936bf80a Remove unneeded <stddef.h> #includes. 2000-10-29 16:57:42 +00:00
David Malone
5417ec4db1 Add the use of M_ZERO to some malloc calls.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
Approved by:	gibbs
2000-10-29 15:47:16 +00:00
Justin T. Gibbs
60754d0ba3 Bring back the ability to send cdbs of length 13->32 bytes. This was lost
during the qinfifo optimization.  When swapping HSCBs, we were only copying
the first 32 bytes, the amount used in the common case of a cdb <= 12 bytes.
Larger cdbs are stored in the second 32 bytes of the cdb.

Noticed by: Marc Frajola <marc@terasolutions.com>
2000-10-12 14:36:27 +00:00
Justin T. Gibbs
70351c9a14 Store a pointer to our softc in the kernel's SCB structure. In the
past we stored this data in the CCB and attained the CCB via a pointer
in the SCB.  In ahc_timeout(), however, the timedout SCB may have already
been completed (inherent race), meaning that the CCB could have been recycled,
and the ahc pointer reset.

Clean up the logic in ahc_search_qinfifo that deals with the busy device
table.  For some reason it assumed that the only valid time to search
to see if additional lun entries should be checked was if lun 0 matched.
Now we properly itterate through the necessary luns.  The busy device
table is used to detect invalid reselections, so a device would have had
to perform an unexpected reselection for this to cause problems.  Further,
all luns are collapsed to a single entry unless we have external ram
with large SCBs (3940AU models) so the chance of this happening was
rather remote.

Clean up the logic for dealing with the untagged queues.  We now set a
flag in the SCB that indicates that it is on the untagged queue instead
of inferring this from the type and setup of the CCB pased into us by
CAM.

In ahc_timeout(), don't print the path of the SCB until the controller
is paused and we are sure that it has not completed yet.  This, in
conjunction with referencing the ahc pointer in the SCB rather than
the CCB in the SCB avoids panics in the case of a timedout scb completing
just before the timeout handler runs.  This turns out to be guaranteed
if interrupt delivery is failing, as we run our interrupt handler to
flush any "just missed events" when a timeout occurs.  Mention the
likelyhood of broken interrupts if a timedout SCB is completed by
our call to ahc_intr().
2000-10-11 23:46:34 +00:00
Justin T. Gibbs
b00aeda6f0 Close a race condition that doesn't really exist in -current. When
a resource shortage occurs, freeze our queue and then set the resource
shortage flag while the controller data structure is locked.  The old
code did these in the wrong order potentially allowing our interrupt
handler to release the queue and clear the flag before the freeze
ever occurred.
2000-10-09 19:54:54 +00:00
Justin T. Gibbs
73f1c25915 Clean up error recovery code:
aic7xxx.c:
	In target mode, reset the TQINPOS on every restart of the sequencer.
	In the past we did this only during a bus reset, but there are other
	reasons the sequencer might be reset.

	In ahc_clear_critical_section(), disable pausing chip interrupts while
	we step the sequencer out of a critical section.  This avoids the
	possibility of getting a pausing interrupt (unexpected bus free,
	bus reset, etc.) that would prevent the sequencer from stepping.

	Send the correct async notifications in the case of a BDR or bus reset.

	In ahc_loadseq(), correct the calculation of our critical sections.
	In some cases, the sections would be larger than needed.

aic7xxx.h:
	Remove an unused SCB flag.

aic7xxx.seq:
	MK_MESSAGE is cleared by the kernel, there is no need to waste
	a sequencer instruction clearing it.

aic7xxx_freebsd.c:
	Go through the host message loop instead of issuing a single
	byte message directly in the ahc_timeout() case where we
	are currently on the bus to the device.  The effect is the same,
	but this way we get a nice printf saying that an expected BDR
	was delivered instead of an unexpected bus free.

	If we are requeuing an SCB for an error recovery action, be sure
	to set the DISCONNECTED flag in the in-core version of the SCB.
	This ensures that, in the SCB-paging case, the sequencer will
	still recognize the reselection as valid even if the version
	of the SCB with this flag set was never previously paged out
	to system memory.  In the non-paging case, set the MK_MESSAGE
	flag in SCB_CONTROL directly.

aic7xxx_pci.c:
	Enable the Memeory Write and Invalidate bug workaround for
	all aic7880 chips with revs < 1.  This bug is rarely triggered
	in FreeBSD as most transfers end on cache-aligned boundaries,
	but a recheck of my references indicates that these chips
	are affected.
2000-10-09 01:46:01 +00:00
Justin T. Gibbs
039c6f3637 Correct corruption of the qinfifo in ahc_search_qinififo() for all
non-LVD controllers.  We only need to take special action on the qinfifo
if we have dectected the case of an SCB that has been removed from the
qinfifo but has not been fully DMAed to the controller.  A missing
conditional caused this code to be executed every time an SCB was
aborted from the queue

Don't attempt to print the path of an SCB that has been freed.

Clean up the traversal of the pending scb list in
ahc_update_pending_syncrates().  This has no functional change.

Correct ahc_timeout()'s requeing of a timedout SCB to effect a
recovery action.  We now use ahc_qinfifo_requeue() and a
new function ahc_qinfifo_count() instead of performing the
requeue inline.  The old code did not conform to the new qinfifo
method.

Clear the timedout SCB from the disconnected list.  This ensures
that the SCB_NEXT field is free to be used for queuing us to
the qinfifo.
2000-10-08 03:37:52 +00:00
Justin T. Gibbs
580bfdfb00 Fix single character typo in legacy transfer settings function
thereby re-enable tagged queuing.
2000-10-06 19:34:40 +00:00
Justin T. Gibbs
ff0c1daf6b Bring in a slew of fixes that were supposed to be in the last commit.
In ahc_search_qinfifo, the SEARCH_REMOVE case must also handle
an SCB that has been removed from the QINFIFO but not yet been
fully dmaed to the card.

Correct locking for ahc_get_scb() calls.

Set SCB syncrate settings in ahc_execute_scb() to avoid a race
condition that could allow a newly queued SCB to be missed
by ahc_update_pending_syncrates().

When notifying the system of transfer negotiation updates, only
set the valid bits for tagged queuing and disconnection if the
path is fully qualified.  Sync/Wide settins apply to all luns
of a target, but tagged queuing and disconnection may change
on a per-lun basis.

Add missing ahc_unlock() calls in ahc_timeout() for the target
mode case.
2000-10-06 04:01:06 +00:00
Justin T. Gibbs
b1721cfbfd Correct pedantic errors in arrays generated by the assembler (trailing
comma in array declarations).

Output a constant indicating the number of critical section entries
in the firmware.
2000-10-05 04:25:42 +00:00
Justin T. Gibbs
a49630ac82 Convert the driver to use a single DMA for fetching new commands instead
of two (one to access the circular input fifo, the other to get the SCB).
This costs us a command slot so the driver can now only queue 254
simultaneous commands.

Have the kernel driver honor critical sections in sequencer code.

When prefetching S/G segments only pull a cacheline's worth but
never less than two elements.  This reduces the impact of the
prefetch on the main data transfer when compared to the 128
byte fetches the driver used to do.

Add "bootverbose" logging for transfer negotiations.

Correct a bug in ahc_set_syncrate() that would prevent an update
of the sync parameters if only the ppr_options had changed.

Correct locking for calls to ahc_free_scb().  ahc_free_scb() is no
longer protected internally to simplify ports to other platforms.

Make sure we unfreeze our SIMQ if a resource shortage has occurred
and an SCB is been freed.

ahc_pci.c:
	Turn on cacheline streaming for all controllers that support it.

	Clarify diagnostic messages about PCI interrupts.
2000-10-05 04:24:14 +00:00
Justin T. Gibbs
155c0683c7 ahc_set_transaction_status() takes an SCB. This makes it difficult to
use this helper function to report an error when SCB allocation fails.
2000-10-01 20:56:44 +00:00
Justin T. Gibbs
1c1c47a3e9 Correct a logic mistake introduced in a recent cleanup of
ahc_build_transfer_msg() that would cause use to fail to send the
DT_REQ ppr_option in a PPR message for periods where DT transfers
are required.
2000-09-25 21:56:19 +00:00
Justin T. Gibbs
083d01f20d Add Perforce RCSIDs for easy revision correlation to my local tree.
Add support for constructing a table of critical section regions in
the firmware image.  The kernel driver will soon have support for
single stepping the sequencer outside of a critical region prior
to starting exception handling.
2000-09-22 22:19:55 +00:00
Justin T. Gibbs
c498406d58 Add Perforce RCSIDs for easy revision correlation to my local tree.
ahc_pci.c:
	Bring back the AHC_ALLOW_MEMIO option at least until the
	memory mapped I/O problem on the SuperMicro 370DR3 is
	better understood.

aic7xxx.c:
	If we see a spurious SCSI interrupt, attempt to clear it and
	continue by unpausing the sequencer.

	Change the interface to ahc_send_async().  Some async messages
	need to be broadcast to all the luns of a target or all the
	targets of a bus.  This is easier to achieve by passing explicit
	channel, target, and lun parameters instead of attempting to
	construct a device info struct to match.

	Filter the sync parameters for the PPR message in exactly the
	same way we do for an old fashioned SDTR message.

	Correct some typos and correct a panic message.

	Handle rejected PPR messages.

	In ahc_handle_msg_reject(), let ahc_build_transfer_msg() build
	any additional transfer messages instead of doing this inline.

aic7xxx.h:
	Increase the size of both msgout_buf and msgin_buf to
	better accomodate PPR messages.

aic7xxx_freebsd.c:
	Update for change in ahc_send_async() parameters.

aic7xxx_freebsd.h
	Update for change in ahc_send_async() parameters.

	Honor AHC_ALLOW_MEMIO.

aic7xxx_pci.c:
	Check the error register before going into full blown PCI
	interrupt handling.  This avoids a few costly PCI configuration
	space reads when we run our PCI interrupt handler because another
	device sharing our interrupt line is more active than we are.

	Also unpause the sequencer after processing a PCI interrupt.
2000-09-22 22:18:05 +00:00
Justin T. Gibbs
ea6487b395 Use quoted includes instead of full path references inside the aic7xxx
sequencer files.  Different platforms place the included files in different
locations and it is easier to modify the include path passed as arguments
to the assembler than adding #ifdef support to the assembler.

Remove a spurious 'nop' instruction.
2000-09-22 22:06:44 +00:00
Justin T. Gibbs
dfd86f14c0 Remove the last two uses of ahc->unit in the FreeBSD version of the driver.
ahc->unit is depricated and will be going away as soon as the Linux
driver catches up.  In the FreeBSD case, it is always initialized to 0
and this caused some strangeness in registering multiple ahc controllers
with CAM.

Noticed by:	Tor.Egge@fast.no
2000-09-20 04:46:15 +00:00
Justin T. Gibbs
f175cbb663 Today is just not my day. Really get the right file. 2000-09-16 21:55:31 +00:00
Justin T. Gibbs
ae7c64e466 Pull the correct file over to freefall. 2000-09-16 20:59:12 +00:00
Justin T. Gibbs
32da3127a3 Move aicasm to its own subdirectory. 2000-09-16 20:02:39 +00:00
Justin T. Gibbs
717d424718 Move aicasm to its own subdirectory.
Separate our platform independent hooks from core driver functionality
shared between platforms (FreeBSD and Linux at this time).

Add sequencer workarounds for several chip->chipset interactions.

Correct external SCB corruption problem on aic7895 based cards (3940AUW).

Lots of cleanups resulting from the port to another OS.
2000-09-16 20:02:28 +00:00
Doug Rabson
21c3015a24 * Completely rewrite the alpha busspace to hide the implementation from
the drivers.
* Remove legacy inx/outx support from chipset and replace with macros
  which call busspace.
* Rework pci config accesses to route through the pcib device instead of
  calling a MD function directly.

With these changes it is possible to cleanly support machines which have
more than one independantly numbered PCI busses. As a bonus, the new
busspace implementation should be measurably faster than the old one.
2000-08-28 21:48:13 +00:00
Bill Paul
8ebe5155fa *smack* #if 0, not #ifdef 0. 2000-08-04 18:17:45 +00:00
Bill Paul
624539bb38 The check_extport() function appears to have some new code in it that checks
the scratch RAM for data normally found in the SEEPROM (presumably in the
event that the SEEPROM is unavailable or can't be read). This code causes
a spontaneous reboot on monster.osd.bsdi.com, which has an embedded aic7880
controller. The problem appears to happen either when it writes to the
SCBPTR port and then reads from the SCB_CONTROL port. Somewhere during
the inb/outb operations, the system has a heart attack and restarts.

This code looks very suspicious, particularly since it has unconditionalized
debug mesages such as "Got here!" and "And it even worked!". With this
block #ifdef'ed out, the machine boots and runs properly. I stronly suggest
that it stay #ifdef'ed out until it's properly tested.
2000-08-04 18:09:56 +00:00
Justin T. Gibbs
957790c3e6 ahc_pci.c:
Disable "cache line streaming" for aic7890/91 Rev A chips.  I
	have never seen these chips fail using this feature, but
	some of Adaptec's regression tests have.

	Explicitly set "cache line streaming" to on for aic7896/97
	chips.  This was happening before, but this documents the
	fact that these chips will not function correctly without
	CACHETHEEN set.

aic7xxx.h:
	Add new bug types.

	Fix a typo in a comment.

aic7xxx.reg:
	Add a definition for the SHVALID bit in SSTAT3 for Ultra2/3
	chips.  This bit inicates whether the bottom most (current)
	element in the S/G fifo has exhausted its data count.

aic7xxx.seq:
	Be more careful in how we turn off the secondary DMA channel.
	Being less careful may hang the PCI bus arbitor that negotiates
	between the two DMA engines.

	Remove an unecessary and incorrect flag set operation in
	the overrun case.

	On Ultra2/3 controllers, clear the dma FIFO before starting
	to handle an overrun.  We don't want any residual bytes from
	the beginning of the overrun to cause the code that shuts
	down the DMA engine from hanging because the FIFO is not
	(and never will be) empty.

	If the data fifo is empty by the time we notice that a
	read transaction has completed, there is no need to
	hit the flush bit on aic7890/91 hardware that will not
	perform an auto-flush.  Skip some cycles by short circuiting
	the manual flush code in this case.

	When transitioning out of data phase, make sure that we
	have the next S/G element loaded for the following
	reconnect if there is more work to do.  The code
	would do this in most cases before, but there was
	a small window where the current S/G element could
	be exhausted before our fetch of the next S/G element
	completed.  Since the S/G fetch is already initiated
	at this point, it makes sense to just wait for the
	segment to arrive instead of incuring even more latency
	by canceling the fetch and initiating it later.

	Fast path the end of data phase handling for the last
	S/G segment.   In the general case, we might have
	worked ahead a bit by stuffing the S/G FIFO with
	additional segments.  If we stop before using them
	all, we need to fixup our location in the S/G stream.
	Since we can't work past the last S/G segment, no
	fixups are ever required if we stop somewhere in
	that final segment.

	Fix a little buglet in the target mode dma bug handler.
	We were employing the workaround in all cases instead
	of only for the chips that require it.

	Fix the cause of SCB timeouts and possible "lost data"
	during read operations on the aic7890.  When sending
	a data on any Ultra2/3 controller, the final segment
	must be marked as such so the FIFO will be flushed and
	cleaned up correctly when the transfer is ended.  We
	failed to do this for the CDB transfer and so, if
	the target immediately transfered from command to data
	phase without an intervening disconnection, the first
	segment transferred would be any residual bytes from
	the cdb transfer.  The Ultra160 controllers for some
	reason were not affected by this problem.

Many Thanks to Tor Egge for bringing the aic7890 problem
to my attention, providing analysis, as well as a mechanism
to reproduce the problem.
2000-07-27 23:17:52 +00:00
Justin T. Gibbs
f94bf02fdb Properly handle the case where the residual is 0, but, as the target
didn't bother to send a saved data pointers after the last transfer,
is not recorded in sgptr.  This was only a problem if the target
reported non-zero status as we always check the residual in that case.
2000-07-25 20:40:34 +00:00
Justin T. Gibbs
c27eebfde8 aic7xxx.c:
Correct the BUILD_TCL macro.  It was placing the target id
	in the wrong bits.  This was only an issue for adapters that
	do not perform SCB paging (aha-3940AUW for instance).

	Don't bother inlining ahc_index_busy_tcl.  It is never
	used in a performance critical path and is a bit chunky.

	Correct ahc_index_busy_tcl to deal with "busy target tables"
	embedded in the latter half of 64byte SCBs.

	Don't initialize the busy target table to its empty state
	until after we have finished extracting configuration
	information from chip SRAM.  In the common case of using
	16 bytes of chip SRAM to do untagged target lookups,
	we were trashing the last 8 targets configuration data.
	(actually only target 8 because of the bug in the
	BUILD_TCL macro).

	Cram the "bus reset delivered" message back under bootverbose.

	Fix the cleanup of the SCB busy target table when aborting
	commands.  If the lun is wildcarded, we must loop through
	all possible luns.

aic7xxx.h:
	Only bother supporting 64 luns right now.  It doesn't seem
	like either this driver or any peripherals will be doing
	information unit transfers (where the lun number is a
	32 bit integer) any time soon.

aic7xxx.seq:
	Fix support for the aic7895.  We must flush the data
	FIFO if performing a manual transfer that is not
	a multiple of 8 bytes.  We were doing this quite
	regularly for embedded cdbs.

	Manaually flush the fifo on earlier adapters when
	dealing with embedded cdbs too.  We were stuffing
	the FIFO with 16 bytes instead, but triggering
	the flush is more efficient and allows us to
	remove two instructions from the "copy_to_fifo"
	routine.
2000-07-24 22:27:40 +00:00
Justin T. Gibbs
aa6dfd9d3d o Convert to <inttypes.h> style fixed sized types to facilitate porting to
other systems.

 o Normalize copyright text.

 o Clean up probe code function interfaces by passing around a single
   structure of common arguments instead of passing "too many" args
   in each function call.

 o Add support for the AAA-131 as a SCSI adapter.

 o Add support for the AHA-4944 courtesy of "Matthew N. Dodd" <winter@jurai.net

 o Correct manual termination support for PCI cards.  The bit definitions
   for manual termination control in the SEEPROM were incorrect.

 o Add support for extracting NVRAM information from SCB 2 for BIOSen
   that use this mechanism to pass this data to OS drivers.

 o Properly set the STPWLEVEL bit in PCI config space based on the
   setting in an SEEPROM.

 o Go back to useing 32byte SCBs for all controllers.  The current
   firmware allows us to embed 12byte cdbs on all controllers in
   a 32byte SCB, and larger cdbs are rarely used, so it is a
   better use of this space to offer more SCBs (32).

 o Add support for U160 transfers.

 o Add an idle loop executed during data transfers that prefetches
   S/G segments on controllers that have a secondary DMA engine
   (aic789X).

 o Improve the performance of reselections by avoiding an extra
   one byte DMA in the case of an SCB lookup miss for the reselecting
   target.  We now keep a 16byte "untagged target" array on the card
   for dealing with untagged reselections.  If the controller has
   external SCB ram and can support 64byte SCBs, then we use an
   "untagged target/lun" array to maximize concurrency.  Without
   external SCB ram, the controller is limited to one untagged
   transaction per target, auto-request sense operations excluded.

 o Correct the setup of the STPWEN bit in SXFRCTL1.  This control
   line is tri-stated until set to one, so set it to one and then
   set it to the desired value.

 o Add tagged queuing support to our target role implementation.

 o Handle the common cases of the ignore wide residue message
   in firmware.

 o Add preliminary support for 39bit addressing.

 o Add support for assembling on big-endian machines.  Big-endian
   support is not complete in the driver.

 o Correctly remove SCBs in the waiting for selection queue when
   freezing a device queue.

 o Now that we understand more about the autoflush bug on the
   aic7890, only use the workaround on devices that need it.

 o Add a workaround for the "aic7890 hangs the system when you
   attempt to pause it" problem.  We can now pause the aic7890
   safely regardless of what instruction it is executing.
2000-07-18 20:12:14 +00:00
Alexander Langer
0cca1cc078 Fix typo (accessable --> accessible).
PR:		18588
Submitted by:	Anatoly Vorobey <mellon@pobox.com>
Reviewed by:	asmodai
2000-06-14 17:53:40 +00:00
Peter Wemm
7b1e0b9c51 Unused include: #include "ahc.h" 2000-06-10 11:07:54 +00:00
Peter Wemm
9e5c01ffe6 Use the correct register names, not the FreeBSD 2.2 compatability ones. 2000-05-28 15:47:00 +00:00
David E. O'Brien
5415a4bd71 Use /sys/sys/*.h over /usr/include/sys.
No repsonce from:	Maintainer
2000-05-27 21:35:47 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Poul-Henning Kamp
ed6aff7387 Remove unneeded <sys/buf.h> includes.
Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks
by 924 bytes.
2000-04-18 15:15:39 +00:00
Justin T. Gibbs
ff58fb8420 o Correct the offsets into the syncrate table for paritcular
negotiation features (DT, ULTRA2, ULTRA, FAST).  The offsets
  where not properly updated when the DT entry was added and so
  the driver could attempt to negotiate a speed faster than that
  supported by the target device or even requested by the user
  via SCSI-Select settings. *

o Update the target mode incoming command queue kernel index value
  ever 128 commands instead of 32.  This means that the kernel will
  always try to keep its index (as seen on the card - the kernel may
  actually have cleared more space) 128 commands ahead of where the
  sequencer is adding entries.

o Use the HS_MAILBOX register instead of the KERNEL_TQINPOS location
  in SRAM to indicate the kernel's target queue possition on Ultra2
  cards.  This avoids the "pause bug" on these cards and also turns
  out to be much more efficient.

o When enabling or disabling a particular target id for target mode,
  make sure that the taret id in the SCSIID register does not
  reference an ID that is not to receive target selections.  This
  is only an issue on chips that support the multiple target id
  feature where the value in SCSIID will still affect selection
  behavior regardless of the values in the target id bit field
  registers.

o Remove some target mode debugging printfs.

o Make sure that the sense length reported in ATIO commands is
  always zero.  This driver does not, yet, report HBA generated
  sense information for accepted commands.

o Honor the CAM_TIME_INFINITY and CAM_TIME_DEFAULT values for
  the CCB timeout field.

o Make the driver compile with AHC_DEBUG again.

* Noticed by: Andrew Gallatin<gallatin@cs.duke.edu>
2000-03-18 22:28:20 +00:00
Justin T. Gibbs
c4b5781296 KNR -> ANSI function definition in two places. This matches the rest of
the code in this driver.
2000-03-18 22:15:00 +00:00
Justin T. Gibbs
945111e5a7 Remove a diagnostic printf.
Noticed by:	 imp@FreeBSD.org
2000-02-16 18:41:00 +00:00
Justin T. Gibbs
85ac786b13 Kill the "unpause_always" argument to unpause_sequencer(). The reasons
for optimizing the unpause operation no-longer exist, and this is much
safer.

When restarting the sequencer, reconstitute the free SCB list on the card.
This deals with a single instruction gap between marking the SCB as free
and actually getting it onto the free list.

Reduce the number of transfer negotiations that occur.  In the past, we
renegotiated after every reported check condition status.  This ensures
that we catch devices that have unexpectidly reset.  In this situation,
the target will always report the check condition before performing a
data-phase.  The new behavior is to renegotiate for any check-condition where
the residual matches the orginal data-length of the command (including
0 length transffers).  This avoids renegotiations during things like
variable tape block reads, where the check condition is reported only
to indicate the residual of the read.

Revamp the parity error detection logic.  We now properly report and
handle injected parity errors in all phases.  The old code used to hang
on message-in parity errors.

Correct the reporting of selection timeout errors to the XPT.  When
a selection timeout occurs, only the currently selecting command
is flagged with SELTO status instead of aborting all currently active
commands to that target.

Fix flipped arguments in ahc_match_scb and in some of the callers of this
routine.  I wish that gcc allowed you to request warnings for enums passed
as ints.

Make ahc_find_msg generically handle all message types.

Work around the target mode data-in wideodd bug in all non-U2 chips.
We can now do sync-wide target mode transfers in target mode across the
hole product line.

Use lastphase exclusively for handling timeouts.  The current phase
doesn't take the bus free state into account.

Fix a bug in the timeout handler that could cause corruption of the
disconnected list.

When sending an embedded cdb to a target, ensure that we start on a
quad word boundary in the data-fifo.  It seems that unaligned stores
do not work correctly.
2000-02-09 21:25:00 +00:00
Justin T. Gibbs
1907f932b8 Fix parity error detection logic for aic7880 and aic7895 chips during
the probe of external SRAM.

Approved by: jkh@FreeBSD.org
2000-02-09 21:00:22 +00:00
Justin T. Gibbs
31fef9fb1a Update copyright license terms to match the reset of the aic7xxx dirver. 2000-02-03 16:54:11 +00:00
Peter Wemm
0cdb7d6692 remove #include "eisa.h" and #if NEISA > 0 - this is guaranteed by
config since ahc_eisa.c is "optional ahc eisa" meaning "only compile
ahc_eisa if ahc and eisa are defined"
2000-01-29 14:22:19 +00:00
Peter Wemm
c5191a983c Pre 4.0 tidy up.
Collect together the components of several drivers and export eisa from
the i386-only area (It's not, it's on some alphas too).  The code hasn't
been updated to work on the Alpha yet, but that can come later.

Repository copies were done a while ago.
Moving these now keeps them in consistant place across the 4.x series
as the newbusification progresses.

Submitted by:   mdodd
2000-01-14 07:14:17 +00:00
Justin T. Gibbs
dbf94fd693 Avoid setting DPARCKEN until I can figure out why it causes
spurious parity errors on some controllers.
2000-01-10 01:47:51 +00:00
Justin T. Gibbs
1a24969d60 Turn on parity error reporting before configuring external sram. This
makes it a little easier to notice that parity checking an 8bit sram
isn't working.

Turn on scb and internal data-path parity checking for all pci chips types.
We were only doing this for ultra2 chips.

After clearing the parity interrupt status, clear the BRKADRINT.  This
avoids seeing a bogus BRKADRINT interrupt after external SCB probing
once normal interrupts are enabled.
2000-01-08 05:31:38 +00:00
Justin T. Gibbs
c971c124a1 Really enable external SCB ram on Ultra2 capable controllers.
Don't even bother to look for SCB ram on controllers < aic7870.

Clear any parity errors generated by looking at external SCB ram.
2000-01-08 00:32:08 +00:00
Justin T. Gibbs
ba09901130 Update copyrights to Y2K.
93cx6.c:
	Make the SRAM dump output a little prettier.

aic7xxx.c:
	Store all SG entries into our SG array in kernel space.
	This makes data-overrun and other error reporting more
	useful as we can dump all SG entries.  In the past,
	we only stored the SG entries that the sequencer might
	need to access, which meant we skipped the first element
	that is embedded into the SCB.

	Add a table of chip strings and replace ugly switch
	statements with table lookups.

	Add a table with bus phase strings and message reponses
	to parity errors in those phases.  Use the table to
	pretty print bus phase messages as well as collapse
	another switch statement.

	Fix a bug in target mode that could cause us to unpause
	the sequencer early in bus reset processing.

	Add the 80MHz/DT mode into our syncrate table.  This
	rate is not yet used or enabled.

	Correct some comments, clean up some code...

aic7xxx.h:
	Add U160 controller feature information.

	Add some more bit fields for various SEEPROM formats.

aic7xxx.reg:
	Add U160 register and register bit definitions.

aic7xxx.seq:
	Make phasemis state tracking more straight forward.  This
	avoids the consumption of SINDEX which is a very useful register.

	For the U160 chips, you must use the 'mov' instruction to
	update DFCNTRL.  Using 'or' to set the PRELOADED bit is
	completely ineffective.

	At the end of the command phase, wair for our ACK signal
	to de-assert before disabling the SCSI dma engine.  For
	slow devices, this avoids clearing the ACK before the
	other end has had a chance to see it and lower REQ.
2000-01-07 23:08:20 +00:00
Justin T. Gibbs
77dd846834 Add detection logic for the U160 family of adaptec controllers. These
controllers will run at U2 speeds until I can complete the U160 support
for this driver.

Correct a termination buglet for the 2940UW-Pro.

Be more paranoid in how we probe and enable external ram, fast external
ram timing and external ram parity checking.  We should now work on
20ns and 8bit SRAM parts.

Perform initial setup for the DT feature on cards that support it.

Factorize and clean up code.  Use tables where it makes sense, etc.

Add some delays in dealing with the board control logic.  I've never
seen this code fail, but with the ever increasing speed of processors,
its better to insert deterministic delays just to be safe.  This stuff
is only touched during probe and attach, so the extra delay is of no
concern.
2000-01-07 22:53:37 +00:00
Peter Wemm
664a31e496 Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot).  This is consistant with the other
BSD's who made this change quite some time ago.  More commits to come.
1999-12-29 04:46:21 +00:00
Justin T. Gibbs
038fc50e5a Correct an "argument reversal" bug that could cause commands requed from
the input fifo to be returned as successful and frozen.  Most, if not
all, peripheral drivers do not check the qfrozen bit for successfully
completed commands, so the result would not only be lost commands, but
devices locked out from receiving commands.  This was a bad bug that
crept in two or three months ago during some target mode work.
1999-12-20 21:32:32 +00:00
Justin T. Gibbs
e0b0c6aad5 When booting verbose, indicate if we are using manual termination
settings for U2 cards.

Don't assume that all aic7859 cards are 2930CUs.
1999-12-12 04:54:14 +00:00
Justin T. Gibbs
820379186b Simplify my license.
Don't arbitrarily limit the initiator ID of the card to something <= 7.

Fix a bug in the checksum code that would incorrectly prevent a valid
checksum of zero. (cp)

Don't touch rely on seeprom data when configuring termination.  We may
not have seeprom data. (cp)

Treat all ULTRA2 capable adapters the same way when reading or writing
the BRDCTL register.  We previously only did this correctly for aic7890/91
chips.  This should correct some problems with termination settings on
aic7896/97 adapters. (cp)

Changes marked with "(cp)"
Pointed out by:	Chuck Paterson <cp@bsdi.com>
1999-12-06 18:29:03 +00:00
Justin T. Gibbs
41c47eee15 Simplify my copyright license terms.
aic7xxx.c:
	Add a function for sucking firmware out of the controller
	prior to reset.

	Remove some inline bloat from functions that should not have
	been inlined.

	During initialization, wait 1ms after the chip reset before
	touching any registers.  You can get machine checks on certain
	architectures (Atari I think?) without the delay.

	Return CAM_REQ_CMP for external BDR requests instead
	of CAM_BDR_SENT.

	Bump some messages to bootverbose levels above 1.

	Don't clear any negotiated sync rate if the target rejects
	a WDTR message.  The sync rate is only cleared if the target
	accepts a WDTR message.

	Fix a small bug in the mesgin handling code that could cause
	us to believe that we had recieved a message that was actually
	received by another target.  This could only confuse us in
	some very rare transmission negotiation scenarios.

	Remove some unecessary cleanup of residual information after
	a residual is reported.  The sequencer does this when the
	command is queued now.
1999-12-06 18:23:31 +00:00
Justin T. Gibbs
d8a4660643 Clear the SELINGO bit after a selection timeout occurs. SELINGO is
usually cleared by a successful selection, but there is no guarantee
that a future successful selection will ever occur (e.g. empty bus).
The driver never looks at SELINGO, but the busy LED does, so this
change has the cosmetic effect of fixing the rare instance where the
busy LED was left on, confusing the user.
1999-09-20 19:04:22 +00:00
Justin T. Gibbs
55bad6b5c3 Work around a defect in the FIFOEMP status bit of Ultra2 class
aic7xxx parts.  This problem could result in data corruption
during periods of my PCI bus load by busmasters other than the
aic7xxx.

Many thanks to Andrew Gallatin <gallatin@cs.duke.edu> for characterizing
the symptoms of this problem and testing this fix.
1999-09-20 18:57:04 +00:00
Kenneth D. Merry
20d39afec3 Get rid of a stray printf on boot. (BRDCTL = ...)
Approved by:	gibbs
1999-09-13 16:32:34 +00:00
Justin T. Gibbs
9be376cc32 aic7xxx.c:
Clean out some #if 0'ed debugging cruft.

aic7xxx.h:
	Definitions for the aic7855 and aic7859.
1999-08-30 16:12:39 +00:00
Justin T. Gibbs
5bdd92770e Add support for the aic7859 which is found on the 2930CU.
Break out the detection logic for the aic7855 and properly report
these chips as 7855s instead of 7850s.

The 2940AU_CN is an aic7860 based card, not aic7860.

Not setting CACHETHEN turned out to be a bad idea.  It can cause
spurious corruption under heavy PCI load with multiple masters.
1999-08-30 16:11:46 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Peter Wemm
0c3c5956d1 Disable some apparently stray debug printfs:
ahc0: <Adaptec 274X SCSI host adapter> at 0x1c00-0x1cff, irq 11 (edge)
ahc0: on eisa0 slot 1
ahc0: aic7770 >= Rev E, SBLKCTL = 0x8
SSTAT0 = 0x0
SFUNCT = 0x0
Twin Channel, A SCSI Id=7, B SCSI Id=7, primary A, 4/255 SCBs

Not objected to by:	gibbs
1999-08-23 12:08:45 +00:00
Mike Smith
fcb893a801 Implement a new generic mechanism for attaching handler functions to
events, in order to pave the way for removing a number of the ad-hoc
implementations currently in use.

Retire the at_shutdown family of functions and replace them with
new event handler lists.

Rework kern_shutdown.c to take greater advantage of the use of event
handlers.

Reviewed by:	green
1999-08-21 06:24:40 +00:00
Justin T. Gibbs
99cfa26a69 Differentiate between aic7895C chips and their earlier brethren
via the PCI revid register.
1999-08-16 22:50:37 +00:00
Justin T. Gibbs
7457cf2d46 Add support for issuing immediate notify event ccbs for bus resets, bdr
messages, abort messages, and abort tag messages.

Fix a bug in how default transfer negotiations are handled if the
user had disabled initial bus resets.

Support multi-targetid on the aic7895C.
1999-08-16 22:49:29 +00:00
Justin T. Gibbs
42aed36923 Kill an unused INTSTAT type. 1999-08-16 22:43:08 +00:00
Justin T. Gibbs
95a5efc2c3 Fix a few compiler nits.
Submitted by:	Bill Fumerola <billf@jade.chc-chimes.com>
1999-08-16 22:42:33 +00:00
Justin T. Gibbs
7debf5e75e Fix a long standing bug in the auto-termination control settings for
the aic7890/91/96/97 cards.  This could cause the system to go into
a long retry/recovery loop during probe.

Fix the alignment argument to bus_dma_tag_create().

Don't set the CACHETHEN bit in dscommand0 for Ultra2 controllers
until we know more about its behavior.  The description for this
bit makes it sound like it could cause problems with certain
PCI chipsets.
1999-08-16 02:33:46 +00:00
Justin T. Gibbs
086646f7c6 Properly set the alignment argument to bus_dma_tag_create(). If we
don't care about the alignment, set it to 1, meaning single byte alignment.
1999-08-16 01:52:21 +00:00
Matthew N. Dodd
0d6ab4a16a Move the specification of EDGE/LEVEL triggered interrupts to
eisa_add_intr() which now takes an additional arguement (one of
EISA_TRIGGER_LEVEL or EISA_TRIGGER_EDGE).

The flag RR_SHAREABLE has no effect when passed to
bus_alloc_resource(dev, SYS_RES_IRQ, ...) in an EISA device context as
the eisa_alloc_resource() call (bus_alloc_resource method) now deals
with this flag directly, depending on the device ivars.

This change does nothing more than move all the 'shared = inb(foo + iobsse)'
nonesense to the device probe methods rather than the device attach.

Also, print out 'edge' or 'level' in the IRQ announcement message.

Reviewed by: dfr
1999-08-01 22:57:09 +00:00
Peter Wemm
9929d2a045 Eliminate a bunch of #include "pci.h" and #if NPCI > 0 around entire
files.  config will leave the whole file out if configured to do so.
1999-07-03 20:17:08 +00:00
Justin T. Gibbs
51064aaaf8 Ignore subvendor and subdevice ids for all ai7880 parts. These chips
only support 'mirroring' the vendor and device ids, so we don't
lose any information.  Certain revisions of the aic7880 will not
perform the mirroring so to match all possiblities would double
the number of table entries.  This change also allows us to match
things like the 2944B which I missed in the original table.
1999-05-26 16:59:17 +00:00
Justin T. Gibbs
b53bae294f Turn the 'dump eeprom' flag into a real option. 1999-05-25 20:15:41 +00:00
Justin T. Gibbs
f40c8d7155 All cards using aic789X chips use the new eeprom format.
Corrects bogus negotiation values on aic7890 based controllers.

PR: 11872
1999-05-25 20:12:32 +00:00
Justin T. Gibbs
3caf668db7 Don't reference our SCB until we have validated that the firmware has
returned an SCB that is in range.
1999-05-23 18:55:58 +00:00
Justin T. Gibbs
ebada55cce aic7xxx.c:
Honor the 'bus reset at startup' option now that the XPT properly
	handles transfer negotiation in this scenario.

	Honor the sync rate settings on Ultra2 controllers.  We would
	always negotiate at the fastest speed.  Oops.

aic7xxx.h:
	Whitespace.

aic7xxx.seq:
	Fix a minor nit that would cause the controller to miss the update
	of the negotiation required bitmask causing the negotiation to
	be delayed by a command.
1999-05-22 22:04:11 +00:00
Justin T. Gibbs
b1334ec97d Correct a bug where the chip could be unpaused in the middle of a bus
or device reset error recovery operation.
1999-05-18 03:58:49 +00:00
Justin T. Gibbs
493950f6d9 Correct the comment for the last commit.
Clean up the handling of failure modes in our attach so we don't free
resources twice.  ahc_free() will do all of the work for us (as would
be required by an unload event) so we only need to handle resources that
the softc has not taken ownership of.
1999-05-17 21:56:00 +00:00
Justin T. Gibbs
40ca72018b Update copyright. Correct some whitespace. 1999-05-17 21:53:51 +00:00
Justin T. Gibbs
923dc21bfe Add a masking scheme to allow for detection of unknown cards using a
chip we think we understand.

Correct identification entry for the AHA2950U2.
1999-05-17 21:53:09 +00:00
Justin T. Gibbs
f240c08e4a Fix whitespace. Correct a comment. 1999-05-17 21:51:41 +00:00
Justin T. Gibbs
168d6886b8 Use a lookup table for device matching instead of a switch on a 64bit
value.  EGCS generates poor code for sparse switch statements on 64bit
values.

Requested by: bde
1999-05-14 17:38:07 +00:00
Justin T. Gibbs
f3da2c5d80 Take the subvendor and subdevice ids into account during device probe.
Sync up device Ids with the master Adaptec list.

Add probe support for the 2940 Pro although it isn't obvious that
all of the termination support is correct for this adapter yet.
1999-05-14 05:09:24 +00:00
Justin T. Gibbs
06d2b844cc Better workaround for aic7890 chip bug. Use the HS_MAILBOX register to
tell the sequencer to pause itself for a target msg variable update.  This
avoids the pause race entirely as HS_MAILBOX can be accessed without
pausing the chip.

3.2 Merge candidate.
1999-05-14 05:07:25 +00:00
Doug Rabson
566643e39e Move the declaration of the interrupt type from the driver structure
to the BUS_SETUP_INTR call.
1999-05-08 21:59:43 +00:00
Kenneth D. Merry
9deea8574e Add a number of interrelated CAM feature enhancements and bug fixes.
NOTE:  These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface.  A make world is recommended.

camcontrol.[c8]:
 - We now support two new commands, "tags" and "negotiate".

	- The tags commands allows users to view the number of tagged
	  openings for a device as well as a number of other related
	  parameters, and it allows users to set tagged openings for
	  a device.

	- The negotiate command allows users to enable and disable
	  disconnection and tagged queueing, set sync rates, offsets
	  and bus width.  Note that not all of those features are
	  available for all controllers.  Only the adv, ahc, and ncr
	  drivers fully support all of the features at this point.
	  Some cards do not allow the setting of sync rates, offsets and
	  the like, and some of the drivers don't have any facilities to
	  do so.  Some drivers, like the adw driver, only support enabling
	  or disabling sync negotiation, but do not support setting sync
	  rates.

 - new description in the camcontrol man page of how to format a disk
 - cleanup of the camcontrol inquiry command
 - add support in the 'devlist' command for skipping unconfigured devices if
   -v was not specified on the command line.
 - make use of the new base_transfer_speed in the path inquiry CCB.
 - fix CCB bzero cases

cam_xpt.c, cam_sim.[ch], cam_ccb.h:

 - new flags on many CCB function codes to designate whether they're
   non-immediate, use a user-supplied CCB, and can only be passed from
   userland programs via the xpt device.  Use these flags in the transport
   layer and pass driver to categorize CCBs.

 - new flag in the transport layer device matching code for device nodes
   that indicates whether a device is unconfigured

 - bump the CAM version from 0x10 to 0x11

 - Change the CAM ioctls to use the version as their group code, so we can
   force users to recompile code even when the CCB size doesn't change.

 - add + fill in a new value in the path inquiry CCB, base_transfer_speed.
   Remove a corresponding field from the cam_sim structure, and add code to
   every SIM to set this field to the proper value.

 - Fix the set transfer settings code in the transport layer.

scsi_cd.c:

 - make some variables volatile instead of just casting them in various
   places
 - fix a race condition in the changer code
 - attach unless we get a "logical unit not supported" error.  This should
   fix all of the cases where people have devices that return weird errors
   when they don't have media in the drive.

scsi_da.c:

 - attach unless we get a "logical unit not supported" error

scsi_pass.c:

 - for immediate CCBs, just malloc a CCB to send the user request in.  This
   gets rid of the 'held' count problem in camcontrol tags.

scsi_pass.h:

 - change the CAM ioctls to use the CAM version as their group code.

adv driver:

 - Allow changing the sync rate and offset separately.

adw driver

 - Allow changing the sync rate and offset separately.

aha driver:

 - Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

ahc driver:

 - Allow setting offset and sync rate separately

bt driver:

 - Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

NCR driver:

 - Fix the ultra/ultra 2 negotiation bug
 - allow setting both the sync rate and offset separately

Other HBA drivers:
 - Put code in to set the base_transfer_speed field for
   XPT_GET_TRAN_SETTINGS CCBs.

Reviewed by:	gibbs, mjacob (isp), imp (aha)
1999-05-06 20:16:39 +00:00
Kenneth D. Merry
5007fcb30f Fix from Justin for transfer negotiations for targets up to target ID 7. 1999-04-26 22:03:44 +00:00
Justin T. Gibbs
1d28309371 ahc_pci.c:
Convert to new bus and bus dma.
	Use latest PCI API.

bt_pci.c:
	Fix a few bugs in how resourses are released left over from
	when this driver was converted to new bus.
1999-04-23 23:30:22 +00:00
Justin T. Gibbs
6d6f090033 ahb.c:
Synchronize malloc types for our softc.

ahc_eisa.c:
	Sync to aic7xxx driver bus dma and new bus changes.
1999-04-23 23:29:00 +00:00
Justin T. Gibbs
00fa2b1fa7 Complete conversion to bus dma. This driver now works on the alpha.
aicasm_symbol.c:
	Correct an unaligned access problem.  You can't rely on DB to
	store your data in an aligned fashion.
1999-04-23 23:27:31 +00:00
Justin T. Gibbs
b19a4814fc Preserve termination settings across the card reset in our shutdown hook. 1999-04-19 21:28:15 +00:00
Peter Wemm
a49a3d4433 Implement an EISA new-bus framework. The old driver probe mechanism
had a quirk that made a shim rather hard to implement properly and it was
just easier to convert the drivers in one go.  The changes to the
buslogic driver go beyond just this - the whole driver was new-bus'ed
including pci and isa.  I have only tested the EISA part of this so far.

Submitted by:	 Doug Rabson <dfr@nlsystems.com>
1999-04-18 15:50:35 +00:00
Justin T. Gibbs
5a151d297c Correct an invalid (and unused) #define in 93cx6.c
Freeze the transaction queue for any type of scsi status other than "okay".
1999-04-07 23:02:45 +00:00
Justin T. Gibbs
73c9c6dd62 Add support for the 3950U2B controller.
Recognize aic7895 controllers that have been "acquired" by a RAIDPort
card as normal aic7895s.

Recognize the aic7815 Raid Parity/Memory controller chip and notify
the user that it's RAID functionality will be ignored.
1999-03-23 07:26:41 +00:00
Justin T. Gibbs
e287abc83c Use TCL_CHANNEL/SCSI_ID/etc. macros in more locations.
Don't mess with the IRQMS bit in the host control register unless
we are an aic7770 chip.

Use calling context to determine if the card is already paused when
we update the target message request bit field in controller scratch
ram.  Looking at the paused bit in the HCNTRL register opened up a
race condition.

Insert delays in the target message request update routine as a temporary
work around for what looks like a chip bug.  I'm still investigating this
one.

Fix the Abort/Abort Tag/BDR handler to pull its message from the message
buffer in our softc instead of attempting to get it from a register on
the controller.  The message is never recorded by the controller in the
new message scheme.

Don't rely on having an SCB when a BDR occurs.  We can issue these during
invalid reconnects to.

Fix a few cases where we were restarting the sequencer but then still
falling out of a switch statement to unpause the sequencer again.
This could cause us to mess up sequencer state if it generated another
pausing interrupt between the time of the restart and unpause.

Kill the 'transceiver settle' loop during card initialization.  I
failed to realize that a controller that is not connected to any
cables will never settle or enable the SCSI transceivers at all.
The correct solution is to monitor the IOERR interrupt which indicates
that the transceiver state has changed (UW<->LVD).

Modify the aic7xxx assembler to properly echo input when stdin is not
a tty.
1999-03-23 07:24:29 +00:00
Justin T. Gibbs
1ab33b7b83 Clean up and order register definitions. 1999-03-08 22:43:23 +00:00
Justin T. Gibbs
048714e71c Add necessary splcam() protection around target mode setup and teardown
routines as well as card access that occurs for the AC_LOST_DEVICE async
event.
1999-03-08 22:42:52 +00:00
Justin T. Gibbs
c562189829 Keep track of negotiated transfer parameters for each initiator<->target
connection.

Clean up support for devices featuring the multiple target SCSI ID feature.
On aic7890/91/96/97 chips, we can now assume the target role on multiple
target ids simultaneously.  Although these chips also have sufficient
instruction space to hold to support the initiator and target role at the
same time, the initiator role is currently disabled as it will conflict
(chip design restriction) with the multi-tid feature.  I'll probably add
a nob to enable the initiator (there-by disabling multi-tid) some time
in the future.

Return queue full or busy, depending on the tagged nature of the incoming
request, if our command input queue fills up in host memeory.

Deal with accept target I/O resource shortages.

If we get an underrun on a transaction that wasn't supposed to transmit
any data, don't attempt to print out the S/G list.  The code would
run until hitting a non-present page. (oops)
1999-03-05 23:35:48 +00:00
Justin T. Gibbs
f15aa8d8d9 Modify to deal with changes in the storage of user negotiation settings. 1999-03-05 23:28:42 +00:00
Justin T. Gibbs
b08ce6a386 Add untested code to support the aha2930U2W.
Modify to deal with changes in the storage of user negotiation settings.
1999-03-05 23:28:36 +00:00
Justin T. Gibbs
957fea92f0 Set the ultra enable bits in the adaptor's scratch ram area only after
we finish modifying our in kernel version during seeprom configuration.
1999-02-11 07:12:16 +00:00
Justin T. Gibbs
03c4f58aa3 Ensure that the ACK from the last information transfer phase has been
de-asserted by the initiator before changing phase or releasing the bus.
Corrects a SCSI specification violation in target mode.
1999-02-11 07:10:20 +00:00