Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp52881rwo; Fri, 21 Jul 2023 08:24:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFFsFZiUB7iOxO85udoHMU/npb1/lbSBuQAgkv53Rjc1YglsmSJR4rf6MEJZy34FPz2nHxw X-Received: by 2002:a17:90a:cd:b0:262:fe45:85f6 with SMTP id v13-20020a17090a00cd00b00262fe4585f6mr1648081pjd.0.1689953048892; Fri, 21 Jul 2023 08:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689953048; cv=none; d=google.com; s=arc-20160816; b=ylm0F+cRyGs6c/pq0S7dCHt8dJQiSUjpcBZo0ixPH7QcffeuhVt674v9oqubD1mED8 GtKxBJ8sb6zecrIkmmD8EFPgg00CLEUiwDYaA51pW6d5prMXnpc4d7HsEWbsi3QAnAZs U5TjcW5gdaBHAqqfRWH/QrIJJ3Mpa1DBSNBeb0d625pil50CrQ+xziQ843g/oGzj6Cu3 iZmLJsRWK5SuwUBzRLqEU3Dv0b/wg1AthlKW1wB8/a+lD8bS8Av1VJV63s2PtK6r+2wK LS5HSBQjKe1xILmnVIe810uJx3bwZbm2cu32cnwhL5EdFCpBo8GwMeDHV+9QV/vmoHLu qcUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/04C8/1xhQXML0AOTDulZK23ZV8MFCRPSrLCPf+37Ho=; fh=IYka8XsVM/p0Ij4nNnjkcpgdY+nLOdZ5JseyDIjOfb4=; b=XWnMJqd5TkYXblMeifpny5YZf+ghmQi2HeM9K78+K72+sWK2BGm7yYjDLG2BlwiGPh ePGJf1NgaQFlxeMOR8o9OGloJrtAKxt7zS87p1Ry4uIWIvzVxkqLsFpUbucILhPVjttn PSxxETbq/2p8zUqdyOhgV3vwGVa0YNFbGDPi8aF10SjVf9oqXMrRp6Ya7XDxXrrB4BfI DNhCNjA6SGrhxOEX1rDBRxJJfqsgZo7k6byjTj/6FMRsk1nl7KA55jEo50rGpusOGlMJ VSuu6WB9j7VVRawWxp8ETJe+6hjFovWiKjxCjIQQmZvQMFcntxcR8jVIR/PSjpR3eQWK rXMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lx3f1KiL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bt8-20020a632908000000b0055387ef9633si3089582pgb.804.2023.07.21.08.23.55; Fri, 21 Jul 2023 08:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lx3f1KiL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbjGUOvl (ORCPT + 99 others); Fri, 21 Jul 2023 10:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjGUOvj (ORCPT ); Fri, 21 Jul 2023 10:51:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DAE30DD; Fri, 21 Jul 2023 07:51:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D763A61CBC; Fri, 21 Jul 2023 14:51:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7258C433C8; Fri, 21 Jul 2023 14:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689951095; bh=JyLcr+hjjbOtJozv2nCAZS5KuLenLLEMRv93SGfMz0A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lx3f1KiLZQ6aMFKpJddnpZcfv2cZAUxd0rHUGPpu6dHJXgGys0vJUzVc6BDb/ToIz BDY55EEfyr4U4HmAyisYd+xC7w0KqmXNj9+59w4BN3AeSUdAxZHeatNDdWCFLxe5PP 3p31py3eSUZhE5dxG7QgMhLkBvDgm3toODzpTQAg= Date: Fri, 21 Jul 2023 16:51:32 +0200 From: Greg KH To: Dingyan Li <18500469033@163.com> 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 Message-ID: <2023072159-carol-underfeed-43eb@gregkh> References: <20230721084039.9728-1-18500469033@163.com> <2023072105-lethargic-saddling-ad97@gregkh> <130b453c.5c8f.1897872ce54.Coremail.18500469033@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <130b453c.5c8f.1897872ce54.Coremail.18500469033@163.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 21, 2023 at 08:35:37PM +0800, Dingyan Li wrote: > > At 2023-07-21 19:04:29, "Greg KH" 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. It needs to be documented somewhere, otherwise no one knows how to use it. > 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. Ok, that should be documented. > 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. If libusb doesn't need this ioctl, who would use it? We only add apis that are actually going to be used. So if libusb doesn't use it, we need a real-world user for us to be able to add this. thanks, greg k-h