From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Felipe Balbi <balbi@kernel.org>,
linux-usb@vger.kernel.org, John Youn <John.Youn@synopsys.com>
Subject: Re: [PATCH 01/11] usb: ch9: Add sublink speed struct
Date: Fri, 17 Jul 2020 08:34:03 +0200 [thread overview]
Message-ID: <20200717063403.GC3238569@kroah.com> (raw)
In-Reply-To: <90961eec3e1ed3c27e41e7169353cc295c551604.1594935978.git.thinhn@synopsys.com>
On Thu, Jul 16, 2020 at 02:58:36PM -0700, Thinh Nguyen wrote:
> USB 3.2 specification supports dual-lane for super-speed-plus. USB
> devices may operate at different sublink speeds. To avoid using magic
> numbers and capture the sublink speed better, introduce the
> usb_sublink_speed structure and various sublink speed attribute enum.
>
> See SSP BOS descriptor in USB 3.2 specification section 9.6.2.5
>
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
> ---
> include/uapi/linux/usb/ch9.h | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
> index 2b623f36af6b..d4fd403a3664 100644
> --- a/include/uapi/linux/usb/ch9.h
> +++ b/include/uapi/linux/usb/ch9.h
> @@ -1145,6 +1145,48 @@ enum usb_device_speed {
> USB_SPEED_SUPER_PLUS, /* usb 3.1 */
> };
>
> +/* USB 3.2 sublink speed attributes */
> +
> +enum usb_lane_speed_exponent {
> + USB_LSE_BPS = 0,
> + USB_LSE_KBPS = 1,
> + USB_LSE_MBPS = 2,
> + USB_LSE_GBPS = 3,
> +};
> +
> +enum usb_sublink_type {
> + USB_ST_SYMMETRIC_RX = 0,
> + USB_ST_ASYMMETRIC_RX = 1,
> + USB_ST_SYMMETRIC_TX = 2,
> + USB_ST_ASYMMETRIC_TX = 3,
> +};
> +
> +enum usb_link_protocol {
> + USB_LP_SS = 0,
> + USB_LP_SSP = 1,
> +};
> +
> +/**
> + * struct usb_sublink_speed - sublink speed attribute
> + * @id: sublink speed attribute ID (SSID)
> + * @mantissa: lane speed mantissa
> + * @exponent: lane speed exponent
> + * @sublink type: sublink type
> + * @protocol: sublink protocol
> + *
> + * Super-speed-plus supports multiple lanes. Use the sublink speed attributes to
> + * describe the sublink speed.
> + *
> + * See USB 3.2 spec section 9.6.2.6 for super-speed-plus capability for more
> + * information.
> + */
> +struct usb_sublink_speed {
> + u8 id;
> + u16 mantissa;
You have to use the proper data types for crossing the user/kernel
boundry here. That would be __u8 and __u16, right?
> + enum usb_lane_speed_exponent exponent;
> + enum usb_sublink_type type;
> + enum usb_link_protocol protocol;
Are you _sure_ that an enum is the correct size for these fields? How
can you guarantee this? We do not use enums in this way for any other
field in this file for a reason...
And did you look at the layout of this structure to verify it actually
matches what is on the wire with USB? I think you need to add a packed
attribute to guarantee it.
thanks,
greg k-h
> +};
>
> enum usb_device_state {
> /* NOTATTACHED isn't in the USB spec, and this state acts
> --
> 2.11.0
>
next prev parent reply other threads:[~2020-07-17 6:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 21:58 [PATCH 00/11] usb: Handle different sublink speeds Thinh Nguyen
2020-07-16 21:58 ` [PATCH 01/11] usb: ch9: Add sublink speed struct Thinh Nguyen
2020-07-17 6:34 ` Greg Kroah-Hartman [this message]
2020-07-17 7:06 ` Thinh Nguyen
2020-07-17 7:33 ` Greg Kroah-Hartman
2020-07-17 7:47 ` Thinh Nguyen
2020-07-17 8:15 ` Greg Kroah-Hartman
2020-07-17 8:29 ` Thinh Nguyen
2020-07-17 8:39 ` kernel test robot
2020-07-17 8:46 ` Sergei Shtylyov
2020-07-17 22:42 ` Thinh Nguyen
2020-07-18 12:53 ` kernel test robot
2020-07-16 21:58 ` [PATCH 02/11] usb: gadget: composite: Avoid using magic numbers Thinh Nguyen
2020-07-16 21:58 ` [PATCH 03/11] usb: gadget: Expose sublink speed attributes Thinh Nguyen
2020-07-16 21:58 ` [PATCH 04/11] usb: gadget: Set max speed for SSP devices Thinh Nguyen
2020-07-16 21:59 ` [PATCH 05/11] usb: composite: Properly report sublink speed Thinh Nguyen
2020-07-16 21:59 ` [PATCH 06/11] usb: devicetree: dwc3: Introduce num-lanes and lsm Thinh Nguyen
2020-07-21 3:39 ` Rob Herring
2020-07-21 5:01 ` Thinh Nguyen
2020-07-21 15:04 ` Rob Herring
2020-07-21 16:41 ` Thinh Nguyen
2020-07-22 11:06 ` Felipe Balbi
2020-07-22 14:45 ` Rob Herring
2020-07-22 15:14 ` Thinh Nguyen
2020-07-22 17:30 ` Thinh Nguyen
2020-07-23 2:11 ` Thinh Nguyen
2020-07-16 21:59 ` [PATCH 07/11] usb: dwc3: Initialize lane count and sublink speed Thinh Nguyen
2020-07-16 21:59 ` [PATCH 08/11] usb: dwc3: gadget: Report sublink speed capability Thinh Nguyen
2020-07-16 21:59 ` [PATCH 09/11] usb: dwc3: gadget: Implement setting of sublink speed Thinh Nguyen
2020-07-16 21:59 ` [PATCH 10/11] usb: dwc3: gadget: Track connected lane and " Thinh Nguyen
2020-07-16 21:59 ` [PATCH 11/11] usb: dwc3: gadget: Set speed only up to the max supported Thinh Nguyen
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=20200717063403.GC3238569@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=John.Youn@synopsys.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=linux-usb@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).