linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sanjay R Mehta <Sanju.Mehta@amd.com>
To: <mika.westerberg@linux.intel.com>, <andreas.noever@gmail.com>,
	<michael.jamet@intel.com>, <YehezkelShB@gmail.com>
Cc: <Basavaraj.Natikar@amd.com>, <linux-usb@vger.kernel.org>,
	Sanjay R Mehta <sanju.mehta@amd.com>
Subject: [PATCH v2 1/4] thunderbolt: Intel controller uses BIT(2) for intr auto
Date: Tue, 3 Aug 2021 07:34:53 -0500	[thread overview]
Message-ID: <1627994096-99972-2-git-send-email-Sanju.Mehta@amd.com> (raw)
In-Reply-To: <1627994096-99972-1-git-send-email-Sanju.Mehta@amd.com>

From: Sanjay R Mehta <sanju.mehta@amd.com>

REG_DMA_MISC_INT_AUTO_CLEAR which is bit 2 in that register is
actually Intel specific.

As per the USB4 spec bit 17 is used for interrupt auto clear and
by default its enabled.

Hence limit usage of REG_DMA_MISC_INT_AUTO_CLEAR for Intel controllers
and moved this to quirk.

Fixes: 046bee1f9ab8 ("thunderbolt: Add MSI-X support")
Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
---
 drivers/thunderbolt/nhi.c    |  8 ++------
 drivers/thunderbolt/quirks.c | 14 ++++++++++++++
 drivers/thunderbolt/tb.h     |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index fa44332..ef01aa6 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -57,8 +57,8 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
 	u32 old, new;
 
 	if (ring->irq > 0) {
-		u32 step, shift, ivr, misc;
 		void __iomem *ivr_base;
+		u32 step, shift, ivr;
 		int index;
 
 		if (ring->is_tx)
@@ -70,11 +70,7 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
 		 * Ask the hardware to clear interrupt status bits automatically
 		 * since we already know which interrupt was triggered.
 		 */
-		misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
-		if (!(misc & REG_DMA_MISC_INT_AUTO_CLEAR)) {
-			misc |= REG_DMA_MISC_INT_AUTO_CLEAR;
-			iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
-		}
+		quirk_enable_intr_auto_clr(ring);
 
 		ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
 		step = index / REG_INT_VEC_ALLOC_REGS * REG_INT_VEC_ALLOC_BITS;
diff --git a/drivers/thunderbolt/quirks.c b/drivers/thunderbolt/quirks.c
index b5f2ec7..af6dab9 100644
--- a/drivers/thunderbolt/quirks.c
+++ b/drivers/thunderbolt/quirks.c
@@ -6,6 +6,7 @@
  */
 
 #include "tb.h"
+#include "nhi_regs.h"
 
 static void quirk_force_power_link(struct tb_switch *sw)
 {
@@ -64,3 +65,16 @@ void tb_check_quirks(struct tb_switch *sw)
 		q->hook(sw);
 	}
 }
+
+void quirk_enable_intr_auto_clr(struct tb_ring *ring)
+{
+	u32 misc;
+
+	if (ring->nhi->pdev->vendor == PCI_VENDOR_ID_INTEL) {
+		misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
+		if (!(misc & REG_DMA_MISC_INT_AUTO_CLEAR)) {
+			misc |= REG_DMA_MISC_INT_AUTO_CLEAR;
+			iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
+		}
+	}
+}
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 725104c..0b8f9d3 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -1122,6 +1122,7 @@ int usb4_port_device_resume(struct usb4_port *usb4);
 #define QUIRK_FORCE_POWER_LINK_CONTROLLER		BIT(0)
 
 void tb_check_quirks(struct tb_switch *sw);
+void quirk_enable_intr_auto_clr(struct tb_ring *ring);
 
 #ifdef CONFIG_ACPI
 void tb_acpi_add_links(struct tb_nhi *nhi);
-- 
2.7.4


  reply	other threads:[~2021-08-03 12:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 12:34 [PATCH v2 0/4] Added some bug fixes for USB4 Sanjay R Mehta
2021-08-03 12:34 ` Sanjay R Mehta [this message]
2021-08-03 12:34 ` [PATCH v2 2/4] thunderbolt: Handle ring interrupt by reading intr status Sanjay R Mehta
2021-08-04 15:48   ` Mika Westerberg
2021-08-05 12:56     ` Mika Westerberg
2021-08-05 13:06       ` Sanjay R Mehta
2021-08-05 14:20         ` Mika Westerberg
2021-08-05 12:59     ` Sanjay R Mehta
2021-08-05 14:19       ` Mika Westerberg
2021-08-05 14:46         ` Mika Westerberg
2021-08-05 18:03           ` Sanjay R Mehta
2021-08-03 12:34 ` [PATCH v2 3/4] thunderbolt: Skip port init for control adapter(0) Sanjay R Mehta
2021-08-03 12:34 ` [PATCH v2 4/4] thunderbolt: Fix port linking by checking all adapters Sanjay R Mehta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1627994096-99972-2-git-send-email-Sanju.Mehta@amd.com \
    --to=sanju.mehta@amd.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael.jamet@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).