Lines Matching refs:chp
199 ata_channel_attach(struct ata_channel *chp) in ata_channel_attach() argument
201 if (chp->ch_flags & ATACH_DISABLED) in ata_channel_attach()
204 ata_channel_init(chp); in ata_channel_attach()
206 KASSERT(chp->ch_queue != NULL); in ata_channel_attach()
208 chp->atabus = config_found(chp->ch_atac->atac_dev, chp, atabusprint, in ata_channel_attach()
218 ata_channel_detach(struct ata_channel *chp) in ata_channel_detach() argument
220 if (chp->ch_flags & ATACH_DISABLED) in ata_channel_detach()
223 ata_channel_destroy(chp); in ata_channel_detach()
225 chp->ch_flags |= ATACH_DETACHED; in ata_channel_detach()
231 struct ata_channel *chp = atabus_sc->sc_chan; in atabusconfig() local
232 struct atac_softc *atac = chp->ch_atac; in atabusconfig()
243 if (chp->ch_satapmp_nports == 0) in atabusconfig()
244 (*atac->atac_probe)(chp); in atabusconfig()
246 if (chp->ch_ndrives >= 2) { in atabusconfig()
248 chp->ch_drive[0].drive_type, chp->ch_drive[1].drive_type), in atabusconfig()
262 ata_channel_lock(chp); in atabusconfig()
264 KASSERT(ata_is_thread_run(chp)); in atabusconfig()
267 if (chp->ch_drive == NULL) in atabusconfig()
269 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabusconfig()
270 for (i = 0; i < chp->ch_ndrives; i++) in atabusconfig()
271 if (chp->ch_drive[i].drive_type != ATA_DRIVET_NONE) in atabusconfig()
273 if (i == chp->ch_ndrives) in atabusconfig()
277 if (chp->ch_flags & ATACH_SHUTDOWN) in atabusconfig()
280 ata_channel_unlock(chp); in atabusconfig()
290 ata_channel_unlock(chp); in atabusconfig()
299 ata_delref(chp); in atabusconfig()
312 struct ata_channel *chp = atabus_sc->sc_chan; in atabusconfig_thread() local
313 struct atac_softc *atac = chp->ch_atac; in atabusconfig_thread()
326 if (chp->ch_ndrives == PMP_MAX_DRIVES && in atabusconfig_thread()
327 chp->ch_drive[PMP_PORT_CTL].drive_type == ATA_DRIVET_PM) { in atabusconfig_thread()
329 satapmp_attach(chp); in atabusconfig_thread()
340 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabusconfig_thread()
341 for (i = 0; i < chp->ch_ndrives && chp->atapibus == NULL; i++) { in atabusconfig_thread()
342 if (chp->ch_drive[i].drive_type == ATA_DRIVET_ATAPI) { in atabusconfig_thread()
351 chp->atapibus = NULL; in atabusconfig_thread()
353 for (i = 0; i < chp->ch_ndrives; i++) { in atabusconfig_thread()
354 if (chp->ch_drive[i].drive_type == ATA_DRIVET_ATAPI) in atabusconfig_thread()
355 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabusconfig_thread()
363 for (i = 0; i < chp->ch_ndrives; i++) { in atabusconfig_thread()
365 if (chp->ch_drive[i].drive_type != ATA_DRIVET_ATA && in atabusconfig_thread()
366 chp->ch_drive[i].drive_type != ATA_DRIVET_OLD) { in atabusconfig_thread()
369 if (chp->ch_drive[i].drv_softc != NULL) in atabusconfig_thread()
373 adev.adev_channel = chp->ch_channel; in atabusconfig_thread()
374 adev.adev_drv_data = &chp->ch_drive[i]; in atabusconfig_thread()
375 chp->ch_drive[i].drv_softc = config_found(atabus_sc->sc_dev, in atabusconfig_thread()
378 if (chp->ch_drive[i].drv_softc != NULL) { in atabusconfig_thread()
379 ata_probe_caps(&chp->ch_drive[i]); in atabusconfig_thread()
382 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabusconfig_thread()
389 (*atac->atac_set_modes)(chp); in atabusconfig_thread()
390 ata_print_modes(chp); in atabusconfig_thread()
394 for (i = 0; i < chp->ch_ndrives; i++) { in atabusconfig_thread()
395 if (chp->ch_drive[i].drive_type == ATA_DRIVET_ATA) { in atabusconfig_thread()
397 chp->ch_drive[i].drv_softc); in atabusconfig_thread()
408 for (i = 0; i < chp->ch_ndrives; i++) { in atabusconfig_thread()
409 if (chp->ch_drive[i].drive_type == ATA_DRIVET_PM) in atabusconfig_thread()
411 if (chp->ch_drive[i].drv_softc == NULL) { in atabusconfig_thread()
412 chp->ch_drive[i].drive_flags = 0; in atabusconfig_thread()
413 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabusconfig_thread()
415 chp->ch_drive[i].state = 0; in atabusconfig_thread()
426 ata_delref(chp); in atabusconfig_thread()
441 struct ata_channel *chp = sc->sc_chan; in atabus_thread() local
442 struct ata_queue *chq = chp->ch_queue; in atabus_thread()
446 ata_channel_lock(chp); in atabus_thread()
447 KASSERT(ata_is_thread_run(chp)); in atabus_thread()
455 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabus_thread()
456 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_thread()
457 chp->ch_drive[i].drive_flags = 0; in atabus_thread()
458 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabus_thread()
460 ata_channel_unlock(chp); in atabus_thread()
464 ata_channel_lock(chp); in atabus_thread()
466 if ((chp->ch_flags & (ATACH_TH_RESET | ATACH_TH_DRIVE_RESET in atabus_thread()
469 cv_wait(&chp->ch_thr_idle, &chp->ch_lock); in atabus_thread()
471 if (chp->ch_flags & ATACH_SHUTDOWN) { in atabus_thread()
474 if (chp->ch_flags & ATACH_TH_RESCAN) { in atabus_thread()
475 chp->ch_flags &= ~ATACH_TH_RESCAN; in atabus_thread()
476 ata_channel_unlock(chp); in atabus_thread()
478 ata_channel_lock(chp); in atabus_thread()
480 if (chp->ch_flags & ATACH_TH_RESET) { in atabus_thread()
482 ata_thread_run(chp, AT_WAIT, in atabus_thread()
484 } else if (chp->ch_flags & ATACH_TH_DRIVE_RESET) { in atabus_thread()
486 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_thread()
489 drvp = &chp->ch_drive[i]; in atabus_thread()
492 ata_thread_run(chp, in atabus_thread()
496 chp->ch_flags &= ~ATACH_TH_DRIVE_RESET; in atabus_thread()
497 } else if (chp->ch_flags & ATACH_TH_RECOVERY) { in atabus_thread()
504 ata_thread_run(chp, AT_WAIT, ATACH_TH_RECOVERY, in atabus_thread()
505 chp->recovery_tfd); in atabus_thread()
512 KASSERT((chp->ch_flags & ATACH_NCQ) == 0); in atabus_thread()
515 ata_channel_thaw_locked(chp); in atabus_thread()
516 xfer = ata_queue_get_active_xfer_locked(chp); in atabus_thread()
537 ata_channel_unlock(chp); in atabus_thread()
538 atastart(chp); in atabus_thread()
539 ata_channel_lock(chp); in atabus_thread()
542 chp->ch_thread = NULL; in atabus_thread()
543 cv_signal(&chp->ch_thr_idle); in atabus_thread()
544 ata_channel_unlock(chp); in atabus_thread()
549 ata_is_thread_run(struct ata_channel *chp) in ata_is_thread_run() argument
551 KASSERT(mutex_owned(&chp->ch_lock)); in ata_is_thread_run()
553 return (chp->ch_thread == curlwp && !cpu_intr_p()); in ata_is_thread_run()
557 ata_thread_wake_locked(struct ata_channel *chp) in ata_thread_wake_locked() argument
559 KASSERT(mutex_owned(&chp->ch_lock)); in ata_thread_wake_locked()
560 ata_channel_freeze_locked(chp); in ata_thread_wake_locked()
561 cv_signal(&chp->ch_thr_idle); in ata_thread_wake_locked()
572 struct ata_channel *chp = aux; in atabus_match() local
574 if (chp == NULL) in atabus_match()
577 if (cf->cf_loc[ATACF_CHANNEL] != chp->ch_channel && in atabus_match()
593 struct ata_channel *chp = aux; in atabus_attach() local
597 sc->sc_chan = chp; in atabus_attach()
604 if (ata_addref(chp)) in atabus_attach()
618 &chp->ch_thread, "%s", device_xname(self))) != 0) in atabus_attach()
635 struct ata_channel *chp = sc->sc_chan; in atabus_detach() local
642 if ((dev = chp->atapibus) != NULL) { in atabus_detach()
649 KASSERT(chp->atapibus == NULL); in atabus_detach()
652 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabus_detach()
657 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_detach()
658 if (chp->ch_drive[i].drive_type == ATA_DRIVET_ATAPI) in atabus_detach()
660 if (chp->ch_drive[i].drive_type == ATA_DRIVET_PM) in atabus_detach()
661 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabus_detach()
662 if ((dev = chp->ch_drive[i].drv_softc) != NULL) { in atabus_detach()
669 KASSERT(chp->ch_drive[i].drv_softc == NULL); in atabus_detach()
670 KASSERT(chp->ch_drive[i].drive_type == 0); in atabus_detach()
675 ata_channel_lock(chp); in atabus_detach()
676 chp->ch_flags |= ATACH_SHUTDOWN; in atabus_detach()
677 while (chp->ch_thread != NULL) { in atabus_detach()
678 cv_signal(&chp->ch_thr_idle); in atabus_detach()
679 cv_wait(&chp->ch_thr_idle, &chp->ch_lock); in atabus_detach()
681 ata_channel_unlock(chp); in atabus_detach()
683 atabus_free_drives(chp); in atabus_detach()
701 struct ata_channel *chp = sc->sc_chan; in atabus_childdetached() local
704 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabus_childdetached()
708 if (child == chp->atapibus) { in atabus_childdetached()
709 chp->atapibus = NULL; in atabus_childdetached()
711 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_childdetached()
712 if (chp->ch_drive[i].drive_type != ATA_DRIVET_ATAPI) in atabus_childdetached()
714 KASSERT(chp->ch_drive[i].drv_softc != NULL); in atabus_childdetached()
715 chp->ch_drive[i].drv_softc = NULL; in atabus_childdetached()
716 chp->ch_drive[i].drive_flags = 0; in atabus_childdetached()
717 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabus_childdetached()
724 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_childdetached()
725 if (chp->ch_drive[i].drive_type == ATA_DRIVET_ATAPI) in atabus_childdetached()
727 if (child == chp->ch_drive[i].drv_softc) { in atabus_childdetached()
728 chp->ch_drive[i].drv_softc = NULL; in atabus_childdetached()
729 chp->ch_drive[i].drive_flags = 0; in atabus_childdetached()
730 if (chp->ch_drive[i].drive_type == ATA_DRIVET_PM) in atabus_childdetached()
731 chp->ch_satapmp_nports = 0; in atabus_childdetached()
732 chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; in atabus_childdetached()
752 atabus_alloc_drives(struct ata_channel *chp, int ndrives) in atabus_alloc_drives() argument
755 if (chp->ch_ndrives != ndrives) in atabus_alloc_drives()
756 atabus_free_drives(chp); in atabus_alloc_drives()
757 if (chp->ch_drive == NULL) { in atabus_alloc_drives()
760 ata_channel_unlock(chp); in atabus_alloc_drives()
761 drv = kmem_zalloc(sizeof(*chp->ch_drive) * ndrives, KM_SLEEP); in atabus_alloc_drives()
762 ata_channel_lock(chp); in atabus_alloc_drives()
764 if (chp->ch_drive != NULL) { in atabus_alloc_drives()
766 kmem_free(drv, sizeof(*chp->ch_drive) * ndrives); in atabus_alloc_drives()
769 chp->ch_drive = drv; in atabus_alloc_drives()
772 chp->ch_drive[i].chnl_softc = chp; in atabus_alloc_drives()
773 chp->ch_drive[i].drive = i; in atabus_alloc_drives()
775 chp->ch_ndrives = ndrives; in atabus_alloc_drives()
780 atabus_free_drives(struct ata_channel *chp) in atabus_free_drives() argument
785 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabus_free_drives()
786 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_free_drives()
787 if (chp->ch_drive[i].drive_type != ATA_DRIVET_NONE) { in atabus_free_drives()
789 device_xname(chp->atabus), i, in atabus_free_drives()
790 chp->ch_drive[i].drive_type); in atabus_free_drives()
793 if (chp->ch_drive[i].drv_softc != NULL) { in atabus_free_drives()
795 device_xname(chp->atabus), i, in atabus_free_drives()
796 device_xname(chp->ch_drive[i].drv_softc)); in atabus_free_drives()
804 if (chp->ch_drive == NULL) in atabus_free_drives()
806 kmem_free(chp->ch_drive, in atabus_free_drives()
807 sizeof(struct ata_drive_datas) * chp->ch_ndrives); in atabus_free_drives()
808 chp->ch_ndrives = 0; in atabus_free_drives()
809 chp->ch_drive = NULL; in atabus_free_drives()
818 struct ata_channel *chp = drvp->chnl_softc; in ata_get_params() local
819 struct atac_softc *atac = chp->ch_atac; in ata_get_params()
826 xfer = ata_get_xfer(chp, false); in ata_get_params()
856 ata_wait_cmd(chp, xfer); in ata_get_params()
912 ata_free_xfer(chp, xfer); in ata_get_params()
921 struct ata_channel *chp = drvp->chnl_softc; in ata_set_mode() local
922 struct atac_softc *atac = chp->ch_atac; in ata_set_mode()
926 xfer = ata_get_xfer(chp, false); in ata_set_mode()
941 ata_wait_cmd(chp, xfer); in ata_set_mode()
950 ata_free_xfer(chp, xfer); in ata_set_mode()
997 ata_channel_idle(struct ata_channel *chp) in ata_channel_idle() argument
999 ata_channel_lock(chp); in ata_channel_idle()
1000 ata_channel_freeze_locked(chp); in ata_channel_idle()
1001 while (chp->ch_queue->queue_active > 0) { in ata_channel_idle()
1002 chp->ch_queue->queue_flags |= QF_IDLE_WAIT; in ata_channel_idle()
1003 cv_timedwait(&chp->ch_queue->queue_idle, &chp->ch_lock, 1); in ata_channel_idle()
1005 ata_channel_unlock(chp); in ata_channel_idle()
1014 ata_exec_xfer(struct ata_channel *chp, struct ata_xfer *xfer) in ata_exec_xfer() argument
1018 chp->ch_channel, xfer->c_drive), DEBUG_XFERS); in ata_exec_xfer()
1021 xfer->c_chp = chp; in ata_exec_xfer()
1023 ata_channel_lock(chp); in ata_exec_xfer()
1030 SIMPLEQ_INSERT_TAIL(&chp->ch_queue->queue_xfer, xfer, in ata_exec_xfer()
1033 SIMPLEQ_INSERT_HEAD(&chp->ch_queue->queue_xfer, xfer, in ata_exec_xfer()
1040 while (chp->ch_queue->queue_active > 0 || in ata_exec_xfer()
1041 SIMPLEQ_FIRST(&chp->ch_queue->queue_xfer) != xfer) { in ata_exec_xfer()
1043 cv_wait(&chp->ch_queue->c_active, &chp->ch_lock); in ata_exec_xfer()
1052 ata_channel_unlock(chp); in ata_exec_xfer()
1054 ata_free_xfer(chp, xfer); in ata_exec_xfer()
1059 ata_channel_unlock(chp); in ata_exec_xfer()
1062 chp->ch_flags), DEBUG_XFERS); in ata_exec_xfer()
1063 atastart(chp); in ata_exec_xfer()
1082 atastart(struct ata_channel *chp) in atastart() argument
1084 struct atac_softc *atac = chp->ch_atac; in atastart()
1085 struct ata_queue *chq = chp->ch_queue; in atastart()
1102 ata_channel_lock(chp); in atastart()
1106 if ((xfer = SIMPLEQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL) { in atastart()
1108 __func__, chp, chp->ch_channel), DEBUG_XFERS); in atastart()
1118 "wait active\n", xfer, chp->ch_channel, xfer->c_drive), in atastart()
1120 cv_broadcast(&chp->ch_queue->c_active); in atastart()
1130 cv_signal(&chp->ch_queue->queue_idle); in atastart()
1134 __func__, chp, chp->ch_channel, xfer->c_drive, in atastart()
1141 KASSERT(xfer->c_chp == chp); in atastart()
1151 if (!skipq && (axfer = TAILQ_FIRST(&chp->ch_queue->active_xfers))) { in atastart()
1158 struct ata_drive_datas * const drvp = &chp->ch_drive[xfer->c_drive]; in atastart()
1172 __func__, chp->ch_channel); in atastart()
1176 __func__, chp, chp->ch_channel), DEBUG_XFERS); in atastart()
1181 if (!ata_queue_alloc_slot(chp, &xfer->c_slot, drv_openings)) in atastart()
1185 if (!atac->atac_claim_hw(chp, 0)) { in atastart()
1186 ata_queue_free_slot(chp, xfer->c_slot); in atastart()
1194 __func__, chp, xfer, chp->ch_channel, xfer->c_drive), DEBUG_XFERS); in atastart()
1201 SET(chp->ch_flags, ATACH_NCQ); in atastart()
1203 CLR(chp->ch_flags, ATACH_NCQ); in atastart()
1207 ata_activate_xfer_locked(chp, xfer); in atastart()
1227 ata_channel_unlock(chp); in atastart()
1233 struct ata_channel *chp = xfer->c_chp; in ata_xfer_start() local
1236 KASSERT(mutex_owned(&chp->ch_lock)); in ata_xfer_start()
1239 rv = xfer->ops->c_start(chp, xfer); in ata_xfer_start()
1246 ata_thread_wake_locked(chp); in ata_xfer_start()
1250 ata_channel_unlock(chp); in ata_xfer_start()
1252 status = xfer->ops->c_poll(chp, xfer); in ata_xfer_start()
1253 ata_channel_lock(chp); in ata_xfer_start()
1258 ata_channel_unlock(chp); in ata_xfer_start()
1260 xfer->ops->c_abort(chp, xfer); in ata_xfer_start()
1261 ata_channel_lock(chp); in ata_xfer_start()
1269 ata_activate_xfer_locked(struct ata_channel *chp, struct ata_xfer *xfer) in ata_activate_xfer_locked() argument
1271 struct ata_queue * const chq = chp->ch_queue; in ata_activate_xfer_locked()
1273 KASSERT(mutex_owned(&chp->ch_lock)); in ata_activate_xfer_locked()
1295 ata_get_xfer(struct ata_channel *chp, bool waitok) in ata_get_xfer() argument
1305 ata_free_xfer(struct ata_channel *chp, struct ata_xfer *xfer) in ata_free_xfer() argument
1307 struct ata_queue *chq = chp->ch_queue; in ata_free_xfer()
1309 ata_channel_lock(chp); in ata_free_xfer()
1315 ata_channel_unlock(chp); in ata_free_xfer()
1322 struct wdc_softc *wdc = CHAN_TO_WDC(chp); in ata_free_xfer()
1326 chp->ch_channel, xfer->c_drive); in ata_free_xfer()
1327 chp->ch_flags &= ~(ATACH_DMA_WAIT | ATACH_PIOBM_WAIT | ATACH_IRQ_WAIT); in ata_free_xfer()
1331 if (__predict_false(chp->ch_atac->atac_free_hw)) in ata_free_xfer()
1332 chp->ch_atac->atac_free_hw(chp); in ata_free_xfer()
1334 ata_channel_unlock(chp); in ata_free_xfer()
1341 ata_deactivate_xfer(struct ata_channel *chp, struct ata_xfer *xfer) in ata_deactivate_xfer() argument
1343 struct ata_queue * const chq = chp->ch_queue; in ata_deactivate_xfer()
1345 ata_channel_lock(chp); in ata_deactivate_xfer()
1352 callout_stop(&chp->c_timo_callout); in ata_deactivate_xfer()
1354 if (callout_invoking(&chp->c_timo_callout)) in ata_deactivate_xfer()
1361 ata_queue_free_slot(chp, xfer->c_slot); in ata_deactivate_xfer()
1366 ata_channel_unlock(chp); in ata_deactivate_xfer()
1379 ata_waitdrain_xfer_check(struct ata_channel *chp, struct ata_xfer *xfer) in ata_waitdrain_xfer_check() argument
1384 ata_channel_lock(chp); in ata_waitdrain_xfer_check()
1386 if (chp->ch_drive[drive].drive_flags & ATA_DRIVE_WAITDRAIN) { in ata_waitdrain_xfer_check()
1387 ata_channel_unlock(chp); in ata_waitdrain_xfer_check()
1389 xfer->ops->c_kill_xfer(chp, xfer, KILL_GONE); in ata_waitdrain_xfer_check()
1391 ata_channel_lock(chp); in ata_waitdrain_xfer_check()
1392 chp->ch_drive[drive].drive_flags &= ~ATA_DRIVE_WAITDRAIN; in ata_waitdrain_xfer_check()
1393 cv_signal(&chp->ch_queue->queue_drain); in ata_waitdrain_xfer_check()
1397 ata_channel_unlock(chp); in ata_waitdrain_xfer_check()
1408 struct ata_channel *chp = xfer->c_chp; in ata_timo_xfer_check() local
1409 struct ata_drive_datas *drvp = &chp->ch_drive[xfer->c_drive]; in ata_timo_xfer_check()
1411 ata_channel_lock(chp); in ata_timo_xfer_check()
1419 ata_channel_unlock(chp); in ata_timo_xfer_check()
1425 ata_free_xfer(chp, xfer); in ata_timo_xfer_check()
1430 ata_channel_unlock(chp); in ata_timo_xfer_check()
1438 ata_channel_unlock(chp); in ata_timo_xfer_check()
1450 ata_kill_active(struct ata_channel *chp, int reason, int flags) in ata_kill_active() argument
1452 struct ata_queue * const chq = chp->ch_queue; in ata_kill_active()
1455 KASSERT(mutex_owned(&chp->ch_lock)); in ata_kill_active()
1458 ata_channel_unlock(chp); in ata_kill_active()
1460 ata_channel_lock(chp); in ata_kill_active()
1470 struct ata_channel * const chp = drvp->chnl_softc; in ata_kill_pending() local
1471 struct ata_queue * const chq = chp->ch_queue; in ata_kill_pending()
1474 ata_channel_lock(chp); in ata_kill_pending()
1478 KASSERT(xfer->c_chp == chp); in ata_kill_pending()
1483 SIMPLEQ_REMOVE_HEAD(&chp->ch_queue->queue_xfer, c_xferchain); in ata_kill_pending()
1491 xfer->ops->c_kill_xfer(chp, xfer, KILL_GONE_INACTIVE); in ata_kill_pending()
1499 KASSERT(xfer->c_chp == chp); in ata_kill_pending()
1513 cv_wait(&chq->queue_drain, &chp->ch_lock); in ata_kill_pending()
1516 ata_channel_unlock(chp); in ata_kill_pending()
1520 ata_channel_freeze_locked(struct ata_channel *chp) in ata_channel_freeze_locked() argument
1522 chp->ch_queue->queue_freeze++; in ata_channel_freeze_locked()
1524 ATADEBUG_PRINT(("%s(chp=%p) -> %d\n", __func__, chp, in ata_channel_freeze_locked()
1525 chp->ch_queue->queue_freeze), DEBUG_FUNCS | DEBUG_XFERS); in ata_channel_freeze_locked()
1529 ata_channel_freeze(struct ata_channel *chp) in ata_channel_freeze() argument
1531 ata_channel_lock(chp); in ata_channel_freeze()
1532 ata_channel_freeze_locked(chp); in ata_channel_freeze()
1533 ata_channel_unlock(chp); in ata_channel_freeze()
1537 ata_channel_thaw_locked(struct ata_channel *chp) in ata_channel_thaw_locked() argument
1539 KASSERT(mutex_owned(&chp->ch_lock)); in ata_channel_thaw_locked()
1540 KASSERT(chp->ch_queue->queue_freeze > 0); in ata_channel_thaw_locked()
1542 chp->ch_queue->queue_freeze--; in ata_channel_thaw_locked()
1544 ATADEBUG_PRINT(("%s(chp=%p) -> %d\n", __func__, chp, in ata_channel_thaw_locked()
1545 chp->ch_queue->queue_freeze), DEBUG_FUNCS | DEBUG_XFERS); in ata_channel_thaw_locked()
1554 ata_thread_run(struct ata_channel *chp, int flags, int type, int arg) in ata_thread_run() argument
1556 struct atac_softc *atac = chp->ch_atac; in ata_thread_run()
1560 ata_channel_lock_owned(chp); in ata_thread_run()
1567 __func__, flags, chp->ch_flags), DEBUG_FUNCS | DEBUG_XFERS); in ata_thread_run()
1571 if (chp->ch_flags & ATACH_TH_RESET) { in ata_thread_run()
1580 KASSERT(drive <= chp->ch_ndrives); in ata_thread_run()
1581 drvp = &chp->ch_drive[drive]; in ata_thread_run()
1594 KASSERT((chp->ch_flags & ATACH_RECOVERING) == 0); in ata_thread_run()
1595 chp->recovery_tfd = tfd; in ata_thread_run()
1603 if (!(chp->ch_flags & type)) { in ata_thread_run()
1608 ata_channel_freeze_locked(chp); in ata_thread_run()
1609 chp->ch_flags |= type; in ata_thread_run()
1612 cv_signal(&chp->ch_thr_idle); in ata_thread_run()
1617 ata_channel_freeze_locked(chp); in ata_thread_run()
1624 if (chp->ch_flags & type) { in ata_thread_run()
1625 chp->ch_flags &= ~type; in ata_thread_run()
1631 (*atac->atac_bustype_ata->ata_reset_channel)(chp, flags); in ata_thread_run()
1633 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in ata_thread_run()
1634 for (int drive = 0; drive < chp->ch_ndrives; drive++) in ata_thread_run()
1635 chp->ch_drive[drive].state = 0; in ata_thread_run()
1642 KASSERT(drive <= chp->ch_ndrives); in ata_thread_run()
1643 drvp = &chp->ch_drive[drive]; in ata_thread_run()
1653 KASSERT((chp->ch_flags & ATACH_RECOVERING) == 0); in ata_thread_run()
1656 SET(chp->ch_flags, ATACH_RECOVERING); in ata_thread_run()
1657 (*atac->atac_bustype_ata->ata_recovery)(chp, flags, tfd); in ata_thread_run()
1658 CLR(chp->ch_flags, ATACH_RECOVERING); in ata_thread_run()
1672 ata_channel_thaw_locked(chp); in ata_thread_run()
1675 ata_channel_thaw_locked(chp); in ata_thread_run()
1678 cv_signal(&chp->ch_thr_idle); in ata_thread_run()
1682 ata_addref(struct ata_channel *chp) in ata_addref() argument
1684 struct atac_softc *atac = chp->ch_atac; in ata_addref()
1700 ata_delref(struct ata_channel *chp) in ata_delref() argument
1702 struct atac_softc *atac = chp->ch_atac; in ata_delref()
1714 ata_print_modes(struct ata_channel *chp) in ata_print_modes() argument
1716 struct atac_softc *atac = chp->ch_atac; in ata_print_modes()
1720 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in ata_print_modes()
1721 for (drive = 0; drive < chp->ch_ndrives; drive++) { in ata_print_modes()
1722 drvp = &chp->ch_drive[drive]; in ata_print_modes()
1729 chp->ch_channel, drvp->drive, drvp->PIO_mode); in ata_print_modes()
1761 ATA_REAL_OPENINGS(chp->ch_queue->queue_openings), in ata_print_modes()
1782 struct ata_channel *chp = drvp->chnl_softc; in ata_downgrade_mode() local
1783 struct atac_softc *atac = chp->ch_atac; in ata_downgrade_mode()
1823 (*atac->atac_set_modes)(chp); in ata_downgrade_mode()
1824 ata_print_modes(chp); in ata_downgrade_mode()
1826 ata_thread_run(chp, flags, ATACH_TH_RESET, ATACH_NODRIVE); in ata_downgrade_mode()
1839 struct ata_channel *chp = drvp->chnl_softc; in ata_probe_caps() local
1840 struct atac_softc *atac = chp->ch_atac; in ata_probe_caps()
1857 ata_channel_lock(chp); in ata_probe_caps()
1859 ata_channel_unlock(chp); in ata_probe_caps()
1863 ata_channel_lock(chp); in ata_probe_caps()
1865 ata_channel_unlock(chp); in ata_probe_caps()
1943 ata_channel_lock(chp); in ata_probe_caps()
1945 ata_channel_unlock(chp); in ata_probe_caps()
1969 ata_channel_lock(chp); in ata_probe_caps()
1971 ata_channel_unlock(chp); in ata_probe_caps()
2010 ata_channel_lock(chp); in ata_probe_caps()
2012 ata_channel_unlock(chp); in ata_probe_caps()
2020 ata_channel_lock(chp); in ata_probe_caps()
2029 ata_channel_unlock(chp); in ata_probe_caps()
2043 ata_channel_lock(chp); in ata_probe_caps()
2047 ata_channel_unlock(chp); in ata_probe_caps()
2055 ata_channel_lock(chp); in ata_probe_caps()
2064 ata_channel_unlock(chp); in ata_probe_caps()
2081 ata_channel_lock(chp); in ata_probe_caps()
2096 ata_channel_unlock(chp); in ata_probe_caps()
2104 ata_channel_lock(chp); in ata_probe_caps()
2113 ata_channel_unlock(chp); in ata_probe_caps()
2163 struct ata_channel *chp = sc->sc_chan; in atabusioctl() local
2182 ata_channel_lock(chp); in atabusioctl()
2185 ata_channel_unlock(chp); in atabusioctl()
2193 if ((chp->ch_drive[0].drive_type == ATA_DRIVET_OLD) || in atabusioctl()
2194 (chp->ch_drive[1].drive_type == ATA_DRIVET_OLD)) in atabusioctl()
2202 if ((chp->ch_drive[0].drive_type == ATA_DRIVET_OLD) || in atabusioctl()
2203 (chp->ch_drive[1].drive_type == ATA_DRIVET_OLD)) in atabusioctl()
2218 if (chp->ch_drive[drive].drv_softc != NULL) { in atabusioctl()
2220 chp->ch_drive[drive].drv_softc, 0); in atabusioctl()
2223 KASSERT(chp->ch_drive[drive].drv_softc == NULL); in atabusioctl()
2237 struct ata_channel *chp = sc->sc_chan; in atabus_suspend() local
2239 ata_channel_idle(chp); in atabus_suspend()
2248 struct ata_channel *chp = sc->sc_chan; in atabus_resume() local
2254 ata_channel_lock(chp); in atabus_resume()
2255 if (chp->ch_queue->queue_freeze == 0) { in atabus_resume()
2256 ata_channel_unlock(chp); in atabus_resume()
2261 ata_channel_thaw_locked(chp); in atabus_resume()
2264 if (chp->ch_ndrives > 0) in atabus_resume()
2265 ata_thread_run(chp, AT_WAIT, ATACH_TH_RESET, ATACH_NODRIVE); in atabus_resume()
2267 ata_channel_unlock(chp); in atabus_resume()
2277 struct ata_channel *chp = sc->sc_chan; in atabus_rescan() local
2285 if (chp->ch_satapmp_nports == 0) { in atabus_rescan()
2286 if (chp->atapibus != NULL) { in atabus_rescan()
2290 KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); in atabus_rescan()
2291 for (i = 0; i < chp->ch_ndrives; i++) { in atabus_rescan()
2292 if (chp->ch_drive[i].drv_softc != NULL) { in atabus_rescan()
2305 ata_channel_lock(chp); in atabus_rescan()
2306 chp->ch_flags |= ATACH_TH_RESCAN; in atabus_rescan()
2307 cv_signal(&chp->ch_thr_idle); in atabus_rescan()
2308 ata_channel_unlock(chp); in atabus_rescan()
2314 ata_delay(struct ata_channel *chp, int ms, const char *msg, int flags) in ata_delay() argument
2316 KASSERT(mutex_owned(&chp->ch_lock)); in ata_delay()
2327 kpause(msg, false, pause > 0 ? pause : 1, &chp->ch_lock); in ata_delay()
2362 ata_wait_cmd(struct ata_channel *chp, struct ata_xfer *xfer) in ata_wait_cmd() argument
2364 struct ata_queue *chq = chp->ch_queue; in ata_wait_cmd()
2367 ata_channel_lock(chp); in ata_wait_cmd()
2370 cv_wait(&chq->c_cmd_finish, &chp->ch_lock); in ata_wait_cmd()
2372 ata_channel_unlock(chp); in ata_wait_cmd()