1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Generic driver for the aic7xxx based adaptec SCSI controllers
|
|
|
|
* Product specific probe and attach routines can be found in:
|
1996-01-03 06:32:12 +00:00
|
|
|
* i386/eisa/aic7770.c 27/284X and aic7770 motherboard controllers
|
|
|
|
* pci/aic7870.c 3940, 2940, aic7870 and aic7850 controllers
|
1995-01-13 02:24:31 +00:00
|
|
|
*
|
1996-04-20 21:29:27 +00:00
|
|
|
* Copyright (c) 1994, 1995, 1996 Justin T. Gibbs.
|
|
|
|
* All rights reserved.
|
1994-11-17 20:22:31 +00:00
|
|
|
*
|
1996-04-20 21:29:27 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
1994-11-17 20:22:31 +00:00
|
|
|
*
|
1996-04-20 21:29:27 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1994-11-17 20:22:31 +00:00
|
|
|
*
|
1996-06-09 17:33:18 +00:00
|
|
|
* $Id: aic7xxx.c,v 1.73 1996/06/08 06:55:01 gibbs Exp $
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* Implement Target Mode
|
|
|
|
*
|
1996-04-20 21:29:27 +00:00
|
|
|
* A few notes on how SCB paging works...
|
|
|
|
*
|
|
|
|
* SCB paging takes advantage of the fact that devices stay disconnected
|
|
|
|
* from the bus a relatively long time and that while they're disconnected,
|
|
|
|
* having the SCBs for that device down on the host adapter is of little use.
|
|
|
|
* Instead we copy the SCB back up into kernel memory and reuse the SCB slot
|
|
|
|
* on the card to schedule another transaction. This can be a real payoff
|
|
|
|
* when doing random I/O to tagged queueing devices since there are more
|
|
|
|
* transactions active at once for the device to sort for optimal seek
|
|
|
|
* reduction. The algorithm goes like this...
|
|
|
|
*
|
|
|
|
* At the sequencer level:
|
|
|
|
* 1) Disconnected SCBs are threaded onto a doubly linked list, headed by
|
|
|
|
* DISCONNECTED_SCBH using the SCB_NEXT and SCB_PREV fields. The most
|
|
|
|
* recently disconnected device is always at the head.
|
|
|
|
*
|
|
|
|
* 2) The SCB has an added field SCB_TAG that corresponds to the kernel
|
|
|
|
* SCB number (ie 0-254).
|
|
|
|
*
|
|
|
|
* 3) When a command is queued, the hardware index of the SCB it was downloaded
|
|
|
|
* into is placed into the QINFIFO for easy indexing by the sequencer.
|
|
|
|
*
|
|
|
|
* 4) The tag field is used as the tag for tagged-queueing, for determining
|
|
|
|
* the related kernel SCB, and is the value put into the QOUTFIFO
|
|
|
|
* so the kernel doesn't have to upload the SCB to determine the kernel SCB
|
|
|
|
* that completed on command completes.
|
|
|
|
*
|
|
|
|
* 5) When a reconnect occurs, the sequencer must scan the SCB array (even
|
|
|
|
* in the tag case) looking for the appropriate SCB and if it can't find
|
|
|
|
* it, it interrupts the kernel so it can page the SCB in.
|
|
|
|
*
|
|
|
|
* 6) If the sequencer is successful in finding the SCB, it removes it from
|
|
|
|
* the doubly linked list of disconnected SCBS.
|
|
|
|
*
|
|
|
|
* At the kernel level:
|
|
|
|
* 1) There are four queues that a kernel SCB may reside on:
|
|
|
|
* free_scbs - SCBs that are not in use and have a hardware slot assigned
|
|
|
|
* to them.
|
|
|
|
* page_scbs - SCBs that are not in use and need to have a hardware slot
|
|
|
|
* assigned to them (i.e. they will most likely cause a page
|
|
|
|
* out event).
|
|
|
|
* waiting_scbs - SCBs that are active, don't have an assigned hardware
|
|
|
|
* slot assigned to them and are waiting for either a
|
|
|
|
* disconnection or a command complete to free up a slot.
|
1996-04-28 19:21:20 +00:00
|
|
|
* assigned_scbs - SCBs that were in the waiting_scbs queue, but were
|
|
|
|
* assigned a slot by ahc_free_scb.
|
1996-04-20 21:29:27 +00:00
|
|
|
*
|
|
|
|
* 2) When a new request comes in, an SCB is allocated from the free_scbs or
|
|
|
|
* page_scbs queue with preference to SCBs on the free_scbs queue.
|
|
|
|
*
|
|
|
|
* 3) If there are no free slots (we retrieved the SCB off of the page_scbs
|
|
|
|
* queue), the SCB is inserted onto the tail of the waiting_scbs list and
|
|
|
|
* we attempt to run this queue down.
|
|
|
|
*
|
|
|
|
* 4) ahc_run_waiing_queues() looks at both the assigned_scbs and waiting_scbs
|
|
|
|
* queues. In the case of the assigned_scbs, the commands are immediately
|
|
|
|
* downloaded and started. For waiting_scbs, we page in all that we can
|
|
|
|
* ensuring we don't create a resource deadlock (see comments in
|
|
|
|
* ahc_run_waing_queues()).
|
|
|
|
*
|
|
|
|
* 5) After we handle a bunch of command completes, we also try running the
|
|
|
|
* queues since many SCBs may have disconnected since the last command
|
|
|
|
* was started and we have at least one free slot on the card.
|
|
|
|
*
|
|
|
|
* 6) ahc_free_scb looks at the waiting_scbs queue for a transaction
|
|
|
|
* requiring a slot and moves it to the assigned_scbs queue if it
|
|
|
|
* finds one. Otherwise it puts the current SCB onto the free_scbs
|
|
|
|
* queue for later use.
|
|
|
|
*
|
|
|
|
* 7) The driver handles page-in requests from the sequencer in response to
|
|
|
|
* the NO_MATCH sequencer interrupt. For tagged commands, the approprite
|
|
|
|
* SCB is easily found since the tag is a direct index into our kernel SCB
|
|
|
|
* array. For non-tagged commands, we keep a separate array of 16 pointers
|
|
|
|
* that point to the single possible SCB that was paged out for that target.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#endif /* defined(__NetBSD__) */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
1995-12-06 23:52:35 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
#include <scsi/scsi_all.h>
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
#include <scsi/scsi_debug.h>
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
#include <scsi/scsiconf.h>
|
1995-12-06 23:52:35 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-03-07 08:59:28 +00:00
|
|
|
#include <machine/clock.h>
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1995-12-06 23:52:35 +00:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.h>
|
1995-12-06 23:52:35 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-01-13 02:27:08 +00:00
|
|
|
#include <i386/scsi/aic7xxx.h>
|
1995-12-06 23:52:35 +00:00
|
|
|
|
1995-11-05 04:50:55 +00:00
|
|
|
#include <dev/aic7xxx/aic7xxx_reg.h>
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif /* defined(__FreeBSD__) */
|
|
|
|
|
|
|
|
#if defined(__NetBSD__)
|
|
|
|
#include <dev/ic/aic7xxxreg.h>
|
|
|
|
#include <dev/ic/aic7xxxvar.h>
|
|
|
|
|
|
|
|
#define bootverbose 1
|
|
|
|
|
|
|
|
#define DEBUGTARG DEBUGTARGET
|
|
|
|
#if DEBUGTARG < 0 /* Negative numbrs for disabling cause warnings */
|
|
|
|
#undef DEBUGTARG
|
|
|
|
#define DEBUGTARG 9
|
|
|
|
#endif
|
|
|
|
#endif /* defined(__NetBSD__) */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#define KVTOPHYS(x) vtophys(x)
|
|
|
|
|
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
|
|
|
#define MIN(a,b) ((a < b) ? a : b)
|
1995-07-31 08:25:36 +00:00
|
|
|
#define ALL_TARGETS -1
|
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
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-06 05:21:13 +00:00
|
|
|
u_long ahc_unit = 0;
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1996-05-30 07:19:59 +00:00
|
|
|
static int ahc_debug = AHC_DEBUG;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AHC_BROKEN_CACHE
|
|
|
|
int ahc_broken_cache = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "wbinvd" cause writing back whole cache (both CPU internal & external)
|
|
|
|
* to memory, so that the instruction takes a lot of time.
|
|
|
|
* This makes machine slow.
|
|
|
|
*/
|
|
|
|
#define INVALIDATE_CACHE() __asm __volatile("wbinvd")
|
1996-04-20 21:29:27 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/**** bit definitions for SCSIDEF ****/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define HSCSIID 0x07 /* our SCSI ID */
|
|
|
|
#define HWSCSIID 0x0f /* our SCSI ID if Wide Bus */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
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
|
|
|
static void ahcminphys __P((struct buf *bp));
|
|
|
|
static int32_t ahc_scsi_cmd __P((struct scsi_xfer *xs));
|
1995-12-15 23:49:42 +00:00
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static struct scsi_adapter ahc_switch =
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_scsi_cmd,
|
|
|
|
ahcminphys,
|
|
|
|
0,
|
|
|
|
0,
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-04-20 21:29:27 +00:00
|
|
|
0,
|
1994-11-17 20:22:31 +00:00
|
|
|
"ahc",
|
|
|
|
{ 0, 0 }
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1995-05-30 08:16:23 +00:00
|
|
|
};
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/* the below structure is so we have a default dev struct for our link struct */
|
1995-10-31 18:41:49 +00:00
|
|
|
static struct scsi_device ahc_dev =
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
|
|
|
NULL, /* Use default error handler */
|
|
|
|
NULL, /* have a queue, served by this */
|
|
|
|
NULL, /* have no async handler */
|
|
|
|
NULL, /* Use default 'done' routine */
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1994-11-17 20:22:31 +00:00
|
|
|
"ahc",
|
1995-05-30 08:16:23 +00:00
|
|
|
0,
|
1994-11-17 20:22:31 +00:00
|
|
|
{ 0, 0 }
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since the sequencer can disable pausing in a critical section, we
|
1995-05-30 08:16:23 +00:00
|
|
|
* must loop until it actually stops.
|
1994-12-31 19:31:56 +00:00
|
|
|
* XXX Should add a timeout in here??
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1996-01-03 06:32:12 +00:00
|
|
|
#define PAUSE_SEQUENCER(ahc) \
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, HCNTRL, ahc->pause); \
|
1996-01-03 06:32:12 +00:00
|
|
|
\
|
1996-05-30 07:19:59 +00:00
|
|
|
while ((AHC_INB(ahc, HCNTRL) & PAUSE) == 0) \
|
1996-01-03 06:32:12 +00:00
|
|
|
;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
#define UNPAUSE_SEQUENCER(ahc) \
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, HCNTRL, ahc->unpause )
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Restart the sequencer program from address zero
|
|
|
|
*/
|
1996-01-03 06:32:12 +00:00
|
|
|
#define RESTART_SEQUENCER(ahc) \
|
1996-06-08 06:55:01 +00:00
|
|
|
do { \
|
|
|
|
AHC_OUTB(ahc, SEQCTL, SEQRESET|FASTMODE); \
|
|
|
|
} while((AHC_INB(ahc, SEQADDR0) != 0) \
|
|
|
|
|| (AHC_INB(ahc, SEQADDR1) != 0)); \
|
1996-01-03 06:32:12 +00:00
|
|
|
\
|
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
/*
|
|
|
|
* Is device which is pointed by sc_link connected on second scsi bus ?
|
|
|
|
*/
|
|
|
|
#define IS_SCSIBUS_B(ahc, sc_link) \
|
|
|
|
((sc_link)->scsibus == (ahc)->sc_link_b.scsibus)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* convert FreeBSD's SCSI symbols to NetBSD's
|
|
|
|
*/
|
|
|
|
#define SCSI_NOMASK SCSI_POLL
|
|
|
|
#define opennings openings
|
|
|
|
#endif
|
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
static u_char ahc_abort_wscb __P((struct ahc_data *ahc, struct scb *scbp,
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char prev,
|
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
|
|
|
u_char timedout_scb, u_int32_t xs_error));
|
1996-05-30 07:19:59 +00:00
|
|
|
static void ahc_add_waiting_scb __P((struct ahc_data *ahc,
|
|
|
|
struct scb *scb));
|
1996-01-03 06:32:12 +00:00
|
|
|
static void ahc_done __P((struct ahc_data *ahc, struct scb *scbp));
|
|
|
|
static void ahc_free_scb __P((struct ahc_data *ahc, struct scb *scb,
|
|
|
|
int flags));
|
1996-04-20 21:29:27 +00:00
|
|
|
static inline void ahc_send_scb __P((struct ahc_data *ahc, struct scb *scb));
|
|
|
|
static inline void ahc_fetch_scb __P((struct ahc_data *ahc, struct scb *scb));
|
|
|
|
static inline void ahc_page_scb __P((struct ahc_data *ahc, struct scb *out_scb,
|
|
|
|
struct scb *in_scb));
|
|
|
|
static inline void ahc_run_waiting_queues __P((struct ahc_data *ahc));
|
1995-12-15 23:49:42 +00:00
|
|
|
static struct scb *
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_get_scb __P((struct ahc_data *ahc, int flags));
|
1996-05-30 07:19:59 +00:00
|
|
|
static void ahc_loadseq __P((struct ahc_data *ahc));
|
1995-12-15 23:49:42 +00:00
|
|
|
static int ahc_match_scb __P((struct scb *scb, int target, char channel));
|
1996-01-29 03:17:39 +00:00
|
|
|
static int ahc_poll __P((struct ahc_data *ahc, int wait));
|
1995-12-15 23:49:42 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
static void ahc_print_scb __P((struct scb *scb));
|
|
|
|
#endif
|
1996-01-03 06:32:12 +00:00
|
|
|
static int ahc_reset_channel __P((struct ahc_data *ahc, char channel,
|
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
|
|
|
u_char timedout_scb, u_int32_t xs_error,
|
|
|
|
u_char initiate_reset));
|
1996-01-03 06:32:12 +00:00
|
|
|
static int ahc_reset_device __P((struct ahc_data *ahc, int target,
|
|
|
|
char channel, u_char timedout_scb,
|
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
|
|
|
u_int32_t xs_error));
|
1996-05-30 07:19:59 +00:00
|
|
|
static void ahc_reset_current_bus __P((struct ahc_data *ahc));
|
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
|
|
|
static void ahc_run_done_queue __P((struct ahc_data *ahc));
|
1996-01-03 06:32:12 +00:00
|
|
|
static void ahc_scsirate __P((struct ahc_data* ahc, u_char *scsirate,
|
1996-05-21 18:37:25 +00:00
|
|
|
int period, int offset, char channel,
|
|
|
|
int target));
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-12-15 23:49:42 +00:00
|
|
|
static timeout_t
|
|
|
|
ahc_timeout;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
static void ahc_timeout __P((void *));
|
|
|
|
#endif
|
|
|
|
static void ahc_busy_target __P((struct ahc_data *ahc,
|
|
|
|
int target, char channel));
|
|
|
|
static void ahc_unbusy_target __P((struct ahc_data *ahc,
|
|
|
|
int target, char channel));
|
|
|
|
|
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
|
|
|
|
char *ahc_name(ahc)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
{
|
|
|
|
static char name[10];
|
|
|
|
|
|
|
|
sprintf(name, "ahc%d", ahc->unit);
|
|
|
|
return (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
struct cfdriver ahc_cd = {
|
|
|
|
NULL, "ahc", DV_DULL
|
|
|
|
};
|
|
|
|
#endif
|
1995-12-15 23:49:42 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_print_scb(scb)
|
|
|
|
struct scb *scb;
|
|
|
|
{
|
1995-11-06 05:21:13 +00:00
|
|
|
printf("scb:%p control:0x%x tcl:0x%x cmdlen:%d cmdpointer:0x%lx\n"
|
1996-04-20 21:29:27 +00:00
|
|
|
,scb
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb->control
|
1996-04-20 21:29:27 +00:00
|
|
|
,scb->tcl
|
|
|
|
,scb->cmdlen
|
|
|
|
,scb->cmdpointer );
|
1996-01-03 06:32:12 +00:00
|
|
|
printf(" datlen:%d data:0x%lx segs:0x%x segp:0x%lx\n"
|
1996-04-20 21:29:27 +00:00
|
|
|
,scb->datalen
|
|
|
|
,scb->data
|
|
|
|
,scb->SG_segment_count
|
|
|
|
,scb->SG_list_pointer);
|
1995-11-06 05:21:13 +00:00
|
|
|
printf(" sg_addr:%lx sg_len:%ld\n"
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb->ahc_dma[0].addr
|
|
|
|
,scb->ahc_dma[0].len);
|
|
|
|
}
|
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#endif
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
static struct {
|
1995-05-30 08:16:23 +00:00
|
|
|
u_char errno;
|
1994-11-17 20:22:31 +00:00
|
|
|
char *errmesg;
|
|
|
|
} hard_error[] = {
|
1995-03-07 08:59:28 +00:00
|
|
|
{ ILLHADDR, "Illegal Host Access" },
|
|
|
|
{ ILLSADDR, "Illegal Sequencer Address referrenced" },
|
|
|
|
{ ILLOPCODE, "Illegal Opcode in sequencer program" },
|
|
|
|
{ PARERR, "Sequencer Ram Parity Error" }
|
1995-05-30 08:16:23 +00:00
|
|
|
};
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid SCSIRATE values. (p. 3-17)
|
|
|
|
* Provides a mapping of tranfer periods in ns to the proper value to
|
|
|
|
* stick in the scsiscfr reg to use that transfer rate.
|
|
|
|
*/
|
|
|
|
static struct {
|
|
|
|
short sxfr;
|
1995-10-26 23:57:18 +00:00
|
|
|
/* Rates in Ultra mode have bit 8 of sxfr set */
|
|
|
|
#define ULTRA_SXFR 0x100
|
1994-11-17 20:22:31 +00:00
|
|
|
short period; /* in ns */
|
|
|
|
char *rate;
|
|
|
|
} ahc_syncrates[] = {
|
1995-10-26 23:57:18 +00:00
|
|
|
{ 0x100, 50, "20.0" },
|
|
|
|
{ 0x110, 62, "16.0" },
|
|
|
|
{ 0x120, 75, "13.4" },
|
|
|
|
{ 0x000, 100, "10.0" },
|
|
|
|
{ 0x010, 125, "8.0" },
|
|
|
|
{ 0x020, 150, "6.67" },
|
|
|
|
{ 0x030, 175, "5.7" },
|
|
|
|
{ 0x040, 200, "5.0" },
|
|
|
|
{ 0x050, 225, "4.4" },
|
|
|
|
{ 0x060, 250, "4.0" },
|
|
|
|
{ 0x070, 275, "3.6" }
|
1994-11-17 20:22:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int ahc_num_syncrates =
|
|
|
|
sizeof(ahc_syncrates) / sizeof(ahc_syncrates[0]);
|
|
|
|
|
|
|
|
/*
|
1995-11-05 04:50:55 +00:00
|
|
|
* Allocate a controller structures for a new device and initialize it.
|
|
|
|
* ahc_reset should be called before now since we assume that the card
|
|
|
|
* is paused.
|
|
|
|
*
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-05 04:50:55 +00:00
|
|
|
struct ahc_data *
|
|
|
|
ahc_alloc(unit, iobase, type, flags)
|
1995-01-13 02:24:31 +00:00
|
|
|
int unit;
|
|
|
|
u_long iobase;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
void
|
|
|
|
ahc_construct(ahc, bc, ioh, type, flags)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
bus_chipset_tag_t bc;
|
|
|
|
bus_io_handle_t ioh;
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_type type;
|
1995-09-05 23:52:03 +00:00
|
|
|
ahc_flag flags;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
/*
|
|
|
|
* find unit and check we have that many defined
|
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-01-03 06:32:12 +00:00
|
|
|
struct ahc_data *ahc;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
/*
|
|
|
|
* Allocate a storage area for us
|
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc = malloc(sizeof(struct ahc_data), M_TEMP, M_NOWAIT);
|
|
|
|
if (!ahc) {
|
|
|
|
printf("ahc%d: cannot malloc!\n", unit);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
bzero(ahc, sizeof(struct ahc_data));
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1996-04-20 21:29:27 +00:00
|
|
|
STAILQ_INIT(&ahc->free_scbs);
|
|
|
|
STAILQ_INIT(&ahc->page_scbs);
|
|
|
|
STAILQ_INIT(&ahc->waiting_scbs);
|
|
|
|
STAILQ_INIT(&ahc->assigned_scbs);
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc->unit = unit;
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
|
|
|
#if defined(__FreeBSD__)
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc->baseport = iobase;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
ahc->sc_bc = bc;
|
|
|
|
ahc->sc_ioh = ioh;
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc->type = type;
|
1995-09-05 23:52:03 +00:00
|
|
|
ahc->flags = flags;
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc->unpause = (AHC_INB(ahc, HCNTRL) & IRQMS) | INTEN;
|
1995-11-05 04:50:55 +00:00
|
|
|
ahc->pause = ahc->unpause | PAUSE;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-01-03 06:32:12 +00:00
|
|
|
return (ahc);
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-05 04:50:55 +00:00
|
|
|
void
|
|
|
|
ahc_free(ahc)
|
1996-01-03 06:32:12 +00:00
|
|
|
struct ahc_data *ahc;
|
1995-11-05 04:50:55 +00:00
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-05 04:50:55 +00:00
|
|
|
free(ahc, M_DEVBUF);
|
|
|
|
return;
|
1996-05-30 07:19:59 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1995-11-05 04:50:55 +00:00
|
|
|
void
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-05 04:50:55 +00:00
|
|
|
ahc_reset(iobase)
|
1996-01-03 06:32:12 +00:00
|
|
|
u_long iobase;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
ahc_reset(devname, bc, ioh)
|
|
|
|
char *devname;
|
|
|
|
bus_chipset_tag_t bc;
|
|
|
|
bus_io_handle_t ioh;
|
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
{
|
|
|
|
u_char hcntrl;
|
|
|
|
int wait;
|
|
|
|
|
|
|
|
/* Retain the IRQ type accross the chip reset */
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-05 04:50:55 +00:00
|
|
|
hcntrl = (inb(HCNTRL + iobase) & IRQMS) | INTEN;
|
1996-05-10 16:21:05 +00:00
|
|
|
|
1995-11-05 04:50:55 +00:00
|
|
|
outb(HCNTRL + iobase, CHIPRST | PAUSE);
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
hcntrl = (bus_io_read_1(bc, ioh, HCNTRL) & IRQMS) | INTEN;
|
|
|
|
|
|
|
|
bus_io_write_1(bc, ioh, HCNTRL, CHIPRST | PAUSE);
|
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
/*
|
|
|
|
* Ensure that the reset has finished
|
|
|
|
*/
|
|
|
|
wait = 1000;
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-05-10 16:21:05 +00:00
|
|
|
while (--wait && !(inb(HCNTRL + iobase) & CHIPRSTACK))
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
while (--wait && !(bus_io_read_1(bc, ioh, HCNTRL) & CHIPRSTACK))
|
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
DELAY(1000);
|
|
|
|
if(wait == 0) {
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-06 05:21:13 +00:00
|
|
|
printf("ahc at 0x%lx: WARNING - Failed chip reset! "
|
1995-11-05 04:50:55 +00:00
|
|
|
"Trying to initialize anyway.\n", iobase);
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
printf("%s: WARNING - Failed chip reset! "
|
|
|
|
"Trying to initialize anyway.\n", devname);
|
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-11-05 04:50:55 +00:00
|
|
|
outb(HCNTRL + iobase, hcntrl | PAUSE);
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
bus_io_write_1(bc, ioh, HCNTRL, hcntrl | PAUSE);
|
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Look up the valid period to SCSIRATE conversion in our table.
|
|
|
|
*/
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1996-05-21 18:37:25 +00:00
|
|
|
ahc_scsirate(ahc, scsirate, period, offset, channel, target )
|
1996-01-03 06:32:12 +00:00
|
|
|
struct ahc_data *ahc;
|
1994-11-17 20:22:31 +00:00
|
|
|
u_char *scsirate;
|
1996-01-03 06:32:12 +00:00
|
|
|
short period;
|
|
|
|
u_char offset;
|
1996-05-21 18:37:25 +00:00
|
|
|
char channel;
|
1996-01-03 06:32:12 +00:00
|
|
|
int target;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1996-01-03 06:32:12 +00:00
|
|
|
int i;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
for (i = 0; i < ahc_num_syncrates; i++) {
|
1996-05-21 18:37:25 +00:00
|
|
|
u_char ultra_enb;
|
1996-05-22 15:32:28 +00:00
|
|
|
u_char sxfrctl0;
|
1996-05-21 18:37:25 +00:00
|
|
|
u_long ultra_enb_addr;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
if ((ahc_syncrates[i].period - period) >= 0) {
|
1995-10-26 23:57:18 +00:00
|
|
|
/*
|
|
|
|
* Watch out for Ultra speeds when ultra is not
|
|
|
|
* enabled and vice-versa.
|
|
|
|
*/
|
1996-05-21 18:37:25 +00:00
|
|
|
if(!(ahc->type & AHC_ULTRA)
|
|
|
|
&& (ahc_syncrates[i].sxfr & ULTRA_SXFR)) {
|
|
|
|
/*
|
|
|
|
* This should only happen if the
|
|
|
|
* drive is the first to negotiate
|
|
|
|
* and chooses a high rate. We'll
|
|
|
|
* just move down the table util
|
|
|
|
* we hit a non ultra speed.
|
|
|
|
*/
|
|
|
|
continue;
|
1995-10-26 23:57:18 +00:00
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
*scsirate = (ahc_syncrates[i].sxfr) | (offset & 0x0f);
|
1996-05-21 18:37:25 +00:00
|
|
|
/*
|
|
|
|
* Ensure Ultra mode is set properly for
|
|
|
|
* this target.
|
|
|
|
*/
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
ultra_enb_addr = ULTRA_ENB;
|
1996-05-21 18:37:25 +00:00
|
|
|
if(channel == 'B' || target > 7)
|
|
|
|
ultra_enb_addr++;
|
1996-05-30 07:19:59 +00:00
|
|
|
ultra_enb = AHC_INB(ahc, ultra_enb_addr);
|
|
|
|
sxfrctl0 = AHC_INB(ahc, SXFRCTL0);
|
1996-05-22 15:32:28 +00:00
|
|
|
if (ahc_syncrates[i].sxfr & ULTRA_SXFR) {
|
1996-05-21 18:37:25 +00:00
|
|
|
ultra_enb |= 0x01 << (target & 0x07);
|
1996-05-22 15:32:28 +00:00
|
|
|
sxfrctl0 |= ULTRAEN;
|
|
|
|
}
|
|
|
|
else {
|
1996-05-21 18:37:25 +00:00
|
|
|
ultra_enb &= ~(0x01 << (target & 0x07));
|
1996-05-22 15:32:28 +00:00
|
|
|
sxfrctl0 &= ~ULTRAEN;
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, ultra_enb_addr, ultra_enb);
|
|
|
|
AHC_OUTB(ahc, SXFRCTL0, sxfrctl0);
|
1996-05-21 18:37:25 +00:00
|
|
|
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: target %d synchronous at %sMHz,"
|
|
|
|
" offset = 0x%x\n",
|
|
|
|
ahc_name(ahc), target,
|
1995-09-05 23:52:03 +00:00
|
|
|
ahc_syncrates[i].rate, offset );
|
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1995-04-15 21:37:32 +00:00
|
|
|
/* Default to asyncronous transfers. Also reject this SDTR request. */
|
|
|
|
*scsirate = 0;
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: target %d using asyncronous transfers\n",
|
|
|
|
ahc_name(ahc), target );
|
1995-09-05 23:52:03 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
int
|
|
|
|
ahcprint(aux, name)
|
|
|
|
void *aux;
|
|
|
|
char *name;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (name != NULL)
|
|
|
|
printf("%s: scsibus ", name);
|
|
|
|
return UNCONF;
|
|
|
|
}
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach all the sub-devices we can find
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
int
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_attach(ahc)
|
|
|
|
struct ahc_data *ahc;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-08-23 23:03:17 +00:00
|
|
|
struct scsibus_data *scbus;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#ifdef AHC_BROKEN_CACHE
|
|
|
|
if (cpu_class == CPUCLASS_386) /* doesn't have "wbinvd" instruction */
|
|
|
|
ahc_broken_cache = 0;
|
|
|
|
#endif
|
1995-08-23 23:03:17 +00:00
|
|
|
/*
|
1996-05-10 16:21:05 +00:00
|
|
|
* fill in the prototype scsi_links.
|
1995-08-23 23:03:17 +00:00
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc->sc_link.adapter_unit = ahc->unit;
|
1995-08-23 23:03:17 +00:00
|
|
|
ahc->sc_link.adapter_targ = ahc->our_id;
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc->sc_link.fordriver = 0;
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
ahc->sc_link.adapter_target = ahc->our_id;
|
|
|
|
#endif
|
1996-01-07 19:24:36 +00:00
|
|
|
ahc->sc_link.adapter_softc = ahc;
|
1995-08-23 23:03:17 +00:00
|
|
|
ahc->sc_link.adapter = &ahc_switch;
|
1995-03-17 23:58:27 +00:00
|
|
|
ahc->sc_link.opennings = 2;
|
1995-08-23 23:03:17 +00:00
|
|
|
ahc->sc_link.device = &ahc_dev;
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc->sc_link.flags = DEBUGLEVEL;
|
1994-11-18 20:34:30 +00:00
|
|
|
|
1996-05-10 16:21:05 +00:00
|
|
|
if(ahc->type & AHC_TWIN) {
|
|
|
|
/* Configure the second scsi bus */
|
|
|
|
ahc->sc_link_b = ahc->sc_link;
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-05-10 16:21:05 +00:00
|
|
|
ahc->sc_link_b.adapter_targ = ahc->our_id_b;
|
|
|
|
ahc->sc_link_b.adapter_bus = 1;
|
|
|
|
ahc->sc_link_b.fordriver = (void *)SELBUSB;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
ahc->sc_link_b.adapter_target = ahc->our_id_b;
|
|
|
|
#endif
|
1996-05-10 16:21:05 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
|
|
|
|
#if defined(__FreeBSD__)
|
1995-08-23 23:03:17 +00:00
|
|
|
/*
|
|
|
|
* Prepare the scsibus_data area for the upperlevel
|
|
|
|
* scsi code.
|
|
|
|
*/
|
|
|
|
scbus = scsi_alloc_bus();
|
|
|
|
if(!scbus)
|
|
|
|
return 0;
|
1996-05-10 16:21:05 +00:00
|
|
|
scbus->adapter_link = (ahc->flags & AHC_CHANNEL_B_PRIMARY) ?
|
|
|
|
&ahc->sc_link_b : &ahc->sc_link;
|
1995-08-23 23:03:17 +00:00
|
|
|
if(ahc->type & AHC_WIDE)
|
|
|
|
scbus->maxtarg = 15;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ask the adapter what subunits are present
|
|
|
|
*/
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose)
|
1996-05-10 16:21:05 +00:00
|
|
|
printf("ahc%d: Probing channel %c\n", ahc->unit,
|
|
|
|
(ahc->flags & AHC_CHANNEL_B_PRIMARY) ? 'B' : 'A');
|
1995-08-23 23:03:17 +00:00
|
|
|
scsi_attachdevs(scbus);
|
|
|
|
scbus = NULL; /* Upper-level SCSI code owns this now */
|
1996-05-10 16:21:05 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
if(ahc->type & AHC_TWIN) {
|
1995-08-23 23:03:17 +00:00
|
|
|
scbus = scsi_alloc_bus();
|
|
|
|
if(!scbus)
|
|
|
|
return 0;
|
1996-05-10 16:21:05 +00:00
|
|
|
scbus->adapter_link = (ahc->flags & AHC_CHANNEL_B_PRIMARY) ?
|
|
|
|
&ahc->sc_link : &ahc->sc_link_b;
|
1995-08-23 23:03:17 +00:00
|
|
|
if(ahc->type & AHC_WIDE)
|
|
|
|
scbus->maxtarg = 15;
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose)
|
1996-05-10 16:21:05 +00:00
|
|
|
printf("ahc%d: Probing Channel %c\n", ahc->unit,
|
|
|
|
(ahc->flags & AHC_CHANNEL_B_PRIMARY) ? 'A': 'B');
|
1995-08-23 23:03:17 +00:00
|
|
|
scsi_attachdevs(scbus);
|
|
|
|
scbus = NULL; /* Upper-level SCSI code owns this now */
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
/*
|
|
|
|
* XXX - Update MI SCSI code
|
|
|
|
*
|
|
|
|
* if(ahc->type & AHC_WIDE)
|
|
|
|
* max target of both channel A and B = 15;
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ask the adapter what subunits are present
|
|
|
|
*/
|
|
|
|
if ((ahc->flags & AHC_CHANNEL_B_PRIMARY) == 0) {
|
|
|
|
/* make IS_SCSIBUS_B() == false, while probing channel A */
|
|
|
|
ahc->sc_link_b.scsibus = 0xff;
|
|
|
|
|
|
|
|
if (ahc->type & AHC_TWIN)
|
|
|
|
printf("%s: Probing channel A\n", ahc_name(ahc));
|
|
|
|
config_found((void *)ahc, &ahc->sc_link, ahcprint);
|
|
|
|
if (ahc->type & AHC_TWIN) {
|
|
|
|
printf("%s: Probing channel B\n", ahc_name(ahc));
|
|
|
|
config_found((void *)ahc, &ahc->sc_link_b, ahcprint);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* if implementation of IS_SCSIBUS_B() is changed to use
|
|
|
|
* ahc->sc_link.scsibus, then "ahc->sc_link.scsibus = 0xff;"
|
|
|
|
* is needed, here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* assert(ahc->type & AHC_TWIN); */
|
|
|
|
printf("%s: Probing channel B\n", ahc_name(ahc));
|
|
|
|
config_found((void *)ahc, &ahc->sc_link_b, ahcprint);
|
|
|
|
printf("%s: Probing channel A\n", ahc_name(ahc));
|
|
|
|
config_found((void *)ahc, &ahc->sc_link, ahcprint);
|
|
|
|
}
|
|
|
|
#endif
|
1995-08-23 23:03:17 +00:00
|
|
|
return 1;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/*
|
|
|
|
* Send an SCB down to the card via PIO.
|
|
|
|
* We assume that the proper SCB is already selected in SCBPTR.
|
|
|
|
*/
|
1996-01-29 03:17:39 +00:00
|
|
|
static inline void
|
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
|
|
|
ahc_send_scb(ahc, scb)
|
1996-01-29 03:17:39 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
struct scb *scb;
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBCNT, SCBAUTO);
|
1996-04-20 21:29:27 +00:00
|
|
|
if( ahc->type == AHC_284 )
|
|
|
|
/* Can only do 8bit PIO */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTSB(ahc, SCBARRAY, scb, SCB_PIO_TRANSFER_SIZE);
|
1996-04-20 21:29:27 +00:00
|
|
|
else
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTSL(ahc, SCBARRAY, scb,
|
1996-04-20 21:29:27 +00:00
|
|
|
(SCB_PIO_TRANSFER_SIZE + 3) / 4);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBCNT, 0);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/*
|
|
|
|
* Retrieve an SCB from the card via PIO.
|
|
|
|
* We assume that the proper SCB is already selected in SCBPTR.
|
|
|
|
*/
|
1996-01-29 03:17:39 +00:00
|
|
|
static inline void
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc_fetch_scb(ahc, scb)
|
1996-01-29 03:17:39 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
struct scb *scb;
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBCNT, 0x80); /* SCBAUTO */
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-04-28 19:21:20 +00:00
|
|
|
/* Can only do 8bit PIO for reads */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_INSB(ahc, SCBARRAY, scb, SCB_PIO_TRANSFER_SIZE);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBCNT, 0);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/*
|
|
|
|
* Swap in_scbp for out_scbp down in the cards SCB array.
|
|
|
|
* We assume that the SCB for out_scbp is already selected in SCBPTR.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
ahc_page_scb(ahc, out_scbp, in_scbp)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
struct scb *out_scbp;
|
|
|
|
struct scb *in_scbp;
|
|
|
|
{
|
|
|
|
/* Page-out */
|
|
|
|
ahc_fetch_scb(ahc, out_scbp);
|
|
|
|
out_scbp->flags |= SCB_PAGED_OUT;
|
|
|
|
if(!(out_scbp->control & TAG_ENB))
|
|
|
|
{
|
|
|
|
/* Stick in non-tagged array */
|
|
|
|
int index = (out_scbp->tcl >> 4)
|
|
|
|
| (out_scbp->tcl & SELBUSB);
|
|
|
|
ahc->pagedout_ntscbs[index] = out_scbp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Page-in */
|
|
|
|
in_scbp->position = out_scbp->position;
|
|
|
|
out_scbp->position = SCB_LIST_NULL;
|
|
|
|
ahc_send_scb(ahc, in_scbp);
|
|
|
|
in_scbp->flags &= ~SCB_PAGED_OUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ahc_run_waiting_queues(ahc)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
{
|
|
|
|
struct scb* scb;
|
|
|
|
u_char cur_scb;
|
|
|
|
|
|
|
|
if(!(ahc->assigned_scbs.stqh_first || ahc->waiting_scbs.stqh_first))
|
|
|
|
return;
|
|
|
|
|
|
|
|
PAUSE_SEQUENCER(ahc);
|
1996-05-30 07:19:59 +00:00
|
|
|
cur_scb = AHC_INB(ahc, SCBPTR);
|
1996-04-20 21:29:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First handle SCBs that are waiting but have been
|
|
|
|
* assigned a slot.
|
|
|
|
*/
|
|
|
|
while((scb = ahc->assigned_scbs.stqh_first) != NULL) {
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->assigned_scbs, links);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc_send_scb(ahc, scb);
|
1996-04-28 19:21:20 +00:00
|
|
|
|
|
|
|
/* Mark this as an active command */
|
|
|
|
scb->flags = SCB_ACTIVE;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, QINFIFO, scb->position);
|
1996-04-20 21:29:27 +00:00
|
|
|
if (!(scb->xs->flags & SCSI_NOMASK)) {
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb,
|
|
|
|
(scb->xs->timeout * hz) / 1000);
|
|
|
|
}
|
|
|
|
SC_DEBUG(scb->xs->sc_link, SDEV_DB3, ("cmd_sent\n"));
|
|
|
|
}
|
|
|
|
/* Now deal with SCBs that require paging */
|
|
|
|
if((scb = ahc->waiting_scbs.stqh_first) != NULL) {
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char disc_scb = AHC_INB(ahc, DISCONNECTED_SCBH);
|
|
|
|
u_char active = AHC_INB(ahc, FLAGS) & (SELECTED|IDENTIFY_SEEN);
|
1996-04-20 21:29:27 +00:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
u_char next_scb;
|
|
|
|
|
|
|
|
/* Attempt to page this SCB in */
|
|
|
|
if(disc_scb == SCB_LIST_NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance disc_scb to the next on in the
|
|
|
|
* list.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, disc_scb);
|
|
|
|
next_scb = AHC_INB(ahc, SCB_NEXT);
|
1996-04-20 21:29:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to be careful about when we allow
|
|
|
|
* an SCB to be paged out. There must always
|
|
|
|
* be at least one slot availible for a
|
|
|
|
* reconnecting target in case it references
|
|
|
|
* an SCB that has been paged out. Our
|
|
|
|
* heuristic is that either the disconnected
|
|
|
|
* list has at least two entries in it or
|
|
|
|
* there is one entry and the sequencer is
|
|
|
|
* activily working on an SCB which implies that
|
|
|
|
* it will either complete or disconnect before
|
|
|
|
* another reconnection can occur.
|
|
|
|
*/
|
|
|
|
if((next_scb != SCB_LIST_NULL) || active)
|
|
|
|
{
|
|
|
|
u_char out_scbi;
|
|
|
|
struct scb* out_scbp;
|
|
|
|
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->waiting_scbs, links);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the in-core SCB for the one
|
|
|
|
* we're paging out.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
out_scbi = AHC_INB(ahc, SCB_TAG);
|
1996-04-20 21:29:27 +00:00
|
|
|
out_scbp = ahc->scbarray[out_scbi];
|
|
|
|
|
|
|
|
/* Do the page out */
|
|
|
|
ahc_page_scb(ahc, out_scbp, scb);
|
|
|
|
|
1996-04-28 19:21:20 +00:00
|
|
|
/* Mark this as an active command */
|
|
|
|
scb->flags = SCB_ACTIVE;
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/* Queue the command */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, QINFIFO, scb->position);
|
1996-04-20 21:29:27 +00:00
|
|
|
if (!(scb->xs->flags & SCSI_NOMASK)) {
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb,
|
|
|
|
(scb->xs->timeout * hz) / 1000);
|
|
|
|
}
|
|
|
|
SC_DEBUG(scb->xs->sc_link, SDEV_DB3,
|
|
|
|
("cmd_paged-in\n"));
|
|
|
|
count++;
|
|
|
|
|
|
|
|
/* Advance to the next disconnected SCB */
|
|
|
|
disc_scb = next_scb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} while((scb = ahc->waiting_scbs.stqh_first) != NULL);
|
|
|
|
|
|
|
|
if(count) {
|
|
|
|
/*
|
|
|
|
* Update the head of the disconnected list.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, DISCONNECTED_SCBH, disc_scb);
|
1996-04-20 21:29:27 +00:00
|
|
|
if(disc_scb != SCB_LIST_NULL) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, disc_scb);
|
|
|
|
AHC_OUTB(ahc, SCB_PREV, SCB_LIST_NULL);
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Restore old position */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, cur_scb);
|
1996-04-20 21:29:27 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
}
|
|
|
|
|
1995-07-31 08:25:36 +00:00
|
|
|
/*
|
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
|
|
|
* Add this SCB to the head of the "waiting for selection" list.
|
1995-07-31 08:25:36 +00:00
|
|
|
*/
|
|
|
|
static
|
1996-05-30 07:19:59 +00:00
|
|
|
void ahc_add_waiting_scb(ahc, scb)
|
|
|
|
struct ahc_data *ahc;
|
1995-07-31 08:25:36 +00:00
|
|
|
struct scb *scb;
|
|
|
|
{
|
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
|
|
|
u_char next;
|
1995-07-31 08:25:36 +00:00
|
|
|
u_char curscb;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
curscb = AHC_INB(ahc, SCBPTR);
|
|
|
|
next = AHC_INB(ahc, WAITING_SCBH);
|
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
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
|
|
|
AHC_OUTB(ahc, SCB_NEXT, next);
|
|
|
|
AHC_OUTB(ahc, WAITING_SCBH, scb->position);
|
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
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, curscb);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
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
|
|
|
* Catch an interrupt from the adapter
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-01-23 21:48:28 +00:00
|
|
|
void
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined (__NetBSD__)
|
|
|
|
int
|
|
|
|
#endif
|
1996-01-23 21:48:28 +00:00
|
|
|
ahc_intr(arg)
|
1995-11-05 04:50:55 +00:00
|
|
|
void *arg;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
|
|
|
int intstat;
|
|
|
|
u_char status;
|
1996-05-30 07:19:59 +00:00
|
|
|
struct scb *scb;
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
struct ahc_data *ahc = (struct ahc_data *)arg;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
intstat = AHC_INB(ahc, INTSTAT);
|
1995-03-31 13:54:41 +00:00
|
|
|
/*
|
|
|
|
* Is this interrupt for me? or for
|
|
|
|
* someone who is sharing my interrupt
|
|
|
|
*/
|
|
|
|
if (!(intstat & INT_PEND))
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-01-23 21:48:28 +00:00
|
|
|
return;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
return 0;
|
|
|
|
#endif
|
1995-11-05 04:50:55 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
if (intstat & BRKADRINT) {
|
1994-11-17 20:22:31 +00:00
|
|
|
/* We upset the sequencer :-( */
|
|
|
|
|
|
|
|
/* Lookup the error message */
|
1996-05-30 07:19:59 +00:00
|
|
|
int i, error = AHC_INB(ahc, ERROR);
|
1994-11-17 20:22:31 +00:00
|
|
|
int num_errors = sizeof(hard_error)/sizeof(hard_error[0]);
|
|
|
|
for(i = 0; error != 1 && i < num_errors; i++)
|
|
|
|
error >>= 1;
|
1996-05-30 07:19:59 +00:00
|
|
|
panic("%s: brkadrint, %s at seqaddr = 0x%x\n",
|
|
|
|
ahc_name(ahc), hard_error[i].errmesg,
|
|
|
|
(AHC_INB(ahc, SEQADDR1) << 8) |
|
|
|
|
AHC_INB(ahc, SEQADDR0));
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
if (intstat & SEQINT) {
|
|
|
|
u_short targ_mask;
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char target = (AHC_INB(ahc, SCSIID) >> 4) & 0x0f;
|
1995-06-11 19:33:05 +00:00
|
|
|
u_char scratch_offset = target;
|
|
|
|
char channel =
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_INB(ahc, SBLKCTL) & SELBUSB ? 'B': 'A';
|
1995-06-11 19:33:05 +00:00
|
|
|
|
|
|
|
if (channel == 'B')
|
|
|
|
scratch_offset += 8;
|
|
|
|
targ_mask = (0x01 << scratch_offset);
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
switch (intstat & SEQINT_MASK) {
|
|
|
|
case NO_MATCH:
|
1996-04-20 21:29:27 +00:00
|
|
|
if(ahc->flags & AHC_PAGESCBS) {
|
|
|
|
/* SCB Page-in request */
|
1996-05-10 16:21:05 +00:00
|
|
|
u_char tag;
|
|
|
|
u_char next;
|
|
|
|
u_char disc_scb;
|
1996-04-20 21:29:27 +00:00
|
|
|
struct scb *outscb;
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char arg_1 = AHC_INB(ahc, ARG_1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We should succeed, so set this now.
|
|
|
|
* If we don't, and one of the methods
|
|
|
|
* we use to aquire an SCB calls ahc_done,
|
|
|
|
* we may wind up in our start routine
|
|
|
|
* and unpause the adapter without giving
|
|
|
|
* it the correct return value, which will
|
|
|
|
* cause a hang.
|
|
|
|
*/
|
|
|
|
AHC_OUTB(ahc, RETURN_1, SCB_PAGEDIN);
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
if(arg_1 == SCB_LIST_NULL) {
|
|
|
|
/* Non-tagged command */
|
1996-04-28 19:21:20 +00:00
|
|
|
int index = target |
|
|
|
|
(channel == 'B' ? SELBUSB : 0);
|
1996-04-20 21:29:27 +00:00
|
|
|
scb = ahc->pagedout_ntscbs[index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scb = ahc->scbarray[arg_1];
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
if(!(scb->flags & SCB_PAGED_OUT))
|
|
|
|
panic("%s: Request to page in a"
|
|
|
|
"non paged out SCB.",
|
|
|
|
ahc_name(ahc));
|
1996-04-20 21:29:27 +00:00
|
|
|
/*
|
|
|
|
* Now to pick the SCB to page out.
|
1996-04-28 19:21:20 +00:00
|
|
|
* Either take a free SCB, an assigned SCB,
|
1996-05-10 16:21:05 +00:00
|
|
|
* an SCB that just completed, the first
|
|
|
|
* one on the disconnected SCB list, or
|
|
|
|
* as a last resort a queued SCB.
|
1996-04-20 21:29:27 +00:00
|
|
|
*/
|
|
|
|
if(ahc->free_scbs.stqh_first) {
|
|
|
|
outscb = ahc->free_scbs.stqh_first;
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->free_scbs,
|
|
|
|
links);
|
|
|
|
scb->position = outscb->position;
|
|
|
|
outscb->position = SCB_LIST_NULL;
|
|
|
|
STAILQ_INSERT_HEAD(&ahc->page_scbs,
|
|
|
|
outscb, links);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc_send_scb(ahc, scb);
|
|
|
|
scb->flags &= ~SCB_PAGED_OUT;
|
1996-05-10 16:21:05 +00:00
|
|
|
goto pagein_done;
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
1996-05-10 16:21:05 +00:00
|
|
|
if(ahc->assigned_scbs.stqh_first) {
|
1996-04-28 19:21:20 +00:00
|
|
|
outscb = ahc->assigned_scbs.stqh_first;
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->assigned_scbs,
|
|
|
|
links);
|
|
|
|
scb->position = outscb->position;
|
|
|
|
outscb->position = SCB_LIST_NULL;
|
|
|
|
STAILQ_INSERT_HEAD(&ahc->waiting_scbs,
|
|
|
|
outscb, links);
|
|
|
|
outscb->flags = SCB_WAITINGQ;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
1996-04-28 19:21:20 +00:00
|
|
|
ahc_send_scb(ahc, scb);
|
|
|
|
scb->flags &= ~SCB_PAGED_OUT;
|
1996-05-10 16:21:05 +00:00
|
|
|
goto pagein_done;
|
1996-04-28 19:21:20 +00:00
|
|
|
}
|
1996-05-10 16:21:05 +00:00
|
|
|
if(intstat & CMDCMPLT) {
|
1996-04-28 19:21:20 +00:00
|
|
|
int scb_index;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRINT, CLRCMDINT);
|
|
|
|
scb_index = AHC_INB(ahc, QOUTFIFO);
|
|
|
|
if(!(AHC_INB(ahc, QOUTCNT) & ahc->qcntmask))
|
1996-04-28 19:21:20 +00:00
|
|
|
intstat &= ~CMDCMPLT;
|
|
|
|
|
|
|
|
outscb = ahc->scbarray[scb_index];
|
|
|
|
if (!outscb || !(outscb->flags & SCB_ACTIVE)) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: WARNING "
|
1996-04-28 19:21:20 +00:00
|
|
|
"no command for scb %d (cmdcmplt)\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
scb_index);
|
1996-05-10 16:21:05 +00:00
|
|
|
/* Fall through in hopes of finding another SCB */
|
1996-04-28 19:21:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
scb->position = outscb->position;
|
|
|
|
outscb->position = SCB_LIST_NULL;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
1996-04-28 19:21:20 +00:00
|
|
|
ahc_send_scb(ahc, scb);
|
|
|
|
scb->flags &= ~SCB_PAGED_OUT;
|
|
|
|
untimeout(ahc_timeout, (caddr_t)outscb);
|
|
|
|
ahc_done(ahc, outscb);
|
1996-05-10 16:21:05 +00:00
|
|
|
goto pagein_done;
|
1996-04-28 19:21:20 +00:00
|
|
|
}
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
disc_scb = AHC_INB(ahc, DISCONNECTED_SCBH);
|
1996-05-10 16:21:05 +00:00
|
|
|
if(disc_scb != SCB_LIST_NULL) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, disc_scb);
|
|
|
|
tag = AHC_INB(ahc, SCB_TAG);
|
1996-04-20 21:29:27 +00:00
|
|
|
outscb = ahc->scbarray[tag];
|
1996-05-30 07:19:59 +00:00
|
|
|
next = AHC_INB(ahc, SCB_NEXT);
|
1996-04-20 21:29:27 +00:00
|
|
|
if(next != SCB_LIST_NULL) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, next);
|
|
|
|
AHC_OUTB(ahc, SCB_PREV,
|
1996-04-20 21:29:27 +00:00
|
|
|
SCB_LIST_NULL);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, disc_scb);
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, DISCONNECTED_SCBH, next);
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc_page_scb(ahc, outscb, scb);
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
else if(AHC_INB(ahc, QINCNT) & ahc->qcntmask) {
|
1996-05-10 16:21:05 +00:00
|
|
|
/* Pull one of our queued commands as a last resort */
|
1996-05-30 07:19:59 +00:00
|
|
|
disc_scb = AHC_INB(ahc, QINFIFO);
|
|
|
|
AHC_OUTB(ahc, SCBPTR, disc_scb);
|
|
|
|
tag = AHC_INB(ahc, SCB_TAG);
|
1996-05-10 16:21:05 +00:00
|
|
|
outscb = ahc->scbarray[tag];
|
|
|
|
if((outscb->control & 0x23) != TAG_ENB) {
|
|
|
|
/*
|
|
|
|
* This is not a simple tagged command
|
|
|
|
* so its position in the queue
|
|
|
|
* matters. Take the command at the
|
|
|
|
* end of the queue instead.
|
|
|
|
*/
|
|
|
|
int i;
|
1996-05-22 15:32:28 +00:00
|
|
|
u_char saved_queue[AHC_SCB_MAX];
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char queued = AHC_INB(ahc, QINCNT) & ahc->qcntmask;
|
1996-05-10 16:21:05 +00:00
|
|
|
|
|
|
|
/* Count the command we removed already */
|
|
|
|
saved_queue[0] = disc_scb;
|
|
|
|
queued++;
|
|
|
|
|
|
|
|
/* Empty the input queue */
|
|
|
|
for (i = 1; i < queued; i++)
|
1996-05-30 07:19:59 +00:00
|
|
|
saved_queue[i] = AHC_INB(ahc, QINFIFO);
|
1996-05-10 16:21:05 +00:00
|
|
|
|
|
|
|
/* Put everyone back put the last entry */
|
|
|
|
queued--;
|
|
|
|
for (i = 0; i < queued; i++)
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, QINFIFO, saved_queue[i]);
|
1996-05-10 16:21:05 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, saved_queue[queued]);
|
|
|
|
tag = AHC_INB(ahc, SCB_TAG);
|
1996-05-10 16:21:05 +00:00
|
|
|
outscb = ahc->scbarray[tag];
|
|
|
|
}
|
|
|
|
untimeout(ahc_timeout, (caddr_t)outscb);
|
|
|
|
scb->position = outscb->position;
|
|
|
|
outscb->position = SCB_LIST_NULL;
|
|
|
|
STAILQ_INSERT_HEAD(&ahc->waiting_scbs,
|
|
|
|
outscb, links);
|
|
|
|
outscb->flags = SCB_WAITINGQ;
|
|
|
|
ahc_send_scb(ahc, scb);
|
|
|
|
scb->flags &= ~SCB_PAGED_OUT;
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
else {
|
1996-05-10 16:21:05 +00:00
|
|
|
panic("Page-in request with no candidates");
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1, 0);
|
|
|
|
}
|
1996-05-10 16:21:05 +00:00
|
|
|
pagein_done:
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
|
|
|
else {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s:%c:%d: no active SCB for "
|
1995-07-04 21:14:45 +00:00
|
|
|
"reconnecting target - "
|
1996-05-30 07:19:59 +00:00
|
|
|
"issuing ABORT\n",
|
|
|
|
ahc_name(ahc), channel, target);
|
1995-02-22 01:43:25 +00:00
|
|
|
printf("SAVED_TCL == 0x%x\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_INB(ahc, SAVED_TCL));
|
|
|
|
ahc_unbusy_target(ahc, target, channel);
|
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
|
|
|
AHC_OUTB(ahc, CLRSINT1, CLRSELTIMEO);
|
|
|
|
AHC_OUTB(ahc, RETURN_1, 0);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
break;
|
1996-05-30 07:19:59 +00:00
|
|
|
case SEND_REJECT:
|
|
|
|
{
|
|
|
|
u_char rejbyte = AHC_INB(ahc, REJBYTE);
|
|
|
|
if(( rejbyte & 0xf0) == 0x20) {
|
|
|
|
/* Tagged Message */
|
|
|
|
printf("\n%s:%c:%d: Tagged message "
|
|
|
|
"received without identify. "
|
|
|
|
"Disabling tagged commands "
|
|
|
|
"for this target.\n",
|
|
|
|
ahc_name(ahc),
|
|
|
|
channel, target);
|
|
|
|
ahc->tagenable &= ~targ_mask;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("%s:%c:%d: Warning - "
|
|
|
|
"unknown message recieved from "
|
|
|
|
"target (0x%x - 0x%x). Rejecting\n",
|
|
|
|
ahc_name(ahc), channel, target,
|
|
|
|
rejbyte,
|
|
|
|
AHC_INB(ahc, REJBYTE_EXT));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NO_IDENT:
|
|
|
|
panic("%s:%c:%d: Target did not send an IDENTIFY "
|
|
|
|
"message. SAVED_TCL == 0x%x\n",
|
|
|
|
ahc_name(ahc), channel, target,
|
|
|
|
AHC_INB(ahc, SAVED_TCL));
|
|
|
|
break;
|
|
|
|
case BAD_PHASE:
|
|
|
|
printf("%s:%c:%d: unknown scsi bus phase. "
|
|
|
|
"Attempting to continue\n",
|
|
|
|
ahc_name(ahc), channel, target);
|
|
|
|
break;
|
1996-01-03 06:32:12 +00:00
|
|
|
case SDTR_MSG:
|
1995-01-13 02:24:31 +00:00
|
|
|
{
|
1996-01-03 06:32:12 +00:00
|
|
|
short period;
|
|
|
|
u_char offset, rate;
|
1995-06-11 19:33:05 +00:00
|
|
|
u_char targ_scratch;
|
|
|
|
u_char maxoffset;
|
|
|
|
/*
|
|
|
|
* Help the sequencer to translate the
|
|
|
|
* negotiated transfer rate. Transfer is
|
|
|
|
* 1/4 the period in ns as is returned by
|
|
|
|
* the sync negotiation message. So, we must
|
1995-01-13 02:24:31 +00:00
|
|
|
* multiply by four
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
period = AHC_INB(ahc, ARG_1) << 2;
|
|
|
|
offset = AHC_INB(ahc, ACCUM);
|
|
|
|
targ_scratch = AHC_INB(ahc, TARG_SCRATCH
|
1995-06-11 19:33:05 +00:00
|
|
|
+ scratch_offset);
|
|
|
|
if(targ_scratch & WIDEXFER)
|
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
|
|
|
maxoffset = 0x08;
|
|
|
|
else
|
|
|
|
maxoffset = 0x0f;
|
1996-05-21 18:37:25 +00:00
|
|
|
ahc_scsirate(ahc, &rate, period,
|
|
|
|
MIN(offset, maxoffset),
|
|
|
|
channel, target);
|
1995-01-13 02:24:31 +00:00
|
|
|
/* Preserve the WideXfer flag */
|
1995-06-11 19:33:05 +00:00
|
|
|
targ_scratch = rate | (targ_scratch & WIDEXFER);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset,
|
1995-06-11 19:33:05 +00:00
|
|
|
targ_scratch);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSIRATE, targ_scratch);
|
1995-06-11 19:33:05 +00:00
|
|
|
if( (targ_scratch & 0x0f) == 0 )
|
1995-04-15 21:37:32 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The requested rate was so low
|
|
|
|
* that asyncronous transfers are
|
1995-05-30 08:16:23 +00:00
|
|
|
* faster (not to mention the
|
1995-04-15 21:37:32 +00:00
|
|
|
* controller won't support them),
|
|
|
|
* so we issue a message reject to
|
|
|
|
* ensure we go to asyncronous
|
|
|
|
* transfers.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1, SEND_REJ);
|
1995-04-15 21:37:32 +00:00
|
|
|
}
|
1995-01-13 02:24:31 +00:00
|
|
|
/* See if we initiated Sync Negotiation */
|
1995-06-11 19:33:05 +00:00
|
|
|
else if(ahc->sdtrpending & targ_mask)
|
1995-01-13 02:24:31 +00:00
|
|
|
{
|
1995-03-17 23:58:27 +00:00
|
|
|
/*
|
|
|
|
* Don't send an SDTR back to
|
|
|
|
* the target
|
1995-01-13 02:24:31 +00:00
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1, 0);
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
/*
|
|
|
|
* Send our own SDTR in reply
|
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if(ahc_debug & AHC_SHOWMISC)
|
|
|
|
printf("Sending SDTR!!\n");
|
|
|
|
#endif
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1, SEND_SDTR);
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-03-17 23:58:27 +00:00
|
|
|
* Negate the flags
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needsdtr &= ~targ_mask;
|
|
|
|
ahc->sdtrpending &= ~targ_mask;
|
1995-01-13 02:24:31 +00:00
|
|
|
break;
|
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
case WDTR_MSG:
|
1995-01-13 02:24:31 +00:00
|
|
|
{
|
1995-06-11 19:33:05 +00:00
|
|
|
u_char scratch, bus_width;
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
bus_width = AHC_INB(ahc, ARG_1);
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
scratch = AHC_INB(ahc, TARG_SCRATCH
|
1995-06-11 19:33:05 +00:00
|
|
|
+ scratch_offset);
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
if(ahc->wdtrpending & targ_mask)
|
1995-01-13 02:24:31 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
|
|
|
* Don't send a WDTR back to the
|
1995-01-13 02:24:31 +00:00
|
|
|
* target, since we asked first.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1, 0);
|
1995-01-13 02:24:31 +00:00
|
|
|
switch(bus_width)
|
|
|
|
{
|
|
|
|
case BUS_8_BIT:
|
1995-09-05 23:52:03 +00:00
|
|
|
scratch &= 0x7f;
|
|
|
|
break;
|
1995-01-13 02:24:31 +00:00
|
|
|
case BUS_16_BIT:
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose)
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: target "
|
1995-01-13 02:24:31 +00:00
|
|
|
"%d using 16Bit "
|
|
|
|
"transfers\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
target);
|
1995-09-05 23:52:03 +00:00
|
|
|
scratch |= 0x80;
|
|
|
|
break;
|
1996-01-03 06:32:12 +00:00
|
|
|
case BUS_32_BIT:
|
|
|
|
/*
|
|
|
|
* How can we do 32bit
|
|
|
|
* transfers on a 16bit
|
|
|
|
* bus?
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1,
|
1996-01-03 06:32:12 +00:00
|
|
|
SEND_REJ);
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: target "
|
1996-01-03 06:32:12 +00:00
|
|
|
"%d requested 32Bit "
|
|
|
|
"transfers. "
|
|
|
|
"Rejecting...\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
target);
|
1996-01-03 06:32:12 +00:00
|
|
|
break;
|
1995-09-05 23:52:03 +00:00
|
|
|
default:
|
|
|
|
break;
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Send our own WDTR in reply
|
|
|
|
*/
|
|
|
|
switch(bus_width)
|
|
|
|
{
|
|
|
|
case BUS_8_BIT:
|
|
|
|
scratch &= 0x7f;
|
|
|
|
break;
|
|
|
|
case BUS_32_BIT:
|
1996-04-20 21:29:27 +00:00
|
|
|
case BUS_16_BIT:
|
|
|
|
if(ahc->type & AHC_WIDE) {
|
1995-01-13 02:24:31 +00:00
|
|
|
/* Negotiate 16_BITS */
|
|
|
|
bus_width = BUS_16_BIT;
|
1996-04-20 21:29:27 +00:00
|
|
|
if(bootverbose)
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: "
|
1996-04-20 21:29:27 +00:00
|
|
|
"target %d "
|
|
|
|
"using 16Bit "
|
|
|
|
"transfers\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
1996-01-03 06:32:12 +00:00
|
|
|
target);
|
1996-04-20 21:29:27 +00:00
|
|
|
scratch |= 0x80;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bus_width = BUS_8_BIT;
|
1995-09-05 23:52:03 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1,
|
1995-01-13 02:24:31 +00:00
|
|
|
bus_width | SEND_WDTR);
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needwdtr &= ~targ_mask;
|
|
|
|
ahc->wdtrpending &= ~targ_mask;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset,
|
1995-06-11 19:33:05 +00:00
|
|
|
scratch);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSIRATE, scratch);
|
1995-01-13 02:24:31 +00:00
|
|
|
break;
|
|
|
|
}
|
1996-01-05 16:13:44 +00:00
|
|
|
case REJECT_MSG:
|
1995-01-16 16:33:47 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-01-16 16:33:47 +00:00
|
|
|
* What we care about here is if we had an
|
|
|
|
* outstanding SDTR or WDTR message for this
|
|
|
|
* target. If we did, this is a signal that
|
|
|
|
* the target is refusing negotiation.
|
|
|
|
*/
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 16:33:47 +00:00
|
|
|
u_char targ_scratch;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
targ_scratch = AHC_INB(ahc, TARG_SCRATCH
|
1995-06-11 19:33:05 +00:00
|
|
|
+ scratch_offset);
|
1995-01-16 16:33:47 +00:00
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
if(ahc->wdtrpending & targ_mask){
|
1995-01-16 16:33:47 +00:00
|
|
|
/* note 8bit xfers and clear flag */
|
|
|
|
targ_scratch &= 0x7f;
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needwdtr &= ~targ_mask;
|
|
|
|
ahc->wdtrpending &= ~targ_mask;
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s:%c:%d: refuses "
|
1995-01-16 16:33:47 +00:00
|
|
|
"WIDE negotiation. Using "
|
|
|
|
"8bit transfers\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
channel, target);
|
1995-01-16 16:33:47 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
else if(ahc->sdtrpending & targ_mask){
|
1995-01-27 17:37:05 +00:00
|
|
|
/* note asynch xfers and clear flag */
|
|
|
|
targ_scratch &= 0xf0;
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needsdtr &= ~targ_mask;
|
|
|
|
ahc->sdtrpending &= ~targ_mask;
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s:%c:%d: refuses "
|
1995-01-27 17:37:05 +00:00
|
|
|
"syncronous negotiation. Using "
|
|
|
|
"asyncronous transfers\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
channel, target);
|
1995-01-27 17:37:05 +00:00
|
|
|
}
|
1995-03-17 23:58:27 +00:00
|
|
|
else {
|
1995-01-27 17:37:05 +00:00
|
|
|
/*
|
|
|
|
* Otherwise, we ignore it.
|
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if(ahc_debug & AHC_SHOWMISC)
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s:%c:%d: Message "
|
|
|
|
"reject -- ignored\n",
|
|
|
|
ahc_name(ahc),
|
|
|
|
channel, target);
|
1995-03-17 23:58:27 +00:00
|
|
|
#endif
|
1995-01-27 17:37:05 +00:00
|
|
|
break;
|
1995-03-17 23:58:27 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset,
|
1995-01-16 16:33:47 +00:00
|
|
|
targ_scratch);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSIRATE, targ_scratch);
|
1995-01-16 16:33:47 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
case BAD_STATUS:
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-03-07 08:59:28 +00:00
|
|
|
int scb_index;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/* The sequencer will notify us when a command
|
|
|
|
* has an error that would be of interest to
|
|
|
|
* the kernel. This allows us to leave the sequencer
|
|
|
|
* running in the common case of command completes
|
|
|
|
* without error.
|
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
scb_index = AHC_INB(ahc, SCB_TAG);
|
1996-04-20 21:29:27 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
1995-05-01 09:49:45 +00:00
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Set the default return value to 0 (don't
|
1996-01-03 06:32:12 +00:00
|
|
|
* send sense). The sense code will change
|
1995-05-30 08:16:23 +00:00
|
|
|
* this if needed and this reduces code
|
1995-05-01 09:49:45 +00:00
|
|
|
* duplication.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, RETURN_1, 0);
|
1996-04-20 21:29:27 +00:00
|
|
|
if (!(scb && (scb->flags & SCB_ACTIVE))) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s:%c:%d: ahc_intr - referenced scb "
|
1996-04-20 21:29:27 +00:00
|
|
|
"not valid during seqint 0x%x scb(%d)\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
channel, target, intstat,
|
1996-04-20 21:29:27 +00:00
|
|
|
scb_index);
|
1994-11-17 20:22:31 +00:00
|
|
|
goto clear;
|
1995-05-01 09:49:45 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-05-01 09:49:45 +00:00
|
|
|
xs = scb->xs;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
scb->status = AHC_INB(ahc, SCB_TARGET_STATUS);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-07-31 08:25:36 +00:00
|
|
|
if((ahc_debug & AHC_SHOWSCBS)
|
|
|
|
&& xs->sc_link->target == DEBUGTARG)
|
1994-12-31 19:31:56 +00:00
|
|
|
ahc_print_scb(scb);
|
1994-11-17 20:22:31 +00:00
|
|
|
#endif
|
1996-04-20 21:29:27 +00:00
|
|
|
xs->status = scb->status;
|
|
|
|
switch(scb->status){
|
1994-12-31 19:31:56 +00:00
|
|
|
case SCSI_OK:
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Interrupted for staus of"
|
|
|
|
" 0???\n", ahc_name(ahc));
|
1994-12-31 19:31:56 +00:00
|
|
|
break;
|
|
|
|
case SCSI_CHECK:
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-07-31 08:25:36 +00:00
|
|
|
if(ahc_debug & AHC_SHOWSENSE)
|
|
|
|
{
|
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("requests Check Status\n");
|
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
#endif
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
if((xs->error == XS_NOERROR) &&
|
1994-12-31 19:31:56 +00:00
|
|
|
!(scb->flags & SCB_SENSE)) {
|
1994-11-17 20:22:31 +00:00
|
|
|
struct ahc_dma_seg *sg = scb->ahc_dma;
|
|
|
|
struct scsi_sense *sc = &(scb->sense_cmd);
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-07-31 08:25:36 +00:00
|
|
|
if(ahc_debug & AHC_SHOWSENSE)
|
|
|
|
{
|
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Sending Sense\n");
|
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
#endif
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1994-11-17 20:22:31 +00:00
|
|
|
sc->op_code = REQUEST_SENSE;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
sc->opcode = REQUEST_SENSE;
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
sc->byte2 = xs->sc_link->lun << 5;
|
|
|
|
sc->length = sizeof(struct scsi_sense_data);
|
1994-12-31 19:31:56 +00:00
|
|
|
sc->control = 0;
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
sg->addr = KVTOPHYS(&xs->sense);
|
|
|
|
sg->len = sizeof(struct scsi_sense_data);
|
1995-04-23 22:04:58 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->control &= DISCENB;
|
|
|
|
scb->status = 0;
|
1994-12-31 19:31:56 +00:00
|
|
|
scb->SG_segment_count = 1;
|
|
|
|
scb->SG_list_pointer = KVTOPHYS(sg);
|
1995-07-04 21:14:45 +00:00
|
|
|
scb->data = sg->addr;
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->datalen = sg->len;
|
1996-05-30 07:19:59 +00:00
|
|
|
#ifdef AHC_BROKEN_CACHE
|
|
|
|
if (ahc_broken_cache)
|
|
|
|
INVALIDATE_CACHE();
|
|
|
|
#endif
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->cmdpointer = KVTOPHYS(sc);
|
|
|
|
scb->cmdlen = sizeof(*sc);
|
1996-01-29 03:17:39 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->flags |= SCB_SENSE;
|
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
|
|
|
ahc_send_scb(ahc, scb);
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* Ensure that the target is "BUSY"
|
|
|
|
* so we don't get overlapping
|
|
|
|
* commands if we happen to be doing
|
|
|
|
* tagged I/O.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_busy_target(ahc, target, channel);
|
1996-01-03 06:32:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make us the next command to run
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_add_waiting_scb(ahc, scb);
|
|
|
|
AHC_OUTB(ahc, RETURN_1, SEND_SENSE);
|
1995-01-16 16:33:47 +00:00
|
|
|
break;
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Clear the SCB_SENSE Flag and have
|
|
|
|
* the sequencer do a normal command
|
|
|
|
* complete with either a "DRIVER_STUFFUP"
|
|
|
|
* error or whatever other error condition
|
|
|
|
* we already had.
|
|
|
|
*/
|
|
|
|
scb->flags &= ~SCB_SENSE;
|
|
|
|
if(xs->error == XS_NOERROR)
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
break;
|
|
|
|
case SCSI_BUSY:
|
|
|
|
xs->error = XS_BUSY;
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Target Busy\n");
|
1995-03-31 13:54:41 +00:00
|
|
|
break;
|
1995-02-22 01:43:25 +00:00
|
|
|
case SCSI_QUEUE_FULL:
|
|
|
|
/*
|
1996-05-30 07:19:59 +00:00
|
|
|
* The upper level SCSI code will someday
|
1995-03-31 13:54:41 +00:00
|
|
|
* handle this properly.
|
1995-02-22 01:43:25 +00:00
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Queue Full\n");
|
1996-04-28 19:21:20 +00:00
|
|
|
scb->flags = SCB_ASSIGNEDQ;
|
1996-04-20 21:29:27 +00:00
|
|
|
STAILQ_INSERT_TAIL(&ahc->assigned_scbs,
|
|
|
|
scb, links);
|
1995-02-22 01:43:25 +00:00
|
|
|
break;
|
1994-12-31 19:31:56 +00:00
|
|
|
default:
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
1994-12-31 19:31:56 +00:00
|
|
|
printf("unexpected targ_status: %x\n",
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->status);
|
1994-12-31 19:31:56 +00:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1995-03-31 13:54:41 +00:00
|
|
|
case RESIDUAL:
|
|
|
|
{
|
|
|
|
int scb_index;
|
1996-05-30 07:19:59 +00:00
|
|
|
scb_index = AHC_INB(ahc, SCB_TAG);
|
1995-03-31 13:54:41 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
1995-06-11 19:33:05 +00:00
|
|
|
xs = scb->xs;
|
1995-03-31 13:54:41 +00:00
|
|
|
/*
|
|
|
|
* Don't clobber valid resid info with
|
|
|
|
* a resid coming from a check sense
|
|
|
|
* operation.
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
if(!(scb->flags & SCB_SENSE)) {
|
1996-01-03 06:32:12 +00:00
|
|
|
int resid_sgs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remainder of the SG where the transfer
|
|
|
|
* stopped.
|
|
|
|
*/
|
1996-03-31 03:15:31 +00:00
|
|
|
xs->resid =
|
1996-05-30 07:19:59 +00:00
|
|
|
(AHC_INB(ahc, SCB_RESID_DCNT2)<<16) |
|
|
|
|
(AHC_INB(ahc, SCB_RESID_DCNT1)<<8) |
|
|
|
|
AHC_INB(ahc, SCB_RESID_DCNT0);
|
1996-01-03 06:32:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add up the contents of all residual
|
|
|
|
* SG segments that are after the SG where
|
|
|
|
* the transfer stopped.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
resid_sgs = AHC_INB(ahc, SCB_RESID_SGCNT) - 1;
|
1996-01-03 06:32:12 +00:00
|
|
|
while(resid_sgs > 0) {
|
|
|
|
int sg;
|
|
|
|
|
|
|
|
sg = scb->SG_segment_count - resid_sgs;
|
1996-03-31 03:15:31 +00:00
|
|
|
xs->resid += scb->ahc_dma[sg].len;
|
1996-01-03 06:32:12 +00:00
|
|
|
resid_sgs--;
|
|
|
|
}
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1995-06-11 19:33:05 +00:00
|
|
|
xs->flags |= SCSI_RESID_VALID;
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
/* XXX - Update to do this right */
|
|
|
|
#endif
|
1995-04-23 22:04:58 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-07-31 08:25:36 +00:00
|
|
|
if(ahc_debug & AHC_SHOWMISC) {
|
|
|
|
sc_print_addr(xs->sc_link);
|
1995-11-06 05:21:13 +00:00
|
|
|
printf("Handled Residual of %ld bytes\n"
|
1996-03-31 03:15:31 +00:00
|
|
|
,xs->resid);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
#endif
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-03-31 13:54:41 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-04-01 19:53:04 +00:00
|
|
|
case ABORT_TAG:
|
|
|
|
{
|
1996-04-20 21:29:27 +00:00
|
|
|
int scb_index;
|
1996-05-30 07:19:59 +00:00
|
|
|
scb_index = AHC_INB(ahc, SCB_TAG);
|
1995-04-01 19:53:04 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
1995-06-11 19:33:05 +00:00
|
|
|
xs = scb->xs;
|
1995-04-01 19:53:04 +00:00
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* We didn't recieve a valid tag back from
|
1995-04-01 19:53:04 +00:00
|
|
|
* the target on a reconnect.
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("invalid tag recieved -- sending ABORT_TAG\n");
|
1996-03-31 03:15:31 +00:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
1995-04-01 19:53:04 +00:00
|
|
|
untimeout(ahc_timeout, (caddr_t)scb);
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_done(ahc, scb);
|
1995-04-01 19:53:04 +00:00
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
case AWAITING_MSG:
|
|
|
|
{
|
|
|
|
int scb_index;
|
1996-05-30 07:19:59 +00:00
|
|
|
scb_index = AHC_INB(ahc, SCB_TAG);
|
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
|
|
|
scb = ahc->scbarray[scb_index];
|
|
|
|
/*
|
|
|
|
* This SCB had a zero length command, informing
|
|
|
|
* the sequencer that we wanted to send a special
|
|
|
|
* message to this target. We only do this for
|
|
|
|
* BUS_DEVICE_RESET messages currently.
|
|
|
|
*/
|
|
|
|
if(scb->flags & SCB_DEVICE_RESET)
|
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, MSG0,
|
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
|
|
|
MSG_BUS_DEVICE_RESET);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, MSG_LEN, 1);
|
1996-04-28 19:21:20 +00:00
|
|
|
printf("Bus Device Reset Message Sent\n");
|
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
|
|
|
}
|
|
|
|
else
|
1996-01-29 03:17:39 +00:00
|
|
|
panic("ahc_intr: AWAITING_MSG for an SCB that "
|
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
|
|
|
"does not have a waiting message");
|
|
|
|
break;
|
|
|
|
}
|
1995-07-31 08:25:36 +00:00
|
|
|
case IMMEDDONE:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Take care of device reset messages
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char scbindex = AHC_INB(ahc, SCB_TAG);
|
1995-07-31 08:25:36 +00:00
|
|
|
scb = ahc->scbarray[scbindex];
|
|
|
|
if(scb->flags & SCB_DEVICE_RESET) {
|
|
|
|
u_char targ_scratch;
|
|
|
|
int found;
|
|
|
|
/*
|
|
|
|
* Go back to async/narrow transfers and
|
|
|
|
* renegotiate.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_unbusy_target(ahc, target, channel);
|
1995-07-31 08:25:36 +00:00
|
|
|
ahc->needsdtr |= ahc->needsdtr_orig & targ_mask;
|
|
|
|
ahc->needwdtr |= ahc->needwdtr_orig & targ_mask;
|
|
|
|
ahc->sdtrpending &= ~targ_mask;
|
|
|
|
ahc->wdtrpending &= ~targ_mask;
|
1996-05-30 07:19:59 +00:00
|
|
|
targ_scratch = AHC_INB(ahc, TARG_SCRATCH
|
1995-07-31 08:25:36 +00:00
|
|
|
+ scratch_offset);
|
|
|
|
targ_scratch &= SXFR;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset,
|
1995-07-31 08:25:36 +00:00
|
|
|
targ_scratch);
|
1996-01-03 06:32:12 +00:00
|
|
|
found = ahc_reset_device(ahc, target,
|
1995-07-31 08:25:36 +00:00
|
|
|
channel, SCB_LIST_NULL,
|
|
|
|
XS_NOERROR);
|
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
|
|
|
sc_print_addr(scb->xs->sc_link);
|
|
|
|
printf("Bus Device Reset delivered. "
|
|
|
|
"%d SCBs aborted\n", found);
|
|
|
|
ahc->in_timeout = FALSE;
|
|
|
|
ahc_run_done_queue(ahc);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
else
|
1996-01-23 21:48:28 +00:00
|
|
|
panic("ahc_intr: Immediate complete for "
|
1995-07-31 08:25:36 +00:00
|
|
|
"unknown operation.");
|
|
|
|
break;
|
|
|
|
}
|
1996-06-09 17:33:18 +00:00
|
|
|
case DATA_OVERRUN:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* When the sequencer detects an overrun, it
|
|
|
|
* sets STCNT to 0x00ffffff and allows the
|
|
|
|
* target to complete its transfer in
|
|
|
|
* BITBUCKET mode.
|
|
|
|
*/
|
|
|
|
u_char scbindex = AHC_INB(ahc, SCB_TAG);
|
|
|
|
u_int32_t overrun;
|
|
|
|
scb = ahc->scbarray[scbindex];
|
|
|
|
overrun = AHC_INB(ahc, STCNT0)
|
|
|
|
| (AHC_INB(ahc, STCNT1) << 8)
|
|
|
|
| (AHC_INB(ahc, STCNT2) << 16);
|
|
|
|
overrun = 0x00ffffff - overrun;
|
|
|
|
sc_print_addr(scb->xs->sc_link);
|
|
|
|
printf("data overrun of %d bytes detected."
|
|
|
|
" Forcing a retry.\n", overrun);
|
|
|
|
/*
|
|
|
|
* Set this and it will take affect when the
|
|
|
|
* target does a command complete.
|
|
|
|
*/
|
|
|
|
scb->xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
break;
|
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
#if NOT_YET
|
|
|
|
/* XXX Fill these in later */
|
|
|
|
case MESG_BUFFER_BUSY:
|
|
|
|
break;
|
|
|
|
case MSGIN_PHASEMIS:
|
|
|
|
break;
|
|
|
|
#endif
|
1996-03-31 03:15:31 +00:00
|
|
|
default:
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("ahc_intr: seqint, "
|
1996-03-31 03:15:31 +00:00
|
|
|
"intstat == 0x%x, scsisigi = 0x%x\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
intstat, AHC_INB(ahc, SCSISIGI));
|
1996-03-31 03:15:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
clear:
|
|
|
|
/*
|
|
|
|
* Clear the upper byte that holds SEQINT status
|
|
|
|
* codes and clear the SEQINT bit.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSEQINT);
|
1996-03-31 03:15:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The sequencer is paused immediately on
|
|
|
|
* a SEQINT, so we should restart it when
|
|
|
|
* we leave this section.
|
|
|
|
*/
|
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (intstat & SCSIINT) {
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
int scb_index = AHC_INB(ahc, SCB_TAG);
|
|
|
|
status = AHC_INB(ahc, SSTAT1);
|
1996-03-31 03:15:31 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
|
|
|
|
|
|
|
if (status & SCSIRSTI) {
|
|
|
|
char channel;
|
1996-05-30 07:19:59 +00:00
|
|
|
channel = AHC_INB(ahc, SBLKCTL);
|
1996-03-31 03:15:31 +00:00
|
|
|
channel = channel & SELBUSB ? 'B' : 'A';
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Someone reset channel %c\n",
|
|
|
|
ahc_name(ahc), channel);
|
1996-03-31 03:15:31 +00:00
|
|
|
ahc_reset_channel(ahc,
|
|
|
|
channel,
|
|
|
|
SCB_LIST_NULL,
|
|
|
|
XS_BUSY,
|
|
|
|
/* Initiate Reset */FALSE);
|
1996-04-20 21:29:27 +00:00
|
|
|
scb = NULL;
|
|
|
|
}
|
|
|
|
else if (!(scb && (scb->flags & SCB_ACTIVE))){
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: ahc_intr - referenced scb not "
|
1996-04-20 21:29:27 +00:00
|
|
|
"valid during scsiint 0x%x scb(%d)\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc), status, scb_index);
|
|
|
|
AHC_OUTB(ahc, CLRSINT1, status);
|
1996-04-20 21:29:27 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
1996-04-20 21:29:27 +00:00
|
|
|
scb = NULL;
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
else if (status & SCSIPERR) {
|
1996-01-29 03:17:39 +00:00
|
|
|
/*
|
|
|
|
* Determine the bus phase and
|
|
|
|
* queue an appropriate message
|
|
|
|
*/
|
|
|
|
char *phase;
|
|
|
|
u_char mesg_out = MSG_NOP;
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char lastphase = AHC_INB(ahc, LASTPHASE);
|
1996-01-29 03:17:39 +00:00
|
|
|
|
1996-05-21 18:37:25 +00:00
|
|
|
xs = scb->xs;
|
1996-03-31 03:15:31 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
1996-01-29 03:17:39 +00:00
|
|
|
|
|
|
|
switch(lastphase) {
|
|
|
|
case P_DATAOUT:
|
|
|
|
phase = "Data-Out";
|
|
|
|
break;
|
|
|
|
case P_DATAIN:
|
|
|
|
phase = "Data-In";
|
|
|
|
mesg_out = MSG_INITIATOR_DET_ERROR;
|
|
|
|
break;
|
|
|
|
case P_COMMAND:
|
|
|
|
phase = "Command";
|
|
|
|
break;
|
|
|
|
case P_MESGOUT:
|
|
|
|
phase = "Message-Out";
|
|
|
|
break;
|
|
|
|
case P_STATUS:
|
|
|
|
phase = "Status";
|
|
|
|
mesg_out = MSG_INITIATOR_DET_ERROR;
|
|
|
|
break;
|
|
|
|
case P_MESGIN:
|
|
|
|
phase = "Message-In";
|
|
|
|
mesg_out = MSG_MSG_PARITY_ERROR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
phase = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("parity error during %s phase.\n", phase);
|
|
|
|
|
|
|
|
/*
|
1996-06-08 06:55:01 +00:00
|
|
|
* We've set the hardware to assert ATN if we
|
|
|
|
* get a parity error on "in" phases, so all we
|
|
|
|
* need to do is stuff the message buffer with
|
1996-05-30 07:19:59 +00:00
|
|
|
* the appropriate message. "In" phases have set
|
1996-01-29 03:17:39 +00:00
|
|
|
* mesg_out to something other than MSG_NOP.
|
|
|
|
*/
|
|
|
|
if(mesg_out != MSG_NOP) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, MSG0, mesg_out);
|
|
|
|
AHC_OUTB(ahc, MSG_LEN, 1);
|
1996-01-29 03:17:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
/*
|
|
|
|
* Should we allow the target to make
|
|
|
|
* this decision for us?
|
|
|
|
*/
|
1996-03-31 03:15:31 +00:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
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
|
|
|
}
|
1996-03-31 03:15:31 +00:00
|
|
|
else if (status & SELTO) {
|
1995-04-27 17:47:17 +00:00
|
|
|
u_char waiting;
|
1995-01-13 02:24:31 +00:00
|
|
|
u_char flags;
|
1996-05-21 18:37:25 +00:00
|
|
|
|
|
|
|
xs = scb->xs;
|
1996-05-22 15:32:28 +00:00
|
|
|
xs->error = XS_SELTIMEOUT;
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* Clear any pending messages for the timed out
|
|
|
|
* target, and mark the target as free
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
flags = AHC_INB(ahc, FLAGS);
|
|
|
|
AHC_OUTB(ahc, MSG_LEN, 0);
|
|
|
|
ahc_unbusy_target(ahc, xs->sc_link->target,
|
|
|
|
#if defined(__FreeBSD__)
|
1995-07-31 08:25:36 +00:00
|
|
|
((long)xs->sc_link->fordriver & SELBUSB)
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
IS_SCSIBUS_B(ahc, xs->sc_link)
|
|
|
|
#endif
|
|
|
|
? 'B' : 'A');
|
1996-05-31 06:32:09 +00:00
|
|
|
/* Stop the selection */
|
|
|
|
AHC_OUTB(ahc, SCSISEQ, 0);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
1995-01-16 16:33:47 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRSINT1, CLRSELTIMEO);
|
1995-01-16 16:33:47 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
1995-04-27 17:47:17 +00:00
|
|
|
|
|
|
|
/* Shift the waiting for selection queue forward */
|
1996-05-30 07:19:59 +00:00
|
|
|
waiting = AHC_INB(ahc, WAITING_SCBH);
|
|
|
|
AHC_OUTB(ahc, SCBPTR, waiting);
|
|
|
|
waiting = AHC_INB(ahc, SCB_NEXT);
|
|
|
|
AHC_OUTB(ahc, WAITING_SCBH, waiting);
|
1995-04-27 17:47:17 +00:00
|
|
|
|
1996-03-31 03:15:31 +00:00
|
|
|
RESTART_SEQUENCER(ahc);
|
|
|
|
}
|
|
|
|
else if (!(status & BUSFREE)) {
|
1996-05-30 07:19:59 +00:00
|
|
|
sc_print_addr(scb->xs->sc_link);
|
1996-03-31 03:15:31 +00:00
|
|
|
printf("Unknown SCSIINT. Status = 0x%x\n", status);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRSINT1, status);
|
1996-03-31 03:15:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb = NULL;
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
if(scb != NULL) {
|
|
|
|
/* We want to process the command */
|
1996-03-31 03:15:31 +00:00
|
|
|
untimeout(ahc_timeout, (caddr_t)scb);
|
|
|
|
ahc_done(ahc, scb);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
if (intstat & CMDCMPLT) {
|
|
|
|
int scb_index;
|
|
|
|
|
|
|
|
do {
|
1996-05-30 07:19:59 +00:00
|
|
|
scb_index = AHC_INB(ahc, QOUTFIFO);
|
1996-03-31 03:15:31 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
|
|
|
if (!scb || !(scb->flags & SCB_ACTIVE)) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: WARNING "
|
1996-03-31 03:15:31 +00:00
|
|
|
"no command for scb %d (cmdcmplt)\n"
|
1994-12-31 19:31:56 +00:00
|
|
|
"QOUTCNT == %d\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc), scb_index,
|
|
|
|
AHC_INB(ahc, QOUTCNT));
|
|
|
|
AHC_OUTB(ahc, CLRINT, CLRCMDINT);
|
1996-03-31 03:15:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRINT, CLRCMDINT);
|
1996-03-31 03:15:31 +00:00
|
|
|
untimeout(ahc_timeout, (caddr_t)scb);
|
|
|
|
ahc_done(ahc, scb);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
} while (AHC_INB(ahc, QOUTCNT) & ahc->qcntmask);
|
1996-04-28 19:21:20 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc_run_waiting_queues(ahc);
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
return 1;
|
|
|
|
#endif
|
1995-11-04 14:43:30 +00:00
|
|
|
}
|
1995-07-04 21:14:45 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* We have a scb which has been processed by the
|
|
|
|
* adaptor, now we look to see how the operation
|
|
|
|
* went.
|
|
|
|
*/
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_done(ahc, scb)
|
|
|
|
struct ahc_data *ahc;
|
1996-03-31 03:15:31 +00:00
|
|
|
struct scb *scb;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1996-03-31 03:15:31 +00:00
|
|
|
struct scsi_xfer *xs = scb->xs;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-03-31 03:15:31 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_done\n"));
|
|
|
|
/*
|
|
|
|
* Put the results of the operation
|
|
|
|
* into the xfer and call whoever started it
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
if (xs->error != XS_NOERROR) {
|
|
|
|
/* Don't override the error value. */
|
|
|
|
} else if (scb->flags & SCB_ABORTED) {
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
} else
|
|
|
|
#endif
|
1994-12-31 19:31:56 +00:00
|
|
|
if(scb->flags & SCB_SENSE)
|
|
|
|
xs->error = XS_SENSE;
|
1996-04-28 19:21:20 +00:00
|
|
|
if(scb->flags & SCB_SENTORDEREDTAG)
|
|
|
|
ahc->in_timeout = FALSE;
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-03-31 03:15:31 +00:00
|
|
|
if ((xs->flags & SCSI_ERR_OK) && !(xs->error == XS_SENSE)) {
|
1994-11-17 20:22:31 +00:00
|
|
|
/* All went correctly OR errors expected */
|
1996-03-31 03:15:31 +00:00
|
|
|
xs->error = XS_NOERROR;
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
/*
|
|
|
|
* Since NetBSD doesn't have error ignoring operation mode
|
|
|
|
* (SCSI_ERR_OK in FreeBSD), we don't have to care this case.
|
|
|
|
*/
|
|
|
|
#endif
|
1996-03-31 03:15:31 +00:00
|
|
|
xs->flags |= ITSDONE;
|
1996-04-28 19:21:20 +00:00
|
|
|
#ifdef AHC_TAGENABLE
|
1996-05-30 07:19:59 +00:00
|
|
|
if(xs->cmd->opcode == INQUIRY && xs->error == XS_NOERROR)
|
1995-02-22 01:43:25 +00:00
|
|
|
{
|
|
|
|
struct scsi_inquiry_data *inq_data;
|
|
|
|
u_short mask = 0x01 << (xs->sc_link->target |
|
1996-04-20 21:29:27 +00:00
|
|
|
(scb->tcl & 0x08));
|
1995-02-22 01:43:25 +00:00
|
|
|
/*
|
|
|
|
* Sneak a look at the results of the SCSI Inquiry
|
|
|
|
* command and see if we can do Tagged queing. This
|
|
|
|
* should really be done by the higher level drivers.
|
|
|
|
*/
|
|
|
|
inq_data = (struct scsi_inquiry_data *)xs->data;
|
1996-01-03 06:32:12 +00:00
|
|
|
if((inq_data->flags & SID_CmdQue) && !(ahc->tagenable & mask))
|
1995-02-22 01:43:25 +00:00
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: target %d Tagged Queuing Device\n",
|
|
|
|
ahc_name(ahc), xs->sc_link->target);
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->tagenable |= mask;
|
1996-04-20 21:29:27 +00:00
|
|
|
if(ahc->maxhscbs >= 16 || (ahc->flags & AHC_PAGESCBS)) {
|
|
|
|
/* Default to 8 tags */
|
1996-04-22 13:21:40 +00:00
|
|
|
xs->sc_link->opennings += 6;
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Default to 4 tags on whimpy
|
|
|
|
* cards that don't have much SCB
|
|
|
|
* space and can't page. This prevents
|
|
|
|
* a single device from hogging all
|
|
|
|
* slots. We should really have a better
|
|
|
|
* way of providing fairness.
|
|
|
|
*/
|
|
|
|
xs->sc_link->opennings += 2;
|
|
|
|
}
|
1995-02-22 01:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
1996-04-28 19:21:20 +00:00
|
|
|
#endif
|
1996-03-31 03:15:31 +00:00
|
|
|
ahc_free_scb(ahc, scb, xs->flags);
|
|
|
|
scsi_done(xs);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the board, ready for normal operation
|
|
|
|
*/
|
1995-11-05 04:50:55 +00:00
|
|
|
int
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_init(ahc)
|
|
|
|
struct ahc_data *ahc;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1996-01-03 06:32:12 +00:00
|
|
|
u_char scsi_conf, sblkctl, i;
|
1996-05-21 18:37:25 +00:00
|
|
|
u_short ultraenable = 0;
|
1996-01-03 06:32:12 +00:00
|
|
|
int max_targ = 15;
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1995-11-05 04:50:55 +00:00
|
|
|
* Assume we have a board at this stage and it has been reset.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/* Handle the SCBPAGING option */
|
|
|
|
#ifndef AHC_SCBPAGING_ENABLE
|
|
|
|
ahc->flags &= ~AHC_PAGESCBS;
|
|
|
|
#endif
|
|
|
|
|
1996-03-31 03:15:31 +00:00
|
|
|
/* Determine channel configuration and who we are on the scsi bus. */
|
1996-05-30 07:19:59 +00:00
|
|
|
switch ( (sblkctl = AHC_INB(ahc, SBLKCTL) & 0x0a) ) {
|
1996-03-31 03:15:31 +00:00
|
|
|
case 0:
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc->our_id = (AHC_INB(ahc, SCSICONF) & HSCSIID);
|
1996-05-10 16:21:05 +00:00
|
|
|
ahc->flags &= ~AHC_CHANNEL_B_PRIMARY;
|
1995-09-05 23:52:03 +00:00
|
|
|
if(ahc->type == AHC_394)
|
|
|
|
printf("Channel %c, SCSI Id=%d, ",
|
|
|
|
ahc->flags & AHC_CHNLB ? 'B' : 'A',
|
|
|
|
ahc->our_id);
|
|
|
|
else
|
|
|
|
printf("Single Channel, SCSI Id=%d, ", ahc->our_id);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, FLAGS, SINGLE_BUS | (ahc->flags & AHC_PAGESCBS));
|
1996-03-31 03:15:31 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc->our_id = (AHC_INB(ahc, SCSICONF + 1) & HWSCSIID);
|
1996-05-10 16:21:05 +00:00
|
|
|
ahc->flags &= ~AHC_CHANNEL_B_PRIMARY;
|
1995-09-05 23:52:03 +00:00
|
|
|
if(ahc->type == AHC_394)
|
|
|
|
printf("Wide Channel %c, SCSI Id=%d, ",
|
|
|
|
ahc->flags & AHC_CHNLB ? 'B' : 'A',
|
|
|
|
ahc->our_id);
|
|
|
|
else
|
|
|
|
printf("Wide Channel, SCSI Id=%d, ", ahc->our_id);
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->type |= AHC_WIDE;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, FLAGS, WIDE_BUS | (ahc->flags & AHC_PAGESCBS));
|
1996-03-31 03:15:31 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc->our_id = (AHC_INB(ahc, SCSICONF) & HSCSIID);
|
|
|
|
ahc->our_id_b = (AHC_INB(ahc, SCSICONF + 1) & HSCSIID);
|
1996-03-31 03:15:31 +00:00
|
|
|
printf("Twin Channel, A SCSI Id=%d, B SCSI Id=%d, ",
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc->our_id, ahc->our_id_b);
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->type |= AHC_TWIN;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, FLAGS, TWIN_BUS | (ahc->flags & AHC_PAGESCBS));
|
1996-03-31 03:15:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" Unsupported adapter type. Ignoring\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine the number of SCBs */
|
|
|
|
|
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, 0);
|
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
1996-04-20 21:29:27 +00:00
|
|
|
for(i = 1; i < AHC_SCB_MAX; i++) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, i);
|
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, i);
|
|
|
|
if(AHC_INB(ahc, SCB_CONTROL) != i)
|
1996-04-20 21:29:27 +00:00
|
|
|
break;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, 0);
|
|
|
|
if(AHC_INB(ahc, SCB_CONTROL) != 0)
|
1996-04-20 21:29:27 +00:00
|
|
|
break;
|
|
|
|
/* Clear the control byte. */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, i);
|
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
1996-04-20 21:29:27 +00:00
|
|
|
|
|
|
|
ahc->qcntmask |= i; /* Update the count mask. */
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
/* Ensure we clear the 0 SCB's control byte. */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, 0);
|
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
1996-04-20 21:29:27 +00:00
|
|
|
|
|
|
|
ahc->qcntmask |= i;
|
|
|
|
ahc->maxhscbs = i;
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
if((ahc->maxhscbs < AHC_SCB_MAX) && (ahc->flags & AHC_PAGESCBS))
|
|
|
|
ahc->maxscbs = AHC_SCB_MAX;
|
|
|
|
else {
|
|
|
|
ahc->maxscbs = ahc->maxhscbs;
|
|
|
|
ahc->flags &= ~AHC_PAGESCBS;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%d SCBs\n", ahc->maxhscbs);
|
1995-04-27 17:47:17 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if(ahc_debug & AHC_SHOWMISC) {
|
|
|
|
struct scb test;
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: hardware scb %ld bytes; kernel scb; "
|
1996-01-03 06:32:12 +00:00
|
|
|
"ahc_dma %d bytes\n",
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_name(ahc),
|
|
|
|
(u_long)&(test.next) - (u_long)(&test),
|
1996-01-03 06:32:12 +00:00
|
|
|
sizeof(test),
|
|
|
|
sizeof(struct ahc_dma_seg));
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
#endif /* AHC_DEBUG */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-10-26 23:57:18 +00:00
|
|
|
/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1, for both channels*/
|
1996-01-03 06:32:12 +00:00
|
|
|
if(ahc->type & AHC_TWIN)
|
1995-01-22 00:48:39 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-01-22 00:48:39 +00:00
|
|
|
* The device is gated to channel B after a chip reset,
|
|
|
|
* so set those values first
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSIID, ahc->our_id_b);
|
|
|
|
scsi_conf = AHC_INB(ahc, SCSICONF + 1);
|
|
|
|
AHC_OUTB(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
|
1996-05-10 16:21:05 +00:00
|
|
|
| ENSTIMER|ACTNEGEN|STPWEN);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
|
1995-10-26 23:57:18 +00:00
|
|
|
if(ahc->type & AHC_ULTRA)
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN|ULTRAEN);
|
1995-10-29 05:57:48 +00:00
|
|
|
else
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN);
|
1995-07-31 08:25:36 +00:00
|
|
|
|
1996-05-10 16:21:05 +00:00
|
|
|
if(scsi_conf & RESET_SCSI) {
|
|
|
|
/* Reset the bus */
|
|
|
|
if(bootverbose)
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Reseting Channel B\n",
|
|
|
|
ahc_name(ahc));
|
|
|
|
AHC_OUTB(ahc, SCSISEQ, SCSIRSTO);
|
1996-05-10 16:21:05 +00:00
|
|
|
DELAY(1000);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSISEQ, 0);
|
1995-07-31 08:25:36 +00:00
|
|
|
|
1996-05-10 16:21:05 +00:00
|
|
|
/* Ensure we don't get a RSTI interrupt from this */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI);
|
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
1996-05-10 16:21:05 +00:00
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
|
1995-01-22 00:48:39 +00:00
|
|
|
/* Select Channel A */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SBLKCTL, 0);
|
1995-01-22 00:48:39 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSIID, ahc->our_id);
|
|
|
|
scsi_conf = AHC_INB(ahc, SCSICONF);
|
|
|
|
AHC_OUTB(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
|
1996-05-10 16:21:05 +00:00
|
|
|
| ENSTIMER|ACTNEGEN|STPWEN);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
|
1995-10-26 23:57:18 +00:00
|
|
|
if(ahc->type & AHC_ULTRA)
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN|ULTRAEN);
|
1995-10-29 05:57:48 +00:00
|
|
|
else
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-10 16:21:05 +00:00
|
|
|
if(scsi_conf & RESET_SCSI) {
|
|
|
|
/* Reset the bus */
|
|
|
|
if(bootverbose)
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Reseting Channel A\n", ahc_name(ahc));
|
1996-05-10 16:21:05 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSISEQ, SCSIRSTO);
|
1996-05-10 16:21:05 +00:00
|
|
|
DELAY(1000);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSISEQ, 0);
|
1995-07-31 08:25:36 +00:00
|
|
|
|
1996-05-10 16:21:05 +00:00
|
|
|
/* Ensure we don't get a RSTI interrupt from this */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI);
|
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
1996-05-10 16:21:05 +00:00
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1994-12-31 19:31:56 +00:00
|
|
|
* Look at the information that board initialization or
|
|
|
|
* the board bios has left us. In the lower four bits of each
|
|
|
|
* target's scratch space any value other than 0 indicates
|
1995-05-30 08:16:23 +00:00
|
|
|
* that we should initiate syncronous transfers. If it's zero,
|
|
|
|
* the user or the BIOS has decided to disable syncronous
|
1996-01-03 06:32:12 +00:00
|
|
|
* negotiation to that target so we don't activate the needsdtr
|
1994-12-31 19:31:56 +00:00
|
|
|
* flag.
|
|
|
|
*/
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needsdtr_orig = 0;
|
|
|
|
ahc->needwdtr_orig = 0;
|
1995-07-04 21:14:45 +00:00
|
|
|
|
|
|
|
/* Grab the disconnection disable table and invert it for our needs */
|
1996-01-03 06:32:12 +00:00
|
|
|
if(ahc->flags & AHC_USEDEFAULTS) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Host Adapter Bios disabled. Using default SCSI "
|
|
|
|
"device parameters\n", ahc_name(ahc));
|
1995-07-04 21:14:45 +00:00
|
|
|
ahc->discenable = 0xff;
|
|
|
|
}
|
|
|
|
else
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc->discenable = ~((AHC_INB(ahc, DISC_DSB + 1) << 8)
|
|
|
|
| AHC_INB(ahc, DISC_DSB));
|
1995-07-04 21:14:45 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
if(!(ahc->type & (AHC_WIDE|AHC_TWIN)))
|
1995-09-05 23:52:03 +00:00
|
|
|
max_targ = 7;
|
1995-03-31 13:54:41 +00:00
|
|
|
|
1995-09-05 23:52:03 +00:00
|
|
|
for(i = 0; i <= max_targ; i++){
|
1995-07-04 21:14:45 +00:00
|
|
|
u_char target_settings;
|
1996-01-03 06:32:12 +00:00
|
|
|
if (ahc->flags & AHC_USEDEFAULTS) {
|
1995-07-04 21:14:45 +00:00
|
|
|
target_settings = 0; /* 10MHz */
|
|
|
|
ahc->needsdtr_orig |= (0x01 << i);
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needwdtr_orig |= (0x01 << i);
|
1995-07-04 21:14:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Take the settings leftover in scratch RAM. */
|
1996-05-30 07:19:59 +00:00
|
|
|
target_settings = AHC_INB(ahc, TARG_SCRATCH + i);
|
1995-07-04 21:14:45 +00:00
|
|
|
|
|
|
|
if(target_settings & 0x0f){
|
|
|
|
ahc->needsdtr_orig |= (0x01 << i);
|
|
|
|
/*Default to a asyncronous transfers(0 offset)*/
|
|
|
|
target_settings &= 0xf0;
|
|
|
|
}
|
|
|
|
if(target_settings & 0x80){
|
|
|
|
ahc->needwdtr_orig |= (0x01 << i);
|
|
|
|
/*
|
|
|
|
* We'll set the Wide flag when we
|
1996-01-03 06:32:12 +00:00
|
|
|
* are successful with Wide negotiation.
|
|
|
|
* Turn it off for now so we aren't
|
1995-07-04 21:14:45 +00:00
|
|
|
* confused.
|
|
|
|
*/
|
|
|
|
target_settings &= 0x7f;
|
|
|
|
}
|
1996-05-21 18:37:25 +00:00
|
|
|
if(ahc->type & AHC_ULTRA) {
|
|
|
|
/*
|
|
|
|
* Enable Ultra for any target that
|
|
|
|
* has a valid ultra syncrate setting.
|
|
|
|
*/
|
|
|
|
u_char rate = target_settings & 0x70;
|
1996-05-23 15:02:18 +00:00
|
|
|
if(rate == 0x00 || rate == 0x10 ||
|
|
|
|
rate == 0x20 || rate == 0x40) {
|
|
|
|
if(rate == 0x40) {
|
|
|
|
/* Treat 10MHz specially */
|
|
|
|
target_settings &= ~0x70;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ultraenable |= (0x01 << i);
|
|
|
|
}
|
1996-05-21 18:37:25 +00:00
|
|
|
}
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, TARG_SCRATCH+i,target_settings);
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-02-22 01:43:25 +00:00
|
|
|
* If we are not a WIDE device, forget WDTR. This
|
|
|
|
* makes the driver work on some cards that don't
|
|
|
|
* leave these fields cleared when the BIOS is not
|
|
|
|
* installed.
|
|
|
|
*/
|
|
|
|
if(!(ahc->type & AHC_WIDE))
|
|
|
|
ahc->needwdtr_orig = 0;
|
1995-03-07 08:59:28 +00:00
|
|
|
ahc->needsdtr = ahc->needsdtr_orig;
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needwdtr = ahc->needwdtr_orig;
|
1995-02-03 17:15:12 +00:00
|
|
|
ahc->sdtrpending = 0;
|
|
|
|
ahc->wdtrpending = 0;
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->tagenable = 0;
|
1996-04-28 19:21:20 +00:00
|
|
|
ahc->orderedtag = 0;
|
1995-03-17 23:58:27 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, ULTRA_ENB, ultraenable & 0xff);
|
|
|
|
AHC_OUTB(ahc, ULTRA_ENB + 1, (ultraenable >> 8) & 0xff);
|
1996-05-21 18:37:25 +00:00
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
/* How did we do? */
|
|
|
|
if(ahc_debug & AHC_SHOWMISC)
|
|
|
|
printf("NEEDSDTR == 0x%x\nNEEDWDTR == 0x%x\n"
|
|
|
|
"DISCENABLE == 0x%x\n", ahc->needsdtr,
|
|
|
|
ahc->needwdtr, ahc->discenable);
|
|
|
|
#endif
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Set the number of availible SCBs
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBCOUNT, ahc->maxhscbs);
|
1996-01-03 06:32:12 +00:00
|
|
|
|
|
|
|
/*
|
1996-04-20 21:29:27 +00:00
|
|
|
* 2's compliment of maximum tag value
|
1996-01-03 06:32:12 +00:00
|
|
|
*/
|
|
|
|
i = ahc->maxscbs;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, COMP_SCBCOUNT, -i & 0xff);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1996-03-31 03:15:31 +00:00
|
|
|
/*
|
|
|
|
* QCount mask to deal with broken aic7850s that
|
|
|
|
* sporatically get garbage in the upper bits of
|
|
|
|
* their QCount registers.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, QCNTMASK, ahc->qcntmask);
|
1996-03-31 03:15:31 +00:00
|
|
|
|
1994-12-31 19:31:56 +00:00
|
|
|
/* We don't have any busy targets right now */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, ACTIVE_A, 0);
|
|
|
|
AHC_OUTB(ahc, ACTIVE_B, 0);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-04-27 17:47:17 +00:00
|
|
|
/* We don't have any waiting selections */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, WAITING_SCBH, SCB_LIST_NULL);
|
1996-04-20 21:29:27 +00:00
|
|
|
|
|
|
|
/* Our disconnection list is empty too */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, DISCONNECTED_SCBH, SCB_LIST_NULL);
|
1996-01-03 06:32:12 +00:00
|
|
|
|
|
|
|
/* Message out buffer starts empty */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, MSG_LEN, 0x00);
|
1996-01-03 06:32:12 +00:00
|
|
|
|
1995-03-07 08:59:28 +00:00
|
|
|
/*
|
1996-01-03 06:32:12 +00:00
|
|
|
* Load the Sequencer program and Enable the adapter
|
|
|
|
* in "fast" mode.
|
1995-03-07 08:59:28 +00:00
|
|
|
*/
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose)
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Downloading Sequencer Program...",
|
|
|
|
ahc_name(ahc));
|
1996-01-03 06:32:12 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_loadseq(ahc);
|
1996-01-03 06:32:12 +00:00
|
|
|
|
1995-09-05 23:52:03 +00:00
|
|
|
if(bootverbose)
|
|
|
|
printf("Done\n");
|
1995-03-07 08:59:28 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SEQCTL, FASTMODE);
|
1995-03-07 08:59:28 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that we are going and return (to probe)
|
|
|
|
*/
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc->flags |= AHC_INIT;
|
1994-11-17 20:22:31 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1994-11-17 20:22:31 +00:00
|
|
|
ahcminphys(bp)
|
1995-05-30 08:16:23 +00:00
|
|
|
struct buf *bp;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Even though the card can transfer up to 16megs per command
|
1994-11-17 20:22:31 +00:00
|
|
|
* we are limited by the number of segments in the dma segment
|
|
|
|
* list that we can hold. The worst case is that all pages are
|
|
|
|
* discontinuous physically, hense the "page per segment" limit
|
|
|
|
* enforced here.
|
|
|
|
*/
|
1996-05-21 18:37:25 +00:00
|
|
|
if (bp->b_bcount > ((AHC_NSEG - 1) * PAGE_SIZE)) {
|
|
|
|
bp->b_bcount = ((AHC_NSEG - 1) * PAGE_SIZE);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
minphys(bp);
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* start a scsi operation given the command and
|
1995-05-30 08:16:23 +00:00
|
|
|
* the data address, target, and lun all of which
|
1994-11-17 20:22:31 +00:00
|
|
|
* are stored in the scsi_xfer struct
|
|
|
|
*/
|
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
|
|
|
static int32_t
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_scsi_cmd(xs)
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
{
|
1996-01-07 19:24:36 +00:00
|
|
|
struct scb *scb;
|
|
|
|
struct ahc_dma_seg *sg;
|
1994-11-17 20:22:31 +00:00
|
|
|
int seg; /* scatter gather seg being worked on */
|
1995-05-30 08:16:23 +00:00
|
|
|
int thiskv;
|
1994-11-17 20:22:31 +00:00
|
|
|
physaddr thisphys, nextphys;
|
|
|
|
int bytes_this_seg, bytes_this_page, datalen, flags;
|
1996-01-07 19:24:36 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
u_short mask;
|
1994-11-17 20:22:31 +00:00
|
|
|
int s;
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1996-01-07 19:24:36 +00:00
|
|
|
ahc = (struct ahc_data *)xs->sc_link->adapter_softc;
|
|
|
|
mask = (0x01 << (xs->sc_link->target
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1996-01-07 19:24:36 +00:00
|
|
|
| ((u_long)xs->sc_link->fordriver & 0x08)));
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
| (IS_SCSIBUS_B(ahc, xs->sc_link) ? SELBUSB : 0) ));
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_scsi_cmd\n"));
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* get an scb to use. If the transfer
|
|
|
|
* is from a buf (possibly from interrupt time)
|
|
|
|
* then we can't allow it to sleep
|
|
|
|
*/
|
|
|
|
flags = xs->flags;
|
|
|
|
if (flags & ITSDONE) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Already done?", ahc_name(ahc));
|
1995-05-30 08:16:23 +00:00
|
|
|
xs->flags &= ~ITSDONE;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
if (!(flags & INUSE)) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Not in use?", ahc_name(ahc));
|
1994-11-17 20:22:31 +00:00
|
|
|
xs->flags |= INUSE;
|
|
|
|
}
|
1996-01-03 06:32:12 +00:00
|
|
|
if (!(scb = ahc_get_scb(ahc, flags))) {
|
1994-11-17 20:22:31 +00:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
return (TRY_AGAIN_LATER);
|
|
|
|
}
|
1995-05-11 19:26:53 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB3, ("start scb(%p)\n", scb));
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->xs = xs;
|
1995-05-30 08:16:23 +00:00
|
|
|
if (flags & SCSI_RESET)
|
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
|
|
|
scb->flags |= SCB_DEVICE_RESET|SCB_IMMED;
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Put all the arguments for the xfer in the scb
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1995-02-22 01:43:25 +00:00
|
|
|
|
1996-04-28 19:21:20 +00:00
|
|
|
if(ahc->tagenable & mask) {
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->control |= TAG_ENB;
|
1996-04-28 19:21:20 +00:00
|
|
|
if(ahc->orderedtag & mask) {
|
|
|
|
printf("Ordered Tag sent\n");
|
|
|
|
scb->control |= 0x02;
|
|
|
|
ahc->orderedtag &= ~mask;
|
|
|
|
}
|
|
|
|
}
|
1995-07-04 21:14:45 +00:00
|
|
|
if(ahc->discenable & mask)
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->control |= DISCENB;
|
1995-05-30 08:16:23 +00:00
|
|
|
if((ahc->needwdtr & mask) && !(ahc->wdtrpending & mask))
|
1995-02-03 17:15:12 +00:00
|
|
|
{
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->control |= NEEDWDTR;
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->wdtrpending |= mask;
|
1995-02-03 17:15:12 +00:00
|
|
|
}
|
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
|
|
|
else if((ahc->needsdtr & mask) && !(ahc->sdtrpending & mask))
|
1995-02-03 17:15:12 +00:00
|
|
|
{
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->control |= NEEDSDTR;
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->sdtrpending |= mask;
|
1995-02-03 17:15:12 +00:00
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->tcl = ((xs->sc_link->target << 4) & 0xF0) |
|
1996-05-30 07:19:59 +00:00
|
|
|
#if defined(__FreeBSD__)
|
1994-12-31 19:31:56 +00:00
|
|
|
((u_long)xs->sc_link->fordriver & 0x08) |
|
1996-05-30 07:19:59 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
(IS_SCSIBUS_B(ahc,xs->sc_link)? SELBUSB : 0)|
|
|
|
|
#endif
|
1995-03-07 08:59:28 +00:00
|
|
|
(xs->sc_link->lun & 0x07);
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->cmdlen = xs->cmdlen;
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->cmdpointer = KVTOPHYS(xs->cmd);
|
1995-03-31 13:54:41 +00:00
|
|
|
xs->resid = 0;
|
1995-06-11 19:33:05 +00:00
|
|
|
xs->status = 0;
|
1996-04-20 21:29:27 +00:00
|
|
|
if (xs->datalen) { /* should use S/G only if not zero length */
|
|
|
|
scb->SG_list_pointer = KVTOPHYS(scb->ahc_dma);
|
|
|
|
sg = scb->ahc_dma;
|
|
|
|
seg = 0;
|
|
|
|
/*
|
|
|
|
* Set up the scatter gather block
|
|
|
|
*/
|
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB4,
|
|
|
|
("%ld @%p:- ", xs->datalen, xs->data));
|
|
|
|
datalen = xs->datalen;
|
|
|
|
thiskv = (int) xs->data;
|
|
|
|
thisphys = KVTOPHYS(thiskv);
|
|
|
|
|
|
|
|
while ((datalen) && (seg < AHC_NSEG)) {
|
|
|
|
bytes_this_seg = 0;
|
|
|
|
|
|
|
|
/* put in the base address */
|
|
|
|
sg->addr = thisphys;
|
|
|
|
|
|
|
|
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("0x%lx", thisphys));
|
|
|
|
|
|
|
|
/* do it at least once */
|
|
|
|
nextphys = thisphys;
|
|
|
|
while ((datalen) && (thisphys == nextphys)) {
|
|
|
|
/*
|
|
|
|
* This page is contiguous (physically)
|
|
|
|
* with the the last, just extend the
|
|
|
|
* length
|
|
|
|
*/
|
|
|
|
/* how far to the end of the page */
|
1996-05-21 18:37:25 +00:00
|
|
|
nextphys = (thisphys & (~(PAGE_SIZE- 1)))
|
|
|
|
+ PAGE_SIZE;
|
1996-04-20 21:29:27 +00:00
|
|
|
bytes_this_page = nextphys - thisphys;
|
|
|
|
/**** or the data ****/
|
|
|
|
bytes_this_page = min(bytes_this_page ,datalen);
|
|
|
|
bytes_this_seg += bytes_this_page;
|
|
|
|
datalen -= bytes_this_page;
|
|
|
|
|
|
|
|
/* get more ready for the next page */
|
1996-05-21 18:37:25 +00:00
|
|
|
thiskv = (thiskv & (~(PAGE_SIZE - 1)))
|
|
|
|
+ PAGE_SIZE;
|
1996-04-20 21:29:27 +00:00
|
|
|
if (datalen)
|
|
|
|
thisphys = KVTOPHYS(thiskv);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* next page isn't contiguous, finish the seg
|
|
|
|
*/
|
|
|
|
SC_DEBUGN(xs->sc_link, SDEV_DB4,
|
1995-05-30 08:16:23 +00:00
|
|
|
("(0x%x)", bytes_this_seg));
|
1996-04-20 21:29:27 +00:00
|
|
|
sg->len = bytes_this_seg;
|
|
|
|
sg++;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
scb->SG_segment_count = seg;
|
1995-07-04 21:14:45 +00:00
|
|
|
|
|
|
|
/* Copy the first SG into the data pointer area */
|
|
|
|
scb->data = scb->ahc_dma->addr;
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->datalen = scb->ahc_dma->len;
|
1996-04-20 21:29:27 +00:00
|
|
|
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n"));
|
|
|
|
if (datalen) {
|
1995-07-04 21:14:45 +00:00
|
|
|
/* there's still data, must have run out of segs! */
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: ahc_scsi_cmd: more than %d DMA segs\n",
|
|
|
|
ahc_name(ahc), AHC_NSEG);
|
1996-04-20 21:29:27 +00:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
ahc_free_scb(ahc, scb, flags);
|
|
|
|
return (COMPLETE);
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
#ifdef AHC_BROKEN_CACHE
|
|
|
|
if (ahc_broken_cache)
|
|
|
|
INVALIDATE_CACHE();
|
|
|
|
#endif
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
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
|
|
|
else {
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* No data xfer, use non S/G values
|
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
|
|
|
*/
|
|
|
|
scb->SG_segment_count = 0;
|
|
|
|
scb->SG_list_pointer = 0;
|
1995-07-04 21:14:45 +00:00
|
|
|
scb->data = 0;
|
1996-01-03 06:32:12 +00:00
|
|
|
scb->datalen = 0;
|
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
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1996-04-20 21:29:27 +00:00
|
|
|
if((ahc_debug & AHC_SHOWSCBS) && (xs->sc_link->target == DEBUGTARG))
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_print_scb(scb);
|
|
|
|
#endif
|
1996-04-20 21:29:27 +00:00
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
if( scb->position != SCB_LIST_NULL )
|
|
|
|
{
|
|
|
|
/* We already have a valid slot */
|
|
|
|
u_char curscb;
|
|
|
|
|
1996-01-29 03:17:39 +00:00
|
|
|
PAUSE_SEQUENCER(ahc);
|
1996-05-30 07:19:59 +00:00
|
|
|
curscb = AHC_INB(ahc, SCBPTR);
|
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
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
|
|
|
ahc_send_scb(ahc, scb);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, curscb);
|
|
|
|
AHC_OUTB(ahc, QINFIFO, scb->position);
|
1996-01-29 03:17:39 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1996-04-28 19:21:20 +00:00
|
|
|
scb->flags = SCB_ACTIVE;
|
1996-04-20 21:29:27 +00:00
|
|
|
if (!(flags & SCSI_NOMASK)) {
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb,
|
|
|
|
(xs->timeout * hz) / 1000);
|
|
|
|
}
|
1996-01-29 03:17:39 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n"));
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
|
|
|
else {
|
1996-04-28 19:21:20 +00:00
|
|
|
scb->flags = SCB_WAITINGQ;
|
1996-04-20 21:29:27 +00:00
|
|
|
STAILQ_INSERT_TAIL(&ahc->waiting_scbs, scb, links);
|
|
|
|
ahc_run_waiting_queues(ahc);
|
|
|
|
}
|
|
|
|
if (!(flags & SCSI_NOMASK)) {
|
|
|
|
splx(s);
|
1996-01-29 03:17:39 +00:00
|
|
|
return (SUCCESSFULLY_QUEUED);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If we can't use interrupts, poll for completion
|
|
|
|
*/
|
1996-04-20 21:29:27 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_poll\n"));
|
1996-01-29 03:17:39 +00:00
|
|
|
do {
|
|
|
|
if (ahc_poll(ahc, xs->timeout)) {
|
|
|
|
if (!(xs->flags & SCSI_SILENT))
|
|
|
|
printf("cmd fail\n");
|
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
|
|
|
ahc_timeout(scb);
|
|
|
|
break;
|
1996-01-29 03:17:39 +00:00
|
|
|
}
|
|
|
|
} while (!(xs->flags & ITSDONE)); /* a non command complete intr */
|
|
|
|
splx(s);
|
|
|
|
return (COMPLETE);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A scb (and hence an scb entry on the board is put onto the
|
|
|
|
* free list.
|
|
|
|
*/
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_free_scb(ahc, scb, flags)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
int flags;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct scb *scb;
|
|
|
|
{
|
1996-04-20 21:29:27 +00:00
|
|
|
struct scb *wscb;
|
|
|
|
unsigned int opri;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-04-23 22:04:58 +00:00
|
|
|
opri = splbio();
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->flags = SCB_FREE;
|
|
|
|
if(scb->position == SCB_LIST_NULL) {
|
|
|
|
STAILQ_INSERT_HEAD(&ahc->page_scbs, scb, links);
|
|
|
|
if(!scb->links.stqe_next && !ahc->free_scbs.stqh_first)
|
|
|
|
/*
|
|
|
|
* If there were no SCBs availible, wake anybody waiting
|
|
|
|
* for one to come free.
|
|
|
|
*/
|
|
|
|
wakeup((caddr_t)&ahc->free_scbs);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If there are any SCBS on the waiting queue,
|
|
|
|
* assign the slot of this "freed" SCB to the first
|
|
|
|
* one. We'll run the waiting queues after all command
|
|
|
|
* completes for a particular interrupt are completed
|
|
|
|
* or when we start another command.
|
|
|
|
*/
|
|
|
|
else if((wscb = ahc->waiting_scbs.stqh_first) != NULL) {
|
|
|
|
wscb->position = scb->position;
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->waiting_scbs, links);
|
1996-04-28 19:21:20 +00:00
|
|
|
STAILQ_INSERT_HEAD(&ahc->assigned_scbs, wscb, links);
|
|
|
|
wscb->flags = SCB_ASSIGNEDQ;
|
1996-04-20 21:29:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The "freed" SCB will need to be assigned a slot
|
|
|
|
* before being used, so put it in the page_scbs
|
|
|
|
* queue.
|
|
|
|
*/
|
|
|
|
scb->position = SCB_LIST_NULL;
|
|
|
|
STAILQ_INSERT_HEAD(&ahc->page_scbs, scb, links);
|
|
|
|
if(!scb->links.stqe_next && !ahc->free_scbs.stqh_first)
|
|
|
|
/*
|
|
|
|
* If there were no SCBs availible, wake anybody waiting
|
|
|
|
* for one to come free.
|
|
|
|
*/
|
|
|
|
wakeup((caddr_t)&ahc->free_scbs);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
STAILQ_INSERT_HEAD(&ahc->free_scbs, scb, links);
|
1995-04-23 22:04:58 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc->activescbs--;
|
1995-04-23 22:04:58 +00:00
|
|
|
#endif
|
1996-04-20 21:29:27 +00:00
|
|
|
if(!scb->links.stqe_next && !ahc->page_scbs.stqh_first)
|
|
|
|
/*
|
|
|
|
* If there were no SCBs availible, wake anybody waiting
|
|
|
|
* for one to come free.
|
|
|
|
*/
|
|
|
|
wakeup((caddr_t)&ahc->free_scbs);
|
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
splx(opri);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1996-04-20 21:29:27 +00:00
|
|
|
* Get a free scb, either one already assigned to a hardware slot
|
|
|
|
* on the adapter or one that will require an SCB to be paged out before
|
|
|
|
* use. If there are none, see if we can allocate a new SCB. Otherwise
|
|
|
|
* either return an error or sleep.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1995-10-31 18:41:49 +00:00
|
|
|
static struct scb *
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_get_scb(ahc, flags)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
int flags;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1996-04-20 21:29:27 +00:00
|
|
|
unsigned opri;
|
|
|
|
struct scb *scbp;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-04-23 22:04:58 +00:00
|
|
|
opri = splbio();
|
1996-04-20 21:29:27 +00:00
|
|
|
/*
|
|
|
|
* If we can and have to, sleep waiting for one to come free
|
|
|
|
* but only if we can't allocate a new one.
|
|
|
|
*/
|
|
|
|
while (1) {
|
|
|
|
if((scbp = ahc->free_scbs.stqh_first)) {
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->free_scbs, links);
|
|
|
|
}
|
|
|
|
else if((scbp = ahc->page_scbs.stqh_first)) {
|
|
|
|
STAILQ_REMOVE_HEAD(&ahc->page_scbs, links);
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
else if (ahc->numscbs < ahc->maxscbs) {
|
|
|
|
scbp = (struct scb *) malloc(sizeof(struct scb),
|
|
|
|
M_TEMP, M_NOWAIT);
|
|
|
|
if (scbp) {
|
1995-04-27 17:47:17 +00:00
|
|
|
bzero(scbp, sizeof(struct scb));
|
1996-04-20 21:29:27 +00:00
|
|
|
scbp->tag = ahc->numscbs;
|
|
|
|
if( ahc->numscbs < ahc->maxhscbs )
|
|
|
|
scbp->position = ahc->numscbs;
|
|
|
|
else
|
|
|
|
scbp->position = SCB_LIST_NULL;
|
1995-04-27 17:47:17 +00:00
|
|
|
ahc->numscbs++;
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Place in the scbarray
|
1996-04-20 21:29:27 +00:00
|
|
|
* Never is removed.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1996-04-20 21:29:27 +00:00
|
|
|
ahc->scbarray[scbp->tag] = scbp;
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
else {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Can't malloc SCB\n",
|
|
|
|
ahc_name(ahc));
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!(flags & SCSI_NOSLEEP)) {
|
1996-04-20 21:29:27 +00:00
|
|
|
tsleep((caddr_t)&ahc->free_scbs, PRIBIO,
|
1996-03-31 03:15:31 +00:00
|
|
|
"ahcscb", 0);
|
1995-04-23 22:04:58 +00:00
|
|
|
continue;
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
|
|
|
|
if (scbp) {
|
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
|
|
|
scbp->control = 0;
|
1996-04-20 21:29:27 +00:00
|
|
|
scbp->status = 0;
|
1996-04-28 19:21:20 +00:00
|
|
|
scbp->flags = 0;
|
1995-04-23 22:04:58 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
ahc->activescbs++;
|
1996-01-03 06:32:12 +00:00
|
|
|
if((ahc_debug & AHC_SHOWSCBCNT)
|
1996-04-20 21:29:27 +00:00
|
|
|
&& (ahc->activescbs == ahc->maxhscbs))
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Max SCBs active\n", ahc_name(ahc));
|
1995-04-23 22:04:58 +00:00
|
|
|
#endif
|
1996-03-31 03:15:31 +00:00
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
|
|
|
|
splx(opri);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-03-31 03:15:31 +00:00
|
|
|
return (scbp);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
static void ahc_loadseq(ahc)
|
|
|
|
struct ahc_data *ahc;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1994-11-18 09:14:14 +00:00
|
|
|
static unsigned char seqprog[] = {
|
1995-01-13 02:24:31 +00:00
|
|
|
# include "aic7xxx_seq.h"
|
1996-03-31 03:15:31 +00:00
|
|
|
};
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SEQCTL, PERRORDIS|SEQRESET|LOADRAM);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTSB(ahc, SEQRAM, seqprog, sizeof(seqprog));
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1996-06-08 06:55:01 +00:00
|
|
|
do {
|
|
|
|
AHC_OUTB(ahc, SEQCTL, SEQRESET|FASTMODE);
|
|
|
|
} while((AHC_INB(ahc, SEQADDR0) != 0)
|
|
|
|
|| (AHC_INB(ahc, SEQADDR1) != 0));
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1996-01-29 03:17:39 +00:00
|
|
|
/*
|
|
|
|
* Function to poll for command completion when
|
|
|
|
* interrupts are disabled (crash dumps)
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ahc_poll(ahc, wait)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
int wait; /* in msec */
|
|
|
|
{
|
|
|
|
while (--wait) {
|
|
|
|
DELAY(1000);
|
1996-05-30 07:19:59 +00:00
|
|
|
if (AHC_INB(ahc, INTSTAT) & INT_PEND)
|
1996-01-29 03:17:39 +00:00
|
|
|
break;
|
|
|
|
} if (wait == 0) {
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: board is not responding\n", ahc_name(ahc));
|
1996-01-29 03:17:39 +00:00
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
ahc_intr((void *)ahc);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
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
|
|
|
ahc_timeout(arg)
|
|
|
|
void *arg;
|
1994-12-31 19:31:56 +00:00
|
|
|
{
|
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
|
|
|
struct scb *scb = (struct scb *)arg;
|
|
|
|
struct ahc_data *ahc;
|
1996-05-21 18:37:25 +00:00
|
|
|
int s, found;
|
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
|
|
|
u_char bus_state;
|
1996-04-20 21:29:27 +00:00
|
|
|
char channel;
|
1994-12-31 19:31:56 +00:00
|
|
|
|
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
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
if (!(scb->flags & SCB_ACTIVE)) {
|
|
|
|
/* Previous timeout took care of me already */
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ahc = (struct ahc_data *)scb->xs->sc_link->adapter_softc;
|
|
|
|
|
|
|
|
if (ahc->in_timeout) {
|
|
|
|
/*
|
|
|
|
* Some other SCB has started a recovery operation
|
|
|
|
* and is still working on cleaning things up.
|
|
|
|
*/
|
|
|
|
if (scb->flags & SCB_TIMEDOUT) {
|
|
|
|
/*
|
|
|
|
* This SCB has been here before and is not the
|
|
|
|
* recovery SCB. Cut our losses and panic. Its
|
|
|
|
* better to do this than trash a filesystem.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
panic("%s: Timed-out command times out "
|
|
|
|
"again\n", ahc_name(ahc));
|
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
|
|
|
}
|
|
|
|
else if (!(scb->flags & SCB_ABORTED))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This is not the SCB that started this timeout
|
|
|
|
* processing. Give this scb another lifetime so
|
|
|
|
* that it can continue once we deal with the
|
|
|
|
* timeout.
|
|
|
|
*/
|
|
|
|
scb->flags |= SCB_TIMEDOUT;
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb,
|
|
|
|
(scb->xs->timeout * hz) / 1000);
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ahc->in_timeout = TRUE;
|
|
|
|
|
|
|
|
/*
|
1995-07-31 08:25:36 +00:00
|
|
|
* Ensure that the card doesn't do anything
|
|
|
|
* behind our back.
|
1994-12-31 19:31:56 +00:00
|
|
|
*/
|
1995-07-31 08:25:36 +00:00
|
|
|
PAUSE_SEQUENCER(ahc);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
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
|
|
|
sc_print_addr(scb->xs->sc_link);
|
|
|
|
printf("timed out ");
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
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
|
|
|
* Take a snapshot of the bus state and print out
|
|
|
|
* some information so we can track down driver bugs.
|
1994-12-31 19:31:56 +00:00
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
bus_state = AHC_INB(ahc, LASTPHASE);
|
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
|
|
|
|
|
|
|
switch(bus_state & PHASE_MASK)
|
|
|
|
{
|
|
|
|
case P_DATAOUT:
|
|
|
|
printf("in dataout phase");
|
|
|
|
break;
|
|
|
|
case P_DATAIN:
|
|
|
|
printf("in datain phase");
|
|
|
|
break;
|
|
|
|
case P_COMMAND:
|
|
|
|
printf("in command phase");
|
|
|
|
break;
|
|
|
|
case P_MESGOUT:
|
|
|
|
printf("in message out phase");
|
|
|
|
break;
|
|
|
|
case P_STATUS:
|
|
|
|
printf("in status phase");
|
|
|
|
break;
|
|
|
|
case P_MESGIN:
|
|
|
|
printf("in message in phase");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("while idle, LASTPHASE == 0x%x",
|
|
|
|
bus_state);
|
|
|
|
/*
|
|
|
|
* We aren't in a valid phase, so assume we're
|
|
|
|
* idle.
|
|
|
|
*/
|
|
|
|
bus_state = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
printf(", SCSISIGI == 0x%x\n", AHC_INB(ahc, SCSISIGI));
|
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
|
|
|
|
|
|
|
/* Decide our course of action */
|
|
|
|
|
1995-07-31 08:25:36 +00:00
|
|
|
if(scb->flags & SCB_ABORTED)
|
|
|
|
{
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
1995-07-31 08:25:36 +00:00
|
|
|
* Been down this road before.
|
|
|
|
* Do a full bus reset.
|
1994-12-31 19:31:56 +00:00
|
|
|
*/
|
1996-04-20 21:29:27 +00:00
|
|
|
char channel = (scb->tcl & SELBUSB)
|
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
|
|
|
? 'B': 'A';
|
1996-04-20 21:29:27 +00:00
|
|
|
found = ahc_reset_channel(ahc, channel, scb->tag,
|
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
|
|
|
XS_TIMEOUT, /*Initiate Reset*/TRUE);
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Issued Channel %c Bus Reset #1. "
|
|
|
|
"%d SCBs aborted\n", ahc_name(ahc), channel, found);
|
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
|
|
|
ahc->in_timeout = FALSE;
|
1995-04-01 19:53:04 +00:00
|
|
|
}
|
1996-04-28 19:21:20 +00:00
|
|
|
else if(scb->control & TAG_ENB) {
|
|
|
|
/*
|
|
|
|
* We could be starving this command
|
|
|
|
* try sending an ordered tag command
|
|
|
|
* to the target we come from.
|
|
|
|
*/
|
|
|
|
scb->flags |= SCB_ABORTED|SCB_SENTORDEREDTAG;
|
|
|
|
ahc->orderedtag |= 0xFF;
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb, (5 * hz));
|
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
printf("Ordered Tag queued\n");
|
|
|
|
goto done;
|
|
|
|
}
|
1995-07-31 08:25:36 +00:00
|
|
|
else {
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-07-31 08:25:36 +00:00
|
|
|
* Send a Bus Device Reset Message:
|
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
|
|
|
* The target that is holding up the bus may not
|
|
|
|
* be the same as the one that triggered this timeout
|
|
|
|
* (different commands have different timeout lengths).
|
|
|
|
* It is also impossible to get a message to a target
|
|
|
|
* if we are in a "frozen" data transfer phase. Our
|
|
|
|
* strategy here is to queue a bus device reset message
|
|
|
|
* to the timed out target if it is disconnected.
|
|
|
|
* Otherwise, if we have an active target we stuff the
|
|
|
|
* message buffer with a bus device reset message and
|
|
|
|
* assert ATN in the hopes that the target will let go
|
|
|
|
* of the bus and finally disconnect. If this fails,
|
|
|
|
* we'll get another timeout 2 seconds later which will
|
|
|
|
* cause a bus reset.
|
1996-04-20 21:29:27 +00:00
|
|
|
*
|
|
|
|
* XXX If the SCB is paged out, we simply reset the
|
|
|
|
* bus. We should probably queue a new command
|
|
|
|
* instead.
|
1994-12-31 19:31:56 +00:00
|
|
|
*/
|
1995-07-31 08:25:36 +00:00
|
|
|
|
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
|
|
|
/* Test to see if scb is disconnected */
|
1996-04-20 21:29:27 +00:00
|
|
|
if( !(scb->flags & SCB_PAGED_OUT ) ){
|
|
|
|
u_char active_scb;
|
|
|
|
struct scb *active_scbp;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
active_scb = AHC_INB(ahc, SCBPTR);
|
|
|
|
active_scbp = ahc->scbarray[AHC_INB(ahc, SCB_TAG)];
|
|
|
|
AHC_OUTB(ahc, SCBPTR, scb->position);
|
1996-04-20 21:29:27 +00:00
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
if(AHC_INB(ahc, SCB_CONTROL) & DISCONNECTED) {
|
1996-04-28 19:21:20 +00:00
|
|
|
if(ahc->flags & AHC_PAGESCBS) {
|
|
|
|
/*
|
|
|
|
* Pull this SCB out of the
|
|
|
|
* disconnected list.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char prev = AHC_INB(ahc, SCB_PREV);
|
|
|
|
u_char next = AHC_INB(ahc, SCB_NEXT);
|
1996-04-28 19:21:20 +00:00
|
|
|
if(prev == SCB_LIST_NULL) {
|
|
|
|
/* At the head */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, DISCONNECTED_SCBH,
|
1996-04-28 19:21:20 +00:00
|
|
|
next );
|
|
|
|
}
|
|
|
|
else {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, prev);
|
|
|
|
AHC_OUTB(ahc, SCB_NEXT, next);
|
1996-04-28 19:21:20 +00:00
|
|
|
if(next != SCB_LIST_NULL) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR,
|
1996-04-28 19:21:20 +00:00
|
|
|
next);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCB_PREV,
|
1996-04-28 19:21:20 +00:00
|
|
|
prev);
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR,
|
1996-04-28 19:21:20 +00:00
|
|
|
scb->position);
|
|
|
|
}
|
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->flags |= SCB_DEVICE_RESET|SCB_ABORTED;
|
1996-04-28 19:21:20 +00:00
|
|
|
scb->control &= DISCENB;
|
|
|
|
scb->cmdlen = 0;
|
1996-04-20 21:29:27 +00:00
|
|
|
scb->SG_segment_count = 0;
|
|
|
|
scb->SG_list_pointer = 0;
|
|
|
|
scb->data = 0;
|
|
|
|
scb->datalen = 0;
|
|
|
|
ahc_send_scb(ahc, scb);
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_add_waiting_scb(ahc, scb);
|
1996-04-20 21:29:27 +00:00
|
|
|
timeout(ahc_timeout, (caddr_t)scb, (2 * hz));
|
|
|
|
sc_print_addr(scb->xs->sc_link);
|
|
|
|
printf("BUS DEVICE RESET message queued.\n");
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, active_scb);
|
1996-04-20 21:29:27 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/* Is the active SCB really active? */
|
|
|
|
else if((active_scbp->flags & SCB_ACTIVE) && bus_state){
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, MSG_LEN, 1);
|
|
|
|
AHC_OUTB(ahc, MSG0, MSG_BUS_DEVICE_RESET);
|
|
|
|
AHC_OUTB(ahc, SCSISIGO, bus_state|ATNO);
|
1996-04-20 21:29:27 +00:00
|
|
|
sc_print_addr(active_scbp->xs->sc_link);
|
|
|
|
printf("asserted ATN - device reset in "
|
|
|
|
"message buffer\n");
|
|
|
|
active_scbp->flags |= SCB_DEVICE_RESET
|
|
|
|
| SCB_ABORTED;
|
|
|
|
if(active_scbp != scb) {
|
|
|
|
untimeout(ahc_timeout,
|
|
|
|
(caddr_t)active_scbp);
|
|
|
|
/* Give scb a new lease on life */
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb,
|
|
|
|
(scb->xs->timeout * hz) / 1000);
|
|
|
|
}
|
|
|
|
timeout(ahc_timeout, (caddr_t)active_scbp,
|
|
|
|
(2 * hz));
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, active_scb);
|
1996-04-20 21:29:27 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
goto done;
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
/*
|
|
|
|
* No active target or a paged out SCB.
|
1996-04-28 19:21:20 +00:00
|
|
|
* Try reseting the bus.
|
1996-04-20 21:29:27 +00:00
|
|
|
*/
|
|
|
|
channel = (scb->tcl & SELBUSB) ? 'B': 'A';
|
|
|
|
found = ahc_reset_channel(ahc, channel, scb->tag,
|
|
|
|
XS_TIMEOUT,
|
|
|
|
/*Initiate Reset*/TRUE);
|
1996-05-30 07:19:59 +00:00
|
|
|
printf("%s: Issued Channel %c Bus Reset #2. "
|
|
|
|
"%d SCBs aborted\n", ahc_name(ahc), channel,
|
1996-04-20 21:29:27 +00:00
|
|
|
found);
|
|
|
|
ahc->in_timeout = FALSE;
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
1996-04-20 21:29:27 +00:00
|
|
|
done:
|
1995-10-26 23:57:18 +00:00
|
|
|
splx(s);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1995-07-31 08:25:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The device at the given target/channel has been reset. Abort
|
|
|
|
* all active and queued scbs for that target/channel.
|
|
|
|
*/
|
1995-10-31 18:41:49 +00:00
|
|
|
static int
|
1996-01-03 06:32:12 +00:00
|
|
|
ahc_reset_device(ahc, target, channel, timedout_scb, xs_error)
|
1995-07-31 08:25:36 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
int target;
|
|
|
|
char channel;
|
|
|
|
u_char timedout_scb;
|
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
|
|
|
u_int32_t xs_error;
|
1995-07-31 08:25:36 +00:00
|
|
|
{
|
|
|
|
struct scb *scbp;
|
|
|
|
u_char active_scb;
|
|
|
|
int i = 0;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
/* restore this when we're done */
|
1996-05-30 07:19:59 +00:00
|
|
|
active_scb = AHC_INB(ahc, SCBPTR);
|
1995-07-31 08:25:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Search the QINFIFO.
|
|
|
|
*/
|
|
|
|
{
|
1996-05-22 15:32:28 +00:00
|
|
|
u_char saved_queue[AHC_SCB_MAX];
|
1996-05-30 07:19:59 +00:00
|
|
|
u_char queued = AHC_INB(ahc, QINCNT) & ahc->qcntmask;
|
1995-07-31 08:25:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < (queued - found); i++) {
|
1996-05-30 07:19:59 +00:00
|
|
|
saved_queue[i] = AHC_INB(ahc, QINFIFO);
|
|
|
|
AHC_OUTB(ahc, SCBPTR, saved_queue[i]);
|
|
|
|
scbp = ahc->scbarray[AHC_INB(ahc, SCB_TAG)];
|
1995-07-31 08:25:36 +00:00
|
|
|
if (ahc_match_scb (scbp, target, channel)){
|
|
|
|
/*
|
|
|
|
* We found an scb that needs to be aborted.
|
|
|
|
*/
|
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
|
|
|
scbp->flags = SCB_ABORTED|SCB_QUEUED_FOR_DONE;
|
1995-07-31 08:25:36 +00:00
|
|
|
scbp->xs->error |= xs_error;
|
|
|
|
if(scbp->position != timedout_scb)
|
|
|
|
untimeout(ahc_timeout, (caddr_t)scbp);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
1995-07-31 08:25:36 +00:00
|
|
|
i--;
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Now put the saved scbs back. */
|
|
|
|
for (queued = 0; queued < i; queued++) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, QINFIFO, saved_queue[queued]);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search waiting for selection list.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
u_char next, prev;
|
|
|
|
|
1996-05-30 07:19:59 +00:00
|
|
|
next = AHC_INB(ahc, WAITING_SCBH); /* Start at head of list. */
|
1995-07-31 08:25:36 +00:00
|
|
|
prev = SCB_LIST_NULL;
|
|
|
|
|
|
|
|
while (next != SCB_LIST_NULL) {
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, next);
|
|
|
|
scbp = ahc->scbarray[AHC_INB(ahc, SCB_TAG)];
|
1995-07-31 08:25:36 +00:00
|
|
|
/*
|
|
|
|
* Select the SCB.
|
|
|
|
*/
|
|
|
|
if (ahc_match_scb(scbp, target, channel)) {
|
1996-01-03 06:32:12 +00:00
|
|
|
next = ahc_abort_wscb(ahc, scbp, prev,
|
1996-05-30 07:19:59 +00:00
|
|
|
timedout_scb, xs_error);
|
1995-07-31 08:25:36 +00:00
|
|
|
found++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prev = next;
|
1996-05-30 07:19:59 +00:00
|
|
|
next = AHC_INB(ahc, SCB_NEXT);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Go through the entire SCB array now and look for
|
|
|
|
* commands for this target that are active. These
|
|
|
|
* are other (most likely tagged) commands that
|
|
|
|
* were disconnected when the reset occured.
|
|
|
|
*/
|
|
|
|
for(i = 0; i < ahc->numscbs; i++) {
|
|
|
|
scbp = ahc->scbarray[i];
|
|
|
|
if((scbp->flags & SCB_ACTIVE)
|
|
|
|
&& ahc_match_scb(scbp, target, channel)) {
|
|
|
|
/* Ensure the target is "free" */
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_unbusy_target(ahc, target, channel);
|
1996-04-20 21:29:27 +00:00
|
|
|
if( !(scbp->flags & SCB_PAGED_OUT) )
|
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, scbp->position);
|
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
1996-04-20 21:29:27 +00:00
|
|
|
}
|
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
|
|
|
scbp->flags = SCB_ABORTED|SCB_QUEUED_FOR_DONE;
|
1995-07-31 08:25:36 +00:00
|
|
|
scbp->xs->error |= xs_error;
|
1996-04-20 21:29:27 +00:00
|
|
|
if(scbp->tag != timedout_scb)
|
1995-07-31 08:25:36 +00:00
|
|
|
untimeout(ahc_timeout, (caddr_t)scbp);
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, active_scb);
|
1995-07-31 08:25:36 +00:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Manipulate the waiting for selection list and return the
|
|
|
|
* scb that follows the one that we remove.
|
|
|
|
*/
|
1995-10-31 18:41:49 +00:00
|
|
|
static u_char
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_abort_wscb (ahc, scbp, prev, timedout_scb, xs_error)
|
1996-01-03 06:32:12 +00:00
|
|
|
struct ahc_data *ahc;
|
1995-07-31 08:25:36 +00:00
|
|
|
struct scb *scbp;
|
|
|
|
u_char prev;
|
|
|
|
u_char timedout_scb;
|
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
|
|
|
u_int32_t xs_error;
|
1995-07-31 08:25:36 +00:00
|
|
|
{
|
|
|
|
u_char curscbp, next;
|
1996-04-20 21:29:27 +00:00
|
|
|
int target = ((scbp->tcl >> 4) & 0x0f);
|
|
|
|
char channel = (scbp->tcl & SELBUSB) ? 'B' : 'A';
|
1995-07-31 08:25:36 +00:00
|
|
|
/*
|
|
|
|
* Select the SCB we want to abort and
|
|
|
|
* pull the next pointer out of it.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
curscbp = AHC_INB(ahc, SCBPTR);
|
|
|
|
AHC_OUTB(ahc, SCBPTR, scbp->position);
|
|
|
|
next = AHC_INB(ahc, SCB_NEXT);
|
1995-07-31 08:25:36 +00:00
|
|
|
|
|
|
|
/* Clear the necessary fields */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCB_CONTROL, 0);
|
|
|
|
AHC_OUTB(ahc, SCB_NEXT, SCB_LIST_NULL);
|
|
|
|
ahc_unbusy_target(ahc, target, channel);
|
1995-07-31 08:25:36 +00:00
|
|
|
|
|
|
|
/* update the waiting list */
|
|
|
|
if( prev == SCB_LIST_NULL )
|
|
|
|
/* First in the list */
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, WAITING_SCBH, next);
|
1995-07-31 08:25:36 +00:00
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Select the scb that pointed to us
|
|
|
|
* and update its next pointer.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, prev);
|
|
|
|
AHC_OUTB(ahc, SCB_NEXT, next);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Point us back at the original scb position
|
|
|
|
* and inform the SCSI system that the command
|
|
|
|
* has been aborted.
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCBPTR, curscbp);
|
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
|
|
|
scbp->flags = SCB_ABORTED|SCB_QUEUED_FOR_DONE;
|
1995-07-31 08:25:36 +00:00
|
|
|
scbp->xs->error |= xs_error;
|
1996-04-20 21:29:27 +00:00
|
|
|
if(scbp->tag != timedout_scb)
|
1995-07-31 08:25:36 +00:00
|
|
|
untimeout(ahc_timeout, (caddr_t)scbp);
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
static void
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_busy_target(ahc, target, channel)
|
|
|
|
struct ahc_data *ahc;
|
1996-01-03 06:32:12 +00:00
|
|
|
u_char target;
|
|
|
|
char channel;
|
|
|
|
{
|
|
|
|
u_char active;
|
1996-05-30 07:19:59 +00:00
|
|
|
u_long active_port = ACTIVE_A;
|
|
|
|
|
1996-01-03 06:32:12 +00:00
|
|
|
if(target > 0x07 || channel == 'B') {
|
|
|
|
/*
|
|
|
|
* targets on the Second channel or
|
|
|
|
* above id 7 store info in byte two
|
|
|
|
* of HA_ACTIVE
|
|
|
|
*/
|
|
|
|
active_port++;
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
active = AHC_INB(ahc, active_port);
|
1996-01-03 06:32:12 +00:00
|
|
|
active |= (0x01 << (target & 0x07));
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, active_port, active);
|
1996-01-03 06:32:12 +00:00
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_unbusy_target(ahc, target, channel)
|
|
|
|
struct ahc_data *ahc;
|
1995-07-31 08:25:36 +00:00
|
|
|
u_char target;
|
|
|
|
char channel;
|
|
|
|
{
|
|
|
|
u_char active;
|
1996-05-30 07:19:59 +00:00
|
|
|
u_long active_port = ACTIVE_A;
|
|
|
|
|
1995-07-31 08:25:36 +00:00
|
|
|
if(target > 0x07 || channel == 'B') {
|
|
|
|
/*
|
|
|
|
* targets on the Second channel or
|
|
|
|
* above id 7 store info in byte two
|
|
|
|
* of HA_ACTIVE
|
|
|
|
*/
|
|
|
|
active_port++;
|
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
active = AHC_INB(ahc, active_port);
|
1995-07-31 08:25:36 +00:00
|
|
|
active &= ~(0x01 << (target & 0x07));
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, active_port, active);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_reset_current_bus(ahc)
|
|
|
|
struct ahc_data *ahc;
|
1995-07-31 08:25:36 +00:00
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSISEQ, SCSIRSTO);
|
1995-07-31 08:25:36 +00:00
|
|
|
DELAY(1000);
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SCSISEQ, 0);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static int
|
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
|
|
|
ahc_reset_channel(ahc, channel, timedout_scb, xs_error, initiate_reset)
|
1995-07-31 08:25:36 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
char channel;
|
|
|
|
u_char timedout_scb;
|
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
|
|
|
u_int32_t xs_error;
|
|
|
|
u_char initiate_reset;
|
1995-07-31 08:25:36 +00:00
|
|
|
{
|
|
|
|
u_char sblkctl;
|
|
|
|
char cur_channel;
|
|
|
|
u_long offset, offset_max;
|
|
|
|
int found;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up all the state information for the
|
|
|
|
* pending transactions on this bus.
|
|
|
|
*/
|
1996-01-03 06:32:12 +00:00
|
|
|
found = ahc_reset_device(ahc, ALL_TARGETS, channel,
|
1995-07-31 08:25:36 +00:00
|
|
|
timedout_scb, xs_error);
|
|
|
|
if(channel == 'B'){
|
|
|
|
ahc->needsdtr |= (ahc->needsdtr_orig & 0xff00);
|
|
|
|
ahc->sdtrpending &= 0x00ff;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, ACTIVE_B, 0);
|
|
|
|
offset = TARG_SCRATCH + 8;
|
|
|
|
offset_max = TARG_SCRATCH + 16;
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
else if (ahc->type & AHC_WIDE){
|
|
|
|
ahc->needsdtr = ahc->needsdtr_orig;
|
|
|
|
ahc->needwdtr = ahc->needwdtr_orig;
|
|
|
|
ahc->sdtrpending = 0;
|
|
|
|
ahc->wdtrpending = 0;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, ACTIVE_A, 0);
|
|
|
|
AHC_OUTB(ahc, ACTIVE_B, 0);
|
|
|
|
offset = TARG_SCRATCH;
|
|
|
|
offset_max = TARG_SCRATCH + 16;
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
ahc->needsdtr |= (ahc->needsdtr_orig & 0x00ff);
|
|
|
|
ahc->sdtrpending &= 0xff00;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, ACTIVE_A, 0);
|
|
|
|
offset = TARG_SCRATCH;
|
|
|
|
offset_max = TARG_SCRATCH + 8;
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
for(;offset < offset_max;offset++) {
|
|
|
|
/*
|
|
|
|
* Revert to async/narrow transfers
|
|
|
|
* until we renegotiate.
|
|
|
|
*/
|
|
|
|
u_char targ_scratch;
|
1996-05-30 07:19:59 +00:00
|
|
|
|
|
|
|
targ_scratch = AHC_INB(ahc, offset);
|
1995-07-31 08:25:36 +00:00
|
|
|
targ_scratch &= SXFR;
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, offset, targ_scratch);
|
1995-07-31 08:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
* Reset the bus if we are initiating this reset and
|
|
|
|
* restart/unpause the sequencer
|
1995-07-31 08:25:36 +00:00
|
|
|
*/
|
|
|
|
/* Case 1: Command for another bus is active */
|
1996-05-30 07:19:59 +00:00
|
|
|
sblkctl = AHC_INB(ahc, SBLKCTL);
|
1995-07-31 08:25:36 +00:00
|
|
|
cur_channel = (sblkctl & SELBUSB) ? 'B' : 'A';
|
|
|
|
if(cur_channel != channel)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Stealthily reset the other bus
|
|
|
|
* without upsetting the current bus
|
|
|
|
*/
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, SBLKCTL, sblkctl ^ SELBUSB);
|
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
|
|
|
if( initiate_reset )
|
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_reset_current_bus(ahc);
|
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
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI|CLRSELTIMEO);
|
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
|
|
|
AHC_OUTB(ahc, SBLKCTL, sblkctl);
|
1995-07-31 08:25:36 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
}
|
|
|
|
/* Case 2: A command from this bus is active or we're idle */
|
|
|
|
else {
|
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
|
|
|
if( initiate_reset )
|
|
|
|
{
|
1996-05-30 07:19:59 +00:00
|
|
|
ahc_reset_current_bus(ahc);
|
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
|
|
|
}
|
1996-05-30 07:19:59 +00:00
|
|
|
AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI|CLRSELTIMEO);
|
|
|
|
AHC_OUTB(ahc, CLRINT, CLRSCSIINT);
|
1995-07-31 08:25:36 +00:00
|
|
|
RESTART_SEQUENCER(ahc);
|
|
|
|
}
|
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
|
|
|
ahc_run_done_queue(ahc);
|
1995-07-31 08:25:36 +00:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void
|
|
|
|
ahc_run_done_queue(ahc)
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct scb *scbp;
|
|
|
|
|
|
|
|
for(i = 0; i < ahc->numscbs; i++) {
|
|
|
|
scbp = ahc->scbarray[i];
|
|
|
|
if(scbp->flags & SCB_QUEUED_FOR_DONE)
|
|
|
|
ahc_done(ahc, scbp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static int
|
1995-07-31 08:25:36 +00:00
|
|
|
ahc_match_scb (scb, target, channel)
|
|
|
|
struct scb *scb;
|
|
|
|
int target;
|
|
|
|
char channel;
|
|
|
|
{
|
1996-04-20 21:29:27 +00:00
|
|
|
int targ = (scb->tcl >> 4) & 0x0f;
|
|
|
|
char chan = (scb->tcl & SELBUSB) ? 'B' : 'A';
|
1995-07-31 08:25:36 +00:00
|
|
|
|
|
|
|
if (target == ALL_TARGETS)
|
|
|
|
return (chan == channel);
|
|
|
|
else
|
|
|
|
return ((chan == channel) && (targ == target));
|
|
|
|
}
|