git: cec0a5ec6b10 - main - dwc3: uncondinationally enable Host IN Auto Retry

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 03 Jul 2022 22:17:21 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=cec0a5ec6b1074d253a7ba30226d1f99e0c18d4e

commit cec0a5ec6b1074d253a7ba30226d1f99e0c18d4e
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-07-02 19:14:39 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-07-03 22:15:12 +0000

    dwc3: uncondinationally enable Host IN Auto Retry
    
    Enable dwc3's auto retry feature. For IN transfers with crc errors
    or internal overruns this will make the host reply with a
    non-terminating retry ACK.  I believe the hope was to improve
    reliability after seeing occasional hiccups.
    
    Obtained from:  an old debugging patch
    MFC after:      2 weeks
    Reviewed by:    mw
    Differential Revision: https://reviews.freebsd.org/D35698
---
 sys/dev/usb/controller/dwc3.c | 9 +++++++++
 sys/dev/usb/controller/dwc3.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/sys/dev/usb/controller/dwc3.c b/sys/dev/usb/controller/dwc3.c
index 1ab4862fb97c..ac94a1327bcf 100644
--- a/sys/dev/usb/controller/dwc3.c
+++ b/sys/dev/usb/controller/dwc3.c
@@ -209,6 +209,15 @@ snps_dwc3_configure_host(struct snps_dwc3_softc *sc)
 	reg &= ~DWC3_GCTL_PRTCAPDIR_MASK;
 	reg |= DWC3_GCTL_PRTCAPDIR_HOST;
 	DWC3_WRITE(sc, DWC3_GCTL, reg);
+
+	/*
+	 * Enable the Host IN Auto Retry feature, making the
+	 * host respond with a non-terminating retry ACK.
+	 * XXX If we ever support more than host mode this needs a dr_mode check.
+	 */
+	reg = DWC3_READ(sc, DWC3_GUCTL);
+	reg |= DWC3_GUCTL_HOST_AUTO_RETRY;
+	DWC3_WRITE(sc, DWC3_GUCTL, reg);
 }
 
 static void
diff --git a/sys/dev/usb/controller/dwc3.h b/sys/dev/usb/controller/dwc3.h
index a8b127cda9a8..862e17b1bcd9 100644
--- a/sys/dev/usb/controller/dwc3.h
+++ b/sys/dev/usb/controller/dwc3.h
@@ -54,6 +54,7 @@
 #define	DWC3_GGPIO		0xc124
 #define	DWC3_GUID		0xc128
 #define	DWC3_GUCTL		0xc12C
+#define	DWC3_GUCTL_HOST_AUTO_RETRY		(1 << 14)
 #define	DWC3_GBUSERRADDRLO	0xc130
 #define	DWC3_GBUSERRADDRHI	0xc134
 #define	DWC3_GPRTBIMAPLO	0xc138