diff mbox series

[SRU,I/Unstable/OEM-5.13,5/7] thunderbolt: Handle ring interrupt by reading interrupt status register

Message ID 20210825052335.53234-6-kai.heng.feng@canonical.com
State New
Headers show
Series Add USB4 support for AMD SoC | expand

Commit Message

Kai-Heng Feng Aug. 25, 2021, 5:23 a.m. UTC
From: Sanjay R Mehta <sanju.mehta@amd.com>

BugLink: https://bugs.launchpad.net/bugs/1941036

As per USB4 specification by default "Disable ISR Auto-Clear" bit is set
to zero and the Tx/Rx ring interrupt status needs to be cleared.

Hence handle it by reading the interrupt status register (ISR) in the
MSI-X handler.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
(cherry picked from commit 7a1808f82a37d638ee6862175e8e5c5433fdd642 linux-next)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/thunderbolt/nhi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index c044a64420752..98aac1cd328ce 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -383,11 +383,24 @@  void tb_ring_poll_complete(struct tb_ring *ring)
 }
 EXPORT_SYMBOL_GPL(tb_ring_poll_complete);
 
+static void ring_clear_msix(const struct tb_ring *ring)
+{
+	if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT)
+		return;
+
+	if (ring->is_tx)
+		ioread32(ring->nhi->iobase + REG_RING_NOTIFY_BASE);
+	else
+		ioread32(ring->nhi->iobase + REG_RING_NOTIFY_BASE +
+			 4 * (ring->nhi->hop_count / 32));
+}
+
 static irqreturn_t ring_msix(int irq, void *data)
 {
 	struct tb_ring *ring = data;
 
 	spin_lock(&ring->nhi->lock);
+	ring_clear_msix(ring);
 	spin_lock(&ring->lock);
 	__ring_interrupt(ring);
 	spin_unlock(&ring->lock);