2000-09-16 20:02:28 +00:00
|
|
|
/*
|
|
|
|
* FreeBSD platform specific driver option settings, data structures,
|
|
|
|
* function declarations and includes.
|
|
|
|
*
|
2001-01-27 20:54:24 +00:00
|
|
|
* Copyright (c) 1994-2001 Justin T. Gibbs.
|
2000-09-16 20:02:28 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU Public License ("GPL").
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2002-08-31 06:44:20 +00:00
|
|
|
* $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#10 $
|
2000-09-16 20:02:28 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _AIC7XXX_FREEBSD_H_
|
|
|
|
#define _AIC7XXX_FREEBSD_H_
|
|
|
|
|
|
|
|
#include <opt_aic7xxx.h> /* for config options */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/bus.h> /* For device_t */
|
2002-08-31 06:44:20 +00:00
|
|
|
#if __FreeBSD_version >= 500000
|
2002-04-26 22:48:23 +00:00
|
|
|
#include <sys/endian.h>
|
2002-08-31 06:44:20 +00:00
|
|
|
#endif
|
ahc_eisa.c:
ahc_pci.c:
Add detach support.
Make use of soft allocated on our behalf by newbus.
For PCI devices, disable the mapping type we aren't
using for extra protection from rogue code.
aic7xxx_93cx6.c:
aic7xxx_93cx6.h:
Sync perforce IDs.
aic7xxx_freebsd.c:
Capture the eventhandle returned by EVENTHANDER_REGISTER
so we can kill the handler off during detach.
Use AHC_* constants instead of hard coded numbers in a
few more places.
Test PPR option state when deciding to "really" negotiate
when the CAM_NEGOTIATE flag is passed in a CCB.
Make use of core "ahc_pause_and_flushwork" routine in our
timeout handler rather than re-inventing this code.
Cleanup all of our resources (really!) in ahc_platform_free().
We should be all set to become a module now.
Implement the core ahc_detach() routine shared by all of
the FreeBSD front-ends.
aic7xxx_freebsd.h:
Softc storage for our event handler.
Null implementation for the ahc_platform_flushwork() OSM
callback. FreeBSD doesn't need this as XPT callbacks are
safe from all contexts and are done directly in ahc_done().
aic7xxx_inline.h:
Implement new lazy interrupt scheme. To avoid an extra
PCI bus read, we first check our completion queues to
see if any work has completed. If work is available, we
assume that this is the source of the interrupt and skip
reading INTSTAT. Any remaining interrupt status will be
cleared by a second call to the interrupt handler should
the interrupt line still be asserted. This drops the
interrupt handler down to a single PCI bus read in the
common case of I/O completion. This is the same overhead
as in the not so distant past, but the extra sanity of
perforning a PCI read after clearing the command complete
interrupt and before running the completion queue to avoid
missing command complete interrupts added a cycle.
aic7xxx.c:
During initialization, be sure to initialize all scratch
ram locations before they are read to avoid parity errors.
In this case, we use a new function, ahc_unbusy_tcl() to
initialize the scratch ram busy target table.
Replace instances of ahc_index_busy_tcl() used to unbusy
a tcl without looking at the old value with ahc_unbusy_tcl().
Modify ahc_sent_msg so that it can find single byte messages.
ahc_sent_msg is now used to determine if a transfer negotiation
attempt resulted in a bus free.
Be more careful in filtering out only the SCSI interrupts
of interest in ahc_handle_scsiint.
Rearrange interrupt clearing code to ensure that at least
one PCI transaction occurrs after hitting CLRSINT1 and
writting to CLRINT. CLRSINT1 writes take a bit to
take effect, and the re-arrangement provides sufficient
delay to ensure the write to CLRINT is effective. The
old code might report a spurious interrupt on some "fast"
chipsets.
export ahc-update_target_msg_request for use by OSM code.
If a target does not respond to our ATN request, clear
it once we move to a non-message phase. This avoids
sending a MSG_NOOP in some later message out phase.
Use max lun and max target constants instead of
hard-coded values.
Use softc storage built into our device_t under FreeBSD.
Fix a bug in ahc_free() that caused us to delete
resources that were not allocated.
Clean up any tstate/lstate info in ahc_free().
Clear the powerdown state in ahc_reset() so that
registers can be accessed.
Add a preliminary function for pausing the chip and
processing any posted work.
Add a preliminary suspend and resume functions.
aic7xxx.h:
Limit the number of supported luns to 64. We don't
support information unit transfers, so this is the
maximum that makes sense for these chips.
Add a new flag AHC_ALL_INTERRUPTS that forces the
processing of all interrupt state in a single invokation
of ahc_intr(). When the flag is not set, we use the
lazy interrupt handling scheme.
Add data structures to store controller state while
we are suspended.
Use constants instead of hard coded values where appropriate.
Correct some harmless "unsigned/signed" conflicts.
aic7xxx.seq:
Only perform the SCSIBUSL fix on ULTRA2 or newer controllers.
Older controllers seem to be confused by this.
In target mode, ignore PHASEMIS during data phases.
This bit seems to be flakey on U160 controllers acting
in target mode.
aic7xxx_pci.c:
Add support for the 29160C CPCI adapter.
Add definitions for subvendor ID information
available for devices with the "9005" vendor id.
We currently use this information to determine
if a multi-function device doesn't have the second
channel hooked up on a board.
Add rudimentary power mode code so we can put the
controller into the D0 state. In the future this
will be an OSM callback so that in FreeBSD we don't
duplicate functionality provided by the PCI code.
The powerstate code was added after I'd completed
my regression tests on this code.
Only capture "left over BIOS state" if the POWRDN
setting is not set in HCNTRL.
In target mode, don't bother sending incremental
CRC data.
2000-12-20 01:11:37 +00:00
|
|
|
#include <sys/eventhandler.h>
|
2000-09-16 20:02:28 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
|
2002-07-23 06:31:45 +00:00
|
|
|
#if __FreeBSD_version < 500000
|
|
|
|
#include <pci.h>
|
|
|
|
#else
|
|
|
|
#define NPCI 1
|
|
|
|
#endif
|
|
|
|
|
2000-09-16 20:02:28 +00:00
|
|
|
#if NPCI > 0
|
This is an MFC candidate.
ahc_eisa.c:
Change aic7770_map_int to take an additional irq parameter.
Although we can get the irq from the eisa dev under FreeBSD,
we can't do this under linux, so the OSM interface must supply
this.
ahc_pci.c:
Move ahc_power_state_change() to the OSM. This allows us to
use a platform supplied function that does the same thing.
-current will move to the FreeBSD native API in the near
future.
aic7770.c:
Sync up with core changes to support Linux EISA.
We now store a 2 bit primary channel number rather
than a bit flag that only allows b to be the primary
channel. Adjust for this change.
aic7xxx.c:
Namespace and staticization cleanup. All exported symbols
use an "ahc_" prefix to avoid collisions with other modules.
Correct a logic bug that prevented us from dropping
ATN during some exceptional conditions during message
processing.
Take advantage of a new flag managed by the sequencer
that indicates if an SCB fetch is in progress. If so,
the currently selected SCB needs to be returned to the
free list to prevent an SCB leak. This leak is a rarity
and would only occur if a bus reset or timeout resulting
in a bus reset occurred in the middle of an SCB fetch.
Don't attempt to perform ULTRA transfers on ultra capable
adapters missing the external precision resistor required
for ultra speeds. I've never encountered an adapter
configured this way, but better safe than sorry.
Handle the case of 5MHz user sync rate set as "0" instead of 0x1c
in scratch ram.
If we lookup a period of 0 in our table (async), clear the scsi offset.
aic7xxx.h:
Adjust for the primary channel being represented as
a 2 bit integer in the flags member of the ahc softc.
Cleanup the flags definitions so that comment blocks are
not cramped.
Update seeprom definitions to correctly reflect the fact
that the primary channel is represented as a 2 bit integer.
Add AHC_ULTRA_DIASABLED softc flag to denote controllers
missing the external precision resistor.
aic7xxx.reg:
Add DFCACHETH to the definition of DFSTATUS for completness sake.
Add SEQ_FLAGS2 which currently only contains the SCB_DMA
(SCB DMA in progress) flag.
aic7xxx.seq:
Correct a problem when one lun has a disconnected untagged
transaction and another lun has disconnected tagged transactions.
Just because an entry is found in the untagged table doesn't
mean that it will match. If the match on the lun fails, cleanup
the SCB (return it to the disconnected list or free it), and snoop
for a tag message. Before this change, we reported an unsolicited
reselection. This bug was introduced about a month ago during an
overly aggressive optimization pass on the reselection code.
When cleaning up an SCB, we can't just blindly free the SCB. In
the paging case, if the SCB came off of the disconnected list, its
state may never have been updated in host memory. So, check the
disconnected bit in SCB_CONTROL and return the SCB to the disconnected
list if appropriate.
Manage the SCB_DMA flag of SEQ_FLAGS2.
More carefully shutdown the S/G dma engine in all cases by using
a subroutine. Supposedly not doing this can cause an arbiter hang
on some ULTRA2 chips.
Formatting cleanup.
On some chips, at least the aic7856, the transition from
MREQPEND to HDONE can take a full 4 clock cycles. Test
HDONE one more time to avoid this race. We only want our
FIFO hung recovery code to execute when the engine is
really hung.
aic7xxx_93cx6.c:
Sync perforce ids.
aic7xxx_freebsd.c:
Adjust for the primary channel being a 2 bit integer
rather than a flag for 'B' channel being the primary.
Namespace cleanup.
Unpause the sequencer in one error recovery path that
neglected to do so. This could have caused us to perform
a bus reset when a recovery message might have otherwise been
successful.
aic7xxx_freebsd.h:
Use AHC_PCI_CONFIG for controlling compilation of PCI
support consistently throughout the driver.
Move ahc_power_state_change() to OSM.
aic7xxx_inline.h
Namespace cleanup.
Adjust our interrupt handler so it will work in the edge
interrupt case. We must process all interrupt sources
when the interrupt fires or risk not ever getting an
interrupt again. This involves marking the fact
that we are relying on an edge interrupt in ahc->flags
and checking for this condition in addition to the
AHC_ALL_INTERRUPTS flag. This fixes hangs on the
284X and any other aic7770 installation where level
interrupts are not available.
aic7xxx_pci.c:
Move the powerstate manipulation code into the OSM. Several
OSes now provide this functionality natively.
Take another shot at using the data stored in scratch ram
if the SCB2 signature is correct and no SEEPROM data is
available. In the past this failed if external SCB ram
was configured because the memory port was locked. We
now release the memory port prior to testing the values
in SCB2 and re-acquire it prior to doing termination control.
Adjust for new 2 bit primary channel setting.
Trust the STPWLEVEL setting on v 3.X BIOSes too.
Configure any 785X ID in the same fashion and assume
that any device with a rev id of 1 or higher has the
PCI 2.1 retry bug.
2001-03-11 06:34:17 +00:00
|
|
|
#define AHC_PCI_CONFIG 1
|
2000-09-22 22:18:05 +00:00
|
|
|
#ifdef AHC_ALLOW_MEMIO
|
2000-09-16 20:02:28 +00:00
|
|
|
#include <machine/bus_memio.h>
|
|
|
|
#endif
|
2000-09-22 22:18:05 +00:00
|
|
|
#endif
|
2000-09-16 20:02:28 +00:00
|
|
|
#include <machine/bus_pio.h>
|
|
|
|
#include <machine/bus.h>
|
2002-04-24 16:58:51 +00:00
|
|
|
#include <machine/endian.h>
|
2000-09-16 20:02:28 +00:00
|
|
|
#include <machine/clock.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#if NPCI > 0
|
|
|
|
#include <pci/pcireg.h>
|
|
|
|
#include <pci/pcivar.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <cam/cam.h>
|
|
|
|
#include <cam/cam_ccb.h>
|
|
|
|
#include <cam/cam_debug.h>
|
|
|
|
#include <cam/cam_sim.h>
|
|
|
|
#include <cam/cam_xpt_sim.h>
|
|
|
|
|
|
|
|
#include <cam/scsi/scsi_all.h>
|
|
|
|
#include <cam/scsi/scsi_message.h>
|
|
|
|
|
2001-06-22 01:02:41 +00:00
|
|
|
#ifdef CAM_NEW_TRAN_CODE
|
|
|
|
#define AHC_NEW_TRAN_SETTINGS
|
|
|
|
#endif /* CAM_NEW_TRAN_CODE */
|
|
|
|
|
2002-09-22 23:03:31 +00:00
|
|
|
/*************************** Attachment Bookkeeping ***************************/
|
|
|
|
extern devclass_t ahc_devclass;
|
|
|
|
|
2000-09-16 20:02:28 +00:00
|
|
|
/****************************** Platform Macros *******************************/
|
|
|
|
#define SIM_IS_SCSIBUS_B(ahc, sim) \
|
|
|
|
((sim) == ahc->platform_data->sim_b)
|
|
|
|
#define SIM_CHANNEL(ahc, sim) \
|
|
|
|
(((sim) == ahc->platform_data->sim_b) ? 'B' : 'A')
|
|
|
|
#define SIM_SCSI_ID(ahc, sim) \
|
|
|
|
(((sim) == ahc->platform_data->sim_b) ? ahc->our_id_b : ahc->our_id)
|
|
|
|
#define SIM_PATH(ahc, sim) \
|
|
|
|
(((sim) == ahc->platform_data->sim_b) ? ahc->platform_data->path_b \
|
|
|
|
: ahc->platform_data->path)
|
|
|
|
#define BUILD_SCSIID(ahc, sim, target_id, our_id) \
|
|
|
|
((((target_id) << TID_SHIFT) & TID) | (our_id) \
|
|
|
|
| (SIM_IS_SCSIBUS_B(ahc, sim) ? TWIN_CHNLB : 0))
|
|
|
|
|
|
|
|
#define SCB_GET_SIM(ahc, scb) \
|
|
|
|
(SCB_GET_CHANNEL(ahc, scb) == 'A' ? (ahc)->platform_data->sim \
|
|
|
|
: (ahc)->platform_data->sim_b)
|
|
|
|
|
2001-05-15 19:41:12 +00:00
|
|
|
#ifndef offsetof
|
|
|
|
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
|
|
|
#endif
|
2000-09-16 20:02:28 +00:00
|
|
|
/************************* Forward Declarations *******************************/
|
|
|
|
typedef device_t ahc_dev_softc_t;
|
|
|
|
typedef union ccb *ahc_io_ctx_t;
|
|
|
|
|
|
|
|
/***************************** Bus Space/DMA **********************************/
|
|
|
|
#define ahc_dma_tag_create(ahc, parent_tag, alignment, boundary, \
|
|
|
|
lowaddr, highaddr, filter, filterarg, \
|
|
|
|
maxsize, nsegments, maxsegsz, flags, \
|
|
|
|
dma_tagp) \
|
|
|
|
bus_dma_tag_create(parent_tag, alignment, boundary, \
|
|
|
|
lowaddr, highaddr, filter, filterarg, \
|
|
|
|
maxsize, nsegments, maxsegsz, flags, \
|
|
|
|
dma_tagp)
|
|
|
|
|
|
|
|
#define ahc_dma_tag_destroy(ahc, tag) \
|
|
|
|
bus_dma_tag_destroy(tag)
|
|
|
|
|
|
|
|
#define ahc_dmamem_alloc(ahc, dmat, vaddr, flags, mapp) \
|
|
|
|
bus_dmamem_alloc(dmat, vaddr, flags, mapp)
|
|
|
|
|
|
|
|
#define ahc_dmamem_free(ahc, dmat, vaddr, map) \
|
|
|
|
bus_dmamem_free(dmat, vaddr, map)
|
|
|
|
|
|
|
|
#define ahc_dmamap_create(ahc, tag, flags, mapp) \
|
|
|
|
bus_dmamap_create(tag, flags, mapp)
|
|
|
|
|
|
|
|
#define ahc_dmamap_destroy(ahc, tag, map) \
|
|
|
|
bus_dmamap_destroy(tag, map)
|
|
|
|
|
|
|
|
#define ahc_dmamap_load(ahc, dmat, map, addr, buflen, callback, \
|
|
|
|
callback_arg, flags) \
|
|
|
|
bus_dmamap_load(dmat, map, addr, buflen, callback, callback_arg, flags)
|
|
|
|
|
|
|
|
#define ahc_dmamap_unload(ahc, tag, map) \
|
|
|
|
bus_dmamap_unload(tag, map)
|
|
|
|
|
2001-07-18 21:39:48 +00:00
|
|
|
/* XXX Need to update Bus DMA for partial map syncs */
|
|
|
|
#define ahc_dmamap_sync(ahc, dma_tag, dmamap, offset, len, op) \
|
|
|
|
bus_dmamap_sync(dma_tag, dmamap, op)
|
2000-09-16 20:02:28 +00:00
|
|
|
|
|
|
|
/************************ Tunable Driver Parameters **************************/
|
|
|
|
/*
|
|
|
|
* The number of dma segments supported. The sequencer can handle any number
|
|
|
|
* of physically contiguous S/G entrys. To reduce the driver's memory
|
|
|
|
* consumption, we limit the number supported to be sufficient to handle
|
|
|
|
* the largest mapping supported by the kernel, MAXPHYS. Assuming the
|
|
|
|
* transfer is as fragmented as possible and unaligned, this turns out to
|
|
|
|
* be the number of paged sized transfers in MAXPHYS plus an extra element
|
|
|
|
* to handle any unaligned residual. The sequencer fetches SG elements
|
2001-05-15 19:41:12 +00:00
|
|
|
* in cacheline sized chucks, so make the number per-transaction an even
|
|
|
|
* multiple of 16 which should align us on even the largest of cacheline
|
|
|
|
* boundaries.
|
2000-09-16 20:02:28 +00:00
|
|
|
*/
|
|
|
|
#define AHC_NSEG (roundup(btoc(MAXPHYS) + 1, 16))
|
|
|
|
|
|
|
|
/* This driver supports target mode */
|
|
|
|
#define AHC_TARGET_MODE 1
|
|
|
|
|
|
|
|
/************************** Softc/SCB Platform Data ***************************/
|
|
|
|
struct ahc_platform_data {
|
|
|
|
/*
|
|
|
|
* Hooks into the XPT.
|
|
|
|
*/
|
|
|
|
struct cam_sim *sim;
|
|
|
|
struct cam_sim *sim_b;
|
|
|
|
struct cam_path *path;
|
|
|
|
struct cam_path *path_b;
|
|
|
|
|
|
|
|
int regs_res_type;
|
|
|
|
int regs_res_id;
|
|
|
|
int irq_res_type;
|
|
|
|
struct resource *regs;
|
|
|
|
struct resource *irq;
|
|
|
|
void *ih;
|
ahc_eisa.c:
ahc_pci.c:
Add detach support.
Make use of soft allocated on our behalf by newbus.
For PCI devices, disable the mapping type we aren't
using for extra protection from rogue code.
aic7xxx_93cx6.c:
aic7xxx_93cx6.h:
Sync perforce IDs.
aic7xxx_freebsd.c:
Capture the eventhandle returned by EVENTHANDER_REGISTER
so we can kill the handler off during detach.
Use AHC_* constants instead of hard coded numbers in a
few more places.
Test PPR option state when deciding to "really" negotiate
when the CAM_NEGOTIATE flag is passed in a CCB.
Make use of core "ahc_pause_and_flushwork" routine in our
timeout handler rather than re-inventing this code.
Cleanup all of our resources (really!) in ahc_platform_free().
We should be all set to become a module now.
Implement the core ahc_detach() routine shared by all of
the FreeBSD front-ends.
aic7xxx_freebsd.h:
Softc storage for our event handler.
Null implementation for the ahc_platform_flushwork() OSM
callback. FreeBSD doesn't need this as XPT callbacks are
safe from all contexts and are done directly in ahc_done().
aic7xxx_inline.h:
Implement new lazy interrupt scheme. To avoid an extra
PCI bus read, we first check our completion queues to
see if any work has completed. If work is available, we
assume that this is the source of the interrupt and skip
reading INTSTAT. Any remaining interrupt status will be
cleared by a second call to the interrupt handler should
the interrupt line still be asserted. This drops the
interrupt handler down to a single PCI bus read in the
common case of I/O completion. This is the same overhead
as in the not so distant past, but the extra sanity of
perforning a PCI read after clearing the command complete
interrupt and before running the completion queue to avoid
missing command complete interrupts added a cycle.
aic7xxx.c:
During initialization, be sure to initialize all scratch
ram locations before they are read to avoid parity errors.
In this case, we use a new function, ahc_unbusy_tcl() to
initialize the scratch ram busy target table.
Replace instances of ahc_index_busy_tcl() used to unbusy
a tcl without looking at the old value with ahc_unbusy_tcl().
Modify ahc_sent_msg so that it can find single byte messages.
ahc_sent_msg is now used to determine if a transfer negotiation
attempt resulted in a bus free.
Be more careful in filtering out only the SCSI interrupts
of interest in ahc_handle_scsiint.
Rearrange interrupt clearing code to ensure that at least
one PCI transaction occurrs after hitting CLRSINT1 and
writting to CLRINT. CLRSINT1 writes take a bit to
take effect, and the re-arrangement provides sufficient
delay to ensure the write to CLRINT is effective. The
old code might report a spurious interrupt on some "fast"
chipsets.
export ahc-update_target_msg_request for use by OSM code.
If a target does not respond to our ATN request, clear
it once we move to a non-message phase. This avoids
sending a MSG_NOOP in some later message out phase.
Use max lun and max target constants instead of
hard-coded values.
Use softc storage built into our device_t under FreeBSD.
Fix a bug in ahc_free() that caused us to delete
resources that were not allocated.
Clean up any tstate/lstate info in ahc_free().
Clear the powerdown state in ahc_reset() so that
registers can be accessed.
Add a preliminary function for pausing the chip and
processing any posted work.
Add a preliminary suspend and resume functions.
aic7xxx.h:
Limit the number of supported luns to 64. We don't
support information unit transfers, so this is the
maximum that makes sense for these chips.
Add a new flag AHC_ALL_INTERRUPTS that forces the
processing of all interrupt state in a single invokation
of ahc_intr(). When the flag is not set, we use the
lazy interrupt handling scheme.
Add data structures to store controller state while
we are suspended.
Use constants instead of hard coded values where appropriate.
Correct some harmless "unsigned/signed" conflicts.
aic7xxx.seq:
Only perform the SCSIBUSL fix on ULTRA2 or newer controllers.
Older controllers seem to be confused by this.
In target mode, ignore PHASEMIS during data phases.
This bit seems to be flakey on U160 controllers acting
in target mode.
aic7xxx_pci.c:
Add support for the 29160C CPCI adapter.
Add definitions for subvendor ID information
available for devices with the "9005" vendor id.
We currently use this information to determine
if a multi-function device doesn't have the second
channel hooked up on a board.
Add rudimentary power mode code so we can put the
controller into the D0 state. In the future this
will be an OSM callback so that in FreeBSD we don't
duplicate functionality provided by the PCI code.
The powerstate code was added after I'd completed
my regression tests on this code.
Only capture "left over BIOS state" if the POWRDN
setting is not set in HCNTRL.
In target mode, don't bother sending incremental
CRC data.
2000-12-20 01:11:37 +00:00
|
|
|
eventhandler_tag eh;
|
2000-09-16 20:02:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct scb_platform_data {
|
|
|
|
};
|
|
|
|
|
2001-01-05 19:15:37 +00:00
|
|
|
/********************************* Byte Order *********************************/
|
2002-08-31 06:44:20 +00:00
|
|
|
#if __FreeBSD_version >= 500000
|
2002-04-24 16:58:51 +00:00
|
|
|
#define ahc_htobe16(x) htobe16(x)
|
|
|
|
#define ahc_htobe32(x) htobe32(x)
|
|
|
|
#define ahc_htobe64(x) htobe64(x)
|
|
|
|
#define ahc_htole16(x) htole16(x)
|
|
|
|
#define ahc_htole32(x) htole32(x)
|
|
|
|
#define ahc_htole64(x) htole64(x)
|
|
|
|
|
|
|
|
#define ahc_be16toh(x) be16toh(x)
|
|
|
|
#define ahc_be32toh(x) be32toh(x)
|
|
|
|
#define ahc_be64toh(x) be64toh(x)
|
|
|
|
#define ahc_le16toh(x) le16toh(x)
|
|
|
|
#define ahc_le32toh(x) le32toh(x)
|
|
|
|
#define ahc_le64toh(x) le64toh(x)
|
2002-08-31 06:44:20 +00:00
|
|
|
#else
|
|
|
|
#define ahc_htobe16(x) (x)
|
|
|
|
#define ahc_htobe32(x) (x)
|
|
|
|
#define ahc_htobe64(x) (x)
|
|
|
|
#define ahc_htole16(x) (x)
|
|
|
|
#define ahc_htole32(x) (x)
|
|
|
|
#define ahc_htole64(x) (x)
|
|
|
|
|
|
|
|
#define ahc_be16toh(x) (x)
|
|
|
|
#define ahc_be32toh(x) (x)
|
|
|
|
#define ahc_be64toh(x) (x)
|
|
|
|
#define ahc_le16toh(x) (x)
|
|
|
|
#define ahc_le32toh(x) (x)
|
|
|
|
#define ahc_le64toh(x) (x)
|
|
|
|
#endif
|
2001-01-05 19:15:37 +00:00
|
|
|
|
2000-09-16 20:02:28 +00:00
|
|
|
/***************************** Core Includes **********************************/
|
2002-08-31 06:44:20 +00:00
|
|
|
#if AHC_REG_PRETTY_PRINT
|
|
|
|
#define AIC_DEBUG_REGISTERS 1
|
|
|
|
#else
|
|
|
|
#define AIC_DEBUG_REGISTERS 0
|
|
|
|
#endif
|
2000-09-16 20:02:28 +00:00
|
|
|
#include <dev/aic7xxx/aic7xxx.h>
|
|
|
|
|
|
|
|
/*************************** Device Access ************************************/
|
|
|
|
#define ahc_inb(ahc, port) \
|
|
|
|
bus_space_read_1((ahc)->tag, (ahc)->bsh, port)
|
|
|
|
|
|
|
|
#define ahc_outb(ahc, port, value) \
|
|
|
|
bus_space_write_1((ahc)->tag, (ahc)->bsh, port, value)
|
|
|
|
|
|
|
|
#define ahc_outsb(ahc, port, valp, count) \
|
|
|
|
bus_space_write_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
|
|
|
|
|
|
|
|
#define ahc_insb(ahc, port, valp, count) \
|
|
|
|
bus_space_read_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
|
|
|
|
|
|
|
|
static __inline void ahc_flush_device_writes(struct ahc_softc *);
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_flush_device_writes(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
/* XXX Is this sufficient for all architectures??? */
|
|
|
|
ahc_inb(ahc, INTSTAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************** Locking Primitives ******************************/
|
|
|
|
/* Lock protecting internal data structures */
|
|
|
|
static __inline void ahc_lockinit(struct ahc_softc *);
|
|
|
|
static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags);
|
|
|
|
static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags);
|
|
|
|
|
|
|
|
/* Lock held during command compeletion to the upper layer */
|
|
|
|
static __inline void ahc_done_lockinit(struct ahc_softc *);
|
|
|
|
static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags);
|
|
|
|
static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags);
|
|
|
|
|
2002-08-31 06:44:20 +00:00
|
|
|
/* Lock held during ahc_list manipulation and ahc softc frees */
|
|
|
|
static __inline void ahc_list_lockinit(void);
|
|
|
|
static __inline void ahc_list_lock(unsigned long *flags);
|
|
|
|
static __inline void ahc_list_unlock(unsigned long *flags);
|
|
|
|
|
2000-09-16 20:02:28 +00:00
|
|
|
static __inline void
|
|
|
|
ahc_lockinit(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_lock(struct ahc_softc *ahc, unsigned long *flags)
|
|
|
|
{
|
|
|
|
*flags = splcam();
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
|
|
|
|
{
|
|
|
|
splx(*flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lock held during command compeletion to the upper layer */
|
|
|
|
static __inline void
|
|
|
|
ahc_done_lockinit(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-08-31 06:44:20 +00:00
|
|
|
/* Lock held during ahc_list manipulation and ahc softc frees */
|
|
|
|
static __inline void
|
|
|
|
ahc_list_lockinit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_list_lock(unsigned long *flags)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_list_unlock(unsigned long *flags)
|
|
|
|
{
|
|
|
|
}
|
2000-09-16 20:02:28 +00:00
|
|
|
/****************************** OS Primitives *********************************/
|
|
|
|
#define ahc_delay DELAY
|
|
|
|
|
|
|
|
/************************** Transaction Operations ****************************/
|
|
|
|
static __inline void ahc_set_transaction_status(struct scb *, uint32_t);
|
|
|
|
static __inline void ahc_set_scsi_status(struct scb *, uint32_t);
|
|
|
|
static __inline uint32_t ahc_get_transaction_status(struct scb *);
|
|
|
|
static __inline uint32_t ahc_get_scsi_status(struct scb *);
|
|
|
|
static __inline void ahc_set_transaction_tag(struct scb *, int, u_int);
|
|
|
|
static __inline u_long ahc_get_transfer_length(struct scb *);
|
|
|
|
static __inline int ahc_get_transfer_dir(struct scb *);
|
|
|
|
static __inline void ahc_set_residual(struct scb *, u_long);
|
|
|
|
static __inline void ahc_set_sense_residual(struct scb *, u_long);
|
|
|
|
static __inline u_long ahc_get_residual(struct scb *);
|
|
|
|
static __inline int ahc_perform_autosense(struct scb *);
|
|
|
|
static __inline uint32_t ahc_get_sense_bufsize(struct ahc_softc*, struct scb*);
|
|
|
|
static __inline void ahc_freeze_ccb(union ccb *ccb);
|
|
|
|
static __inline void ahc_freeze_scb(struct scb *scb);
|
|
|
|
static __inline void ahc_platform_freeze_devq(struct ahc_softc *, struct scb *);
|
|
|
|
static __inline int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
|
|
|
|
char channel, int lun, u_int tag,
|
|
|
|
role_t role, uint32_t status);
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
void ahc_set_transaction_status(struct scb *scb, uint32_t status)
|
|
|
|
{
|
|
|
|
scb->io_ctx->ccb_h.status &= ~CAM_STATUS_MASK;
|
|
|
|
scb->io_ctx->ccb_h.status |= status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
void ahc_set_scsi_status(struct scb *scb, uint32_t status)
|
|
|
|
{
|
|
|
|
scb->io_ctx->csio.scsi_status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
uint32_t ahc_get_transaction_status(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->io_ctx->ccb_h.status & CAM_STATUS_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
uint32_t ahc_get_scsi_status(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->io_ctx->csio.scsi_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
void ahc_set_transaction_tag(struct scb *scb, int enabled, u_int type)
|
|
|
|
{
|
|
|
|
scb->io_ctx->csio.tag_action = type;
|
|
|
|
if (enabled)
|
|
|
|
scb->io_ctx->ccb_h.flags |= CAM_TAG_ACTION_VALID;
|
|
|
|
else
|
|
|
|
scb->io_ctx->ccb_h.flags &= ~CAM_TAG_ACTION_VALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
u_long ahc_get_transfer_length(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->io_ctx->csio.dxfer_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
int ahc_get_transfer_dir(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->io_ctx->ccb_h.flags & CAM_DIR_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
void ahc_set_residual(struct scb *scb, u_long resid)
|
|
|
|
{
|
|
|
|
scb->io_ctx->csio.resid = resid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
void ahc_set_sense_residual(struct scb *scb, u_long resid)
|
|
|
|
{
|
|
|
|
scb->io_ctx->csio.sense_resid = resid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
u_long ahc_get_residual(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (scb->io_ctx->csio.resid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
int ahc_perform_autosense(struct scb *scb)
|
|
|
|
{
|
|
|
|
return (!(scb->io_ctx->ccb_h.flags & CAM_DIS_AUTOSENSE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline uint32_t
|
|
|
|
ahc_get_sense_bufsize(struct ahc_softc *ahc, struct scb *scb)
|
|
|
|
{
|
|
|
|
return (sizeof(struct scsi_sense_data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_freeze_ccb(union ccb *ccb)
|
|
|
|
{
|
|
|
|
if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
|
|
|
|
ccb->ccb_h.status |= CAM_DEV_QFRZN;
|
|
|
|
xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_freeze_scb(struct scb *scb)
|
|
|
|
{
|
|
|
|
ahc_freeze_ccb(scb->io_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
|
|
|
|
{
|
|
|
|
/* Nothing to do here for FreeBSD */
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
|
|
|
|
char channel, int lun, u_int tag,
|
|
|
|
role_t role, uint32_t status)
|
|
|
|
{
|
|
|
|
/* Nothing to do here for FreeBSD */
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-10-05 04:24:14 +00:00
|
|
|
static __inline void
|
|
|
|
ahc_platform_scb_free(struct ahc_softc *ahc, struct scb *scb)
|
|
|
|
{
|
|
|
|
/* What do we do to generically handle driver resource shortages??? */
|
|
|
|
if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0
|
|
|
|
&& scb->io_ctx != NULL
|
|
|
|
&& (scb->io_ctx->ccb_h.status & CAM_RELEASE_SIMQ) == 0) {
|
|
|
|
scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ;
|
|
|
|
ahc->flags &= ~AHC_RESOURCE_SHORTAGE;
|
|
|
|
}
|
|
|
|
scb->io_ctx = NULL;
|
|
|
|
}
|
|
|
|
|
2000-09-16 20:02:28 +00:00
|
|
|
/********************************** PCI ***************************************/
|
This is an MFC candidate.
ahc_eisa.c:
Change aic7770_map_int to take an additional irq parameter.
Although we can get the irq from the eisa dev under FreeBSD,
we can't do this under linux, so the OSM interface must supply
this.
ahc_pci.c:
Move ahc_power_state_change() to the OSM. This allows us to
use a platform supplied function that does the same thing.
-current will move to the FreeBSD native API in the near
future.
aic7770.c:
Sync up with core changes to support Linux EISA.
We now store a 2 bit primary channel number rather
than a bit flag that only allows b to be the primary
channel. Adjust for this change.
aic7xxx.c:
Namespace and staticization cleanup. All exported symbols
use an "ahc_" prefix to avoid collisions with other modules.
Correct a logic bug that prevented us from dropping
ATN during some exceptional conditions during message
processing.
Take advantage of a new flag managed by the sequencer
that indicates if an SCB fetch is in progress. If so,
the currently selected SCB needs to be returned to the
free list to prevent an SCB leak. This leak is a rarity
and would only occur if a bus reset or timeout resulting
in a bus reset occurred in the middle of an SCB fetch.
Don't attempt to perform ULTRA transfers on ultra capable
adapters missing the external precision resistor required
for ultra speeds. I've never encountered an adapter
configured this way, but better safe than sorry.
Handle the case of 5MHz user sync rate set as "0" instead of 0x1c
in scratch ram.
If we lookup a period of 0 in our table (async), clear the scsi offset.
aic7xxx.h:
Adjust for the primary channel being represented as
a 2 bit integer in the flags member of the ahc softc.
Cleanup the flags definitions so that comment blocks are
not cramped.
Update seeprom definitions to correctly reflect the fact
that the primary channel is represented as a 2 bit integer.
Add AHC_ULTRA_DIASABLED softc flag to denote controllers
missing the external precision resistor.
aic7xxx.reg:
Add DFCACHETH to the definition of DFSTATUS for completness sake.
Add SEQ_FLAGS2 which currently only contains the SCB_DMA
(SCB DMA in progress) flag.
aic7xxx.seq:
Correct a problem when one lun has a disconnected untagged
transaction and another lun has disconnected tagged transactions.
Just because an entry is found in the untagged table doesn't
mean that it will match. If the match on the lun fails, cleanup
the SCB (return it to the disconnected list or free it), and snoop
for a tag message. Before this change, we reported an unsolicited
reselection. This bug was introduced about a month ago during an
overly aggressive optimization pass on the reselection code.
When cleaning up an SCB, we can't just blindly free the SCB. In
the paging case, if the SCB came off of the disconnected list, its
state may never have been updated in host memory. So, check the
disconnected bit in SCB_CONTROL and return the SCB to the disconnected
list if appropriate.
Manage the SCB_DMA flag of SEQ_FLAGS2.
More carefully shutdown the S/G dma engine in all cases by using
a subroutine. Supposedly not doing this can cause an arbiter hang
on some ULTRA2 chips.
Formatting cleanup.
On some chips, at least the aic7856, the transition from
MREQPEND to HDONE can take a full 4 clock cycles. Test
HDONE one more time to avoid this race. We only want our
FIFO hung recovery code to execute when the engine is
really hung.
aic7xxx_93cx6.c:
Sync perforce ids.
aic7xxx_freebsd.c:
Adjust for the primary channel being a 2 bit integer
rather than a flag for 'B' channel being the primary.
Namespace cleanup.
Unpause the sequencer in one error recovery path that
neglected to do so. This could have caused us to perform
a bus reset when a recovery message might have otherwise been
successful.
aic7xxx_freebsd.h:
Use AHC_PCI_CONFIG for controlling compilation of PCI
support consistently throughout the driver.
Move ahc_power_state_change() to OSM.
aic7xxx_inline.h
Namespace cleanup.
Adjust our interrupt handler so it will work in the edge
interrupt case. We must process all interrupt sources
when the interrupt fires or risk not ever getting an
interrupt again. This involves marking the fact
that we are relying on an edge interrupt in ahc->flags
and checking for this condition in addition to the
AHC_ALL_INTERRUPTS flag. This fixes hangs on the
284X and any other aic7770 installation where level
interrupts are not available.
aic7xxx_pci.c:
Move the powerstate manipulation code into the OSM. Several
OSes now provide this functionality natively.
Take another shot at using the data stored in scratch ram
if the SCB2 signature is correct and no SEEPROM data is
available. In the past this failed if external SCB ram
was configured because the memory port was locked. We
now release the memory port prior to testing the values
in SCB2 and re-acquire it prior to doing termination control.
Adjust for new 2 bit primary channel setting.
Trust the STPWLEVEL setting on v 3.X BIOSes too.
Configure any 785X ID in the same fashion and assume
that any device with a rev id of 1 or higher has the
PCI 2.1 retry bug.
2001-03-11 06:34:17 +00:00
|
|
|
#ifdef AHC_PCI_CONFIG
|
2000-09-16 20:02:28 +00:00
|
|
|
static __inline uint32_t ahc_pci_read_config(ahc_dev_softc_t pci,
|
|
|
|
int reg, int width);
|
|
|
|
static __inline void ahc_pci_write_config(ahc_dev_softc_t pci,
|
|
|
|
int reg, uint32_t value,
|
|
|
|
int width);
|
|
|
|
static __inline int ahc_get_pci_function(ahc_dev_softc_t);
|
|
|
|
static __inline int ahc_get_pci_slot(ahc_dev_softc_t);
|
|
|
|
static __inline int ahc_get_pci_bus(ahc_dev_softc_t);
|
|
|
|
|
|
|
|
int ahc_pci_map_registers(struct ahc_softc *ahc);
|
|
|
|
int ahc_pci_map_int(struct ahc_softc *ahc);
|
|
|
|
|
|
|
|
static __inline uint32_t
|
|
|
|
ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width)
|
|
|
|
{
|
|
|
|
return (pci_read_config(pci, reg, width));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width)
|
|
|
|
{
|
|
|
|
pci_write_config(pci, reg, value, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
ahc_get_pci_function(ahc_dev_softc_t pci)
|
|
|
|
{
|
|
|
|
return (pci_get_function(pci));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
ahc_get_pci_slot(ahc_dev_softc_t pci)
|
|
|
|
{
|
|
|
|
return (pci_get_slot(pci));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
ahc_get_pci_bus(ahc_dev_softc_t pci)
|
|
|
|
{
|
|
|
|
return (pci_get_bus(pci));
|
|
|
|
}
|
This is an MFC candidate.
ahc_eisa.c:
Change aic7770_map_int to take an additional irq parameter.
Although we can get the irq from the eisa dev under FreeBSD,
we can't do this under linux, so the OSM interface must supply
this.
ahc_pci.c:
Move ahc_power_state_change() to the OSM. This allows us to
use a platform supplied function that does the same thing.
-current will move to the FreeBSD native API in the near
future.
aic7770.c:
Sync up with core changes to support Linux EISA.
We now store a 2 bit primary channel number rather
than a bit flag that only allows b to be the primary
channel. Adjust for this change.
aic7xxx.c:
Namespace and staticization cleanup. All exported symbols
use an "ahc_" prefix to avoid collisions with other modules.
Correct a logic bug that prevented us from dropping
ATN during some exceptional conditions during message
processing.
Take advantage of a new flag managed by the sequencer
that indicates if an SCB fetch is in progress. If so,
the currently selected SCB needs to be returned to the
free list to prevent an SCB leak. This leak is a rarity
and would only occur if a bus reset or timeout resulting
in a bus reset occurred in the middle of an SCB fetch.
Don't attempt to perform ULTRA transfers on ultra capable
adapters missing the external precision resistor required
for ultra speeds. I've never encountered an adapter
configured this way, but better safe than sorry.
Handle the case of 5MHz user sync rate set as "0" instead of 0x1c
in scratch ram.
If we lookup a period of 0 in our table (async), clear the scsi offset.
aic7xxx.h:
Adjust for the primary channel being represented as
a 2 bit integer in the flags member of the ahc softc.
Cleanup the flags definitions so that comment blocks are
not cramped.
Update seeprom definitions to correctly reflect the fact
that the primary channel is represented as a 2 bit integer.
Add AHC_ULTRA_DIASABLED softc flag to denote controllers
missing the external precision resistor.
aic7xxx.reg:
Add DFCACHETH to the definition of DFSTATUS for completness sake.
Add SEQ_FLAGS2 which currently only contains the SCB_DMA
(SCB DMA in progress) flag.
aic7xxx.seq:
Correct a problem when one lun has a disconnected untagged
transaction and another lun has disconnected tagged transactions.
Just because an entry is found in the untagged table doesn't
mean that it will match. If the match on the lun fails, cleanup
the SCB (return it to the disconnected list or free it), and snoop
for a tag message. Before this change, we reported an unsolicited
reselection. This bug was introduced about a month ago during an
overly aggressive optimization pass on the reselection code.
When cleaning up an SCB, we can't just blindly free the SCB. In
the paging case, if the SCB came off of the disconnected list, its
state may never have been updated in host memory. So, check the
disconnected bit in SCB_CONTROL and return the SCB to the disconnected
list if appropriate.
Manage the SCB_DMA flag of SEQ_FLAGS2.
More carefully shutdown the S/G dma engine in all cases by using
a subroutine. Supposedly not doing this can cause an arbiter hang
on some ULTRA2 chips.
Formatting cleanup.
On some chips, at least the aic7856, the transition from
MREQPEND to HDONE can take a full 4 clock cycles. Test
HDONE one more time to avoid this race. We only want our
FIFO hung recovery code to execute when the engine is
really hung.
aic7xxx_93cx6.c:
Sync perforce ids.
aic7xxx_freebsd.c:
Adjust for the primary channel being a 2 bit integer
rather than a flag for 'B' channel being the primary.
Namespace cleanup.
Unpause the sequencer in one error recovery path that
neglected to do so. This could have caused us to perform
a bus reset when a recovery message might have otherwise been
successful.
aic7xxx_freebsd.h:
Use AHC_PCI_CONFIG for controlling compilation of PCI
support consistently throughout the driver.
Move ahc_power_state_change() to OSM.
aic7xxx_inline.h
Namespace cleanup.
Adjust our interrupt handler so it will work in the edge
interrupt case. We must process all interrupt sources
when the interrupt fires or risk not ever getting an
interrupt again. This involves marking the fact
that we are relying on an edge interrupt in ahc->flags
and checking for this condition in addition to the
AHC_ALL_INTERRUPTS flag. This fixes hangs on the
284X and any other aic7770 installation where level
interrupts are not available.
aic7xxx_pci.c:
Move the powerstate manipulation code into the OSM. Several
OSes now provide this functionality natively.
Take another shot at using the data stored in scratch ram
if the SCB2 signature is correct and no SEEPROM data is
available. In the past this failed if external SCB ram
was configured because the memory port was locked. We
now release the memory port prior to testing the values
in SCB2 and re-acquire it prior to doing termination control.
Adjust for new 2 bit primary channel setting.
Trust the STPWLEVEL setting on v 3.X BIOSes too.
Configure any 785X ID in the same fashion and assume
that any device with a rev id of 1 or higher has the
PCI 2.1 retry bug.
2001-03-11 06:34:17 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
AHC_POWER_STATE_D0,
|
|
|
|
AHC_POWER_STATE_D1,
|
|
|
|
AHC_POWER_STATE_D2,
|
|
|
|
AHC_POWER_STATE_D3
|
|
|
|
} ahc_power_state;
|
|
|
|
|
|
|
|
void ahc_power_state_change(struct ahc_softc *ahc,
|
|
|
|
ahc_power_state new_state);
|
2000-09-16 20:02:28 +00:00
|
|
|
#endif
|
|
|
|
/******************************** VL/EISA *************************************/
|
2002-04-24 16:58:51 +00:00
|
|
|
int aic7770_map_registers(struct ahc_softc *ahc, u_int port);
|
This is an MFC candidate.
ahc_eisa.c:
Change aic7770_map_int to take an additional irq parameter.
Although we can get the irq from the eisa dev under FreeBSD,
we can't do this under linux, so the OSM interface must supply
this.
ahc_pci.c:
Move ahc_power_state_change() to the OSM. This allows us to
use a platform supplied function that does the same thing.
-current will move to the FreeBSD native API in the near
future.
aic7770.c:
Sync up with core changes to support Linux EISA.
We now store a 2 bit primary channel number rather
than a bit flag that only allows b to be the primary
channel. Adjust for this change.
aic7xxx.c:
Namespace and staticization cleanup. All exported symbols
use an "ahc_" prefix to avoid collisions with other modules.
Correct a logic bug that prevented us from dropping
ATN during some exceptional conditions during message
processing.
Take advantage of a new flag managed by the sequencer
that indicates if an SCB fetch is in progress. If so,
the currently selected SCB needs to be returned to the
free list to prevent an SCB leak. This leak is a rarity
and would only occur if a bus reset or timeout resulting
in a bus reset occurred in the middle of an SCB fetch.
Don't attempt to perform ULTRA transfers on ultra capable
adapters missing the external precision resistor required
for ultra speeds. I've never encountered an adapter
configured this way, but better safe than sorry.
Handle the case of 5MHz user sync rate set as "0" instead of 0x1c
in scratch ram.
If we lookup a period of 0 in our table (async), clear the scsi offset.
aic7xxx.h:
Adjust for the primary channel being represented as
a 2 bit integer in the flags member of the ahc softc.
Cleanup the flags definitions so that comment blocks are
not cramped.
Update seeprom definitions to correctly reflect the fact
that the primary channel is represented as a 2 bit integer.
Add AHC_ULTRA_DIASABLED softc flag to denote controllers
missing the external precision resistor.
aic7xxx.reg:
Add DFCACHETH to the definition of DFSTATUS for completness sake.
Add SEQ_FLAGS2 which currently only contains the SCB_DMA
(SCB DMA in progress) flag.
aic7xxx.seq:
Correct a problem when one lun has a disconnected untagged
transaction and another lun has disconnected tagged transactions.
Just because an entry is found in the untagged table doesn't
mean that it will match. If the match on the lun fails, cleanup
the SCB (return it to the disconnected list or free it), and snoop
for a tag message. Before this change, we reported an unsolicited
reselection. This bug was introduced about a month ago during an
overly aggressive optimization pass on the reselection code.
When cleaning up an SCB, we can't just blindly free the SCB. In
the paging case, if the SCB came off of the disconnected list, its
state may never have been updated in host memory. So, check the
disconnected bit in SCB_CONTROL and return the SCB to the disconnected
list if appropriate.
Manage the SCB_DMA flag of SEQ_FLAGS2.
More carefully shutdown the S/G dma engine in all cases by using
a subroutine. Supposedly not doing this can cause an arbiter hang
on some ULTRA2 chips.
Formatting cleanup.
On some chips, at least the aic7856, the transition from
MREQPEND to HDONE can take a full 4 clock cycles. Test
HDONE one more time to avoid this race. We only want our
FIFO hung recovery code to execute when the engine is
really hung.
aic7xxx_93cx6.c:
Sync perforce ids.
aic7xxx_freebsd.c:
Adjust for the primary channel being a 2 bit integer
rather than a flag for 'B' channel being the primary.
Namespace cleanup.
Unpause the sequencer in one error recovery path that
neglected to do so. This could have caused us to perform
a bus reset when a recovery message might have otherwise been
successful.
aic7xxx_freebsd.h:
Use AHC_PCI_CONFIG for controlling compilation of PCI
support consistently throughout the driver.
Move ahc_power_state_change() to OSM.
aic7xxx_inline.h
Namespace cleanup.
Adjust our interrupt handler so it will work in the edge
interrupt case. We must process all interrupt sources
when the interrupt fires or risk not ever getting an
interrupt again. This involves marking the fact
that we are relying on an edge interrupt in ahc->flags
and checking for this condition in addition to the
AHC_ALL_INTERRUPTS flag. This fixes hangs on the
284X and any other aic7770 installation where level
interrupts are not available.
aic7xxx_pci.c:
Move the powerstate manipulation code into the OSM. Several
OSes now provide this functionality natively.
Take another shot at using the data stored in scratch ram
if the SCB2 signature is correct and no SEEPROM data is
available. In the past this failed if external SCB ram
was configured because the memory port was locked. We
now release the memory port prior to testing the values
in SCB2 and re-acquire it prior to doing termination control.
Adjust for new 2 bit primary channel setting.
Trust the STPWLEVEL setting on v 3.X BIOSes too.
Configure any 785X ID in the same fashion and assume
that any device with a rev id of 1 or higher has the
PCI 2.1 retry bug.
2001-03-11 06:34:17 +00:00
|
|
|
int aic7770_map_int(struct ahc_softc *ahc, int irq);
|
2000-09-16 20:02:28 +00:00
|
|
|
|
|
|
|
/********************************* Debug **************************************/
|
|
|
|
static __inline void ahc_print_path(struct ahc_softc *, struct scb *);
|
|
|
|
static __inline void ahc_platform_dump_card_state(struct ahc_softc *ahc);
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_print_path(struct ahc_softc *ahc, struct scb *scb)
|
|
|
|
{
|
|
|
|
xpt_print_path(scb->io_ctx->ccb_h.path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_platform_dump_card_state(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
/* Nothing to do here for FreeBSD */
|
|
|
|
}
|
|
|
|
/**************************** Transfer Settings *******************************/
|
|
|
|
void ahc_notify_xfer_settings_change(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *);
|
|
|
|
void ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *,
|
|
|
|
int /*enable*/);
|
|
|
|
|
ahc_eisa.c:
ahc_pci.c:
Add detach support.
Make use of soft allocated on our behalf by newbus.
For PCI devices, disable the mapping type we aren't
using for extra protection from rogue code.
aic7xxx_93cx6.c:
aic7xxx_93cx6.h:
Sync perforce IDs.
aic7xxx_freebsd.c:
Capture the eventhandle returned by EVENTHANDER_REGISTER
so we can kill the handler off during detach.
Use AHC_* constants instead of hard coded numbers in a
few more places.
Test PPR option state when deciding to "really" negotiate
when the CAM_NEGOTIATE flag is passed in a CCB.
Make use of core "ahc_pause_and_flushwork" routine in our
timeout handler rather than re-inventing this code.
Cleanup all of our resources (really!) in ahc_platform_free().
We should be all set to become a module now.
Implement the core ahc_detach() routine shared by all of
the FreeBSD front-ends.
aic7xxx_freebsd.h:
Softc storage for our event handler.
Null implementation for the ahc_platform_flushwork() OSM
callback. FreeBSD doesn't need this as XPT callbacks are
safe from all contexts and are done directly in ahc_done().
aic7xxx_inline.h:
Implement new lazy interrupt scheme. To avoid an extra
PCI bus read, we first check our completion queues to
see if any work has completed. If work is available, we
assume that this is the source of the interrupt and skip
reading INTSTAT. Any remaining interrupt status will be
cleared by a second call to the interrupt handler should
the interrupt line still be asserted. This drops the
interrupt handler down to a single PCI bus read in the
common case of I/O completion. This is the same overhead
as in the not so distant past, but the extra sanity of
perforning a PCI read after clearing the command complete
interrupt and before running the completion queue to avoid
missing command complete interrupts added a cycle.
aic7xxx.c:
During initialization, be sure to initialize all scratch
ram locations before they are read to avoid parity errors.
In this case, we use a new function, ahc_unbusy_tcl() to
initialize the scratch ram busy target table.
Replace instances of ahc_index_busy_tcl() used to unbusy
a tcl without looking at the old value with ahc_unbusy_tcl().
Modify ahc_sent_msg so that it can find single byte messages.
ahc_sent_msg is now used to determine if a transfer negotiation
attempt resulted in a bus free.
Be more careful in filtering out only the SCSI interrupts
of interest in ahc_handle_scsiint.
Rearrange interrupt clearing code to ensure that at least
one PCI transaction occurrs after hitting CLRSINT1 and
writting to CLRINT. CLRSINT1 writes take a bit to
take effect, and the re-arrangement provides sufficient
delay to ensure the write to CLRINT is effective. The
old code might report a spurious interrupt on some "fast"
chipsets.
export ahc-update_target_msg_request for use by OSM code.
If a target does not respond to our ATN request, clear
it once we move to a non-message phase. This avoids
sending a MSG_NOOP in some later message out phase.
Use max lun and max target constants instead of
hard-coded values.
Use softc storage built into our device_t under FreeBSD.
Fix a bug in ahc_free() that caused us to delete
resources that were not allocated.
Clean up any tstate/lstate info in ahc_free().
Clear the powerdown state in ahc_reset() so that
registers can be accessed.
Add a preliminary function for pausing the chip and
processing any posted work.
Add a preliminary suspend and resume functions.
aic7xxx.h:
Limit the number of supported luns to 64. We don't
support information unit transfers, so this is the
maximum that makes sense for these chips.
Add a new flag AHC_ALL_INTERRUPTS that forces the
processing of all interrupt state in a single invokation
of ahc_intr(). When the flag is not set, we use the
lazy interrupt handling scheme.
Add data structures to store controller state while
we are suspended.
Use constants instead of hard coded values where appropriate.
Correct some harmless "unsigned/signed" conflicts.
aic7xxx.seq:
Only perform the SCSIBUSL fix on ULTRA2 or newer controllers.
Older controllers seem to be confused by this.
In target mode, ignore PHASEMIS during data phases.
This bit seems to be flakey on U160 controllers acting
in target mode.
aic7xxx_pci.c:
Add support for the 29160C CPCI adapter.
Add definitions for subvendor ID information
available for devices with the "9005" vendor id.
We currently use this information to determine
if a multi-function device doesn't have the second
channel hooked up on a board.
Add rudimentary power mode code so we can put the
controller into the D0 state. In the future this
will be an OSM callback so that in FreeBSD we don't
duplicate functionality provided by the PCI code.
The powerstate code was added after I'd completed
my regression tests on this code.
Only capture "left over BIOS state" if the POWRDN
setting is not set in HCNTRL.
In target mode, don't bother sending incremental
CRC data.
2000-12-20 01:11:37 +00:00
|
|
|
/************************* Initialization/Teardown ****************************/
|
2000-09-16 20:02:28 +00:00
|
|
|
int ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg);
|
|
|
|
void ahc_platform_free(struct ahc_softc *ahc);
|
2002-04-24 16:58:51 +00:00
|
|
|
int ahc_map_int(struct ahc_softc *ahc);
|
2000-09-16 20:02:28 +00:00
|
|
|
int ahc_attach(struct ahc_softc *);
|
|
|
|
int ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc);
|
ahc_eisa.c:
ahc_pci.c:
Add detach support.
Make use of soft allocated on our behalf by newbus.
For PCI devices, disable the mapping type we aren't
using for extra protection from rogue code.
aic7xxx_93cx6.c:
aic7xxx_93cx6.h:
Sync perforce IDs.
aic7xxx_freebsd.c:
Capture the eventhandle returned by EVENTHANDER_REGISTER
so we can kill the handler off during detach.
Use AHC_* constants instead of hard coded numbers in a
few more places.
Test PPR option state when deciding to "really" negotiate
when the CAM_NEGOTIATE flag is passed in a CCB.
Make use of core "ahc_pause_and_flushwork" routine in our
timeout handler rather than re-inventing this code.
Cleanup all of our resources (really!) in ahc_platform_free().
We should be all set to become a module now.
Implement the core ahc_detach() routine shared by all of
the FreeBSD front-ends.
aic7xxx_freebsd.h:
Softc storage for our event handler.
Null implementation for the ahc_platform_flushwork() OSM
callback. FreeBSD doesn't need this as XPT callbacks are
safe from all contexts and are done directly in ahc_done().
aic7xxx_inline.h:
Implement new lazy interrupt scheme. To avoid an extra
PCI bus read, we first check our completion queues to
see if any work has completed. If work is available, we
assume that this is the source of the interrupt and skip
reading INTSTAT. Any remaining interrupt status will be
cleared by a second call to the interrupt handler should
the interrupt line still be asserted. This drops the
interrupt handler down to a single PCI bus read in the
common case of I/O completion. This is the same overhead
as in the not so distant past, but the extra sanity of
perforning a PCI read after clearing the command complete
interrupt and before running the completion queue to avoid
missing command complete interrupts added a cycle.
aic7xxx.c:
During initialization, be sure to initialize all scratch
ram locations before they are read to avoid parity errors.
In this case, we use a new function, ahc_unbusy_tcl() to
initialize the scratch ram busy target table.
Replace instances of ahc_index_busy_tcl() used to unbusy
a tcl without looking at the old value with ahc_unbusy_tcl().
Modify ahc_sent_msg so that it can find single byte messages.
ahc_sent_msg is now used to determine if a transfer negotiation
attempt resulted in a bus free.
Be more careful in filtering out only the SCSI interrupts
of interest in ahc_handle_scsiint.
Rearrange interrupt clearing code to ensure that at least
one PCI transaction occurrs after hitting CLRSINT1 and
writting to CLRINT. CLRSINT1 writes take a bit to
take effect, and the re-arrangement provides sufficient
delay to ensure the write to CLRINT is effective. The
old code might report a spurious interrupt on some "fast"
chipsets.
export ahc-update_target_msg_request for use by OSM code.
If a target does not respond to our ATN request, clear
it once we move to a non-message phase. This avoids
sending a MSG_NOOP in some later message out phase.
Use max lun and max target constants instead of
hard-coded values.
Use softc storage built into our device_t under FreeBSD.
Fix a bug in ahc_free() that caused us to delete
resources that were not allocated.
Clean up any tstate/lstate info in ahc_free().
Clear the powerdown state in ahc_reset() so that
registers can be accessed.
Add a preliminary function for pausing the chip and
processing any posted work.
Add a preliminary suspend and resume functions.
aic7xxx.h:
Limit the number of supported luns to 64. We don't
support information unit transfers, so this is the
maximum that makes sense for these chips.
Add a new flag AHC_ALL_INTERRUPTS that forces the
processing of all interrupt state in a single invokation
of ahc_intr(). When the flag is not set, we use the
lazy interrupt handling scheme.
Add data structures to store controller state while
we are suspended.
Use constants instead of hard coded values where appropriate.
Correct some harmless "unsigned/signed" conflicts.
aic7xxx.seq:
Only perform the SCSIBUSL fix on ULTRA2 or newer controllers.
Older controllers seem to be confused by this.
In target mode, ignore PHASEMIS during data phases.
This bit seems to be flakey on U160 controllers acting
in target mode.
aic7xxx_pci.c:
Add support for the 29160C CPCI adapter.
Add definitions for subvendor ID information
available for devices with the "9005" vendor id.
We currently use this information to determine
if a multi-function device doesn't have the second
channel hooked up on a board.
Add rudimentary power mode code so we can put the
controller into the D0 state. In the future this
will be an OSM callback so that in FreeBSD we don't
duplicate functionality provided by the PCI code.
The powerstate code was added after I'd completed
my regression tests on this code.
Only capture "left over BIOS state" if the POWRDN
setting is not set in HCNTRL.
In target mode, don't bother sending incremental
CRC data.
2000-12-20 01:11:37 +00:00
|
|
|
int ahc_detach(device_t);
|
|
|
|
|
|
|
|
/****************************** Interrupts ************************************/
|
|
|
|
void ahc_platform_intr(void *);
|
|
|
|
static __inline void ahc_platform_flushwork(struct ahc_softc *ahc);
|
|
|
|
static __inline void
|
|
|
|
ahc_platform_flushwork(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
}
|
2000-09-16 20:02:28 +00:00
|
|
|
|
|
|
|
/************************ Misc Function Declarations **************************/
|
|
|
|
timeout_t ahc_timeout;
|
|
|
|
void ahc_done(struct ahc_softc *ahc, struct scb *scb);
|
2000-09-22 22:18:05 +00:00
|
|
|
void ahc_send_async(struct ahc_softc *, char /*channel*/,
|
2001-05-15 19:41:12 +00:00
|
|
|
u_int /*target*/, u_int /*lun*/, ac_code, void *arg);
|
2000-09-16 20:02:28 +00:00
|
|
|
#endif /* _AIC7XXX_FREEBSD_H_ */
|