Re: [PATCH V1] ufs: core: Fix interrupt handling for MCQ Mode in ufshcd_intr

From: Nitin Rawat
Date: Tue Jul 29 2025 - 10:39:43 EST




On 7/29/2025 5:11 AM, Bart Van Assche wrote:
On 7/28/25 3:57 PM, Nitin Rawat wrote:
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index fd8015ed36a4..5413464d63c8 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7145,14 +7145,19 @@ static irqreturn_t ufshcd_threaded_intr(int irq, void *__hba)
  static irqreturn_t ufshcd_intr(int irq, void *__hba)
  {
      struct ufs_hba *hba = __hba;
+    u32 intr_status, enabled_intr_status;

      /* Move interrupt handling to thread when MCQ & ESI are not enabled */
      if (!hba->mcq_enabled || !hba->mcq_esi_enabled)
          return IRQ_WAKE_THREAD;

+    intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
+    enabled_intr_status = intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+
+    ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS);
+
      /* Directly handle interrupts since MCQ ESI handlers does the hard job */
-    return ufshcd_sl_intr(hba, ufshcd_readl(hba, REG_INTERRUPT_STATUS) &
-                   ufshcd_readl(hba, REG_INTERRUPT_ENABLE));
+    return ufshcd_sl_intr(hba, enabled_intr_status);
  }

Hi Nitin,

Thank you for having published this patch. It seems like we both have been working on a fix independently and without knowing about each other's efforts. Can you please take a look at this patch and let me
know which version you prefer?

Hi Bart,

I reviewed your patch and test it locally—it resolves the issue.

The patch looks good. Since this path handles only UIC, TM, and error conditions with no IO for MCQ, we still check for outstanding_reqs and UTP_TRANSFER_REQ_COMPL for the error case within ufshcd_threaded_intr in the patch. In my opinion, we can skip these additional checks.

Thanks,
Nitin


https://lore.kernel.org/linux-scsi/20250728212731.899429-1- bvanassche@xxxxxxx/

Thanks,

Bart.