2 * Common functions for CAM "type" (peripheral) drivers.
4 * Copyright (c) 1997, 1998 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions, and the following disclaimer,
13 * without modification, immediately at the beginning of the file.
14 * 2. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sys/cam/cam_periph.c,v 1.70 2008/02/12 11:07:33 raj Exp $
30 * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.41 2008/07/18 00:07:21 dillon Exp $
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/types.h>
36 #include <sys/malloc.h>
37 #include <sys/kernel.h>
41 #include <sys/devicestat.h>
44 #include <vm/vm_extern.h>
46 #include <sys/thread2.h>
50 #include "cam_xpt_periph.h"
51 #include "cam_periph.h"
52 #include "cam_debug.h"
55 #include <bus/cam/scsi/scsi_all.h>
56 #include <bus/cam/scsi/scsi_message.h>
57 #include <bus/cam/scsi/scsi_pass.h>
59 static u_int camperiphnextunit(struct periph_driver *p_drv,
60 u_int newunit, int wired,
61 path_id_t pathid, target_id_t target,
63 static u_int camperiphunit(struct periph_driver *p_drv,
64 struct cam_sim *sim, path_id_t pathid,
65 target_id_t target, lun_id_t lun);
66 static void camperiphdone(struct cam_periph *periph,
68 static void camperiphfree(struct cam_periph *periph);
69 static int camperiphscsistatuserror(union ccb *ccb,
71 u_int32_t sense_flags,
74 u_int32_t *relsim_flags,
76 static int camperiphscsisenseerror(union ccb *ccb,
78 u_int32_t sense_flags,
81 u_int32_t *relsim_flags,
83 static void cam_periph_unmapbufs(struct cam_periph_map_info *mapinfo,
84 u_int8_t ***data_ptrs, int numbufs);
86 static int nperiph_drivers;
87 struct periph_driver **periph_drivers;
89 MALLOC_DEFINE(M_CAMPERIPH, "CAM periph", "CAM peripheral buffers");
91 static int periph_selto_delay = 1000;
92 TUNABLE_INT("kern.cam.periph_selto_delay", &periph_selto_delay);
93 static int periph_noresrc_delay = 500;
94 TUNABLE_INT("kern.cam.periph_noresrc_delay", &periph_noresrc_delay);
95 static int periph_busy_delay = 500;
96 TUNABLE_INT("kern.cam.periph_busy_delay", &periph_busy_delay);
100 periphdriver_register(void *data)
102 struct periph_driver **newdrivers, **old;
105 ndrivers = nperiph_drivers + 2;
106 newdrivers = kmalloc(sizeof(*newdrivers) * ndrivers, M_CAMPERIPH,
109 bcopy(periph_drivers, newdrivers,
110 sizeof(*newdrivers) * nperiph_drivers);
111 newdrivers[nperiph_drivers] = (struct periph_driver *)data;
112 newdrivers[nperiph_drivers + 1] = NULL;
113 old = periph_drivers;
114 periph_drivers = newdrivers;
116 kfree(old, M_CAMPERIPH);
121 cam_periph_alloc(periph_ctor_t *periph_ctor,
122 periph_oninv_t *periph_oninvalidate,
123 periph_dtor_t *periph_dtor, periph_start_t *periph_start,
124 char *name, cam_periph_type type, struct cam_path *path,
125 ac_callback_t *ac_callback, ac_code code, void *arg)
127 struct periph_driver **p_drv;
129 struct cam_periph *periph;
130 struct cam_periph *cur_periph;
132 target_id_t target_id;
139 * Handle Hot-Plug scenarios. If there is already a peripheral
140 * of our type assigned to this path, we are likely waiting for
141 * final close on an old, invalidated, peripheral. If this is
142 * the case, queue up a deferred call to the peripheral's async
143 * handler. If it looks like a mistaken re-allocation, complain.
145 if ((periph = cam_periph_find(path, name)) != NULL) {
147 if ((periph->flags & CAM_PERIPH_INVALID) != 0
148 && (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) == 0) {
149 periph->flags |= CAM_PERIPH_NEW_DEV_FOUND;
150 periph->deferred_callback = ac_callback;
151 periph->deferred_ac = code;
152 return (CAM_REQ_INPROG);
154 kprintf("cam_periph_alloc: attempt to re-allocate "
155 "valid device %s%d rejected\n",
156 periph->periph_name, periph->unit_number);
158 return (CAM_REQ_INVALID);
161 periph = kmalloc(sizeof(*periph), M_CAMPERIPH, M_INTWAIT | M_ZERO);
163 init_level++; /* 1 */
166 for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
167 if (strcmp((*p_drv)->driver_name, name) == 0)
172 sim = xpt_path_sim(path);
174 path_id = xpt_path_path_id(path);
175 target_id = xpt_path_target_id(path);
176 lun_id = xpt_path_lun_id(path);
177 cam_init_pinfo(&periph->pinfo);
178 periph->periph_start = periph_start;
179 periph->periph_dtor = periph_dtor;
180 periph->periph_oninval = periph_oninvalidate;
182 periph->periph_name = name;
183 periph->unit_number = camperiphunit(*p_drv, sim, path_id,
185 periph->immediate_priority = CAM_PRIORITY_NONE;
186 periph->refcount = 0;
188 SLIST_INIT(&periph->ccb_list);
189 status = xpt_create_path(&path, periph, path_id, target_id, lun_id);
190 if (status != CAM_REQ_CMP)
193 init_level++; /* 2 */
196 status = xpt_add_periph(periph);
198 if (status != CAM_REQ_CMP)
201 cur_periph = TAILQ_FIRST(&(*p_drv)->units);
202 while (cur_periph != NULL
203 && cur_periph->unit_number < periph->unit_number)
204 cur_periph = TAILQ_NEXT(cur_periph, unit_links);
206 if (cur_periph != NULL)
207 TAILQ_INSERT_BEFORE(cur_periph, periph, unit_links);
209 TAILQ_INSERT_TAIL(&(*p_drv)->units, periph, unit_links);
210 (*p_drv)->generation++;
215 status = periph_ctor(periph, arg);
217 if (status == CAM_REQ_CMP)
221 switch (init_level) {
223 /* Initialized successfully */
227 TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
228 xpt_remove_periph(periph);
234 CAM_SIM_UNLOCK(sim); /* sim was retrieved from path */
236 kfree(periph, M_CAMPERIPH);
239 /* No cleanup to perform. */
242 panic("cam_periph_alloc: Unknown init level");
248 * Find a peripheral structure with the specified path, target, lun,
249 * and (optionally) type. If the name is NULL, this function will return
250 * the first peripheral driver that matches the specified path.
253 cam_periph_find(struct cam_path *path, char *name)
255 struct periph_driver **p_drv;
256 struct cam_periph *periph;
259 for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
260 if (name != NULL && (strcmp((*p_drv)->driver_name, name) != 0))
263 TAILQ_FOREACH(periph, &(*p_drv)->units, unit_links) {
264 if (xpt_path_comp(periph->path, path) == 0) {
279 cam_periph_acquire(struct cam_periph *periph)
282 return(CAM_REQ_CMP_ERR);
292 * Release the peripheral. The XPT is not locked and the SIM may or may
293 * not be locked on entry.
295 * The last release on a peripheral marked invalid frees it. In this
296 * case we must be sure to hold both the XPT lock and the SIM lock,
297 * requiring a bit of fancy footwork if the SIM lock already happens
301 cam_periph_release(struct cam_periph *periph)
308 * First try the critical path case
312 if ((periph->flags & CAM_PERIPH_INVALID) == 0 ||
313 periph->refcount != 1) {
320 * Otherwise we also need to free the peripheral and must
321 * acquire the sim lock and xpt lock in the correct order
324 * The condition must be re-checked after the locks have
328 doun = CAM_SIM_COND_LOCK(sim);
331 if ((periph->flags & CAM_PERIPH_INVALID) &&
332 periph->refcount == 0) {
333 camperiphfree(periph);
336 CAM_SIM_COND_UNLOCK(sim, doun);
342 cam_periph_hold(struct cam_periph *periph, int flags)
346 sim_lock_assert_owned(periph->sim->lock);
349 * Increment the reference count on the peripheral
350 * while we wait for our lock attempt to succeed
351 * to ensure the peripheral doesn't disappear out
352 * from user us while we sleep.
355 if (cam_periph_acquire(periph) != CAM_REQ_CMP)
358 while ((periph->flags & CAM_PERIPH_LOCKED) != 0) {
359 periph->flags |= CAM_PERIPH_LOCK_WANTED;
360 if ((error = sim_lock_sleep(periph, flags, "caplck", 0,
361 periph->sim->lock)) != 0) {
362 cam_periph_release(periph);
367 periph->flags |= CAM_PERIPH_LOCKED;
372 cam_periph_unhold(struct cam_periph *periph, int unlock)
376 sim_lock_assert_owned(periph->sim->lock);
377 periph->flags &= ~CAM_PERIPH_LOCKED;
378 if ((periph->flags & CAM_PERIPH_LOCK_WANTED) != 0) {
379 periph->flags &= ~CAM_PERIPH_LOCK_WANTED;
384 cam_periph_release(periph);
385 /* periph may be garbage now */
388 cam_periph_release(periph);
393 * Look for the next unit number that is not currently in use for this
394 * peripheral type starting at "newunit". Also exclude unit numbers that
395 * are reserved by for future "hardwiring" unless we already know that this
396 * is a potential wired device. Only assume that the device is "wired" the
397 * first time through the loop since after that we'll be looking at unit
398 * numbers that did not match a wiring entry.
401 camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired,
402 path_id_t pathid, target_id_t target, lun_id_t lun)
404 struct cam_periph *periph;
405 char *periph_name, *strval;
409 periph_name = p_drv->driver_name;
412 for (periph = TAILQ_FIRST(&p_drv->units);
413 periph != NULL && periph->unit_number != newunit;
414 periph = TAILQ_NEXT(periph, unit_links))
417 if (periph != NULL && periph->unit_number == newunit) {
419 xpt_print(periph->path, "Duplicate Wired "
421 xpt_print(periph->path, "Second device (%s "
422 "device at scbus%d target %d lun %d) will "
423 "not be wired\n", periph_name, pathid,
433 * Don't match entries like "da 4" as a wired down
434 * device, but do match entries like "da 4 target 5"
435 * or even "da 4 scbus 1".
438 while ((i = resource_locate(i, periph_name)) != -1) {
439 dname = resource_query_name(i);
440 dunit = resource_query_unit(i);
441 /* if no "target" and no specific scbus, skip */
442 if (resource_int_value(dname, dunit, "target", &val) &&
443 (resource_string_value(dname, dunit, "at",&strval)||
444 strcmp(strval, "scbus") == 0))
446 if (newunit == dunit)
456 camperiphunit(struct periph_driver *p_drv,
457 struct cam_sim *sim, path_id_t pathid,
458 target_id_t target, lun_id_t lun)
461 int hit, i, val, dunit;
463 char pathbuf[32], *strval, *periph_name;
467 periph_name = p_drv->driver_name;
468 ksnprintf(pathbuf, sizeof(pathbuf), "scbus%d", pathid);
470 for (hit = 0; (i = resource_locate(i, periph_name)) != -1; hit = 0) {
471 dname = resource_query_name(i);
472 dunit = resource_query_unit(i);
473 if (resource_string_value(dname, dunit, "at", &strval) == 0) {
474 if (strcmp(strval, pathbuf) != 0)
478 if (resource_int_value(dname, dunit, "target", &val) == 0) {
483 if (resource_int_value(dname, dunit, "lun", &val) == 0) {
495 * If no wired units are in the kernel config do an auto unit
496 * start selection. We want usb mass storage out of the way
497 * so it doesn't steal low numbered da%d slots from ahci, sili,
498 * or other scsi attachments.
500 if (hit == 0 && sim) {
501 if (strncmp(sim->sim_name, "umass", 4) == 0 && unit < 8)
506 * Either start from 0 looking for the next unit or from
507 * the unit number given in the resource config. This way,
508 * if we have wildcard matches, we don't return the same
511 unit = camperiphnextunit(p_drv, unit, /*wired*/hit, pathid,
518 cam_periph_invalidate(struct cam_periph *periph)
521 * We only call this routine the first time a peripheral is
524 if (((periph->flags & CAM_PERIPH_INVALID) == 0)
525 && (periph->periph_oninval != NULL))
526 periph->periph_oninval(periph);
528 periph->flags |= CAM_PERIPH_INVALID;
529 periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
532 if (periph->refcount == 0)
533 camperiphfree(periph);
534 else if (periph->refcount < 0)
535 kprintf("cam_invalidate_periph: refcount < 0!!\n");
540 camperiphfree(struct cam_periph *periph)
542 struct periph_driver **p_drv;
544 for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
545 if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
549 if (*p_drv == NULL) {
550 kprintf("camperiphfree: attempt to free non-existent periph\n");
554 TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
555 (*p_drv)->generation++;
558 if (periph->periph_dtor != NULL)
559 periph->periph_dtor(periph);
560 xpt_remove_periph(periph);
562 if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) {
566 switch (periph->deferred_ac) {
567 case AC_FOUND_DEVICE:
568 ccb.ccb_h.func_code = XPT_GDEV_TYPE;
569 xpt_setup_ccb(&ccb.ccb_h, periph->path, /*priority*/ 1);
573 case AC_PATH_REGISTERED:
574 ccb.ccb_h.func_code = XPT_PATH_INQ;
575 xpt_setup_ccb(&ccb.ccb_h, periph->path, /*priority*/ 1);
583 periph->deferred_callback(NULL, periph->deferred_ac,
586 xpt_free_path(periph->path);
587 kfree(periph, M_CAMPERIPH);
592 * Map user virtual pointers into kernel virtual address space, so we can
593 * access the memory. This won't work on physical pointers, for now it's
594 * up to the caller to check for that. (XXX KDM -- should we do that here
595 * instead?) This also only works for up to MAXPHYS memory. Since we use
596 * buffers to map stuff in and out, we're limited to the buffer size.
599 cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo)
601 buf_cmd_t cmd[CAM_PERIPH_MAXMAPS];
602 u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS];
603 u_int32_t lengths[CAM_PERIPH_MAXMAPS];
609 switch(ccb->ccb_h.func_code) {
611 if (ccb->cdm.match_buf_len == 0) {
612 kprintf("cam_periph_mapmem: invalid match buffer "
616 if (ccb->cdm.pattern_buf_len > 0) {
617 data_ptrs[0] = (void *)&ccb->cdm.patterns;
618 lengths[0] = ccb->cdm.pattern_buf_len;
619 mapinfo->dirs[0] = CAM_DIR_OUT;
620 data_ptrs[1] = (void *)&ccb->cdm.matches;
621 lengths[1] = ccb->cdm.match_buf_len;
622 mapinfo->dirs[1] = CAM_DIR_IN;
625 data_ptrs[0] = (void *)&ccb->cdm.matches;
626 lengths[0] = ccb->cdm.match_buf_len;
627 mapinfo->dirs[0] = CAM_DIR_IN;
632 case XPT_CONT_TARGET_IO:
633 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE)
636 data_ptrs[0] = &ccb->csio.data_ptr;
637 lengths[0] = ccb->csio.dxfer_len;
638 mapinfo->dirs[0] = ccb->ccb_h.flags & CAM_DIR_MASK;
643 break; /* NOTREACHED */
647 * Check the transfer length and permissions first, so we don't
648 * have to unmap any previously mapped buffers.
650 for (i = 0; i < numbufs; i++) {
652 * Its kinda bogus, we need a R+W command. For now the
653 * buffer needs some sort of command. Use BUF_CMD_WRITE
654 * to indicate a write and BUF_CMD_READ to indicate R+W.
656 cmd[i] = BUF_CMD_WRITE;
659 * The userland data pointer passed in may not be page
660 * aligned. vmapbuf() truncates the address to a page
661 * boundary, so if the address isn't page aligned, we'll
662 * need enough space for the given transfer length, plus
663 * whatever extra space is necessary to make it to the page
667 (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)) > MAXPHYS){
668 kprintf("cam_periph_mapmem: attempt to map %lu bytes, "
669 "which is greater than MAXPHYS(%d)\n",
671 (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)),
676 if (mapinfo->dirs[i] & CAM_DIR_OUT) {
677 if (!useracc(*data_ptrs[i], lengths[i],
679 kprintf("cam_periph_mapmem: error, "
680 "address %p, length %lu isn't "
681 "user accessible for READ\n",
682 (void *)*data_ptrs[i],
688 if (mapinfo->dirs[i] & CAM_DIR_IN) {
689 cmd[i] = BUF_CMD_READ;
690 if (!useracc(*data_ptrs[i], lengths[i],
692 kprintf("cam_periph_mapmem: error, "
693 "address %p, length %lu isn't "
694 "user accessible for WRITE\n",
695 (void *)*data_ptrs[i],
704 for (i = 0; i < numbufs; i++) {
708 bp = getpbuf_kva(NULL);
710 /* save the original user pointer */
711 mapinfo->saved_ptrs[i] = *data_ptrs[i];
717 * Require 16-byte alignment and bounce if we don't get it.
718 * (NATA does not realign buffers for DMA).
720 if ((intptr_t)*data_ptrs[i] & 15)
721 mapinfo->bounce[i] = 1;
723 mapinfo->bounce[i] = 0;
726 * Map the user buffer into kernel memory. If the user
727 * buffer is not aligned we have to allocate a bounce buffer
730 if (mapinfo->bounce[i]) {
731 bp->b_data = bp->b_kvabase;
732 bp->b_bcount = lengths[i];
733 vm_hold_load_pages(bp, (vm_offset_t)bp->b_data,
734 (vm_offset_t)bp->b_data + bp->b_bcount);
735 if (mapinfo->dirs[i] & CAM_DIR_OUT) {
736 error = copyin(*data_ptrs[i], bp->b_data, bp->b_bcount);
738 vm_hold_free_pages(bp, (vm_offset_t)bp->b_data, (vm_offset_t)bp->b_data + bp->b_bcount);
743 } else if (vmapbuf(bp, *data_ptrs[i], lengths[i]) < 0) {
744 kprintf("cam_periph_mapmem: error, "
745 "address %p, length %lu isn't "
746 "user accessible any more\n",
747 (void *)*data_ptrs[i],
755 cam_periph_unmapbufs(mapinfo, data_ptrs, i);
756 mapinfo->num_bufs_used -= i;
760 /* set our pointer to the new mapped area */
761 *data_ptrs[i] = bp->b_data;
764 mapinfo->num_bufs_used++;
771 * Unmap memory segments mapped into kernel virtual address space by
772 * cam_periph_mapmem().
775 cam_periph_unmapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo)
778 u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS];
780 if (mapinfo->num_bufs_used <= 0) {
781 /* allow ourselves to be swapped once again */
785 switch (ccb->ccb_h.func_code) {
787 numbufs = min(mapinfo->num_bufs_used, 2);
790 data_ptrs[0] = (void *)&ccb->cdm.matches;
792 data_ptrs[0] = (void *)&ccb->cdm.patterns;
793 data_ptrs[1] = (void *)&ccb->cdm.matches;
797 case XPT_CONT_TARGET_IO:
798 data_ptrs[0] = &ccb->csio.data_ptr;
799 numbufs = min(mapinfo->num_bufs_used, 1);
802 /* allow ourselves to be swapped once again */
804 break; /* NOTREACHED */
806 cam_periph_unmapbufs(mapinfo, data_ptrs, numbufs);
810 cam_periph_unmapbufs(struct cam_periph_map_info *mapinfo,
811 u_int8_t ***data_ptrs, int numbufs)
816 for (i = 0; i < numbufs; i++) {
819 /* Set the user's pointer back to the original value */
820 *data_ptrs[i] = mapinfo->saved_ptrs[i];
822 /* unmap the buffer */
823 if (mapinfo->bounce[i]) {
824 if (mapinfo->dirs[i] & CAM_DIR_IN) {
825 /* XXX return error */
826 copyout(bp->b_data, *data_ptrs[i],
829 vm_hold_free_pages(bp, (vm_offset_t)bp->b_data,
830 (vm_offset_t)bp->b_data + bp->b_bcount);
835 mapinfo->bp[i] = NULL;
840 cam_periph_getccb(struct cam_periph *periph, u_int32_t priority)
842 struct ccb_hdr *ccb_h;
844 sim_lock_assert_owned(periph->sim->lock);
845 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering cdgetccb\n"));
847 while (SLIST_FIRST(&periph->ccb_list) == NULL) {
848 if (periph->immediate_priority > priority)
849 periph->immediate_priority = priority;
850 xpt_schedule(periph, priority);
851 if ((SLIST_FIRST(&periph->ccb_list) != NULL)
852 && (SLIST_FIRST(&periph->ccb_list)->pinfo.priority == priority))
854 sim_lock_sleep(&periph->ccb_list, 0, "cgticb", 0,
858 ccb_h = SLIST_FIRST(&periph->ccb_list);
859 SLIST_REMOVE_HEAD(&periph->ccb_list, periph_links.sle);
860 return ((union ccb *)ccb_h);
864 cam_periph_ccbwait(union ccb *ccb)
868 sim = xpt_path_sim(ccb->ccb_h.path);
869 while ((ccb->ccb_h.pinfo.index != CAM_UNQUEUED_INDEX)
870 || ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG)) {
871 sim_lock_sleep(&ccb->ccb_h.cbfcnp, 0, "cbwait", 0, sim->lock);
876 cam_periph_ioctl(struct cam_periph *periph, int cmd, caddr_t addr,
877 int (*error_routine)(union ccb *ccb,
879 u_int32_t sense_flags))
889 ccb = cam_periph_getccb(periph, /* priority */ 1);
890 xpt_setup_ccb(&ccb->ccb_h,
893 ccb->ccb_h.func_code = XPT_GDEVLIST;
896 * Basically, the point of this is that we go through
897 * getting the list of devices, until we find a passthrough
898 * device. In the current version of the CAM code, the
899 * only way to determine what type of device we're dealing
900 * with is by its name.
904 ccb->cgdl.status = CAM_GDEVLIST_MORE_DEVS;
905 while (ccb->cgdl.status == CAM_GDEVLIST_MORE_DEVS) {
907 /* we want the next device in the list */
909 if (strncmp(ccb->cgdl.periph_name,
915 if ((ccb->cgdl.status == CAM_GDEVLIST_LAST_DEVICE) &&
917 ccb->cgdl.periph_name[0] = '\0';
918 ccb->cgdl.unit_number = 0;
923 /* copy the result back out */
924 bcopy(ccb, addr, sizeof(union ccb));
926 /* and release the ccb */
927 xpt_release_ccb(ccb);
938 cam_periph_runccb(union ccb *ccb,
939 int (*error_routine)(union ccb *ccb,
941 u_int32_t sense_flags),
942 cam_flags camflags, u_int32_t sense_flags,
949 sim = xpt_path_sim(ccb->ccb_h.path);
950 sim_lock_assert_owned(sim->lock);
953 * If the user has supplied a stats structure, and if we understand
954 * this particular type of ccb, record the transaction start.
956 if ((ds != NULL) && (ccb->ccb_h.func_code == XPT_SCSI_IO))
957 devstat_start_transaction(ds);
962 cam_periph_ccbwait(ccb);
963 if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)
965 else if (error_routine != NULL)
966 error = (*error_routine)(ccb, camflags, sense_flags);
970 } while (error == ERESTART);
972 if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
973 cam_release_devq(ccb->ccb_h.path,
977 /* getcount_only */ FALSE);
979 if ((ds != NULL) && (ccb->ccb_h.func_code == XPT_SCSI_IO))
980 devstat_end_transaction(ds,
982 ccb->csio.tag_action & 0xf,
983 ((ccb->ccb_h.flags & CAM_DIR_MASK) ==
984 CAM_DIR_NONE) ? DEVSTAT_NO_DATA :
985 (ccb->ccb_h.flags & CAM_DIR_OUT) ?
993 cam_freeze_devq(struct cam_path *path)
995 struct ccb_hdr ccb_h;
997 xpt_setup_ccb(&ccb_h, path, /*priority*/1);
998 ccb_h.func_code = XPT_NOOP;
999 ccb_h.flags = CAM_DEV_QFREEZE;
1000 xpt_action((union ccb *)&ccb_h);
1004 cam_release_devq(struct cam_path *path, u_int32_t relsim_flags,
1005 u_int32_t openings, u_int32_t timeout,
1008 struct ccb_relsim crs;
1010 xpt_setup_ccb(&crs.ccb_h, path,
1012 crs.ccb_h.func_code = XPT_REL_SIMQ;
1013 crs.ccb_h.flags = getcount_only ? CAM_DEV_QFREEZE : 0;
1014 crs.release_flags = relsim_flags;
1015 crs.openings = openings;
1016 crs.release_timeout = timeout;
1017 xpt_action((union ccb *)&crs);
1018 return (crs.qfrozen_cnt);
1021 #define saved_ccb_ptr ppriv_ptr0
1023 camperiphdone(struct cam_periph *periph, union ccb *done_ccb)
1025 union ccb *saved_ccb;
1029 struct scsi_start_stop_unit *scsi_cmd;
1030 u_int32_t relsim_flags, timeout;
1031 u_int32_t qfrozen_cnt;
1034 xpt_done_ccb = FALSE;
1035 status = done_ccb->ccb_h.status;
1036 frozen = (status & CAM_DEV_QFRZN) != 0;
1037 sense = (status & CAM_AUTOSNS_VALID) != 0;
1038 status &= CAM_STATUS_MASK;
1042 saved_ccb = (union ccb *)done_ccb->ccb_h.saved_ccb_ptr;
1045 * Unfreeze the queue once if it is already frozen..
1048 qfrozen_cnt = cam_release_devq(done_ccb->ccb_h.path,
1052 /*getcount_only*/0);
1059 * If we have successfully taken a device from the not
1060 * ready to ready state, re-scan the device and re-get
1061 * the inquiry information. Many devices (mostly disks)
1062 * don't properly report their inquiry information unless
1065 * If we manually retrieved sense into a CCB and got
1066 * something other than "NO SENSE" send the updated CCB
1067 * back to the client via xpt_done() to be processed via
1068 * the error recovery code again.
1070 if (done_ccb->ccb_h.func_code == XPT_SCSI_IO) {
1071 scsi_cmd = (struct scsi_start_stop_unit *)
1072 &done_ccb->csio.cdb_io.cdb_bytes;
1074 if (scsi_cmd->opcode == START_STOP_UNIT)
1075 xpt_async(AC_INQ_CHANGED,
1076 done_ccb->ccb_h.path, NULL);
1077 if (scsi_cmd->opcode == REQUEST_SENSE) {
1080 sense_key = saved_ccb->csio.sense_data.flags;
1081 sense_key &= SSD_KEY;
1082 if (sense_key != SSD_KEY_NO_SENSE) {
1083 saved_ccb->ccb_h.status |=
1086 xpt_print(saved_ccb->ccb_h.path,
1087 "Recovered Sense\n");
1088 scsi_sense_print(&saved_ccb->csio);
1089 cam_error_print(saved_ccb, CAM_ESF_ALL,
1092 xpt_done_ccb = TRUE;
1096 bcopy(done_ccb->ccb_h.saved_ccb_ptr, done_ccb,
1099 periph->flags &= ~CAM_PERIPH_RECOVERY_INPROG;
1101 if (xpt_done_ccb == FALSE)
1102 xpt_action(done_ccb);
1106 case CAM_SCSI_STATUS_ERROR:
1107 scsi_cmd = (struct scsi_start_stop_unit *)
1108 &done_ccb->csio.cdb_io.cdb_bytes;
1110 struct ccb_getdev cgd;
1111 struct scsi_sense_data *sense;
1112 int error_code, sense_key, asc, ascq;
1113 scsi_sense_action err_action;
1115 sense = &done_ccb->csio.sense_data;
1116 scsi_extract_sense(sense, &error_code,
1117 &sense_key, &asc, &ascq);
1120 * Grab the inquiry data for this device.
1122 xpt_setup_ccb(&cgd.ccb_h, done_ccb->ccb_h.path,
1124 cgd.ccb_h.func_code = XPT_GDEV_TYPE;
1125 xpt_action((union ccb *)&cgd);
1126 err_action = scsi_error_action(&done_ccb->csio,
1130 * If the error is "invalid field in CDB",
1131 * and the load/eject flag is set, turn the
1132 * flag off and try again. This is just in
1133 * case the drive in question barfs on the
1134 * load eject flag. The CAM code should set
1135 * the load/eject flag by default for
1140 * Should we check to see what the specific
1141 * scsi status is?? Or does it not matter
1142 * since we already know that there was an
1143 * error, and we know what the specific
1144 * error code was, and we know what the
1147 if ((scsi_cmd->opcode == START_STOP_UNIT) &&
1148 ((scsi_cmd->how & SSS_LOEJ) != 0) &&
1149 (asc == 0x24) && (ascq == 0x00) &&
1150 (done_ccb->ccb_h.retry_count > 0)) {
1152 scsi_cmd->how &= ~SSS_LOEJ;
1154 xpt_action(done_ccb);
1156 } else if ((done_ccb->ccb_h.retry_count > 1)
1157 && ((err_action & SS_MASK) != SS_FAIL)) {
1160 * In this case, the error recovery
1161 * command failed, but we've got
1162 * some retries left on it. Give
1163 * it another try unless this is an
1164 * unretryable error.
1167 /* set the timeout to .5 sec */
1169 RELSIM_RELEASE_AFTER_TIMEOUT;
1172 xpt_action(done_ccb);
1178 * Perform the final retry with the original
1179 * CCB so that final error processing is
1180 * performed by the owner of the CCB.
1182 bcopy(done_ccb->ccb_h.saved_ccb_ptr,
1183 done_ccb, sizeof(union ccb));
1185 periph->flags &= ~CAM_PERIPH_RECOVERY_INPROG;
1187 xpt_action(done_ccb);
1191 * Eh?? The command failed, but we don't
1192 * have any sense. What's up with that?
1193 * Fire the CCB again to return it to the
1196 bcopy(done_ccb->ccb_h.saved_ccb_ptr,
1197 done_ccb, sizeof(union ccb));
1199 periph->flags &= ~CAM_PERIPH_RECOVERY_INPROG;
1201 xpt_action(done_ccb);
1206 bcopy(done_ccb->ccb_h.saved_ccb_ptr, done_ccb,
1209 periph->flags &= ~CAM_PERIPH_RECOVERY_INPROG;
1211 xpt_action(done_ccb);
1216 /* decrement the retry count */
1218 * XXX This isn't appropriate in all cases. Restructure,
1219 * so that the retry count is only decremented on an
1220 * actual retry. Remeber that the orignal ccb had its
1221 * retry count dropped before entering recovery, so
1222 * doing it again is a bug.
1224 if (done_ccb->ccb_h.retry_count > 0)
1225 done_ccb->ccb_h.retry_count--;
1227 qfrozen_cnt = cam_release_devq(done_ccb->ccb_h.path,
1228 /*relsim_flags*/relsim_flags,
1231 /*getcount_only*/0);
1232 if (xpt_done_ccb == TRUE)
1233 (*done_ccb->ccb_h.cbfcnp)(periph, done_ccb);
1237 * Generic Async Event handler. Peripheral drivers usually
1238 * filter out the events that require personal attention,
1239 * and leave the rest to this function.
1242 cam_periph_async(struct cam_periph *periph, u_int32_t code,
1243 struct cam_path *path, void *arg)
1246 case AC_LOST_DEVICE:
1247 cam_periph_invalidate(periph);
1252 cam_periph_bus_settle(periph, scsi_delay);
1261 cam_periph_bus_settle(struct cam_periph *periph, u_int bus_settle)
1263 struct ccb_getdevstats cgds;
1265 xpt_setup_ccb(&cgds.ccb_h, periph->path, /*priority*/1);
1266 cgds.ccb_h.func_code = XPT_GDEV_STATS;
1267 xpt_action((union ccb *)&cgds);
1268 cam_periph_freeze_after_event(periph, &cgds.last_reset, bus_settle);
1272 cam_periph_freeze_after_event(struct cam_periph *periph,
1273 struct timeval* event_time, u_int duration_ms)
1275 struct timeval delta;
1276 struct timeval duration_tv;
1278 microuptime(&delta);
1279 timevalsub(&delta, event_time);
1280 duration_tv.tv_sec = duration_ms / 1000;
1281 duration_tv.tv_usec = (duration_ms % 1000) * 1000;
1282 if (timevalcmp(&delta, &duration_tv, <)) {
1283 timevalsub(&duration_tv, &delta);
1285 duration_ms = duration_tv.tv_sec * 1000;
1286 duration_ms += duration_tv.tv_usec / 1000;
1287 cam_freeze_devq(periph->path);
1288 cam_release_devq(periph->path,
1289 RELSIM_RELEASE_AFTER_TIMEOUT,
1291 /*timeout*/duration_ms,
1292 /*getcount_only*/0);
1298 camperiphscsistatuserror(union ccb *ccb, cam_flags camflags,
1299 u_int32_t sense_flags, union ccb *save_ccb,
1300 int *openings, u_int32_t *relsim_flags,
1305 switch (ccb->csio.scsi_status) {
1306 case SCSI_STATUS_OK:
1307 case SCSI_STATUS_COND_MET:
1308 case SCSI_STATUS_INTERMED:
1309 case SCSI_STATUS_INTERMED_COND_MET:
1312 case SCSI_STATUS_CMD_TERMINATED:
1313 case SCSI_STATUS_CHECK_COND:
1314 error = camperiphscsisenseerror(ccb,
1322 case SCSI_STATUS_QUEUE_FULL:
1325 struct ccb_getdevstats cgds;
1328 * First off, find out what the current
1329 * transaction counts are.
1331 xpt_setup_ccb(&cgds.ccb_h,
1334 cgds.ccb_h.func_code = XPT_GDEV_STATS;
1335 xpt_action((union ccb *)&cgds);
1338 * If we were the only transaction active, treat
1339 * the QUEUE FULL as if it were a BUSY condition.
1341 if (cgds.dev_active != 0) {
1345 * Reduce the number of openings to
1346 * be 1 less than the amount it took
1347 * to get a queue full bounded by the
1348 * minimum allowed tag count for this
1351 total_openings = cgds.dev_active + cgds.dev_openings;
1352 *openings = cgds.dev_active;
1353 if (*openings < cgds.mintags)
1354 *openings = cgds.mintags;
1355 if (*openings < total_openings)
1356 *relsim_flags = RELSIM_ADJUST_OPENINGS;
1359 * Some devices report queue full for
1360 * temporary resource shortages. For
1361 * this reason, we allow a minimum
1362 * tag count to be entered via a
1363 * quirk entry to prevent the queue
1364 * count on these devices from falling
1365 * to a pessimisticly low value. We
1366 * still wait for the next successful
1367 * completion, however, before queueing
1368 * more transactions to the device.
1370 *relsim_flags = RELSIM_RELEASE_AFTER_CMDCMPLT;
1375 xpt_print(ccb->ccb_h.path, "Queue Full\n");
1381 case SCSI_STATUS_BUSY:
1383 * Restart the queue after either another
1384 * command completes or a 1 second timeout.
1387 xpt_print(ccb->ccb_h.path, "Device Busy\n");
1389 if (ccb->ccb_h.retry_count > 0) {
1390 ccb->ccb_h.retry_count--;
1392 *relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT
1393 | RELSIM_RELEASE_AFTER_CMDCMPLT;
1399 case SCSI_STATUS_RESERV_CONFLICT:
1400 xpt_print(ccb->ccb_h.path, "Reservation Conflict\n");
1404 xpt_print(ccb->ccb_h.path, "SCSI Status 0x%x\n",
1405 ccb->csio.scsi_status);
1413 camperiphscsisenseerror(union ccb *ccb, cam_flags camflags,
1414 u_int32_t sense_flags, union ccb *save_ccb,
1415 int *openings, u_int32_t *relsim_flags,
1418 struct cam_periph *periph;
1421 periph = xpt_path_periph(ccb->ccb_h.path);
1422 if (periph->flags & CAM_PERIPH_RECOVERY_INPROG) {
1425 * If error recovery is already in progress, don't attempt
1426 * to process this error, but requeue it unconditionally
1427 * and attempt to process it once error recovery has
1428 * completed. This failed command is probably related to
1429 * the error that caused the currently active error recovery
1430 * action so our current recovery efforts should also
1431 * address this command. Be aware that the error recovery
1432 * code assumes that only one recovery action is in progress
1433 * on a particular peripheral instance at any given time
1434 * (e.g. only one saved CCB for error recovery) so it is
1435 * imperitive that we don't violate this assumption.
1439 scsi_sense_action err_action;
1440 struct ccb_getdev cgd;
1441 const char *action_string;
1442 union ccb* print_ccb;
1444 /* A description of the error recovery action performed */
1445 action_string = NULL;
1448 * The location of the orignal ccb
1449 * for sense printing purposes.
1454 * Grab the inquiry data for this device.
1456 xpt_setup_ccb(&cgd.ccb_h, ccb->ccb_h.path, /*priority*/ 1);
1457 cgd.ccb_h.func_code = XPT_GDEV_TYPE;
1458 xpt_action((union ccb *)&cgd);
1460 if ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)
1461 err_action = scsi_error_action(&ccb->csio,
1464 else if ((ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0)
1465 err_action = SS_REQSENSE;
1467 err_action = SS_RETRY|SSQ_DECREMENT_COUNT|EIO;
1469 error = err_action & SS_ERRMASK;
1472 * If the recovery action will consume a retry,
1473 * make sure we actually have retries available.
1475 if ((err_action & SSQ_DECREMENT_COUNT) != 0) {
1476 if (ccb->ccb_h.retry_count > 0)
1477 ccb->ccb_h.retry_count--;
1479 action_string = "Retries Exhausted";
1480 goto sense_error_done;
1484 if ((err_action & SS_MASK) >= SS_START) {
1486 * Do common portions of commands that
1487 * use recovery CCBs.
1489 if (save_ccb == NULL) {
1490 action_string = "No recovery CCB supplied";
1491 goto sense_error_done;
1493 bcopy(ccb, save_ccb, sizeof(*save_ccb));
1494 print_ccb = save_ccb;
1495 periph->flags |= CAM_PERIPH_RECOVERY_INPROG;
1498 switch (err_action & SS_MASK) {
1500 action_string = "No Recovery Action Needed";
1504 action_string = "Retrying Command (per Sense Data)";
1508 action_string = "Unretryable error";
1515 * Send a start unit command to the device, and
1516 * then retry the command.
1518 action_string = "Attempting to Start Unit";
1521 * Check for removable media and set
1522 * load/eject flag appropriately.
1524 if (SID_IS_REMOVABLE(&cgd.inq_data))
1529 scsi_start_stop(&ccb->csio,
1543 * Send a Test Unit Ready to the device.
1544 * If the 'many' flag is set, we send 120
1545 * test unit ready commands, one every half
1546 * second. Otherwise, we just send one TUR.
1547 * We only want to do this if the retry
1548 * count has not been exhausted.
1552 if ((err_action & SSQ_MANY) != 0) {
1553 action_string = "Polling device for readiness";
1556 action_string = "Testing device for readiness";
1559 scsi_test_unit_ready(&ccb->csio,
1567 * Accomplish our 500ms delay by deferring
1568 * the release of our device queue appropriately.
1570 *relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT;
1577 * Send a Request Sense to the device. We
1578 * assume that we are in a contingent allegiance
1579 * condition so we do not tag this request.
1581 scsi_request_sense(&ccb->csio, /*retries*/1,
1583 &save_ccb->csio.sense_data,
1584 sizeof(save_ccb->csio.sense_data),
1585 CAM_TAG_ACTION_NONE,
1586 /*sense_len*/SSD_FULL_SIZE,
1591 panic("Unhandled error action %x", err_action);
1594 if ((err_action & SS_MASK) >= SS_START) {
1596 * Drop the priority to 0 so that the recovery
1597 * CCB is the first to execute. Freeze the queue
1598 * after this command is sent so that we can
1599 * restore the old csio and have it queued in
1600 * the proper order before we release normal
1601 * transactions to the device.
1603 ccb->ccb_h.pinfo.priority = 0;
1604 ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
1605 ccb->ccb_h.saved_ccb_ptr = save_ccb;
1610 if ((err_action & SSQ_PRINT_SENSE) != 0
1611 && (ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0) {
1612 cam_error_print(print_ccb, CAM_ESF_ALL, CAM_EPF_ALL);
1613 xpt_print_path(ccb->ccb_h.path);
1615 scsi_sense_print(&print_ccb->csio);
1616 kprintf("%s\n", action_string);
1623 * Generic error handler. Peripheral drivers usually filter
1624 * out the errors that they handle in a unique mannor, then
1625 * call this function.
1628 cam_periph_error(union ccb *ccb, cam_flags camflags,
1629 u_int32_t sense_flags, union ccb *save_ccb)
1631 const char *action_string;
1634 int error, printed = 0;
1636 u_int32_t relsim_flags;
1637 u_int32_t timeout = 0;
1639 action_string = NULL;
1640 status = ccb->ccb_h.status;
1641 frozen = (status & CAM_DEV_QFRZN) != 0;
1642 status &= CAM_STATUS_MASK;
1643 openings = relsim_flags = 0;
1649 case CAM_SCSI_STATUS_ERROR:
1650 error = camperiphscsistatuserror(ccb,
1658 case CAM_AUTOSENSE_FAIL:
1659 xpt_print(ccb->ccb_h.path, "AutoSense Failed\n");
1660 error = EIO; /* we have to kill the command */
1662 case CAM_REQ_CMP_ERR:
1663 if (bootverbose && printed == 0) {
1664 xpt_print(ccb->ccb_h.path,
1665 "Request completed with CAM_REQ_CMP_ERR\n");
1669 case CAM_CMD_TIMEOUT:
1670 if (bootverbose && printed == 0) {
1671 xpt_print(ccb->ccb_h.path, "Command timed out\n");
1675 case CAM_UNEXP_BUSFREE:
1676 if (bootverbose && printed == 0) {
1677 xpt_print(ccb->ccb_h.path, "Unexpected Bus Free\n");
1681 case CAM_UNCOR_PARITY:
1682 if (bootverbose && printed == 0) {
1683 xpt_print(ccb->ccb_h.path,
1684 "Uncorrected Parity Error\n");
1688 case CAM_DATA_RUN_ERR:
1689 if (bootverbose && printed == 0) {
1690 xpt_print(ccb->ccb_h.path, "Data Overrun\n");
1693 error = EIO; /* we have to kill the command */
1694 /* decrement the number of retries */
1695 if (ccb->ccb_h.retry_count > 0) {
1696 ccb->ccb_h.retry_count--;
1699 action_string = "Retries Exhausted";
1705 case CAM_MSG_REJECT_REC:
1706 /* XXX Don't know that these are correct */
1709 case CAM_SEL_TIMEOUT:
1711 struct cam_path *newpath;
1713 if ((camflags & CAM_RETRY_SELTO) != 0) {
1714 if (ccb->ccb_h.retry_count > 0) {
1716 ccb->ccb_h.retry_count--;
1718 if (bootverbose && printed == 0) {
1719 xpt_print(ccb->ccb_h.path,
1720 "Selection Timeout\n");
1725 * Wait a bit to give the device
1726 * time to recover before we try again.
1728 relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT;
1729 timeout = periph_selto_delay;
1734 /* Should we do more if we can't create the path?? */
1735 if (xpt_create_path(&newpath, xpt_path_periph(ccb->ccb_h.path),
1736 xpt_path_path_id(ccb->ccb_h.path),
1737 xpt_path_target_id(ccb->ccb_h.path),
1738 CAM_LUN_WILDCARD) != CAM_REQ_CMP)
1742 * Let peripheral drivers know that this device has gone
1745 xpt_async(AC_LOST_DEVICE, newpath, NULL);
1746 xpt_free_path(newpath);
1749 case CAM_REQ_INVALID:
1750 case CAM_PATH_INVALID:
1751 case CAM_DEV_NOT_THERE:
1753 case CAM_PROVIDE_FAIL:
1754 case CAM_REQ_TOO_BIG:
1755 case CAM_LUN_INVALID:
1756 case CAM_TID_INVALID:
1759 case CAM_SCSI_BUS_RESET:
1762 * Commands that repeatedly timeout and cause these
1763 * kinds of error recovery actions, should return
1764 * CAM_CMD_TIMEOUT, which allows us to safely assume
1765 * that this command was an innocent bystander to
1766 * these events and should be unconditionally
1769 if (bootverbose && printed == 0) {
1770 xpt_print_path(ccb->ccb_h.path);
1771 if (status == CAM_BDR_SENT)
1772 kprintf("Bus Device Reset sent\n");
1774 kprintf("Bus Reset issued\n");
1778 case CAM_REQUEUE_REQ:
1779 /* Unconditional requeue */
1781 if (bootverbose && printed == 0) {
1782 xpt_print(ccb->ccb_h.path, "Request Requeued\n");
1786 case CAM_RESRC_UNAVAIL:
1787 /* Wait a bit for the resource shortage to abate. */
1788 timeout = periph_noresrc_delay;
1792 /* Wait a bit for the busy condition to abate. */
1793 timeout = periph_busy_delay;
1795 relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT;
1798 /* decrement the number of retries */
1799 if (ccb->ccb_h.retry_count > 0) {
1800 ccb->ccb_h.retry_count--;
1802 if (bootverbose && printed == 0) {
1803 xpt_print(ccb->ccb_h.path, "CAM Status 0x%x\n",
1809 action_string = "Retries Exhausted";
1814 /* Attempt a retry */
1815 if (error == ERESTART || error == 0) {
1817 ccb->ccb_h.status &= ~CAM_DEV_QFRZN;
1819 if (error == ERESTART) {
1820 action_string = "Retrying Command";
1825 cam_release_devq(ccb->ccb_h.path,
1829 /*getcount_only*/0);
1833 * If we have an error and are booting verbosely, whine
1834 * *unless* this was a non-retryable selection timeout.
1836 if (error != 0 && bootverbose &&
1837 !(status == CAM_SEL_TIMEOUT && (camflags & CAM_RETRY_SELTO) == 0)) {
1840 if (action_string == NULL)
1841 action_string = "Unretryable Error";
1842 if (error != ERESTART) {
1843 xpt_print(ccb->ccb_h.path, "error %d\n", error);
1845 xpt_print(ccb->ccb_h.path, "%s\n", action_string);