Print this page
XXXX introduce drv_sectohz


3377  * Start the pipe's timer
3378  */
3379 static void
3380 ehci_start_timer(
3381         ehci_state_t            *ehcip,
3382         ehci_pipe_private_t     *pp)
3383 {
3384         USB_DPRINTF_L4(PRINT_MASK_LISTS,  ehcip->ehci_log_hdl,
3385             "ehci_start_timer: ehcip = 0x%p, pp = 0x%p",
3386             (void *)ehcip, (void *)pp);
3387 
3388         ASSERT(mutex_owned(&ehcip->ehci_int_mutex));
3389 
3390         /*
3391          * Start the pipe's timer only if currently timer is not
3392          * running and if there are any transfers on the timeout
3393          * list. This timer will be per pipe.
3394          */
3395         if ((!pp->pp_timer_id) && (pp->pp_timeout_list)) {
3396                 pp->pp_timer_id = timeout(ehci_xfer_timeout_handler,
3397                     (void *)(pp->pp_pipe_handle), drv_usectohz(1000000));
3398         }
3399 }
3400 
3401 /*
3402  * ehci_deallocate_tw:
3403  *
3404  * Deallocate of a Transaction Wrapper (TW) and this involves the freeing of
3405  * of DMA resources.
3406  */
3407 void
3408 ehci_deallocate_tw(
3409         ehci_state_t            *ehcip,
3410         ehci_pipe_private_t     *pp,
3411         ehci_trans_wrapper_t    *tw)
3412 {
3413         ehci_trans_wrapper_t    *prev, *next;
3414 
3415         USB_DPRINTF_L4(PRINT_MASK_ALLOC, ehcip->ehci_log_hdl,
3416             "ehci_deallocate_tw: tw = 0x%p", (void *)tw);
3417 


3783                                 pp->pp_count_done_qtds++;
3784                         }
3785 
3786                         qtd = ehci_qtd_iommu_to_cpu(ehcip,
3787                             Get_QTD(qtd->qtd_tw_next_qtd));
3788                 }
3789 
3790                 next_tw = next_tw->tw_next;
3791         }
3792 
3793         USB_DPRINTF_L3(PRINT_MASK_LISTS, ehcip->ehci_log_hdl,
3794             "ehci_wait_for_transfers_completion: count_done_qtds = 0x%x",
3795             pp->pp_count_done_qtds);
3796 
3797         if (!pp->pp_count_done_qtds) {
3798 
3799                 return;
3800         }
3801 
3802         (void) cv_reltimedwait(&pp->pp_xfer_cmpl_cv, &ehcip->ehci_int_mutex,
3803             drv_usectohz(EHCI_XFER_CMPL_TIMEWAIT * 1000000), TR_CLOCK_TICK);
3804 
3805         if (pp->pp_count_done_qtds) {
3806 
3807                 USB_DPRINTF_L2(PRINT_MASK_LISTS, ehcip->ehci_log_hdl,
3808                     "ehci_wait_for_transfers_completion:"
3809                     "No transfers completion confirmation received");
3810         }
3811 }
3812 
3813 /*
3814  * ehci_check_for_transfers_completion:
3815  *
3816  * Check whether anybody is waiting for transfers completion event. If so, send
3817  * this event and also stop initiating any new transfers on this pipe.
3818  */
3819 void
3820 ehci_check_for_transfers_completion(
3821         ehci_state_t            *ehcip,
3822         ehci_pipe_private_t     *pp)
3823 {




3377  * Start the pipe's timer
3378  */
3379 static void
3380 ehci_start_timer(
3381         ehci_state_t            *ehcip,
3382         ehci_pipe_private_t     *pp)
3383 {
3384         USB_DPRINTF_L4(PRINT_MASK_LISTS,  ehcip->ehci_log_hdl,
3385             "ehci_start_timer: ehcip = 0x%p, pp = 0x%p",
3386             (void *)ehcip, (void *)pp);
3387 
3388         ASSERT(mutex_owned(&ehcip->ehci_int_mutex));
3389 
3390         /*
3391          * Start the pipe's timer only if currently timer is not
3392          * running and if there are any transfers on the timeout
3393          * list. This timer will be per pipe.
3394          */
3395         if ((!pp->pp_timer_id) && (pp->pp_timeout_list)) {
3396                 pp->pp_timer_id = timeout(ehci_xfer_timeout_handler,
3397                     (void *)(pp->pp_pipe_handle), drv_sectohz(1));
3398         }
3399 }
3400 
3401 /*
3402  * ehci_deallocate_tw:
3403  *
3404  * Deallocate of a Transaction Wrapper (TW) and this involves the freeing of
3405  * of DMA resources.
3406  */
3407 void
3408 ehci_deallocate_tw(
3409         ehci_state_t            *ehcip,
3410         ehci_pipe_private_t     *pp,
3411         ehci_trans_wrapper_t    *tw)
3412 {
3413         ehci_trans_wrapper_t    *prev, *next;
3414 
3415         USB_DPRINTF_L4(PRINT_MASK_ALLOC, ehcip->ehci_log_hdl,
3416             "ehci_deallocate_tw: tw = 0x%p", (void *)tw);
3417 


3783                                 pp->pp_count_done_qtds++;
3784                         }
3785 
3786                         qtd = ehci_qtd_iommu_to_cpu(ehcip,
3787                             Get_QTD(qtd->qtd_tw_next_qtd));
3788                 }
3789 
3790                 next_tw = next_tw->tw_next;
3791         }
3792 
3793         USB_DPRINTF_L3(PRINT_MASK_LISTS, ehcip->ehci_log_hdl,
3794             "ehci_wait_for_transfers_completion: count_done_qtds = 0x%x",
3795             pp->pp_count_done_qtds);
3796 
3797         if (!pp->pp_count_done_qtds) {
3798 
3799                 return;
3800         }
3801 
3802         (void) cv_reltimedwait(&pp->pp_xfer_cmpl_cv, &ehcip->ehci_int_mutex,
3803             drv_sectohz(EHCI_XFER_CMPL_TIMEWAIT), TR_CLOCK_TICK);
3804 
3805         if (pp->pp_count_done_qtds) {
3806 
3807                 USB_DPRINTF_L2(PRINT_MASK_LISTS, ehcip->ehci_log_hdl,
3808                     "ehci_wait_for_transfers_completion:"
3809                     "No transfers completion confirmation received");
3810         }
3811 }
3812 
3813 /*
3814  * ehci_check_for_transfers_completion:
3815  *
3816  * Check whether anybody is waiting for transfers completion event. If so, send
3817  * this event and also stop initiating any new transfers on this pipe.
3818  */
3819 void
3820 ehci_check_for_transfers_completion(
3821         ehci_state_t            *ehcip,
3822         ehci_pipe_private_t     *pp)
3823 {