mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: octeon-hcd: keep SOF interrupts while a periodic pipe is due
@ 2026-09-15  8:17 Orgad Shaneh
  2026-10-11  6:56 ` Orgad Shaneh
  0 siblings, 1 reply; 3+ messages in thread
From: Orgad Shaneh @ 2026-09-15  8:17 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel

cvmx_usb_schedule() now sleeps on an hrtimer until the nearest future
periodic deadline instead of counting frames down on every SOF. The scan
that finds that deadline only looks at pipes with

	next_tx_frame > usb->frame_number

which is right for picking the deadline, but it means a periodic pipe
that is already due and was *not* started is invisible to the decision.
A pipe can be due and not started for reasons that resolve on their own:
no idle hardware channel this round, its split window is closed
(cvmx_usb_find_ready_pipe() rejects both), or another pipe owns
usb->active_split.

Such a pipe is only retried from a SOF - cvmx_usb_next_pipe() looks at
the isochronous and interrupt lists only when is_sof is true - so when
some other periodic pipe sets a far deadline, the driver masks SOF, arms
the timer for that far deadline and the due pipe waits for it. With a
hub's status pipe as the far one, that is hundreds of frames; the code
allows up to 8000 (one second) before it falls back to SOF.

Before the hrtimer this could not happen: any pipe with a future
deadline set need_sof, so SOF stayed enabled every frame and the due
pipe was retried on the next one.

Note the pipe that is due and not started, and keep SOF enabled in that
case, exactly as the old code did. Nothing changes when no periodic pipe
is due, which is the case the timer was added for.

Control and bulk pipes are excluded deliberately: their next_tx_frame is
not updated on completion, so they are almost always "due" and would
keep SOF enabled permanently.

Fixes: aebbc7d63407 ("usb: octeon-hcd: sleep on an hrtimer for far-off periodic transfers")
Assisted-by: Claude:claude-opus-5
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
diff --git a/drivers/usb/host/octeon-hcd.c b/drivers/usb/host/octeon-hcd.c
--- a/drivers/usb/host/octeon-hcd.c
+++ b/drivers/usb/host/octeon-hcd.c
@@ -1923,6 +1923,7 @@ static void cvmx_usb_schedule(struct octeon_hcd *usb, int is_sof)
 	struct cvmx_usb_pipe *pipe;
 	int need_sof;
 	u64 min_due;
+	bool due_now;
 	enum cvmx_usb_transfer ttype;
 
 	if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) {
@@ -1964,12 +1965,23 @@ done:
 	 */
 	need_sof = 0;
 	min_due = ~0ull;
+	due_now = false;
 	for (ttype = CVMX_USB_TRANSFER_CONTROL;
 	     ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) {
 		list_for_each_entry(pipe, &usb->active_pipes[ttype], node) {
-			if (pipe->next_tx_frame > usb->frame_number &&
-			    pipe->next_tx_frame < min_due)
+			if (pipe->next_tx_frame <= usb->frame_number) {
+				/*
+				 * A periodic pipe that is due but was not
+				 * started - no idle channel, or its split
+				 * window is closed - is only retried from a
+				 * SOF, so do not sleep past it.
+				 */
+				if (ttype == CVMX_USB_TRANSFER_ISOCHRONOUS ||
+				    ttype == CVMX_USB_TRANSFER_INTERRUPT)
+					due_now = true;
+			} else if (pipe->next_tx_frame < min_due) {
 				min_due = pipe->next_tx_frame;
+			}
 		}
 	}
 	if (min_due != ~0ull) {
@@ -1983,7 +1995,7 @@ done:
 		 * a few frames. Stay well below the 16383-frame wrap of
 		 * HFNUM. One (micro)frame is 125us in high-speed mode.
 		 */
-		if (delta <= 4 || delta > 8000)
+		if (due_now || delta <= 4 || delta > 8000)
 			need_sof = 1;
 		else
 			hrtimer_start(&usb->sof_timer,
-- 
2.47.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: octeon-hcd: keep SOF interrupts while a periodic pipe is due
  2026-09-15  8:17 [PATCH] usb: octeon-hcd: keep SOF interrupts while a periodic pipe is due Orgad Shaneh
@ 2026-10-11  6:56 ` Orgad Shaneh
  2026-10-11  7:17   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Orgad Shaneh @ 2026-10-11  6:56 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel

Hi Greg,

A gentle ping on this one. It fixes aebbc7d63407 ("usb: octeon-hcd: sleep
on an hrtimer for far-off periodic transfers"), which came in with the
usb-7.3-rc6 pull, so 7.3 will ship with the regression unless this is
picked up: a periodic pipe that is due but could not be started can wait
up to a second for the next SOF.

If it looks fine, could it go to Linus through usb-linus? If you would
like anything changed, I will respin.

Thanks,
Orgad

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: octeon-hcd: keep SOF interrupts while a periodic pipe is due
  2026-10-11  6:56 ` Orgad Shaneh
@ 2026-10-11  7:17   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-10-11  7:17 UTC (permalink / raw)
  To: Orgad Shaneh; +Cc: linux-usb, linux-kernel

On Sun, Oct 11, 2026 at 06:56:51AM +0000, Orgad Shaneh wrote:
> Hi Greg,
> 
> A gentle ping on this one. It fixes aebbc7d63407 ("usb: octeon-hcd: sleep
> on an hrtimer for far-off periodic transfers"), which came in with the
> usb-7.3-rc6 pull, so 7.3 will ship with the regression unless this is
> picked up: a periodic pipe that is due but could not be started can wait
> up to a second for the next SOF.
> 
> If it looks fine, could it go to Linus through usb-linus? If you would
> like anything changed, I will respin.

Sorry, but there is no context here, where is the patch?

And I am way behind in patch review due to travel and conferences, will
be catching up "soon".

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-11  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  8:17 [PATCH] usb: octeon-hcd: keep SOF interrupts while a periodic pipe is due Orgad Shaneh
2026-10-11  6:56 ` Orgad Shaneh
2026-10-11  7:17   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®