stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: dwc3: gadget: Fix ssp speed setting
@ 2021-03-09  2:16 Thinh Nguyen
  2021-03-09  2:16 ` [PATCH 1/2] usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate Thinh Nguyen
  2021-03-09  2:16 ` [PATCH 2/2] usb: dwc3: gadget: Use max speed if unspecified Thinh Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: Thinh Nguyen @ 2021-03-09  2:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh.Nguyen, linux-usb
  Cc: John Youn, stable

Fix a couple of issues with setting the gadget's speed for DWC_usb32 IP. We
should not notice this issue with other IPs.


Thinh Nguyen (2):
  usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate
  usb: dwc3: gadget: Use max speed if unspecified

 drivers/usb/dwc3/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


base-commit: 7f6f181b3e2c4d08f5d693eebe7901a28fab8666
-- 
2.28.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate
  2021-03-09  2:16 [PATCH 0/2] usb: dwc3: gadget: Fix ssp speed setting Thinh Nguyen
@ 2021-03-09  2:16 ` Thinh Nguyen
  2021-03-09  2:16 ` [PATCH 2/2] usb: dwc3: gadget: Use max speed if unspecified Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2021-03-09  2:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh.Nguyen, linux-usb
  Cc: John Youn, stable

Set the dwc->gadget_max_speed to SuperSpeed Plus if the user sets the
ssp_rate. The udc_set_ssp_rate() is intended for setting the gadget's
speed to SuperSpeed Plus at the specified rate.

Cc: <stable@vger.kernel.org>
Fixes: 072cab8a0fe2 ("usb: dwc3: gadget: Implement setting of SSP rate")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index aebcf8ec0716..53696c4bed0a 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2523,6 +2523,7 @@ static void dwc3_gadget_set_ssp_rate(struct usb_gadget *g,
 	unsigned long		flags;
 
 	spin_lock_irqsave(&dwc->lock, flags);
+	dwc->gadget_max_speed = USB_SPEED_SUPER_PLUS;
 	dwc->gadget_ssp_rate = rate;
 	spin_unlock_irqrestore(&dwc->lock, flags);
 }
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] usb: dwc3: gadget: Use max speed if unspecified
  2021-03-09  2:16 [PATCH 0/2] usb: dwc3: gadget: Fix ssp speed setting Thinh Nguyen
  2021-03-09  2:16 ` [PATCH 1/2] usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate Thinh Nguyen
@ 2021-03-09  2:16 ` Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2021-03-09  2:16 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh.Nguyen, linux-usb
  Cc: John Youn, stable

If the gadget driver doesn't specify a max_speed, then use the
controller's maximum supported speed as default. For DWC_usb32 IP, the
gadget's speed maybe limited to gen2x1 rate only if the driver's
max_speed is unknown. This scenario should not occur with the current
implementation since the default gadget driver's max_speed should always
be specified. However, to make the driver more robust and help with
readability, let's cover all the scenarios in __dwc3_gadget_set_speed().

Cc: <stable@vger.kernel.org>
Fixes: 450b9e9fabd8 ("usb: dwc3: gadget: Set speed only up to the max supported")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 53696c4bed0a..a04a9757f541 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2083,7 +2083,7 @@ static void __dwc3_gadget_set_speed(struct dwc3 *dwc)
 	u32			reg;
 
 	speed = dwc->gadget_max_speed;
-	if (speed > dwc->maximum_speed)
+	if (speed == USB_SPEED_UNKNOWN || speed > dwc->maximum_speed)
 		speed = dwc->maximum_speed;
 
 	if (speed == USB_SPEED_SUPER_PLUS &&
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-09  2:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09  2:16 [PATCH 0/2] usb: dwc3: gadget: Fix ssp speed setting Thinh Nguyen
2021-03-09  2:16 ` [PATCH 1/2] usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate Thinh Nguyen
2021-03-09  2:16 ` [PATCH 2/2] usb: dwc3: gadget: Use max speed if unspecified Thinh Nguyen

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).