]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: ufs: core: Do not write interrupt enable register unnecessarily
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 23 Jul 2025 16:58:55 +0000 (19:58 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Jul 2025 02:37:30 +0000 (22:37 -0400)
Write a new value to the interrupt enable register only if it is
different from the old value, thereby saving a register write operation.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20250723165856.145750-8-adrian.hunter@intel.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c

index 54082af7f65ebd36949b4528ef544caa7af60790..fa1fdba372677722061f0aad2979b5ce846ff009 100644 (file)
@@ -371,10 +371,11 @@ EXPORT_SYMBOL_GPL(ufshcd_disable_irq);
  */
 static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs)
 {
-       u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+       u32 old_val = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+       u32 new_val = old_val | intrs;
 
-       set |= intrs;
-       ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+       if (new_val != old_val)
+               ufshcd_writel(hba, new_val, REG_INTERRUPT_ENABLE);
 }
 
 /**
@@ -384,10 +385,11 @@ static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs)
  */
 static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
 {
-       u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+       u32 old_val = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+       u32 new_val = old_val & ~intrs;
 
-       set &= ~intrs;
-       ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+       if (new_val != old_val)
+               ufshcd_writel(hba, new_val, REG_INTERRUPT_ENABLE);
 }
 
 static void ufshcd_configure_wb(struct ufs_hba *hba)