aic79xx.c:

Implement the SCB_SILENT flag.  This is useful for
	hushing up the driver during DV or other operations
	that we expect to cause transmission errors.  The
	messages will still print if the SHOW_MASKED_ERRORS
	debug option is enabled.

	Save and restore the NEGOADDR address when setting
	new transfer settings.  The sequencer performs lookups
	in the negotiation table too and it expects NEGOADDR
	to remain consistent across pause/unpause sessions.

	Consistently use "offset" instead of "period" to determine
	if we are running sync or not.

	Add a SHOW_MESSAGES diagnostic for when we assert ATN
	during message processing.

	Print out IU, QAS, and RTI features when showing transfer options.

	Limit the syncrate after all option conformance
	changes have taken place in ahd_devlimited_syncrate.
	Changes in options may change the final syncrate we
	accept.

	Keep a copy of the hs_mailbox in our softc so that
	we can perform read/modify/write operations on the
	hs_mailbox without having to pause the sequencer to
	read the last written value.  Use the ENINT_COALESS
	flag in the hs_mailbox to toggle interrupt coalessing.

	Add entrypoints for enabling interrupt coalessing and
	setting both a timeout (how long to wait for commands
	to be coalessed) and a maximum commands to coaless value.
	Add a statistics timer that decides when to enable or
	disable interrupt coalessing based on load.

	Add a routine, ahd_reset_cmds_pending() which is used
	to update the CMDS_PENDING sequencer variable whenever
	error recovery compeltes SCBs without notifying the
	sequencer.  Since ahd_reset_cmds_pending is called
	during ahd_unpause() only if we've aborted SCBs, its
	call to ahd_flush_qoutfifo should not cause recursion
	through ahd_run_qoutfifo().  A panic has been added to
	ensure that this recursion does not occur.

	In ahd_search_qinfifo, update the CMDS_PENDING sequencer
	variable directly.  ahd_search_qinififo can be called
	in situations where using ahd_reset_cmds_pending() might
	cause recursion.  Since we can safely determine the
	exact number to reduce CMDS_PENDING by in this scenario
	without running the qoutfifo, the manual update is sufficient.

	Clean up diagnostics.
	Add ahd_flush_qoutfifo() which will run the qoutfifo
	as well as complete any commands sitting on the
	sequencer's COMPLETE_SCB lists or the good status FIFO.
	Use this routine in several places that did similar
	things in an add-hoc, but incomplete, fashion.  A call
	to this routine was also added to ahd_abort_scbs() to
	close a race.

	In ahd_pause_and_flushwork() only return once selections
	are safely disabled.  Flush all completed commands via
	ahd_flush_qoutfifo().

	Remove "Now packetized" diagnostic now that this
	information is incorperated into the actual negotiation
	messages that are displayed.

	When forcing renegotiation, don't clober the current
	ppr_options.  Much of the driver uses this information
	to determine if we are currently packetized or not.

	Remove some stray spaces at column 1 in ahd_set_tags.

	When complaining about getting a host message loop
	request with no pending messages, print out the
	SCB_CONTROL register down on the card.

	Modify the ahd_sent_msg() routine to handle a search
	for an outgoing identify message.  Use this to detect
	a msg reject on an identify message which typically
	indicates that the target thought we were packetized.
	Force a renegotiation in this case.

	In ahd_search_qinfifo(), wait more effectively for SCB
	DMA activities to cease.  We also disable SCB fetch
	operations since we are about to change the qinfifo
	and any fetch in progress will likely be invalidated.

	In ahd_qinfifo_count(), fix the qinfifo empty case.

	In ahd_dump_card_state(), print out CCSCBCTL in the
	correct mode.

	If we are a narrow controller, don't set the current
	width to unknown when forcing a future negotiation.
	This just confuses the code into attempting a wide
	negotiation on a narrow bus.

	Add support for task management function completions.

	Modify ahd_handle_devreset so that it can handle
	lun resets in addition to target resets.  Use
	ahd_handle_devreset for lun and target reset task
	management functions.

	Handle the abort task TMF race case better.  We now
	wait until any current selections are over and then
	set the TMF back to zero.  This should cause the sequencer
	to ignore the abort TMF completion should it occur.

	Correct a bug in the illegal phase handler that
	caused us to drop down to narrow when handling the
	unexpected command phase case after 3rd party
	reset of a packetized device.

	Indicate the features, bugs, and flags set in the softc
	that are used to control firmware patch download when
        booting verbose.

aic79xx.h:
	Add coalessing and HS_MAILBOX fields.

	Add per-softc variables for the stats "daemon".

	Add a debug option for interrupt coalessing activities.

	Add two new softc flags:
	o AHD_UPDATE_PEND_CMDS
	  Run ahd_reset_cmds_pending() on the next unpause.

	o AHD_RUNNING_QOUTFIFO
	  Used to catch recursion through ahd_run_qoutfifo().

aic79xx.reg:
	Correct register addresses related to the software timer
	and the DFDBCTL register.

	Add constants paramaterizing the software timer.

	Add scratch ram locations for storing interrupt coalessing
	tunables.

	Break INTMASK in SEQITNCTL out into INTMASK1 and INTMASK2.
	In at least the REV A, these are writable bits.  We make
	use of that for a swtimer workaround in the sequencer.

	Since HS_MAILBOX autoclears, provide a sequencer variable
	to store its contents.

	Add SEQINT codes for handling task management completions.

aic79xx.seq:
	Correct ignore wide residue processing check for
	a wide negotiation being in effect.  We must be
	in the SCSI register window in order to access the
	negotiation table.

	Use the software timer and a commands completed count to
	implement interrupt coalessing.  The command complete is
	deferred until either the maximum command threshold or a
	the expiration of a command deferral timer.  If we have
	more SCBs to complete to the host (sitting in COMPLETE_SCB
	lists), always try to coaless them up to our coalessing limit.
	If coalessing is enabled, but we have fewer commands oustanting
	than the host's min coalessing limit, complete the command
	immediately.

	Add code to track the number of commands outstanding.
	Commands are outstanding from the time they are placed
	into the execution queue until the DMA to post completion
	is setup.

	Add a workaround for intvec_2 interrupts on the H2A4.
	In H2A4, the mode pointer is not saved for intvec2, but
	is restored on iret.  This can lead to the restoration
	of a bogus mode ptr.  Manually clear the intmask bits and
	do a normal return to compensate.  We use intvec_2 to
	track interrupt coalessing timeouts.

	Since we cannot disable the swtimer's countdown, simply
	mask its interrupt once we no longer care about it firing.

	In idle_loop_cchan, update LOCAL_HS_MAILBOX everytime
	we are notified of an HS_MAILBOX update via the
	HS_MAILBOX_ACT bit in QOFF_CTLSTA.  We have to use a
	local copy of persistant portions of the HS_MAILBOX as
	the mailbox auto-clears on any read.

	Move the test for the cfg4istat interrupt up an instruction
	to hopefully close a race between the next outgoing selection
	and our disabling of selections.

	Add a missing ret to the last instruction in load_overrun_buf.

	Add notifications to the host of task management
	completions as well as the completions for commands
	that completed successfully before their corresponding
	TMF could be sent.

	Hold a critical section during select-out processing
	until we have a fully identified connection.  This
	removes a race condition with the legacy abort handler.

	Correct a few spelling errors in some comments.

aic79xx_inline.h:
	Call ahd_reset_cmds_pending() in ahd_unpause if required.

	Update cmdcmplt interrupt statistics in our interrupt
	handler.

	Allow callers to ahd_send_scb() to set the task management
	function.

aic79xx_pci.c:
	Disable SERR and pause the controller prior to performing
	our mmapped I/O test.  The U320 controllers do not support
	"auto-access-pause".

aic79xx_osm.c:
	Set the task management function now that
	ahd_send_scb() doesn't do it for us.  We
	also perform a lun reset in response to BDR
	requests to packetized devices.
This commit is contained in:
gibbs 2003-01-20 20:17:35 +00:00
parent 350972d0c2
commit 623abc78ac
7 changed files with 844 additions and 152 deletions

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#73 $
* $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#78 $
*
* $FreeBSD$
*/
@ -97,6 +97,14 @@ struct scb_platform_data;
SCB_GET_TARGET(ahd, scb)
#define SCB_GET_TARGET_MASK(ahd, scb) \
(0x01 << (SCB_GET_TARGET_OFFSET(ahd, scb)))
#ifdef AHD_DEBUG
#define SCB_IS_SILENT(scb) \
((ahd_debug & AHD_SHOW_MASKED_ERRORS) == 0 \
&& (((scb)->flags & SCB_SILENT) != 0))
#else
#define SCB_IS_SILENT(scb) \
(((scb)->flags & SCB_SILENT) != 0)
#endif
/*
* TCLs have the following format: TTTTLLLLLLLL
*/
@ -348,7 +356,9 @@ typedef enum {
AHD_CURRENT_SENSING = 0x40000,
AHD_SCB_CONFIG_USED = 0x80000,/* No SEEPROM but SCB had info. */
AHD_HP_BOARD = 0x100000,
AHD_RESET_POLL_ACTIVE = 0x200000
AHD_RESET_POLL_ACTIVE = 0x200000,
AHD_UPDATE_PEND_CMDS = 0x400000,
AHD_RUNNING_QOUTFIFO = 0x800000
} ahd_flag;
/************************* Hardware SCB Definition ***************************/
@ -560,7 +570,13 @@ typedef enum {
SCB_EXPECT_PPR_BUSFREE = 0x01000,
SCB_PKT_SENSE = 0x02000,
SCB_CMDPHASE_ABORT = 0x04000,
SCB_ON_COL_LIST = 0x08000
SCB_ON_COL_LIST = 0x08000,
SCB_SILENT = 0x10000 /*
* Be quiet about transmission type
* errors. They are expected and we
* don't want to upset the user. This
* flag is typically used during DV.
*/
} scb_flag;
struct scb {
@ -707,7 +723,6 @@ struct ahd_tmode_lstate;
#define AHD_TRANS_ACTIVE 0x03 /* Assume this target is on the bus */
#define AHD_TRANS_GOAL 0x04 /* Modify negotiation goal */
#define AHD_TRANS_USER 0x08 /* Modify user negotiation settings */
#define AHD_PERIOD_ASYNC 0xFF
#define AHD_PERIOD_10MHz 0x19
#define AHD_WIDTH_UNKNOWN 0xFF
@ -757,7 +772,6 @@ struct ahd_tmode_tstate {
/*
* Points of interest along the negotiated transfer scale.
*/
#define AHD_SYNCRATE_MAX 0x8
#define AHD_SYNCRATE_160 0x8
#define AHD_SYNCRATE_PACED 0x8
#define AHD_SYNCRATE_DT 0x9
@ -768,6 +782,7 @@ struct ahd_tmode_tstate {
#define AHD_SYNCRATE_SYNC 0x32
#define AHD_SYNCRATE_MIN 0x60
#define AHD_SYNCRATE_ASYNC 0xFF
#define AHD_SYNCRATE_MAX AHD_SYNCRATE_160
/* Safe and valid period for async negotiations. */
#define AHD_ASYNC_XFER_PERIOD 0x44
@ -1050,6 +1065,16 @@ struct ahd_softc {
* Timer handles for timer driven callbacks.
*/
ahd_timer_t reset_timer;
ahd_timer_t stat_timer;
/*
* Statistics.
*/
#define AHD_STAT_UPDATE_US 250000 /* 250ms */
#define AHD_STAT_BUCKETS 4
u_int cmdcmplt_bucket;
uint32_t cmdcmplt_counts[AHD_STAT_BUCKETS];
uint32_t cmdcmplt_total;
/*
* Card characteristics
@ -1093,6 +1118,12 @@ struct ahd_softc {
struct target_cmd *targetcmds;
uint8_t tqinfifonext;
/*
* Cached verson of the hs_mailbox so we can avoid
* pausing the sequencer during mailbox updates.
*/
uint8_t hs_mailbox;
/*
* Incoming and outgoing message handling.
*/
@ -1141,6 +1172,22 @@ struct ahd_softc {
/* Selection Timer settings */
int seltime;
/*
* Interrupt coalessing settings.
*/
#define AHD_INT_COALESSING_TIMER_DEFAULT 250 /*us*/
#define AHD_INT_COALESSING_MAXCMDS_DEFAULT 10
#define AHD_INT_COALESSING_MAXCMDS_MAX 127
#define AHD_INT_COALESSING_MINCMDS_DEFAULT 5
#define AHD_INT_COALESSING_MINCMDS_MAX 127
#define AHD_INT_COALESSING_THRESHOLD_DEFAULT 2000
#define AHD_INT_COALESSING_STOP_THRESHOLD_DEFAULT 1000
u_int int_coalessing_timer;
u_int int_coalessing_maxcmds;
u_int int_coalessing_mincmds;
u_int int_coalessing_threshold;
u_int int_coalessing_stop_threshold;
uint16_t user_discenable;/* Disconnection allowed */
uint16_t user_tagenable;/* Tagged Queuing allowed */
};
@ -1227,6 +1274,7 @@ extern const int ahd_num_aic7770_devs;
/*************************** Function Declarations ****************************/
/******************************************************************************/
void ahd_reset_cmds_pending(struct ahd_softc *ahd);
u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
void ahd_busy_tcl(struct ahd_softc *ahd,
u_int tcl, u_int busyid);
@ -1260,6 +1308,12 @@ int ahd_default_config(struct ahd_softc *ahd);
int ahd_parse_cfgdata(struct ahd_softc *ahd,
struct seeprom_config *sc);
void ahd_intr_enable(struct ahd_softc *ahd, int enable);
void ahd_update_coalessing_values(struct ahd_softc *ahd,
u_int timer,
u_int maxcmds,
u_int mincmds);
void ahd_enable_coalessing(struct ahd_softc *ahd,
int enable);
void ahd_pause_and_flushwork(struct ahd_softc *ahd);
int ahd_suspend(struct ahd_softc *ahd);
int ahd_resume(struct ahd_softc *ahd);
@ -1282,6 +1336,7 @@ int ahd_wait_flexport(struct ahd_softc *ahd);
/*************************** Interrupt Services *******************************/
void ahd_pci_intr(struct ahd_softc *ahd);
void ahd_clear_intstat(struct ahd_softc *ahd);
void ahd_flush_qoutfifo(struct ahd_softc *ahd);
void ahd_run_qoutfifo(struct ahd_softc *ahd);
#ifdef AHD_TARGET_MODE
void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
@ -1405,7 +1460,8 @@ extern uint32_t ahd_debug;
#define AHD_SHOW_QUEUE 0x02000
#define AHD_SHOW_TQIN 0x04000
#define AHD_SHOW_SG 0x08000
#define AHD_DEBUG_SEQUENCER 0x10000
#define AHD_SHOW_INT_COALESSING 0x10000
#define AHD_DEBUG_SEQUENCER 0x20000
#endif
void ahd_print_scb(struct scb *scb);
void ahd_print_devinfo(struct ahd_softc *ahd,

View File

@ -39,7 +39,7 @@
*
* $FreeBSD$
*/
VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#56 $"
VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#60 $"
/*
* This file is processed by the aic7xxx_asm utility for use in assembling
@ -173,6 +173,23 @@ register SEQINTCODE {
STATUS_OVERRUN,
CFG4OVERRUN,
ENTERING_NONPACK,
TASKMGMT_FUNC_COMPLETE, /*
* Task management function
* request completed with
* an expected busfree.
*/
TASKMGMT_CMD_CMPLT_OKAY, /*
* A command with a non-zero
* task management function
* has completed via the normal
* command completion method
* for commands with a zero
* task management function.
* This happens when an attempt
* to abort a command loses
* the race for the command to
* complete normally.
*/
TRACEPOINT0,
TRACEPOINT1,
TRACEPOINT2,
@ -265,16 +282,17 @@ register HESCB_QOFF {
* Host Mailbox
*/
register HS_MAILBOX {
address 0x0B
address 0x00B
access_mode RW
mask HOST_TQINPOS 0x80 /* Boundary at either 0 or 128 */
mask ENINT_COALESS 0x40 /* Perform interrupt coalessing */
}
/*
* Sequencer Interupt Status
*/
register SEQINTSTAT {
address 0x0C
address 0x00C
access_mode RO
field SEQ_SWTMRTO 0x10
field SEQ_SEQINT 0x08
@ -287,7 +305,7 @@ register SEQINTSTAT {
* Clear SEQ Interrupt
*/
register CLRSEQINTSTAT {
address 0x0C0
address 0x00C
access_mode WO
field CLRSEQ_SWTMRTO 0x10
field CLRSEQ_SEQINT 0x08
@ -300,7 +318,7 @@ register CLRSEQINTSTAT {
* Software Timer
*/
register SWTIMER {
address 0x0E0
address 0x00E
access_mode RW
size 2
}
@ -3105,21 +3123,6 @@ register RCVRBIASCALC {
modes M_CFG
}
/*
* Data FIFO Debug Control
*/
register DFDBCTL {
address 0x0C8
access_mode RW
modes M_DFF0, M_DFF1
field DFF_CIO_WR_RDY 0x20
field DFF_CIO_RD_RDY 0x10
field DFF_DIR_ERR 0x08
field DFF_RAMBIST_FAIL 0x04
field DFF_RAMBIST_DONE 0x02
field DFF_RAMBIST_EN 0x01
}
/*
* Data FIFO Backup Read Pointer
* Contains the data FIFO address to be restored if the last
@ -3141,6 +3144,21 @@ register SKEWCALC {
modes M_CFG
}
/*
* Data FIFO Debug Control
*/
register DFDBCTL {
address 0x0CB
access_mode RW
modes M_DFF0, M_DFF1
field DFF_CIO_WR_RDY 0x20
field DFF_CIO_RD_RDY 0x10
field DFF_DIR_ERR 0x08
field DFF_RAMBIST_FAIL 0x04
field DFF_RAMBIST_DONE 0x02
field DFF_RAMBIST_EN 0x01
}
/*
* Data FIFO Space Count
* Number of FIFO locations that are free.
@ -3226,7 +3244,8 @@ register SEQINTCTL {
field INT1_CONTEXT 0x20
field SCS_SEQ_INT1M1 0x10
field SCS_SEQ_INT1M0 0x08
field INTMASK 0x06
field INTMASK2 0x04
field INTMASK1 0x02
field IRET 0x01
}
@ -3686,6 +3705,53 @@ scratch_ram {
size 2
}
/*
* The maximum amount of time to wait, when interrupt coalessing
* is enabled, before issueing a CMDCMPLT interrupt for a completed
* command.
*/
INT_COALESSING_TIMER {
size 2
}
/*
* The maximum number of commands to coaless into a single interrupt.
* Actually the 2's complement of that value to simplify sequencer
* code.
*/
INT_COALESSING_MAXCMDS {
size 1
}
/*
* The minimum number of commands still outstanding required
* to continue coalessing (2's compliment of value).
*/
INT_COALESSING_MINCMDS {
size 1
}
/*
* Number of commands "in-flight".
*/
CMDS_PENDING {
size 2
}
/*
* The count of commands that have been coalessed.
*/
INT_COALESSING_CMDCOUNT {
size 1
}
/*
* Since the HS_MAIBOX is self clearing, copy its contents to
* this position in scratch ram every time it changes.
*/
LOCAL_HS_MAILBOX {
size 1
}
/*
* Target-mode CDB type to CDB length table used
* in non-packetized operation.
@ -3860,6 +3926,13 @@ const SCB_TRANSFER_SIZE_1BYTE_LUN 48
/* PKT_OVERRUN_BUFSIZE must be a multiple of 256 less than 64K */
const PKT_OVERRUN_BUFSIZE 512
/*
* Timer parameters.
*/
const AHD_TIMER_US_PER_TICK 25
const AHD_TIMER_MAX_TICKS 0xFFFF
const AHD_TIMER_MAX_US (AHD_TIMER_MAX_TICKS * AHD_TIMER_US_PER_TICK)
/*
* Downloaded (kernel inserted) constants
*/

View File

@ -40,7 +40,7 @@
* $FreeBSD$
*/
VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#73 $"
VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#78 $"
PATCH_ARG_LIST = "struct ahd_softc *ahd"
PREFIX = "ahd_"
@ -107,6 +107,16 @@ idle_loop_gsfifo_in_scsi_mode:
good_status_IU_done:
bmov SCBPTR, GSFIFO, 2;
clr SCB_SCSI_STATUS;
/*
* If a command completed before an attempted task management
* function completed, notify the host after disabling any
* pending select-outs.
*/
test SCB_TASK_MANAGEMENT, 0xFF jz gsfifo_complete_normally;
test SSTAT0, SELDO|SELINGO jnz . + 2;
and SCSISEQ0, ~ENSELO;
SET_SEQINTCODE(TASKMGMT_CMD_CMPLT_OKAY)
gsfifo_complete_normally:
or SCB_CONTROL, STATUS_RCVD;
/*
@ -164,6 +174,10 @@ idle_loop_next_fifo:
idle_loop_cchan:
SET_MODE(M_CCHAN, M_CCHAN)
test QOFF_CTLSTA, HS_MAILBOX_ACT jz hs_mailbox_empty;
mov LOCAL_HS_MAILBOX, HS_MAILBOX;
or QOFF_CTLSTA, HS_MAILBOX_ACT;
hs_mailbox_empty:
BEGIN_CRITICAL;
test CCSCBCTL, CCARREN|CCSCBEN jz scbdma_idle;
test CCSCBCTL, CCSCBDIR jnz fetch_new_scb_inprog;
@ -181,19 +195,65 @@ scbdma_tohost_done:
and CCSCBCTL, ~(CCARREN|CCSCBEN) ret;
fill_qoutfifo_dmadone:
and CCSCBCTL, ~(CCARREN|CCSCBEN);
mvi INTSTAT, CMDCMPLT;
call qoutfifo_updated;
mvi COMPLETE_SCB_DMAINPROG_HEAD[1], SCB_LIST_NULL;
bmov QOUTFIFO_NEXT_ADDR, SCBHADDR, 4;
test QOFF_CTLSTA, SDSCB_ROLLOVR jz return;
bmov QOUTFIFO_NEXT_ADDR, SHARED_DATA_ADDR, 4;
xor QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID_TOGGLE ret;
qoutfifo_updated:
/*
* If there are more commands waiting to be dma'ed
* to the host, always coaless. Otherwise honor the
* host's wishes.
*/
cmp COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne coaless_by_count;
cmp COMPLETE_SCB_HEAD[1], SCB_LIST_NULL jne coaless_by_count;
test LOCAL_HS_MAILBOX, ENINT_COALESS jz issue_cmdcmplt;
/*
* If we have relatively few commands outstanding, don't
* bother waiting for another command to complete.
*/
test CMDS_PENDING[1], 0xFF jnz coaless_by_count;
/* Add -1 so that jnc means <= not just < */
add A, -1, INT_COALESSING_MINCMDS;
add NONE, A, CMDS_PENDING;
jnc issue_cmdcmplt;
/*
* If coalessing, only coaless up to the limit
* provided by the host driver.
*/
coaless_by_count:
mov A, INT_COALESSING_MAXCMDS;
add NONE, A, INT_COALESSING_CMDCOUNT;
jc issue_cmdcmplt;
/*
* If the timer is not currently active,
* fire it up.
*/
test INTCTL, SWTMINTMASK jz return;
bmov SWTIMER, INT_COALESSING_TIMER, 2;
mvi CLRSEQINTSTAT, CLRSEQ_SWTMRTO;
or INTCTL, SWTMINTEN|SWTIMER_START;
and INTCTL, ~SWTMINTMASK ret;
issue_cmdcmplt:
mvi INTSTAT, CMDCMPLT;
clr INT_COALESSING_CMDCOUNT;
or INTCTL, SWTMINTMASK ret;
BEGIN_CRITICAL;
fetch_new_scb_inprog:
test CCSCBCTL, ARRDONE jz return;
fetch_new_scb_done:
and CCSCBCTL, ~(CCARREN|CCSCBEN);
bmov REG0, SCBPTR, 2;
clr A;
add CMDS_PENDING, 1;
adc CMDS_PENDING[1], A;
/* Update the next SCB address to download. */
bmov NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
mvi SCB_NEXT[1], SCB_LIST_NULL;
@ -229,7 +289,6 @@ scbdma_idle:
/*
* Give precedence to downloading new SCBs to execute
* unless select-outs are currently frozen.
* XXX Use a timer to prevent completion starvation.
*/
test SEQ_FLAGS2, SELECTOUT_QFROZEN jnz . + 2;
BEGIN_CRITICAL;
@ -251,6 +310,9 @@ fill_qoutfifo_loop:
mov CCSCBRAM, SCBPTR;
or CCSCBRAM, A, SCBPTR[1];
mov NONE, SDSCB_QOFF;
inc INT_COALESSING_CMDCOUNT;
add CMDS_PENDING, -1;
adc CMDS_PENDING[1], -1;
cmp SCB_NEXT_COMPLETE[1], SCB_LIST_NULL je fill_qoutfifo_done;
cmp CCSCBADDR, CCSCBADDR_MAX je fill_qoutfifo_done;
test QOFF_CTLSTA, SDSCB_ROLLOVR jnz fill_qoutfifo_done;
@ -419,7 +481,7 @@ select_in:
/*
* This exposes a window whereby a
* busfree just after a selection will
* be missed, but there is not other safe
* be missed, but there is no other safe
* way to enable busfree detection if
* the busfreerev function is broken.
*/
@ -545,7 +607,6 @@ select_out_inc_tid_q:
cmp WAITING_TID_HEAD[1], SCB_LIST_NULL jne . + 2;
mvi WAITING_TID_TAIL[1], SCB_LIST_NULL;
bmov SCBPTR, CURRSCB, 2;
END_CRITICAL;
mvi CLRSINT0, CLRSELDO;
test LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_phase;
test LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_phase;
@ -554,17 +615,23 @@ END_CRITICAL;
* If this is a packetized connection, return to our
* idle_loop and let our interrupt handler deal with
* any connection setup/teardown issues. The only
* exception is the case of MK_MESSAGE SCBs. In the
* A, the LQO manager transitions to LQOSTOP0 even if
* we have selected out with ATN asserted and the target
* REQs in a non-packet phase.
* exceptions are the case of MK_MESSAGE and task management
* SCBs.
*/
if ((ahd->bugs & AHD_LQO_ATNO_BUG) != 0) {
/*
* In the A, the LQO manager transitions to LQOSTOP0 even if
* we have selected out with ATN asserted and the target
* REQs in a non-packet phase.
*/
test SCB_CONTROL, MK_MESSAGE jz select_out_no_message;
test SCSISIGO, ATNO jnz select_out_non_packetized;
select_out_no_message:
}
test LQOSTAT2, LQOSTOP0 jnz idle_loop;
test LQOSTAT2, LQOSTOP0 jz select_out_non_packetized;
test SCB_TASK_MANAGEMENT, 0xFF jz idle_loop;
SET_SEQINTCODE(TASKMGMT_FUNC_COMPLETE)
jmp idle_loop;
select_out_non_packetized:
/* Non packetized request. */
@ -573,7 +640,7 @@ select_out_non_packetized:
/*
* This exposes a window whereby a
* busfree just after a selection will
* be missed, but there is not other safe
* be missed, but there is no other safe
* way to enable busfree detection if
* the busfreerev function is broken.
*/
@ -582,6 +649,8 @@ select_out_non_packetized:
}
mov SAVED_SCSIID, SCB_SCSIID;
mov SAVED_LUN, SCB_LUN;
mvi SEQ_FLAGS, NO_CDB_SENT;
END_CRITICAL;
or SXFRCTL0, SPIOEN;
/*
@ -590,7 +659,6 @@ select_out_non_packetized:
* asserted.
*/
mvi MSG_OUT, MSG_IDENTIFYFLAG;
mvi SEQ_FLAGS, NO_CDB_SENT;
/*
* Main loop for information transfer phases. Wait for the
@ -781,14 +849,17 @@ host_message_loop:
jmp host_message_loop;
mesgin_ign_wide_residue:
mov SAVED_MODE, MODE_PTR;
SET_MODE(M_SCSI, M_SCSI)
shr NEGOADDR, 4, SAVED_SCSIID;
test NEGCONOPTS, WIDEXFER jz mesgin_reject;
mov A, NEGCONOPTS;
RESTORE_MODE(SAVED_MODE)
test A, WIDEXFER jz mesgin_reject;
/* Pull the residue byte */
mvi REG0 call inb_next;
cmp REG0, 0x01 jne mesgin_reject;
test SCB_RESIDUAL_SGPTR[0], SG_LIST_NULL jz . + 2;
test DATA_COUNT_ODD, 0x1 jz mesgin_done;
SET_SEQINTCODE(IGN_WIDE_RES)
jmp mesgin_done;
mesgin_proto_violation:
@ -946,7 +1017,7 @@ complete_nomsg:
freeze_queue:
/* Cancel any pending select-out. */
test SSTAT0, SELDO jnz . + 2;
test SSTAT0, SELDO|SELINGO jnz . + 2;
and SCSISEQ0, ~ENSELO;
mov ACCUM_SAVE, A;
clr A;
@ -1481,11 +1552,28 @@ sgptr_fixup_done:
clr SCB_RESIDUAL_DATACNT[3]; /* We are not the last seg */
bmov SCB_RESIDUAL_DATACNT, SHCNT, 3 ret;
export timer_isr:
call issue_cmdcmplt;
mvi CLRSEQINTSTAT, CLRSEQ_SWTMRTO;
if ((ahd->bugs & AHD_SET_MODE_BUG) != 0) {
/*
* In H2A4, the mode pointer is not saved
* for intvec2, but is restored on iret.
* This can lead to the restoration of a
* bogus mode ptr. Manually clear the
* intmask bits and do a normal return
* to compensate.
*/
and SEQINTCTL, ~(INTMASK2|INTMASK1) ret;
} else {
or SEQINTCTL, IRET ret;
}
export seq_isr:
nop; /* Jumps in the first ISR instruction fail on Rev A. */
test SEQINTSRC, SAVEPTRS jnz saveptr_intr;
test SEQINTSRC, CFG4DATA jnz cfg4data_intr;
test SEQINTSRC, CFG4ISTAT jnz cfg4istat_intr;
test SEQINTSRC, SAVEPTRS jnz saveptr_intr;
test SEQINTSRC, CFG4ICMD jnz cfg4icmd_intr;
SET_SEQINTCODE(INVALID_SEQINT)
@ -1536,7 +1624,12 @@ cfg4istat_setup_handler:
/*
* Status pkt is transferring to host.
* Wait in idle loop for transfer to complete.
* If a command completed before an attempted
* task management function completed, notify the host.
*/
test SCB_TASK_MANAGEMENT, 0xFF jz cfg4istat_no_taskmgmt_func;
SET_SEQINTCODE(TASKMGMT_CMD_CMPLT_OKAY)
cfg4istat_no_taskmgmt_func:
call pkt_handle_status;
or SEQINTCTL, IRET ret;
@ -1790,7 +1883,7 @@ load_overrun_buf:
/* PKT_OVERRUN_BUFSIZE is a multiple of 256 */
clr HCNT[0];
mvi HCNT[1], ((PKT_OVERRUN_BUFSIZE >> 8) & 0xFF);
clr HCNT[2];
clr HCNT[2] ret;
}
cfg4icmd_intr:

View File

@ -2,7 +2,7 @@
* Inline routines shareable across OS platforms.
*
* Copyright (c) 1994-2001 Justin T. Gibbs.
* Copyright (c) 2000-2002 Adaptec Inc.
* Copyright (c) 2000-2003 Adaptec Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,7 +37,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#39 $
* $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#41 $
*
* $FreeBSD$
*/
@ -217,8 +217,11 @@ ahd_unpause(struct ahd_softc *ahd)
* prior to the first change of the mode.
*/
if (ahd->saved_src_mode != AHD_MODE_UNKNOWN
&& ahd->saved_dst_mode != AHD_MODE_UNKNOWN)
&& ahd->saved_dst_mode != AHD_MODE_UNKNOWN) {
if ((ahd->flags & AHD_UPDATE_PEND_CMDS) != 0)
ahd_reset_cmds_pending(ahd);
ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
}
if ((ahd_inb(ahd, INTSTAT) & ~(SWTMINT | CMDCMPLT)) == 0)
ahd_outb(ahd, HCNTRL, ahd->unpause);
@ -269,7 +272,6 @@ ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
if ((scb->flags & SCB_PACKETIZED) != 0) {
/* XXX what about ACA?? It is type 4, but TAG_TYPE == 0x3. */
scb->hscb->task_attribute= scb->hscb->control & SCB_TAG_TYPE;
scb->hscb->task_management = 0;
/*
* For Rev A short lun workaround.
*/
@ -913,6 +915,8 @@ ahd_intr(struct ahd_softc *ahd)
ahd_flush_device_writes(ahd);
}
ahd_run_qoutfifo(ahd);
ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++;
ahd->cmdcmplt_total++;
#ifdef AHD_TARGET_MODE
if ((ahd->flags & AHD_TARGETROLE) != 0)
ahd_run_tqinfifo(ahd, /*paused*/FALSE);

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#24 $
* $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#25 $
*
* $FreeBSD$
*/
@ -465,6 +465,7 @@ ahd_action(struct cam_sim *sim, union ccb *ccb)
hscb->cdb_len = 0;
scb->flags |= SCB_DEVICE_RESET;
hscb->control |= MK_MESSAGE;
hscb->task_management = SIU_TASKMGMT_LUN_RESET;
ahd_execute_scb(scb, NULL, 0, 0);
} else {
#ifdef AHD_TARGET_MODE
@ -488,6 +489,7 @@ ahd_action(struct cam_sim *sim, union ccb *ccb)
ahd_htole16(ccb->csio.tag_id);
}
#endif
hscb->task_management = 0;
if (ccb->ccb_h.flags & CAM_TAG_ACTION_VALID)
hscb->control |= ccb->csio.tag_action;
@ -1112,8 +1114,11 @@ ahd_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
&& (ccb->ccb_h.flags & CAM_DIS_DISCONNECT) == 0)
scb->hscb->control |= DISCENB;
if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0)
if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
scb->flags |= SCB_PACKETIZED;
if (scb->hscb->task_management != 0)
scb->hscb->control &= ~MK_MESSAGE;
}
if ((ccb->ccb_h.flags & CAM_NEGOTIATE) != 0
&& (tinfo->goal.width != 0

View File

@ -38,7 +38,7 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#60 $
* $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#61 $
*
* $FreeBSD$
*/
@ -379,15 +379,20 @@ int
ahd_pci_test_register_access(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
uint32_t cmd;
int error;
uint8_t seqctl;
uint8_t hcntrl;
saved_modes = ahd_save_modes(ahd);
error = EIO;
/* Enable PCI error interrupt status */
seqctl = ahd_inb(ahd, SEQCTL0);
ahd_outb(ahd, SEQCTL0, seqctl & ~FAILDIS);
/*
* Enable PCI error interrupt status, but suppress NMIs
* generated by SERR raised due to target aborts.
*/
cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
cmd & ~PCIM_CMD_SERRESPEN, /*bytes*/2);
/*
* First a simple test to see if any
@ -397,7 +402,8 @@ ahd_pci_test_register_access(struct ahd_softc *ahd)
* be zero so it is a good register to
* use for this test.
*/
if (ahd_inb(ahd, HCNTRL) == 0xFF)
hcntrl = ahd_inb(ahd, HCNTRL);
if (hcntrl == 0xFF)
goto fail;
/*
@ -407,6 +413,10 @@ ahd_pci_test_register_access(struct ahd_softc *ahd)
* either, so look for data corruption and/or flaged
* PCI errors.
*/
ahd_outb(ahd, HCNTRL, hcntrl|PAUSE);
while (ahd_is_paused(ahd) == 0)
;
ahd_outb(ahd, SEQCTL0, PERRORDIS);
ahd_outl(ahd, SRAM_BASE, 0x5aa555aa);
if (ahd_inl(ahd, SRAM_BASE) != 0x5aa555aa)
goto fail;
@ -440,7 +450,8 @@ ahd_pci_test_register_access(struct ahd_softc *ahd)
}
ahd_restore_modes(ahd, saved_modes);
ahd_outb(ahd, SEQCTL0, seqctl);
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS);
ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, cmd, /*bytes*/2);
return (error);
}