Lines Matching defs:periph

72 static	void		camperiphdone(struct cam_periph *periph, 
74 static void camperiphfree(struct cam_periph *periph);
99 static MALLOC_DEFINE(M_CAMPERIPH, "CAM periph", "CAM peripheral buffers");
159 printf("CAM periph driver '%s' doesn't have deinit.\n",
203 struct cam_periph *periph;
219 if ((periph = cam_periph_find(path, name)) != NULL) {
220 if ((periph->flags & CAM_PERIPH_INVALID) != 0
221 && (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) == 0) {
222 periph->flags |= CAM_PERIPH_NEW_DEV_FOUND;
223 periph->deferred_callback = ac_callback;
224 periph->deferred_ac = code;
229 "refcount %d\n", periph->periph_name,
230 periph->unit_number, periph->flags,
231 periph->refcount);
236 periph = (struct cam_periph *)malloc(sizeof(*periph), M_CAMPERIPH,
239 if (periph == NULL)
248 periph->periph_start = periph_start;
249 periph->periph_dtor = periph_dtor;
250 periph->periph_oninval = periph_oninvalidate;
251 periph->type = type;
252 periph->periph_name = name;
253 periph->scheduled_priority = CAM_PRIORITY_NONE;
254 periph->immediate_priority = CAM_PRIORITY_NONE;
255 periph->refcount = 1; /* Dropped by invalidation. */
256 periph->sim = sim;
257 SLIST_INIT(&periph->ccb_list);
258 status = xpt_create_path(&path, periph, path_id, target_id, lun_id);
261 periph->path = path;
269 printf("cam_periph_alloc: invalid periph name '%s'\n", name);
271 xpt_free_path(periph->path);
272 free(periph, M_CAMPERIPH);
275 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,
283 ("duplicate units on periph list"));
284 TAILQ_INSERT_BEFORE(cur_periph, periph, unit_links);
286 TAILQ_INSERT_TAIL(&(*p_drv)->units, periph, unit_links);
293 status = xpt_add_periph(periph);
298 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph created\n"));
300 status = periph_ctor(periph, arg);
311 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n"));
312 xpt_remove_periph(periph);
316 TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
318 xpt_free_path(periph->path);
321 free(periph, M_CAMPERIPH);
341 struct cam_periph *periph;
348 TAILQ_FOREACH(periph, &(*p_drv)->units, unit_links) {
349 if (xpt_path_comp(periph->path, path) == 0) {
351 cam_periph_assert(periph, MA_OWNED);
352 return(periph);
372 struct cam_periph *periph;
382 TAILQ_FOREACH(periph, &(*p_drv)->units, unit_links) {
383 if (xpt_path_comp(periph->path, path) != 0)
389 sbuf_printf(&local_sb, "%s%d", periph->periph_name,
390 periph->unit_number);
411 cam_periph_acquire(struct cam_periph *periph)
415 if (periph == NULL)
420 if ((periph->flags & CAM_PERIPH_INVALID) == 0) {
421 periph->refcount++;
430 cam_periph_doacquire(struct cam_periph *periph)
434 KASSERT(periph->refcount >= 1,
435 ("cam_periph_doacquire() with refcount == %d", periph->refcount));
436 periph->refcount++;
441 cam_periph_release_locked_buses(struct cam_periph *periph)
444 cam_periph_assert(periph, MA_OWNED);
445 KASSERT(periph->refcount >= 1, ("periph->refcount >= 1"));
446 if (--periph->refcount == 0)
447 camperiphfree(periph);
451 cam_periph_release_locked(struct cam_periph *periph)
454 if (periph == NULL)
458 cam_periph_release_locked_buses(periph);
463 cam_periph_release(struct cam_periph *periph)
467 if (periph == NULL)
470 cam_periph_assert(periph, MA_NOTOWNED);
471 mtx = cam_periph_mtx(periph);
473 cam_periph_release_locked(periph);
484 cam_periph_hold(struct cam_periph *periph, int priority)
495 if (cam_periph_acquire(periph) != 0)
498 cam_periph_assert(periph, MA_OWNED);
499 while ((periph->flags & CAM_PERIPH_LOCKED) != 0) {
500 periph->flags |= CAM_PERIPH_LOCK_WANTED;
501 if ((error = cam_periph_sleep(periph, periph, priority,
503 cam_periph_release_locked(periph);
506 if (periph->flags & CAM_PERIPH_INVALID) {
507 cam_periph_release_locked(periph);
512 periph->flags |= CAM_PERIPH_LOCKED;
517 cam_periph_unhold(struct cam_periph *periph)
520 cam_periph_assert(periph, MA_OWNED);
522 periph->flags &= ~CAM_PERIPH_LOCKED;
523 if ((periph->flags & CAM_PERIPH_LOCK_WANTED) != 0) {
524 periph->flags &= ~CAM_PERIPH_LOCK_WANTED;
525 wakeup(periph);
528 cam_periph_release_locked(periph);
532 cam_periph_hold_boot(struct cam_periph *periph)
535 root_mount_hold_token(periph->periph_name, &periph->periph_rootmount);
539 cam_periph_release_boot(struct cam_periph *periph)
542 root_mount_rel(&periph->periph_rootmount);
557 struct cam_periph *periph;
564 for (periph = TAILQ_FIRST(&p_drv->units);
565 periph != NULL && periph->unit_number != newunit;
566 periph = TAILQ_NEXT(periph, unit_links))
569 if (periph != NULL && periph->unit_number == newunit) {
571 xpt_print(periph->path, "Duplicate Wired "
573 xpt_print(periph->path, "Second device (%s "
667 cam_periph_invalidate(struct cam_periph *periph)
670 cam_periph_assert(periph, MA_OWNED);
675 if ((periph->flags & CAM_PERIPH_INVALID) != 0)
678 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n"));
679 if ((periph->flags & CAM_PERIPH_ANNOUNCED) && !rebooting) {
684 xpt_denounce_periph_sbuf(periph, &sb);
688 periph->flags |= CAM_PERIPH_INVALID;
689 periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
690 if (periph->periph_oninval != NULL)
691 periph->periph_oninval(periph);
692 cam_periph_release_locked(periph);
696 camperiphfree(struct cam_periph *periph)
701 cam_periph_assert(periph, MA_OWNED);
702 KASSERT(periph->periph_allocating == 0, ("%s%d: freed while allocating",
703 periph->periph_name, periph->unit_number));
705 if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
709 printf("camperiphfree: attempt to free non-existant periph\n");
728 periph->flags |= CAM_PERIPH_FREE;
748 if (periph->periph_dtor != NULL)
749 periph->periph_dtor(periph);
753 * remove the periph from the drv list before we call deferred_ac. The
754 * AC_FOUND_DEVICE callback won't create a new periph if it's still there.
758 TAILQ_REMOVE(&drv->units, periph, unit_links);
761 xpt_remove_periph(periph);
764 if ((periph->flags & CAM_PERIPH_ANNOUNCED) && !rebooting)
765 xpt_print(periph->path, "Periph destroyed\n");
767 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph destroyed\n"));
769 if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) {
774 switch (periph->deferred_ac) {
777 xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
782 xpt_path_inq(&ccb.cpi, periph->path);
789 periph->deferred_callback(NULL, periph->deferred_ac,
790 periph->path, arg);
792 xpt_free_path(periph->path);
793 free(periph, M_CAMPERIPH);
1112 cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr,
1126 ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
1174 cam_periph_done_panic(struct cam_periph *periph, union ccb *done_ccb)
1181 cam_periph_done(struct cam_periph *periph, union ccb *done_ccb)
1256 * without a periph lock held.
1263 * in the periph. cam_periph_error can reschedule the ccb by calling
1372 camperiphdone(struct cam_periph *periph, union ccb *done_ccb)
1431 if ((periph->flags & CAM_PERIPH_RECOVERY_WAIT) &&
1433 periph->flags &= ~CAM_PERIPH_RECOVERY_WAIT;
1435 periph->flags |= CAM_PERIPH_RECOVERY_WAIT_FAILED;
1460 periph->flags &= ~CAM_PERIPH_RECOVERY_INPROG;
1476 cam_periph_async(struct cam_periph *periph, uint32_t code,
1481 cam_periph_invalidate(periph);
1489 cam_periph_bus_settle(struct cam_periph *periph, u_int bus_settle)
1494 xpt_setup_ccb(&cgds.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
1497 cam_periph_freeze_after_event(periph, &cgds.last_reset, bus_settle);
1501 cam_periph_freeze_after_event(struct cam_periph *periph,
1519 cam_freeze_devq(periph->path);
1520 cam_release_devq(periph->path,
1535 struct cam_periph *periph;
1619 periph = xpt_path_periph(ccb->ccb_h.path);
1620 if (periph->flags & CAM_PERIPH_INVALID) {
1650 struct cam_periph *periph;
1660 periph = xpt_path_periph(ccb->ccb_h.path);
1662 if ((periph->flags & CAM_PERIPH_RECOVERY_INPROG) && !recoveryccb) {
1725 (periph->flags & CAM_PERIPH_INVALID) == 0)
1778 periph->flags |= CAM_PERIPH_RECOVERY_INPROG;
1812 if ((err_action & SSQ_MANY) != 0 && (periph->flags &
1814 periph->flags |= CAM_PERIPH_RECOVERY_WAIT;
1821 periph->flags |= CAM_PERIPH_RECOVERY_INPROG;
1874 struct cam_periph *periph;
1881 periph = xpt_path_periph(ccb->ccb_h.path);
1930 (periph->flags & CAM_PERIPH_INVALID) == 0) {
1971 if (periph->flags & CAM_PERIPH_INVALID) {
2002 if (periph->flags & CAM_PERIPH_INVALID) {
2058 if (xpt_create_path(&newpath, periph,
2117 struct cam_periph *periph;
2129 periph = xpt_path_periph(ccb->ccb_h.path);
2130 sbuf_printf(&sb, "device=%s%d ", periph->periph_name,
2131 periph->unit_number);
2211 devctl_notify("CAM", "periph", type, sbuf_data(&sb));
2218 * called with CTLFLAG_MPSAFE since we take periph lock.
2223 struct cam_periph *periph;
2226 periph = arg1;
2232 cam_periph_lock(periph);
2233 cam_periph_invalidate(periph);
2234 cam_periph_unlock(periph);