On Mon, 23 Sep 2019, Lorenzo Sutton wrote:
I have anecdotally, but recurrently observed on
laptops - including a
rather recent one - that there is always a 'best' USB port for external
sound cards.
Surprise!
1. Is there a more scientific (well, precise at least)
method to assess
this USB port performance? What to test or look into?
2. Is there a way to change (e.g. improve the not-so-good USB port
performance) OS/software wise, or is this usually hard-wired in notebooks?
2a. Are IRQs relevant on laptops and if so can a whole USB port (or
the device attached to it) be optimised from the OS?
I have had this experience too. In my case, I had two sockets on the right
and one on the left. It was not a matter of one was better than the
others, it turned out I could use either of the right hand sockets for my
audio device... so long as the other was empty. So I had to add a USB hub
to the left side for everything else.
The way to look for a good port is to start by finding out which USB bus
each of your sockets go to and what buses are already being used. The tool
for this seems to be usb-devices. All computers I have looked at (by no
means everything) have on each bus a controller and a hub internally. That
is ok. So plugin something in each port, one at a time and run usb-devices
to see which bus it ends up on. It is also a good time to check what other
things may be using that bus internally. So for Audio work you want to use
one of the buses just for your audio device.
IRQs can be checked with:
cat /proc/interrupts
The first number is the IRQ and the last is the process using it... or the
processes using it. If you are lucky you will see something like:
ehci_hcd:usb1
and that will tell you what bus uses which irq each bus uses. You can then
use rtirq to raise the priority of that bus in the line:
RTIRQ_NAME_LIST="rtc snd usb i8042"
rtc and i8042 need not be there
allowing just the usb in there may be counter productive as well because
then rtirq raises all the usb buses up and may put your mouse on a higher
priority than youe audio. Better to leave them alone in that case.
However, if you can see the bus on:
ps ax (ps ax |grep usb1)
then you can change that line to: "usb1 snd usb" and that will allow your
audio device to have a higher priority.
However, newer kernals and newer mother boards are different. (and not
even that new) My desktop as it came insisted that my usb audio device was
on bus 3 no matter which socket I used. It did not matter if they were
USB2.0 or USB3.0 sockets but it would internally route them all to the
same socket... till I went into the bios and turned the xhci controller
off. Now I have two buses (I had four before with only one ever getting
used) that say ehci and only bus 1 and 2. Rtirq does not find usb1
separately from usb2 still but there is udev-rtirq:
https://github.com/jhernberg/udev-rtirq
and that sets it just fine dynamically. turning xhci off means no usb3.0
use... but I am ok with that. (I have no usb3.0 bits anyway)
Adding a USB PCIe card would give me it's own IRQ even with xhci but that
is not a laptop solution.
Things I don't know: I think my cheap USB audio device is actually USB 1.1
and not usb 2. A USB2.0 device may grab one of the ehci controllers even
with xhci running, I don't know. A USB3.0 hub plugged into a USB3.0 socket
may use one of the other usb buses besides the one xhci wants to use for
everything usb1.1.
As a side note, USB has never been about latency. Rather the opposite if
anything. The advances in USB have been speed or throughput. Latency is
not even the same from one run to the next.
In USB there are no guarantees... but in low latency, guaranteed
schedualing is what it is all about.
USB audio devices means getting things sort of good. With a laptop that is
about as far as things go.
--
Len Ovens
www.ovenwerks.net