Lines Matching defs:periph

221  *	Insert a periph into the channel.
224 scsipi_insert_periph(struct scsipi_channel *chan, struct scsipi_periph *periph)
228 hash = scsipi_chan_periph_hash(periph->periph_target,
229 periph->periph_lun);
232 LIST_INSERT_HEAD(&chan->chan_periphtab[hash], periph, periph_hash);
239 * Remove a periph from the channel.
243 struct scsipi_periph *periph)
246 LIST_REMOVE(periph, periph_hash);
252 * Lookup a periph on the specified channel.
257 struct scsipi_periph *periph;
268 LIST_FOREACH(periph, &chan->chan_periphtab[hash], periph_hash) {
269 if (periph->periph_target == target &&
270 periph->periph_lun == lun)
276 return periph;
379 struct scsipi_periph *periph = xs->xs_periph;
383 KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
387 bit = ffs(periph->periph_freetags[word]);
393 scsipi_printaddr(periph);
400 periph->periph_freetags[word] &= ~(1U << bit);
404 if (tag >= periph->periph_openings) {
405 scsipi_printaddr(periph);
407 tag, periph->periph_openings);
425 struct scsipi_periph *periph = xs->xs_periph;
428 KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
436 periph->periph_freetags[word] |= (1U << bit);
451 scsipi_get_xs(struct scsipi_periph *periph, int flags)
456 SC_DEBUG(periph, SCSIPI_DB3, ("scsipi_get_xs\n"));
466 scsipi_printaddr(periph);
479 * - if the periph has sense pending, only URGENT & REQSENSE
482 * - If the periph is recovering, only URGENT xfers may
485 * - If the periph is currently executing a recovery
490 mutex_enter(chan_mtx(periph->periph_channel));
493 if (periph->periph_active > periph->periph_openings)
495 if (periph->periph_flags & PERIPH_SENSE) {
499 if ((periph->periph_flags &
502 periph->periph_flags |= PERIPH_RECOVERY_ACTIVE;
506 if (periph->periph_active >= periph->periph_openings ||
507 (periph->periph_flags & PERIPH_RECOVERING) != 0)
509 periph->periph_active++;
510 KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
519 SC_DEBUG(periph, SCSIPI_DB3, ("sleeping\n"));
520 periph->periph_flags |= PERIPH_WAITING;
521 cv_wait(periph_cv_periph(periph),
522 chan_mtx(periph->periph_channel));
525 mutex_exit(chan_mtx(periph->periph_channel));
527 SC_DEBUG(periph, SCSIPI_DB3, ("calling pool_get\n"));
532 mutex_enter(chan_mtx(periph->periph_channel));
535 periph->periph_flags &= ~PERIPH_RECOVERY_ACTIVE;
537 periph->periph_active--;
539 mutex_exit(chan_mtx(periph->periph_channel));
540 scsipi_printaddr(periph);
545 SC_DEBUG(periph, SCSIPI_DB3, ("returning\n"));
550 xs->xs_periph = periph;
554 mutex_enter(chan_mtx(periph->periph_channel));
555 TAILQ_INSERT_TAIL(&periph->periph_xferq, xs, device_q);
556 KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
558 mutex_exit(chan_mtx(periph->periph_channel));
576 struct scsipi_periph *periph = xs->xs_periph;
580 SC_DEBUG(periph, SCSIPI_DB3, ("scsipi_free_xs\n"));
581 KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
583 TAILQ_REMOVE(&periph->periph_xferq, xs, device_q);
588 if ((periph->periph_flags & PERIPH_RECOVERY_ACTIVE) != 0 &&
589 periph->periph_active == 0) {
590 scsipi_printaddr(periph);
598 periph->periph_flags &= ~PERIPH_RECOVERY_ACTIVE;
600 periph->periph_active--;
601 if (periph->periph_active == 0 &&
602 (periph->periph_flags & PERIPH_WAITDRAIN) != 0) {
603 periph->periph_flags &= ~PERIPH_WAITDRAIN;
604 cv_broadcast(periph_cv_active(periph));
607 if (periph->periph_flags & PERIPH_WAITING) {
608 periph->periph_flags &= ~PERIPH_WAITING;
609 cv_broadcast(periph_cv_periph(periph));
611 if (periph->periph_switch->psw_start != NULL &&
612 device_is_active(periph->periph_dev)) {
613 SC_DEBUG(periph, SCSIPI_DB2,
615 (*periph->periph_switch->psw_start)(periph);
705 scsipi_periph_freeze_locked(struct scsipi_periph *periph, int count)
708 periph->periph_qfreeze += count;
717 scsipi_periph_thaw_locked(struct scsipi_periph *periph, int count)
720 periph->periph_qfreeze -= count;
722 if (periph->periph_qfreeze < 0) {
723 static const char pc[] = "periph freeze count < 0";
724 scsipi_printaddr(periph);
729 if (periph->periph_qfreeze == 0 &&
730 (periph->periph_flags & PERIPH_WAITING) != 0)
731 cv_broadcast(periph_cv_periph(periph));
735 scsipi_periph_freeze(struct scsipi_periph *periph, int count)
738 mutex_enter(chan_mtx(periph->periph_channel));
739 scsipi_periph_freeze_locked(periph, count);
740 mutex_exit(chan_mtx(periph->periph_channel));
744 scsipi_periph_thaw(struct scsipi_periph *periph, int count)
747 mutex_enter(chan_mtx(periph->periph_channel));
748 scsipi_periph_thaw_locked(periph, count);
749 mutex_exit(chan_mtx(periph->periph_channel));
760 struct scsipi_periph *periph = arg;
761 struct scsipi_channel *chan = periph->periph_channel;
763 callout_stop(&periph->periph_callout);
766 scsipi_periph_thaw_locked(periph, 1);
767 if ((periph->periph_channel->chan_flags & SCSIPI_CHAN_TACTIVE) == 0) {
774 scsipi_run_queue(periph->periph_channel);
779 periph->periph_channel->chan_tflags |= SCSIPI_CHANT_KICK;
788 * Wait for a periph's pending xfers to drain.
791 scsipi_wait_drain(struct scsipi_periph *periph)
793 struct scsipi_channel *chan = periph->periph_channel;
796 while (periph->periph_active != 0) {
797 periph->periph_flags |= PERIPH_WAITDRAIN;
798 cv_wait(periph_cv_active(periph), chan_mtx(chan));
806 * Kill off all pending xfers for a periph.
811 scsipi_kill_pending(struct scsipi_periph *periph)
813 struct scsipi_channel *chan = periph->periph_channel;
815 (*chan->chan_bustype->bustype_kill_pending)(periph);
816 while (periph->periph_active != 0) {
817 periph->periph_flags |= PERIPH_WAITDRAIN;
818 cv_wait(periph_cv_active(periph), chan_mtx(chan));
883 struct scsipi_periph *periph = xs->xs_periph;
900 if (periph->periph_flags & SCSIPI_DB1) {
902 scsipi_printaddr(periph);
929 * If the periph has its own error handler, call it first.
933 if (periph->periph_switch->psw_error != NULL) {
934 SC_DEBUG(periph, SCSIPI_DB2,
936 error = (*periph->periph_switch->psw_error)(xs);
950 if ((periph->periph_flags & PERIPH_REMOVABLE) != 0)
951 periph->periph_flags &= ~PERIPH_MEDIA_LOADED;
969 scsipi_printaddr(periph);
995 if ((periph->periph_flags & PERIPH_REMOVABLE) != 0)
996 periph->periph_flags &= ~PERIPH_MEDIA_LOADED;
1030 if ((periph->periph_flags & PERIPH_REMOVABLE) != 0)
1031 periph->periph_flags &= ~PERIPH_MEDIA_LOADED;
1035 (periph->periph_flags &
1078 scsipi_printaddr(periph);
1120 scsipi_printaddr(periph);
1132 scsipi_printaddr(periph);
1153 scsipi_test_unit_ready(struct scsipi_periph *periph, int flags)
1159 if (periph->periph_quirks & PQUIRK_NOTUR)
1170 return scsipi_command(periph, (void *)&cmd, sizeof(cmd), 0, 0,
1202 scsipi_inquire(struct scsipi_periph *periph, struct scsipi_inquiry_data *inqbuf,
1228 error = scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1238 error = scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1297 scsipi_prevent(struct scsipi_periph *periph, int type, int flags)
1301 if (periph->periph_quirks & PQUIRK_NODOORLOCK)
1308 return (scsipi_command(periph, (void *)&cmd, sizeof(cmd), 0, 0,
1318 scsipi_start(struct scsipi_periph *periph, int type, int flags)
1327 return scsipi_command(periph, (void *)&cmd, sizeof(cmd), 0, 0,
1337 scsipi_mode_sense(struct scsipi_periph *periph, int byte2, int page,
1349 return scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1354 scsipi_mode_sense_big(struct scsipi_periph *periph, int byte2, int page,
1366 return scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1371 scsipi_mode_select(struct scsipi_periph *periph, int byte2,
1382 return scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1387 scsipi_mode_select_big(struct scsipi_periph *periph, int byte2,
1398 return scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1409 scsipi_get_opcodeinfo(struct scsipi_periph *periph)
1418 if (periph->periph_quirks & PQUIRK_NOREPSUPPOPC ||
1419 periph->periph_type == T_PROCESSOR || /* spec. */
1420 periph->periph_type == T_CDROM) /* spec. */
1423 scsipi_free_opcodeinfo(periph);
1442 rc = scsipi_command(periph, (void *)&cmd, sizeof(cmd),
1447 SC_DEBUG(periph, SCSIPI_DB3,
1461 SC_DEBUG(periph, SCSIPI_DB3,
1463 SC_DEBUG(periph, SCSIPI_DB3,
1479 SC_DEBUG(periph, SCSIPI_DB3,
1485 SC_DEBUGN(periph, SCSIPI_DB3,
1490 SC_DEBUGN(periph, SCSIPI_DB3, (" "));
1504 SC_DEBUGN(periph, SCSIPI_DB3,
1514 SC_DEBUGN(periph, SCSIPI_DB3,("\n"));
1518 periph->periph_opcs = tot;
1521 SC_DEBUG(periph, SCSIPI_DB3,
1525 SC_DEBUG(periph, SCSIPI_DB3,
1589 scsipi_free_opcodeinfo(struct scsipi_periph *periph)
1591 if (periph->periph_opcs != NULL) {
1592 free(periph->periph_opcs, M_DEVBUF);
1595 periph->periph_opcs = NULL;
1607 struct scsipi_periph *periph = xs->xs_periph;
1608 struct scsipi_channel *chan = periph->periph_channel;
1611 SC_DEBUG(periph, SCSIPI_DB2, ("scsipi_done\n"));
1613 if (periph->periph_dbflags & SCSIPI_DB1)
1646 periph->periph_flags &= ~PERIPH_UNTAG;
1659 * periph's queue. Freeze it again if we were requested
1668 scsipi_periph_freeze_locked(periph, freezecnt);
1675 periph->periph_flags |= PERIPH_SENSE;
1676 periph->periph_xscheck = xs;
1761 struct scsipi_periph *periph = xs->xs_periph;
1762 struct scsipi_channel *chan = periph->periph_channel;
1782 scsipi_printaddr(periph);
1786 scsipi_periph_thaw_locked(periph, 1);
1805 SC_DEBUG(periph, SCSIPI_DB3, ("calling user done()\n"));
1808 scsipi_periph_thaw_locked(periph, 1);
1811 SC_DEBUG(periph, SCSIPI_DB3, ("returned from user done()\n "));
1829 scsipi_printaddr(periph);
1843 mo.mo_target = periph->periph_target;
1844 mo.mo_lun = periph->periph_lun;
1845 if (periph->periph_active < periph->periph_openings)
1846 mo.mo_openings = periph->periph_active - 1;
1848 mo.mo_openings = periph->periph_openings - 1;
1851 scsipi_printaddr(periph);
1857 scsipi_printaddr(periph);
1873 } else if (!callout_pending(&periph->periph_callout)) {
1874 scsipi_periph_freeze_locked(periph, 1);
1875 callout_reset(&periph->periph_callout,
1876 hz, scsipi_periph_timed_thaw, periph);
1897 if (scsipi_lookup_periph(chan, periph->periph_target,
1898 periph->periph_lun) && xs->xs_retries != 0) {
1922 scsipi_printaddr(periph);
1927 scsipi_printaddr(periph);
1937 * If we get here, the periph has been thawed and frozen
1940 * any case, we thaw the periph once we re-enqueue the
1941 * command. Once the periph is fully thawed, it will begin
1950 scsipi_periph_thaw_locked(periph, 1);
1961 scsipi_periph_thaw_locked(periph, 1);
1964 if (periph->periph_switch->psw_done)
1965 periph->periph_switch->psw_done(xs, error);
1984 struct scsipi_periph *periph = xs->xs_periph;
1988 periph->periph_flags |= PERIPH_SENSE;
2003 error = scsipi_command(periph, (void *)&cmd, sizeof(cmd),
2006 periph->periph_flags &= ~PERIPH_SENSE;
2007 periph->periph_xscheck = NULL;
2028 scsipi_printaddr(periph);
2071 * Immediately before the first xfer for this periph
2106 struct scsipi_periph *periph;
2126 periph = xs->xs_periph;
2128 if ((periph->periph_sent >= periph->periph_openings) ||
2129 periph->periph_qfreeze != 0 ||
2130 (periph->periph_flags & PERIPH_UNTAG) != 0)
2133 if ((periph->periph_flags &
2198 periph->periph_flags |= PERIPH_UNTAG;
2199 periph->periph_sent++;
2216 struct scsipi_periph *periph = xs->xs_periph;
2217 struct scsipi_channel *chan = periph->periph_channel;
2251 if ((PERIPH_XFER_MODE(periph) & PERIPH_CAP_TQING) == 0 ||
2282 scsipi_printaddr(periph);
2316 scsipi_printaddr(periph);
2322 scsipi_printaddr(periph);
2344 scsipi_printaddr(periph);
2537 struct scsipi_periph *periph;
2551 periph = scsipi_lookup_periph_locked(chan, mo->mo_target, minlun);
2552 if (periph == NULL)
2555 if (mo->mo_openings < periph->periph_openings)
2556 periph->periph_openings = mo->mo_openings;
2557 else if (mo->mo_openings > periph->periph_openings &&
2558 (periph->periph_flags & PERIPH_GROW_OPENINGS) != 0)
2559 periph->periph_openings = mo->mo_openings;
2621 struct scsipi_periph *periph;
2647 periph = scsipi_lookup_periph_locked(chan, target, lun);
2648 if (periph) {
2649 xs = periph->periph_xscheck;
2660 * detach all periph associated with a I_T
2667 struct scsipi_periph *periph;
2704 periph = scsipi_lookup_periph_locked(chan, ctarget, clun);
2705 if (periph == NULL)
2707 tdev = periph->periph_dev;
2896 printf("periph(%p)", xs->xs_periph);