Project

General

Profile

Bug #915 ยป aac.patch

pavalos, 01/13/2008 05:42 PM

View differences:

sys/dev/raid/aac/aac.c
/*
* Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters.
*/
#define AAC_DRIVER_VERSION 0x02000000
#define AAC_DRIVERNAME "aac"
#include "opt_aac.h"
......
#include <sys/kthread.h>
#include <sys/sysctl.h>
#include <sys/poll.h>
#if defined(__FreeBSD__) && __FreeBSD_version >= 500005
#include <sys/selinfo.h>
#else
#include <sys/select.h>
#endif
#include "aac_compat.h"
#include <sys/bus.h>
#include <sys/conf.h>
......
#include <sys/signalvar.h>
#include <sys/time.h>
#include <sys/eventhandler.h>
#include <sys/rman.h>
#include <bus/pci/pcireg.h>
#include <bus/pci/pcivar.h>
#include "aacreg.h"
#include "aac_ioctl.h"
#include "aacvar.h"
#include "aac_tables.h"
#include "aac_cam.h"
static void aac_startup(void *arg);
static void aac_add_container(struct aac_softc *sc,
......
/* Command Processing */
static void aac_timeout(void *ssc);
static int aac_start(struct aac_command *cm);
static int aac_map_command(struct aac_command *cm);
static void aac_complete(void *context, int pending);
static int aac_bio_command(struct aac_softc *sc, struct aac_command **cmp);
static void aac_bio_complete(struct aac_command *cm);
static int aac_wait_command(struct aac_command *cm, int timeout);
static void aac_host_command(struct aac_softc *sc);
static void aac_host_response(struct aac_softc *sc);
static int aac_wait_command(struct aac_command *cm);
static void aac_command_thread(struct aac_softc *sc);
/* Command Buffer Management */
static void aac_map_command_sg(void *arg, bus_dma_segment_t *segs,
int nseg, int error);
static void aac_map_command_helper(void *arg, bus_dma_segment_t *segs,
int nseg, int error);
static int aac_alloc_commands(struct aac_softc *sc);
static void aac_free_commands(struct aac_softc *sc);
static void aac_map_command(struct aac_command *cm);
static void aac_unmap_command(struct aac_command *cm);
/* Hardware Interface */
......
aac_fa_clear_istatus,
aac_fa_set_mailbox,
aac_fa_get_mailbox,
aac_fa_set_interrupts
aac_fa_set_interrupts,
NULL, NULL, NULL
};
/* StrongARM interface */
......
aac_sa_clear_istatus,
aac_sa_set_mailbox,
aac_sa_get_mailbox,
aac_sa_set_interrupts
aac_sa_set_interrupts,
NULL, NULL, NULL
};
/* i960Rx interface */
/* i960Rx interface */
static int aac_rx_get_fwstatus(struct aac_softc *sc);
static void aac_rx_qnotify(struct aac_softc *sc, int qbit);
static int aac_rx_get_istatus(struct aac_softc *sc);
......
u_int32_t arg2, u_int32_t arg3);
static int aac_rx_get_mailbox(struct aac_softc *sc, int mb);
static void aac_rx_set_interrupts(struct aac_softc *sc, int enable);
static int aac_rx_send_command(struct aac_softc *sc, struct aac_command *cm);
static int aac_rx_get_outb_queue(struct aac_softc *sc);
static void aac_rx_set_outb_queue(struct aac_softc *sc, int index);
struct aac_interface aac_rx_interface = {
aac_rx_get_fwstatus,
......
aac_rx_clear_istatus,
aac_rx_set_mailbox,
aac_rx_get_mailbox,
aac_rx_set_interrupts
aac_rx_set_interrupts,
aac_rx_send_command,
aac_rx_get_outb_queue,
aac_rx_set_outb_queue
};
/* Rocket/MIPS interface */
static int aac_rkt_get_fwstatus(struct aac_softc *sc);
static void aac_rkt_qnotify(struct aac_softc *sc, int qbit);
static int aac_rkt_get_istatus(struct aac_softc *sc);
static void aac_rkt_clear_istatus(struct aac_softc *sc, int mask);
static void aac_rkt_set_mailbox(struct aac_softc *sc, u_int32_t command,
u_int32_t arg0, u_int32_t arg1,
u_int32_t arg2, u_int32_t arg3);
static int aac_rkt_get_mailbox(struct aac_softc *sc, int mb);
static void aac_rkt_set_interrupts(struct aac_softc *sc, int enable);
static int aac_rkt_send_command(struct aac_softc *sc, struct aac_command *cm);
static int aac_rkt_get_outb_queue(struct aac_softc *sc);
static void aac_rkt_set_outb_queue(struct aac_softc *sc, int index);
struct aac_interface aac_rkt_interface = {
aac_rkt_get_fwstatus,
aac_rkt_qnotify,
aac_rkt_get_istatus,
aac_rkt_clear_istatus,
aac_rkt_set_mailbox,
aac_rkt_get_mailbox,
aac_rkt_set_interrupts,
aac_rkt_send_command,
aac_rkt_get_outb_queue,
aac_rkt_set_outb_queue
};
/* Debugging and Diagnostics */
......
static d_close_t aac_close;
static d_ioctl_t aac_ioctl;
static d_poll_t aac_poll;
static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib);
static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib) __unused;
static void aac_handle_aif(struct aac_softc *sc,
struct aac_fib *fib);
static int aac_rev_check(struct aac_softc *sc, caddr_t udata);
static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg);
static int aac_return_aif(struct aac_softc *sc, caddr_t uptr);
static int aac_query_disk(struct aac_softc *sc, caddr_t uptr);
static int aac_get_pci_info(struct aac_softc *sc, caddr_t uptr);
static void aac_ioctl_event(struct aac_softc *sc,
struct aac_event *event, void *arg);
#define AAC_CDEV_MAJOR 150
......
aac_initq_complete(sc);
aac_initq_bio(sc);
#if defined(__FreeBSD__) && __FreeBSD_version >= 500005
/*
* Initialise command-completion task.
*/
TASK_INIT(&sc->aac_task_complete, 0, aac_complete, sc);
#endif
/* disable interrupts before we enable anything */
AAC_MASK_INTERRUPTS(sc);
/* mark controller as suspended until we get ourselves organised */
sc->aac_state |= AAC_STATE_SUSPEND;
......
if ((error = aac_check_firmware(sc)) != 0)
return(error);
/* Init the sync fib lock */
AAC_LOCK_INIT(&sc->aac_sync_lock, "AAC sync FIB lock");
/*
* Initialize locks
*/
AAC_LOCK_INIT(&sc->aac_aifq_lock, "AAC AIF lock");
AAC_LOCK_INIT(&sc->aac_io_lock, "AAC I/O lock");
AAC_LOCK_INIT(&sc->aac_container_lock, "AAC container lock");
TAILQ_INIT(&sc->aac_container_tqh);
TAILQ_INIT(&sc->aac_ev_cmfree);
/* Initialize the local AIF queue pointers */
sc->aac_aifq_head = sc->aac_aifq_tail = AAC_AIFQ_LENGTH;
/*
* Initialise the adapter.
......
if ((error = aac_init(sc)) != 0)
return(error);
/*
* Print a little information about the controller.
/*
* Allocate and connect our interrupt.
*/
aac_describe_controller(sc);
sc->aac_irq_rid = 0;
if ((sc->aac_irq = bus_alloc_resource_any(sc->aac_dev, SYS_RES_IRQ,
&sc->aac_irq_rid,
RF_SHAREABLE |
RF_ACTIVE)) == NULL) {
device_printf(sc->aac_dev, "can't allocate interrupt\n");
return (EINVAL);
}
if (sc->flags & AAC_FLAGS_NEW_COMM) {
if (bus_setup_intr(sc->aac_dev, sc->aac_irq,
INTR_MPSAFE, aac_new_intr,
sc, &sc->aac_intr, NULL)) {
device_printf(sc->aac_dev, "can't set up interrupt\n");
return (EINVAL);
}
} else {
if (bus_setup_intr(sc->aac_dev, sc->aac_irq,
INTR_FAST, aac_fast_intr,
sc, &sc->aac_intr, NULL)) {
device_printf(sc->aac_dev,
"can't set up FAST interrupt\n");
if (bus_setup_intr(sc->aac_dev, sc->aac_irq,
INTR_MPSAFE, aac_fast_intr,
sc, &sc->aac_intr, NULL)) {
device_printf(sc->aac_dev,
"can't set up MPSAFE interrupt\n");
return (EINVAL);
}
}
}
/*
* Register to probe our containers later.
* Print a little information about the controller.
*/
TAILQ_INIT(&sc->aac_container_tqh);
AAC_LOCK_INIT(&sc->aac_container_lock, "AAC container lock");
aac_describe_controller(sc);
/*
* Lock for the AIF queue
* Register to probe our containers later.
*/
AAC_LOCK_INIT(&sc->aac_aifq_lock, "AAC AIF lock");
sc->aac_ich.ich_func = aac_startup;
sc->aac_ich.ich_arg = sc;
sc->aac_ich.ich_desc = "aac";
......
*/
unit = device_get_unit(sc->aac_dev);
dev_ops_add(&aac_ops, -1, unit);
sc->aac_dev_t = make_dev(&aac_ops, unit, UID_ROOT, GID_WHEEL, 0644,
sc->aac_dev_t = make_dev(&aac_ops, unit, UID_ROOT, GID_OPERATOR, 0640,
"aac%d", unit);
#if defined(__FreeBSD__) && __FreeBSD_version > 500005
(void)make_dev_alias(sc->aac_dev_t, "afa%d", unit);
(void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit);
#endif
sc->aac_dev_t->si_drv1 = sc;
reference_dev(sc->aac_dev_t);
/* Create the AIF thread */
#if defined(__FreeBSD__) && __FreeBSD_version > 500005
if (kthread_create((void(*)(void *))aac_host_command, sc,
&sc->aifthread, 0, "aac%daif", unit))
#else
if (kthread_create((void(*)(void *))aac_host_command, sc,
if (kthread_create((void(*)(void *))aac_command_thread, sc,
&sc->aifthread, "aac%daif", unit))
#endif
panic("Could not create AIF thread\n");
/* Register the shutdown method to only be called post-dump */
if ((EVENTHANDLER_REGISTER(shutdown_post_sync, aac_shutdown, sc->aac_dev,
SHUTDOWN_PRI_DRIVER)) == NULL)
device_printf(sc->aac_dev, "shutdown event registration failed\n");
if ((sc->eh = EVENTHANDLER_REGISTER(shutdown_post_sync, aac_shutdown,
sc->aac_dev, SHUTDOWN_PRI_DRIVER)) == NULL)
device_printf(sc->aac_dev,
"shutdown event registration failed\n");
/* Register with CAM for the non-DASD devices */
if ((sc->flags & AAC_FLAGS_ENABLE_CAM) != 0)
if ((sc->flags & AAC_FLAGS_ENABLE_CAM) != 0) {
TAILQ_INIT(&sc->aac_sim_tqh);
aac_get_bus_info(sc);
}
return(0);
}
void
aac_add_event(struct aac_softc *sc, struct aac_event *event)
{
switch (event->ev_type & AAC_EVENT_MASK) {
case AAC_EVENT_CMFREE:
TAILQ_INSERT_TAIL(&sc->aac_ev_cmfree, event, ev_links);
break;
default:
device_printf(sc->aac_dev, "aac_add event: unknown event %d\n",
event->ev_type);
break;
}
return;
}
/*
* Probe for containers, create disks.
*/
......
/* disconnect ourselves from the intrhook chain */
config_intrhook_disestablish(&sc->aac_ich);
aac_alloc_sync_fib(sc, &fib, 0);
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
aac_alloc_sync_fib(sc, &fib);
mi = (struct aac_mntinfo *)&fib->data[0];
/* loop over possible containers */
......
} while ((i < count) && (i < AAC_MAX_CONTAINERS));
aac_release_sync_fib(sc);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
/* poke the bus to actually attach the child devices */
if (bus_generic_attach(sc->aac_dev))
......
/* enable interrupts now */
AAC_UNMASK_INTERRUPTS(sc);
/* enable the timeout watchdog */
callout_reset(&sc->aac_watchdog, AAC_PERIODIC_INTERVAL * hz,
aac_timeout, sc);
}
/*
......
struct aac_container *co;
device_t child;
/*
/*
* Check container volume type for validity. Note that many of
* the possible types may never show up.
*/
if ((mir->Status == ST_OK) && (mir->MntTable[0].VolType != CT_NONE)) {
MALLOC(co, struct aac_container *, sizeof *co, M_AACBUF,
M_INTWAIT);
debug(1, "id %x name '%.16s' size %u type %d",
co = (struct aac_container *)kmalloc(sizeof *co, M_AACBUF,
M_INTWAIT | M_ZERO);
debug(1, "id %x name '%.16s' size %u type %d",
mir->MntTable[0].ObjectId,
mir->MntTable[0].FileSystemName,
mir->MntTable[0].Capacity, mir->MntTable[0].VolType);
if ((child = device_add_child(sc->aac_dev, "aacd", -1)) == NULL)
device_printf(sc->aac_dev, "device_add_child failed\n");
else
......
void
aac_free(struct aac_softc *sc)
{
debug_called(1);
/* remove the control device */
......
destroy_dev(sc->aac_dev_t);
/* throw away any FIB buffers, discard the FIB DMA tag */
if (sc->aac_fibs != NULL)
aac_free_commands(sc);
aac_free_commands(sc);
if (sc->aac_fib_dmat)
bus_dma_tag_destroy(sc->aac_fib_dmat);
kfree(sc->aac_commands, M_AACBUF);
/* destroy the common area */
if (sc->aac_common) {
bus_dmamap_unload(sc->aac_common_dmat, sc->aac_common_dmamap);
......
aac_detach(device_t dev)
{
struct aac_softc *sc;
#if AAC_BROKEN
struct aac_container *co;
struct aac_sim *sim;
int error;
#endif
debug_called(1);
......
callout_stop(&sc->aac_watchdog);
if (sc->aac_state & AAC_STATE_OPEN)
return(EBUSY);
return(EBUSY);
/* Remove the child containers */
while ((co = TAILQ_FIRST(&sc->aac_container_tqh)) != NULL) {
error = device_delete_child(dev, co->co_disk);
if (error)
return (error);
TAILQ_REMOVE(&sc->aac_container_tqh, co, co_link);
kfree(co, M_AACBUF);
}
/* Remove the CAM SIMs */
while ((sim = TAILQ_FIRST(&sc->aac_sim_tqh)) != NULL) {
TAILQ_REMOVE(&sc->aac_sim_tqh, sim, sim_link);
error = device_delete_child(dev, sim->sim_dev);
if (error)
return (error);
kfree(sim, M_AACBUF);
}
#if AAC_BROKEN
if (sc->aifflags & AAC_AIFFLAGS_RUNNING) {
sc->aifflags |= AAC_AIFFLAGS_EXIT;
wakeup(sc->aifthread);
......
if ((error = aac_shutdown(dev)))
return(error);
EVENTHANDLER_DEREGISTER(shutdown_post_sync, sc->eh);
aac_free(sc);
lockuninit(&sc->aac_aifq_lock);
lockuninit(&sc->aac_io_lock);
lockuninit(&sc->aac_container_lock);
return(0);
#else
return (EBUSY);
#endif
}
/*
......
sc = device_get_softc(dev);
crit_enter();
sc->aac_state |= AAC_STATE_SUSPEND;
/*
/*
* Send a Container shutdown followed by a HostShutdown FIB to the
* controller to convince it that we don't want to talk to it anymore.
* We've been closed and all I/O completed already
*/
device_printf(sc->aac_dev, "shutting down controller...");
aac_alloc_sync_fib(sc, &fib, AAC_SYNC_LOCK_FORCE);
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
aac_alloc_sync_fib(sc, &fib);
cc = (struct aac_close_command *)&fib->data[0];
bzero(cc, sizeof(struct aac_close_command));
......
if (aac_sync_fib(sc, ContainerCommand, 0, fib,
sizeof(struct aac_close_command)))
kprintf("FAILED.\n");
else
kprintf("done\n");
#if 0
else {
fib->data[0] = 0;
/*
......
kprintf("done.\n");
}
}
#endif
AAC_MASK_INTERRUPTS(sc);
aac_release_sync_fib(sc);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
crit_exit();
return(0);
}
......
sc = device_get_softc(dev);
crit_enter();
sc->aac_state |= AAC_STATE_SUSPEND;
AAC_MASK_INTERRUPTS(sc);
crit_exit();
return(0);
}
......
}
/*
* Take an interrupt.
* Interrupt handler for NEW_COMM interface.
*/
void
aac_intr(void *arg)
aac_new_intr(void *arg)
{
struct aac_softc *sc;
u_int32_t index, fast;
struct aac_command *cm;
struct aac_fib *fib;
int i;
debug_called(2);
sc = (struct aac_softc *)arg;
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
while (1) {
index = AAC_GET_OUTB_QUEUE(sc);
if (index == 0xffffffff)
index = AAC_GET_OUTB_QUEUE(sc);
if (index == 0xffffffff)
break;
if (index & 2) {
if (index == 0xfffffffe) {
/* XXX This means that the controller wants
* more work. Ignore it for now.
*/
continue;
}
/* AIF */
fib = (struct aac_fib *)kmalloc(sizeof *fib, M_AACBUF,
M_INTWAIT | M_ZERO);
index &= ~2;
for (i = 0; i < sizeof(struct aac_fib)/4; ++i)
((u_int32_t *)fib)[i] = AAC_GETREG4(sc, index + i*4);
aac_handle_aif(sc, fib);
kfree(fib, M_AACBUF);
/*
* AIF memory is owned by the adapter, so let it
* know that we are done with it.
*/
AAC_SET_OUTB_QUEUE(sc, index);
AAC_CLEAR_ISTATUS(sc, AAC_DB_RESPONSE_READY);
} else {
fast = index & 1;
cm = sc->aac_commands + (index >> 2);
fib = cm->cm_fib;
if (fast) {
fib->Header.XferState |= AAC_FIBSTATE_DONEADAP;
*((u_int32_t *)(fib->data)) = AAC_ERROR_NORMAL;
}
aac_remove_busy(cm);
aac_unmap_command(cm);
cm->cm_flags |= AAC_CMD_COMPLETED;
/* is there a completion handler? */
if (cm->cm_complete != NULL) {
cm->cm_complete(cm);
} else {
/* assume that someone is sleeping on this
* command
*/
wakeup(cm);
}
sc->flags &= ~AAC_QUEUE_FRZN;
}
}
/* see if we can start some more I/O */
if ((sc->flags & AAC_QUEUE_FRZN) == 0)
aac_startio(sc);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
}
void
aac_fast_intr(void *arg)
{
struct aac_softc *sc;
u_int16_t reason;
u_int32_t *resp_queue;
debug_called(2);
sc = (struct aac_softc *)arg;
/*
* Optimize the common case of adapter response interrupts.
* We must read from the card prior to processing the responses
* to ensure the clear is flushed prior to accessing the queues.
* Reading the queues from local memory might save us a PCI read.
* Read the status register directly. This is faster than taking the
* driver lock and reading the queues directly. It also saves having
* to turn parts of the driver lock into a spin mutex, which would be
* ugly.
*/
resp_queue = sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE];
if (resp_queue[AAC_PRODUCER_INDEX] != resp_queue[AAC_CONSUMER_INDEX])
reason = AAC_DB_RESPONSE_READY;
else
reason = AAC_GET_ISTATUS(sc);
reason = AAC_GET_ISTATUS(sc);
AAC_CLEAR_ISTATUS(sc, reason);
(void)AAC_GET_ISTATUS(sc);
/* It's not ok to return here because of races with the previous step */
/* handle completion processing */
if (reason & AAC_DB_RESPONSE_READY)
aac_host_response(sc);
taskqueue_enqueue(taskqueue_swi, &sc->aac_task_complete);
/* controller wants to talk to the log */
if (reason & AAC_DB_PRINTF)
aac_print_printf(sc);
/* controller wants to talk to us */
if (reason & (AAC_DB_PRINTF | AAC_DB_COMMAND_READY)) {
/*
* XXX Make sure that we don't get fooled by strange messages
* that start with a NULL.
*/
if ((reason & AAC_DB_PRINTF) &&
(sc->aac_common->ac_printf[0] == 0))
sc->aac_common->ac_printf[0] = 32;
/* controller has a message for us? */
if (reason & AAC_DB_COMMAND_READY) {
/* XXX What happens if the thread is already awake? */
if (sc->aifflags & AAC_AIFFLAGS_RUNNING) {
sc->aifflags |= AAC_AIFFLAGS_PENDING;
wakeup(sc->aifthread);
}
/*
* This might miss doing the actual wakeup. However, the
* msleep that this is waking up has a timeout, so it will
* wake up eventually. AIFs and printfs are low enough
* priority that they can handle hanging out for a few seconds
* if needed.
*/
wakeup(sc->aifthread);
}
}
......
debug_called(2);
if (sc->flags & AAC_QUEUE_FRZN)
return;
for (;;) {
/*
* Try to get a command that's been put off for lack of
* Try to get a command that's been put off for lack of
* resources
*/
cm = aac_dequeue_ready(sc);
/*
* Try to build a command off the bio queue (ignore error
* Try to build a command off the bio queue (ignore error
* return)
*/
if (cm == NULL)
......
if (cm == NULL)
break;
/* try to give the command to the controller */
if (aac_start(cm) == EBUSY) {
/* put it on the ready queue for later */
aac_requeue_ready(cm);
break;
}
/*
* Try to give the command to the controller. Any error is
* catastrophic since it means that bus_dmamap_load() failed.
*/
if (aac_map_command(cm) != 0)
panic("aac: error mapping command %p\n", cm);
}
}
......
* last moment when possible.
*/
static int
aac_start(struct aac_command *cm)
aac_map_command(struct aac_command *cm)
{
struct aac_softc *sc;
int error;
......
debug_called(2);
sc = cm->cm_sc;
error = 0;
/* get the command mapped */
aac_map_command(cm);
/* fix up the address values in the FIB */
cm->cm_fib->Header.SenderFibAddress = (u_int32_t)cm->cm_fib;
cm->cm_fib->Header.ReceiverFibAddress = cm->cm_fibphys;
/* don't map more than once */
if (cm->cm_flags & AAC_CMD_MAPPED)
panic("aac: command %p already mapped", cm);
/* save a pointer to the command for speedy reverse-lookup */
cm->cm_fib->Header.SenderData = (u_int32_t)cm; /* XXX 64-bit physical
* address issue */
/* put the FIB on the outbound queue */
error = aac_enqueue_fib(sc, cm->cm_queue, cm);
return(error);
if (cm->cm_datalen != 0) {
error = bus_dmamap_load(sc->aac_buffer_dmat, cm->cm_datamap,
cm->cm_data, cm->cm_datalen,
aac_map_command_sg, cm, 0);
if (error == EINPROGRESS) {
debug(1, "freezing queue\n");
sc->flags |= AAC_QUEUE_FRZN;
error = 0;
}
} else {
aac_map_command_sg(cm, NULL, 0, 0);
}
return (error);
}
/*
* Handle notification of one or more FIBs coming from the controller.
*/
static void
aac_host_command(struct aac_softc *sc)
aac_command_thread(struct aac_softc *sc)
{
struct aac_fib *fib;
u_int32_t fib_size;
int size;
int size, retval;
debug_called(2);
sc->aifflags |= AAC_AIFFLAGS_RUNNING;
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
sc->aifflags = AAC_AIFFLAGS_RUNNING;
while (!(sc->aifflags & AAC_AIFFLAGS_EXIT)) {
if (!(sc->aifflags & AAC_AIFFLAGS_PENDING))
tsleep(sc->aifthread, 0, "aifthd", 15 * hz);
while ((sc->aifflags & AAC_AIFFLAGS_EXIT) == 0) {
retval = 0;
if ((sc->aifflags & AAC_AIFFLAGS_PENDING) == 0) {
crit_enter();
tsleep_interlock(sc->aifthread);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
retval = tsleep(sc->aifthread, 0,
"aifthd", AAC_PERIODIC_INTERVAL * hz);
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
crit_exit();
}
/*
* First see if any FIBs need to be allocated. This needs
* to be called without the driver lock because contigmalloc
* will grab Giant, and would result in an LOR.
*/
if ((sc->aifflags & AAC_AIFFLAGS_ALLOCFIBS) != 0) {
AAC_LOCK_RELEASE(&sc->aac_io_lock);
aac_alloc_commands(sc);
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
sc->aifflags &= ~AAC_AIFFLAGS_ALLOCFIBS;
aac_startio(sc);
}
/*
* While we're here, check to see if any commands are stuck.
* This is pretty low-priority, so it's ok if it doesn't
* always fire.
*/
if (retval == EWOULDBLOCK)
aac_timeout(sc);
/* Check the hardware printf message buffer */
if (sc->aac_common->ac_printf[0] != 0)
aac_print_printf(sc);
sc->aifflags &= ~AAC_AIFFLAGS_PENDING;
/* Also check to see if the adapter has a command for us. */
if (sc->flags & AAC_FLAGS_NEW_COMM)
continue;
for (;;) {
if (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE,
&fib_size, &fib))
break; /* nothing to do */
break;
AAC_PRINT_FIB(sc, fib);
switch (fib->Header.Command) {
case AifRequest:
aac_handle_aif(sc, fib);
......
break;
}
/* Return the AIF to the controller. */
if ((fib->Header.XferState == 0) ||
(fib->Header.StructType != AAC_FIBTYPE_TFIB))
(fib->Header.StructType != AAC_FIBTYPE_TFIB)) {
break;
}
/* Return the AIF to the controller. */
if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) {
fib->Header.XferState |= AAC_FIBSTATE_DONEHOST;
*(AAC_FSAStatus*)fib->data = ST_OK;
......
* enqueue->startio chain.
*/
aac_enqueue_response(sc,
AAC_ADAP_NORM_RESP_QUEUE,
fib);
AAC_ADAP_NORM_RESP_QUEUE,
fib);
}
}
}
sc->aifflags &= ~AAC_AIFFLAGS_RUNNING;
AAC_LOCK_RELEASE(&sc->aac_io_lock);
wakeup(sc->aac_dev);
#if defined(__FreeBSD__) && __FreeBSD_version > 500005
mtx_lock(&Giant);
#endif
kthread_exit();
}
/*
* Handle notification of one or more FIBs completed by the controller
* Process completed commands.
*/
static void
aac_host_response(struct aac_softc *sc)
aac_complete(void *context, int pending)
{
struct aac_softc *sc;
struct aac_command *cm;
struct aac_fib *fib;
u_int32_t fib_size;
debug_called(2);
sc = (struct aac_softc *)context;
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
/* pull completed commands off the queue */
for (;;) {
/* look for completed FIBs on our queue */
if (aac_dequeue_fib(sc, AAC_HOST_NORM_RESP_QUEUE, &fib_size,
&fib))
&fib))
break; /* nothing to do */
/* get the command, unmap and queue for later processing */
cm = (struct aac_command *)fib->Header.SenderData;
cm = sc->aac_commands + fib->Header.SenderData;
if (cm == NULL) {
AAC_PRINT_FIB(sc, fib);
} else {
aac_remove_busy(cm);
aac_unmap_command(cm); /* XXX defer? */
aac_enqueue_complete(cm);
}
}
/* handle completion processing */
#if defined(__FreeBSD__) && __FreeBSD_version >= 500005
taskqueue_enqueue(taskqueue_swi, &sc->aac_task_complete);
#else
aac_complete(sc, 0);
#endif
}
/*
* Process completed commands.
*/
static void
aac_complete(void *context, int pending)
{
struct aac_softc *sc;
struct aac_command *cm;
debug_called(2);
sc = (struct aac_softc *)context;
/* pull completed commands off the queue */
for (;;) {
cm = aac_dequeue_complete(sc);
if (cm == NULL)
break;
}
aac_remove_busy(cm);
aac_unmap_command(cm); /* XXX defer? */
cm->cm_flags |= AAC_CMD_COMPLETED;
/* is there a completion handler? */
......
}
/* see if we can start some more I/O */
sc->flags &= ~AAC_QUEUE_FRZN;
aac_startio(sc);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
}
/*
......
{
struct aac_command *cm;
struct aac_fib *fib;
struct aac_blockread *br;
struct aac_blockwrite *bw;
struct aac_disk *ad;
struct bio *bio;
struct buf *bp;
......
/* get the resources we will need */
cm = NULL;
if ((bio = aac_dequeue_bio(sc)) == NULL)
goto fail;
bio = NULL;
if (aac_alloc_command(sc, &cm)) /* get a command */
goto fail;
if ((bio = aac_dequeue_bio(sc)) == NULL)
goto fail;
/* fill out the command */
bp = bio->bio_buf;
......
/* build the FIB */
fib = cm->cm_fib;
fib->Header.XferState =
AAC_FIBSTATE_HOSTOWNED |
AAC_FIBSTATE_INITIALISED |
AAC_FIBSTATE_EMPTY |
fib->Header.Size = sizeof(struct aac_fib_header);
fib->Header.XferState =
AAC_FIBSTATE_HOSTOWNED |
AAC_FIBSTATE_INITIALISED |
AAC_FIBSTATE_EMPTY |
AAC_FIBSTATE_FROMHOST |
AAC_FIBSTATE_REXPECTED |
AAC_FIBSTATE_NORM |
AAC_FIBSTATE_ASYNC |
AAC_FIBSTATE_FAST_RESPONSE;
fib->Header.Command = ContainerCommand;
fib->Header.Size = sizeof(struct aac_fib_header);
/* build the read/write request */
ad = (struct aac_disk *)bio->bio_driver_info;
if (bp->b_cmd == BUF_CMD_READ) {
br = (struct aac_blockread *)&fib->data[0];
br->Command = VM_CtBlockRead;
br->ContainerId = ad->ad_container->co_mntobj.ObjectId;
br->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
br->ByteCount = bp->b_bcount;
fib->Header.Size += sizeof(struct aac_blockread);
cm->cm_sgtable = &br->SgMap;
cm->cm_flags |= AAC_CMD_DATAIN;
if (sc->flags & AAC_FLAGS_RAW_IO) {
struct aac_raw_io *raw;
raw = (struct aac_raw_io *)&fib->data[0];
fib->Header.Command = RawIo;
raw->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
raw->ByteCount = bp->b_bcount;
raw->ContainerId = ad->ad_container->co_mntobj.ObjectId;
raw->BpTotal = 0;
raw->BpComplete = 0;
fib->Header.Size += sizeof(struct aac_raw_io);
cm->cm_sgtable = (struct aac_sg_table *)&raw->SgMapRaw;
if (bp->b_cmd == BUF_CMD_READ) {
raw->Flags = 1;
cm->cm_flags |= AAC_CMD_DATAIN;
} else {
raw->Flags = 0;
cm->cm_flags |= AAC_CMD_DATAOUT;
}
} else if ((sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
fib->Header.Command = ContainerCommand;
if (bp->b_cmd == BUF_CMD_READ) {
struct aac_blockread *br;
br = (struct aac_blockread *)&fib->data[0];
br->Command = VM_CtBlockRead;
br->ContainerId = ad->ad_container->co_mntobj.ObjectId;
br->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
br->ByteCount = bp->b_bcount;
fib->Header.Size += sizeof(struct aac_blockread);
cm->cm_sgtable = &br->SgMap;
cm->cm_flags |= AAC_CMD_DATAIN;
} else {
struct aac_blockwrite *bw;
bw = (struct aac_blockwrite *)&fib->data[0];
bw->Command = VM_CtBlockWrite;
bw->ContainerId = ad->ad_container->co_mntobj.ObjectId;
bw->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
bw->ByteCount = bp->b_bcount;
bw->Stable = CUNSTABLE;
fib->Header.Size += sizeof(struct aac_blockwrite);
cm->cm_flags |= AAC_CMD_DATAOUT;
cm->cm_sgtable = &bw->SgMap;
}
} else {
bw = (struct aac_blockwrite *)&fib->data[0];
bw->Command = VM_CtBlockWrite;
bw->ContainerId = ad->ad_container->co_mntobj.ObjectId;
bw->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
bw->ByteCount = bp->b_bcount;
bw->Stable = CUNSTABLE; /* XXX what's appropriate here? */
fib->Header.Size += sizeof(struct aac_blockwrite);
cm->cm_flags |= AAC_CMD_DATAOUT;
cm->cm_sgtable = &bw->SgMap;
fib->Header.Command = ContainerCommand64;
if (bp->b_cmd == BUF_CMD_READ) {
struct aac_blockread64 *br;
br = (struct aac_blockread64 *)&fib->data[0];
br->Command = VM_CtHostRead64;
br->ContainerId = ad->ad_container->co_mntobj.ObjectId;
br->SectorCount = bp->b_bcount / AAC_BLOCK_SIZE;
br->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
br->Pad = 0;
br->Flags = 0;
fib->Header.Size += sizeof(struct aac_blockread64);
cm->cm_flags |= AAC_CMD_DATAOUT;
cm->cm_sgtable = (struct aac_sg_table *)&br->SgMap64;
} else {
struct aac_blockwrite64 *bw;
bw = (struct aac_blockwrite64 *)&fib->data[0];
bw->Command = VM_CtHostWrite64;
bw->ContainerId = ad->ad_container->co_mntobj.ObjectId;
bw->SectorCount = bp->b_bcount / AAC_BLOCK_SIZE;
bw->BlockNumber = bio->bio_offset / AAC_BLOCK_SIZE;
bw->Pad = 0;
bw->Flags = 0;
fib->Header.Size += sizeof(struct aac_blockwrite64);
cm->cm_flags |= AAC_CMD_DATAIN;
cm->cm_sgtable = (struct aac_sg_table *)&bw->SgMap64;
}
}
*cmp = cm;
......
cm->cm_flags |= AAC_CMD_DATAOUT;
cm->cm_sgtable = &bw->SgMap;
return (aac_start(cm));
return (aac_map_command(cm));
}
/*
......
* Submit a command to the controller, return when it completes.
* XXX This is very dangerous! If the card has gone out to lunch, we could
* be stuck here forever. At the same time, signals are not caught
* because there is a risk that a signal could wakeup the tsleep before
* the card has a chance to complete the command. The passed in timeout
* is ignored for the same reason. Since there is no way to cancel a
* command in progress, we should probably create a 'dead' queue where
* commands go that have been interrupted/timed-out/etc, that keeps them
* out of the free pool. That way, if the card is just slow, it won't
* spam the memory of a command that has been recycled.
* because there is a risk that a signal could wakeup the sleep before
* the card has a chance to complete the command. Since there is no way
* to cancel a command that is in progress, we can't protect against the
* card completing a command late and spamming the command and data
* memory. So, we are held hostage until the command completes.
*/
static int
aac_wait_command(struct aac_command *cm, int timeout)
aac_wait_command(struct aac_command *cm)
{
int error = 0;
struct aac_softc *sc;
int error;
debug_called(2);
sc = cm->cm_sc;
/* Put the command on the ready queue and get things going */
cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE;
aac_enqueue_ready(cm);
aac_startio(cm->cm_sc);
aac_startio(sc);
/* Lock is held */
KKASSERT(lockstatus(&sc->aac_io_lock, curthread) != 0);
crit_enter();
while (!(cm->cm_flags & AAC_CMD_COMPLETED) && (error != EWOULDBLOCK)) {
error = tsleep(cm, 0, "aacwait", 0);
}
tsleep_interlock(cm);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
error = tsleep(cm, 0, "aacwait", 0);
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
crit_exit();
return(error);
}
......
debug_called(3);
if ((cm = aac_dequeue_free(sc)) == NULL)
return(ENOMEM);
if ((cm = aac_dequeue_free(sc)) == NULL) {
if (sc->total_fibs < sc->aac_max_fibs) {
sc->aifflags |= AAC_AIFFLAGS_ALLOCFIBS;
wakeup(sc->aifthread);
}
return (EBUSY);
}
*cmp = cm;
return(0);
......
void
aac_release_command(struct aac_command *cm)
{
struct aac_event *event;
struct aac_softc *sc;
debug_called(3);
/* (re)initialise the command/FIB */
......
cm->cm_fib->Header.XferState = AAC_FIBSTATE_EMPTY;
cm->cm_fib->Header.StructType = AAC_FIBTYPE_TFIB;
cm->cm_fib->Header.Flags = 0;
cm->cm_fib->Header.SenderSize = sizeof(struct aac_fib);
cm->cm_fib->Header.SenderSize = cm->cm_sc->aac_max_fib_size;
/*
/*
* These are duplicated in aac_start to cover the case where an
* intermediate stage may have destroyed them. They're left
* initialised here for debugging purposes only.
*/
cm->cm_fib->Header.SenderFibAddress = (u_int32_t)cm->cm_fib;
cm->cm_fib->Header.ReceiverFibAddress = (u_int32_t)cm->cm_fibphys;
cm->cm_fib->Header.SenderData = 0;
aac_enqueue_free(cm);
sc = cm->cm_sc;
event = TAILQ_FIRST(&sc->aac_ev_cmfree);
if (event != NULL) {
TAILQ_REMOVE(&sc->aac_ev_cmfree, event, ev_links);
event->ev_callback(sc, event, event->ev_arg);
}
}
/*
......
static void
aac_map_command_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
struct aac_softc *sc;
uint64_t *fibphys;
sc = (struct aac_softc *)arg;
fibphys = (uint64_t *)arg;
debug_called(3);
sc->aac_fibphys = segs[0].ds_addr;
*fibphys = segs[0].ds_addr;
}
/*
......
aac_alloc_commands(struct aac_softc *sc)
{
struct aac_command *cm;
int i;
debug_called(1);
struct aac_fibmap *fm;
uint64_t fibphys;
int i, error;
debug_called(2);
if (sc->total_fibs + sc->aac_max_fibs_alloc > sc->aac_max_fibs)
return (ENOMEM);
fm = kmalloc(sizeof(struct aac_fibmap), M_AACBUF, M_INTWAIT | M_ZERO);
/* allocate the FIBs in DMAable memory and load them */
if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&sc->aac_fibs,
BUS_DMA_NOWAIT, &sc->aac_fibmap)) {
return(ENOMEM);
if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&fm->aac_fibs,
BUS_DMA_NOWAIT, &fm->aac_fibmap)) {
device_printf(sc->aac_dev,
"Not enough contiguous memory available.\n");
kfree(fm, M_AACBUF);
return (ENOMEM);
}
bus_dmamap_load(sc->aac_fib_dmat, sc->aac_fibmap, sc->aac_fibs,
AAC_FIB_COUNT * sizeof(struct aac_fib),
aac_map_command_helper, sc, 0);
/* Ignore errors since this doesn't bounce */
bus_dmamap_load(sc->aac_fib_dmat, fm->aac_fibmap, fm->aac_fibs,
sc->aac_max_fibs_alloc * sc->aac_max_fib_size,
aac_map_command_helper, &fibphys, 0);
/* initialise constant fields in the command structure */
bzero(sc->aac_fibs, AAC_FIB_COUNT * sizeof(struct aac_fib));
for (i = 0; i < AAC_FIB_COUNT; i++) {
cm = &sc->aac_command[i];
bzero(fm->aac_fibs, sc->aac_max_fibs_alloc * sc->aac_max_fib_size);
for (i = 0; i < sc->aac_max_fibs_alloc; i++) {
cm = sc->aac_commands + sc->total_fibs;
fm->aac_commands = cm;
cm->cm_sc = sc;
cm->cm_fib = sc->aac_fibs + i;
cm->cm_fibphys = sc->aac_fibphys + (i * sizeof(struct aac_fib));
cm->cm_fib = (struct aac_fib *)
((u_int8_t *)fm->aac_fibs + i*sc->aac_max_fib_size);
cm->cm_fibphys = fibphys + i*sc->aac_max_fib_size;
cm->cm_index = sc->total_fibs;
if (!bus_dmamap_create(sc->aac_buffer_dmat, 0, &cm->cm_datamap))
aac_release_command(cm);
if ((error = bus_dmamap_create(sc->aac_buffer_dmat, 0,
&cm->cm_datamap)) != 0)
break;
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
aac_release_command(cm);
sc->total_fibs++;
AAC_LOCK_RELEASE(&sc->aac_io_lock);
}
return(0);
if (i > 0) {
AAC_LOCK_ACQUIRE(&sc->aac_io_lock);
TAILQ_INSERT_TAIL(&sc->aac_fibmap_tqh, fm, fm_link);
debug(1, "total_fibs= %d\n", sc->total_fibs);
AAC_LOCK_RELEASE(&sc->aac_io_lock);
return (0);
}
bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap);
bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap);
kfree(fm, M_AACBUF);
return (ENOMEM);
}
/*
......
static void
aac_free_commands(struct aac_softc *sc)
{
struct aac_fibmap *fm;
struct aac_command *cm;
int i;
debug_called(1);
for (i = 0; i < AAC_FIB_COUNT; i++)
bus_dmamap_destroy(sc->aac_buffer_dmat,
sc->aac_command[i].cm_datamap);
while ((fm = TAILQ_FIRST(&sc->aac_fibmap_tqh)) != NULL) {
bus_dmamap_unload(sc->aac_fib_dmat, sc->aac_fibmap);
bus_dmamem_free(sc->aac_fib_dmat, sc->aac_fibs, sc->aac_fibmap);
TAILQ_REMOVE(&sc->aac_fibmap_tqh, fm, fm_link);
/*
* We check against total_fibs to handle partially
* allocated blocks.
*/
for (i = 0; i < sc->aac_max_fibs_alloc && sc->total_fibs--; i++) {
cm = fm->aac_commands + i;
bus_dmamap_destroy(sc->aac_buffer_dmat, cm->cm_datamap);
}
bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap);
bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap);
kfree(fm, M_AACBUF);
}
}
/*
......
static void
aac_map_command_sg(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
struct aac_softc *sc;
struct aac_command *cm;
struct aac_fib *fib;
struct aac_sg_table *sg;
int i;
debug_called(3);
cm = (struct aac_command *)arg;
sc = cm->cm_sc;
fib = cm->cm_fib;
/* find the s/g table */
sg = cm->cm_sgtable;
/* copy into the FIB */
if (sg != NULL) {
sg->SgCount = nseg;
for (i = 0; i < nseg; i++) {
sg->SgEntry[i].SgAddress = segs[i].ds_addr;
sg->SgEntry[i].SgByteCount = segs[i].ds_len;
if (cm->cm_sgtable != NULL) {
if (fib->Header.Command == RawIo) {
struct aac_sg_tableraw *sg;
sg = (struct aac_sg_tableraw *)cm->cm_sgtable;
sg->SgCount = nseg;
for (i = 0; i < nseg; i++) {
sg->SgEntryRaw[i].SgAddress = segs[i].ds_addr;
sg->SgEntryRaw[i].SgByteCount = segs[i].ds_len;
sg->SgEntryRaw[i].Next = 0;
sg->SgEntryRaw[i].Prev = 0;
sg->SgEntryRaw[i].Flags = 0;
}
/* update the FIB size for the s/g count */
fib->Header.Size += nseg*sizeof(struct aac_sg_entryraw);
} else if ((cm->cm_sc->flags & AAC_FLAGS_SG_64BIT) == 0) {
struct aac_sg_table *sg;
sg = cm->cm_sgtable;
sg->SgCount = nseg;
for (i = 0; i < nseg; i++) {
sg->SgEntry[i].SgAddress = segs[i].ds_addr;
sg->SgEntry[i].SgByteCount = segs[i].ds_len;
}
/* update the FIB size for the s/g count */
fib->Header.Size += nseg*sizeof(struct aac_sg_entry);
} else {
struct aac_sg_table64 *sg;
sg = (struct aac_sg_table64 *)cm->cm_sgtable;
sg->SgCount = nseg;
for (i = 0; i < nseg; i++) {
sg->SgEntry64[i].SgAddress = segs[i].ds_addr;
sg->SgEntry64[i].SgByteCount = segs[i].ds_len;
}
/* update the FIB size for the s/g count */
fib->Header.Size += nseg*sizeof(struct aac_sg_entry64);
}
/* update the FIB size for the s/g count */
fib->Header.Size += nseg * sizeof(struct aac_sg_entry);
}
}
/*
* Map a command into controller-visible space.
*/
static void
aac_map_command(struct aac_command *cm)
{
struct aac_softc *sc;
debug_called(2);
sc = cm->cm_sc;
/* don't map more than once */
if (cm->cm_flags & AAC_CMD_MAPPED)
return;
/* Fix up the address values in the FIB. Use the command array index
* instead of a pointer since these fields are only 32 bits. Shift
* the SenderFibAddress over to make room for the fast response bit
* and for the AIF bit
*/
cm->cm_fib->Header.SenderFibAddress = (cm->cm_index << 2);
cm->cm_fib->Header.ReceiverFibAddress = (u_int32_t)cm->cm_fibphys;
if (cm->cm_datalen != 0) {
bus_dmamap_load(sc->aac_buffer_dmat, cm->cm_datamap,
cm->cm_data, cm->cm_datalen,
aac_map_command_sg, cm, 0);
/* save a pointer to the command for speedy reverse-lookup */
cm->cm_fib->Header.SenderData = cm->cm_index;
if (cm->cm_flags & AAC_CMD_DATAIN)
bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
BUS_DMASYNC_PREREAD);
if (cm->cm_flags & AAC_CMD_DATAOUT)
bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
BUS_DMASYNC_PREWRITE);
cm->cm_flags |= AAC_CMD_MAPPED;
if (cm->cm_flags & AAC_CMD_DATAIN)
bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
BUS_DMASYNC_PREREAD);
if (cm->cm_flags & AAC_CMD_DATAOUT)
bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap,
BUS_DMASYNC_PREWRITE);
if (sc->flags & AAC_FLAGS_NEW_COMM) {
int count = 10000000L;
while (AAC_SEND_COMMAND(sc, cm) != 0) {
if (--count == 0) {
aac_unmap_command(cm);
sc->flags |= AAC_QUEUE_FRZN;
aac_requeue_ready(cm);
}
DELAY(5); /* wait 5 usec. */
}
} else {
/* Put the FIB on the outbound queue */
if (aac_enqueue_fib(sc, cm->cm_queue, cm) == EBUSY) {
aac_unmap_command(cm);
sc->flags |= AAC_QUEUE_FRZN;
aac_requeue_ready(cm);
}
}
cm->cm_flags |= AAC_CMD_MAPPED;
}
/*
......
static int
aac_check_firmware(struct aac_softc *sc)
{
u_int32_t major, minor, options;
u_int32_t major, minor, options = 0, atu_size = 0;
int status;
debug_called(1);
......
/*
* Retrieve the capabilities/supported options word so we know what
* work-arounds to enable.
* work-arounds to enable. Some firmware revs don't support this
* command.
*/
if (aac_sync_command(sc, AAC_MONKER_GETINFO, 0, 0, 0, 0, NULL)) {
device_printf(sc->aac_dev, "RequestAdapterInfo failed\n");
return (EIO);
if (aac_sync_command(sc, AAC_MONKER_GETINFO, 0, 0, 0, 0, &status)) {
if (status != AAC_SRB_STS_INVALID_REQUEST) {
device_printf(sc->aac_dev,
"RequestAdapterInfo failed\n");
return (EIO);
}
} else {
options = AAC_GET_MAILBOX(sc, 1);
atu_size = AAC_GET_MAILBOX(sc, 2);
sc->supported_options = options;
if ((options & AAC_SUPPORTED_4GB_WINDOW) != 0 &&
(sc->flags & AAC_FLAGS_NO4GB) == 0)
sc->flags |= AAC_FLAGS_4GB_WINDOW;
if (options & AAC_SUPPORTED_NONDASD)
sc->flags |= AAC_FLAGS_ENABLE_CAM;
if ((options & AAC_SUPPORTED_SGMAP_HOST64) != 0
&& (sizeof(bus_addr_t) > 4)) {
device_printf(sc->aac_dev,
"Enabling 64-bit address support\n");
sc->flags |= AAC_FLAGS_SG_64BIT;
}
if ((options & AAC_SUPPORTED_NEW_COMM)
&& sc->aac_if.aif_send_command)
sc->flags |= AAC_FLAGS_NEW_COMM;
if (options & AAC_SUPPORTED_64BIT_ARRAYSIZE)
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)