git: 7858a57baa2f - main - thunderbolt: Explicitly read NHI ISR0 register to clear it

From: Aymeric Wibo <obiwac_at_FreeBSD.org>
Date: Thu, 13 Aug 2026 05:51:06 UTC
The branch main has been updated by obiwac:

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

commit 7858a57baa2f2efc4cfbd61303efb7e72ec43194
Author:     Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2026-08-12 17:40:56 +0000
Commit:     Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2026-08-13 05:46:14 +0000

    thunderbolt: Explicitly read NHI ISR0 register to clear it
    
    This fixes and issue where Pink Sardine controllers were not receiving
    interrupts for more than the first command sent on the ring.
    
    Reviewed by:    emaste, imp
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D52862
---
 sys/dev/thunderbolt/nhi.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sys/dev/thunderbolt/nhi.c b/sys/dev/thunderbolt/nhi.c
index 75eb4fe6a5d9..22427cf324fb 100644
--- a/sys/dev/thunderbolt/nhi.c
+++ b/sys/dev/thunderbolt/nhi.c
@@ -26,6 +26,12 @@
  * SUCH DAMAGE.
  */
 
+/*
+ * Spec references are to the Universal Serial Bus 4 (USB4®) Specification
+ * version 2.0, September 2024:
+ * https://usb.org/document-library/usb4r-specification-v20
+ */
+
 #include "opt_thunderbolt.h"
 
 /* PCIe interface for Thunderbolt Native Host Interface (nhi) */
@@ -1090,6 +1096,16 @@ nhi_intr(void *data)
 	if ((r = trkr->ring) == NULL)
 		return;
 
+	/*
+	 * Need to read this necessarily to clear it; see 12.6.3.4.1.  Disable
+	 * ISR Auto-Clear must be set to 0.
+	 *
+	 * XXX This might not be necessary on all platforms.  It is on Pink
+	 * Sardine, but this was not being done previously so it might have
+	 * been working without this on whatever scottl@ was testing on.
+	 */
+	nhi_read_reg(sc, NHI_ISR0);
+
 	/*
 	 * Process TX completions from the adapter.  Only go through
 	 * the ring once to prevent unbounded looping.