Linux Kernels

usb: dwc2: host: reset frame number after suspend

This change “usb: dwc2: host: reset frame number after suspend” (commit 08c4ffc) in Linux kernel is authored by Gregory Herrero <gregory.herrero [at] intel.com> on Tue Sep 22 15:16:45 2015 +0200.

Description of "usb: dwc2: host: reset frame number after suspend"

The change “usb: dwc2: host: reset frame number after suspend” introduces changes as follows.

usb: dwc2: host: reset frame number after suspend

Frame number is reset in hardware after exiting hibernation.
Thus, reset frame_number and ensure qh are queued with correct
sched_frame.

Otherwise, qh->sched_frame may be too high compared to
current frame number (which is 0). This can delay addition of qh in
the list of transfers until frame number reaches qh->sched_frame.

Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

Linux kernel releases containing commit 08c4ffc

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "usb: dwc2: host: reset frame number after suspend"

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/usb/dwc2/core.c      | 1 +
 drivers/usb/dwc2/hcd_queue.c | 8 ++++++++
 2 files changed, 9 insertions(+)
 
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 0bfc987dd373..f5c3120f4879 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -116,6 +116,7 @@ static int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
 
 	dwc2_writel(hr->hprt0, hsotg->regs + HPRT0);
 	dwc2_writel(hr->hfir, hsotg->regs + HFIR);
+	hsotg->frame_number = 0;
 
 	return 0;
 }
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index 712977fd67d1..801bd9d9c4bd 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -583,6 +583,14 @@ int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
 		/* QH already in a schedule */
 		return 0;
 
+	if (!dwc2_frame_num_le(qh->sched_frame, hsotg->frame_number) &&
+			!hsotg->frame_number) {
+		dev_dbg(hsotg->dev,
+				"reset frame number counter\n");
+		qh->sched_frame = dwc2_frame_num_inc(hsotg->frame_number,
+				SCHEDULE_SLOP);
+	}
+
 	/* Add the new QH to the appropriate schedule */
 	if (dwc2_qh_is_non_per(qh)) {
 		/* Always start in inactive schedule */

The commit for this change in Linux stable tree is 08c4ffc (patch).

Last modified: 2020/01/11 09:26