Lines Matching refs:hsotg
42 static int dwc2_periodic_channel_available(struct dwc2_hsotg *hsotg) in dwc2_periodic_channel_available() argument
52 num_channels = hsotg->params.host_channels; in dwc2_periodic_channel_available()
53 if ((hsotg->periodic_channels + hsotg->non_periodic_channels < in dwc2_periodic_channel_available()
54 num_channels) && (hsotg->periodic_channels < num_channels - 1)) { in dwc2_periodic_channel_available()
57 dev_dbg(hsotg->dev, in dwc2_periodic_channel_available()
60 hsotg->periodic_channels, hsotg->non_periodic_channels); in dwc2_periodic_channel_available()
79 static int dwc2_check_periodic_bandwidth(struct dwc2_hsotg *hsotg, in dwc2_check_periodic_bandwidth() argument
101 if (hsotg->periodic_usecs > max_claimed_usecs) { in dwc2_check_periodic_bandwidth()
102 dev_err(hsotg->dev, in dwc2_check_periodic_bandwidth()
104 __func__, hsotg->periodic_usecs, qh->host_us); in dwc2_check_periodic_bandwidth()
344 static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg, in dwc2_get_ls_map() argument
462 struct dwc2_hsotg *hsotg; member
476 dwc2_sch_dbg(print_data->hsotg, "QH=%p ...%s\n", print_data->qh, str); in dwc2_qh_print()
485 static void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, in dwc2_qh_schedule_print() argument
488 struct dwc2_qh_print_data print_data = { hsotg, qh }; in dwc2_qh_schedule_print()
498 unsigned long *map = dwc2_get_ls_map(hsotg, qh); in dwc2_qh_schedule_print()
500 dwc2_sch_dbg(hsotg, "QH=%p LS/FS trans: %d=>%d us @ %d us", in dwc2_qh_schedule_print()
506 dwc2_sch_dbg(hsotg, in dwc2_qh_schedule_print()
522 dwc2_sch_dbg(hsotg, in dwc2_qh_schedule_print()
527 dwc2_sch_dbg(hsotg, "QH=%p Whole high speed map now:\n", qh); in dwc2_qh_schedule_print()
528 pmap_print(hsotg->hs_periodic_bitmap, in dwc2_qh_schedule_print()
535 static inline void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, in dwc2_qh_schedule_print() argument
554 static int dwc2_ls_pmap_schedule(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_ls_pmap_schedule() argument
558 unsigned long *map = dwc2_get_ls_map(hsotg, qh); in dwc2_ls_pmap_schedule()
593 static void dwc2_ls_pmap_unschedule(struct dwc2_hsotg *hsotg, in dwc2_ls_pmap_unschedule() argument
597 unsigned long *map = dwc2_get_ls_map(hsotg, qh); in dwc2_ls_pmap_unschedule()
628 static int dwc2_hs_pmap_schedule(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hs_pmap_schedule() argument
634 us = pmap_schedule(hsotg->hs_periodic_bitmap, in dwc2_hs_pmap_schedule()
654 static void dwc2_hs_pmap_unschedule(struct dwc2_hsotg *hsotg, in dwc2_hs_pmap_unschedule() argument
659 pmap_unschedule(hsotg->hs_periodic_bitmap, in dwc2_hs_pmap_unschedule()
678 static int dwc2_uframe_schedule_split(struct dwc2_hsotg *hsotg, in dwc2_uframe_schedule_split() argument
719 err = dwc2_ls_pmap_schedule(hsotg, qh, ls_search_slice); in dwc2_uframe_schedule_split()
754 dwc2_ls_pmap_unschedule(hsotg, qh); in dwc2_uframe_schedule_split()
827 dwc2_sch_dbg(hsotg, in dwc2_uframe_schedule_split()
831 dwc2_ls_pmap_unschedule(hsotg, qh); in dwc2_uframe_schedule_split()
926 err = dwc2_hs_pmap_schedule(hsotg, qh, true, i); in dwc2_uframe_schedule_split()
936 dwc2_hs_pmap_unschedule(hsotg, qh, i); in dwc2_uframe_schedule_split()
939 dwc2_ls_pmap_unschedule(hsotg, qh); in dwc2_uframe_schedule_split()
960 static int dwc2_uframe_schedule_hs(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_uframe_schedule_hs() argument
971 return dwc2_hs_pmap_schedule(hsotg, qh, false, 0); in dwc2_uframe_schedule_hs()
983 static int dwc2_uframe_schedule_ls(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_uframe_schedule_ls() argument
991 return dwc2_ls_pmap_schedule(hsotg, qh, 0); in dwc2_uframe_schedule_ls()
1003 static int dwc2_uframe_schedule(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_uframe_schedule() argument
1008 ret = dwc2_uframe_schedule_hs(hsotg, qh); in dwc2_uframe_schedule()
1010 ret = dwc2_uframe_schedule_ls(hsotg, qh); in dwc2_uframe_schedule()
1012 ret = dwc2_uframe_schedule_split(hsotg, qh); in dwc2_uframe_schedule()
1015 dwc2_sch_dbg(hsotg, "QH=%p Failed to schedule %d\n", qh, ret); in dwc2_uframe_schedule()
1017 dwc2_qh_schedule_print(hsotg, qh); in dwc2_uframe_schedule()
1028 static void dwc2_uframe_unschedule(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_uframe_unschedule() argument
1033 dwc2_hs_pmap_unschedule(hsotg, qh, i); in dwc2_uframe_unschedule()
1036 dwc2_ls_pmap_unschedule(hsotg, qh); in dwc2_uframe_unschedule()
1038 dwc2_sch_dbg(hsotg, "QH=%p Unscheduled\n", qh); in dwc2_uframe_unschedule()
1056 static void dwc2_pick_first_frame(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_pick_first_frame() argument
1068 frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_pick_first_frame()
1082 if (!hsotg->params.uframe_sched) { in dwc2_pick_first_frame()
1156 dwc2_sch_vdbg(hsotg, "QH=%p First fn=%04x nxt=%04x\n", in dwc2_pick_first_frame()
1171 static int dwc2_do_reserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_do_reserve() argument
1175 if (hsotg->params.uframe_sched) { in dwc2_do_reserve()
1176 status = dwc2_uframe_schedule(hsotg, qh); in dwc2_do_reserve()
1178 status = dwc2_periodic_channel_available(hsotg); in dwc2_do_reserve()
1180 dev_info(hsotg->dev, in dwc2_do_reserve()
1186 status = dwc2_check_periodic_bandwidth(hsotg, qh); in dwc2_do_reserve()
1190 dev_dbg(hsotg->dev, in dwc2_do_reserve()
1196 if (!hsotg->params.uframe_sched) in dwc2_do_reserve()
1198 hsotg->periodic_channels++; in dwc2_do_reserve()
1201 hsotg->periodic_usecs += qh->host_us; in dwc2_do_reserve()
1203 dwc2_pick_first_frame(hsotg, qh); in dwc2_do_reserve()
1217 static void dwc2_do_unreserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_do_unreserve() argument
1219 assert_spin_locked(&hsotg->lock); in dwc2_do_unreserve()
1230 hsotg->periodic_usecs -= qh->host_us; in dwc2_do_unreserve()
1232 if (hsotg->params.uframe_sched) { in dwc2_do_unreserve()
1233 dwc2_uframe_unschedule(hsotg, qh); in dwc2_do_unreserve()
1236 hsotg->periodic_channels--; in dwc2_do_unreserve()
1255 struct dwc2_hsotg *hsotg = qh->hsotg; in dwc2_unreserve_timer_fn() local
1267 while (!spin_trylock_irqsave(&hsotg->lock, flags)) { in dwc2_unreserve_timer_fn()
1283 dwc2_do_unreserve(hsotg, qh); in dwc2_unreserve_timer_fn()
1285 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_unreserve_timer_fn()
1298 static int dwc2_check_max_xfer_size(struct dwc2_hsotg *hsotg, in dwc2_check_max_xfer_size() argument
1306 max_channel_xfer_size = hsotg->params.max_transfer_size; in dwc2_check_max_xfer_size()
1309 dev_err(hsotg->dev, in dwc2_check_max_xfer_size()
1328 static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_schedule_periodic() argument
1332 status = dwc2_check_max_xfer_size(hsotg, qh); in dwc2_schedule_periodic()
1334 dev_dbg(hsotg->dev, in dwc2_schedule_periodic()
1352 status = dwc2_do_reserve(hsotg, qh); in dwc2_schedule_periodic()
1363 hsotg->frame_number)) in dwc2_schedule_periodic()
1364 dwc2_pick_first_frame(hsotg, qh); in dwc2_schedule_periodic()
1369 if (hsotg->params.dma_desc_enable) in dwc2_schedule_periodic()
1371 list_add_tail(&qh->qh_list_entry, &hsotg->periodic_sched_ready); in dwc2_schedule_periodic()
1375 &hsotg->periodic_sched_inactive); in dwc2_schedule_periodic()
1387 static void dwc2_deschedule_periodic(struct dwc2_hsotg *hsotg, in dwc2_deschedule_periodic() argument
1392 assert_spin_locked(&hsotg->lock); in dwc2_deschedule_periodic()
1443 struct dwc2_hsotg *hsotg = qh->hsotg; in dwc2_wait_timer_fn() local
1446 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_wait_timer_fn()
1458 &hsotg->non_periodic_sched_inactive); in dwc2_wait_timer_fn()
1460 tr_type = dwc2_hcd_select_transactions(hsotg); in dwc2_wait_timer_fn()
1462 dwc2_hcd_queue_transactions(hsotg, tr_type); in dwc2_wait_timer_fn()
1465 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_wait_timer_fn()
1478 static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_qh_init() argument
1481 int dev_speed = dwc2_host_get_speed(hsotg, urb->priv); in dwc2_qh_init()
1486 u32 hprt = dwc2_readl(hsotg, HPRT0); in dwc2_qh_init()
1496 qh->hsotg = hsotg; in dwc2_qh_init()
1515 struct dwc2_tt *dwc_tt = dwc2_host_get_tt_info(hsotg, urb->priv, in dwc2_qh_init()
1587 dwc2_sch_dbg(hsotg, "QH=%p Init %s, %s speed, %d bytes:\n", qh, type, in dwc2_qh_init()
1589 dwc2_sch_dbg(hsotg, "QH=%p ...addr=%d, ep=%d, %s\n", qh, in dwc2_qh_init()
1594 dwc2_sch_dbg(hsotg, in dwc2_qh_init()
1597 dwc2_sch_dbg(hsotg, "QH=%p ...interval: host=%d, device=%d\n", in dwc2_qh_init()
1600 dwc2_sch_dbg(hsotg, "QH=%p ...low speed schedule=%p\n", in dwc2_qh_init()
1601 qh, dwc2_get_ls_map(hsotg, qh)); in dwc2_qh_init()
1615 struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, in dwc2_hcd_qh_create() argument
1629 dwc2_qh_init(hsotg, qh, urb, mem_flags); in dwc2_hcd_qh_create()
1631 if (hsotg->params.dma_desc_enable && in dwc2_hcd_qh_create()
1632 dwc2_hcd_qh_init_ddma(hsotg, qh, mem_flags) < 0) { in dwc2_hcd_qh_create()
1633 dwc2_hcd_qh_free(hsotg, qh); in dwc2_hcd_qh_create()
1651 void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_qh_free() argument
1657 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_qh_free()
1658 dwc2_do_unreserve(hsotg, qh); in dwc2_hcd_qh_free()
1659 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_qh_free()
1671 dwc2_host_put_tt_info(hsotg, qh->dwc_tt); in dwc2_hcd_qh_free()
1674 dwc2_hcd_qh_free_ddma(hsotg, qh); in dwc2_hcd_qh_free()
1675 else if (hsotg->unaligned_cache && qh->dw_align_buf) in dwc2_hcd_qh_free()
1676 kmem_cache_free(hsotg->unaligned_cache, qh->dw_align_buf); in dwc2_hcd_qh_free()
1691 int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_qh_add() argument
1698 dev_vdbg(hsotg->dev, "%s()\n", __func__); in dwc2_hcd_qh_add()
1707 qh->start_active_frame = hsotg->frame_number; in dwc2_hcd_qh_add()
1712 &hsotg->non_periodic_sched_waiting); in dwc2_hcd_qh_add()
1718 &hsotg->non_periodic_sched_inactive); in dwc2_hcd_qh_add()
1723 status = dwc2_schedule_periodic(hsotg, qh); in dwc2_hcd_qh_add()
1726 if (!hsotg->periodic_qh_count) { in dwc2_hcd_qh_add()
1727 intr_mask = dwc2_readl(hsotg, GINTMSK); in dwc2_hcd_qh_add()
1729 dwc2_writel(hsotg, intr_mask, GINTMSK); in dwc2_hcd_qh_add()
1731 hsotg->periodic_qh_count++; in dwc2_hcd_qh_add()
1743 void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_qh_unlink() argument
1747 dev_vdbg(hsotg->dev, "%s()\n", __func__); in dwc2_hcd_qh_unlink()
1757 if (hsotg->non_periodic_qh_ptr == &qh->qh_list_entry) in dwc2_hcd_qh_unlink()
1758 hsotg->non_periodic_qh_ptr = in dwc2_hcd_qh_unlink()
1759 hsotg->non_periodic_qh_ptr->next; in dwc2_hcd_qh_unlink()
1764 dwc2_deschedule_periodic(hsotg, qh); in dwc2_hcd_qh_unlink()
1765 hsotg->periodic_qh_count--; in dwc2_hcd_qh_unlink()
1766 if (!hsotg->periodic_qh_count && in dwc2_hcd_qh_unlink()
1767 !hsotg->params.dma_desc_enable) { in dwc2_hcd_qh_unlink()
1768 intr_mask = dwc2_readl(hsotg, GINTMSK); in dwc2_hcd_qh_unlink()
1770 dwc2_writel(hsotg, intr_mask, GINTMSK); in dwc2_hcd_qh_unlink()
1793 static int dwc2_next_for_periodic_split(struct dwc2_hsotg *hsotg, in dwc2_next_for_periodic_split() argument
1856 static int dwc2_next_periodic_start(struct dwc2_hsotg *hsotg, in dwc2_next_periodic_start() argument
1947 void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hcd_qh_deactivate() argument
1955 dev_vdbg(hsotg->dev, "%s()\n", __func__); in dwc2_hcd_qh_deactivate()
1958 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_qh_deactivate()
1961 dwc2_hcd_qh_add(hsotg, qh); in dwc2_hcd_qh_deactivate()
1971 frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_hcd_qh_deactivate()
1974 missed = dwc2_next_for_periodic_split(hsotg, qh, frame_number); in dwc2_hcd_qh_deactivate()
1976 missed = dwc2_next_periodic_start(hsotg, qh, frame_number); in dwc2_hcd_qh_deactivate()
1978 dwc2_sch_vdbg(hsotg, in dwc2_hcd_qh_deactivate()
1986 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_qh_deactivate()
1997 if (dwc2_frame_num_le(qh->next_active_frame, hsotg->frame_number)) in dwc2_hcd_qh_deactivate()
1999 &hsotg->periodic_sched_ready); in dwc2_hcd_qh_deactivate()
2002 &hsotg->periodic_sched_inactive); in dwc2_hcd_qh_deactivate()
2048 int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, in dwc2_hcd_qtd_add() argument
2054 dev_err(hsotg->dev, "%s: Invalid QH\n", __func__); in dwc2_hcd_qtd_add()
2059 retval = dwc2_hcd_qh_add(hsotg, qh); in dwc2_hcd_qtd_add()