From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753424AbdCNBns (ORCPT ); Mon, 13 Mar 2017 21:43:48 -0400 Received: from netrider.rowland.org ([192.131.102.5]:52335 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752012AbdCNBnr (ORCPT ); Mon, 13 Mar 2017 21:43:47 -0400 Date: Mon, 13 Mar 2017 21:43:44 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Dave Mielke cc: Samuel Thibault , , , , , , Subject: Re: [PATCH] usb-core: Add MS_INTR_BINTERVAL USB quirk In-Reply-To: <20170313014641.GI20039@beta.private.mielke.cc> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 12 Mar 2017, Dave Mielke wrote: > [quoted lines by Alan Stern on 2017/03/12 at 21:40 -0400] > > >No, I was wondering why an HID device would run at high speed. Both > >you and Samuel implied that this was because it was a USB-2 device. > >But that is not an adequate answer, because it is perfectly valid for a > >USB-2 device to run at full speed. > > What should we look at to find out what speed it wants to operate at? We didn't The speed is reported in the kernel log and in /sys/kernel/debug/usb/devices. > look into it becuaase the real problem, from our perspective, was that the 64ms > interval was being honoured by the host when it should be the 10ms as is > literally in the endpoint descriptor. Our assumption was that since it says > it's USB 2.0 then bInterval must be intterpreted in light of that regardless of > the actual speed used for communication. You should read the USB specification. Specifically, table 9-13 in section 9.6.6 describes bInterval like this (in part): Interval for polling endpoint for data transfers. Expressed in frames or microframes depending on the device operating speed (i.e., either 1 millisecond or 125 μs units). For full-/high-speed isochronous endpoints, this value must be in the range from 1 to 16. The bInterval value is used as the exponent for a 2^(bInterval-1) value; e.g., a bInterval of 4 means a period of 8 (2^(4-1)). For full-/low-speed interrupt endpoints, the value of this field may be from 1 to 255. For high-speed interrupt endpoints, the bInterval value is used as the exponent for a 2^(bInterval-1) value; e.g., a bInterval of 4 means a period of 8 (2^(4-1)). This value must be from 1 to 16. > Yes, I did know this, so maybe I misunderstood what you were wondering about. > Were you wondering why 64ms was too long? No. I was wondering why an HID device would run at high speed. > I think I've misunderstood something about how to interpret bInterval. I'm now > suspecting that bInterval must be interpreted the new (mocro frame) way only if > the device is operating at least at high speed, and that, even if the device > advertizes itself as USB 2.0, bInterval must still be interpreted the old way > if the device is operating at full or low speed. Is that correct? Like I said, read the spec. > If the above is correct, how can we tell from usbfs which way to > interpret bInterval? There is an ioctl you can use to find the device speed: USBDEVFS_CONNECTINFO. Unfortunately, this ioctl is badly out of date and only distinguishes between low speed and non-low speed. A patch to remedy this situation would be welcome. However, in general, users of usbfs don't need to know the device speed. In particular, you don't need to interpret bInterval. Just submit URBs quickly enough that the pipeline never empties out. Alan Stern