From: "Dingyan Li" <18500469033@163.com>
To: "Alan Stern" <stern@rowland.harvard.edu>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
"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:Re: Re: Re: [PATCH] USB: add usbfs ioctl to get specific superspeedplus rates
Date: Sat, 19 Aug 2023 12:32:43 +0800 (CST) [thread overview]
Message-ID: <79f3ec25.fa3.18a0c111fa9.Coremail.18500469033@163.com> (raw)
In-Reply-To: <daa39dd3-4e8b-4d69-8ad3-5ec73fa12f8c@rowland.harvard.edu>
At 2023-08-04 22:55:49, "Alan Stern" <stern@rowland.harvard.edu> wrote:
>> Another issue is that USB_SPEED_SUPER_PLUS has been widely used in
>> so many files to execute conditional banches. Once we extend and store device's
>> speed with new values in the first place, we might need to check all places where
>> USB_SPEED_SUPER_PLUS is used in case of any regression.
>
>Certainly. That's part of auditing all the current users of
>usb_device_speed.
This might not be a good idea and feels kind of drift away from what we originally
want to do. Besides, suppose later new speed values are added, someone still has
to revisit all the files to modify those checks. I think we should try to avoid this situation.
>> I think maybe we can try to remove the dependency on enum usb_device_speed
>> in usbfs and define a separate set of speed values similar to previous design
>> at https://www.spinics.net/lists/linux-usb/msg157709.html
>> By this way, in usbfs we get more freedom to determine how to explain
>> usb_device_speed and usb_ssp_rate, without the risk of breaking anything
>> elsewhere.
>>
>> For example, define an USBDEVFS_SPEED_SUPER_PLUS to indicate
>> USB_SPEED_SUPER_PLUS with ssp rates GEN_UNKNOWN, GEN_2x1 and
>> GEN_1x2. They all stand for 10Gbps and we don't need to tell one from
>> another, similar to how it works in sysfs. Then define an
>> USBDEVFS_SPEED_SUPER_PLUS_BY2(maybe there is a more proper name)
>> to indicate USB_SPEED_SUPER_PLUS with ssp rate GEN_2x2, which stands
>> for 20Gbps.
>
>You can't really do that. The values returned by the USBDEVFS_GET_SPEED
>ioctl are the ones defined in include/uapi/linux/usb/ch9.h. They are
>USB_SPEED_UNKNOWN, etc., not USBDEVFS_SPEED_UNKNOWN, etc. The only way
>to extend them is by adding new entries to enum usb_device_speed.
>
>For example, you must not do anything that would break a user program
>which does something like this:
>
>#include <linux/usbdevfs.h>
>#include <linux/usb/ch9.h>
>
>...
>
> enum usb_device_speed s;
>
> s = ioctl(fd, USBDEVFS_GET_SPEED);
> if (s == USB_SPEED_HIGH) ...
>
>Alan Stern
Since those speed definitions are just int values, we could manage to maintain the compatibility
by keeping the same value. But anyway, my latest idea is not to extend enum usb_device_speed.
There are three basic cases:
1) When speed is less than USB_SPEED_SUPER_PLUS, just return dev->speed;
2) When speed is USB_SPEED_SUPER_PLUS but ssp_rate is less than USB_SSP_GEN_2x2,
return dev->speed;
3) When speed is USB_SPEED_SUPER_PLUS and ssp_rate is USB_SSP_GEN_2x2, a new
speed for usbdevfs should be #defined and let's call it USBDEVFS_SPEED_SUPER_PLUS_BY2.
This value won't be overlapped with any value in enum usb_device_speed, for example 7.
In this case, return USBDEVFS_SPEED_SUPER_PLUS_BY2.
The code could be like:
case USBDEVFS_GET_SPEED:
ret = ps->dev->speed;
+ if (ret == USB_SPEED_SUPER_PLUS &&
+ ps->dev->ssp_rate == USB_SSP_GEN_2x2)
+ ret = USBDEVFS_SPEED_SUPER_PLUS_BY2;
break;
By this way, no need to add a new ioctl. No need to touch so many files. And when new
speeds are added later, just #define new values and extend the checks in above code.
Compatibility is also maintained. Before this change, USBDEVFS_GET_SPEED could
return 0-6. After this change, we can still return 0-6 for most of the cases, and 7 for
GEN_2x2 devices.
Regards,
Dingyan
next prev parent reply other threads:[~2023-08-19 4:34 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
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 [this message]
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=79f3ec25.fa3.18a0c111fa9.Coremail.18500469033@163.com \
--to=18500469033@163.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--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®