-/*
+/*-
* Generic driver for the BusLogic MultiMaster SCSI host adapters
* Product specific probe and attach routines can be found in:
* sys/dev/buslogic/bt_pci.c BT-946, BT-948, BT-956, BT-958 cards
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/buslogic/bt.c,v 1.25.2.1 2000/08/02 22:32:26 peter Exp $
+ * $FreeBSD: src/sys/dev/buslogic/bt.c,v 1.54 2012/11/17 01:51:40 svnexp Exp $
*/
/*
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
#include <sys/rman.h>
-#include <sys/thread2.h>
-#include <machine/clock.h>
-
#include <bus/cam/cam.h>
#include <bus/cam/cam_ccb.h>
#include <bus/cam/cam_sim.h>
#include <vm/vm.h>
#include <vm/pmap.h>
-#include "btreg.h"
+#include <dev/disk/buslogic/btreg.h>
/* MailBox Management functions */
static __inline void btnextinbox(struct bt_softc *bt);
btccbptov(struct bt_softc *bt, u_int32_t ccb_addr)
{
return (bt->bt_ccb_array +
- ((struct bt_ccb*)(uintptr_t)ccb_addr-(struct bt_ccb*)(uintptr_t)bt->bt_ccb_physbase));
+ ((struct bt_ccb*)(uintptr_t)ccb_addr - (struct bt_ccb*)(uintptr_t)bt->bt_ccb_physbase));
}
static __inline u_int32_t
static bus_dmamap_callback_t btexecuteccb;
static void btdone(struct bt_softc *bt, struct bt_ccb *bccb,
bt_mbi_comp_code_t comp_code);
+static void bt_intr_locked(struct bt_softc *bt);
/* Host adapter command functions */
static int btreset(struct bt_softc* bt, int hard_reset);
static void btpoll(struct cam_sim *sim);
/* Our timeout handler */
-timeout_t bttimeout;
+static void bttimeout(void *arg);
-u_long bt_unit = 0;
/* Exported functions */
void
LIST_INIT(&bt->pending_ccbs);
SLIST_INIT(&bt->sg_maps);
bt->dev = dev;
- bt->unit = device_get_unit(dev);
bt->port = port;
bt->irq = irq;
bt->drq = drq;
- bt->tag = rman_get_bustag(port);
- bt->bsh = rman_get_bushandle(port);
+ lockinit(&bt->lock, "bt", 0, LK_CANRECURSE);
}
void
}
case 7:
bus_dmamap_unload(bt->ccb_dmat, bt->ccb_dmamap);
+ /* FALLTHROUGH */
case 6:
bus_dmamem_free(bt->ccb_dmat, bt->bt_ccb_array,
bt->ccb_dmamap);
bus_dmamap_destroy(bt->ccb_dmat, bt->ccb_dmamap);
+ /* FALLTHROUGH */
case 5:
bus_dma_tag_destroy(bt->ccb_dmat);
+ /* FALLTHROUGH */
case 4:
bus_dmamap_unload(bt->mailbox_dmat, bt->mailbox_dmamap);
+ /* FALLTHROUGH */
case 3:
bus_dmamem_free(bt->mailbox_dmat, bt->in_boxes,
bt->mailbox_dmamap);
bus_dmamap_destroy(bt->mailbox_dmat, bt->mailbox_dmamap);
+ /* FALLTHROUGH */
case 2:
bus_dma_tag_destroy(bt->buffer_dmat);
+ /* FALLTHROUGH */
case 1:
bus_dma_tag_destroy(bt->mailbox_dmat);
+ /* FALLTHROUGH */
case 0:
break;
}
+ lockuninit(&bt->lock);
}
/*
* adapter and attempt to fetch the extended setup
* information. This should filter out all 1542 cards.
*/
+ lockmgr(&bt->lock, LK_EXCLUSIVE);
if ((error = btreset(bt, /*hard_reset*/TRUE)) != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
if (bootverbose)
device_printf(dev, "Failed Reset\n");
return (ENXIO);
error = bt_cmd(bt, BOP_INQUIRE_ESETUP_INFO, ¶m, /*parmlen*/1,
(u_int8_t*)&esetup_info, sizeof(esetup_info),
DEFAULT_CMD_TIMEOUT);
+ lockmgr(&bt->lock, LK_RELEASE);
if (error != 0) {
return (ENXIO);
}
u_int8_t length_param;
/* First record the firmware version */
+ lockmgr(&bt->lock, LK_EXCLUSIVE);
error = bt_cmd(bt, BOP_INQUIRE_BOARD_ID, NULL, /*parmlen*/0,
(u_int8_t*)&board_id, sizeof(board_id),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
device_printf(dev, "bt_fetch_adapter_info - Failed Get Board Info\n");
return (error);
}
(u_int8_t*)&bt->firmware_ver[3], 1,
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
device_printf(dev,
"bt_fetch_adapter_info - Failed Get "
"Firmware 3rd Digit\n");
(u_int8_t*)&bt->firmware_ver[4], 1,
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
device_printf(dev,
"bt_fetch_adapter_info - Failed Get "
"Firmware 4th Digit\n");
(u_int8_t*)&esetup_info, sizeof(esetup_info),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
return (error);
}
(u_int8_t*)&model_data, sizeof(model_data),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
device_printf(dev,
"bt_fetch_adapter_info - Failed Inquire "
"Model Number\n");
sizeof(auto_scsi_data), DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
device_printf(dev,
"bt_fetch_adapter_info - Failed "
"Get Auto SCSI Info\n");
sizeof(setup_info), DEFAULT_CMD_TIMEOUT);
if (error != 0) {
+ lockmgr(&bt->lock, LK_RELEASE);
device_printf(dev,
"bt_fetch_adapter_info - Failed "
"Get Setup Info\n");
error = bt_cmd(bt, BOP_INQUIRE_CONFIG, NULL, /*parmlen*/0,
(u_int8_t*)&config_data, sizeof(config_data),
DEFAULT_CMD_TIMEOUT);
+ lockmgr(&bt->lock, LK_RELEASE);
if (error != 0) {
device_printf(dev,
"bt_fetch_adapter_info - Failed Get Config\n");
*/
/* DMA tag for mapping buffers into device visible space. */
- if (bus_dma_tag_create(bt->parent_dmat, /*alignment*/1, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/MAXBSIZE, /*nsegments*/BT_NSEG,
- /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
- /*flags*/BUS_DMA_ALLOCNOW,
- &bt->buffer_dmat) != 0) {
+ if (bus_dma_tag_create( /* parent */ bt->parent_dmat,
+ /* alignment */ 1,
+ /* boundary */ 0,
+ /* lowaddr */ BUS_SPACE_MAXADDR,
+ /* highaddr */ BUS_SPACE_MAXADDR,
+ /* filter */ NULL,
+ /* filterarg */ NULL,
+ /* maxsize */ MAXBSIZE,
+ /* nsegments */ BT_NSEG,
+ /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
+ /* flags */ BUS_DMA_ALLOCNOW,
+ &bt->buffer_dmat) != 0) {
goto error_exit;
}
bt->init_level++;
/* DMA tag for our mailboxes */
- if (bus_dma_tag_create(bt->parent_dmat, /*alignment*/1, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- bt->num_boxes * (sizeof(bt_mbox_in_t)
- + sizeof(bt_mbox_out_t)),
- /*nsegments*/1,
- /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
- /*flags*/0, &bt->mailbox_dmat) != 0) {
+ if (bus_dma_tag_create( /* parent */ bt->parent_dmat,
+ /* alignment */ 1,
+ /* boundary */ 0,
+ /* lowaddr */ BUS_SPACE_MAXADDR,
+ /* highaddr */ BUS_SPACE_MAXADDR,
+ /* filter */ NULL,
+ /* filterarg */ NULL,
+ /* maxsize */ bt->num_boxes *
+ (sizeof(bt_mbox_in_t) +
+ sizeof(bt_mbox_out_t)),
+ /* nsegments */ 1,
+ /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
+ /* flags */ 0,
+ &bt->mailbox_dmat) != 0) {
goto error_exit;
}
bt->init_level++;
/* Allocation for our mailboxes */
- if (bus_dmamem_alloc(bt->mailbox_dmat, (void *)&bt->out_boxes,
+ if (bus_dmamem_alloc(bt->mailbox_dmat, (void **)&bt->out_boxes,
BUS_DMA_NOWAIT, &bt->mailbox_dmamap) != 0) {
goto error_exit;
}
bt->in_boxes = (bt_mbox_in_t *)&bt->out_boxes[bt->num_boxes];
+ lockmgr(&bt->lock, LK_EXCLUSIVE);
btinitmboxes(bt);
+ lockmgr(&bt->lock, LK_RELEASE);
/* DMA tag for our ccb structures */
- if (bus_dma_tag_create(bt->parent_dmat, /*alignment*/1, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- bt->max_ccbs * sizeof(struct bt_ccb),
- /*nsegments*/1,
- /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
- /*flags*/0, &bt->ccb_dmat) != 0) {
+ if (bus_dma_tag_create( /* parent */ bt->parent_dmat,
+ /* alignment */ 1,
+ /* boundary */ 0,
+ /* lowaddr */ BUS_SPACE_MAXADDR,
+ /* highaddr */ BUS_SPACE_MAXADDR,
+ /* filter */ NULL,
+ /* filterarg */ NULL,
+ /* maxsize */ bt->max_ccbs *
+ sizeof(struct bt_ccb),
+ /* nsegments */ 1,
+ /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
+ /* flags */ 0,
+ &bt->ccb_dmat) != 0) {
goto error_exit;
}
bt->init_level++;
/* Allocation for our ccbs */
- if (bus_dmamem_alloc(bt->ccb_dmat, (void *)&bt->bt_ccb_array,
+ if (bus_dmamem_alloc(bt->ccb_dmat, (void **)&bt->bt_ccb_array,
BUS_DMA_NOWAIT, &bt->ccb_dmamap) != 0) {
goto error_exit;
}
bt->init_level++;
/* DMA tag for our S/G structures. We allocate in page sized chunks */
- if (bus_dma_tag_create(bt->parent_dmat, /*alignment*/1, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- PAGE_SIZE, /*nsegments*/1,
- /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
- /*flags*/0, &bt->sg_dmat) != 0) {
+ if (bus_dma_tag_create( /* parent */ bt->parent_dmat,
+ /* alignment */ 1,
+ /* boundary */ 0,
+ /* lowaddr */ BUS_SPACE_MAXADDR,
+ /* highaddr */ BUS_SPACE_MAXADDR,
+ /* filter */ NULL,
+ /* filterarg */ NULL,
+ /* maxsize */ PAGE_SIZE,
+ /* nsegments */ 1,
+ /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT,
+ /* flags */ 0,
+ &bt->sg_dmat) != 0) {
goto error_exit;
}
}
/*
- * Note that we are going and return (to probe)
+ * Note that we are going and return (to attach)
*/
return 0;
/*
* Construct our SIM entry
*/
- bt->sim = cam_sim_alloc(btaction, btpoll, "bt", bt, bt->unit,
- &sim_mplock, 2, tagged_dev_openings, devq);
+ bt->sim = cam_sim_alloc(btaction, btpoll, "bt", bt,
+ device_get_unit(bt->dev), &bt->lock, 2, tagged_dev_openings, devq);
cam_simq_release(devq);
if (bt->sim == NULL)
return (ENOMEM);
-
+
+ lockmgr(&bt->lock, LK_EXCLUSIVE);
if (xpt_bus_register(bt->sim, 0) != CAM_SUCCESS) {
cam_sim_free(bt->sim);
+ lockmgr(&bt->lock, LK_RELEASE);
return (ENXIO);
}
CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
xpt_bus_deregister(cam_sim_path(bt->sim));
cam_sim_free(bt->sim);
+ lockmgr(&bt->lock, LK_RELEASE);
return (ENXIO);
}
+ lockmgr(&bt->lock, LK_RELEASE);
/*
* Setup interrupt.
*/
- error = bus_setup_intr(dev, bt->irq, 0,
- bt_intr, bt, &bt->ih, NULL);
+ error = bus_setup_intr(dev, bt->irq,
+ INTR_MPSAFE, bt_intr, bt, &bt->ih, NULL);
if (error) {
device_printf(dev, "bus_setup_intr() failed: %d\n", error);
return (error);
sg_map = kmalloc(sizeof(*sg_map), M_DEVBUF, M_WAITOK);
/* Allocate S/G space for the next batch of CCBS */
- if (bus_dmamem_alloc(bt->sg_dmat, (void *)&sg_map->sg_vaddr,
+ if (bus_dmamem_alloc(bt->sg_dmat, (void **)&sg_map->sg_vaddr,
BUS_DMA_NOWAIT, &sg_map->sg_dmamap) != 0) {
kfree(sg_map, M_DEVBUF);
goto error_exit;
next_ccb->sg_list = segs;
next_ccb->sg_list_phys = physaddr;
next_ccb->flags = BCCB_FREE;
+ callout_init_mp(&next_ccb->timer);
error = bus_dmamap_create(bt->buffer_dmat, /*flags*/0,
&next_ccb->dmamap);
if (error != 0)
static __inline void
btfreeccb(struct bt_softc *bt, struct bt_ccb *bccb)
{
- crit_enter();
+ if (!dumping)
+ KKASSERT(lockowned(&bt->lock));
if ((bccb->flags & BCCB_ACTIVE) != 0)
LIST_REMOVE(&bccb->ccb->ccb_h, sim_links.le);
if (bt->resource_shortage != 0
bccb->flags = BCCB_FREE;
SLIST_INSERT_HEAD(&bt->free_bt_ccbs, bccb, links);
bt->active_ccbs--;
- crit_exit();
}
static __inline struct bt_ccb*
{
struct bt_ccb* bccb;
- crit_enter();
+ if (!dumping)
+ KKASSERT(lockowned(&bt->lock));
if ((bccb = SLIST_FIRST(&bt->free_bt_ccbs)) != NULL) {
SLIST_REMOVE_HEAD(&bt->free_bt_ccbs, links);
bt->active_ccbs++;
bt->active_ccbs++;
}
}
- crit_exit();
return (bccb);
}
CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("btaction\n"));
bt = (struct bt_softc *)cam_sim_softc(sim);
-
+ KKASSERT(lockowned(&bt->lock));
+
switch (ccb->ccb_h.func_code) {
/* Common cases first */
case XPT_SCSI_IO: /* Execute the requested I/O operation */
* get a bccb to use.
*/
if ((bccb = btgetccb(bt)) == NULL) {
- crit_enter();
bt->resource_shortage = TRUE;
- crit_exit();
xpt_freeze_simq(bt->sim, /*count*/1);
ccb->ccb_h.status = CAM_REQUEUE_REQ;
xpt_done(ccb);
if ((ccbh->flags & CAM_DATA_PHYS)==0) {
int error;
- crit_enter();
error = bus_dmamap_load(
bt->buffer_dmat,
bccb->dmamap,
csio->ccb_h.status |=
CAM_RELEASE_SIMQ;
}
- crit_exit();
} else {
struct bus_dma_segment seg;
bccb->hccb.data_addr = 0;
}
- crit_enter();
-
/*
* Last time we need to check if this CCB needs to
* be aborted.
bus_dmamap_unload(bt->buffer_dmat, bccb->dmamap);
btfreeccb(bt, bccb);
xpt_done(ccb);
- crit_exit();
return;
}
ccb->ccb_h.status |= CAM_SIM_QUEUED;
LIST_INSERT_HEAD(&bt->pending_ccbs, &ccb->ccb_h, sim_links.le);
- callout_reset(&ccb->ccb_h.timeout_ch, (ccb->ccb_h.timeout * hz) / 1000,
+ callout_reset(&bccb->timer, (ccb->ccb_h.timeout * hz) / 1000,
bttimeout, bccb);
/* Tell the adapter about this command */
"Encountered busy mailbox with %d out of %d "
"commands active!!!\n", bt->active_ccbs,
bt->max_ccbs);
- callout_stop(&ccb->ccb_h.timeout_ch);
+ callout_stop(&bccb->timer);
if (nseg != 0)
bus_dmamap_unload(bt->buffer_dmat, bccb->dmamap);
btfreeccb(bt, bccb);
xpt_freeze_simq(bt->sim, /*count*/1);
ccb->ccb_h.status = CAM_REQUEUE_REQ;
xpt_done(ccb);
- crit_exit();
return;
}
bt->cur_outbox->action_code = BMBO_START;
bt_outb(bt, COMMAND_REG, BOP_START_MBOX);
btnextoutbox(bt);
- crit_exit();
}
void
bt_intr(void *arg)
{
struct bt_softc *bt;
+
+ bt = arg;
+ lockmgr(&bt->lock, LK_EXCLUSIVE);
+ bt_intr_locked(bt);
+ lockmgr(&bt->lock, LK_RELEASE);
+}
+
+void
+bt_intr_locked(struct bt_softc *bt)
+{
u_int intstat;
- bt = (struct bt_softc *)arg;
while (((intstat = bt_inb(bt, INTSTAT_REG)) & INTR_PENDING) != 0) {
if ((intstat & CMD_COMPLETE) != 0) {
ccb_h = LIST_NEXT(ccb_h, sim_links.le);
btdone(bt, pending_bccb, BMBI_ERROR);
} else {
- callout_reset(&ccb_h->timeout_ch,
+ callout_reset(&pending_bccb->timer,
(ccb_h->timeout * hz) / 1000,
bttimeout, pending_bccb);
ccb_h = LIST_NEXT(ccb_h, sim_links.le);
return;
}
- callout_stop(&ccb->ccb_h.timeout_ch);
+ callout_stop(&bccb->timer);
switch (comp_code) {
case BMBI_FREE:
}
if (timeout == 0) {
if (bootverbose)
- kprintf("%s: btreset - Diagnostic Active failed to "
- "assert. status = 0x%x\n", bt_name(bt), status);
+ device_printf(bt->dev,
+ "btreset - Diagnostic Active failed to "
+ "assert. status = 0x%x\n", status);
return (ETIMEDOUT);
}
DELAY(100);
}
if (timeout == 0) {
- kprintf("%s: btreset - Host adapter failed to come ready. "
- "status = 0x%x\n", bt_name(bt), status);
+ device_printf(bt->dev,
+ "btreset - Host adapter failed to come ready. "
+ "status = 0x%x\n", status);
return (ETIMEDOUT);
}
/* If the diagnostics failed, tell the user */
if ((status & DIAG_FAIL) != 0
|| (status & HA_READY) == 0) {
- kprintf("%s: btreset - Adapter failed diagnostics\n",
- bt_name(bt));
+ device_printf(bt->dev,
+ "btreset - Adapter failed diagnostics\n");
if ((status & DATAIN_REG_READY) != 0)
- kprintf("%s: btreset - Host Adapter Error code = 0x%x\n",
- bt_name(bt), bt_inb(bt, DATAIN_REG));
+ device_printf(bt->dev,
+ "btreset - Host Adapter Error code = 0x%x\n",
+ bt_inb(bt, DATAIN_REG));
return (ENXIO);
}
DELAY(100);
}
if (timeout == 0) {
- kprintf("%s: bt_cmd: Timeout waiting for adapter ready, "
- "status = 0x%x\n", bt_name(bt), status);
+ device_printf(bt->dev,
+ "bt_cmd: Timeout waiting for adapter ready, "
+ "status = 0x%x\n", status);
return (ETIMEDOUT);
}
bt_outb(bt, COMMAND_REG, opcode);
/*
- * Wait for up to 1sec for each byte of the the
+ * Wait for up to 1sec for each byte of the
* parameter list sent to be sent.
*/
timeout = 10000;
while (param_len && --timeout) {
DELAY(100);
- crit_enter();
status = bt_inb(bt, STATUS_REG);
intstat = bt_inb(bt, INTSTAT_REG);
- crit_exit();
if ((intstat & (INTR_PENDING|CMD_COMPLETE))
== (INTR_PENDING|CMD_COMPLETE)) {
}
}
if (timeout == 0) {
- kprintf("%s: bt_cmd: Timeout sending parameters, "
- "status = 0x%x\n", bt_name(bt), status);
+ device_printf(bt->dev, "bt_cmd: Timeout sending parameters, "
+ "status = 0x%x\n", status);
cmd_complete = 1;
saved_status = status;
error = ETIMEDOUT;
* Wait for the command to complete.
*/
while (cmd_complete == 0 && --cmd_timeout) {
-
- crit_enter();
status = bt_inb(bt, STATUS_REG);
intstat = bt_inb(bt, INTSTAT_REG);
/*
*/
if ((intstat & (INTR_PENDING|IMB_LOADED))
== (INTR_PENDING|IMB_LOADED))
- bt_intr(bt);
- crit_exit();
+ bt_intr_locked(bt);
if (bt->command_cmp != 0) {
/*
if (reply_len < reply_buf_size) {
*reply_data++ = data;
} else {
- kprintf("%s: bt_cmd - Discarded reply data byte "
- "for opcode 0x%x\n", bt_name(bt),
- opcode);
+ device_printf(bt->dev,
+ "bt_cmd - Discarded reply data byte "
+ "for opcode 0x%x\n", opcode);
}
/*
* Reset timeout to ensure at least a second
DELAY(100);
}
if (cmd_timeout == 0) {
- kprintf("%s: bt_cmd: Timeout waiting for command (%x) "
- "to complete.\n%s: status = 0x%x, intstat = 0x%x, "
- "rlen %d\n", bt_name(bt), opcode,
- bt_name(bt), status, intstat, reply_len);
+ device_printf(bt->dev,
+ "bt_cmd: Timeout waiting for command (%x) "
+ "to complete.\n", opcode);
+ device_printf(bt->dev, "status = 0x%x, intstat = 0x%x, "
+ "rlen %d\n", status, intstat, reply_len);
error = (ETIMEDOUT);
}
/*
- * Clear any pending interrupts. Block interrupts so our
- * interrupt handler is not re-entered.
+ * Clear any pending interrupts.
*/
- crit_enter();
- bt_intr(bt);
- crit_exit();
+ bt_intr_locked(bt);
if (error != 0)
return (error);
* reset above), perform a soft reset.
*/
if (bootverbose)
- kprintf("%s: Invalid Command 0x%x\n", bt_name(bt),
+ device_printf(bt->dev, "Invalid Command 0x%x\n",
opcode);
DELAY(1000);
status = bt_inb(bt, STATUS_REG);
kprintf("btinitmboxes: Unable to enable strict RR\n");
error = 0;
} else if (bootverbose) {
- kprintf("%s: Using Strict Round Robin Mailbox Mode\n",
- bt_name(bt));
+ device_printf(bt->dev,
+ "Using Strict Round Robin Mailbox Mode\n");
}
}
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- kprintf("%s: btfetchtransinfo - Inquire Setup Info Failed %x\n",
- bt_name(bt), error);
+ device_printf(bt->dev,
+ "btfetchtransinfo - Inquire Setup Info Failed %x\n",
+ error);
return;
}
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
- kprintf("%s: btfetchtransinfo - Inquire Sync "
- "Info Failed 0x%x\n", bt_name(bt), error);
+ device_printf(bt->dev,
+ "btfetchtransinfo - Inquire Sync "
+ "Info Failed 0x%x\n", error);
return;
}
sync_period = sync_info.sync_rate[target] * 100;
static void
btpoll(struct cam_sim *sim)
{
- bt_intr(cam_sim_softc(sim));
+ bt_intr_locked(cam_sim_softc(sim));
}
void
bccb = (struct bt_ccb *)arg;
ccb = bccb->ccb;
bt = (struct bt_softc *)ccb->ccb_h.ccb_bt_ptr;
+ lockmgr(&bt->lock, LK_EXCLUSIVE);
xpt_print_path(ccb->ccb_h.path);
kprintf("CCB %p - timed out\n", (void *)bccb);
- crit_enter();
-
if ((bccb->flags & BCCB_ACTIVE) == 0) {
xpt_print_path(ccb->ccb_h.path);
kprintf("CCB %p - timed out CCB already completed\n",
(void *)bccb);
- crit_exit();
+ lockmgr(&bt->lock, LK_RELEASE);
return;
}
struct bt_ccb *pending_bccb;
pending_bccb = (struct bt_ccb *)ccb_h->ccb_bccb_ptr;
- callout_stop(&ccb_h->timeout_ch);
+ callout_stop(&pending_bccb->timer);
ccb_h = LIST_NEXT(ccb_h, sim_links.le);
}
}
*/
ccb->ccb_h.status = CAM_CMD_TIMEOUT;
btreset(bt, /*hardreset*/TRUE);
- kprintf("%s: No longer in timeout\n", bt_name(bt));
+ device_printf(bt->dev, "No longer in timeout\n");
} else {
/*
* Send a Bus Device Reset message:
* later which will attempt a bus reset.
*/
bccb->flags |= BCCB_DEVICE_RESET;
- callout_reset(&ccb->ccb_h.timeout_ch, 2 * hz, bttimeout, bccb);
+ callout_reset(&bccb->timer, 2 * hz, bttimeout, bccb);
bt->recovery_bccb->hccb.opcode = INITIATOR_BUS_DEV_RESET;
bt_outb(bt, COMMAND_REG, BOP_START_MBOX);
btnextoutbox(bt);
}
-
- crit_exit();
+ lockmgr(&bt->lock, LK_RELEASE);
}
+MODULE_VERSION(bt, 1);
+MODULE_DEPEND(bt, cam, 1, 1, 1);