Lines Matching refs:nvp

112 static int nv_start_common(nv_port_t *nvp, sata_pkt_t *spkt);
113 static int nv_start_nodata(nv_port_t *nvp, int slot);
114 static void nv_intr_nodata(nv_port_t *nvp, nv_slot_t *spkt);
115 static int nv_start_pio_in(nv_port_t *nvp, int slot);
116 static int nv_start_pio_out(nv_port_t *nvp, int slot);
117 static void nv_intr_pio_in(nv_port_t *nvp, nv_slot_t *spkt);
118 static void nv_intr_pio_out(nv_port_t *nvp, nv_slot_t *spkt);
119 static int nv_start_pkt_pio(nv_port_t *nvp, int slot);
120 static void nv_intr_pkt_pio(nv_port_t *nvp, nv_slot_t *nv_slotp);
121 static int nv_start_dma(nv_port_t *nvp, int slot);
122 static void nv_intr_dma(nv_port_t *nvp, struct nv_slot *spkt);
126 static void nv_uninit_port(nv_port_t *nvp);
127 static void nv_init_port(nv_port_t *nvp);
129 static int mcp5x_packet_complete_intr(nv_ctl_t *nvc, nv_port_t *nvp);
131 static int mcp5x_dma_setup_intr(nv_ctl_t *nvc, nv_port_t *nvp);
133 static void nv_start_dma_engine(nv_port_t *nvp, int slot);
134 static void nv_port_state_change(nv_port_t *nvp, int event, uint8_t addr_type,
138 static void nv_reset(nv_port_t *nvp, char *reason);
139 static void nv_complete_io(nv_port_t *nvp, sata_pkt_t *spkt, int slot);
141 static int nv_poll_wait(nv_port_t *nvp, sata_pkt_t *spkt);
142 static void nv_cmn_err(int ce, nv_ctl_t *nvc, nv_port_t *nvp, char *fmt, ...);
143 static void nv_read_signature(nv_port_t *nvp);
144 static void mcp5x_set_intr(nv_port_t *nvp, int flag);
145 static void ck804_set_intr(nv_port_t *nvp, int flag);
146 static void nv_resume(nv_port_t *nvp);
147 static void nv_suspend(nv_port_t *nvp);
148 static int nv_start_sync(nv_port_t *nvp, sata_pkt_t *spkt);
149 static int nv_abort_active(nv_port_t *nvp, sata_pkt_t *spkt, int abort_reason,
151 static void nv_copy_registers(nv_port_t *nvp, sata_device_t *sd,
153 static void nv_link_event(nv_port_t *nvp, int flags);
154 static int nv_start_async(nv_port_t *nvp, sata_pkt_t *spkt);
155 static int nv_wait3(nv_port_t *nvp, uchar_t onbits1, uchar_t offbits1,
159 static int nv_wait(nv_port_t *nvp, uchar_t onbits, uchar_t offbits,
161 static int nv_start_rqsense_pio(nv_port_t *nvp, nv_slot_t *nv_slotp);
162 static void nv_setup_timeout(nv_port_t *nvp, clock_t microseconds);
163 static clock_t nv_monitor_reset(nv_port_t *nvp);
164 static int nv_bm_status_clear(nv_port_t *nvp);
165 static void nv_log(nv_ctl_t *nvc, nv_port_t *nvp, const char *fmt, ...);
767 nv_port_t *nvp; in nv_attach() local
769 nvp = &(nvc->nvc_port[j]); in nv_attach()
770 bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_attach()
771 sstatus = ddi_get32(bar5_hdl, nvp->nvp_sstatus); in nv_attach()
776 nvp->nvp_state |= NV_ATTACH; in nv_attach()
777 nvp->nvp_type = SATA_DTYPE_UNKNOWN; in nv_attach()
778 mutex_enter(&nvp->nvp_mutex); in nv_attach()
779 nv_reset(nvp, "attach"); in nv_attach()
781 while (nvp->nvp_state & NV_RESET) { in nv_attach()
782 cv_wait(&nvp->nvp_reset_cv, in nv_attach()
783 &nvp->nvp_mutex); in nv_attach()
786 mutex_exit(&nvp->nvp_mutex); in nv_attach()
864 nv_port_t *nvp; in nv_attach() local
867 nvp = &(nvc->nvc_port[port]); in nv_attach()
868 if (nvp->nvp_timeout_id != 0) { in nv_attach()
869 (void) untimeout(nvp->nvp_timeout_id); in nv_attach()
907 nv_port_t *nvp; in nv_detach() local
926 nvp = &(nvc->nvc_port[port]); in nv_detach()
927 if (nvp->nvp_timeout_id != 0) { in nv_detach()
928 (void) untimeout(nvp->nvp_timeout_id); in nv_detach()
1215 nv_port_t *nvp; in nv_sata_probe() local
1225 nvp = &(nvc->nvc_port[cport]); in nv_sata_probe()
1226 ASSERT(nvp != NULL); in nv_sata_probe()
1228 NVLOG(NVDBG_ENTRY, nvc, nvp, in nv_sata_probe()
1232 mutex_enter(&nvp->nvp_mutex); in nv_sata_probe()
1238 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_sata_probe()
1239 nv_cmn_err(CE_WARN, nvc, nvp, in nv_sata_probe()
1243 mutex_exit(&nvp->nvp_mutex); in nv_sata_probe()
1248 if (nvp->nvp_state & NV_FAILED) { in nv_sata_probe()
1249 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_sata_probe()
1251 sd->satadev_type = nvp->nvp_type; in nv_sata_probe()
1253 mutex_exit(&nvp->nvp_mutex); in nv_sata_probe()
1261 mutex_exit(&nvp->nvp_mutex); in nv_sata_probe()
1262 nv_cmn_err(CE_WARN, nvc, nvp, in nv_sata_probe()
1270 nv_copy_registers(nvp, sd, NULL); in nv_sata_probe()
1272 if (nvp->nvp_state & (NV_RESET|NV_LINK_EVENT)) { in nv_sata_probe()
1279 DTRACE_PROBE1(nvp_state_h, int, nvp->nvp_state); in nv_sata_probe()
1285 sd->satadev_type = nvp->nvp_type; in nv_sata_probe()
1286 mutex_exit(&nvp->nvp_mutex); in nv_sata_probe()
1309 mutex_exit(&nvp->nvp_mutex); in nv_sata_probe()
1317 sd->satadev_type = nvp->nvp_type; in nv_sata_probe()
1318 DTRACE_PROBE1(nvp_type_h, int, nvp->nvp_type); in nv_sata_probe()
1320 mutex_exit(&nvp->nvp_mutex); in nv_sata_probe()
1334 nv_port_t *nvp = &(nvc->nvc_port[cport]); in nv_sata_start() local
1337 NVLOG(NVDBG_ENTRY, nvc, nvp, "nv_sata_start: opmode: 0x%x cmd=%x", in nv_sata_start()
1340 mutex_enter(&nvp->nvp_mutex); in nv_sata_start()
1342 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_sata_start()
1344 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1349 nv_copy_registers(nvp, &spkt->satapkt_device, NULL); in nv_sata_start()
1350 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1355 if (nvp->nvp_state & NV_FAILED) { in nv_sata_start()
1357 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1362 nv_copy_registers(nvp, &spkt->satapkt_device, NULL); in nv_sata_start()
1363 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1368 if (nvp->nvp_state & NV_RESET) { in nv_sata_start()
1370 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1382 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1386 (void) nv_monitor_reset(nvp); in nv_sata_start()
1389 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1394 if (nvp->nvp_state & NV_LINK_EVENT) { in nv_sata_start()
1396 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1403 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1407 nv_timeout(nvp); in nv_sata_start()
1410 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1416 if ((nvp->nvp_type == SATA_DTYPE_NONE) || in nv_sata_start()
1417 (nvp->nvp_type == SATA_DTYPE_UNKNOWN)) { in nv_sata_start()
1419 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1420 "nv_sata_start: nvp_type 0x%x", nvp->nvp_type); in nv_sata_start()
1421 DTRACE_PROBE1(not_ready_nvp_type_h, int, nvp->nvp_type); in nv_sata_start()
1424 nv_copy_registers(nvp, &spkt->satapkt_device, NULL); in nv_sata_start()
1425 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1432 nv_cmn_err(CE_WARN, nvc, nvp, in nv_sata_start()
1435 ASSERT(nvp->nvp_type == SATA_DTYPE_PMULT); in nv_sata_start()
1437 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1450 NVLOG(NVDBG_RESET, nvc, nvp, in nv_sata_start()
1453 DTRACE_PROBE1(nvp_state_before_clear_h, int, nvp->nvp_state); in nv_sata_start()
1455 nvp->nvp_state &= ~NV_RESTORE; in nv_sata_start()
1467 if ((nvp->nvp_state & NV_RESTORE) && in nv_sata_start()
1471 NVLOG(NVDBG_RESET, nvc, nvp, in nv_sata_start()
1474 int, nvp->nvp_state); in nv_sata_start()
1477 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1482 if (nvp->nvp_state & NV_ABORTING) { in nv_sata_start()
1484 NVLOG(NVDBG_ERRS, nvc, nvp, in nv_sata_start()
1486 DTRACE_PROBE1(aborting_nvp_state_h, int, nvp->nvp_state); in nv_sata_start()
1489 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1497 nvp->nvp_seq++; in nv_sata_start()
1499 DTRACE_PROBE2(command_start, int *, nvp, int, in nv_sata_start()
1505 nv_put32(nvp->nvp_ctlp->nvc_bar_hdl[5], nvp->nvp_serror, 0xffffffff); in nv_sata_start()
1510 ret = nv_start_sync(nvp, spkt); in nv_sata_start()
1512 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1520 ret = nv_start_async(nvp, spkt); in nv_sata_start()
1522 mutex_exit(&nvp->nvp_mutex); in nv_sata_start()
1542 nv_start_sync(nv_port_t *nvp, sata_pkt_t *spkt) in nv_start_sync() argument
1544 nv_ctl_t *nvc = nvp->nvp_ctlp; in nv_start_sync()
1547 NVLOG(NVDBG_SYNC, nvp->nvp_ctlp, nvp, "nv_sata_satapkt_sync: entry", in nv_start_sync()
1550 if (nvp->nvp_ncq_run != 0 || nvp->nvp_non_ncq_run != 0) { in nv_start_sync()
1552 NVLOG(NVDBG_SYNC, nvp->nvp_ctlp, nvp, in nv_start_sync()
1555 nvp->nvp_ncq_run, nvp->nvp_non_ncq_run, in nv_start_sync()
1556 (&(nvp->nvp_slot[0]))->nvslot_spkt); in nv_start_sync()
1567 NVLOG(NVDBG_SYNC, nvp->nvp_ctlp, nvp, in nv_start_sync()
1578 (*(nvc->nvc_set_intr))(nvp, NV_INTR_DISABLE); in nv_start_sync()
1587 if ((ret = nv_start_common(nvp, spkt)) != SATA_TRAN_ACCEPTED) { in nv_start_sync()
1589 (*(nvc->nvc_set_intr))(nvp, NV_INTR_ENABLE); in nv_start_sync()
1596 mutex_exit(&nvp->nvp_mutex); in nv_start_sync()
1597 ret = nv_poll_wait(nvp, spkt); in nv_start_sync()
1598 mutex_enter(&nvp->nvp_mutex); in nv_start_sync()
1600 (*(nvc->nvc_set_intr))(nvp, NV_INTR_ENABLE); in nv_start_sync()
1602 NVLOG(NVDBG_SYNC, nvp->nvp_ctlp, nvp, "nv_sata_satapkt_sync:" in nv_start_sync()
1613 cv_wait(&nvp->nvp_sync_cv, &nvp->nvp_mutex); in nv_start_sync()
1617 NVLOG(NVDBG_SYNC, nvp->nvp_ctlp, nvp, "nv_sata_satapkt_sync:" in nv_start_sync()
1625 nv_poll_wait(nv_port_t *nvp, sata_pkt_t *spkt) in nv_poll_wait() argument
1628 nv_ctl_t *nvc = nvp->nvp_ctlp; in nv_poll_wait()
1630 nv_slot_t *nv_slotp = &(nvp->nvp_slot[0]); /* not NCQ aware */ in nv_poll_wait()
1633 NVLOG(NVDBG_SYNC, nvc, nvp, "nv_poll_wait: enter", NULL); in nv_poll_wait()
1639 NVLOG(NVDBG_SYNC, nvc, nvp, "nv_poll_wait: before nv_wait", in nv_poll_wait()
1641 if (nv_wait(nvp, 0, SATA_STATUS_BSY, in nv_poll_wait()
1643 mutex_enter(&nvp->nvp_mutex); in nv_poll_wait()
1645 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_poll_wait()
1646 nv_reset(nvp, "poll_wait"); in nv_poll_wait()
1647 nv_complete_io(nvp, spkt, 0); in nv_poll_wait()
1648 mutex_exit(&nvp->nvp_mutex); in nv_poll_wait()
1649 NVLOG(NVDBG_SYNC, nvc, nvp, "nv_poll_wait: " in nv_poll_wait()
1655 NVLOG(NVDBG_SYNC, nvc, nvp, "nv_poll_wait: before nvc_intr", in nv_poll_wait()
1662 NVLOG(NVDBG_SYNC, nvc, nvp, "nv_poll_wait: after nvc_intr", in nv_poll_wait()
1666 NVLOG(NVDBG_SYNC, nvc, nvp, "nv_poll_wait:" in nv_poll_wait()
1668 mutex_enter(&nvp->nvp_mutex); in nv_poll_wait()
1669 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_poll_wait()
1670 nv_reset(nvp, "poll_wait intr not claimed"); in nv_poll_wait()
1672 nv_complete_io(nvp, spkt, 0); in nv_poll_wait()
1673 mutex_exit(&nvp->nvp_mutex); in nv_poll_wait()
1700 nv_port_t *nvp = &(nvc->nvc_port[cport]); in nv_sata_abort() local
1704 NVLOG(NVDBG_ENTRY, nvc, nvp, "nv_sata_abort %d %p", flag, spkt); in nv_sata_abort()
1706 mutex_enter(&nvp->nvp_mutex); in nv_sata_abort()
1708 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_sata_abort()
1709 mutex_exit(&nvp->nvp_mutex); in nv_sata_abort()
1710 nv_cmn_err(CE_WARN, nvc, nvp, in nv_sata_abort()
1719 c_a = nv_abort_active(nvp, spkt, SATA_PKT_ABORTED, B_TRUE); in nv_sata_abort()
1722 NVLOG(NVDBG_ENTRY, nvc, nvp, in nv_sata_abort()
1727 NVLOG(NVDBG_ENTRY, nvc, nvp, "no spkts to abort", NULL); in nv_sata_abort()
1729 NVLOG(NVDBG_ENTRY, nvc, nvp, in nv_sata_abort()
1735 mutex_exit(&nvp->nvp_mutex); in nv_sata_abort()
1747 nv_abort_active(nv_port_t *nvp, sata_pkt_t *spkt, int abort_reason, in nv_abort_active() argument
1754 ASSERT(MUTEX_HELD(&nvp->nvp_mutex)); in nv_abort_active()
1756 NVLOG(NVDBG_ENTRY, nvp->nvp_ctlp, nvp, "nv_abort_active", NULL); in nv_abort_active()
1758 nvp->nvp_state |= NV_ABORTING; in nv_abort_active()
1760 for (i = 0; i < nvp->nvp_queue_depth; i++) { in nv_abort_active()
1762 nv_slotp = &(nvp->nvp_slot[i]); in nv_abort_active()
1785 ddi_acc_handle_t bmhdl = nvp->nvp_bm_hdl; in nv_abort_active()
1790 nv_put8(bmhdl, nvp->nvp_bmicx, 0); in nv_abort_active()
1797 nv_reset(nvp, "abort_active"); in nv_abort_active()
1802 nv_complete_io(nvp, spkt_slot, i); in nv_abort_active()
1806 nvp->nvp_state &= ~NV_ABORTING; in nv_abort_active()
1820 nv_port_t *nvp = &(nvc->nvc_port[cport]); in nv_sata_reset() local
1825 NVLOG(NVDBG_ENTRY, nvc, nvp, "nv_sata_reset", NULL); in nv_sata_reset()
1827 mutex_enter(&nvp->nvp_mutex); in nv_sata_reset()
1840 if ((nvp->nvp_state & (NV_RESET|NV_RESTORE)) && in nv_sata_reset()
1842 NVLOG(NVDBG_RESET, nvc, nvp, in nv_sata_reset()
1854 NVLOG(NVDBG_RESET, nvc, nvp, "in_panic. nvp_state: " in nv_sata_reset()
1859 "in_interrupt: %d", nvp->nvp_state, in nv_sata_reset()
1860 nvp->nvp_reset_time, nvp->nvp_last_cmd, in nv_sata_reset()
1861 nvp->nvp_previous_cmd, nvp->nvp_reset_count, in nv_sata_reset()
1862 nvp->nvp_first_reset_reason, in nv_sata_reset()
1863 nvp->nvp_reset_reason, nvp->nvp_seq, in nv_sata_reset()
1867 nv_reset(nvp, "sata_reset"); in nv_sata_reset()
1869 (void) nv_abort_active(nvp, NULL, SATA_PKT_RESET, B_FALSE); in nv_sata_reset()
1876 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_sata_reset()
1877 nvp->nvp_state &= ~NV_RESET; in nv_sata_reset()
1878 nvp->nvp_reset_time = 0; in nv_sata_reset()
1887 nvp->nvp_state &= ~NV_FAILED; in nv_sata_reset()
1894 while (nvp->nvp_state & NV_RESET) { in nv_sata_reset()
1896 (void) nv_monitor_reset(nvp); in nv_sata_reset()
1904 NVLOG(NVDBG_ENTRY, nvc, nvp, in nv_sata_reset()
1910 NVLOG(NVDBG_ENTRY, nvc, nvp, in nv_sata_reset()
1920 mutex_exit(&nvp->nvp_mutex); in nv_sata_reset()
1934 nv_port_t *nvp = &(nvc->nvc_port[cport]); in nv_sata_activate() local
1935 ddi_acc_handle_t bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_sata_activate()
1939 NVLOG(NVDBG_ENTRY, nvc, nvp, "nv_sata_activate", NULL); in nv_sata_activate()
1941 mutex_enter(&nvp->nvp_mutex); in nv_sata_activate()
1945 nv_copy_registers(nvp, sd, NULL); in nv_sata_activate()
1947 (*(nvc->nvc_set_intr))(nvp, NV_INTR_ENABLE); in nv_sata_activate()
1953 bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_sata_activate()
1955 sstatus = ddi_get32(bar5_hdl, nvp->nvp_sstatus); in nv_sata_activate()
1957 nvp->nvp_type = SATA_DTYPE_NONE; in nv_sata_activate()
1958 nvp->nvp_signature = NV_NO_SIG; in nv_sata_activate()
1959 nvp->nvp_state &= ~NV_DEACTIVATED; in nv_sata_activate()
1964 nvp->nvp_state |= NV_ATTACH; in nv_sata_activate()
1965 nvp->nvp_type = SATA_DTYPE_UNKNOWN; in nv_sata_activate()
1966 nv_reset(nvp, "sata_activate"); in nv_sata_activate()
1968 while (nvp->nvp_state & NV_RESET) { in nv_sata_activate()
1969 cv_wait(&nvp->nvp_reset_cv, &nvp->nvp_mutex); in nv_sata_activate()
1974 mutex_exit(&nvp->nvp_mutex); in nv_sata_activate()
1988 nv_port_t *nvp = &(nvc->nvc_port[cport]); in nv_sata_deactivate() local
1991 NVLOG(NVDBG_ENTRY, nvc, nvp, "nv_sata_deactivate", NULL); in nv_sata_deactivate()
1993 mutex_enter(&nvp->nvp_mutex); in nv_sata_deactivate()
1995 (void) nv_abort_active(nvp, NULL, SATA_PKT_ABORTED, B_FALSE); in nv_sata_deactivate()
2000 nvp->nvp_state |= NV_DEACTIVATED; in nv_sata_deactivate()
2005 (*(nvc->nvc_set_intr))(nvp, NV_INTR_DISABLE); in nv_sata_deactivate()
2008 nv_copy_registers(nvp, sd, NULL); in nv_sata_deactivate()
2010 mutex_exit(&nvp->nvp_mutex); in nv_sata_deactivate()
2021 nv_start_common(nv_port_t *nvp, sata_pkt_t *spkt) in nv_start_common() argument
2027 nv_ctl_t *nvc = nvp->nvp_ctlp; in nv_start_common()
2031 NVLOG(NVDBG_DELIVER, nvc, nvp, "nv_start_common entered: cmd: 0x%x", in nv_start_common()
2036 nvp->nvp_ncq_run++; in nv_start_common()
2042 for (slot = 0; slot < nvp->nvp_queue_depth; slot++, in nv_start_common()
2044 if ((nvp->nvp_sactive_cache & on_bit) == 0) { in nv_start_common()
2053 ASSERT(slot != nvp->nvp_queue_depth); in nv_start_common()
2056 nvp->nvp_sactive); in nv_start_common()
2058 nv_put32(nvc->nvc_bar_hdl[5], nvp->nvp_sactive, on_bit); in nv_start_common()
2059 NVLOG(NVDBG_DELIVER, nvc, nvp, "setting SACTIVE onbit: %X", in nv_start_common()
2061 nvp->nvp_sactive_cache |= on_bit; in nv_start_common()
2066 nvp->nvp_non_ncq_run++; in nv_start_common()
2070 nv_slotp = (nv_slot_t *)&nvp->nvp_slot[slot]; in nv_start_common()
2100 NVLOG(NVDBG_DELIVER, nvc, nvp, "DMA command", NULL); in nv_start_common()
2104 NVLOG(NVDBG_DELIVER, nvc, nvp, "packet command", NULL); in nv_start_common()
2123 NVLOG(NVDBG_DELIVER, nvc, nvp, "non-data command", NULL); in nv_start_common()
2127 NVLOG(NVDBG_DELIVER, nvc, nvp, "pio in command", NULL); in nv_start_common()
2143 NVLOG(NVDBG_DELIVER, nvc, nvp, "pio out command", NULL); in nv_start_common()
2151 nv_cmn_err(CE_WARN, nvc, nvp, "malformed command: direction" in nv_start_common()
2161 if ((ret = (*nv_slotp->nvslot_start)(nvp, slot)) == in nv_start_common()
2164 nv_sgp_drive_active(nvp->nvp_ctlp, in nv_start_common()
2165 (nvp->nvp_ctlp->nvc_ctlr_num * 2) + nvp->nvp_port_num); in nv_start_common()
2173 if ((nvp->nvp_timeout_id == 0) && in nv_start_common()
2175 nv_setup_timeout(nvp, NV_ONE_SEC); in nv_start_common()
2178 nvp->nvp_previous_cmd = nvp->nvp_last_cmd; in nv_start_common()
2179 nvp->nvp_last_cmd = spkt->satapkt_cmd.satacmd_cmd_reg; in nv_start_common()
2189 nvp->nvp_ncq_run--; in nv_start_common()
2190 nvp->nvp_sactive_cache &= ~on_bit; in nv_start_common()
2192 nvp->nvp_non_ncq_run--; in nv_start_common()
2206 nv_read_signature(nv_port_t *nvp) in nv_read_signature() argument
2208 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_read_signature()
2213 nvp->nvp_signature = nv_get8(cmdhdl, nvp->nvp_count); in nv_read_signature()
2214 nvp->nvp_signature |= (nv_get8(cmdhdl, nvp->nvp_sect) << 8); in nv_read_signature()
2215 nvp->nvp_signature |= (nv_get8(cmdhdl, nvp->nvp_lcyl) << 16); in nv_read_signature()
2216 nvp->nvp_signature |= (nv_get8(cmdhdl, nvp->nvp_hcyl) << 24); in nv_read_signature()
2218 NVLOG(NVDBG_VERBOSE, nvp->nvp_ctlp, nvp, in nv_read_signature()
2219 "nv_read_signature: 0x%x ", nvp->nvp_signature); in nv_read_signature()
2221 switch (nvp->nvp_signature) { in nv_read_signature()
2224 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, "drive is a disk", NULL); in nv_read_signature()
2226 nvp->nvp_type = SATA_DTYPE_ATADISK; in nv_read_signature()
2230 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_read_signature()
2233 nvp->nvp_type = SATA_DTYPE_ATAPICD; in nv_read_signature()
2236 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_read_signature()
2239 nvp->nvp_type = SATA_DTYPE_PMULT; in nv_read_signature()
2242 NVLOG(NVDBG_VERBOSE, nvp->nvp_ctlp, nvp, in nv_read_signature()
2245 nvp->nvp_type = SATA_DTYPE_UNKNOWN; in nv_read_signature()
2256 NVLOG(NVDBG_VERBOSE, nvp->nvp_ctlp, nvp, in nv_read_signature()
2258 nvp->nvp_signature); in nv_read_signature()
2260 int, nvp->nvp_signature); in nv_read_signature()
2265 nv_cmn_err(CE_WARN, nvp->nvp_ctlp, nvp, in nv_read_signature()
2266 "invalid signature 0x%x", nvp->nvp_signature); in nv_read_signature()
2267 nvp->nvp_type = SATA_DTYPE_UNKNOWN; in nv_read_signature()
2280 nv_setup_timeout(nv_port_t *nvp, clock_t microseconds) in nv_setup_timeout() argument
2282 clock_t old_duration = nvp->nvp_timeout_duration; in nv_setup_timeout()
2289 if (nvp->nvp_timeout_id != 0 && nvp->nvp_timeout_duration == 0) { in nv_setup_timeout()
2302 nvp->nvp_timeout_duration = 0; in nv_setup_timeout()
2304 if (nvp->nvp_timeout_id == 0) { in nv_setup_timeout()
2308 nvp->nvp_timeout_id = timeout(nv_timeout, (void *)nvp, in nv_setup_timeout()
2318 mutex_exit(&nvp->nvp_mutex); in nv_setup_timeout()
2319 (void) untimeout(nvp->nvp_timeout_id); in nv_setup_timeout()
2320 mutex_enter(&nvp->nvp_mutex); in nv_setup_timeout()
2321 nvp->nvp_timeout_id = timeout(nv_timeout, (void *)nvp, in nv_setup_timeout()
2326 nvp->nvp_timeout_duration = microseconds; in nv_setup_timeout()
2337 nv_reset(nv_port_t *nvp, char *reason) in nv_reset() argument
2339 ddi_acc_handle_t bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_reset()
2340 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_reset()
2341 nv_ctl_t *nvc = nvp->nvp_ctlp; in nv_reset()
2347 ASSERT(mutex_owned(&nvp->nvp_mutex)); in nv_reset()
2362 serr = nv_get32(bar5_hdl, nvp->nvp_serror); in nv_reset()
2368 bmicx = nv_get8(nvp->nvp_bm_hdl, nvp->nvp_bmicx); in nv_reset()
2369 nv_put8(nvp->nvp_bm_hdl, nvp->nvp_bmicx, bmicx & ~BMICX_SSBM); in nv_reset()
2375 if (nvp->nvp_state & NV_RESET) { in nv_reset()
2376 nvp->nvp_reset_retry_count++; in nv_reset()
2378 NVLOG(NVDBG_RESET, nvc, nvp, "npv_reset_retry_count: %d", in nv_reset()
2379 nvp->nvp_reset_retry_count); in nv_reset()
2382 nvp->nvp_reset_retry_count = 0; in nv_reset()
2383 nvp->nvp_reset_count++; in nv_reset()
2384 nvp->nvp_state |= NV_RESET; in nv_reset()
2386 NVLOG(NVDBG_RESET, nvc, nvp, "nvp_reset_count: %d reason: %s " in nv_reset()
2388 nvp->nvp_reset_count, reason, serr, nvp->nvp_seq, in nv_reset()
2389 nvp->nvp_non_ncq_run, nvp->nvp_last_cmd); in nv_reset()
2397 nvp->nvp_state &= ~(NV_RESTORE|NV_LINK_EVENT); in nv_reset()
2399 nvp->nvp_reset_time = ddi_get_lbolt(); in nv_reset()
2401 if ((nvp->nvp_state & (NV_ATTACH|NV_HOTPLUG)) == 0) { in nv_reset()
2402 nv_cmn_err(CE_NOTE, nvc, nvp, "nv_reset: reason: %s serr 0x%x" in nv_reset()
2403 " nvp_state: 0x%x", reason, serr, nvp->nvp_state); in nv_reset()
2407 if (nvp->nvp_first_reset_reason[0] == '\0') { in nv_reset()
2408 (void) strncpy(nvp->nvp_first_reset_reason, in nv_reset()
2410 nvp->nvp_first_reset_reason[NV_REASON_LEN - 1] = '\0'; in nv_reset()
2414 (void) strncpy(nvp->nvp_reset_reason, reason, NV_REASON_LEN); in nv_reset()
2419 nvp->nvp_reset_reason[NV_REASON_LEN - 1] = '\0'; in nv_reset()
2429 nv_put8(cmdhdl, nvp->nvp_sect, 0); in nv_reset()
2430 nv_put8(cmdhdl, nvp->nvp_lcyl, 0); in nv_reset()
2431 nv_put8(cmdhdl, nvp->nvp_hcyl, 0); in nv_reset()
2432 nv_put8(cmdhdl, nvp->nvp_count, 0); in nv_reset()
2434 nv_put8(nvp->nvp_cmd_hdl, nvp->nvp_error, 0); in nv_reset()
2439 sctrl = nv_get32(bar5_hdl, nvp->nvp_sctrl); in nv_reset()
2441 nv_put32(bar5_hdl, nvp->nvp_sctrl, in nv_reset()
2447 serr = nv_get32(bar5_hdl, nvp->nvp_serror); in nv_reset()
2451 nv_put32(bar5_hdl, nvp->nvp_serror, 0xffffffff); in nv_reset()
2454 sstatus = nv_get32(bar5_hdl, nvp->nvp_sstatus); in nv_reset()
2455 sctrl = nv_get32(bar5_hdl, nvp->nvp_sctrl); in nv_reset()
2456 NVLOG(NVDBG_RESET, nvc, nvp, "nv_reset: applied (%d); " in nv_reset()
2460 nv_put32(bar5_hdl, nvp->nvp_sctrl, in nv_reset()
2469 sstatus = nv_get32(bar5_hdl, nvp->nvp_sstatus); in nv_reset()
2483 serr = nv_get32(bar5_hdl, nvp->nvp_serror); in nv_reset()
2487 NVLOG(NVDBG_RESET, nvc, nvp, "nv_reset not succeeded " in nv_reset()
2490 NVLOG(NVDBG_RESET, nvc, nvp, "nv_reset succeeded" in nv_reset()
2492 nvp->nvp_reset_time), serr); in nv_reset()
2495 nvp->nvp_wait_sig = NV_WAIT_SIG; in nv_reset()
2496 nv_setup_timeout(nvp, nvp->nvp_wait_sig); in nv_reset()
2507 nv_port_t *nvp; in mcp5x_reg_init() local
2515 nvp = &(nvc->nvc_port[port]); in mcp5x_reg_init()
2516 nvp->nvp_mcp5x_int_status = in mcp5x_reg_init()
2518 nvp->nvp_mcp5x_int_ctl = in mcp5x_reg_init()
2524 nv_put16(nvc->nvc_bar_hdl[5], nvp->nvp_mcp5x_int_status, in mcp5x_reg_init()
2536 nv_put16(nvc->nvc_bar_hdl[5], nvp->nvp_mcp5x_int_ctl, in mcp5x_reg_init()
2560 NVLOG(NVDBG_INIT, nvp->nvp_ctlp, nvp, in mcp5x_reg_init()
2584 NVLOG(NVDBG_INIT, nvp->nvp_ctlp, nvp, in mcp5x_reg_init()
2588 nv_cmn_err(CE_NOTE, nvp->nvp_ctlp, nvp, "devid is %X revid is" in mcp5x_reg_init()
2604 nv_port_t *nvp; in ck804_reg_init() local
2634 nvp = &(nvc->nvc_port[j]); in ck804_reg_init()
2635 mutex_enter(&nvp->nvp_mutex); in ck804_reg_init()
2636 (*(nvp->nvp_ctlp->nvc_set_intr))(nvp, in ck804_reg_init()
2638 mutex_exit(&nvp->nvp_mutex); in ck804_reg_init()
2651 nv_port_t *nvp; in nv_init_ctl() local
2739 nvp = &(nvc->nvc_port[j]); in nv_init_ctl()
2741 cmd_addr = nvp->nvp_cmd_addr; in nv_init_ctl()
2742 ctl_addr = nvp->nvp_ctl_addr; in nv_init_ctl()
2743 bm_addr = nvp->nvp_bm_addr; in nv_init_ctl()
2745 mutex_init(&nvp->nvp_mutex, NULL, MUTEX_DRIVER, in nv_init_ctl()
2748 cv_init(&nvp->nvp_sync_cv, NULL, CV_DRIVER, NULL); in nv_init_ctl()
2749 cv_init(&nvp->nvp_reset_cv, NULL, CV_DRIVER, NULL); in nv_init_ctl()
2751 nvp->nvp_data = cmd_addr + NV_DATA; in nv_init_ctl()
2752 nvp->nvp_error = cmd_addr + NV_ERROR; in nv_init_ctl()
2753 nvp->nvp_feature = cmd_addr + NV_FEATURE; in nv_init_ctl()
2754 nvp->nvp_count = cmd_addr + NV_COUNT; in nv_init_ctl()
2755 nvp->nvp_sect = cmd_addr + NV_SECT; in nv_init_ctl()
2756 nvp->nvp_lcyl = cmd_addr + NV_LCYL; in nv_init_ctl()
2757 nvp->nvp_hcyl = cmd_addr + NV_HCYL; in nv_init_ctl()
2758 nvp->nvp_drvhd = cmd_addr + NV_DRVHD; in nv_init_ctl()
2759 nvp->nvp_status = cmd_addr + NV_STATUS; in nv_init_ctl()
2760 nvp->nvp_cmd = cmd_addr + NV_CMD; in nv_init_ctl()
2761 nvp->nvp_altstatus = ctl_addr + NV_ALTSTATUS; in nv_init_ctl()
2762 nvp->nvp_devctl = ctl_addr + NV_DEVCTL; in nv_init_ctl()
2764 nvp->nvp_bmicx = bm_addr + BMICX_REG; in nv_init_ctl()
2765 nvp->nvp_bmisx = bm_addr + BMISX_REG; in nv_init_ctl()
2766 nvp->nvp_bmidtpx = (uint32_t *)(bm_addr + BMIDTPX_REG); in nv_init_ctl()
2768 nvp->nvp_state = 0; in nv_init_ctl()
2774 nv_init_port(nvp); in nv_init_ctl()
2805 nv_init_port(nv_port_t *nvp) in nv_init_port() argument
2807 nv_ctl_t *nvc = nvp->nvp_ctlp; in nv_init_port()
2820 nvp->nvp_sg_dma_hdl = kmem_zalloc(sizeof (ddi_dma_handle_t) * in nv_init_port()
2823 nvp->nvp_sg_acc_hdl = kmem_zalloc(sizeof (ddi_acc_handle_t) * in nv_init_port()
2826 nvp->nvp_sg_addr = kmem_zalloc(sizeof (caddr_t) * in nv_init_port()
2829 nvp->nvp_sg_paddr = kmem_zalloc(sizeof (uint32_t) * in nv_init_port()
2832 nvp->nvp_slot = kmem_zalloc(sizeof (nv_slot_t) * NV_QUEUE_SLOTS, in nv_init_port()
2838 DDI_DMA_SLEEP, NULL, &(nvp->nvp_sg_dma_hdl[i])); in nv_init_port()
2841 nv_uninit_port(nvp); in nv_init_port()
2846 rc = ddi_dma_mem_alloc(nvp->nvp_sg_dma_hdl[i], prd_size, in nv_init_port()
2848 NULL, &(nvp->nvp_sg_addr[i]), &buf_size, in nv_init_port()
2849 &(nvp->nvp_sg_acc_hdl[i])); in nv_init_port()
2852 nv_uninit_port(nvp); in nv_init_port()
2857 rc = ddi_dma_addr_bind_handle(nvp->nvp_sg_dma_hdl[i], NULL, in nv_init_port()
2858 nvp->nvp_sg_addr[i], buf_size, in nv_init_port()
2863 nv_uninit_port(nvp); in nv_init_port()
2873 nvp->nvp_sg_paddr[i] = cookie.dmac_address; in nv_init_port()
2882 nvp->nvp_queue_depth = 1; in nv_init_port()
2889 nvp->nvp_type = SATA_DTYPE_NONE; in nv_init_port()
2897 nv_uninit_port(nv_port_t *nvp) in nv_uninit_port() argument
2901 NVLOG(NVDBG_INIT, nvp->nvp_ctlp, nvp, in nv_uninit_port()
2905 if (nvp->nvp_type == SATA_DTYPE_ATADISK) { in nv_uninit_port()
2906 nv_sgp_drive_disconnect(nvp->nvp_ctlp, SGP_CTLR_PORT_TO_DRV( in nv_uninit_port()
2907 nvp->nvp_ctlp->nvc_ctlr_num, nvp->nvp_port_num)); in nv_uninit_port()
2911 nvp->nvp_type = SATA_DTYPE_NONE; in nv_uninit_port()
2914 if (nvp->nvp_sg_paddr[i]) { in nv_uninit_port()
2915 (void) ddi_dma_unbind_handle(nvp->nvp_sg_dma_hdl[i]); in nv_uninit_port()
2918 if (nvp->nvp_sg_acc_hdl[i] != NULL) { in nv_uninit_port()
2919 ddi_dma_mem_free(&(nvp->nvp_sg_acc_hdl[i])); in nv_uninit_port()
2922 if (nvp->nvp_sg_dma_hdl[i] != NULL) { in nv_uninit_port()
2923 ddi_dma_free_handle(&(nvp->nvp_sg_dma_hdl[i])); in nv_uninit_port()
2927 kmem_free(nvp->nvp_slot, sizeof (nv_slot_t) * NV_QUEUE_SLOTS); in nv_uninit_port()
2928 nvp->nvp_slot = NULL; in nv_uninit_port()
2930 kmem_free(nvp->nvp_sg_dma_hdl, in nv_uninit_port()
2932 nvp->nvp_sg_dma_hdl = NULL; in nv_uninit_port()
2934 kmem_free(nvp->nvp_sg_acc_hdl, in nv_uninit_port()
2936 nvp->nvp_sg_acc_hdl = NULL; in nv_uninit_port()
2938 kmem_free(nvp->nvp_sg_addr, sizeof (caddr_t) * NV_QUEUE_SLOTS); in nv_uninit_port()
2939 nvp->nvp_sg_addr = NULL; in nv_uninit_port()
2941 kmem_free(nvp->nvp_sg_paddr, sizeof (uint32_t) * NV_QUEUE_SLOTS); in nv_uninit_port()
2942 nvp->nvp_sg_paddr = NULL; in nv_uninit_port()
2956 nv_port_t *nvp; in nv_common_reg_init() local
2969 nvp = &(nvc->nvc_port[port]); in nv_common_reg_init()
2970 nvp->nvp_ctlp = nvc; in nv_common_reg_init()
2971 nvp->nvp_port_num = port; in nv_common_reg_init()
2972 NVLOG(NVDBG_INIT, nvc, nvp, "setting up port mappings", NULL); in nv_common_reg_init()
2974 nvp->nvp_cmd_hdl = nvc->nvc_bar_hdl[bar]; in nv_common_reg_init()
2975 nvp->nvp_cmd_addr = nvc->nvc_bar_addr[bar]; in nv_common_reg_init()
2976 nvp->nvp_ctl_hdl = nvc->nvc_bar_hdl[bar + 1]; in nv_common_reg_init()
2977 nvp->nvp_ctl_addr = nvc->nvc_bar_addr[bar + 1]; in nv_common_reg_init()
2978 nvp->nvp_bm_hdl = nvc->nvc_bar_hdl[NV_BAR_4]; in nv_common_reg_init()
2979 nvp->nvp_bm_addr = nvc->nvc_bar_addr[NV_BAR_4] + in nv_common_reg_init()
2982 nvp->nvp_sstatus = (uint32_t *)(sreg_offset + NV_SSTATUS); in nv_common_reg_init()
2983 nvp->nvp_serror = (uint32_t *)(sreg_offset + NV_SERROR); in nv_common_reg_init()
2984 nvp->nvp_sactive = (uint32_t *)(sreg_offset + NV_SACTIVE); in nv_common_reg_init()
2985 nvp->nvp_sctrl = (uint32_t *)(sreg_offset + NV_SCTRL); in nv_common_reg_init()
2994 nv_port_t *nvp; in nv_uninit_ctl() local
2999 nvp = &(nvc->nvc_port[port]); in nv_uninit_ctl()
3000 mutex_enter(&nvp->nvp_mutex); in nv_uninit_ctl()
3001 NVLOG(NVDBG_INIT, nvc, nvp, "uninitializing port", NULL); in nv_uninit_ctl()
3002 nv_uninit_port(nvp); in nv_uninit_ctl()
3003 mutex_exit(&nvp->nvp_mutex); in nv_uninit_ctl()
3004 mutex_destroy(&nvp->nvp_mutex); in nv_uninit_ctl()
3005 cv_destroy(&nvp->nvp_sync_cv); in nv_uninit_ctl()
3006 cv_destroy(&nvp->nvp_reset_cv); in nv_uninit_ctl()
3052 nv_port_t *nvp; in ck804_intr_process() local
3087 nvp = &(nvc->nvc_port[port]); in ck804_intr_process()
3089 mutex_enter(&nvp->nvp_mutex); in ck804_intr_process()
3095 if (nvp->nvp_state & NV_DEACTIVATED) { in ck804_intr_process()
3103 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3109 if ((&(nvp->nvp_slot[0]))->nvslot_spkt == NULL) { in ck804_intr_process()
3110 status = nv_get8(nvp->nvp_ctl_hdl, nvp->nvp_status); in ck804_intr_process()
3111 NVLOG(NVDBG_ALWAYS, nvc, nvp, "spurious interrupt " in ck804_intr_process()
3113 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3124 bmhdl = nvp->nvp_bm_hdl; in ck804_intr_process()
3125 bmstatus = nv_get8(bmhdl, nvp->nvp_bmisx); in ck804_intr_process()
3128 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3133 status = nv_get8(nvp->nvp_ctl_hdl, nvp->nvp_altstatus); in ck804_intr_process()
3136 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3141 nv_slotp = &(nvp->nvp_slot[0]); in ck804_intr_process()
3148 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3153 (*nv_slotp->nvslot_intr)(nvp, nv_slotp); in ck804_intr_process()
3155 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in ck804_intr_process()
3159 nv_complete_io(nvp, spkt, 0); in ck804_intr_process()
3162 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3175 nvp = &(nvc->nvc_port[port]); in ck804_intr_process()
3176 mutex_enter(&nvp->nvp_mutex); in ck804_intr_process()
3180 NVLOG(NVDBG_HOT, nvc, nvp, in ck804_intr_process()
3189 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3206 nv_link_event(nvp, NV_REM_DEV); in ck804_intr_process()
3208 nv_link_event(nvp, NV_ADD_DEV); in ck804_intr_process()
3228 NVLOG(NVDBG_ALWAYS, nvc, nvp, "inst_status=%x " in ck804_intr_process()
3243 (*(nvc->nvc_set_intr))(nvp, NV_INTR_DISABLE); in ck804_intr_process()
3244 nv_port_state_change(nvp, SATA_EVNT_PORT_FAILED, in ck804_intr_process()
3246 nvp->nvp_state |= NV_FAILED; in ck804_intr_process()
3247 (void) nv_abort_active(nvp, NULL, SATA_PKT_DEV_ERROR, in ck804_intr_process()
3249 nv_cmn_err(CE_WARN, nvc, nvp, "unable to clear " in ck804_intr_process()
3254 mutex_exit(&nvp->nvp_mutex); in ck804_intr_process()
3264 mcp5x_intr_port(nv_port_t *nvp) in mcp5x_intr_port() argument
3266 nv_ctl_t *nvc = nvp->nvp_ctlp; in mcp5x_intr_port()
3274 nvp->intr_start_time = ddi_get_lbolt(); in mcp5x_intr_port()
3276 NVLOG(NVDBG_INTR, nvc, nvp, "mcp55_intr_port entered", NULL); in mcp5x_intr_port()
3282 int_status = nv_get16(bar5_hdl, nvp->nvp_mcp5x_int_status); in mcp5x_intr_port()
3289 if (nvp->nvp_state & NV_DEACTIVATED) { in mcp5x_intr_port()
3290 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_status, in mcp5x_intr_port()
3296 NVLOG(NVDBG_INTR, nvc, nvp, "int_status = %x", int_status); in mcp5x_intr_port()
3318 NVLOG(NVDBG_INTR, nvc, nvp, in mcp5x_intr_port()
3329 if (mcp5x_packet_complete_intr(nvc, nvp) == in mcp5x_intr_port()
3338 NVLOG(NVDBG_INTR, nvc, nvp, "mcp5x_dma_setup_intr", in mcp5x_intr_port()
3345 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_status, in mcp5x_intr_port()
3348 ret = mcp5x_dma_setup_intr(nvc, nvp); in mcp5x_intr_port()
3356 mutex_enter(&nvp->nvp_mutex); in mcp5x_intr_port()
3357 nv_link_event(nvp, NV_REM_DEV); in mcp5x_intr_port()
3358 mutex_exit(&nvp->nvp_mutex); in mcp5x_intr_port()
3364 mutex_enter(&nvp->nvp_mutex); in mcp5x_intr_port()
3365 nv_link_event(nvp, NV_ADD_DEV); in mcp5x_intr_port()
3366 mutex_exit(&nvp->nvp_mutex); in mcp5x_intr_port()
3369 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_status, clear); in mcp5x_intr_port()
3378 NVLOG(NVDBG_INTR, nvc, nvp, "excessive interrupt " in mcp5x_intr_port()
3383 mutex_enter(&nvp->nvp_mutex); in mcp5x_intr_port()
3384 (*(nvc->nvc_set_intr))(nvp, NV_INTR_DISABLE); in mcp5x_intr_port()
3389 (void) nv_abort_active(nvp, NULL, SATA_PKT_DEV_ERROR, in mcp5x_intr_port()
3391 mutex_exit(&nvp->nvp_mutex); in mcp5x_intr_port()
3396 if (loop_cnt > nvp->intr_loop_cnt) { in mcp5x_intr_port()
3397 NVLOG(NVDBG_INTR, nvp->nvp_ctlp, nvp, in mcp5x_intr_port()
3399 nvp->intr_loop_cnt = loop_cnt; in mcp5x_intr_port()
3408 status = nv_get8(nvp->nvp_ctl_hdl, nvp->nvp_altstatus); in mcp5x_intr_port()
3409 bmstatus = nv_get8(nvp->nvp_bm_hdl, nvp->nvp_bmisx); in mcp5x_intr_port()
3410 int_status2 = nv_get16(nvp->nvp_ctlp->nvc_bar_hdl[5], in mcp5x_intr_port()
3411 nvp->nvp_mcp5x_int_status); in mcp5x_intr_port()
3412 NVLOG(NVDBG_TIMEOUT, nvp->nvp_ctlp, nvp, in mcp5x_intr_port()
3420 NVLOG(NVDBG_INTR, nvc, nvp, "mcp55_intr_port: finished ret=%d", ret); in mcp5x_intr_port()
3426 intr_time = ddi_get_lbolt() - nvp->intr_start_time; in mcp5x_intr_port()
3427 if (intr_time > nvp->intr_duration) in mcp5x_intr_port()
3428 nvp->intr_duration = intr_time; in mcp5x_intr_port()
3466 mcp5x_dma_setup_intr(nv_ctl_t *nvc, nv_port_t *nvp) in mcp5x_dma_setup_intr() argument
3469 ddi_acc_handle_t bmhdl = nvp->nvp_bm_hdl; in mcp5x_dma_setup_intr()
3471 int port = nvp->nvp_port_num; in mcp5x_dma_setup_intr()
3475 nv_cmn_err(CE_PANIC, nvc, nvp, in mcp5x_dma_setup_intr()
3478 mutex_enter(&nvp->nvp_mutex); in mcp5x_dma_setup_intr()
3484 NVLOG(NVDBG_INTR, nvc, nvp, "mcp5x_dma_setup_intr slot %d" in mcp5x_dma_setup_intr()
3485 " nvp_slot_sactive %X", slot, nvp->nvp_sactive_cache); in mcp5x_dma_setup_intr()
3493 bmicx = nv_get8(bmhdl, nvp->nvp_bmicx); in mcp5x_dma_setup_intr()
3496 NVLOG(NVDBG_INTR, nvc, nvp, "BM was already enabled for " in mcp5x_dma_setup_intr()
3498 nv_put8(bmhdl, nvp->nvp_bmicx, bmicx & ~BMICX_SSBM); in mcp5x_dma_setup_intr()
3500 nv_put8(bmhdl, nvp->nvp_bmicx, bmicx & ~BMICX_SSBM); in mcp5x_dma_setup_intr()
3502 nv_start_dma_engine(nvp, slot); in mcp5x_dma_setup_intr()
3504 mutex_exit(&nvp->nvp_mutex); in mcp5x_dma_setup_intr()
3516 mcp5x_packet_complete_intr(nv_ctl_t *nvc, nv_port_t *nvp) in mcp5x_packet_complete_intr() argument
3519 ddi_acc_handle_t bmhdl = nvp->nvp_bm_hdl; in mcp5x_packet_complete_intr()
3525 mutex_enter(&nvp->nvp_mutex); in mcp5x_packet_complete_intr()
3527 bmstatus = nv_get8(bmhdl, nvp->nvp_bmisx); in mcp5x_packet_complete_intr()
3531 NVLOG(NVDBG_INTR, nvc, nvp, "BMISX_IDEINTS not set %x", in mcp5x_packet_complete_intr()
3533 mutex_exit(&nvp->nvp_mutex); in mcp5x_packet_complete_intr()
3545 if (nvp->nvp_non_ncq_run) { in mcp5x_packet_complete_intr()
3550 status = nv_get8(nvp->nvp_ctl_hdl, nvp->nvp_altstatus); in mcp5x_packet_complete_intr()
3552 nv_cmn_err(CE_WARN, nvc, nvp, in mcp5x_packet_complete_intr()
3555 mutex_exit(&nvp->nvp_mutex); in mcp5x_packet_complete_intr()
3564 ASSERT(nvp->nvp_ncq_run == 0); in mcp5x_packet_complete_intr()
3566 ASSERT(nvp->nvp_non_ncq_run == 0); in mcp5x_packet_complete_intr()
3572 (void) nv_bm_status_clear(nvp); in mcp5x_packet_complete_intr()
3573 (void) nv_get8(nvp->nvp_cmd_hdl, nvp->nvp_status); in mcp5x_packet_complete_intr()
3574 mutex_exit(&nvp->nvp_mutex); in mcp5x_packet_complete_intr()
3600 sactive = nv_get32(nvc->nvc_bar_hdl[5], nvp->nvp_sactive); in mcp5x_packet_complete_intr()
3602 active_pkt_bit = ~sactive & nvp->nvp_sactive_cache; in mcp5x_packet_complete_intr()
3612 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in mcp5x_packet_complete_intr()
3614 nv_cmn_err(CE_CONT, nvc, nvp, "ERROR sactive = %X " in mcp5x_packet_complete_intr()
3616 nvp->nvp_sactive_cache); in mcp5x_packet_complete_intr()
3618 (void) nv_get8(cmdhdl, nvp->nvp_status); in mcp5x_packet_complete_intr()
3620 mutex_exit(&nvp->nvp_mutex); in mcp5x_packet_complete_intr()
3634 nvp->nvp_sactive_cache &= ~(0x01 << active_pkt); in mcp5x_packet_complete_intr()
3637 nv_slotp = &(nvp->nvp_slot[active_pkt]); in mcp5x_packet_complete_intr()
3643 (*nv_slotp->nvslot_intr)(nvp, nv_slotp); in mcp5x_packet_complete_intr()
3645 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in mcp5x_packet_complete_intr()
3649 nv_complete_io(nvp, spkt, active_pkt); in mcp5x_packet_complete_intr()
3652 mutex_exit(&nvp->nvp_mutex); in mcp5x_packet_complete_intr()
3659 nv_complete_io(nv_port_t *nvp, sata_pkt_t *spkt, int slot) in nv_complete_io() argument
3662 ASSERT(MUTEX_HELD(&nvp->nvp_mutex)); in nv_complete_io()
3664 if ((&(nvp->nvp_slot[slot]))->nvslot_flags & NVSLOT_NCQ) { in nv_complete_io()
3665 nvp->nvp_ncq_run--; in nv_complete_io()
3667 nvp->nvp_non_ncq_run--; in nv_complete_io()
3674 (&(nvp->nvp_slot[slot]))->nvslot_spkt = NULL; in nv_complete_io()
3683 cv_signal(&nvp->nvp_sync_cv); in nv_complete_io()
3690 mutex_exit(&nvp->nvp_mutex); in nv_complete_io()
3692 mutex_enter(&nvp->nvp_mutex); in nv_complete_io()
3703 nv_start_async(nv_port_t *nvp, sata_pkt_t *spkt) in nv_start_async() argument
3707 NVLOG(NVDBG_ENTRY, nvp->nvp_ctlp, nvp, "nv_start_async: entry", NULL); in nv_start_async()
3716 if ((nvp->nvp_non_ncq_run == 1) || in nv_start_async()
3717 (nvp->nvp_ncq_run > 0)) { in nv_start_async()
3727 return (nv_start_common(nvp, spkt)); in nv_start_async()
3733 if (nvp->nvp_non_ncq_run == 1) { in nv_start_async()
3751 if (nvp->nvp_queue_depth == 1) { in nv_start_async()
3752 nvp->nvp_queue_depth = in nv_start_async()
3755 ASSERT(nvp->nvp_queue_depth > 1); in nv_start_async()
3757 NVLOG(NVDBG_ENTRY, nvp->nvp_ctlp, nvp, in nv_start_async()
3759 nvp->nvp_queue_depth); in nv_start_async()
3763 if (nvp->nvp_ncq_run >= nvp->nvp_queue_depth) { in nv_start_async()
3772 return (nv_start_common(nvp, spkt)); in nv_start_async()
4020 nv_port_t *nvp; in nv_rem_intrs() local
4029 nvp = (&nvc->nvc_port[i]); in nv_rem_intrs()
4030 mutex_enter(&nvp->nvp_mutex); in nv_rem_intrs()
4031 (*(nvc->nvc_set_intr))(nvp, NV_INTR_DISABLE); in nv_rem_intrs()
4032 mutex_exit(&nvp->nvp_mutex); in nv_rem_intrs()
4062 nv_vcmn_err(int ce, nv_ctl_t *nvc, nv_port_t *nvp, const char *fmt, va_list ap, in nv_vcmn_err() argument
4077 if (nvp) { in nv_vcmn_err()
4079 nvp->nvp_port_num); in nv_vcmn_err()
4080 dip = nvp->nvp_ctlp->nvc_dip; in nv_vcmn_err()
4124 nv_cmn_err(int ce, nv_ctl_t *nvc, nv_port_t *nvp, char *fmt, ...) in nv_cmn_err() argument
4129 nv_vcmn_err(ce, nvc, nvp, fmt, ap, B_TRUE); in nv_cmn_err()
4135 nv_log(nv_ctl_t *nvc, nv_port_t *nvp, const char *fmt, ...) in nv_log() argument
4141 nv_vcmn_err(CE_CONT, nvc, nvp, fmt, ap, B_FALSE); in nv_log()
4148 if (nvp == NULL && nvc == NULL) { in nv_log()
4155 if (nvp == NULL && nvc != NULL) { in nv_log()
4170 nvp->nvp_port_num, fmt); in nv_log()
4172 sata_vtrace_debug(nvp->nvp_ctlp->nvc_dip, nv_log_buf, ap); in nv_log()
4184 nv_program_taskfile_regs(nv_port_t *nvp, int slot) in nv_program_taskfile_regs() argument
4186 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_program_taskfile_regs()
4189 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_program_taskfile_regs()
4196 ASSERT(nvp->nvp_slot); in nv_program_taskfile_regs()
4206 nv_put8(cmdhdl, nvp->nvp_drvhd, satacmd->satacmd_device_reg); in nv_program_taskfile_regs()
4211 if (nv_wait(nvp, SATA_STATUS_DRDY, SATA_STATUS_BSY, in nv_program_taskfile_regs()
4220 NVLOG(NVDBG_DELIVER, nvp->nvp_ctlp, nvp, "ATA_ADDR_LBA mode", in nv_program_taskfile_regs()
4223 nv_put8(cmdhdl, nvp->nvp_count, satacmd->satacmd_sec_count_lsb); in nv_program_taskfile_regs()
4224 nv_put8(cmdhdl, nvp->nvp_hcyl, satacmd->satacmd_lba_high_lsb); in nv_program_taskfile_regs()
4225 nv_put8(cmdhdl, nvp->nvp_lcyl, satacmd->satacmd_lba_mid_lsb); in nv_program_taskfile_regs()
4226 nv_put8(cmdhdl, nvp->nvp_sect, satacmd->satacmd_lba_low_lsb); in nv_program_taskfile_regs()
4227 nv_put8(cmdhdl, nvp->nvp_feature, in nv_program_taskfile_regs()
4234 NVLOG(NVDBG_DELIVER, nvp->nvp_ctlp, nvp, in nv_program_taskfile_regs()
4241 nv_put8(cmdhdl, nvp->nvp_count, satacmd->satacmd_sec_count_lsb); in nv_program_taskfile_regs()
4242 nv_put8(cmdhdl, nvp->nvp_hcyl, satacmd->satacmd_lba_high_lsb); in nv_program_taskfile_regs()
4243 nv_put8(cmdhdl, nvp->nvp_lcyl, satacmd->satacmd_lba_mid_lsb); in nv_program_taskfile_regs()
4244 nv_put8(cmdhdl, nvp->nvp_sect, satacmd->satacmd_lba_low_lsb); in nv_program_taskfile_regs()
4245 nv_put8(cmdhdl, nvp->nvp_feature, in nv_program_taskfile_regs()
4251 NVLOG(NVDBG_DELIVER, nvp->nvp_ctlp, nvp, in nv_program_taskfile_regs()
4260 nv_put8(cmdhdl, nvp->nvp_count, slot << 3); in nv_program_taskfile_regs()
4262 nv_put8(cmdhdl, nvp->nvp_count, in nv_program_taskfile_regs()
4264 nv_put8(cmdhdl, nvp->nvp_count, in nv_program_taskfile_regs()
4268 nv_put8(cmdhdl, nvp->nvp_feature, in nv_program_taskfile_regs()
4270 nv_put8(cmdhdl, nvp->nvp_feature, in nv_program_taskfile_regs()
4276 nv_put8(cmdhdl, nvp->nvp_hcyl, satacmd->satacmd_lba_high_msb); in nv_program_taskfile_regs()
4277 nv_put8(cmdhdl, nvp->nvp_lcyl, satacmd->satacmd_lba_mid_msb); in nv_program_taskfile_regs()
4278 nv_put8(cmdhdl, nvp->nvp_sect, satacmd->satacmd_lba_low_msb); in nv_program_taskfile_regs()
4283 nv_put8(cmdhdl, nvp->nvp_hcyl, satacmd->satacmd_lba_high_lsb); in nv_program_taskfile_regs()
4284 nv_put8(cmdhdl, nvp->nvp_lcyl, satacmd->satacmd_lba_mid_lsb); in nv_program_taskfile_regs()
4285 nv_put8(cmdhdl, nvp->nvp_sect, satacmd->satacmd_lba_low_lsb); in nv_program_taskfile_regs()
4294 nv_put8(cmdhdl, nvp->nvp_count, satacmd->satacmd_sec_count_lsb); in nv_program_taskfile_regs()
4295 nv_put8(cmdhdl, nvp->nvp_feature, in nv_program_taskfile_regs()
4297 nv_put8(cmdhdl, nvp->nvp_hcyl, satacmd->satacmd_lba_high_lsb); in nv_program_taskfile_regs()
4298 nv_put8(cmdhdl, nvp->nvp_lcyl, satacmd->satacmd_lba_mid_lsb); in nv_program_taskfile_regs()
4299 nv_put8(cmdhdl, nvp->nvp_sect, satacmd->satacmd_lba_low_lsb); in nv_program_taskfile_regs()
4307 ASSERT(nvp->nvp_slot); in nv_program_taskfile_regs()
4315 nv_start_nodata(nv_port_t *nvp, int slot) in nv_start_nodata() argument
4317 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_start_nodata()
4320 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_start_nodata()
4322 nv_program_taskfile_regs(nvp, slot); in nv_start_nodata()
4327 nv_put8(cmdhdl, nvp->nvp_cmd, sata_cmdp->satacmd_cmd_reg); in nv_start_nodata()
4334 nv_bm_status_clear(nv_port_t *nvp) in nv_bm_status_clear() argument
4336 ddi_acc_handle_t bmhdl = nvp->nvp_bm_hdl; in nv_bm_status_clear()
4342 ret = status = nv_get8(bmhdl, nvp->nvp_bmisx); in nv_bm_status_clear()
4349 nv_put8(bmhdl, nvp->nvp_bmisx, status); in nv_bm_status_clear()
4360 nv_start_dma_engine(nv_port_t *nvp, int slot) in nv_start_dma_engine() argument
4362 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_start_dma_engine()
4363 ddi_acc_handle_t bmhdl = nvp->nvp_bm_hdl; in nv_start_dma_engine()
4375 NVLOG(NVDBG_DELIVER, nvp->nvp_ctlp, nvp, in nv_start_dma_engine()
4383 (void) nv_bm_status_clear(nvp); in nv_start_dma_engine()
4388 nv_put32(bmhdl, nvp->nvp_bmidtpx, nvp->nvp_sg_paddr[slot]); in nv_start_dma_engine()
4393 nv_put8(bmhdl, nvp->nvp_bmicx, direction | BMICX_SSBM); in nv_start_dma_engine()
4400 nv_start_dma(nv_port_t *nvp, int slot) in nv_start_dma() argument
4402 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_start_dma()
4403 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_start_dma()
4410 ddi_acc_handle_t sghdl = nvp->nvp_sg_acc_hdl[slot]; in nv_start_dma()
4411 uint_t *dstp = (uint_t *)nvp->nvp_sg_addr[slot]; in nv_start_dma()
4418 nv_cmn_err(CE_WARN, nvp->nvp_ctlp, nvp, "NV_DMA_NSEGS=%d <" in nv_start_dma()
4425 nv_program_taskfile_regs(nvp, slot); in nv_start_dma()
4430 nv_put8(cmdhdl, nvp->nvp_cmd, cmd); in nv_start_dma()
4477 (void) ddi_dma_sync(nvp->nvp_sg_dma_hdl[slot], 0, in nv_start_dma()
4480 nv_start_dma_engine(nvp, slot); in nv_start_dma()
4492 NVLOG(NVDBG_DELIVER, nvp->nvp_ctlp, nvp, in nv_start_dma()
4495 nv_start_dma_engine(nvp, slot); in nv_start_dma()
4497 NVLOG(NVDBG_DELIVER, nvp->nvp_ctlp, nvp, "NCQ, so program " in nv_start_dma()
4510 nv_start_pio_in(nv_port_t *nvp, int slot) in nv_start_pio_in() argument
4513 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_start_pio_in()
4515 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_start_pio_in()
4517 nv_program_taskfile_regs(nvp, slot); in nv_start_pio_in()
4522 nv_put8(cmdhdl, nvp->nvp_cmd, spkt->satapkt_cmd.satacmd_cmd_reg); in nv_start_pio_in()
4532 nv_start_pio_out(nv_port_t *nvp, int slot) in nv_start_pio_out() argument
4534 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_start_pio_out()
4535 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_start_pio_out()
4538 nv_program_taskfile_regs(nvp, slot); in nv_start_pio_out()
4543 nv_put8(cmdhdl, nvp->nvp_cmd, spkt->satapkt_cmd.satacmd_cmd_reg); in nv_start_pio_out()
4558 if (nv_wait3(nvp, SATA_STATUS_DRQ, SATA_STATUS_BSY, /* okay */ in nv_start_pio_out()
4570 nv_intr_pio_out(nvp, nv_slotp); in nv_start_pio_out()
4586 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_start_pio_out()
4587 nv_complete_io(nvp, spkt, 0); in nv_start_pio_out()
4588 nv_reset(nvp, "pio_out"); in nv_start_pio_out()
4598 nv_start_pkt_pio(nv_port_t *nvp, int slot) in nv_start_pkt_pio() argument
4600 nv_slot_t *nv_slotp = &(nvp->nvp_slot[slot]); in nv_start_pkt_pio()
4602 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_start_pkt_pio()
4605 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_pkt_pio()
4615 nv_put8(cmdhdl, nvp->nvp_drvhd, satacmd->satacmd_device_reg); in nv_start_pkt_pio()
4618 if (nv_wait(nvp, SATA_STATUS_DRDY, SATA_STATUS_BSY, in nv_start_pkt_pio()
4620 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_pkt_pio()
4630 nv_put8(cmdhdl, nvp->nvp_feature, 0); /* deassert DMA and OVL */ in nv_start_pkt_pio()
4633 nv_put8(cmdhdl, nvp->nvp_hcyl, satacmd->satacmd_lba_high_lsb); in nv_start_pkt_pio()
4634 nv_put8(cmdhdl, nvp->nvp_lcyl, satacmd->satacmd_lba_mid_lsb); in nv_start_pkt_pio()
4635 nv_put8(cmdhdl, nvp->nvp_sect, satacmd->satacmd_lba_low_lsb); in nv_start_pkt_pio()
4636 nv_put8(cmdhdl, nvp->nvp_count, satacmd->satacmd_sec_count_lsb); in nv_start_pkt_pio()
4639 nv_put8(cmdhdl, nvp->nvp_cmd, spkt->satapkt_cmd.satacmd_cmd_reg); in nv_start_pkt_pio()
4649 if (nv_wait3(nvp, SATA_STATUS_DRQ, SATA_STATUS_BSY, /* okay */ in nv_start_pkt_pio()
4661 if (nv_get8(cmdhdl, nvp->nvp_status) & in nv_start_pkt_pio()
4665 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_pkt_pio()
4670 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_pkt_pio()
4674 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_start_pkt_pio()
4675 nv_complete_io(nvp, spkt, 0); in nv_start_pkt_pio()
4676 nv_reset(nvp, "start_pkt_pio"); in nv_start_pkt_pio()
4687 (ushort_t *)nvp->nvp_data, in nv_start_pkt_pio()
4695 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_pkt_pio()
4706 nv_intr_nodata(nv_port_t *nvp, nv_slot_t *nv_slotp) in nv_intr_nodata() argument
4711 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_intr_nodata()
4712 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_intr_nodata()
4714 NVLOG(NVDBG_INTR, nvp->nvp_ctlp, nvp, "nv_intr_nodata entered", NULL); in nv_intr_nodata()
4716 status = nv_get8(cmdhdl, nvp->nvp_status); in nv_intr_nodata()
4724 nvp->nvp_altstatus); in nv_intr_nodata()
4725 sata_cmdp->satacmd_error_reg = nv_get8(cmdhdl, nvp->nvp_error); in nv_intr_nodata()
4738 nv_intr_pio_in(nv_port_t *nvp, nv_slot_t *nv_slotp) in nv_intr_pio_in() argument
4743 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_intr_pio_in()
4744 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_intr_pio_in()
4747 status = nv_get8(cmdhdl, nvp->nvp_status); in nv_intr_pio_in()
4753 nvp->nvp_altstatus); in nv_intr_pio_in()
4754 sata_cmdp->satacmd_error_reg = nv_get8(cmdhdl, nvp->nvp_error); in nv_intr_pio_in()
4755 nv_reset(nvp, "intr_pio_in"); in nv_intr_pio_in()
4765 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_intr_pio_in()
4783 (ushort_t *)nvp->nvp_data, (count >> 1), DDI_DEV_NO_AUTOINCR); in nv_intr_pio_in()
4810 nv_intr_pio_out(nv_port_t *nvp, nv_slot_t *nv_slotp) in nv_intr_pio_out() argument
4815 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_intr_pio_out()
4816 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_intr_pio_out()
4822 status = nv_get8(cmdhdl, nvp->nvp_status); in nv_intr_pio_out()
4831 nvp->nvp_altstatus); in nv_intr_pio_out()
4832 sata_cmdp->satacmd_error_reg = nv_get8(cmdhdl, nvp->nvp_error); in nv_intr_pio_out()
4841 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_intr_pio_out()
4865 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_intr_pio_out()
4885 (ushort_t *)nvp->nvp_data, (count >> 1), DDI_DEV_NO_AUTOINCR); in nv_intr_pio_out()
4904 nv_intr_pkt_pio(nv_port_t *nvp, nv_slot_t *nv_slotp) in nv_intr_pkt_pio() argument
4910 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_intr_pkt_pio()
4911 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_intr_pkt_pio()
4917 status = nv_get8(cmdhdl, nvp->nvp_status); in nv_intr_pkt_pio()
4918 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
4928 nv_reset(nvp, "intr_pkt_pio"); in nv_intr_pkt_pio()
4931 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
4944 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_intr_pkt_pio()
4951 nvp->nvp_altstatus); in nv_intr_pkt_pio()
4953 nvp->nvp_error); in nv_intr_pkt_pio()
4955 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
4970 if (nv_start_rqsense_pio(nvp, nv_slotp) == in nv_intr_pkt_pio()
4972 nv_copy_registers(nvp, &spkt->satapkt_device, in nv_intr_pkt_pio()
4979 nvp->nvp_altstatus); in nv_intr_pkt_pio()
4981 nvp->nvp_error); in nv_intr_pkt_pio()
4986 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_intr_pkt_pio()
4989 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5005 (uint16_t)nv_get8(cmdhdl, nvp->nvp_hcyl) << 8; in nv_intr_pkt_pio()
5006 ctlr_count |= nv_get8(cmdhdl, nvp->nvp_lcyl); in nv_intr_pkt_pio()
5008 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5018 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5029 (ushort_t *)nvp->nvp_data, (count >> 1), in nv_intr_pkt_pio()
5038 (ushort_t *)nvp->nvp_data); in nv_intr_pkt_pio()
5041 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5060 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5075 ctlr_count = (uint16_t)nv_get8(cmdhdl, nvp->nvp_hcyl) << 8; in nv_intr_pkt_pio()
5076 ctlr_count |= nv_get8(cmdhdl, nvp->nvp_lcyl); in nv_intr_pkt_pio()
5084 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5092 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5095 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5104 (ushort_t *)nvp->nvp_data, (count >> 1), in nv_intr_pkt_pio()
5115 (ushort_t *)nvp->nvp_data); in nv_intr_pkt_pio()
5117 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5123 (ushort_t *)nvp->nvp_data, (count >> 1), in nv_intr_pkt_pio()
5130 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5138 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_intr_pkt_pio()
5148 nv_intr_dma(nv_port_t *nvp, struct nv_slot *nv_slotp) in nv_intr_dma() argument
5153 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_intr_dma()
5154 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_intr_dma()
5155 ddi_acc_handle_t bmhdl = nvp->nvp_bm_hdl; in nv_intr_dma()
5164 bmicx = nv_get8(bmhdl, nvp->nvp_bmicx); in nv_intr_dma()
5165 nv_put8(bmhdl, nvp->nvp_bmicx, bmicx & ~BMICX_SSBM); in nv_intr_dma()
5170 status = nv_get8(cmdhdl, nvp->nvp_status); in nv_intr_dma()
5176 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_intr_dma()
5178 (void) nv_bm_status_clear(nvp); in nv_intr_dma()
5183 bm_status = nv_bm_status_clear(nvp); in nv_intr_dma()
5192 nvp->nvp_altstatus); in nv_intr_dma()
5193 sata_cmdp->satacmd_error_reg = nv_get8(cmdhdl, nvp->nvp_error); in nv_intr_dma()
5194 nv_reset(nvp, "intr_dma"); in nv_intr_dma()
5215 nv_wait(nv_port_t *nvp, uchar_t onbits, uchar_t offbits, uint_t timeout_usec, in nv_wait() argument
5218 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_wait()
5224 val = nv_get8(ctlhdl, nvp->nvp_altstatus); in nv_wait()
5284 nv_port_t *nvp, in nv_wait3() argument
5294 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_wait3()
5300 val = nv_get8(ctlhdl, nvp->nvp_altstatus); in nv_wait3()
5374 nv_port_state_change(nv_port_t *nvp, int event, uint8_t addr_type, int state) in nv_port_state_change() argument
5378 NVLOG(NVDBG_EVENT, nvp->nvp_ctlp, nvp, in nv_port_state_change()
5389 nv_copy_registers(nvp, &sd, NULL); in nv_port_state_change()
5395 sd.satadev_addr.cport = nvp->nvp_port_num; in nv_port_state_change()
5399 sata_hba_event_notify(nvp->nvp_ctlp->nvc_dip, &sd, event); in nv_port_state_change()
5407 nv_monitor_reset(nv_port_t *nvp) in nv_monitor_reset() argument
5409 ddi_acc_handle_t bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_monitor_reset()
5412 ASSERT(MUTEX_HELD(&nvp->nvp_mutex)); in nv_monitor_reset()
5414 sstatus = nv_get32(bar5_hdl, nvp->nvp_sstatus); in nv_monitor_reset()
5430 if (TICK_TO_MSEC(ddi_get_lbolt() - nvp->nvp_reset_time) >= in nv_monitor_reset()
5433 nv_cmn_err(CE_NOTE, nvp->nvp_ctlp, nvp, in nv_monitor_reset()
5437 nvp->nvp_reset_time)); in nv_monitor_reset()
5446 if (nvp->nvp_type != SATA_DTYPE_NONE) { in nv_monitor_reset()
5447 nv_port_state_change(nvp, in nv_monitor_reset()
5452 nvp->nvp_type = SATA_DTYPE_NONE; in nv_monitor_reset()
5453 nvp->nvp_signature = NV_NO_SIG; in nv_monitor_reset()
5454 nvp->nvp_state &= ~(NV_DEACTIVATED); in nv_monitor_reset()
5457 nv_sgp_drive_disconnect(nvp->nvp_ctlp, in nv_monitor_reset()
5459 nvp->nvp_ctlp->nvc_ctlr_num, in nv_monitor_reset()
5460 nvp->nvp_port_num)); in nv_monitor_reset()
5463 cv_signal(&nvp->nvp_reset_cv); in nv_monitor_reset()
5470 return (nvp->nvp_wait_sig); in nv_monitor_reset()
5473 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_monitor_reset()
5475 TICK_TO_MSEC(ddi_get_lbolt() - nvp->nvp_reset_time)); in nv_monitor_reset()
5477 nv_read_signature(nvp); in nv_monitor_reset()
5480 if (nvp->nvp_signature != NV_NO_SIG) { in nv_monitor_reset()
5485 if (nvp->nvp_state & (NV_ATTACH|NV_HOTPLUG)) { in nv_monitor_reset()
5488 if (nvp->nvp_state & NV_HOTPLUG) { in nv_monitor_reset()
5491 nv_port_state_change(nvp, in nv_monitor_reset()
5495 int, nvp->nvp_state); in nv_monitor_reset()
5500 int, nvp->nvp_state); in nv_monitor_reset()
5503 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_monitor_reset()
5506 nvp->nvp_signature, nvp->nvp_state, nvp->nvp_type); in nv_monitor_reset()
5509 nvp->nvp_state &= ~(NV_RESET|NV_ATTACH|NV_HOTPLUG); in nv_monitor_reset()
5512 if (nvp->nvp_type == SATA_DTYPE_ATADISK) { in nv_monitor_reset()
5513 nv_sgp_drive_connect(nvp->nvp_ctlp, in nv_monitor_reset()
5515 nvp->nvp_ctlp->nvc_ctlr_num, in nv_monitor_reset()
5516 nvp->nvp_port_num)); in nv_monitor_reset()
5518 nv_sgp_drive_disconnect(nvp->nvp_ctlp, in nv_monitor_reset()
5520 nvp->nvp_ctlp->nvc_ctlr_num, in nv_monitor_reset()
5521 nvp->nvp_port_num)); in nv_monitor_reset()
5525 cv_signal(&nvp->nvp_reset_cv); in nv_monitor_reset()
5534 nvp->nvp_state &= ~NV_RESET; in nv_monitor_reset()
5535 nvp->nvp_state |= NV_RESTORE; in nv_monitor_reset()
5540 DTRACE_PROBE1(nvp_signature_h, int, nvp->nvp_signature); in nv_monitor_reset()
5541 DTRACE_PROBE1(nvp_state_h, int, nvp->nvp_state); in nv_monitor_reset()
5543 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_monitor_reset()
5545 " state: 0x%x", nvp->nvp_signature, nvp->nvp_state); in nv_monitor_reset()
5552 (*(nvp->nvp_ctlp->nvc_set_intr))(nvp, in nv_monitor_reset()
5555 nv_port_state_change(nvp, SATA_EVNT_DEVICE_RESET, in nv_monitor_reset()
5563 if (TICK_TO_MSEC(ddi_get_lbolt() - nvp->nvp_reset_time) > in nv_monitor_reset()
5567 if (nvp->nvp_reset_retry_count >= NV_MAX_RESET_RETRY) { in nv_monitor_reset()
5569 nvp->nvp_state |= NV_FAILED; in nv_monitor_reset()
5570 nvp->nvp_state &= ~(NV_RESET|NV_ATTACH|NV_HOTPLUG); in nv_monitor_reset()
5574 DTRACE_PROBE1(nvp_state_h, int, nvp->nvp_state); in nv_monitor_reset()
5575 NVLOG(NVDBG_RESET, nvp->nvp_ctlp, nvp, in nv_monitor_reset()
5577 nvp->nvp_state); in nv_monitor_reset()
5579 nv_port_state_change(nvp, SATA_EVNT_PORT_FAILED, in nv_monitor_reset()
5582 cv_signal(&nvp->nvp_reset_cv); in nv_monitor_reset()
5587 nv_reset(nvp, "retry"); in nv_monitor_reset()
5589 return (nvp->nvp_wait_sig); in nv_monitor_reset()
5601 nvp->nvp_wait_sig = nvp->nvp_wait_sig * 2; in nv_monitor_reset()
5603 return (nvp->nvp_wait_sig > NV_ONE_SEC ? NV_ONE_SEC : in nv_monitor_reset()
5604 nvp->nvp_wait_sig); in nv_monitor_reset()
5623 nv_port_t *nvp = arg; in nv_timeout() local
5632 ASSERT(nvp != NULL); in nv_timeout()
5634 mutex_enter(&nvp->nvp_mutex); in nv_timeout()
5635 nvp->nvp_timeout_id = 0; in nv_timeout()
5637 if (nvp->nvp_state & (NV_DEACTIVATED|NV_FAILED)) { in nv_timeout()
5643 if (nvp->nvp_state & NV_RESET) { in nv_timeout()
5644 next_timeout_us = nv_monitor_reset(nvp); in nv_timeout()
5649 if (nvp->nvp_state & NV_LINK_EVENT) { in nv_timeout()
5652 ddi_acc_handle_t bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_timeout()
5655 nvp->nvp_link_event_time) < NV_LINK_EVENT_SETTLE) { in nv_timeout()
5666 nvp->nvp_state &= ~NV_LINK_EVENT; in nv_timeout()
5675 sstatus = nv_get32(bar5_hdl, nvp->nvp_sstatus); in nv_timeout()
5683 if ((nvp->nvp_signature != NV_NO_SIG) && in nv_timeout()
5686 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, in nv_timeout()
5691 (void) nv_abort_active(nvp, NULL, SATA_PKT_PORT_ERROR, in nv_timeout()
5694 nv_port_state_change(nvp, SATA_EVNT_DEVICE_DETACHED, in nv_timeout()
5697 nvp->nvp_signature = NV_NO_SIG; in nv_timeout()
5698 nvp->nvp_rem_time = ddi_get_lbolt(); in nv_timeout()
5699 nvp->nvp_type = SATA_DTYPE_NONE; in nv_timeout()
5703 nv_sgp_drive_disconnect(nvp->nvp_ctlp, in nv_timeout()
5704 SGP_CTLR_PORT_TO_DRV(nvp->nvp_ctlp->nvc_ctlr_num, in nv_timeout()
5705 nvp->nvp_port_num)); in nv_timeout()
5717 if ((nvp->nvp_signature != NV_NO_SIG) && in nv_timeout()
5720 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, in nv_timeout()
5724 (void) nv_abort_active(nvp, NULL, SATA_PKT_PORT_ERROR, in nv_timeout()
5727 nvp->nvp_signature = NV_NO_SIG; in nv_timeout()
5728 nvp->nvp_trans_link_time = ddi_get_lbolt(); in nv_timeout()
5729 nvp->nvp_trans_link_count++; in nv_timeout()
5732 nv_reset(nvp, "transient link event"); in nv_timeout()
5741 if ((nvp->nvp_signature == NV_NO_SIG) && in nv_timeout()
5743 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, in nv_timeout()
5747 nvp->nvp_add_time = ddi_get_lbolt(); in nv_timeout()
5749 nvp->nvp_reset_count = 0; in nv_timeout()
5750 nvp->nvp_state = NV_HOTPLUG; in nv_timeout()
5751 nvp->nvp_type = SATA_DTYPE_UNKNOWN; in nv_timeout()
5752 nv_reset(nvp, "hotplug"); in nv_timeout()
5761 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, in nv_timeout()
5766 nvp->nvp_trans_link_time = ddi_get_lbolt(); in nv_timeout()
5767 nvp->nvp_trans_link_count++; in nv_timeout()
5776 nv_slotp = &(nvp->nvp_slot[0]); in nv_timeout()
5810 serror = nv_get32(nvp->nvp_ctlp->nvc_bar_hdl[5], in nv_timeout()
5811 nvp->nvp_serror); in nv_timeout()
5812 status = nv_get8(nvp->nvp_ctl_hdl, in nv_timeout()
5813 nvp->nvp_altstatus); in nv_timeout()
5814 bmstatus = nv_get8(nvp->nvp_bm_hdl, in nv_timeout()
5815 nvp->nvp_bmisx); in nv_timeout()
5817 nv_cmn_err(CE_NOTE, nvp->nvp_ctlp, nvp, in nv_timeout()
5824 cmd, lba, nvp->nvp_seq); in nv_timeout()
5826 NVLOG(NVDBG_TIMEOUT, nvp->nvp_ctlp, nvp, in nv_timeout()
5830 nvp->nvp_previous_cmd); in nv_timeout()
5833 DTRACE_PROBE1(nv_timeout_packet_p, int, nvp); in nv_timeout()
5835 if (nvp->nvp_mcp5x_int_status != NULL) { in nv_timeout()
5838 nvp->nvp_ctlp->nvc_bar_hdl[5], in nv_timeout()
5839 nvp->nvp_mcp5x_int_status); in nv_timeout()
5840 NVLOG(NVDBG_TIMEOUT, nvp->nvp_ctlp, nvp, in nv_timeout()
5851 nvp->nvp_ctlp, in nv_timeout()
5852 nvp, in nv_timeout()
5859 NVLOG(NVDBG_TIMEOUT, nvp->nvp_ctlp, in nv_timeout()
5860 nvp, "timeout detected with " in nv_timeout()
5864 mutex_exit(&nvp->nvp_mutex); in nv_timeout()
5865 (void) mcp5x_intr_port(nvp); in nv_timeout()
5866 mutex_enter(&nvp->nvp_mutex); in nv_timeout()
5874 int *, nvp); in nv_timeout()
5875 (void) nv_abort_active(nvp, spkt, in nv_timeout()
5879 (void) nv_abort_active(nvp, spkt, in nv_timeout()
5884 NVLOG(NVDBG_VERBOSE, nvp->nvp_ctlp, nvp, in nv_timeout()
5896 NVLOG(NVDBG_VERBOSE, nvp->nvp_ctlp, nvp, in nv_timeout()
5903 nv_setup_timeout(nvp, next_timeout_us); in nv_timeout()
5905 mutex_exit(&nvp->nvp_mutex); in nv_timeout()
5914 ck804_set_intr(nv_port_t *nvp, int flag) in ck804_set_intr() argument
5916 nv_ctl_t *nvc = nvp->nvp_ctlp; in ck804_set_intr()
5922 uint8_t int_en, port = nvp->nvp_port_num, intr_status; in ck804_set_intr()
5933 ASSERT(mutex_owned(&nvp->nvp_mutex)); in ck804_set_intr()
5942 NVLOG(NVDBG_INTR, nvc, nvp, in ck804_set_intr()
5954 NVLOG(NVDBG_INTR, nvc, nvp, in ck804_set_intr()
5961 NVLOG(NVDBG_INTR, nvc, nvp, in ck804_set_intr()
5971 NVLOG(NVDBG_INTR, nvc, nvp, "ck804_set_intr: NV_INTR_ENABLE", in ck804_set_intr()
5989 mcp5x_set_intr(nv_port_t *nvp, int flag) in mcp5x_set_intr() argument
5991 nv_ctl_t *nvc = nvp->nvp_ctlp; in mcp5x_set_intr()
5998 int_en = nv_get16(bar5_hdl, nvp->nvp_mcp5x_int_ctl); in mcp5x_set_intr()
6000 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_ctl, int_en); in mcp5x_set_intr()
6004 ASSERT(mutex_owned(&nvp->nvp_mutex)); in mcp5x_set_intr()
6006 NVLOG(NVDBG_INTR, nvc, nvp, "mcp055_set_intr: enter flag: %d", flag); in mcp5x_set_intr()
6009 NVLOG(NVDBG_INTR, nvc, nvp, in mcp5x_set_intr()
6011 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_status, MCP5X_INT_CLEAR); in mcp5x_set_intr()
6015 NVLOG(NVDBG_INTR, nvc, nvp, "mcp5x_set_intr: NV_INTR_ENABLE", in mcp5x_set_intr()
6017 int_en = nv_get16(bar5_hdl, nvp->nvp_mcp5x_int_ctl); in mcp5x_set_intr()
6019 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_ctl, int_en); in mcp5x_set_intr()
6023 NVLOG(NVDBG_INTR, nvc, nvp, in mcp5x_set_intr()
6025 int_en = nv_get16(bar5_hdl, nvp->nvp_mcp5x_int_ctl); in mcp5x_set_intr()
6027 nv_put16(bar5_hdl, nvp->nvp_mcp5x_int_ctl, int_en); in mcp5x_set_intr()
6033 nv_resume(nv_port_t *nvp) in nv_resume() argument
6035 NVLOG(NVDBG_INIT, nvp->nvp_ctlp, nvp, "nv_resume()", NULL); in nv_resume()
6037 mutex_enter(&nvp->nvp_mutex); in nv_resume()
6039 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_resume()
6040 mutex_exit(&nvp->nvp_mutex); in nv_resume()
6046 (*(nvp->nvp_ctlp->nvc_set_intr))(nvp, NV_INTR_CLEAR_ALL|NV_INTR_ENABLE); in nv_resume()
6054 nv_reset(nvp, "resume"); in nv_resume()
6056 mutex_exit(&nvp->nvp_mutex); in nv_resume()
6061 nv_suspend(nv_port_t *nvp) in nv_suspend() argument
6063 NVLOG(NVDBG_INIT, nvp->nvp_ctlp, nvp, "nv_suspend()", NULL); in nv_suspend()
6065 mutex_enter(&nvp->nvp_mutex); in nv_suspend()
6068 if (nvp->nvp_type == SATA_DTYPE_ATADISK) { in nv_suspend()
6069 nv_sgp_drive_disconnect(nvp->nvp_ctlp, SGP_CTLR_PORT_TO_DRV( in nv_suspend()
6070 nvp->nvp_ctlp->nvc_ctlr_num, nvp->nvp_port_num)); in nv_suspend()
6074 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_suspend()
6075 mutex_exit(&nvp->nvp_mutex); in nv_suspend()
6084 if (nvp->nvp_timeout_id) { in nv_suspend()
6085 (void) untimeout(nvp->nvp_timeout_id); in nv_suspend()
6086 nvp->nvp_timeout_id = 0; in nv_suspend()
6090 (*(nvp->nvp_ctlp->nvc_set_intr))(nvp, in nv_suspend()
6093 mutex_exit(&nvp->nvp_mutex); in nv_suspend()
6098 nv_copy_registers(nv_port_t *nvp, sata_device_t *sd, sata_pkt_t *spkt) in nv_copy_registers() argument
6100 ddi_acc_handle_t bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_copy_registers()
6102 ddi_acc_handle_t ctlhdl = nvp->nvp_ctl_hdl; in nv_copy_registers()
6103 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_copy_registers()
6107 sd->satadev_scr.sstatus = nv_get32(bar5_hdl, nvp->nvp_sstatus); in nv_copy_registers()
6108 sd->satadev_scr.serror = nv_get32(bar5_hdl, nvp->nvp_serror); in nv_copy_registers()
6109 sd->satadev_scr.scontrol = nv_get32(bar5_hdl, nvp->nvp_sctrl); in nv_copy_registers()
6121 nvp->nvp_altstatus); in nv_copy_registers()
6143 nv_put8(ctlhdl, nvp->nvp_devctl, ATDC_HOB|ATDC_D3); in nv_copy_registers()
6150 nv_get8(cmdhdl, nvp->nvp_count); in nv_copy_registers()
6155 nv_get8(cmdhdl, nvp->nvp_sect); in nv_copy_registers()
6160 nv_get8(cmdhdl, nvp->nvp_lcyl); in nv_copy_registers()
6165 nv_get8(cmdhdl, nvp->nvp_hcyl); in nv_copy_registers()
6172 nv_put8(ctlhdl, nvp->nvp_devctl, ATDC_D3); in nv_copy_registers()
6178 scmd->satacmd_sec_count_lsb = nv_get8(cmdhdl, nvp->nvp_count); in nv_copy_registers()
6182 scmd->satacmd_lba_low_lsb = nv_get8(cmdhdl, nvp->nvp_sect); in nv_copy_registers()
6186 scmd->satacmd_lba_mid_lsb = nv_get8(cmdhdl, nvp->nvp_lcyl); in nv_copy_registers()
6190 scmd->satacmd_lba_high_lsb = nv_get8(cmdhdl, nvp->nvp_hcyl); in nv_copy_registers()
6197 scmd->satacmd_device_reg = nv_get8(cmdhdl, nvp->nvp_drvhd); in nv_copy_registers()
6204 scmd->satacmd_error_reg = nv_get8(cmdhdl, nvp->nvp_error); in nv_copy_registers()
6219 nv_link_event(nv_port_t *nvp, int flag) in nv_link_event() argument
6222 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, "nv_link_event: flag: %s", in nv_link_event()
6225 ASSERT(MUTEX_HELD(&nvp->nvp_mutex)); in nv_link_event()
6227 nvp->nvp_link_event_time = ddi_get_lbolt(); in nv_link_event()
6232 if (nvp->nvp_state & NV_DEACTIVATED) { in nv_link_event()
6233 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, "ignoring link event" in nv_link_event()
6244 if (nvp->nvp_state & NV_RESET) { in nv_link_event()
6245 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, "ignoring link event" in nv_link_event()
6256 if (nvp->nvp_state & NV_LINK_EVENT) { in nv_link_event()
6258 NVLOG(NVDBG_HOT, nvp->nvp_ctlp, nvp, in nv_link_event()
6266 DTRACE_PROBE1(link_event_p, int, nvp); in nv_link_event()
6268 nvp->nvp_state |= NV_LINK_EVENT; in nv_link_event()
6270 nv_setup_timeout(nvp, NV_LINK_EVENT_SETTLE); in nv_link_event()
6292 nv_start_rqsense_pio(nv_port_t *nvp, nv_slot_t *nv_slotp) in nv_start_rqsense_pio() argument
6296 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_start_rqsense_pio()
6299 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_rqsense_pio()
6308 nv_put8(cmdhdl, nvp->nvp_drvhd, satacmd->satacmd_device_reg); in nv_start_rqsense_pio()
6311 if (nv_wait(nvp, SATA_STATUS_DRDY, SATA_STATUS_BSY, in nv_start_rqsense_pio()
6313 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_rqsense_pio()
6319 nv_put8(cmdhdl, nvp->nvp_feature, 0); /* deassert DMA and OVL */ in nv_start_rqsense_pio()
6320 nv_put8(cmdhdl, nvp->nvp_hcyl, SATA_ATAPI_MAX_BYTES_PER_DRQ >> 8); in nv_start_rqsense_pio()
6321 nv_put8(cmdhdl, nvp->nvp_lcyl, SATA_ATAPI_MAX_BYTES_PER_DRQ & 0xff); in nv_start_rqsense_pio()
6322 nv_put8(cmdhdl, nvp->nvp_sect, 0); in nv_start_rqsense_pio()
6323 nv_put8(cmdhdl, nvp->nvp_count, 0); /* no tag */ in nv_start_rqsense_pio()
6326 nv_put8(cmdhdl, nvp->nvp_cmd, SATAC_PACKET); in nv_start_rqsense_pio()
6336 if (nv_wait3(nvp, SATA_STATUS_DRQ, SATA_STATUS_BSY, /* okay */ in nv_start_rqsense_pio()
6340 if (nv_get8(cmdhdl, nvp->nvp_status) & in nv_start_rqsense_pio()
6343 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_rqsense_pio()
6348 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_rqsense_pio()
6353 nv_copy_registers(nvp, &spkt->satapkt_device, spkt); in nv_start_rqsense_pio()
6354 nv_complete_io(nvp, spkt, 0); in nv_start_rqsense_pio()
6355 nv_reset(nvp, "rqsense_pio"); in nv_start_rqsense_pio()
6366 (ushort_t *)nvp->nvp_data, in nv_start_rqsense_pio()
6369 NVLOG(NVDBG_ATAPI, nvp->nvp_ctlp, nvp, in nv_start_rqsense_pio()
6395 nv_port_t *nvp = &(nvc->nvc_port[port]); in nv_quiesce() local
6396 ddi_acc_handle_t cmdhdl = nvp->nvp_cmd_hdl; in nv_quiesce()
6397 ddi_acc_handle_t bar5_hdl = nvp->nvp_ctlp->nvc_bar_hdl[5]; in nv_quiesce()
6403 (*(nvc->nvc_set_intr))(nvp, NV_INTR_DISABLE_NON_BLOCKING); in nv_quiesce()
6408 nv_put8(cmdhdl, nvp->nvp_sect, 0); in nv_quiesce()
6409 nv_put8(cmdhdl, nvp->nvp_lcyl, 0); in nv_quiesce()
6410 nv_put8(cmdhdl, nvp->nvp_hcyl, 0); in nv_quiesce()
6411 nv_put8(cmdhdl, nvp->nvp_count, 0); in nv_quiesce()
6413 nvp->nvp_signature = NV_NO_SIG; in nv_quiesce()
6414 nvp->nvp_type = SATA_DTYPE_NONE; in nv_quiesce()
6415 nvp->nvp_state |= NV_RESET; in nv_quiesce()
6416 nvp->nvp_reset_time = ddi_get_lbolt(); in nv_quiesce()
6421 sctrl = nv_get32(bar5_hdl, nvp->nvp_sctrl); in nv_quiesce()
6423 nv_put32(bar5_hdl, nvp->nvp_sctrl, in nv_quiesce()
6434 nv_put32(bar5_hdl, nvp->nvp_sctrl, sctrl); in nv_quiesce()