From: Linyu Yuan <quic_linyyuan@quicinc.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>, Linyu Yuan <quic_linyyuan@quicinc.com>
Subject: [PATCH v2 1/7] usb: gadget: use working speed to calcaulate network bitrate and qlen
Date: Thu, 3 Aug 2023 17:10:47 +0800 [thread overview]
Message-ID: <20230803091053.9714-2-quic_linyyuan@quicinc.com> (raw)
In-Reply-To: <20230803091053.9714-1-quic_linyyuan@quicinc.com>
Take ecm_bitrate() as example, it will be called after gadget device
link speed negotiation, consider code
if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER),
if a gadget device link speed is USB_SPEED_SUPER,
gadget_is_superspeed(g) must be true, or not it is a wrong
configuration of gadget max support speed.
Remove gadget_is_superspeed(g) checking should be safe, and remove other
similar operation in ncm, rndis, u_ether.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
v2: move this as first patch to fix comment from Oliver Neukum <oneukum@suse.com>
drivers/usb/gadget/function/f_ecm.c | 4 ++--
drivers/usb/gadget/function/f_ncm.c | 6 +++---
drivers/usb/gadget/function/f_rndis.c | 6 +++---
drivers/usb/gadget/function/u_ether.c | 5 ++---
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index c6e63ad77a40..cbe05da94bde 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -68,9 +68,9 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f)
/* peak (theoretical) bulk transfer rate in bits-per-second */
static inline unsigned ecm_bitrate(struct usb_gadget *g)
{
- if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
+ if (g->speed == USB_SPEED_SUPER)
return 13 * 1024 * 8 * 1000 * 8;
- else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
+ else if (g->speed == USB_SPEED_HIGH)
return 13 * 512 * 8 * 1000 * 8;
else
return 19 * 64 * 1 * 1000 * 8;
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 424bb3b666db..e6dac5510540 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -85,11 +85,11 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
{
if (!g)
return 0;
- else if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS)
+ else if (g->speed >= USB_SPEED_SUPER_PLUS)
return 4250000000U;
- else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
+ else if (g->speed == USB_SPEED_SUPER)
return 3750000000U;
- else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
+ else if (g->speed == USB_SPEED_HIGH)
return 13 * 512 * 8 * 1000 * 8;
else
return 19 * 64 * 1 * 1000 * 8;
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index ee95e8f5f9d4..eff5d7cbce00 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -87,11 +87,11 @@ static inline struct f_rndis *func_to_rndis(struct usb_function *f)
/* peak (theoretical) bulk transfer rate in bits-per-second */
static unsigned int bitrate(struct usb_gadget *g)
{
- if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS)
+ if (g->speed >= USB_SPEED_SUPER_PLUS)
return 4250000000U;
- if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
+ if (g->speed == USB_SPEED_SUPER)
return 3750000000U;
- else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
+ else if (g->speed == USB_SPEED_HIGH)
return 13 * 512 * 8 * 1000 * 8;
else
return 19 * 64 * 1 * 1000 * 8;
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index a366abb45623..4bb0553da658 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -93,11 +93,10 @@ struct eth_dev {
#define DEFAULT_QLEN 2 /* double buffering by default */
-/* for dual-speed hardware, use deeper queues at high/super speed */
+/* use deeper queues at high/super speed */
static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
{
- if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH ||
- gadget->speed >= USB_SPEED_SUPER))
+ if (gadget->speed == USB_SPEED_HIGH || gadget->speed >= USB_SPEED_SUPER)
return qmult * DEFAULT_QLEN;
else
return DEFAULT_QLEN;
--
2.17.1
next prev parent reply other threads:[~2023-08-03 9:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 9:10 [PATCH v2 0/7] remove some usage of gadget_is_{*}speed() API Linyu Yuan
2023-08-03 9:10 ` Linyu Yuan [this message]
2023-08-03 9:10 ` [PATCH v2 2/7] usb: gadget: add a inline function gether_bitrate() Linyu Yuan
2023-08-03 9:10 ` [PATCH v2 3/7] usb: gadget: f_uvc: change endpoint allocation in uvc_function_bind() Linyu Yuan
2023-12-19 16:17 ` Frank Li
2023-12-20 14:33 ` yuan linyu
2023-12-20 16:02 ` Frank Li
2023-12-21 14:14 ` yuan linyu
2023-12-21 14:57 ` Frank Li
2023-08-03 9:10 ` [PATCH v2 4/7] usb: gadget: unconditionally allocate hs/ss descriptor in bind operation Linyu Yuan
2023-08-03 9:10 ` [PATCH v2 5/7] usb: gadget: config: remove max speed check in usb_assign_descriptors() Linyu Yuan
2023-08-03 9:10 ` [PATCH v2 6/7] usb: gadget: composite: cleanup function config_ep_by_speed_and_alt() Linyu Yuan
2023-08-03 9:10 ` [PATCH v2 7/7] usb: gadget: remove max support speed info in bind operation Linyu Yuan
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=20230803091053.9714-2-quic_linyyuan@quicinc.com \
--to=quic_linyyuan@quicinc.com \
--cc=gregkh@linuxfoundation.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