Commit Graph

64 Commits

Author SHA1 Message Date
Justin T. Gibbs a515c85818 Fix the abort code in the BUS DEVICE RESET case. Needed to set cmdlen to 0.
Ensure that queued commands are not touched by the abort code by setting
the SCB status to indicate what queue it is in.

Fix deadlocks when using SCB paging by using SCBs from the assigned_scbs
queue or an SCB that completed during the same interrupt if needed.

Don't ever use insl to pull SCBs from any of the controllers.  You can
only do 8bit PIO reads.  This only affected SCB paging.

With this checkin, SCB paging works quite a bit better, but I still have
some problems with it that may be caused by a firmware problem in my
PD1800s.  It seems that using a tag number higher than the maximum number
of tags allowed by the device, confuses it.  For example, if I queue
two commands, tagged 3 and 36, it never reconnects for tag 36.
1996-04-28 19:21:20 +00:00
Justin T. Gibbs c0eccc00c8 Fix second instance of the inb type when getting the current sequencer address.
Submitted by:	Nate Williams <nate@sri.MT.net>
1996-04-23 04:47:02 +00:00
Justin T. Gibbs ff3f23849e Fix a typo in the RESTART_SEQUENCER macro that could have caused
strange results.  This  bug has been in here for a loooong time.
Many thanks to Pedro Salenbauch for finding this.

Submitted by:	pedrosal@nce.ufrj.br (Pedro Salenbauch)
1996-04-23 04:22:41 +00:00
Justin T. Gibbs 91e2481238 The default number of tags in the SCB paging case was supposed to be
8 not the 18 I was using during some of my own testing.  Ooops.

For those that want to change the number for experimentation, you can
set the value on line 1553 of this file.
1996-04-22 13:21:40 +00:00
Justin T. Gibbs 102d19a473 Implement SCB paging which allows up to 255 active commands on aic7770
(Rev E or greater), aic7850, aic7860, aic7870, and aic7880 controllers.
SCB paging is enabled with the option "AHC_SCBPAGING_ENABLE".  Full
comments on the algorithm are at the top of i386/scsi/aic7xxx.c.

options "AHC_TAGENABLE" and "AHC_QUEUE_FULL" have been removed.  The
default is 4 tags without SCB paging, 8 with.

Clear the SCSIRSTI bit after throwing a bus reset.  Some cards seem to get
confused otherwise.

Handle SCSIRSTI interrupts before checking to see if there is a valid
SCB in use since this can happen. (Clears PR# i386/1123)

Clean up the way we determine the number of SCBs on the card
(courtesy of Dan Eischen).

Guard against attempts to negotiate wide to a narrow controller.

Fix some comments.

Update my copyrights.
1996-04-20 21:29:27 +00:00
Justin T. Gibbs 6e9d1d8bb6 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.

Go back to relying on the SCSIPERR interrupt instead of having the sequencer
interrupt at the beginning of ITloop after a parity error occured.

Determine the number of SCBs on a card automatically and base the qcntmask
on the number of SCBs.

Add entries for 11.4MHz, 8.8MHz, 8.0MHz, and 7.2MHz to ULTRA portion of
the syncrate table.  They seem to work fine on the 2940UW I have here and
will allow more non-ultra devices (like my tape drive) to run sync while
the adapter is in ULTRA mode.

Return XS_SELTIMEOUT instead of XS_TIMEOUT for selection timeouts.  I was
getting sick of waiting for the SCSI code to retry each non-existant unit
multiple times during boot and XS_SELTIMEOUT bypasses all retries.

Use new SLIST queue macros.  This was inspired by NetBSD using TAILQs in
their SCSI drivers.  For optimum cache hits, the free scb list should
be LIFO which is what the old and new code does.  NetBSD implemented a
FIFO queue for some reason.

Spaces -> tabs.
1996-03-31 03:15:31 +00:00
Poul-Henning Kamp cb82e804a5 Remove an unused #define.
Requested by: davidg
1996-03-23 11:29:20 +00:00
Justin T. Gibbs 8eb0f56311 Disable SCSI parity checking until we figure out why the aic78X0 generates
them incorrectly in some Wide scenarios.
1996-03-22 16:26:26 +00:00
Justin T. Gibbs 66792b2e44 Disable the selection hardware before acknowledging a SELTO interrupt.
It seems the 7880 gets confused if you don't do this.
1996-03-11 02:48:41 +00:00
Justin T. Gibbs 9dfa2063d5 bt.c, aic7xxx.c:
Cleanse the SCSI subsystem of its internally defined types
	u_int32, u_int16, u_int8, int32, int16, int8.
	Use the system defined *_t types instead.

aic7xxx.c:
	Fix the reset code.
	Instead of queing up all of the SCBs that timeout during timeout
	processing, we take the first and have it champion the effort.
	Any other scbs that timeout during timeout handling are given
	another lifetime to complete in the hopes that once timeout
	handing is finished, they will complete normally.  If one of
	these SCBs times out a second time, we panic and Justin tries
	again.

	The other major change is to queue flag aborted SCBs during timeout
	handling, and "ahc_done" them all at once as soon as we have the
	controller back into a sane state.  Calling ahc_done any earlier
	will cause the SCSI subsystem to toss the command right back at
	us and the attempt to queue the command will conflict with what
	the timeout routine is trying to accomplish.

	The aic7xxx driver will now respond to bus resets initiated by
	other devices.
1996-03-10 07:11:45 +00:00
Justin T. Gibbs 4697fd511e Changes to support Performance enhancements in the sequencer.
Bring back the polling code (for dumps mostly), but protect it
with splbio() to make it safe for reprobes.
1996-01-29 03:17:39 +00:00
Stefan Eßer dd7610fca4 Make PCI interrupt handlers return void like everybody else does.
Reviewed by:	davidg
1996-01-23 21:48:28 +00:00
Justin T. Gibbs 7faea34be2 Use the new adapter_softc field in the scsi_link structure so that
these drivers don't need to maintain an array of configured units.

The bt driver still needs to because ISA interrupt handlers take a
unit number. :(
1996-01-07 19:24:36 +00:00
Justin T. Gibbs 661104e49c The sequencer sets Intstat to REJECT_MSG, not MSG_REJECT.
Submitted by: "Daniel M. Eischen" <deischen@iworks.InterWorks.org>
1996-01-05 16:13:44 +00:00
Justin T. Gibbs 6cb248359e The long awaited stability patch set for the aic7xxx driver:
Simplify the initialization of adapters by pulling all card specific
initialization to the card specific modules.

Update comments and fix formating.

Pass struct ahc_data*'s to functions instead of unit numbers.

Take advantage of the quad word alignment of SCB fields.

Adapt to new sequencer changes:

	1) Waiting scb list no longer has a tail.

	2) Fill the message buffer as appropriate during a parity error.

	3) Count all of the SGs involved in a residual instead of just
	   the current one.

The reset/abort code still needs a lot of work.

Reviewed by:   David Greenman <davidg@FreeBSd.org>
1996-01-03 06:32:12 +00:00
Bruce Evans 82b945084b Completed function declarations and added prototypes. Sorted prototypes. 1995-12-15 23:49:42 +00:00
David Greenman efeaf95a41 Untangled the vm.h include file spaghetti. 1995-12-07 12:48:31 +00:00
Bruce Evans 0310c19f5d Replaced #includes of <sys/user.h> by less gross headers, usually
<sys/vm.h>.  Many device drivers need only the definition of vtophys()
from vm.

Added nearby #includes of <sys/conf.h> where appropriate.
1995-12-06 23:52:35 +00:00
Justin T. Gibbs b3538b9c15 Fix typo in QUEUE_FULL_SUPPORTED section.
Submitted by: Satoshi Asami <asami>
1995-11-07 07:01:05 +00:00
Justin T. Gibbs 319c75485a Properly print out the chip type again. ahc_init really needs a rewrite. 1995-11-07 05:32:47 +00:00
Justin T. Gibbs 6d32158f2b -Wall fixes. 1995-11-06 05:21:13 +00:00
Justin T. Gibbs a43da20ce4 Move aic7xxx register definitions to sys/dev/aic7xxx/aic7xxx_reg.h.
Start the revamp of the initialiation process.  New routines include
ahc_alloc, ahc_free, and ahc_reset.  These help divide the work of staring
up a board more logically between probe and attach.

ahcintr now takes a (void *) and returns int.  The pci code uses it directly.
Until the PCI code for shared edged triggered interrupts is removed, the
eisa code uses a stub (ahc_eisa_intr) that throws away the int returned
by ahcintr.

Use MHz instead of MB/s for printing out sync rates.

Print out "aic7880" instead of "aic7870" for the new aic7880 chips.
1995-11-05 04:50:55 +00:00
Bruce Evans 2e8300f1f6 Fixed the type of ahcintr(). The type of an ISA interrupt handler is
incompatible with the type of a PCI interrupt handler.  A new entry
point `ahc_pci_intr()' is used for PCI.  ISA and PCI interrupts are
penalized equally (:-) by calling a common handler `ahc_intr()'.  This
should be reorganized.  Some strings now name the wrong function...
1995-11-04 14:43:30 +00:00
Poul-Henning Kamp c227cb3456 Cleanup, make things static. 1995-10-31 18:41:49 +00:00
Justin T. Gibbs 25e55cecc6 Initialize SXFRCTL0 with DFON|SPIOEN|ULTRAEN. 1995-10-29 05:57:48 +00:00
Justin T. Gibbs 7ae20993a0 Fix incorrect bit definitions for SXFRCTL0 (typo). The affected bits
aren't referenced by the driver yet, so this error shouldn't have caused
any problems.

Submitted by:	Dan Eischen <deischen@iworks.InterWorks.org>
1995-10-28 17:27:21 +00:00
Justin T. Gibbs 396614a8b4 Properly deal with the Ultra series of adapters. We should now understand
the new seeprom format and negotiate up to 20MHz sync if set in SCSI-Select.

Reduce the complexity of the timeout code by running it at splhigh().  Fix
a bug that caused rescheduled timeouts at 0 clock ticks in the future causing
an infinite loop.

Obtained from: Timeout bug noticed by David Greenman and wcarchive.
1995-10-26 23:57:18 +00:00
Justin T. Gibbs 67f06b6142 Clean up a few nits in the aic7xxx driver:
1) Make the driver "quiet" by sticking most boot messages behind
	bootverbose conditionals.  This means that you won't see the
	sync and wide negotiation, but you will find out if they fail.

2) Add support to the 93cx6 serial eeprom code to read at an abitrary
	offset.  This is needed so that we can access the second half
	of the eeprom on 3940 cards where the second channel's config
	is stored.

3) Add flags argument to ahcprobe().  This is used by the pci probe code
	to tell the generic driver that an adapter should be treated
	as a channel B device as well as notify it of the presence of
	external SCB SRAM.  These are needed for some motherboard
	implementations of the aic7870 and for the 3940 controllers.

4) Print "Channel A"/"Channel B" instead of "Single Channel" for the
	two busses of the 3940.  I received many reports of confusion
	about how the 3940 was probed since most people belived that
	only one ahc entry was needed.  This will hopefully make it
	clearer.

5) Walk the SCBs to determine just how many their are if external SCB
	ram is detected.

6) Hard code that external SCB ram is present for the 3940 since it doesn't
	use the documented reporting facility for reporting the SRAM. :(
	255 commands per channel are supported on the 3940.

7) Read the seeprom starting at addres 32 for the second channel of the
	3940 so we get the right info for that channel.

8) Clean up printing of the "Disabling tagged queuing message".

9) Queue timeouts if they occur while we are handling a timeout.  The code
	was totally unprotected in this scenario.
Reviewed by: Timeout code reviewed by David Greenman <davidg>
1995-09-05 23:52:03 +00:00
Justin T. Gibbs ea46ac014f Remove hard coded assumption that SCSI busses have 7 targets.
Change some leading spaces to tabs.

This change forces the controller drivers to allocate a scsibus_data struct
via a call to scsi_alloc_bus(), fill in the adapter_link field, and optionally
modify any other fields of the struct.  Scsi_alloc_bus() initializes all fields
to the default, so the changes in most drivers are very minimal.  For drivers
that support Wide controllers, the maxtarg field will have to be updated to
allow probing of all targets (for an example, look at the aic7xxx driver).

Scsi_attachdevs() now takes a scsibus_data* as its argument instead of an
sc_link*.  This allows us to expand the role of the scsibus_data struct for
other bus level configuration setings (max number of transactions, current
transaction opennings, etc for better tagged queuing support).

Reviewed by: Rodney Grimes <rgrimes>, Peter Dufault <dufault>, Julian Elischer <julian>
1995-08-23 23:03:17 +00:00
Justin T. Gibbs a8f7c59522 Properly prototype the ahc_done routine, and pass the right number of
arguments to it in one call in the reset code. (doh!)
1995-08-15 08:54:21 +00:00
Justin T. Gibbs 7825f18854 Correctly timeout scb instead of active_scb which is carying the bus device
reset in this case.
1995-08-14 08:29:15 +00:00
Justin T. Gibbs c83d01159a Update the SCB controll byte bit definitions to match new SCB_DISCENB bit.
Remove "#ifdef NOT_YET"s since the features they pertain too are committed
now.
1995-08-05 17:32:55 +00:00
Justin T. Gibbs 185363acb2 Long overdue, more complete, reset code. These changes implement a
BUS DEVICE RESET followed by BUS RESET failure recovery strategy including
the necesary renegotiation of sync/wide transfers after recovery completes.

Clean up debugging code to make it more finely selectable.  Reset code
debugging is enabled for now so I can get more feedback on how this
code behaves in real life.
1995-07-31 08:25:36 +00:00
Justin T. Gibbs eb62827d8a Specify the controller bus in the scsi_link structure to allow hardwired
buses on multi-bus controllers.  Currently only affects the 274xT controllers.

Reviewed by: Peter Dufault(dufault@hda.com), Rod Grimes(rgrimes@FreeBSD.org)
1995-07-17 23:35:16 +00:00
Andreas Schulz f8e365a0e0 Correct a typo in a comment. 1995-07-08 22:09:11 +00:00
Justin T. Gibbs 6b172e59a6 First pass cleanup of this driver. This pass does not include the sequencer
optimizations I have been working on yet, but does bring in some bug fixes
and performance improvments that were easy to regression test:

Setup the data fifo threshold and bus off timing correctly for 27/284x cards.
Users of these adapters with fast periferals (greater than 5MB/s) will notice
a big performance difference. (Sometimes as large as going from 3.7->8.3MB/s).

Fix handling of the active target flags.  Some of the outbs where missing
the base offset in the abort code.  The abort code still needs lots of work.

Support 3940 controllers, but only with 16 SCBs for now.  Eventually I'll
add support for all 255, but I need to find a tester for the code first since
we have to enable the cards external SRAM to do this.

Add Dan Eischen's serial eeprom reading facilities.  This allows the 2940
adapters to pull additional information left over from SCSI-Select right out
out of the configuration seeprom.

If the BIOS is disabled on 274x controllers, reset all target parameters
to there defaults since you can't rely on what is stored in scratch ram.

Report motherboard controllers as such.

Stick the first SG address and count into the SCB data and count areas for
all transfers in preparation of a later sequencer optimization.

Keep track of which targets can are allowed to have the disconnection
priveledge since this will be handled by the kernel driver in the future.

If a target issues a message reject in response to a tagged message,
disable tagged queuing for that target.  Some seagates say they can do
tagged queuing, but lie, and its a shame to have to disable tagged queuing
on all devices just because you have one that can't cope.
1995-07-04 21:14:45 +00:00
Rodney W. Grimes d3628763db Merge RELENG_2_0_5 into HEAD 1995-06-11 19:33:05 +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
Rodney W. Grimes b2b795f07c Fix -Wformat warnings from LINT kernel. 1995-05-11 19:26:53 +00:00
Justin T. Gibbs 877e25ad85 Aaron Daily of Adaptec has informed me that some form of paged SCB
algorithm is used on aic7770 Rev E or higher chips to improve perfomance.
This required a hardware change but we don't know exactly what (most
likely some special register to do fast SCB indexing into host memory),
and we are not at all sure that there are more than 4 SCBs on these
chips.  This probe will still classify the revision of the aic7xxx, but
we now default to 4 SCBs (at least until we know more of what was done).

This also fixes a bug in the timeout routine where we cleared a flag
too soon making it imposible to enter one section of the routine.

Submitted by: Timeout bug - Dan Eischen <deischen@iworks.InterWorks.org>
1995-05-01 18:43:14 +00:00
Justin T. Gibbs 12ab8490af Set the return value (outb'd to the sequencer) for non zero status
interrupts to zero to start with.  This is the value we return in
most cases.  The sense code then outbs the apropriate value to cause
sense retrieval.  The return value was uninitialized before this
change (something that was an okay thing with the old sequencer code,
but not with the semantics of the new).

This problem caused us to always retrieve sense upon recieving a non
zero status byte.  This is exactly what was happening for the "target
busy" status returned by exabyte tape drives when they rewind or
power on with a tape installed.  The request sense proved fatal.
This should fix the tape problems.
1995-05-01 09:49:45 +00:00
Justin T. Gibbs a52deb6d1e Additions to support the WAITING_SCB list that the sequencer maintains.
It is the kernel driver's responsibility to do the list manipulation whenever
a selection timeout or a request sense occurs.

Print out the interrupt type that the device has been set to.  It seems that
one of the Asus motherboards botches this and David thought a diagnostic would
be nice.

Fix a bug in my diagnostic code that David found.

Reviewed by: Wcarchive and David Greenman
1995-04-27 17:47:17 +00:00
Justin T. Gibbs c6baec432a Don't arbitrarily set SCSI_NOSLEEP. It is now handled correctly by the
higher level scsi code.

Spls should never be conditionalized, so don't do so here.

Restructure the get_scb routine so that we can't get into an infinite
loop if the ccbs are exhausted and we are are called with SCSI_NOSLEEP set.

Other driver maintainer's that based their scb allocation routines on Julian's
code should look at these changes and implement them for their driver.

The aic7xxx driver inspired these changes because early revs of the
aic7770 chips have so few SCBs that you can actually run out.  If you
have a rev C or aic7770 (as is reported by the driver probe) and had more
than 2 drives, you could get into an infinite loop when using up all of
the SCBs.  Since the driver will only allow two SCBs per device and I
only had two devices, I never saw this problem on my Rev C card.

Bzero only 19 bytes of the scb instead of 2k (ack!).  This was a hold
over from when a struct SCB only contained the information downloaded
to the board, but we now store kernel driver data in there as well.  This
greatly lowers the overhead for small transactions (I get ~1MB/sec for
dds with a 512 byte block size).

Submitted by: John Dyson with the aic7xxx specific optimization by me
1995-04-23 22:04:58 +00:00
Justin T. Gibbs 04f390ce00 Be more careful with how we do a chip reset.
Clean up some comments.
1995-04-15 21:37:32 +00:00
Justin T. Gibbs f2f31e3b40 Disable tagged queuing by default. option AHC_TAGENABLE will turn it on.
This is temporary until I can get a device flags added.
1995-04-09 06:39:01 +00:00
Justin T. Gibbs 25e44d3935 Log ABORT_TAG messages to the console.
When attempting to abort a command, don't assume that just because the
sequecer happens to have SCBPTR pointing at the scb we want that it is
an active command.
1995-04-01 19:53:04 +00:00
Justin T. Gibbs c5e0851d47 Major overhaul of the aic7xxx driver:
- catch the interrupt type (EDGE/LEVEL) before chip reset instead
	  of guessing the right type.

	- Add pause variable to the ahc struct to better handle the different
	  interrupt types and pausing the sequencer.

	- CLRINTSTAT -> CLRSCSIINT: This is a documented bit in the CLRINT
	  register in newer Adaptec documentation, so use their name for it.

	- Report valid residual byte counts.

	- Don't mess with the target scratch areas > id 8 on single, narrow,
	  channel devices.  The BIOS does a checksum of this area and can
	  flip out if we zero it out.

	- Initialize the sequencer FLAGS scratch ram variable in the single
	  channel devices to 0.  This was the cause of the annoying warning
	  where we would get a cmdcmplt the first time we did any type of
	  transfer negotiation with no valid scb.  It also fixes the problem
	  that looked like the INTSTAT register wasn't clearing fast enough.
	  This only showed up on 294x cards, not motherboard aic7870s.

	- Add the AHC_AIC7870 type and use it as the superset of aic7870
	  based controllers.

	- clear the sync offset section of the targ scratch area so that
	  we default to asyncronous transfers.  This was only a problem
	  for wide controllers because there was a scenario where the
	  offset wouldn't get updated before a data(out/in) phase would
	  occur.  This required some change in the sequencer code since we
	  were depending on this field to hold the rate to negotiate.

	- allow sync and wide negotiated commands to be tagged (the sequencer
	  now handles this properly).
1995-03-31 13:54:41 +00:00
Justin T. Gibbs 0c40ff690c Increase the DELAY used in ahc_poll. This is only used during intial
probe of the device and shouldn't affect normal operation.  It seems that
some version of the aic7870 are extreamly slow in clearing their interrupt
register so the added delay is required to ensure we don't poll a stale
interrupt value.

Clean up debugging printfs and stuff superflous output into #ifdef AHC_DEBUG.

Ensure that sdtrpending and wdtrpending are cleared in all cases after
we recieve an SDTR or WDTR message.

With this commit, the 294x should work or at least be much closer to
working properly.
1995-03-17 23:58:27 +00:00
Justin T. Gibbs 7896fbec24 Compile cleanly -Wall. Remove some code that was an attempt to make
the 294x probe more stable, but since the guess was wrong, go back to
the clearer aproach I used the first time around.
1995-03-07 08:59:28 +00:00