Commit 50aea6fc authored by Daniel Mack's avatar Daniel Mack Committed by Felipe Balbi

usb: musb: cppi41: fire hrtimer according to programmed channel length

The musb/cppi41 code installs a hrtimer to work around DMA completion
interrupts that have fired too early on AM335x hardware. This timer
is currently programmed to first fire 140 microseconds after the DMA
completion callback. According to the commit which introduced it
(a655f481, "usb: musb: musb_cppi41: handle pre-mature TX complete
interrupt"), that value is is considered a 'rule of thumb' that worked
well with the test case described in the commit log.

Test show, however, that for USB audio devices and much smaller packet
sizes, the timer has to fire earlier in order to correctly handle the audio
stream. The original test case had output transfer sizes of 1514 bytes, and
a delay of 140 microseconds. For audio devices with 24 bytes channel size, 3
microseconds seem to work well.

Hence, let's assume that the time it takes to clear the bit correlates with
the number of bytes transferred. The referenced commit log mentions such a
suspicion as well. Let the timer fire in cppi41_channel->total_len/10
microseconds to correctly handle both cases.

Also, shorten the interval in which the timer fires again in case of
a non-empty early_tx list.

With these changes in place, both FS and HS audio devices appear to work
well on AM335x hardware.
Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
Reported-by: default avatarSebastian Reimers <sebastian.reimers@googlemail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent eefae89e
...@@ -200,7 +200,7 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer) ...@@ -200,7 +200,7 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
if (!list_empty(&controller->early_tx_list)) { if (!list_empty(&controller->early_tx_list)) {
ret = HRTIMER_RESTART; ret = HRTIMER_RESTART;
hrtimer_forward_now(&controller->early_tx, hrtimer_forward_now(&controller->early_tx,
ktime_set(0, 150 * NSEC_PER_USEC)); ktime_set(0, 50 * NSEC_PER_USEC));
} }
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
...@@ -274,8 +274,10 @@ static void cppi41_dma_callback(void *private_data) ...@@ -274,8 +274,10 @@ static void cppi41_dma_callback(void *private_data)
list_add_tail(&cppi41_channel->tx_check, list_add_tail(&cppi41_channel->tx_check,
&controller->early_tx_list); &controller->early_tx_list);
if (!hrtimer_active(&controller->early_tx)) { if (!hrtimer_active(&controller->early_tx)) {
unsigned long usecs = cppi41_channel->total_len / 10;
hrtimer_start_range_ns(&controller->early_tx, hrtimer_start_range_ns(&controller->early_tx,
ktime_set(0, 140 * NSEC_PER_USEC), ktime_set(0, usecs * NSEC_PER_USEC),
40 * NSEC_PER_USEC, 40 * NSEC_PER_USEC,
HRTIMER_MODE_REL); HRTIMER_MODE_REL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment