Re: [PATCH v2 1/3] usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 18, 2020 at 9:59 AM Lorenzo Colitti <lorenzo@xxxxxxxxxx> wrote:
>
> Currently, SuperSpeed NCM gadgets report a speed of 851 Mbps
> in USB_CDC_NOTIFY_SPEED_CHANGE. But the calculation appears to
> assume 16 packets per microframe, and USB 3 and above no longer
> use microframes.
>
> Maximum speed is actually much higher. On a direct connection,
> theoretical throughput is about 3.86 Gbps for gen1x1 and
> 9.35 Gbps for gen2x1, and I have seen gadget->host speeds
> >2 Gbps for gen1x1 and >4 Gbps for gen2x1.
>
> Unfortunately the ConnectionSpeedChange defined in the CDC spec
> only uses 32-bit values, so we can't report accurate numbers for
> 10Gbps and above. So always report a speed of 4 Gbps, which is
> close enough to the technical maximum of a 5 Gbps link.
>
> This results in:
>
> [96033.958723] cdc_ncm 8-2:1.0 enx4643f5db6f40: renamed from usb0
> [96033.997136] cdc_ncm 8-2:1.0 enx4643f5db6f40: 4000 mbit/s downlink 4000 mbit/s uplink
>
> Fixes: 1650113888fe ("usb: gadget: f_ncm: add SuperSpeed descriptors for CDC NCM")
> Signed-off-by: Lorenzo Colitti <lorenzo@xxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/f_ncm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
> index 1d900081b1..0c073df225 100644
> --- a/drivers/usb/gadget/function/f_ncm.c
> +++ b/drivers/usb/gadget/function/f_ncm.c
> @@ -85,8 +85,8 @@ static inline struct f_ncm *func_to_ncm(struct usb_function *f)
>  /* peak (theoretical) bulk transfer rate in bits-per-second */
>  static inline unsigned ncm_bitrate(struct usb_gadget *g)
>  {
> -       if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
> -               return 13 * 1024 * 8 * 1000 * 8;
> +       if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER)
> +               return 4000000000;
>         else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
>                 return 13 * 512 * 8 * 1000 * 8;
>         else
> --
> 2.28.0.220.ged08abb693-goog
>

Do you know what this actually affects besides the display?
My cursory investigation shows it gets printed to kernel log and sent
over some sort of ncm notification to the other side...

Is it better to underestimate or overestimate?
(ie. would it be better to report 3.5 gbps for super and max out at
4.2 gbps for super plus instead?)

However, since this is obviously better than the utterly bogus 851,968,000:

Reviewed-by: Maciej Żenczykowski <maze@xxxxxxxxxx>




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux