From: Hans de Goede <hdegoede@redhat.com>
To: Alan Stern <stern@rowland.harvard.edu>, Dingyan Li <18500469033@163.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
Xiaofan Chen <xiaofanc@gmail.com>,
Oliver Neukum <oneukum@suse.com>,
Tormod Volden <lists.tormod@gmail.com>,
sebastian.reichel@collabora.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: add usbfs ioctl to get specific superspeedplus rates
Date: Thu, 3 Aug 2023 17:39:56 +0200 [thread overview]
Message-ID: <a31ee75e-6a8e-fe7b-aadc-f118d9ab60f9@redhat.com> (raw)
In-Reply-To: <51926ee6-ee81-4543-a1f7-338e65a26670@rowland.harvard.edu>
Hi,
On 8/3/23 17:10, Alan Stern wrote:
> On Thu, Aug 03, 2023 at 02:13:33PM +0800, Dingyan Li wrote:
>>
>> At 2023-07-26 22:39:32, "Hans de Goede" <hdegoede@redhat.com> wrote:
>
>>> Right, so the reason why IOCTL USBDEVFS_GET_SPEED was added is so
>>> that a confined qemu process which gets just a fd for a /dev/bus/usb/
>>> device passed by a more privileged process can still get the speed
>>> despite it not having sysfs access. This is necessary for correct
>>> pass-through of USB devices.
>>>
>>> Since USBDEVFS_GET_SPEED now no longer tells the full story I believe
>>> that the proposed USBDEVFS_GET_SSP_RATE ioctl makes sense.
>>>
>>> The current patch however misses moving the enum usb_ssp_rate
>>> declaration from include/linux/usb/ch9.h to
>>> include/uapi/linux/usb/ch9.h so that needs to be fixed in a version
>>> 2. Assuming that with the above explanation of why this is necessary
>>> Greg and Alan are ok with adding the ioctl.
>>>
>>> Regards,
>>>
>>> Hans
>>>
>>
>> Hi Greg and Alan,
>>
>> Could you please share your opinions about Hans' justification?
>
> Instead of adding a new ioctl or modifying an existing one, how about
> increasing the set of constants in enum usb_device_speed? Then the
> existing ioctls could return the newly defined values when appropriate,
> with no other changes necessary.
Right, I was thinking along the same lines but I was not entirely
sure this would work because I looked at the wrong bits of
include/uapi/linux/usb/ch9.h while writing my first email on this.
Looking again I see we already have a straight forward
enum usb_device_speed for this which can easily be extended.
> (This doesn't mean just moving the definition of usb_ssp_rate from one
> header file to the other. The usb_device_speed enumeration should be
> extended with the new members. Perhaps omitting USB_SSP_GEN_UNKNOWN
> since we already have USB_SPEED_SUPER_PLUS, or setting the first equal
> to the second.)
>
> I don't think there was ever a requirement in the API that the set of
> values in usb_device_speed could never increase (and in fact it has
> increased in the past). Such a requirement wouldn't make any sense,
> given how the USB-IF keeps defining newer and faster USB bus
> implementations.
>
> Hans, would that play well with libusb?
It should, this is how libusb uses the USBDEVFS_GET_SPEED ioctl:
static enum libusb_speed usbfs_get_speed(struct libusb_context *ctx, int fd)
{
int r;
r = ioctl(fd, IOCTL_USBFS_GET_SPEED, NULL);
switch (r) {
case USBFS_SPEED_UNKNOWN: return LIBUSB_SPEED_UNKNOWN;
case USBFS_SPEED_LOW: return LIBUSB_SPEED_LOW;
case USBFS_SPEED_FULL: return LIBUSB_SPEED_FULL;
case USBFS_SPEED_HIGH: return LIBUSB_SPEED_HIGH;
case USBFS_SPEED_WIRELESS: return LIBUSB_SPEED_HIGH;
case USBFS_SPEED_SUPER: return LIBUSB_SPEED_SUPER;
case USBFS_SPEED_SUPER_PLUS: return LIBUSB_SPEED_SUPER_PLUS;
default:
usbi_warn(ctx, "Error getting device speed: %d", r);
}
return LIBUSB_SPEED_UNKNOWN;
}
I think that GEN_2x1 should probably be mapped to
USBFS_SPEED_SUPER_PLUS so as to not break this most common case
and to keep apps reporting either Super Speed Plus or 10Gbps
(more common) for this.
GEN_1x2 + GEN_2x2 can then be mapped to new values, which will
cause libusb to log a warning + return LIBUSB_SPEED_UNKNOWN
until libusb is updated which seems harmless enough.
Regards,
Hans
next prev parent reply other threads:[~2023-08-03 15:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 8:40 Dingyan Li
2023-07-21 11:04 ` Greg KH
[not found] ` <550dbb46.5bc4.189785b0360.Coremail.18500469033@163.com>
2023-07-21 12:11 ` Greg KH
2023-07-21 12:35 ` Dingyan Li
2023-07-21 14:51 ` Greg KH
2023-07-21 15:43 ` Dingyan Li
2023-07-21 17:26 ` Alan Stern
2023-07-24 9:47 ` Oliver Neukum
2023-07-25 13:24 ` Greg KH
2023-07-25 13:54 ` Dingyan Li
2023-07-25 14:08 ` Oliver Neukum
2023-07-25 14:40 ` Dingyan Li
2023-07-25 15:12 ` Greg KH
2023-07-25 16:11 ` Dingyan Li
2023-07-26 8:33 ` Oliver Neukum
2023-07-26 9:36 ` Dingyan Li
2023-07-26 9:49 ` Oliver Neukum
2023-07-26 10:10 ` Dingyan Li
2023-07-26 1:37 ` Xiaofan Chen
2023-07-26 9:38 ` Oliver Neukum
2023-07-26 3:20 ` Xiaofan Chen
2023-07-26 14:39 ` Hans de Goede
2023-08-03 6:13 ` Dingyan Li
2023-08-03 15:10 ` Alan Stern
2023-08-03 15:39 ` Hans de Goede [this message]
2023-08-03 16:06 ` Dingyan Li
2023-08-03 17:56 ` Alan Stern
2023-08-04 4:16 ` Dingyan Li
2023-08-04 14:55 ` Alan Stern
2023-08-19 4:32 ` Dingyan Li
2023-08-19 5:46 ` [PATCH v2] USB: Support 20Gbps speed for ioctl USBDEVFS_GET_SPEED Dingyan Li
2023-08-19 19:03 ` Alan Stern
2023-08-20 5:29 ` Dingyan Li
2023-08-19 18:46 ` Re: Re: Re: [PATCH] USB: add usbfs ioctl to get specific superspeedplus rates Alan Stern
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=a31ee75e-6a8e-fe7b-aadc-f118d9ab60f9@redhat.com \
--to=hdegoede@redhat.com \
--cc=18500469033@163.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lists.tormod@gmail.com \
--cc=oneukum@suse.com \
--cc=sebastian.reichel@collabora.com \
--cc=stern@rowland.harvard.edu \
--cc=xiaofanc@gmail.com \
/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
all inboxes | Powered by JetHome®