* [PATCH 0/2] usb: dwc3: gadget: Fix fullspeed interval setting
@ 2021-02-08 21:53 Thinh Nguyen
2021-02-08 21:53 ` [PATCH 1/2] usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Thinh Nguyen
2021-02-08 21:53 ` [PATCH 2/2] usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt Thinh Nguyen
0 siblings, 2 replies; 3+ messages in thread
From: Thinh Nguyen @ 2021-02-08 21:53 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Thinh.Nguyen, linux-usb
Cc: John Youn, stable
The dwc3 driver did not account for operating in fullspeed when setting
DEPCFG.bInterval_m1. This series fixes it.
Note that for some bInterval, some IP versions may not exhibit invalid behavior
from the invalid DEPCFG.bInterval_m1 setting, which may mask this issue.
Thinh Nguyen (2):
usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1
usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt
drivers/usb/dwc3/gadget.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
base-commit: d8c849037d9398abe6a5f5d065eafc777eb3bdaf
--
2.28.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1
2021-02-08 21:53 [PATCH 0/2] usb: dwc3: gadget: Fix fullspeed interval setting Thinh Nguyen
@ 2021-02-08 21:53 ` Thinh Nguyen
2021-02-08 21:53 ` [PATCH 2/2] usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt Thinh Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2021-02-08 21:53 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Thinh.Nguyen, linux-usb
Cc: John Youn, stable
Valid range for DEPCFG.bInterval_m1 is from 0 to 13, and it must be set
to 0 when the controller operates in full-speed. See the programming
guide for DEPCFG command section 3.2.2.1 (v3.30a).
Cc: <stable@vger.kernel.org>
Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
drivers/usb/dwc3/gadget.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 97d707b4f384..d0f8d3ec855f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -605,7 +605,17 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action)
params.param0 |= DWC3_DEPCFG_FIFO_NUMBER(dep->number >> 1);
if (desc->bInterval) {
- params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(desc->bInterval - 1);
+ u8 bInterval_m1;
+
+ /*
+ * Valid range for DEPCFG.bInterval_m1 is from 0 to 13, and it
+ * must be set to 0 when the controller operates in full-speed.
+ */
+ bInterval_m1 = min_t(u8, desc->bInterval - 1, 13);
+ if (dwc->gadget->speed == USB_SPEED_FULL)
+ bInterval_m1 = 0;
+
+ params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(bInterval_m1);
dep->interval = 1 << (desc->bInterval - 1);
}
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt
2021-02-08 21:53 [PATCH 0/2] usb: dwc3: gadget: Fix fullspeed interval setting Thinh Nguyen
2021-02-08 21:53 ` [PATCH 1/2] usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Thinh Nguyen
@ 2021-02-08 21:53 ` Thinh Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2021-02-08 21:53 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Thinh.Nguyen, linux-usb
Cc: John Youn, stable
The dep->interval captures the number of frames/microframes per interval
from bInterval. Fullspeed interrupt endpoint bInterval is the number of
frames per interval and not 2^(bInterval - 1). So fix it here. This
change is only for debugging purpose and should not affect the interrupt
endpoint operation.
Cc: <stable@vger.kernel.org>
Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
drivers/usb/dwc3/gadget.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d0f8d3ec855f..aebcf8ec0716 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -615,8 +615,13 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action)
if (dwc->gadget->speed == USB_SPEED_FULL)
bInterval_m1 = 0;
+ if (usb_endpoint_type(desc) == USB_ENDPOINT_XFER_INT &&
+ dwc->gadget->speed == USB_SPEED_FULL)
+ dep->interval = desc->bInterval;
+ else
+ dep->interval = 1 << (desc->bInterval - 1);
+
params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(bInterval_m1);
- dep->interval = 1 << (desc->bInterval - 1);
}
return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, ¶ms);
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-08 21:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 21:53 [PATCH 0/2] usb: dwc3: gadget: Fix fullspeed interval setting Thinh Nguyen
2021-02-08 21:53 ` [PATCH 1/2] usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Thinh Nguyen
2021-02-08 21:53 ` [PATCH 2/2] usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt 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).