Linux USB
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: ValdikSS <iam@valdikss.org.ru>
Cc: linux-usb@vger.kernel.org
Subject: Re: USB 1.1 Full Speed OHCI slow/high latency
Date: Fri, 15 Aug 2025 10:52:24 -0400	[thread overview]
Message-ID: <7bfaeea9-6eb1-4e49-af8a-77940fdb70fc@rowland.harvard.edu> (raw)
In-Reply-To: <2bf5c54e-7dac-4673-a696-e09eb8d459d5@valdikss.org.ru>

On Fri, Aug 15, 2025 at 11:39:03AM +0300, ValdikSS wrote:
> On 14.08.2025 7:40 PM, Alan Stern wrote:
> > Either .pcap files or the usbmon text output for both of these tests
> > would be good.  But set the number of iterations to something very
> > small, like 10 or so.  No point posting a log containing thousands of
> > repetitions of the same information...
> 
> Here you are, check the attachment. It's a 30 times loop.
> 
> Also tried the speedtest.py on an old HP T510 thin client (x86, VIA chipset,
> UHCI), and the speeds are fine.
> 
> Avg delta: 0.990 ms
> Min: 0.870 ms
> Max: 1.984 ms
> 
> My guess it's OHCI to blame.

The OHCI pcap file shows that transfers take place at intervals of 2 ms, 
which is perhaps slower than expected.  (The EHCI transfers take place 
at intervals of 0.625 or 0.875 ms, which is reasonable.)

I think the reason the OHCI transfers need 2 ms rather than 1 ms is 
because of the way the driver unlinks empty Endpoint Descriptors.  Lines 
1165-1168 of drivers/usb/host/ohci-q.c do this:

	/* clean schedule:  unlink EDs that are no longer busy */
	if (list_empty(&ed->td_list)) {
		if (ed->state == ED_OPER)
			start_ed_unlink(ohci, ed);

As a result, each time a transfer finishes the ED is unlinked, and each 
time a new transfer starts the ED has to be linked again.  Presumably (I 
don't recall all the details about how OHCI works so this is just my 
guess) those steps each require 1 ms, accounting for the 2-ms time 
interval between transfers.

You could try deleting or commenting out the last two of those lines to 
see if it makes a difference.  (Note that this is not a permanent 
solution; without the call to start_ed_unlink(), the memory used by the 
ED will never be freed.  A better approach would be to unlink EDs after 
they have been idle for some minimum time rather than right away.)

Of course, what's going on when you try to print something may be 
different from this simple test.

Alan Stern

  reply	other threads:[~2025-08-15 14:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  1:56 USB 1.1 Full Speed OHCI slow/high latency ValdikSS
2025-08-14  6:01 ` Greg KH
2025-08-14 14:24 ` Alan Stern
2025-08-14 15:11   ` ValdikSS
2025-08-14 16:40     ` Alan Stern
2025-08-15  8:39       ` ValdikSS
2025-08-15 14:52         ` Alan Stern [this message]
2025-08-15 15:53           ` ValdikSS
2025-08-15 17:07             ` Alan Stern
2025-08-15 18:13               ` ValdikSS
2025-08-16  2:04                 ` Alan Stern
2025-09-21 23:11                   ` ValdikSS
2025-09-22 14:16                     ` Alan Stern
2025-09-22 14:38                       ` ValdikSS
2025-09-22 14:43                         ` Alan Stern
2025-09-22 14:48                           ` [PATCH] usb: ohci: delay endpoint descriptor unlinking to reduce transfer latency ValdikSS
2025-10-01 19:27                             ` Alan Stern
2025-10-01 22:34                               ` [PATCH v2] " ValdikSS
2025-10-02 17:05                                 ` Alan Stern
2025-10-22 13:39                               ` [PATCH v2 RESEND] " ValdikSS

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bfaeea9-6eb1-4e49-af8a-77940fdb70fc@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=iam@valdikss.org.ru \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox