Lines Matching defs:periph

73 static	void		camperiphdone(struct cam_periph *periph, 
75 static void camperiphfree(struct cam_periph *periph);
100 static MALLOC_DEFINE(M_CAMPERIPH, "CAM periph", "CAM peripheral buffers");
160 printf("CAM periph driver '%s' doesn't have deinit.\n",
204 struct cam_periph *periph;
220 if ((periph = cam_periph_find(path, name)) != NULL) {
221 if ((periph->flags & CAM_PERIPH_INVALID) != 0
222 && (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) == 0) {
223 periph->flags |= CAM_PERIPH_NEW_DEV_FOUND;
224 periph->deferred_callback = ac_callback;
225 periph->deferred_ac = code;
230 "refcount %d\n", periph->periph_name,
231 periph->unit_number, periph->flags,
232 periph->refcount);
237 periph = (struct cam_periph *)malloc(sizeof(*periph), M_CAMPERIPH,
240 if (periph == NULL)
249 periph->periph_start = periph_start;
250 periph->periph_dtor = periph_dtor;
251 periph->periph_oninval = periph_oninvalidate;
252 periph->type = type;
253 periph->periph_name = name;
254 periph->scheduled_priority = CAM_PRIORITY_NONE;
255 periph->immediate_priority = CAM_PRIORITY_NONE;
256 periph->refcount = 1; /* Dropped by invalidation. */
257 periph->sim = sim;
258 SLIST_INIT(&periph->ccb_list);
259 status = xpt_create_path(&path, periph, path_id, target_id, lun_id);
262 periph->path = path;
270 printf("cam_periph_alloc: invalid periph name '%s'\n", name);
272 xpt_free_path(periph->path);
273 free(periph, M_CAMPERIPH);
276 periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id);
279 && cur_periph->unit_number < periph->unit_number)
282 KASSERT(cur_periph->unit_number != periph->unit_number, ("duplicate units on periph list"));
283 TAILQ_INSERT_BEFORE(cur_periph, periph, unit_links);
285 TAILQ_INSERT_TAIL(&(*p_drv)->units, periph, unit_links);
292 status = xpt_add_periph(periph);
297 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph created\n"));
299 status = periph_ctor(periph, arg);
310 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n"));
311 xpt_remove_periph(periph);
315 TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
317 xpt_free_path(periph->path);
320 free(periph, M_CAMPERIPH);
340 struct cam_periph *periph;
347 TAILQ_FOREACH(periph, &(*p_drv)->units, unit_links) {
348 if (xpt_path_comp(periph->path, path) == 0) {
350 cam_periph_assert(periph, MA_OWNED);
351 return(periph);
371 struct cam_periph *periph;
381 TAILQ_FOREACH(periph, &(*p_drv)->units, unit_links) {
382 if (xpt_path_comp(periph->path, path) != 0)
388 sbuf_printf(&local_sb, "%s%d", periph->periph_name,
389 periph->unit_number);
410 cam_periph_acquire(struct cam_periph *periph)
414 if (periph == NULL)
419 if ((periph->flags & CAM_PERIPH_INVALID) == 0) {
420 periph->refcount++;
429 cam_periph_doacquire(struct cam_periph *periph)
433 KASSERT(periph->refcount >= 1,
434 ("cam_periph_doacquire() with refcount == %d", periph->refcount));
435 periph->refcount++;
440 cam_periph_release_locked_buses(struct cam_periph *periph)
443 cam_periph_assert(periph, MA_OWNED);
444 KASSERT(periph->refcount >= 1, ("periph->refcount >= 1"));
445 if (--periph->refcount == 0)
446 camperiphfree(periph);
450 cam_periph_release_locked(struct cam_periph *periph)
453 if (periph == NULL)
457 cam_periph_release_locked_buses(periph);
462 cam_periph_release(struct cam_periph *periph)
466 if (periph == NULL)
469 cam_periph_assert(periph, MA_NOTOWNED);
470 mtx = cam_periph_mtx(periph);
472 cam_periph_release_locked(periph);
483 cam_periph_hold(struct cam_periph *periph, int priority)
494 if (cam_periph_acquire(periph) != 0)
497 cam_periph_assert(periph, MA_OWNED);
498 while ((periph->flags & CAM_PERIPH_LOCKED) != 0) {
499 periph->flags |= CAM_PERIPH_LOCK_WANTED;
500 if ((error = cam_periph_sleep(periph, periph, priority,
502 cam_periph_release_locked(periph);
505 if (periph->flags & CAM_PERIPH_INVALID) {
506 cam_periph_release_locked(periph);
511 periph->flags |= CAM_PERIPH_LOCKED;
516 cam_periph_unhold(struct cam_periph *periph)
519 cam_periph_assert(periph, MA_OWNED);
521 periph->flags &= ~CAM_PERIPH_LOCKED;
522 if ((periph->flags & CAM_PERIPH_LOCK_WANTED) != 0) {
523 periph->flags &= ~CAM_PERIPH_LOCK_WANTED;
524 wakeup(periph);
527 cam_periph_release_locked(periph);
542 struct cam_periph *periph;
549 for (periph = TAILQ_FIRST(&p_drv->units);
550 periph != NULL && periph->unit_number != newunit;
551 periph = TAILQ_NEXT(periph, unit_links))
554 if (periph != NULL && periph->unit_number == newunit) {
556 xpt_print(periph->path, "Duplicate Wired "
558 xpt_print(periph->path, "Second device (%s "
643 cam_periph_invalidate(struct cam_periph *periph)
646 cam_periph_assert(periph, MA_OWNED);
651 if ((periph->flags & CAM_PERIPH_INVALID) != 0)
654 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n"));
655 if ((periph->flags & CAM_PERIPH_ANNOUNCED) && !rebooting) {
660 xpt_denounce_periph_sbuf(periph, &sb);
664 periph->flags |= CAM_PERIPH_INVALID;
665 periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
666 if (periph->periph_oninval != NULL)
667 periph->periph_oninval(periph);
668 cam_periph_release_locked(periph);
672 camperiphfree(struct cam_periph *periph)
677 cam_periph_assert(periph, MA_OWNED);
678 KASSERT(periph->periph_allocating == 0, ("%s%d: freed while allocating",
679 periph->periph_name, periph->unit_number));
681 if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
685 printf("camperiphfree: attempt to free non-existant periph\n");
704 periph->flags |= CAM_PERIPH_FREE;
724 if (periph->periph_dtor != NULL)
725 periph->periph_dtor(periph);
729 * remove the periph from the drv list before we call deferred_ac. The
730 * AC_FOUND_DEVICE callback won't create a new periph if it's still there.
734 TAILQ_REMOVE(&drv->units, periph, unit_links);
737 xpt_remove_periph(periph);
740 if ((periph->flags & CAM_PERIPH_ANNOUNCED) && !rebooting)
741 xpt_print(periph->path, "Periph destroyed\n");
743 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n"));
745 if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) {
749 switch (periph->deferred_ac) {
752 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
757 xpt_path_inq(&ccb.cpi, periph->path);
764 periph->deferred_callback(NULL, periph->deferred_ac,
765 periph->path, arg);
767 xpt_free_path(periph->path);
768 free(periph, M_CAMPERIPH);
1096 cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr,
1109 ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
1157 cam_periph_done_panic(struct cam_periph *periph, union ccb *done_ccb)
1164 cam_periph_done(struct cam_periph *periph, union ccb *done_ccb)
1239 * without a periph lock held.
1246 * in the periph. cam_periph_error can reschedule the ccb by calling
1348 camperiphdone(struct cam_periph *periph, union ccb *done_ccb)
1406 if ((periph->flags & CAM_PERIPH_RECOVERY_WAIT) &&
1408 periph->flags &= ~CAM_PERIPH_RECOVERY_WAIT;
1410 periph->flags |= CAM_PERIPH_RECOVERY_WAIT_FAILED;
1426 periph->flags &= ~CAM_PERIPH_RECOVERY_INPROG;
1442 cam_periph_async(struct cam_periph *periph, u_int32_t code,
1447 cam_periph_invalidate(periph);
1455 cam_periph_bus_settle(struct cam_periph *periph, u_int bus_settle)
1459 xpt_setup_ccb(&cgds.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
1462 cam_periph_freeze_after_event(periph, &cgds.last_reset, bus_settle);
1466 cam_periph_freeze_after_event(struct cam_periph *periph,
1484 cam_freeze_devq(periph->path);
1485 cam_release_devq(periph->path,
1500 struct cam_periph *periph;
1583 periph = xpt_path_periph(ccb->ccb_h.path);
1584 if (periph->flags & CAM_PERIPH_INVALID) {
1614 struct cam_periph *periph;
1623 periph = xpt_path_periph(ccb->ccb_h.path);
1625 if ((periph->flags & CAM_PERIPH_RECOVERY_INPROG) && !recoveryccb) {
1687 (periph->flags & CAM_PERIPH_INVALID) == 0)
1734 periph->flags |= CAM_PERIPH_RECOVERY_INPROG;
1768 if ((err_action & SSQ_MANY) != 0 && (periph->flags &
1770 periph->flags |= CAM_PERIPH_RECOVERY_WAIT;
1777 periph->flags |= CAM_PERIPH_RECOVERY_INPROG;
1830 struct cam_periph *periph;
1837 periph = xpt_path_periph(ccb->ccb_h.path);
1884 (periph->flags & CAM_PERIPH_INVALID) == 0) {
1925 if (periph->flags & CAM_PERIPH_INVALID) {
1954 if (periph->flags & CAM_PERIPH_INVALID) {
2010 if (xpt_create_path(&newpath, periph,
2069 struct cam_periph *periph;
2081 periph = xpt_path_periph(ccb->ccb_h.path);
2082 sbuf_printf(&sb, "device=%s%d ", periph->periph_name,
2083 periph->unit_number);
2133 devctl_notify("CAM", "periph", type, sbuf_data(&sb));
2140 * called with CTLFLAG_MPSAFE since we take periph lock.
2145 struct cam_periph *periph;
2148 periph = arg1;
2154 cam_periph_lock(periph);
2155 cam_periph_invalidate(periph);
2156 cam_periph_unlock(periph);