]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/amr/amr_cam.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / amr / amr_cam.c
1 /*-
2  * Copyright (c) 2000 Michael Smith
3  * Copyright (c) 2000 BSDi
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *      notice, this list of conditions and the following disclaimer in the
13  *      documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 /*-
28  * Copyright (c) 2002 Eric Moore
29  * Copyright (c) 2002 LSI Logic Corporation
30  * All rights reserved.
31  *
32  * Redistribution and use in source and binary forms, with or without
33  * modification, are permitted provided that the following conditions
34  * are met:
35  * 1. Redistributions of source code must retain the above copyright
36  *      notice, this list of conditions and the following disclaimer.
37  * 2. Redistributions in binary form must reproduce the above copyright
38  *      notice, this list of conditions and the following disclaimer in the
39  *      documentation and/or other materials provided with the distribution.
40  * 3. The party using or redistributing the source code and binary forms
41  *      agrees to the disclaimer below and the terms and conditions set forth
42  *      herein.
43  *
44  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
45  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
48  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54  * SUCH DAMAGE.
55  */
56
57 #include <sys/cdefs.h>
58 __FBSDID("$FreeBSD$");
59
60 #include <sys/param.h>
61 #include <sys/systm.h>
62 #include <sys/malloc.h>
63 #include <sys/kernel.h>
64
65 #include <sys/bio.h>
66 #include <sys/bus.h>
67 #include <sys/conf.h>
68 #include <sys/stat.h>
69
70 #include <cam/cam.h>
71 #include <cam/cam_ccb.h>
72 #include <cam/cam_sim.h>
73 #include <cam/cam_xpt.h>
74 #include <cam/cam_xpt_sim.h>
75 #include <cam/cam_debug.h>
76 #include <cam/scsi/scsi_all.h>
77 #include <cam/scsi/scsi_message.h>
78
79 #include <machine/resource.h>
80 #include <machine/bus.h>
81
82 #include <dev/amr/amrreg.h>
83 #include <dev/amr/amrvar.h>
84
85 static void     amr_cam_action(struct cam_sim *sim, union ccb *ccb);
86 static void     amr_cam_poll(struct cam_sim *sim);
87 static void     amr_cam_complete(struct amr_command *ac);
88
89 MALLOC_DEFINE(M_AMRCAM, "amrcam", "AMR CAM memory");
90
91 /***********************************************************************
92  * Enqueue/dequeue functions
93  */
94 static __inline void
95 amr_enqueue_ccb(struct amr_softc *sc, union ccb *ccb)
96 {
97
98         TAILQ_INSERT_TAIL(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
99 }
100
101 static __inline void
102 amr_requeue_ccb(struct amr_softc *sc, union ccb *ccb)
103 {
104
105         TAILQ_INSERT_HEAD(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
106 }
107
108 static __inline union ccb *
109 amr_dequeue_ccb(struct amr_softc *sc)
110 {
111         union ccb       *ccb;
112
113         if ((ccb = (union ccb *)TAILQ_FIRST(&sc->amr_cam_ccbq)) != NULL)
114                 TAILQ_REMOVE(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
115         return(ccb);
116 }
117
118 /********************************************************************************
119  * Attach our 'real' SCSI channels to CAM
120  */
121 int
122 amr_cam_attach(struct amr_softc *sc)
123 {
124         struct cam_devq *devq;
125         int                     chn, error;
126
127         /* initialise the ccb queue */
128         TAILQ_INIT(&sc->amr_cam_ccbq);
129
130         /*
131          * Allocate a devq for all our channels combined.  This should
132          * allow for the maximum number of SCSI commands we will accept
133          * at one time. Save the pointer in the softc so we can find it later
134          * during detach.
135          */
136         if ((devq = cam_simq_alloc(AMR_MAX_SCSI_CMDS)) == NULL)
137         return(ENOMEM);
138         sc->amr_cam_devq = devq;
139
140         /*
141          * Iterate over our channels, registering them with CAM
142          */
143         for (chn = 0; chn < sc->amr_maxchan; chn++) {
144
145                 /* allocate a sim */
146                 if ((sc->amr_cam_sim[chn] = cam_sim_alloc(amr_cam_action,
147                     amr_cam_poll, "amr", sc, device_get_unit(sc->amr_dev),
148                     &sc->amr_list_lock, 1, AMR_MAX_SCSI_CMDS, devq)) == NULL) {
149                         cam_simq_free(devq);
150                         device_printf(sc->amr_dev, "CAM SIM attach failed\n");
151                         return(ENOMEM);
152                 }
153
154                 /* register the bus ID so we can get it later */
155                 mtx_lock(&sc->amr_list_lock);
156                 error = xpt_bus_register(sc->amr_cam_sim[chn], sc->amr_dev,chn);
157                 mtx_unlock(&sc->amr_list_lock);
158                 if (error) {
159                         device_printf(sc->amr_dev,
160                             "CAM XPT bus registration failed\n");
161                         return(ENXIO);
162                 }
163         }
164         /*
165          * XXX we should scan the config and work out which devices are
166          * actually protected.
167          */
168         return(0);
169 }
170
171 /********************************************************************************
172  * Disconnect ourselves from CAM
173  */
174 void
175 amr_cam_detach(struct amr_softc *sc)
176 {
177         int             chn;
178
179         mtx_lock(&sc->amr_list_lock);
180         for (chn = 0; chn < sc->amr_maxchan; chn++) {
181                 /*
182                  * If a sim was allocated for this channel, free it
183                  */
184                 if (sc->amr_cam_sim[chn] != NULL) {
185                         xpt_bus_deregister(cam_sim_path(sc->amr_cam_sim[chn]));
186                         cam_sim_free(sc->amr_cam_sim[chn], FALSE);
187                 }
188         }
189         mtx_unlock(&sc->amr_list_lock);
190
191         /* Now free the devq */
192         if (sc->amr_cam_devq != NULL)
193                 cam_simq_free(sc->amr_cam_devq);
194 }
195
196 /***********************************************************************
197  ***********************************************************************
198                         CAM passthrough interface
199  ***********************************************************************
200  ***********************************************************************/
201
202 /***********************************************************************
203  * Handle a request for action from CAM
204  */
205 static void
206 amr_cam_action(struct cam_sim *sim, union ccb *ccb)
207 {
208         struct amr_softc        *sc = cam_sim_softc(sim);
209
210         switch(ccb->ccb_h.func_code) {
211
212         /*
213          * Perform SCSI I/O to a physical device.
214          */
215         case XPT_SCSI_IO:
216         {
217                 struct ccb_hdr          *ccbh = &ccb->ccb_h;
218                 struct ccb_scsiio       *csio = &ccb->csio;
219
220                 /* Validate the CCB */
221                 ccbh->status = CAM_REQ_INPROG;
222
223                 /* check the CDB length */
224                 if (csio->cdb_len > AMR_MAX_EXTCDB_LEN)
225                         ccbh->status = CAM_REQ_INVALID;
226
227                 if ((csio->cdb_len > AMR_MAX_CDB_LEN) &&
228                     (sc->support_ext_cdb == 0))
229                         ccbh->status = CAM_REQ_INVALID;
230         
231                 /* check that the CDB pointer is not to a physical address */
232                 if ((ccbh->flags & CAM_CDB_POINTER) &&
233                     (ccbh->flags & CAM_CDB_PHYS))
234                         ccbh->status = CAM_REQ_INVALID;
235                 /*
236                  * if there is data transfer, it must be to/from a virtual
237                  * address
238                  */
239                 if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
240                         if (ccbh->flags & CAM_DATA_PHYS)
241                                 /* we can't map it */
242                                 ccbh->status = CAM_REQ_INVALID;
243                         if (ccbh->flags & CAM_SCATTER_VALID)
244                                 /* we want to do the s/g setup */
245                                 ccbh->status = CAM_REQ_INVALID;
246                 }
247         
248                 /*
249                  * If the command is to a LUN other than 0, fail it.
250                  * This is probably incorrect, but during testing the
251                  * firmware did not seem to respect the LUN field, and thus
252                  * devices appear echoed.
253                  */
254                 if (csio->ccb_h.target_lun != 0)
255                         ccbh->status = CAM_DEV_NOT_THERE;
256
257                 /* if we're happy with the request, queue it for attention */
258                 if (ccbh->status == CAM_REQ_INPROG) {
259
260                         /* save the channel number in the ccb */
261                         csio->ccb_h.sim_priv.entries[0].field= cam_sim_bus(sim);
262
263                         amr_enqueue_ccb(sc, ccb);
264                         amr_startio(sc);
265                         return;
266                 }
267                 break;
268         }
269
270         case XPT_CALC_GEOMETRY:
271         {
272                 cam_calc_geometry(&ccb->ccg, /*extended*/1);
273                 break;
274         }
275
276         /*
277          * Return path stats.  Some of these should probably be amended.
278          */
279         case XPT_PATH_INQ:
280         {
281                 struct ccb_pathinq        *cpi = & ccb->cpi;
282
283                 debug(3, "XPT_PATH_INQ");
284                 cpi->version_num = 1;              /* XXX??? */
285                 cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
286                 cpi->target_sprt = 0;
287                 cpi->hba_misc = PIM_NOBUSRESET|PIM_SEQSCAN;
288                 cpi->hba_eng_cnt = 0;
289                 cpi->max_target = AMR_MAX_TARGETS;
290                 cpi->max_lun = 0 /* AMR_MAX_LUNS*/;
291                 cpi->initiator_id = 7;            /* XXX variable? */
292                 strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
293                 strncpy(cpi->hba_vid, "LSI", HBA_IDLEN);
294                 strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
295                 cpi->unit_number = cam_sim_unit(sim);
296                 cpi->bus_id = cam_sim_bus(sim);
297                 cpi->base_transfer_speed = 132 * 1024;  /* XXX */
298                 cpi->transport = XPORT_SPI;
299                 cpi->transport_version = 2;
300                 cpi->protocol = PROTO_SCSI;
301                 cpi->protocol_version = SCSI_REV_2;
302                 cpi->ccb_h.status = CAM_REQ_CMP;
303
304                 break;
305         }
306
307         case XPT_RESET_BUS:
308         {
309                 struct ccb_pathinq      *cpi = & ccb->cpi;
310
311                 debug(1, "XPT_RESET_BUS");
312                 cpi->ccb_h.status = CAM_REQ_CMP;
313                 break;
314         }
315
316         case XPT_RESET_DEV:
317         {
318                 debug(1, "XPT_RESET_DEV");
319                 ccb->ccb_h.status = CAM_REQ_CMP;
320                 break;
321         }
322
323         case XPT_GET_TRAN_SETTINGS:
324         {
325                 struct ccb_trans_settings       *cts = &(ccb->cts);
326
327                 debug(3, "XPT_GET_TRAN_SETTINGS");
328
329                 struct ccb_trans_settings_scsi *scsi;
330                 struct ccb_trans_settings_spi *spi;
331
332                 scsi = &cts->proto_specific.scsi;
333                 spi = &cts->xport_specific.spi;
334
335                 cts->protocol = PROTO_SCSI;
336                 cts->protocol_version = SCSI_REV_2;
337                 cts->transport = XPORT_SPI;
338                 cts->transport_version = 2;
339
340                 if (cts->type == CTS_TYPE_USER_SETTINGS) {
341                         ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
342                         break;
343                 }
344
345                 spi->flags = CTS_SPI_FLAGS_DISC_ENB;
346                 spi->bus_width = MSG_EXT_WDTR_BUS_32_BIT;
347                 spi->sync_period = 6;   /* 40MHz how wide is this bus? */
348                 spi->sync_offset = 31;  /* How to extract this from board? */
349
350                 spi->valid = CTS_SPI_VALID_SYNC_RATE
351                         | CTS_SPI_VALID_SYNC_OFFSET
352                         | CTS_SPI_VALID_BUS_WIDTH
353                         | CTS_SPI_VALID_DISC;
354                 scsi->valid = CTS_SCSI_VALID_TQ;
355                 ccb->ccb_h.status = CAM_REQ_CMP;
356                 break;
357         }
358
359         case XPT_SET_TRAN_SETTINGS:
360                 debug(3, "XPT_SET_TRAN_SETTINGS");
361                 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
362                 break;
363
364
365         /*
366          * Reject anything else as unsupported.
367          */
368         default:
369                 /* we can't do this */
370                 ccb->ccb_h.status = CAM_REQ_INVALID;
371                 break;
372         }
373
374         mtx_assert(&sc->amr_list_lock, MA_OWNED);
375         xpt_done(ccb);
376 }
377
378 /***********************************************************************
379  * Convert a CAM CCB off the top of the CCB queue to a passthrough SCSI
380  * command.
381  */
382 int
383 amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
384 {
385         struct amr_command              *ac;
386         struct amr_passthrough          *ap;
387         struct amr_ext_passthrough      *aep;
388         struct ccb_scsiio               *csio;
389         int                             bus, target, error;
390
391         error = 0;
392         ac = NULL;
393         ap = NULL;
394         aep = NULL;
395
396         /* check to see if there is a ccb for us to work with */
397         if ((csio = (struct ccb_scsiio *)amr_dequeue_ccb(sc)) == NULL)
398         goto out;
399
400         /* get bus/target, XXX validate against protected devices? */
401         bus = csio->ccb_h.sim_priv.entries[0].field;
402         target = csio->ccb_h.target_id;
403
404         /*
405          * Build a passthrough command.
406          */
407
408         /* construct command */
409         if ((ac = amr_alloccmd(sc)) == NULL) {
410                 error = ENOMEM;
411                 goto out;
412         }
413
414         /* construct passthrough */
415         if (sc->support_ext_cdb ) {
416                 aep = &ac->ac_ccb->ccb_epthru;
417                 aep->ap_timeout = 2;
418                 aep->ap_ars = 1;
419                 aep->ap_request_sense_length = 14;
420                 aep->ap_islogical = 0;
421                 aep->ap_channel = bus;
422                 aep->ap_scsi_id = target;
423                 aep->ap_logical_drive_no = csio->ccb_h.target_lun;
424                 aep->ap_cdb_length = csio->cdb_len;
425                 aep->ap_data_transfer_length = csio->dxfer_len;
426                 if (csio->ccb_h.flags & CAM_CDB_POINTER) {
427                         bcopy(csio->cdb_io.cdb_ptr, aep->ap_cdb, csio->cdb_len);
428                 } else {
429                         bcopy(csio->cdb_io.cdb_bytes, aep->ap_cdb,
430                             csio->cdb_len);
431                 }
432                 /*
433                  * we leave the data s/g list and s/g count to the map routine
434                  * later
435                  */
436
437                 debug(2, " COMMAND %x/%d+%d to %d:%d:%d", aep->ap_cdb[0],
438                     aep->ap_cdb_length, csio->dxfer_len, aep->ap_channel,
439                     aep->ap_scsi_id, aep->ap_logical_drive_no);
440
441         } else {
442                 ap = &ac->ac_ccb->ccb_pthru;
443                 ap->ap_timeout = 0;
444                 ap->ap_ars = 1;
445                 ap->ap_request_sense_length = 14;
446                 ap->ap_islogical = 0;
447                 ap->ap_channel = bus;
448                 ap->ap_scsi_id = target;
449                 ap->ap_logical_drive_no = csio->ccb_h.target_lun;
450                 ap->ap_cdb_length = csio->cdb_len;
451                 ap->ap_data_transfer_length = csio->dxfer_len;
452                 if (csio->ccb_h.flags & CAM_CDB_POINTER) {
453                         bcopy(csio->cdb_io.cdb_ptr, ap->ap_cdb, csio->cdb_len);
454                 } else {
455                         bcopy(csio->cdb_io.cdb_bytes, ap->ap_cdb,
456                             csio->cdb_len);
457                 }
458                 /*
459                  * we leave the data s/g list and s/g count to the map routine
460                  * later
461                  */
462
463                 debug(2, " COMMAND %x/%d+%d to %d:%d:%d", ap->ap_cdb[0],
464                     ap->ap_cdb_length, csio->dxfer_len, ap->ap_channel,
465                     ap->ap_scsi_id, ap->ap_logical_drive_no);
466         }
467
468         ac->ac_flags |= AMR_CMD_CCB;
469
470         ac->ac_data = csio->data_ptr;
471         ac->ac_length = csio->dxfer_len;
472         if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
473                 ac->ac_flags |= AMR_CMD_DATAIN;
474         if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
475                 ac->ac_flags |= AMR_CMD_DATAOUT;
476
477         ac->ac_private = csio;
478         ac->ac_complete = amr_cam_complete;
479         if ( sc->support_ext_cdb ) {
480                 ac->ac_mailbox.mb_command = AMR_CMD_EXTPASS;
481         } else {
482                 ac->ac_mailbox.mb_command = AMR_CMD_PASS;
483         }
484
485 out:
486         if (error != 0) {
487                 if (ac != NULL)
488                         amr_releasecmd(ac);
489                 if (csio != NULL)
490                         /* put it back and try again later */
491                         amr_requeue_ccb(sc, (union ccb *)csio);
492         }
493         *acp = ac;
494         return(error);
495 }
496
497 /***********************************************************************
498  * Check for interrupt status
499  */
500 static void
501 amr_cam_poll(struct cam_sim *sim)
502 {
503
504         amr_done(cam_sim_softc(sim));
505 }
506
507  /**********************************************************************
508  * Handle completion of a command submitted via CAM.
509  */
510 static void
511 amr_cam_complete(struct amr_command *ac)
512 {
513         struct amr_passthrough          *ap;
514         struct amr_ext_passthrough      *aep;
515         struct ccb_scsiio               *csio;
516         struct scsi_inquiry_data        *inq;
517         int                             scsi_status, cdb0;
518
519         ap = &ac->ac_ccb->ccb_pthru;
520         aep = &ac->ac_ccb->ccb_epthru;
521         csio = (struct ccb_scsiio *)ac->ac_private;
522         inq = (struct scsi_inquiry_data *)csio->data_ptr;
523
524         if (ac->ac_mailbox.mb_command == AMR_CMD_EXTPASS)
525                 scsi_status = aep->ap_scsi_status;
526         else
527                 scsi_status = ap->ap_scsi_status;
528         debug(1, "status 0x%x  AP scsi_status 0x%x", ac->ac_status,
529             scsi_status);
530
531         /* Make sure the status is sane */
532         if ((ac->ac_status != AMR_STATUS_SUCCESS) && (scsi_status == 0)) {
533                 csio->ccb_h.status = CAM_REQ_CMP_ERR;
534                 goto out;
535         }
536
537         /*
538          * Hide disks from CAM so that they're not picked up and treated as
539          * 'normal' disks.
540          *
541          * If the configuration provides a mechanism to mark a disk a "not
542          * managed", we could add handling for that to allow disks to be
543          * selectively visible.
544          */
545
546         /* handle passthrough SCSI status */
547         switch(scsi_status) {
548         case 0: /* completed OK */
549                 if (ac->ac_mailbox.mb_command == AMR_CMD_EXTPASS)
550                         cdb0 = aep->ap_cdb[0];
551                 else
552                         cdb0 = ap->ap_cdb[0];
553                 if ((cdb0 == INQUIRY) && (SID_TYPE(inq) == T_DIRECT))
554                         inq->device = (inq->device & 0xe0) | T_NODEVICE;
555                 csio->ccb_h.status = CAM_REQ_CMP;
556                 break;
557
558         case 0x02:
559                 csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
560                 csio->scsi_status = SCSI_STATUS_CHECK_COND;
561                 if (ac->ac_mailbox.mb_command == AMR_CMD_EXTPASS)
562                         bcopy(aep->ap_request_sense_area, &csio->sense_data,
563                             AMR_MAX_REQ_SENSE_LEN);
564                 else
565                         bcopy(ap->ap_request_sense_area, &csio->sense_data,
566                             AMR_MAX_REQ_SENSE_LEN);
567                 csio->sense_len = AMR_MAX_REQ_SENSE_LEN;
568                 csio->ccb_h.status |= CAM_AUTOSNS_VALID;
569                 break;
570
571         case 0x08:
572                 csio->ccb_h.status = CAM_SCSI_BUSY;
573                 break;
574
575         case 0xf0:
576         case 0xf4:
577         default:
578                 /*
579                  * Non-zero LUNs are already filtered, so there's no need
580                  * to return CAM_DEV_NOT_THERE.
581                  */
582                 csio->ccb_h.status = CAM_SEL_TIMEOUT;
583                 break;
584         }
585
586 out:
587         if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
588                 debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr,
589                     " ");
590
591         mtx_lock(&ac->ac_sc->amr_list_lock);
592         xpt_done((union ccb *)csio);
593         amr_releasecmd(ac);
594         mtx_unlock(&ac->ac_sc->amr_list_lock);
595 }