Commit Graph

263 Commits

Author SHA1 Message Date
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
Justin T. Gibbs
922b8593e6 Correct a race condition where a target mode SCB dma could occur
before we finished setting the pending phase information.

Use the ALL_TARGETS_MASK #define instead of 0xffff for the default
ultraenb mask.
1999-02-11 07:07:27 +00:00
Peter Wemm
6b3daecd80 "fix" long standing aicasm build glitch. The problem was the
reorganization in rev 1.16 of i386/include/types.h which changed
stdlib.h's use of <machine/types.h>.  The problem was the -I. was causing
machine/types.h to come from the current kernel source, while stdlib.h was
coming from /usr/include.  /usr/include/stdlib.h is as old as the last
'make world', the machine/types.h was as new as the current source.
1999-01-17 19:56:02 +00:00
Justin T. Gibbs
2e03cdebd5 Add two missing break statements. 1999-01-15 23:24:23 +00:00
Justin T. Gibbs
863c602654 Add support for routing initiator transactions to disabled luns to the
black hole device.  The controller will now only accept selections if
the black hole device is present and some other target/lun is enabled
for target mode.

Handle the IGNORE WIDE RESIDUE message.  This support has not been tested.

Checkpoint work on handling ABORT, BUS DEVICE RESET, TERMINATE I/O PROCESS,
and CLEAR QUEUE messages as a target.

Fix a few problems with tagged command handling in target mode.

Wait until the sync offset counter falls to 0 before changing phase
after a data-in transfer completes as the DMA logic seems to indicate
transfer complete as soon as our last REQ is issued.

Simplify some of the target mode message handling code in the sequencer.
1999-01-14 06:14:15 +00:00
Justin T. Gibbs
0378c40c5c Fix a few problems with handling rejected transfer negotiation messages.
Use the host message loop for any unknown message types instead of performing
a reject message in the sequencer.  Pass reject messages to the host
message loop too which frees up a sequencer interrupt type slot.

Default to issuing a bus reset if initiator mode is enabled.  It seems
that the reset scsi bus bit is not defined in the same location for
all aic78xx BIOSes, so attempting to honor this setting will have to
wait until I get more information on how to detect it.

Nuke some unused variables.
1998-12-17 00:06:52 +00:00
Justin T. Gibbs
41faa7d374 Pull in new ccb_hdr list types. 1998-12-15 08:24:45 +00:00
Justin T. Gibbs
0ca48af774 Perform a save data pointers operation if a data transfer was performed
in target mode, but we are not completing the command.

Use a template of allowed bus arbitration phases to selectively and
dynamically enable/disable initiator or target (re)selection.

Properly handle timeouts for target role transactions - just go to the
bus free state and report the error to the peripheral driver.

Checkpoint support for the XPT_ABORT_CCB function code.  This currently
handles the accept tio and immediate notify ccb types, but does not
handle the continue target I/O or SCSI I/O ccb types.  This is enough
to handle dynamic target enable/disable events.

Clean up the SCSI reset code so that we perform at most 1 SCSI bus
reset at initialization, the reset requested by the XPT layer.
1998-12-15 08:22:42 +00:00
Matthew Dillon
35f069d08b pci_device pd_probe function changed from returning char * to returning
const char *.  Originally I was going to add casts from const char * to
    char * in some of the pci device drivers, but the reality is that the
    pci device probes return constant quoted strings.
1998-12-14 05:47:29 +00:00
Justin T. Gibbs
4dd5dcaecd Revamp the way that exceptional message handling is performed so that it
is more robust and common code can be used for both the target and iniator
roles.  The mechanism for tracking negotiation state has also been simplified.

Add support for sync/wide negotiation in target mode and fix many of
the target mode bugs running at higher speeds uncovered.  Make a first
stab at getting all of the bus skew delays correct.  Sync+Wide dataout
transfers still cause problems, but this may be an initiator problem.

Ensure that we exit BITBUCKET mode if the controller is restarted.

Add support for target mode only firmware downloads.  This has been
tested on the aic7880, but should mean that we can perform target mode
on any aic7xxx controller.  Mixed mode (initiator and target roles in
the same firmware load) is currently only supported on the aic7890, but
with optimization, may fit on chips with less instruction space.
1998-12-10 04:14:50 +00:00
Archie Cobbs
f1d19042b0 The "easy" fixes for compiling the kernel -Wunused: remove unreferenced static
and local variables, goto labels, and functions declared but not defined.
1998-12-07 21:58:50 +00:00
Archie Cobbs
2127f26023 Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.

These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.

Reviewed by:	Bruce Evans <bde@zeta.org.au>
Reviewed by:	Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by:	Mike Spengler <mks@networkcs.com>
1998-12-04 22:54:57 +00:00
Justin T. Gibbs
08c6fbfa40 Change the delivery mechanism for incoming target commands. We now
use a 256 entry ring buffer of descriptersfor this purpose.  This allows
the use of a simple 8bit counter in the sequencer code for tracking start
location.

Entries in the ring buffer now contain a "cmd_valid" byte at their tail.
As an entry is serviced, this byte is cleared by the kernel and set by
the sequencer during its dma of a new entry.  Since this byte is the last
portion of the command touched during a dma, the kernel can use this
byte to ensure the command it processes is completely valid.

The new command format requires a fixed sized DMA from the controller
to deliver which allowed for additional simplification of the sequencer
code.  The hack that required 1 SCB slot to be stolen for incoming
command delivery notification is also gone.
1998-11-23 01:33:47 +00:00
Justin T. Gibbs
1964f204c9 -Wunused cleanup.
Correct a problem where an external bus reset on the 'background' channel of
a Twin Channel EISA controller could put the driver into an infinite loop.

Noticed by: Twin Channel bug, Joerg Wunsch <joerg@FreeBSD.org>
Submitted by: -Wunused, Poul-Henning Kamp <phk@freebsd.org>
1998-10-15 23:49:27 +00:00
Justin T. Gibbs
bc1b1dad36 Bring back support for honoring the primary channel setting for twin channel
EISA adapters.  This could have caused the system to find the wrong root
disk.

Reviewed by:	 J Wunsch <j@ida.interface-business.de>
1998-10-15 18:21:50 +00:00
Justin T. Gibbs
e95de2a602 Pass termination information via softc flags to the core driver. The
EISA probe missed out on this change in attach->core API.
1998-10-09 17:42:28 +00:00
Justin T. Gibbs
4b3aa31c63 When 'using defaults' ensure that termination is enabled.
Removed some unused code.
1998-10-09 17:41:39 +00:00
Justin T. Gibbs
6405ed07d7 ahc_pci.c:
Disable DPARCKEN in the DSCOMMAND0 register on the aic7890/91/96/97.
	Parity checking is broken for some chip/MB combinations and this
	is the work around recommended by Adaptec.

dpt_pci.c:
	Remove a superflous '{' that prevented DPT_ALLOW_MEMIO from working.

pcireg.h:
	Add a definition for Parity Error Reponse bit in the PCI Space
	command register.
1998-10-07 03:40:51 +00:00
Justin T. Gibbs
13cfc225b9 Add a missing newline. 1998-10-07 03:34:13 +00:00
Justin T. Gibbs
0f39fbdeb5 Correct twin channel operation. 1998-09-21 16:46:13 +00:00
Justin T. Gibbs
bd6bae2166 Remove unused variables and functions.
In the rejected message handler, it was possible for us to confuse a
rejected SDTR or WDTR for a rejected tag.
1998-09-20 23:30:14 +00:00
Justin T. Gibbs
ebeec632cd Correct a bug in the timeout handler. When queuing a BDR response to
a timeout, we must remove the pending SCB from the disconnected list
or risk list corruption when our BDR request using the same SCB is placed
on the waiting list.

Eradicate some silly uses of u_int8_t that just serve to slow the code down.
1998-09-20 05:06:10 +00:00
Justin T. Gibbs
a90c881ed7 Don't interpret SCB index 254 as a target mode completion when not in
target mode.  This hack of using the normal command complete mechanism
for target cdb completion will go away soon.

Submitted by:	Tor.Egge@fast.no
1998-09-18 03:42:16 +00:00
Matt Jacob
cde5024e09 Fix compile warnings. 1998-09-16 03:26:10 +00:00
Justin T. Gibbs
4530878e33 Move to new name, convert to CAM, add support for new chips, and
correct lots of eeprom/auto-termination bugs.
1998-09-15 07:25:33 +00:00
Justin T. Gibbs
ccb21a77fb Move to new name and convert to CAM. 1998-09-15 07:24:58 +00:00
Justin T. Gibbs
3bafc9d432 Massive overhaul of the aic7xxx driver:
- Convert to CAM
 - Use a new DMA based queuing and paging scheme
 - Add preliminary target mode support
 - Add support for the aic789X chips
 - Take advantage of external SRAM on more controllers.
 - Numerous bug fixes and performance improvements.
1998-09-15 07:24:17 +00:00
Justin T. Gibbs
b66655cf37 Some revisions of the aic7880 have a problem where, if the
data fifo is full, but the PCI input latch is not empty,
HDMAEN cannot be cleared.  The fix used here is to attempt
to drain the data fifo until there is space for the input
latch to drain and HDMAEN de-asserts.

This is a 1 instruction fix, so it should have no performance
impact.
1998-06-28 02:58:57 +00:00
Justin T. Gibbs
37507c1bd2 Add support to aicasm for "downloaded constants". These are immediate
operands that are set during seqeuncer program download instead of at
assembly time.

Convert the sequencer code to use" downloaded constants" for four run time
constants that vary depending on the board type.  This frees up 4 bytes
of sequencer scratch ram space where these constants used to be stored and
also removes the additional instructions required to load their values
into the accumulator prior to using them.

Remove the REJBYTE sram variable.  The host driver can just as easly
read the accumulator to get this value.

The scratch ram savings is important as the old code used to clober the
SCSICONF register on 274X cards which sits near the top of scratch ram
space.  The SCSICONF register controls bus termination, and clobbering
it is not a good thing.  Now we have 4 bytes to spare.

This should fix the reported problems with cards that don't have devices
attached to them failing with a stream of "Somone reset bus X" messages.

Doug Ledford determined the cause of the problem, fixes by me.
1997-09-27 19:37:31 +00:00
Justin T. Gibbs
c66dbc92d4 Make the aic7xxx sequencer assembler compile in the kernel's object
directory.  Rename (via repository copy) some files so that the potential
for future conflicts is minimized.

PR: conf/4363
1997-09-03 03:44:58 +00:00
Justin T. Gibbs
083bc8b2cc Add a spin lock that prevents the sequencer from attempting to add an
entry to the QOUTFIFO when it is full.  This should eliminate the
"Timed out while idle" problems that many have reported.

In truth, this is somewhat of a hack.  Although are interrupt latency is
low enough that we should be able to always service the queue in time,
since each entry must be passed up to the higher SCSI layer for what can
be a large amount of processing (perhaps even resulting in a new command
being queued) with interrupts disabled, we need this mechanism to avoid
overflow.  In the future, these additional tasks will be offloaded to a
software interrupt handler which should make this hack unnecessary.
1997-08-13 17:02:47 +00:00
Justin T. Gibbs
f68f348b20 Modify my copyright notice to allow the sequencer to be used with GPLed
software (aka Linux).

Fix a few bugs in the sequencer assembler.

Make it easy to compiler the assembler with debugging turned on.
1997-06-27 19:38:56 +00:00
Justin T. Gibbs
cd6867d0d3 The following scenario would result in a bogus residual being reported
if SCB Paging was enabled:

    disconnect with more data to transfer
    disconnected SCB gets paged out
    target reconnects so we page SCB back in
    target completes transfer so residual is 0
    target disconnects
    SCB gets reused but not paged out since the residual is 0 (optimization)
    target reconnects so we page the SCB back in
    we report a residual because of stale residual information.

The fix for this is to set a flag that forces the SCB to be paged back
up to the host if we page in an SCB with a residual

Pointed out by: Doug Ledford <dledford@dialnet.net>
1997-04-24 16:52:18 +00:00
Justin T. Gibbs
7bde50c604 Revert some changes to the selection and reselection code that were thought
to fix a selection timeout problem.

If we can't find an SCB for the reconnecting target, issue a bus device
reset as the SCSI2 spec suggests.

Add a missing call to "add_scb_to_free_list" in the non paging case.  In
the non-paging case, the SCBs don't really need to be on the free list,
but putting them there clears the tag field which is something the recovery
code depends on.
1997-04-18 16:31:55 +00:00
Justin T. Gibbs
45b7cf8750 Re-arange the selection and reselection code to hopefully kill the
spurious selection timeouts that have been reported.
1997-04-14 02:26:59 +00:00
Justin T. Gibbs
9ff0e63881 aic7xxx.seq:
Be consistant about testing for parity errors after waiting for a
	REQ on the bus.

	Don't ack the last byte in a transaction until after we've cleared
	all target state.

aic7xxx_asm.c:
	Test the return value of getopt against -1 not EOF. (Yet another
	shameless victum of the style guide being wrong).
1997-04-10 19:13:07 +00:00
Justin T. Gibbs
1961f6e884 Instead of testing for both SELDI and SELDO in SSTAT0 in the poll for work
loop, test for them separately.  The bug report from David Malone showed that
even though we had been reselected (SELDI was true), we sat in the poll for
work loop until the selection timeout timer expired.  It may be that the
SSTAT0 register doesn't like to have more than one bit tested at a time.
I've seen stranger things than this on these parts.
1997-04-05 22:03:47 +00:00
Justin T. Gibbs
bb5d13ea1c Add missing Id that was lost when the sequencer file format changed. 1997-04-04 19:35:30 +00:00
Justin T. Gibbs
5ea0ae111d When not using SCB paging, we can always directly index the SCB of interest
either by looking it up in the array of pending, per target, untagged
transactions, or by using the tag value passed in during the identify.  The
old code only direct indexed for tagged transactions.  This makes the
"findSCB" routine only necessary when SCB paging is enabled, so appropriately
conditionalize it.  This greatly simplifies the non SCB paging code flow.
1997-04-04 04:09:29 +00:00
Justin T. Gibbs
cbc7db3bf7 CFLAGS += -I. so that building in an obj directory works. 1997-04-03 05:56:00 +00:00
Justin T. Gibbs
23e11becca Re-arrange the code to upload an SCB to ensure that there is at least
on instruction between the last load into the DFIFO and enabling the DMA.
During back to back SCB DMA, it was possible to hang the card.
1997-03-24 05:02:55 +00:00
Justin T. Gibbs
1c147cc352 aic7xxx.seq:
Stick 4 more, twin channel only, instructions behind
	.if ( TWIN_CHANNEL)

aic7xxx_asm.c:
	Add the -O options which allows the specification of which options
	to include in a program listing.  This makes it possible to easily
	determine the address of any instruction in the program across
	different hardware/option configurations.  Updated usage() as well.
1997-03-18 19:18:39 +00:00
Bruce Evans
60b161a92a Don't depend on <sys/types.h> being (bogusly) included by <stdio.h>. 1997-03-16 17:31:59 +00:00
Justin T. Gibbs
65c303b1b1 Missed one. 1997-03-16 07:28:30 +00:00
Justin T. Gibbs
c5cb388883 Makefile gram.y scan.l sequencer.h symbol.c symbol.h aic7xxx_asm.c:
New sequencer assembler for the aic7xxx adapters.  This assembler
	performs some amount of register type checking, allows bit
	manipulation of symbolic constants, and generates "patch tables"
	for conditionalized downloading of portions of the program.
	This makes it easier to take full advantage of the different
	features of the aic7xxx cards without imposing run time penalies
	or being bound to the small memory footprints of the low end
	cards for features like target mode.

aic7xxx.reg:
	New, assembler parsed, register definitions fo the aic7xxx cards.
	This was done primarily in anticipation of 7810 support which
	will have a different register layout, but should be able to use
	the same assembler.  The kernel aic7xxx driver consumes a generated
	file in the compile directory to get the definitions of the register
	locations.

aic7xxx.seq:
	Convert to the slighly different syntax of the new assembler.

	Conditionalize SCB_PAGING, ultra, and twin features which shaves
	quite a bit of space once the program is downloaded.

	Add code to leave the selection hardware enabled during reconnects
	that win bus arbitration.  This ensures that we will rearbitrate
	as soon as the bus goes free instead of delaying for a bit.

	When we expect the bus to go free, perform all of the cleanup
	associated with that event "up front" and enter a loop awaiting
	bus free.  If we see a REQ first, complain, but attempt to
	continue.  This will hopefully address, or at least help diagnose,
	the "target didn't send identify" messages that have been reported.

Spelling corrections obtained from NetBSD.
1997-03-16 07:08:19 +00:00
Justin T. Gibbs
9b2a5540ff No longer clear all interrupt status when the sequencer is reset. The only
time that we really want to do this is when a bus reset causes the sequencer
to be reset and the kernel driver now handles this case.

Remove some reordering in the select2 routine that wasn't necessary.
It was an experimental fix for a race condition I fixed elsewhere, and
confused the code flow.

Don't bother looping on a parity error in the mesgout loop since we can't
see parity errors on out phases.

Clean up the mesgin_identify code.  In the old days, we "snooped" for tag
messages and used this as an indicator of whether or not the target was
using tagged transactions.  This forced the sequencer to ack the identify
before determining if a valid SCB matched the target meaning that an abort
message to handle this case might not be seen before the target entered a
data phase.  Since we can determin the "tagged-ness" of a target by looking
it up in the array of busy targets (recently introduced), we can determine
this up front simplifying the search code as well as ensuring we can follow
the SCSI specs method for rejecting a reselection.

When an SCB is placed on the free list, set its SCB_TAG to SCB_LIST_NULL.
This makes it much easier for the kernel driver to find active SCBs on the
card during error recovery.
1997-02-28 03:51:00 +00:00
Justin T. Gibbs
9df674522b Leave reselections on all the time.
If we are aborting an SCB from findSCB, don't add it back to the free list -
	the kernel driver will do this for us.
1997-02-25 03:02:58 +00:00
Peter Wemm
6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
Justin T. Gibbs
5154778752 Enlarge the message out buffer from 6 to 8 bytes. Now that sync and wide
negotiation messages may be tagged, we were overrunning the old buffer.
The variable that was getting squashed is updated before the message goes
out, causing corrupted SDTR or WDTR messages.  Depending on the phases
traversed before message out, this could cause the wrong offset to be
negotiated allowing data overruns to occur.  The problem is easier to
detect with wide targets on the chain since the allowed offset is smaller.

Also removed the unnecessary  clearing of SPIORDY during the message out
phase.  We don't rely on SPIORDY any more.
1997-02-18 20:22:52 +00:00
Justin T. Gibbs
499c4ce9f6 Clear the DFCNTRL register after every busfree.
When setting the HCNT registers, do so in ascending order.

When performing tagged queueing in non-paging mode, also check the
disconnected bit in the SCB as extra sanity during a reconection.

Make the labels in the DMA routine more sane.

When doing a DMA, if we see the DMADONE condition come true, we can
simply turn of the DMA enable bits in DFCNTRL without testing the FIFO
state as HDONE is true when DMADONE is true and this emplies the FIFO is
empty.

These changes clear up the data overrun error messages and seem to prevent
the "timed out in data-in phase" problems.
1997-02-11 17:07:54 +00:00
Justin T. Gibbs
de1dc306be Clear the channel after (re)selection instead of once we see the bus go
free.

When we clear SCSIRATE, also clear the FAST20 bit in SXFRCTL0.  This also
allowed me to clean up some of the ULTRA code.

ULTRAENB->FAST20 to follow the convention in the Adaptec data books.

Fix the data-overrun code to set both stcnt and hcnt otherwise, the transfer
will just hang until we get a timeout.

Add implicit support for the NOOP message.  I've never heard of the driver
issueing a reject for one, but its silly to reject NOOP and who knows how a
device might react.

In the dma routine, check SDONE before cleaing SDMAEN.  The data books mention
SDONE possibly being cleared when SDMAEN is reset.  Clients of dma now need
to check if SINDEX is cleared to know if a phasemis occured.

Fix some comments to be correct.
1997-02-09 03:23:28 +00:00
Justin T. Gibbs
1d6abdbc6f In dma_finish, don't disturb the direction bit in DFCNTRL when turning off
host DMAs.  The additional test to ensure that the DMA has stopped is also
unnecessary since we've already waited for the DMA to complete.

Update my copyright for the new year.
1997-02-03 02:02:04 +00:00
Justin T. Gibbs
8ebddd1e01 Add 1997 to my copyright.
Expand the boundaries of a pause disabled region to close of possible race
condition.

Revert a portion of the DMA code to fix false overruns.

Add a missing "add_scb_to_free_list" so we don't leak SCBs.
1997-01-29 05:19:46 +00:00
Justin T. Gibbs
ed69a71305 Change the way DMA is handled during the command phase. Only test on
SDONE, not HDONE.

In the data phase dma handler, mask off just the enable bits instead of
clearing the whole register.  Clearing the direction bit could be bad.
Also don't stop a DMA until MREQPEND goes false.  Doing this may cause
an ABORT on the PCI bus although I have yet to see this happen.

Add definitions for MREQPEND and the BRDCTL register.  The BRDCTL register
is used to handle high byte termination and automatic termination testing.
1997-01-24 21:57:47 +00:00
Justin T. Gibbs
6d14c339f6 Clear the SCSI channel after we go to busfree instead of after re/selection.
Only enable reselections once the channel and SCSIRATE have been cleared.

Add a pause block around the test busy code in the non-tagged case to simplify
error recovery in the corner case of aborting an SCB that just got started.

Simplify reselection processing by removing the call to initialize_scsiid.

Clear the scsiseq re/select control bits and setup for catching bogus
busfrees earlier in the re/select process.

Improve the automatic PIO code.  It turns out that SPIORDY is not a reliable
hardware condition bit, so use REQINIT intstead.  Don't rely on PHASEMIS
either since it can take too long to come true.  Use a brute force comparison
instead.

Remove some unnecessary overhead in the command complete processing.  It
should be nearly impossible to overflow the QOUTFIFO (worst case 9 command
have to complete with at least 6 of them requiring paging on an aic7850),
so don't take the additional PIO hit to guard against this condition.  If we
don't see our interrupt in time, the system has bigger problems elsewhere.
If this ever does happen, the timeout handler will notice and retry the
command.
1997-01-22 18:01:07 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Justin T. Gibbs
3d9ab968cd Re-enable reselections as the first thing after we see a bus free. We seem
to miss reselections from some devices and since the reselection response
timeout is only 200ns, enabling reselections too late may be the cause of our
problem.
1996-12-03 17:04:51 +00:00
Justin T. Gibbs
70f6e5521c Conditionally enable the busfree interrupt to catch unexpected busfrees.
Immediate SCBs, since they always send messages that tell the target to
transition to bus free now rely on the busfree interrupt instead of the
IMMEDDONE sequencer interrupt that was generated before.

Rearrange some code in the message out loop to give ATN a little more time
to drop before we ACK the last byte.

Use SPIORDY instead of REQINIT when snooping for a tag message on a reconnect.
This is done for the same reasons we use SPIORDY in the inb functions.

When going into BITBUCKET mode, turn off HDMAEN in the DFCNTRL register so
that we can "not care" what the value of HCNT is.  If HCNT is 0, BITBUCKET
mode won't transfer any data if HDMAEN is set.  Seeing as we don't want the
transfer to even think about touching the host, this seems more sane anyway.
Thanks to "Dan Willis" <dan@plutotech.com> for pointing out that this was
a problem.
1996-11-22 08:25:23 +00:00
Justin T. Gibbs
ad34debda8 Change the way Automatic PIO is performed in the mesgin and mesgout phases.
SPIORDY should go active on any REQ of the bus, so testing for REQINIT is
not necessary.  It also seems that testing for SPIORDY is more robust then
REQINIT since SPIORDY comes active after REQINIT and PHASEMIS seems to take
some time to come true after REQ is asserted if the phase has changed.  Of
course, none of this is documented.

This should give the code savings of my original changes, without breaking the
driver on fast peripherals.
1996-11-21 06:18:33 +00:00
Justin T. Gibbs
bde5245890 Assert that we have seen an identify or have not disconneccted since the
initial selection when entering the status phase.  This is the same assertion
we use for all the other data transfer phases.

Hopefully fix the hangs in the mesgin and mesgout phases that I introduced
last week during some code cleanup.  I need to get some of these 12MB/s
drives so I can reproduce these hangs here...

Add a pause disable in the SCB paging case around our manipulation of the
QOUTQCNT variable.  This is simply extra sanity.

Set LASTPHASE to P_BUSFREE once we see a busfree so that the kernel driver can
differentiate this from a data out phase.
1996-11-16 01:07:35 +00:00
Justin T. Gibbs
8220b8706a Fix two problems with SCB Paging.
1) get_free_or_disc_scb was not being passed its argument correctly
   in one case

2) Add protection in the form of the QOUTQCNT variable to prevent
   overflowing the QOUTFIFO.

This should make SCB Paging work.  Really, I mean it now. 8-)
1996-11-11 05:16:41 +00:00
Justin T. Gibbs
775395aaac index_untagged_scb should rely solely on the argument passed in SINDEX and
not access SCB_TCL directly.  This could have caused problems on twin channel
adapters.

2.2 Candidate.
1996-11-05 07:51:29 +00:00
Justin T. Gibbs
853925d190 In data_phase_reinit when I converted the code to use bcopy, I should have
used mvi instead of mov.  Luckily this code is most likely never executed
since it is only there for sanity should a target goes into the data phase
twice during a single selection or reselection.
1996-10-28 17:00:24 +00:00
Justin T. Gibbs
85772b6529 Fix problems dealing with non-tagged devices when SCB paging is enabled.
Mostly this involved changing the semantics of the findSCB routine so that
it could be used at times other than handling a reconnection.
1996-10-28 06:01:08 +00:00
Justin T. Gibbs
971791f48d Go back to using DMA to get SCBs down to the adapter.
SCB paging is now handled almost entirely by the sequencer and also uses
DMA.  This should make SCB paging at least an order of magnitude more
efficient and vastly simplifies the implementation.

Add a few space optimizations so this code still fits on aic7770 chips.

Update comments.
1996-10-25 06:34:59 +00:00
Justin T. Gibbs
2ea8799246 Bring aic7xxx driver bug fixes from 'SCSI' into current. 1996-10-06 16:38:45 +00:00
Justin T. Gibbs
1ffa43c082 Detect and report dataphase overruns. Put the adapter into 'Bit Bucket'
mode when this occurs and allow the target to complete the transaction.
Force a retry on overruns since they are usually caused by termination or
cable problems.
1996-06-09 17:33:18 +00:00
Justin T. Gibbs
1d40e2f2c5 Hopefully fix the parity problem and the hang on message reject for good. 1996-06-08 06:54:06 +00:00
Justin T. Gibbs
e5442bc690 Don't use the auto ATN on parity error feature. It may be the source
of our parity handling problems.
1996-05-31 06:30:15 +00:00
Justin T. Gibbs
e1ca90bc57 Fix regression. It seems that you need at least one instruction between
seeing SPIORDY and checking for PHASEMIS.  My last change turned out to
be less cosmetic then I thought.

Pointed out by: Satoshi Asami <asami@cs.berkeley.edu>,
		Faried Nawaz <fn@pain.csrv.uidaho.edu
1996-05-30 14:31:08 +00:00
Justin T. Gibbs
56981243dd Merge in changes for NetBSD/OpenBSD.
Cosmetic change to p_mesgout code so that it "looks" the same as what
is done in the inb* routines.
NetBSD/OpenBSD support Submitted by:Noriyuki Soda <soda@sra.co.jp>,
				    Pete Bentley <pete@demon.net>,
				    Charles M. Hannum <mycroft@mit.edu>,
				    Theo de Raadt <deraadt@theos.com>
1996-05-30 07:18:39 +00:00
Justin T. Gibbs
070d32b1a9 Fix a race condition in p_mesgout* and inb* code that could allow a
phasemiss to sneak by without detection.  This should fix the
Wide/Narrow boot problems that have been reported since this bug
caused the driver ignore a narrow target rejecting wide negotiation.
1996-05-27 23:16:55 +00:00
Justin T. Gibbs
087b79e649 Correct a botched commit from yesturday. It helps to bring over the
right patch file.<sigh>
1996-05-23 15:02:18 +00:00
Justin T. Gibbs
61538c3003 Enable/Disable Ultra mode on a per target basis. This allows the driver
to use the full range of settings from 3.6-20MHz on any target.
1996-05-21 18:32:23 +00:00
Justin T. Gibbs
990f21682c One more linux -> __linux__ 1996-05-10 16:28:00 +00:00
Justin T. Gibbs
c2278994ed aic7xxx.seq:
Change #ifdef linux to #ifdef __linux__

aic7xxx_reg.h:
Remove unneeded BOFF_60BCLOCKS
define CHIPRSTACK to be the same as CHIPRST
define RESET_SCSI and CHANNEL_B_PRIMARY bits
All of these aer used during the setup of adapters.
1996-05-10 16:11:03 +00:00
Justin T. Gibbs
0a44712261 Implement SCB paging. This allows up to 255 active commands on
aic7770 >= Rev E, aic7850, aic7860, aic7870, and ai7880 based controllers.

Make findSCB safer for non-tagged commands when tagged commands are
active on the controller.  The symptoms of this problem were
"Overlapped commands attempted" messages during error recovery
attempts.

Compact scratch ram usage.  This leaves 8 bytes free for future use.

Clean up some comments.

aic7xxx_reg.h:
Update my copyright.
1996-04-20 21:20:31 +00:00
Justin T. Gibbs
c2c5fd345d aic7xxx.seq:
Fix support for the aic7850 by looking only at the relavent bits of the
    QINCNT.  The 7850 puts random garbage in the high bits and all my attempts
    to determine the cause of this failed.  This approach does seem to work
    around the problem.

    Don't trust SCSIPERR to tell us when there is a parity error.  On
    some revs of the 7870 and the 7880, this bit follows the parity of
    the current byte.  Instead of using a SEQINT to tell the kernel,
    re-enable the standard parity error interrupt since it seems to pause
    the sequencer right at the time of the error which is the effect we were
    looking for anyway.

aic7xxx_reg.h:
    Remove PARITY_ERROR seqeuncer interrupt type, its no longer used.

    Define QCOUNTMASK as the SRAM location for the mask to use on the
    QINCNT register.  QCOUNTMASK is determined by the number of SCBs
    supported by the device we're working on.

aic7xxx_asm.c
    Properly check the return value of fopen, and define the arg list
    in getopt correctly.
    Submitted by: Pete Bentley <pete@demon.net>
1996-03-31 03:02:37 +00:00
Justin T. Gibbs
75f0b9d070 Reset the DMA control register whenever we reset the sequencer.
Clear LASTPHASE on busfree so the kernel driver can tell that the
   sequencer is idle.
Fix some comments to reflect reality.
1996-03-10 07:02:32 +00:00
Justin T. Gibbs
5327d59536 Performance optimizations. Unroll all bcopies. Use PIO to transfer SCBs
since setting up the DMA is too costly.  Restructure for efficiency.

Pause the sequencer when a parity error occurs so that the kernel driver
knows during which phase the error was encountered.
1996-01-29 03:12:06 +00:00
Justin T. Gibbs
d2c8692ad0 Take a different approach to the SPIORDY race condition. Simply clear
SPIORDY just before we ack on the bus so that there is no chance to
see SPIORDY for the same byte twice.

Make some small modifications so that the Linux aic7xxx driver can use
our sequencer and register definition files verbatum.
1996-01-11 06:17:49 +00:00
Justin T. Gibbs
bff79954c2 Change the inb and outb routines slightly. It seems that waiting for
SPIORDY after polling REQINIT is a bad idea.
1996-01-09 16:14:03 +00:00
Justin T. Gibbs
78aeaf6139 aic7xxx.seq:
Add the same type of safeguards we use in the mesg_in phase to the mesg_out
phase.

aic7xxx_reg.h:
Add definitions for the DSCommand register for PCI adapters.
1996-01-07 19:18:28 +00:00
Justin T. Gibbs
a27c063027 Bring back the more heavy-weight version of the mesgin inb routines. Davidg's
testing made me think that some of the checks were superfluous, but
wcarchive (and Amancio) know better.
1996-01-05 16:11:49 +00:00
Justin T. Gibbs
67e73a53fc Null terminate execl's argument list.
Submitted by: Ron Lenk <rlenk@widget.xmission.com>
1996-01-05 01:48:07 +00:00
Justin T. Gibbs
adf516474d The long awaited stability patch set for the aic7xxx driver:
1) Use cpp to preprocess the sequencer code.

2) Convert all "magic numbers" to #defines shared by the sequencer and
   kernel driver via the aic7xxx_reg.h file.  (The assembler still needs
   to be re-written in lex/yacc to allow ~|& type constructions).

3) Raise ATN on parity errors for "in" phases and send an initiator detected
   error or message-in parity error message as appropriate.

4) Turn off the reselection hardware from the time or a (re)connection to
   busfree.  It seems that some fast targets were able to reconnect before
   the sequencer was able to see busfree.

5) The message buffer is considered "in-use" when there is a positive length
   count.  The ACTIVE_MSG flag was unnecesary.

6) Properly set SCB_NEXT_WAITING to SCB_LIST_HEAD in scbs being added to
   the waiting scb list.  This is a change in how the list code works to
   facilitate some planned work in the reset code.

7) The fields in the SCB have be re-arranged to be quad-word aligned.

8) The inb code has been rewritten to catch phasemisses and be more efficient.

9) Go back to "snooping the bus" to determine if the incomming identify
   message will be followed by a simple queue message.  Its much faster than
   doing a search through the SCBs.

10) Implement better tag range checking for incomming tags.

11) Make sdtr_to_rate more accurate (use 25 instead of 24 in calculations -
    must have been asleep that night).

12) Rearrange some routines to reduce code complexity and size.

13) Update comments and formatting.

14) Fixed bugs I've forgotten about??

Reviewed by: David Greenman <davidg@FreeBSD.org>
1996-01-03 06:25:32 +00:00
Justin T. Gibbs
157b011439 Fix the long dreaded Wide bug and enable WIDEODD for reads. 1995-11-07 05:31:28 +00:00
Justin T. Gibbs
3e4756a1ce Move aic7xxx register definitions from i386/scsi/aic7xxx.c to this file.
The hope is to make the sequencer and kernel code share this file, but
some work on our sequencer assembler will be needed first.
1995-11-05 04:37:25 +00:00
Justin T. Gibbs
1fa2b6b3da Only or in CLRCHN in SXFRCTL0. All other bits in this register are
initialized by the kernel driver now.
1995-10-29 05:56:31 +00:00
Justin T. Gibbs
fca911ecf3 Set SCSIGO generically before we determine the phase instead of doing it
in each phase routine.  Saves a few instructions.

Be more careful in how we deal with SXFRCTL0.  Or in the control bits of
interest instead of using mvi.  The kernel driver will set the ULTRAEN
bit of SXFRCTL0 if we are using Ultra (20MHz) mode and we don't want to
clobber it.

In sdtr_to_rate divide by two if we are in ultra mode to get the correct
setting since its a 20MHz instead of 10MHz scale.
1995-10-26 23:54:13 +00:00
Justin T. Gibbs
1b2a3cf51a Clean up the mesgin code to make it easier to read with proceedure lables
that are based on what mesage is being processed instead of just numbers.

Order the tests for incoming message type by level of occurance.
1995-08-06 05:15:45 +00:00
Justin T. Gibbs
71fb7601c2 Total rewrite of the dataphase sections of the sequencer. This was done
to replace the very poor, original implementation of Scatter/Gather operations.

Use a bit (that was freed up with the rewrite above) in the SCB control byte
to designate commands that should allow disconnection.  The kernel driver
makes this decision now instead of the sequencer since the sequencer can't
do the indexing very efficiently.

This commit drops the sequencer from 426 instructions to 390 most likely
freeing enough space to do a target mode implementation.
1995-08-05 17:31:39 +00:00
Justin T. Gibbs
116616a829 Fix two race conditions.
The first could occur because the original code would continue to reset
the SCSIID register while waiting for a selection.  This could potentially
conflict with a reconnect since a successfull reconnect will also set the
SCSIID register.  The fix is to use a separate wait loop after starting
a selection (as was done a few revisions ago).

The second probably never happens, but it was possible for a target to
reconnect while there was a pending SCB on the waiting list and not get
noticed.  The fix was to remove a supurflous check of the scb waiting
list.
1995-08-05 06:59:17 +00:00
Justin T. Gibbs
4dc2fc9088 Pause the sequencer when message only requests complete. This allows the
kernel driver to know the exact state of the sequencer after a BUS DEVICE
RESET or ABORT completes so it can properly clean up the request.
1995-07-31 08:21:59 +00:00
Justin T. Gibbs
475791c882 Change SCB_LIST_NULL to 0xff from 0x10 to allow for 255 commands. This
is needed for 3940 support.

Have tagged commands look to see if a target is "busy" with a non tagged
command before executing.  This prevents overlapped tagged and non tagged
commands which can happen since request sense commands are not tagged.
1995-07-04 20:58:57 +00:00
Rodney W. Grimes
9b2e535452 Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
David Greenman
57cb71573d Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low.  We now do a MIN(maxoffset, given_offset).

2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation.  Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.

3) We were advertizing a max offset of 15 instead of 8 for wide devices.

4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer.  Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly.  The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.

5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen.  I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.

6) Only tag either SDTR or WDTR negotiation on an SCB.  The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up.  In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR.  I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.

Other stuff that is also included:

1) Don't do a bzero when recycling SCBs.  The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb.  We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.

2) Mask the interrupt type printout for the aic7870 case.  The bit we were
using to determine interrupt type is only valid for the aic7770.


Submitted by:	Justin Gibbs
1995-05-17 07:06:02 +00:00
Justin T. Gibbs
c28447da4c Restructure the arbitration loop to allow for reselections that win out over
the adapter's selections.  Many fast periferals were getting upset when
the sequencer decided to rearbitrate after the device had already won
arbitration.  This also forced the creation of a list threaded through
the SCBs (since we don't have enough space anywhere else) of commands that
are awaiting reselection.  This list is run down before any new transactions
from the input queue are allowed.  The list is appened to whenever we begin
a selection (simple case since the selecting device is always at the head)
and by the kernel driver whenever a request sense occurs.  In the common
case, the list is only one element long, but when a reselection wins out
over a selection and that reselection generates a request sense, the
outstanding selection required for the retreval of the sense code grows
the list.  On machines with many targets, this might cause the list to grow
large, so this solution, which will allow up to the maximum number of I/O
requests capible of the card elements in the list, was chosen.  The list
manipulation is trivial and adds three sequencer instructions of overhead
to the selection phase.

This fixes the "target busy" errors from micropolis drives and the bursty
I/O problem when performing I/O between a Quantum Grand Prix and any other
device.  I anticipate that this will correct many of the problems that
have been reported with this driver.

Reviewed by: Wcarchive and David Greenman
1995-04-27 17:44:27 +00:00
Justin T. Gibbs
3cddb2a3e2 John Aycock's BSD copyrighted sequencer assembler and sequencer code. This
is identical to the older version, just the copyright has changed.  Many
thanks go to Dean Gehnert of the Linux camp who went the extra mile to make
this happen.

Other changes:

Update assembler man page to include the -v and -D options

Merge in Dean's latest changes to the assembler

Have the sequencer do a MSG_REJECT when the negotiated syncronous rate
is lower than the adapter supports.  This forces asyncronous mode which
is faster at these rates anyway.

This code will be moved shortly to the non-gpld portion of the tree.
1995-04-15 21:45:56 +00:00
Justin T. Gibbs
0b000afb3b More code optimizations. Use a slightly different approach to decide
whether a reconnecting target is a tagged device or not.
1995-04-09 06:40:16 +00:00
Justin T. Gibbs
cc865dd008 Off by one error in -MSG-START+0 was just Justin being tired -- revert to
old value.

Remove unnecessary check for active messages in setup SCB.  This same test
would also jump to p_mesgin_done which would "ACK" an extra time possibly
confusing the target.

Tell the kernel driver whenever we send an ABORT_TAG message.
1995-04-01 19:51:40 +00:00