2 * CAM SCSI interface for the the Advanced Systems Inc.
3 * Second Generation SCSI controllers.
5 * Product specific probe and attach routines can be found in:
7 * adw_pci.c ABP[3]940UW, ABP950UW, ABP3940U2W
9 * Copyright (c) 1998, 1999, 2000 Justin Gibbs.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * $FreeBSD: src/sys/dev/advansys/adwcam.c,v 1.7.2.2 2001/03/05 13:08:55 obrien Exp $
34 * $DragonFly: src/sys/dev/disk/advansys/adwcam.c,v 1.3 2003/07/27 01:49:49 hmp Exp $
38 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
40 * Copyright (c) 1995-1998 Advanced System Products, Inc.
41 * All Rights Reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that redistributions of source
45 * code retain the above copyright notice and this comment without
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/kernel.h>
52 #include <sys/malloc.h>
55 #include <machine/bus_pio.h>
56 #include <machine/bus_memio.h>
57 #include <machine/bus.h>
58 #include <machine/clock.h>
59 #include <machine/resource.h>
64 #include <cam/cam_ccb.h>
65 #include <cam/cam_sim.h>
66 #include <cam/cam_xpt_sim.h>
67 #include <cam/cam_debug.h>
69 #include <cam/scsi/scsi_message.h>
71 #include <dev/advansys/adwvar.h>
73 /* Definitions for our use of the SIM private CCB area */
74 #define ccb_acb_ptr spriv_ptr0
75 #define ccb_adw_ptr spriv_ptr1
79 static __inline cam_status adwccbstatus(union ccb*);
80 static __inline struct acb* adwgetacb(struct adw_softc *adw);
81 static __inline void adwfreeacb(struct adw_softc *adw,
84 static void adwmapmem(void *arg, bus_dma_segment_t *segs,
86 static struct sg_map_node*
87 adwallocsgmap(struct adw_softc *adw);
88 static int adwallocacbs(struct adw_softc *adw);
90 static void adwexecuteacb(void *arg, bus_dma_segment_t *dm_segs,
92 static void adw_action(struct cam_sim *sim, union ccb *ccb);
93 static void adw_poll(struct cam_sim *sim);
94 static void adw_async(void *callback_arg, u_int32_t code,
95 struct cam_path *path, void *arg);
96 static void adwprocesserror(struct adw_softc *adw, struct acb *acb);
97 static void adwtimeout(void *arg);
98 static void adw_handle_device_reset(struct adw_softc *adw,
100 static void adw_handle_bus_reset(struct adw_softc *adw,
103 static __inline cam_status
104 adwccbstatus(union ccb* ccb)
106 return (ccb->ccb_h.status & CAM_STATUS_MASK);
109 static __inline struct acb*
110 adwgetacb(struct adw_softc *adw)
116 if ((acb = SLIST_FIRST(&adw->free_acb_list)) != NULL) {
117 SLIST_REMOVE_HEAD(&adw->free_acb_list, links);
118 } else if (adw->num_acbs < adw->max_acbs) {
120 acb = SLIST_FIRST(&adw->free_acb_list);
122 printf("%s: Can't malloc ACB\n", adw_name(adw));
124 SLIST_REMOVE_HEAD(&adw->free_acb_list, links);
133 adwfreeacb(struct adw_softc *adw, struct acb *acb)
138 if ((acb->state & ACB_ACTIVE) != 0)
139 LIST_REMOVE(&acb->ccb->ccb_h, sim_links.le);
140 if ((acb->state & ACB_RELEASE_SIMQ) != 0)
141 acb->ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
142 else if ((adw->state & ADW_RESOURCE_SHORTAGE) != 0
143 && (acb->ccb->ccb_h.status & CAM_RELEASE_SIMQ) == 0) {
144 acb->ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
145 adw->state &= ~ADW_RESOURCE_SHORTAGE;
147 acb->state = ACB_FREE;
148 SLIST_INSERT_HEAD(&adw->free_acb_list, acb, links);
153 adwmapmem(void *arg, bus_dma_segment_t *segs, int nseg, int error)
155 bus_addr_t *busaddrp;
157 busaddrp = (bus_addr_t *)arg;
158 *busaddrp = segs->ds_addr;
161 static struct sg_map_node *
162 adwallocsgmap(struct adw_softc *adw)
164 struct sg_map_node *sg_map;
166 sg_map = malloc(sizeof(*sg_map), M_DEVBUF, M_NOWAIT);
171 /* Allocate S/G space for the next batch of ACBS */
172 if (bus_dmamem_alloc(adw->sg_dmat, (void **)&sg_map->sg_vaddr,
173 BUS_DMA_NOWAIT, &sg_map->sg_dmamap) != 0) {
174 free(sg_map, M_DEVBUF);
178 SLIST_INSERT_HEAD(&adw->sg_maps, sg_map, links);
180 bus_dmamap_load(adw->sg_dmat, sg_map->sg_dmamap, sg_map->sg_vaddr,
181 PAGE_SIZE, adwmapmem, &sg_map->sg_physaddr, /*flags*/0);
183 bzero(sg_map->sg_vaddr, PAGE_SIZE);
188 * Allocate another chunk of CCB's. Return count of entries added.
189 * Assumed to be called at splcam().
192 adwallocacbs(struct adw_softc *adw)
194 struct acb *next_acb;
195 struct sg_map_node *sg_map;
197 struct adw_sg_block *blocks;
201 next_acb = &adw->acbs[adw->num_acbs];
202 sg_map = adwallocsgmap(adw);
207 blocks = sg_map->sg_vaddr;
208 busaddr = sg_map->sg_physaddr;
210 newcount = (PAGE_SIZE / (ADW_SG_BLOCKCNT * sizeof(*blocks)));
211 for (i = 0; adw->num_acbs < adw->max_acbs && i < newcount; i++) {
214 error = bus_dmamap_create(adw->buffer_dmat, /*flags*/0,
218 next_acb->queue.scsi_req_baddr = acbvtob(adw, next_acb);
219 next_acb->queue.scsi_req_bo = acbvtobo(adw, next_acb);
220 next_acb->queue.sense_baddr =
221 acbvtob(adw, next_acb) + offsetof(struct acb, sense_data);
222 next_acb->sg_blocks = blocks;
223 next_acb->sg_busaddr = busaddr;
224 next_acb->state = ACB_FREE;
225 SLIST_INSERT_HEAD(&adw->free_acb_list, next_acb, links);
226 blocks += ADW_SG_BLOCKCNT;
227 busaddr += ADW_SG_BLOCKCNT * sizeof(*blocks);
235 adwexecuteacb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
239 struct adw_softc *adw;
242 acb = (struct acb *)arg;
244 adw = (struct adw_softc *)ccb->ccb_h.ccb_adw_ptr;
248 printf("%s: Unexepected error 0x%x returned from "
249 "bus_dmamap_load\n", adw_name(adw), error);
250 if (ccb->ccb_h.status == CAM_REQ_INPROG) {
251 xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
252 ccb->ccb_h.status = CAM_REQ_TOO_BIG|CAM_DEV_QFRZN;
254 adwfreeacb(adw, acb);
262 acb->queue.data_addr = dm_segs[0].ds_addr;
263 acb->queue.data_cnt = ccb->csio.dxfer_len;
265 struct adw_sg_block *sg_block;
266 struct adw_sg_elm *sg;
267 bus_addr_t sg_busaddr;
269 bus_dma_segment_t *end_seg;
271 end_seg = dm_segs + nseg;
273 sg_busaddr = acb->sg_busaddr;
275 /* Copy the segments into our SG list */
276 for (sg_block = acb->sg_blocks;; sg_block++) {
279 sg = sg_block->sg_list;
280 for (i = 0; i < ADW_NO_OF_SG_PER_BLOCK; i++) {
281 if (dm_segs >= end_seg)
284 sg->sg_addr = dm_segs->ds_addr;
285 sg->sg_count = dm_segs->ds_len;
289 sg_block->sg_cnt = i;
291 if (dm_segs == end_seg) {
292 sg_block->sg_busaddr_next = 0;
296 sizeof(struct adw_sg_block);
297 sg_block->sg_busaddr_next = sg_busaddr;
300 acb->queue.sg_real_addr = acb->sg_busaddr;
302 acb->queue.sg_real_addr = 0;
305 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
306 op = BUS_DMASYNC_PREREAD;
308 op = BUS_DMASYNC_PREWRITE;
310 bus_dmamap_sync(adw->buffer_dmat, acb->dmamap, op);
313 acb->queue.data_addr = 0;
314 acb->queue.data_cnt = 0;
315 acb->queue.sg_real_addr = 0;
321 * Last time we need to check if this CCB needs to
324 if (ccb->ccb_h.status != CAM_REQ_INPROG) {
326 bus_dmamap_unload(adw->buffer_dmat, acb->dmamap);
327 adwfreeacb(adw, acb);
333 acb->state |= ACB_ACTIVE;
334 ccb->ccb_h.status |= CAM_SIM_QUEUED;
335 LIST_INSERT_HEAD(&adw->pending_ccbs, &ccb->ccb_h, sim_links.le);
336 ccb->ccb_h.timeout_ch =
337 timeout(adwtimeout, (caddr_t)acb,
338 (ccb->ccb_h.timeout * hz) / 1000);
340 adw_send_acb(adw, acb, acbvtob(adw, acb));
346 adw_action(struct cam_sim *sim, union ccb *ccb)
348 struct adw_softc *adw;
350 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("adw_action\n"));
352 adw = (struct adw_softc *)cam_sim_softc(sim);
354 switch (ccb->ccb_h.func_code) {
355 /* Common cases first */
356 case XPT_SCSI_IO: /* Execute the requested I/O operation */
358 struct ccb_scsiio *csio;
359 struct ccb_hdr *ccbh;
365 /* Max supported CDB length is 12 bytes */
366 if (csio->cdb_len > 12) {
367 ccb->ccb_h.status = CAM_REQ_INVALID;
372 if ((acb = adwgetacb(adw)) == NULL) {
376 adw->state |= ADW_RESOURCE_SHORTAGE;
378 xpt_freeze_simq(sim, /*count*/1);
379 ccb->ccb_h.status = CAM_REQUEUE_REQ;
384 /* Link acb and ccb so we can find one from the other */
386 ccb->ccb_h.ccb_acb_ptr = acb;
387 ccb->ccb_h.ccb_adw_ptr = adw;
390 acb->queue.target_cmd = 0;
391 acb->queue.target_id = ccb->ccb_h.target_id;
392 acb->queue.target_lun = ccb->ccb_h.target_lun;
394 acb->queue.mflag = 0;
395 acb->queue.sense_len =
396 MIN(csio->sense_len, sizeof(acb->sense_data));
397 acb->queue.cdb_len = csio->cdb_len;
398 if ((ccb->ccb_h.flags & CAM_TAG_ACTION_VALID) != 0) {
399 switch (csio->tag_action) {
400 case MSG_SIMPLE_Q_TAG:
401 acb->queue.scsi_cntl = ADW_QSC_SIMPLE_Q_TAG;
403 case MSG_HEAD_OF_Q_TAG:
404 acb->queue.scsi_cntl = ADW_QSC_HEAD_OF_Q_TAG;
406 case MSG_ORDERED_Q_TAG:
407 acb->queue.scsi_cntl = ADW_QSC_ORDERED_Q_TAG;
410 acb->queue.scsi_cntl = ADW_QSC_NO_TAGMSG;
414 acb->queue.scsi_cntl = ADW_QSC_NO_TAGMSG;
416 if ((ccb->ccb_h.flags & CAM_DIS_DISCONNECT) != 0)
417 acb->queue.scsi_cntl |= ADW_QSC_NO_DISC;
419 acb->queue.done_status = 0;
420 acb->queue.scsi_status = 0;
421 acb->queue.host_status = 0;
422 acb->queue.sg_wk_ix = 0;
423 if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0) {
424 if ((ccb->ccb_h.flags & CAM_CDB_PHYS) == 0) {
425 bcopy(csio->cdb_io.cdb_ptr,
426 acb->queue.cdb, csio->cdb_len);
428 /* I guess I could map it in... */
429 ccb->ccb_h.status = CAM_REQ_INVALID;
430 adwfreeacb(adw, acb);
435 bcopy(csio->cdb_io.cdb_bytes,
436 acb->queue.cdb, csio->cdb_len);
440 * If we have any data to send with this command,
441 * map it into bus space.
443 if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
444 if ((ccbh->flags & CAM_SCATTER_VALID) == 0) {
446 * We've been given a pointer
447 * to a single buffer.
449 if ((ccbh->flags & CAM_DATA_PHYS) == 0) {
455 bus_dmamap_load(adw->buffer_dmat,
461 if (error == EINPROGRESS) {
463 * So as to maintain ordering,
464 * freeze the controller queue
465 * until our mapping is
468 xpt_freeze_simq(sim, 1);
469 acb->state |= CAM_RELEASE_SIMQ;
473 struct bus_dma_segment seg;
475 /* Pointer to physical buffer */
477 (bus_addr_t)csio->data_ptr;
478 seg.ds_len = csio->dxfer_len;
479 adwexecuteacb(acb, &seg, 1, 0);
482 struct bus_dma_segment *segs;
484 if ((ccbh->flags & CAM_DATA_PHYS) != 0)
485 panic("adw_action - Physical "
489 if ((ccbh->flags&CAM_SG_LIST_PHYS)==0)
490 panic("adw_action - Virtual "
494 /* Just use the segments provided */
495 segs = (struct bus_dma_segment *)csio->data_ptr;
496 adwexecuteacb(acb, segs, csio->sglist_cnt,
497 (csio->sglist_cnt < ADW_SGSIZE)
501 adwexecuteacb(acb, NULL, 0, 0);
505 case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */
507 adw_idle_cmd_status_t status;
509 status = adw_idle_cmd_send(adw, ADW_IDLE_CMD_DEVICE_RESET,
510 ccb->ccb_h.target_id);
511 if (status == ADW_IDLE_CMD_SUCCESS) {
512 ccb->ccb_h.status = CAM_REQ_CMP;
514 xpt_print_path(ccb->ccb_h.path);
515 printf("BDR Delivered\n");
518 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
522 case XPT_ABORT: /* Abort the specified CCB */
524 ccb->ccb_h.status = CAM_REQ_INVALID;
527 case XPT_SET_TRAN_SETTINGS:
529 struct ccb_trans_settings *cts;
534 target_mask = 0x01 << ccb->ccb_h.target_id;
537 if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) {
540 sdtrdone = adw_lram_read_16(adw, ADW_MC_SDTR_DONE);
541 if ((cts->valid & CCB_TRANS_DISC_VALID) != 0) {
545 adw_lram_read_16(adw, ADW_MC_DISC_ENABLE);
547 if ((cts->flags & CCB_TRANS_DISC_ENB) != 0)
548 discenb |= target_mask;
550 discenb &= ~target_mask;
552 adw_lram_write_16(adw, ADW_MC_DISC_ENABLE,
556 if ((cts->valid & CCB_TRANS_TQ_VALID) != 0) {
558 if ((cts->flags & CCB_TRANS_TAG_ENB) != 0)
559 adw->tagenb |= target_mask;
561 adw->tagenb &= ~target_mask;
564 if ((cts->valid & CCB_TRANS_BUS_WIDTH_VALID) != 0) {
570 adw_lram_read_16(adw, ADW_MC_WDTR_ABLE);
571 wdtrenb = wdtrenb_orig;
572 wdtrdone = adw_lram_read_16(adw,
574 switch (cts->bus_width) {
575 case MSG_EXT_WDTR_BUS_32_BIT:
576 case MSG_EXT_WDTR_BUS_16_BIT:
577 wdtrenb |= target_mask;
579 case MSG_EXT_WDTR_BUS_8_BIT:
581 wdtrenb &= ~target_mask;
584 if (wdtrenb != wdtrenb_orig) {
585 adw_lram_write_16(adw,
588 wdtrdone &= ~target_mask;
589 adw_lram_write_16(adw,
592 /* Wide negotiation forces async */
593 sdtrdone &= ~target_mask;
594 adw_lram_write_16(adw,
600 if (((cts->valid & CCB_TRANS_SYNC_RATE_VALID) != 0)
601 || ((cts->valid & CCB_TRANS_SYNC_OFFSET_VALID) != 0)) {
607 sdtr = adw_get_chip_sdtr(adw,
608 ccb->ccb_h.target_id);
610 sdtrable = adw_lram_read_16(adw,
612 sdtrable_orig = sdtrable;
615 & CCB_TRANS_SYNC_RATE_VALID) != 0) {
623 & CCB_TRANS_SYNC_OFFSET_VALID) != 0) {
624 if (cts->sync_offset == 0)
625 sdtr = ADW_MC_SDTR_ASYNC;
628 if (sdtr == ADW_MC_SDTR_ASYNC)
629 sdtrable &= ~target_mask;
631 sdtrable |= target_mask;
632 if (sdtr != sdtr_orig
633 || sdtrable != sdtrable_orig) {
634 adw_set_chip_sdtr(adw,
635 ccb->ccb_h.target_id,
637 sdtrdone &= ~target_mask;
638 adw_lram_write_16(adw, ADW_MC_SDTR_ABLE,
640 adw_lram_write_16(adw, ADW_MC_SDTR_DONE,
647 ccb->ccb_h.status = CAM_REQ_CMP;
651 case XPT_GET_TRAN_SETTINGS:
652 /* Get default/user set transfer settings for the target */
654 struct ccb_trans_settings *cts;
658 target_mask = 0x01 << ccb->ccb_h.target_id;
659 if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) {
663 if ((adw->user_discenb & target_mask) != 0)
664 cts->flags |= CCB_TRANS_DISC_ENB;
666 if ((adw->user_tagenb & target_mask) != 0)
667 cts->flags |= CCB_TRANS_TAG_ENB;
669 if ((adw->user_wdtr & target_mask) != 0)
670 cts->bus_width = MSG_EXT_WDTR_BUS_16_BIT;
672 cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
674 mc_sdtr = adw_get_user_sdtr(adw, ccb->ccb_h.target_id);
675 cts->sync_period = adw_find_period(adw, mc_sdtr);
676 if (cts->sync_period != 0)
677 cts->sync_offset = 15; /* XXX ??? */
679 cts->sync_offset = 0;
681 cts->valid = CCB_TRANS_SYNC_RATE_VALID
682 | CCB_TRANS_SYNC_OFFSET_VALID
683 | CCB_TRANS_BUS_WIDTH_VALID
684 | CCB_TRANS_DISC_VALID
685 | CCB_TRANS_TQ_VALID;
686 ccb->ccb_h.status = CAM_REQ_CMP;
691 if ((adw_lram_read_16(adw, ADW_MC_DISC_ENABLE)
693 cts->flags |= CCB_TRANS_DISC_ENB;
695 if ((adw->tagenb & target_mask) != 0)
696 cts->flags |= CCB_TRANS_TAG_ENB;
699 adw_lram_read_16(adw,
700 ADW_MC_DEVICE_HSHK_CFG_TABLE
701 + (2 * ccb->ccb_h.target_id));
703 if ((targ_tinfo & ADW_HSHK_CFG_WIDE_XFR) != 0)
704 cts->bus_width = MSG_EXT_WDTR_BUS_16_BIT;
706 cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
709 adw_hshk_cfg_period_factor(targ_tinfo);
711 cts->sync_offset = targ_tinfo & ADW_HSHK_CFG_OFFSET;
712 if (cts->sync_period == 0)
713 cts->sync_offset = 0;
715 if (cts->sync_offset == 0)
716 cts->sync_period = 0;
718 cts->valid = CCB_TRANS_SYNC_RATE_VALID
719 | CCB_TRANS_SYNC_OFFSET_VALID
720 | CCB_TRANS_BUS_WIDTH_VALID
721 | CCB_TRANS_DISC_VALID
722 | CCB_TRANS_TQ_VALID;
723 ccb->ccb_h.status = CAM_REQ_CMP;
727 case XPT_CALC_GEOMETRY:
729 struct ccb_calc_geometry *ccg;
731 u_int32_t secs_per_cylinder;
735 * XXX Use Adaptec translation until I find out how to
736 * get this information from the card.
739 size_mb = ccg->volume_size
740 / ((1024L * 1024L) / ccg->block_size);
743 if (size_mb > 1024 && extended) {
745 ccg->secs_per_track = 63;
748 ccg->secs_per_track = 32;
750 secs_per_cylinder = ccg->heads * ccg->secs_per_track;
751 ccg->cylinders = ccg->volume_size / secs_per_cylinder;
752 ccb->ccb_h.status = CAM_REQ_CMP;
756 case XPT_RESET_BUS: /* Reset the specified SCSI bus */
760 failure = adw_reset_bus(adw);
762 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
765 xpt_print_path(adw->path);
766 printf("Bus Reset Delivered\n");
768 ccb->ccb_h.status = CAM_REQ_CMP;
773 case XPT_TERM_IO: /* Terminate the I/O process */
775 ccb->ccb_h.status = CAM_REQ_INVALID;
778 case XPT_PATH_INQ: /* Path routing inquiry */
780 struct ccb_pathinq *cpi = &ccb->cpi;
782 cpi->version_num = 1;
783 cpi->hba_inquiry = PI_WIDE_16|PI_SDTR_ABLE|PI_TAG_ABLE;
784 cpi->target_sprt = 0;
786 cpi->hba_eng_cnt = 0;
787 cpi->max_target = ADW_MAX_TID;
788 cpi->max_lun = ADW_MAX_LUN;
789 cpi->initiator_id = adw->initiator_id;
790 cpi->bus_id = cam_sim_bus(sim);
791 cpi->base_transfer_speed = 3300;
792 strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
793 strncpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN);
794 strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
795 cpi->unit_number = cam_sim_unit(sim);
796 cpi->ccb_h.status = CAM_REQ_CMP;
801 ccb->ccb_h.status = CAM_REQ_INVALID;
808 adw_poll(struct cam_sim *sim)
810 adw_intr(cam_sim_softc(sim));
814 adw_async(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
819 adw_alloc(device_t dev, struct resource *regs, int regs_type, int regs_id)
821 struct adw_softc *adw;
825 * Allocate a storage area for us
827 adw = malloc(sizeof(struct adw_softc), M_DEVBUF, M_NOWAIT | M_ZERO);
829 printf("adw%d: cannot malloc!\n", device_get_unit(dev));
832 LIST_INIT(&adw->pending_ccbs);
833 SLIST_INIT(&adw->sg_maps);
835 adw->unit = device_get_unit(dev);
836 adw->regs_res_type = regs_type;
837 adw->regs_res_id = regs_id;
839 adw->tag = rman_get_bustag(regs);
840 adw->bsh = rman_get_bushandle(regs);
842 adw->name = malloc(sizeof("adw") + i + 1, M_DEVBUF, M_NOWAIT);
843 if (adw->name == NULL) {
844 printf("adw%d: cannot malloc name!\n", adw->unit);
848 sprintf(adw->name, "adw%d", adw->unit);
853 adw_free(struct adw_softc *adw)
855 switch (adw->init_level) {
858 struct sg_map_node *sg_map;
860 while ((sg_map = SLIST_FIRST(&adw->sg_maps)) != NULL) {
861 SLIST_REMOVE_HEAD(&adw->sg_maps, links);
862 bus_dmamap_unload(adw->sg_dmat,
864 bus_dmamem_free(adw->sg_dmat, sg_map->sg_vaddr,
866 free(sg_map, M_DEVBUF);
868 bus_dma_tag_destroy(adw->sg_dmat);
871 bus_dmamap_unload(adw->acb_dmat, adw->acb_dmamap);
873 bus_dmamem_free(adw->acb_dmat, adw->acbs,
875 bus_dmamap_destroy(adw->acb_dmat, adw->acb_dmamap);
877 bus_dma_tag_destroy(adw->acb_dmat);
879 bus_dmamap_unload(adw->carrier_dmat, adw->carrier_dmamap);
881 bus_dmamem_free(adw->carrier_dmat, adw->carriers,
882 adw->carrier_dmamap);
883 bus_dmamap_destroy(adw->carrier_dmat, adw->carrier_dmamap);
885 bus_dma_tag_destroy(adw->carrier_dmat);
887 bus_dma_tag_destroy(adw->buffer_dmat);
889 bus_dma_tag_destroy(adw->parent_dmat);
893 free(adw->name, M_DEVBUF);
898 adw_init(struct adw_softc *adw)
900 struct adw_eeprom eep_config;
906 checksum = adw_eeprom_read(adw, &eep_config);
907 bcopy(eep_config.serial_number, adw->serial_number,
908 sizeof(adw->serial_number));
909 if (checksum != eep_config.checksum) {
910 u_int16_t serial_number[3];
912 adw->flags |= ADW_EEPROM_FAILED;
913 printf("%s: EEPROM checksum failed. Restoring Defaults\n",
917 * Restore the default EEPROM settings.
918 * Assume the 6 byte board serial number that was read
919 * from EEPROM is correct even if the EEPROM checksum
922 bcopy(adw->default_eeprom, &eep_config, sizeof(eep_config));
923 bcopy(adw->serial_number, eep_config.serial_number,
924 sizeof(serial_number));
925 adw_eeprom_write(adw, &eep_config);
928 /* Pull eeprom information into our softc. */
929 adw->bios_ctrl = eep_config.bios_ctrl;
930 adw->user_wdtr = eep_config.wdtr_able;
931 for (tid = 0; tid < ADW_MAX_TID; tid++) {
935 tid_mask = 0x1 << tid;
936 if ((adw->features & ADW_ULTRA) != 0) {
938 * Ultra chips store sdtr and ultraenb
939 * bits in their seeprom, so we must
940 * construct valid mc_sdtr entries for
943 if (eep_config.sync1.sync_enable & tid_mask) {
944 if (eep_config.sync2.ultra_enable & tid_mask)
945 mc_sdtr = ADW_MC_SDTR_20;
947 mc_sdtr = ADW_MC_SDTR_10;
949 mc_sdtr = ADW_MC_SDTR_ASYNC;
951 switch (ADW_TARGET_GROUP(tid)) {
953 mc_sdtr = eep_config.sync4.sdtr4;
956 mc_sdtr = eep_config.sync3.sdtr3;
959 mc_sdtr = eep_config.sync2.sdtr2;
961 default: /* Shut up compiler */
963 mc_sdtr = eep_config.sync1.sdtr1;
966 mc_sdtr >>= ADW_TARGET_GROUP_SHIFT(tid);
969 adw_set_user_sdtr(adw, tid, mc_sdtr);
971 adw->user_tagenb = eep_config.tagqng_able;
972 adw->user_discenb = eep_config.disc_enable;
973 adw->max_acbs = eep_config.max_host_qng;
974 adw->initiator_id = (eep_config.adapter_scsi_id & ADW_MAX_TID);
977 * Sanity check the number of host openings.
979 if (adw->max_acbs > ADW_DEF_MAX_HOST_QNG)
980 adw->max_acbs = ADW_DEF_MAX_HOST_QNG;
981 else if (adw->max_acbs < ADW_DEF_MIN_HOST_QNG) {
982 /* If the value is zero, assume it is uninitialized. */
983 if (adw->max_acbs == 0)
984 adw->max_acbs = ADW_DEF_MAX_HOST_QNG;
986 adw->max_acbs = ADW_DEF_MIN_HOST_QNG;
990 if ((adw->features & ADW_ULTRA2) != 0) {
991 switch (eep_config.termination_lvd) {
993 printf("%s: Invalid EEPROM LVD Termination Settings.\n",
995 printf("%s: Reverting to Automatic LVD Termination\n",
998 case ADW_EEPROM_TERM_AUTO:
1000 case ADW_EEPROM_TERM_BOTH_ON:
1001 scsicfg1 |= ADW2_SCSI_CFG1_TERM_LVD_LO;
1003 case ADW_EEPROM_TERM_HIGH_ON:
1004 scsicfg1 |= ADW2_SCSI_CFG1_TERM_LVD_HI;
1006 case ADW_EEPROM_TERM_OFF:
1007 scsicfg1 |= ADW2_SCSI_CFG1_DIS_TERM_DRV;
1012 switch (eep_config.termination_se) {
1014 printf("%s: Invalid SE EEPROM Termination Settings.\n",
1016 printf("%s: Reverting to Automatic SE Termination\n",
1019 case ADW_EEPROM_TERM_AUTO:
1021 case ADW_EEPROM_TERM_BOTH_ON:
1022 scsicfg1 |= ADW_SCSI_CFG1_TERM_CTL_L;
1024 case ADW_EEPROM_TERM_HIGH_ON:
1025 scsicfg1 |= ADW_SCSI_CFG1_TERM_CTL_H;
1027 case ADW_EEPROM_TERM_OFF:
1028 scsicfg1 |= ADW_SCSI_CFG1_TERM_CTL_MANUAL;
1031 printf("%s: SCSI ID %d, ", adw_name(adw), adw->initiator_id);
1033 /* DMA tag for mapping buffers into device visible space. */
1034 if (bus_dma_tag_create(adw->parent_dmat, /*alignment*/1, /*boundary*/0,
1035 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
1036 /*highaddr*/BUS_SPACE_MAXADDR,
1037 /*filter*/NULL, /*filterarg*/NULL,
1038 /*maxsize*/MAXBSIZE, /*nsegments*/ADW_SGSIZE,
1039 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
1040 /*flags*/BUS_DMA_ALLOCNOW,
1041 &adw->buffer_dmat) != 0) {
1047 /* DMA tag for our ccb carrier structures */
1048 if (bus_dma_tag_create(adw->parent_dmat, /*alignment*/0x10,
1050 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
1051 /*highaddr*/BUS_SPACE_MAXADDR,
1052 /*filter*/NULL, /*filterarg*/NULL,
1053 (adw->max_acbs + ADW_NUM_CARRIER_QUEUES + 1)
1054 * sizeof(struct adw_carrier),
1056 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
1057 /*flags*/0, &adw->carrier_dmat) != 0) {
1063 /* Allocation for our ccb carrier structures */
1064 if (bus_dmamem_alloc(adw->carrier_dmat, (void **)&adw->carriers,
1065 BUS_DMA_NOWAIT, &adw->carrier_dmamap) != 0) {
1071 /* And permanently map them */
1072 bus_dmamap_load(adw->carrier_dmat, adw->carrier_dmamap,
1074 (adw->max_acbs + ADW_NUM_CARRIER_QUEUES + 1)
1075 * sizeof(struct adw_carrier),
1076 adwmapmem, &adw->carrier_busbase, /*flags*/0);
1078 /* Clear them out. */
1079 bzero(adw->carriers, (adw->max_acbs + ADW_NUM_CARRIER_QUEUES + 1)
1080 * sizeof(struct adw_carrier));
1082 /* Setup our free carrier list */
1083 adw->free_carriers = adw->carriers;
1084 for (i = 0; i < adw->max_acbs + ADW_NUM_CARRIER_QUEUES; i++) {
1085 adw->carriers[i].carr_offset =
1086 carriervtobo(adw, &adw->carriers[i]);
1087 adw->carriers[i].carr_ba =
1088 carriervtob(adw, &adw->carriers[i]);
1089 adw->carriers[i].areq_ba = 0;
1090 adw->carriers[i].next_ba =
1091 carriervtobo(adw, &adw->carriers[i+1]);
1093 /* Terminal carrier. Never leaves the freelist */
1094 adw->carriers[i].carr_offset =
1095 carriervtobo(adw, &adw->carriers[i]);
1096 adw->carriers[i].carr_ba =
1097 carriervtob(adw, &adw->carriers[i]);
1098 adw->carriers[i].areq_ba = 0;
1099 adw->carriers[i].next_ba = ~0;
1103 /* DMA tag for our acb structures */
1104 if (bus_dma_tag_create(adw->parent_dmat, /*alignment*/1, /*boundary*/0,
1105 /*lowaddr*/BUS_SPACE_MAXADDR,
1106 /*highaddr*/BUS_SPACE_MAXADDR,
1107 /*filter*/NULL, /*filterarg*/NULL,
1108 adw->max_acbs * sizeof(struct acb),
1110 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
1111 /*flags*/0, &adw->acb_dmat) != 0) {
1117 /* Allocation for our ccbs */
1118 if (bus_dmamem_alloc(adw->acb_dmat, (void **)&adw->acbs,
1119 BUS_DMA_NOWAIT, &adw->acb_dmamap) != 0)
1124 /* And permanently map them */
1125 bus_dmamap_load(adw->acb_dmat, adw->acb_dmamap,
1127 adw->max_acbs * sizeof(struct acb),
1128 adwmapmem, &adw->acb_busbase, /*flags*/0);
1130 /* Clear them out. */
1131 bzero(adw->acbs, adw->max_acbs * sizeof(struct acb));
1133 /* DMA tag for our S/G structures. We allocate in page sized chunks */
1134 if (bus_dma_tag_create(adw->parent_dmat, /*alignment*/1, /*boundary*/0,
1135 /*lowaddr*/BUS_SPACE_MAXADDR,
1136 /*highaddr*/BUS_SPACE_MAXADDR,
1137 /*filter*/NULL, /*filterarg*/NULL,
1138 PAGE_SIZE, /*nsegments*/1,
1139 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
1140 /*flags*/0, &adw->sg_dmat) != 0) {
1146 /* Allocate our first batch of ccbs */
1147 if (adwallocacbs(adw) == 0)
1150 if (adw_init_chip(adw, scsicfg1) != 0)
1153 printf("Queue Depth %d\n", adw->max_acbs);
1159 * Attach all the sub-devices we can find
1162 adw_attach(struct adw_softc *adw)
1164 struct ccb_setasync csa;
1165 struct cam_devq *devq;
1171 /* Hook up our interrupt handler */
1172 if ((error = bus_setup_intr(adw->device, adw->irq, INTR_TYPE_CAM,
1173 adw_intr, adw, &adw->ih)) != 0) {
1174 device_printf(adw->device, "bus_setup_intr() failed: %d\n",
1179 /* Start the Risc processor now that we are fully configured. */
1180 adw_outw(adw, ADW_RISC_CSR, ADW_RISC_CSR_RUN);
1183 * Create the device queue for our SIM.
1185 devq = cam_simq_alloc(adw->max_acbs);
1190 * Construct our SIM entry.
1192 adw->sim = cam_sim_alloc(adw_action, adw_poll, "adw", adw, adw->unit,
1193 1, adw->max_acbs, devq);
1194 if (adw->sim == NULL) {
1202 if (xpt_bus_register(adw->sim, 0) != CAM_SUCCESS) {
1203 cam_sim_free(adw->sim, /*free devq*/TRUE);
1208 if (xpt_create_path(&adw->path, /*periph*/NULL, cam_sim_path(adw->sim),
1209 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD)
1211 xpt_setup_ccb(&csa.ccb_h, adw->path, /*priority*/5);
1212 csa.ccb_h.func_code = XPT_SASYNC_CB;
1213 csa.event_enable = AC_LOST_DEVICE;
1214 csa.callback = adw_async;
1215 csa.callback_arg = adw;
1216 xpt_action((union ccb *)&csa);
1227 struct adw_softc *adw;
1230 adw = (struct adw_softc *)arg;
1231 if ((adw_inw(adw, ADW_CTRL_REG) & ADW_CTRL_REG_HOST_INTR) == 0)
1234 /* Reading the register clears the interrupt. */
1235 int_stat = adw_inb(adw, ADW_INTR_STATUS_REG);
1237 if ((int_stat & ADW_INTR_STATUS_INTRB) != 0) {
1240 /* Async Microcode Event */
1241 intrb_code = adw_lram_read_8(adw, ADW_MC_INTRB_CODE);
1242 switch (intrb_code) {
1243 case ADW_ASYNC_CARRIER_READY_FAILURE:
1245 * The RISC missed our update of
1248 if (LIST_FIRST(&adw->pending_ccbs) != NULL)
1249 adw_tickle_risc(adw, ADW_TICKLE_A);
1251 case ADW_ASYNC_SCSI_BUS_RESET_DET:
1253 * The firmware detected a SCSI Bus reset.
1255 printf("Someone Reset the Bus\n");
1256 adw_handle_bus_reset(adw, /*initiated*/FALSE);
1258 case ADW_ASYNC_RDMA_FAILURE:
1260 * Handle RDMA failure by resetting the
1261 * SCSI Bus and chip.
1264 AdvResetChipAndSB(adv_dvc_varp);
1268 case ADW_ASYNC_HOST_SCSI_BUS_RESET:
1270 * Host generated SCSI bus reset occurred.
1272 adw_handle_bus_reset(adw, /*initiated*/TRUE);
1275 printf("adw_intr: unknown async code 0x%x\n",
1282 * Run down the RequestQ.
1284 while ((adw->responseq->next_ba & ADW_RQ_DONE) != 0) {
1285 struct adw_carrier *free_carrier;
1290 printf("0x%x, 0x%x, 0x%x, 0x%x\n",
1291 adw->responseq->carr_offset,
1292 adw->responseq->carr_ba,
1293 adw->responseq->areq_ba,
1294 adw->responseq->next_ba);
1297 * The firmware copies the adw_scsi_req_q.acb_baddr
1298 * field into the areq_ba field of the carrier.
1300 acb = acbbotov(adw, adw->responseq->areq_ba);
1303 * The least significant four bits of the next_ba
1304 * field are used as flags. Mask them out and then
1305 * advance through the list.
1307 free_carrier = adw->responseq;
1309 carrierbotov(adw, free_carrier->next_ba & ADW_NEXT_BA_MASK);
1310 free_carrier->next_ba = adw->free_carriers->carr_offset;
1311 adw->free_carriers = free_carrier;
1315 untimeout(adwtimeout, acb, ccb->ccb_h.timeout_ch);
1316 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
1317 bus_dmasync_op_t op;
1319 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
1320 op = BUS_DMASYNC_POSTREAD;
1322 op = BUS_DMASYNC_POSTWRITE;
1323 bus_dmamap_sync(adw->buffer_dmat, acb->dmamap, op);
1324 bus_dmamap_unload(adw->buffer_dmat, acb->dmamap);
1325 ccb->csio.resid = acb->queue.data_cnt;
1327 ccb->csio.resid = 0;
1329 /* Common Cases inline... */
1330 if (acb->queue.host_status == QHSTA_NO_ERROR
1331 && (acb->queue.done_status == QD_NO_ERROR
1332 || acb->queue.done_status == QD_WITH_ERROR)) {
1333 ccb->csio.scsi_status = acb->queue.scsi_status;
1334 ccb->ccb_h.status = 0;
1335 switch (ccb->csio.scsi_status) {
1336 case SCSI_STATUS_OK:
1337 ccb->ccb_h.status |= CAM_REQ_CMP;
1339 case SCSI_STATUS_CHECK_COND:
1340 case SCSI_STATUS_CMD_TERMINATED:
1341 bcopy(&acb->sense_data, &ccb->csio.sense_data,
1342 ccb->csio.sense_len);
1343 ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
1344 ccb->csio.sense_resid = acb->queue.sense_len;
1347 ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR
1349 xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
1352 adwfreeacb(adw, acb);
1355 adwprocesserror(adw, acb);
1361 adwprocesserror(struct adw_softc *adw, struct acb *acb)
1366 if (acb->queue.done_status == QD_ABORTED_BY_HOST) {
1367 ccb->ccb_h.status = CAM_REQ_ABORTED;
1370 switch (acb->queue.host_status) {
1371 case QHSTA_M_SEL_TIMEOUT:
1372 ccb->ccb_h.status = CAM_SEL_TIMEOUT;
1374 case QHSTA_M_SXFR_OFF_UFLW:
1375 case QHSTA_M_SXFR_OFF_OFLW:
1376 case QHSTA_M_DATA_OVER_RUN:
1377 ccb->ccb_h.status = CAM_DATA_RUN_ERR;
1379 case QHSTA_M_SXFR_DESELECTED:
1380 case QHSTA_M_UNEXPECTED_BUS_FREE:
1381 ccb->ccb_h.status = CAM_UNEXP_BUSFREE;
1383 case QHSTA_M_SCSI_BUS_RESET:
1384 case QHSTA_M_SCSI_BUS_RESET_UNSOL:
1385 ccb->ccb_h.status = CAM_SCSI_BUS_RESET;
1387 case QHSTA_M_BUS_DEVICE_RESET:
1388 ccb->ccb_h.status = CAM_BDR_SENT;
1390 case QHSTA_M_QUEUE_ABORTED:
1391 /* BDR or Bus Reset */
1392 printf("Saw Queue Aborted\n");
1393 ccb->ccb_h.status = adw->last_reset;
1395 case QHSTA_M_SXFR_SDMA_ERR:
1396 case QHSTA_M_SXFR_SXFR_PERR:
1397 case QHSTA_M_RDMA_PERR:
1398 ccb->ccb_h.status = CAM_UNCOR_PARITY;
1400 case QHSTA_M_WTM_TIMEOUT:
1401 case QHSTA_M_SXFR_WD_TMO:
1403 /* The SCSI bus hung in a phase */
1404 xpt_print_path(adw->path);
1405 printf("Watch Dog timer expired. Reseting bus\n");
1409 case QHSTA_M_SXFR_XFR_PH_ERR:
1410 ccb->ccb_h.status = CAM_SEQUENCE_FAIL;
1412 case QHSTA_M_SXFR_UNKNOWN_ERROR:
1414 case QHSTA_M_BAD_CMPL_STATUS_IN:
1415 /* No command complete after a status message */
1416 ccb->ccb_h.status = CAM_SEQUENCE_FAIL;
1418 case QHSTA_M_AUTO_REQ_SENSE_FAIL:
1419 ccb->ccb_h.status = CAM_AUTOSENSE_FAIL;
1421 case QHSTA_M_INVALID_DEVICE:
1422 ccb->ccb_h.status = CAM_PATH_INVALID;
1424 case QHSTA_M_NO_AUTO_REQ_SENSE:
1426 * User didn't request sense, but we got a
1429 ccb->csio.scsi_status = acb->queue.scsi_status;
1430 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR;
1433 panic("%s: Unhandled Host status error %x",
1434 adw_name(adw), acb->queue.host_status);
1438 if ((acb->state & ACB_RECOVERY_ACB) != 0) {
1439 if (ccb->ccb_h.status == CAM_SCSI_BUS_RESET
1440 || ccb->ccb_h.status == CAM_BDR_SENT)
1441 ccb->ccb_h.status = CAM_CMD_TIMEOUT;
1443 if (ccb->ccb_h.status != CAM_REQ_CMP) {
1444 xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
1445 ccb->ccb_h.status |= CAM_DEV_QFRZN;
1447 adwfreeacb(adw, acb);
1452 adwtimeout(void *arg)
1456 struct adw_softc *adw;
1457 adw_idle_cmd_status_t status;
1461 acb = (struct acb *)arg;
1463 adw = (struct adw_softc *)ccb->ccb_h.ccb_adw_ptr;
1464 xpt_print_path(ccb->ccb_h.path);
1465 printf("ACB %p - timed out\n", (void *)acb);
1469 if ((acb->state & ACB_ACTIVE) == 0) {
1470 xpt_print_path(ccb->ccb_h.path);
1471 printf("ACB %p - timed out CCB already completed\n",
1477 acb->state |= ACB_RECOVERY_ACB;
1478 target_id = ccb->ccb_h.target_id;
1480 /* Attempt a BDR first */
1481 status = adw_idle_cmd_send(adw, ADW_IDLE_CMD_DEVICE_RESET,
1482 ccb->ccb_h.target_id);
1484 if (status == ADW_IDLE_CMD_SUCCESS) {
1485 printf("%s: BDR Delivered. No longer in timeout\n",
1487 adw_handle_device_reset(adw, target_id);
1490 xpt_print_path(adw->path);
1491 printf("Bus Reset Delivered. No longer in timeout\n");
1496 adw_handle_device_reset(struct adw_softc *adw, u_int target)
1498 struct cam_path *path;
1501 error = xpt_create_path(&path, /*periph*/NULL, cam_sim_path(adw->sim),
1502 target, CAM_LUN_WILDCARD);
1504 if (error == CAM_REQ_CMP) {
1505 xpt_async(AC_SENT_BDR, path, NULL);
1506 xpt_free_path(path);
1508 adw->last_reset = CAM_BDR_SENT;
1512 adw_handle_bus_reset(struct adw_softc *adw, int initiated)
1516 * The microcode currently sets the SCSI Bus Reset signal
1517 * while handling the AscSendIdleCmd() IDLE_CMD_SCSI_RESET
1518 * command above. But the SCSI Bus Reset Hold Time in the
1519 * microcode is not deterministic (it may in fact be for less
1520 * than the SCSI Spec. minimum of 25 us). Therefore on return
1521 * the Adv Library sets the SCSI Bus Reset signal for
1522 * ADW_SCSI_RESET_HOLD_TIME_US, which is defined to be greater
1527 scsi_ctrl = adw_inw(adw, ADW_SCSI_CTRL) & ~ADW_SCSI_CTRL_RSTOUT;
1528 adw_outw(adw, ADW_SCSI_CTRL, scsi_ctrl | ADW_SCSI_CTRL_RSTOUT);
1529 DELAY(ADW_SCSI_RESET_HOLD_TIME_US);
1530 adw_outw(adw, ADW_SCSI_CTRL, scsi_ctrl);
1533 * We will perform the async notification when the
1534 * SCSI Reset interrupt occurs.
1537 xpt_async(AC_BUS_RESET, adw->path, NULL);
1538 adw->last_reset = CAM_SCSI_BUS_RESET;