From: "Dingyan Li" <18500469033@163.com>
To: "Greg KH" <gregkh@linuxfoundation.org>
Cc: stern@rowland.harvard.edu, sebastian.reichel@collabora.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re:Re: [PATCH] USB: add usbfs ioctl to get specific superspeedplus rates
Date: Fri, 21 Jul 2023 20:35:37 +0800 (CST) [thread overview]
Message-ID: <130b453c.5c8f.1897872ce54.Coremail.18500469033@163.com> (raw)
In-Reply-To: <2023072105-lethargic-saddling-ad97@gregkh>
At 2023-07-21 19:04:29, "Greg KH" <gregkh@linuxfoundation.org> wrote:
>On Fri, Jul 21, 2023 at 04:40:39PM +0800, Dingyan Li wrote:
>> The usbfs interface does not provide any way to get specific
>> superspeedplus rate, like Gen2x1, Gen1x2 or Gen2x2. Current
>> API include an USBDEVFS_GET_SPEED ioctl, but it can only return
>> general superspeedplus speed instead of any specific rates.
>> Therefore we can't tell whether it's a Gen2x2(20Gbps) device.
>>
>> This patch introduce a new ioctl USBDEVFS_GET_SSP_RATE to fix
>> it. Similar information is already available via sysfs, it's
>> good to add it for usbfs too.
>>
>> Signed-off-by: Dingyan Li <18500469033@163.com>
>> ---
>> drivers/usb/core/devio.c | 3 +++
>> include/uapi/linux/usbdevice_fs.h | 1 +
>> 2 files changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
>> index 1a16a8bdea60..2f57eb163360 100644
>> --- a/drivers/usb/core/devio.c
>> +++ b/drivers/usb/core/devio.c
>> @@ -2783,6 +2783,9 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
>> case USBDEVFS_GET_SPEED:
>> ret = ps->dev->speed;
>> break;
>> + case USBDEVFS_GET_SSP_RATE:
>> + ret = ps->dev->ssp_rate;
>> + break;
>
>Shouldn't this new ioctl be documented somewhere? What are the valid
>values it can return? What if it in't a superspeed device? Who is
>going to use this?
>
>And we have traditionally only been adding new information like this to
>sysfs, which was not around when usbfs was created. Why not just use
>that instead? Are you wanting to see all of the sysfs-provided
>information in usbfs also?
>
>thanks,
>
>greg k-h
1. By saying "be documented somewhere", do you mean there is extra
documentation work which needs to be done? Sorry that I missed this
part since it's the first time for me to work on a kernel patch.
2. If no error, returned values are "enum usb_ssp_rate" defined in include/linux/usb/ch9.h
3. ssp rate is only valid for superspeedplus. For other speeds, it should be
USB_SSP_GEN_UNKNOWN.
4. I found in libusb, there are two ways to get speed value for a device.
One way is via sysfs, which has supported 20Gbps now. Another way is
to use ioctl USBDEVFS_GET_SPEED. This is when I found this ioctl can only
return USB_SPEED_SUPER_PLUS at most, it cannot determine current ssp rate
further, no matter Gen1x2(10Gbps), Gen2x1(10Gbps) or Gen2x2(20Gbps). So I
thought maybe it's good to provide a similar way like ioctl USBDEVFS_GET_SPEED
in order to get ssp rates.
5. Okay, now I get it that sysfs is a replacement for usbfs. Even in libusb, sysfs is the
preferred way, then fall back to usbfs if sysfs doesn't exist. My intention is not to see
all of the sysfs-provided information in usbfs also. Anyway, if you think this patch is
really unnecessary, I'm totally fine to withdraw it too.
Regards,
Dingyan
next prev parent reply other threads:[~2023-07-21 12:36 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 [this message]
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
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=130b453c.5c8f.1897872ce54.Coremail.18500469033@163.com \
--to=18500469033@163.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=stern@rowland.harvard.edu \
/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®