|
|
e78766 |
From: Sumit Saxena <sumit.saxena@broadcom.com>
|
|
|
e78766 |
Date: Wed, 29 Sep 2021 18:10:21 +0530
|
|
|
e78766 |
Subject: scsi: megaraid_sas: Add helper functions for irq_context
|
|
|
e78766 |
Patch-mainline: v5.16-rc1
|
|
|
e78766 |
Git-commit: 4c32edc350e4bebd93db1d63f506f4f343e23bd1
|
|
|
e78766 |
References: jsc#SLE-19730
|
|
|
e78766 |
|
|
|
e78766 |
Adding helper functions for ISR access and release to improve readability.
|
|
|
e78766 |
|
|
|
e78766 |
Link: https://lore.kernel.org/r/20210929124022.24605-3-sumit.saxena@broadcom.com
|
|
|
e78766 |
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
|
|
|
e78766 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
|
e78766 |
Acked-by: Martin Wilck <mwilck@suse.com>
|
|
|
e78766 |
---
|
|
|
e78766 |
drivers/scsi/megaraid/megaraid_sas_fusion.c | 45 ++++++++++++++++++++++++----
|
|
|
e78766 |
1 file changed, 39 insertions(+), 6 deletions(-)
|
|
|
e78766 |
|
|
|
e78766 |
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
|
|
|
e78766 |
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
|
|
|
e78766 |
@@ -3498,6 +3498,41 @@ megasas_complete_r1_command(struct megas
|
|
|
e78766 |
}
|
|
|
e78766 |
|
|
|
e78766 |
/**
|
|
|
e78766 |
+ * access_irq_context: Access to reply processing
|
|
|
e78766 |
+ * @irq_context: IRQ context
|
|
|
e78766 |
+ *
|
|
|
e78766 |
+ * Synchronize access to reply processing.
|
|
|
e78766 |
+ *
|
|
|
e78766 |
+ * Return: true on success, false on failure.
|
|
|
e78766 |
+ */
|
|
|
e78766 |
+static inline
|
|
|
e78766 |
+bool access_irq_context(struct megasas_irq_context *irq_context)
|
|
|
e78766 |
+{
|
|
|
e78766 |
+ if (!irq_context)
|
|
|
e78766 |
+ return true;
|
|
|
e78766 |
+
|
|
|
e78766 |
+ if (atomic_add_unless(&irq_context->in_used, 1, 1))
|
|
|
e78766 |
+ return true;
|
|
|
e78766 |
+
|
|
|
e78766 |
+ return false;
|
|
|
e78766 |
+}
|
|
|
e78766 |
+
|
|
|
e78766 |
+/**
|
|
|
e78766 |
+ * release_irq_context: Release reply processing
|
|
|
e78766 |
+ * @irq_context: IRQ context
|
|
|
e78766 |
+ *
|
|
|
e78766 |
+ * Release access of reply processing.
|
|
|
e78766 |
+ *
|
|
|
e78766 |
+ * Return: Nothing.
|
|
|
e78766 |
+ */
|
|
|
e78766 |
+static inline
|
|
|
e78766 |
+void release_irq_context(struct megasas_irq_context *irq_context)
|
|
|
e78766 |
+{
|
|
|
e78766 |
+ if (irq_context)
|
|
|
e78766 |
+ atomic_dec(&irq_context->in_used);
|
|
|
e78766 |
+}
|
|
|
e78766 |
+
|
|
|
e78766 |
+/**
|
|
|
e78766 |
* complete_cmd_fusion - Completes command
|
|
|
e78766 |
* @instance: Adapter soft state
|
|
|
e78766 |
* @MSIxIndex: MSI number
|
|
|
e78766 |
@@ -3530,7 +3565,7 @@ complete_cmd_fusion(struct megasas_insta
|
|
|
e78766 |
if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
|
|
|
e78766 |
return IRQ_HANDLED;
|
|
|
e78766 |
|
|
|
e78766 |
- if (irq_context && !atomic_add_unless(&irq_context->in_used, 1, 1))
|
|
|
e78766 |
+ if (!access_irq_context(irq_context))
|
|
|
e78766 |
return 0;
|
|
|
e78766 |
|
|
|
e78766 |
desc = fusion->reply_frames_desc[MSIxIndex] +
|
|
|
e78766 |
@@ -3544,8 +3579,7 @@ complete_cmd_fusion(struct megasas_insta
|
|
|
e78766 |
MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
|
|
|
e78766 |
|
|
|
e78766 |
if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) {
|
|
|
e78766 |
- if (irq_context)
|
|
|
e78766 |
- atomic_dec(&irq_context->in_used);
|
|
|
e78766 |
+ release_irq_context(irq_context);
|
|
|
e78766 |
return IRQ_NONE;
|
|
|
e78766 |
}
|
|
|
e78766 |
|
|
|
e78766 |
@@ -3663,7 +3697,7 @@ complete_cmd_fusion(struct megasas_insta
|
|
|
e78766 |
irq_context->irq_line_enable = true;
|
|
|
e78766 |
irq_poll_sched(&irq_context->irqpoll);
|
|
|
e78766 |
}
|
|
|
e78766 |
- atomic_dec(&irq_context->in_used);
|
|
|
e78766 |
+ release_irq_context(irq_context);
|
|
|
e78766 |
return num_completed;
|
|
|
e78766 |
}
|
|
|
e78766 |
}
|
|
|
e78766 |
@@ -3682,8 +3716,7 @@ complete_cmd_fusion(struct megasas_insta
|
|
|
e78766 |
megasas_check_and_restore_queue_depth(instance);
|
|
|
e78766 |
}
|
|
|
e78766 |
|
|
|
e78766 |
- if (irq_context)
|
|
|
e78766 |
- atomic_dec(&irq_context->in_used);
|
|
|
e78766 |
+ release_irq_context(irq_context);
|
|
|
e78766 |
|
|
|
e78766 |
return num_completed;
|
|
|
e78766 |
}
|