Lines Matching +full:cmd +full:- +full:timeout +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0+
6 /* This file is part of ehci-hcd.c */
8 /*-------------------------------------------------------------------------*/
13 ehci->command |= bit; in ehci_set_command_bit()
14 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_set_command_bit()
17 ehci_readl(ehci, &ehci->regs->command); in ehci_set_command_bit()
23 ehci->command &= ~bit; in ehci_clear_command_bit()
24 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_clear_command_bit()
27 ehci_readl(ehci, &ehci->regs->command); in ehci_clear_command_bit()
30 /*-------------------------------------------------------------------------*/
35 * Lots of different events are triggered from ehci->hrtimer. Whenever
39 * ehci->enabled_hrtimer_events, and they are numbered in order of
40 * increasing delay values (ranging between 1 ms and 100 ms).
43 * we keep track only of the lowest-numbered pending event, in
44 * ehci->next_hrtimer_event. Whenever ehci->hrtimer gets restarted, its
45 * expiration time is set to the timeout value for this event.
49 * matter, because none of the events are especially time-critical. The
50 * ones that matter most all have a delay of 1 ms, so they will be
51 * handled after 2 ms at most, which is okay. In addition to this, we
52 * allow for an expiration range of 1 ms.
79 ktime_t *timeout = &ehci->hr_timeouts[event]; in ehci_enable_event() local
82 *timeout = ktime_add(ktime_get(), event_delays_ns[event]); in ehci_enable_event()
83 ehci->enabled_hrtimer_events |= (1 << event); in ehci_enable_event()
85 /* Track only the lowest-numbered pending event */ in ehci_enable_event()
86 if (event < ehci->next_hrtimer_event) { in ehci_enable_event()
87 ehci->next_hrtimer_event = event; in ehci_enable_event()
88 hrtimer_start_range_ns(&ehci->hrtimer, *timeout, in ehci_enable_event()
100 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_poll_ASS()
103 want = (ehci->command & CMD_ASE) ? STS_ASS : 0; in ehci_poll_ASS()
104 actual = ehci_readl(ehci, &ehci->regs->status) & STS_ASS; in ehci_poll_ASS()
108 /* Poll again later, but give up after about 2-4 ms */ in ehci_poll_ASS()
109 if (ehci->ASS_poll_count++ < 2) { in ehci_poll_ASS()
116 ehci->ASS_poll_count = 0; in ehci_poll_ASS()
118 /* The status is up-to-date; restart or stop the schedule as needed */ in ehci_poll_ASS()
120 if (ehci->async_count > 0) in ehci_poll_ASS()
124 if (ehci->async_count == 0) { in ehci_poll_ASS()
146 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_poll_PSS()
149 want = (ehci->command & CMD_PSE) ? STS_PSS : 0; in ehci_poll_PSS()
150 actual = ehci_readl(ehci, &ehci->regs->status) & STS_PSS; in ehci_poll_PSS()
154 /* Poll again later, but give up after about 2-4 ms */ in ehci_poll_PSS()
155 if (ehci->PSS_poll_count++ < 2) { in ehci_poll_PSS()
162 ehci->PSS_poll_count = 0; in ehci_poll_PSS()
164 /* The status is up-to-date; restart or stop the schedule as needed */ in ehci_poll_PSS()
166 if (ehci->periodic_count > 0) in ehci_poll_PSS()
170 if (ehci->periodic_count == 0) { in ehci_poll_PSS()
189 if (!(ehci_readl(ehci, &ehci->regs->status) & STS_HALT)) { in ehci_handle_controller_death()
192 if (ehci->died_poll_count++ < 5) { in ehci_handle_controller_death()
201 ehci->rh_state = EHCI_RH_HALTED; in ehci_handle_controller_death()
202 ehci_writel(ehci, 0, &ehci->regs->configured_flag); in ehci_handle_controller_death()
203 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_handle_controller_death()
213 bool stopped = (ehci->rh_state < EHCI_RH_RUNNING); in ehci_handle_start_intr_unlinks()
222 while (!list_empty(&ehci->intr_unlink_wait)) { in ehci_handle_start_intr_unlinks()
225 qh = list_first_entry(&ehci->intr_unlink_wait, in ehci_handle_start_intr_unlinks()
227 if (!stopped && (qh->unlink_cycle == in ehci_handle_start_intr_unlinks()
228 ehci->intr_unlink_wait_cycle)) in ehci_handle_start_intr_unlinks()
230 list_del_init(&qh->unlink_node); in ehci_handle_start_intr_unlinks()
231 qh->unlink_reason |= QH_UNLINK_QUEUE_EMPTY; in ehci_handle_start_intr_unlinks()
236 if (!list_empty(&ehci->intr_unlink_wait)) { in ehci_handle_start_intr_unlinks()
238 ++ehci->intr_unlink_wait_cycle; in ehci_handle_start_intr_unlinks()
245 bool stopped = (ehci->rh_state < EHCI_RH_RUNNING); in ehci_handle_intr_unlinks()
254 ehci->intr_unlinking = true; in ehci_handle_intr_unlinks()
255 while (!list_empty(&ehci->intr_unlink)) { in ehci_handle_intr_unlinks()
258 qh = list_first_entry(&ehci->intr_unlink, struct ehci_qh, in ehci_handle_intr_unlinks()
260 if (!stopped && qh->unlink_cycle == ehci->intr_unlink_cycle) in ehci_handle_intr_unlinks()
262 list_del_init(&qh->unlink_node); in ehci_handle_intr_unlinks()
267 if (!list_empty(&ehci->intr_unlink)) { in ehci_handle_intr_unlinks()
269 ++ehci->intr_unlink_cycle; in ehci_handle_intr_unlinks()
271 ehci->intr_unlinking = false; in ehci_handle_intr_unlinks()
275 /* Start another free-iTDs/siTDs cycle */
278 if (!(ehci->enabled_hrtimer_events & BIT(EHCI_HRTIMER_FREE_ITDS))) { in start_free_itds()
279 ehci->last_itd_to_free = list_entry( in start_free_itds()
280 ehci->cached_itd_list.prev, in start_free_itds()
282 ehci->last_sitd_to_free = list_entry( in start_free_itds()
283 ehci->cached_sitd_list.prev, in start_free_itds()
295 if (ehci->rh_state < EHCI_RH_RUNNING) { in end_free_itds()
296 ehci->last_itd_to_free = NULL; in end_free_itds()
297 ehci->last_sitd_to_free = NULL; in end_free_itds()
300 list_for_each_entry_safe(itd, n, &ehci->cached_itd_list, itd_list) { in end_free_itds()
301 list_del(&itd->itd_list); in end_free_itds()
302 dma_pool_free(ehci->itd_pool, itd, itd->itd_dma); in end_free_itds()
303 if (itd == ehci->last_itd_to_free) in end_free_itds()
306 list_for_each_entry_safe(sitd, sn, &ehci->cached_sitd_list, sitd_list) { in end_free_itds()
307 list_del(&sitd->sitd_list); in end_free_itds()
308 dma_pool_free(ehci->sitd_pool, sitd, sitd->sitd_dma); in end_free_itds()
309 if (sitd == ehci->last_sitd_to_free) in end_free_itds()
313 if (!list_empty(&ehci->cached_itd_list) || in end_free_itds()
314 !list_empty(&ehci->cached_sitd_list)) in end_free_itds()
322 u32 cmd, status; in ehci_iaa_watchdog() local
330 if (!ehci->iaa_in_progress || ehci->rh_state != EHCI_RH_RUNNING) in ehci_iaa_watchdog()
339 cmd = ehci_readl(ehci, &ehci->regs->command); in ehci_iaa_watchdog()
345 * - VIA seems to set IAA without triggering the IRQ; in ehci_iaa_watchdog()
346 * - IAAD potentially cleared without setting IAA. in ehci_iaa_watchdog()
348 status = ehci_readl(ehci, &ehci->regs->status); in ehci_iaa_watchdog()
349 if ((status & STS_IAA) || !(cmd & CMD_IAAD)) { in ehci_iaa_watchdog()
350 INCR(ehci->stats.lost_iaa); in ehci_iaa_watchdog()
351 ehci_writel(ehci, STS_IAA, &ehci->regs->status); in ehci_iaa_watchdog()
354 ehci_dbg(ehci, "IAA watchdog: status %x cmd %x\n", status, cmd); in ehci_iaa_watchdog()
363 if (ehci->rh_state != EHCI_RH_RUNNING || in turn_on_io_watchdog()
364 (ehci->enabled_hrtimer_events & in turn_on_io_watchdog()
372 if (ehci->isoc_count > 0 || (ehci->need_io_watchdog && in turn_on_io_watchdog()
373 ehci->async_count + ehci->intr_count > 0)) in turn_on_io_watchdog()
406 spin_lock_irqsave(&ehci->lock, flags); in ehci_hrtimer_func()
408 events = ehci->enabled_hrtimer_events; in ehci_hrtimer_func()
409 ehci->enabled_hrtimer_events = 0; in ehci_hrtimer_func()
410 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; in ehci_hrtimer_func()
414 * the event; otherwise re-enable it. in ehci_hrtimer_func()
418 if (ktime_compare(now, ehci->hr_timeouts[e]) >= 0) in ehci_hrtimer_func()
424 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hrtimer_func()