diff options
author | Sumit Saxena | 2021-09-29 18:10:21 +0530 |
---|---|---|
committer | Martin K. Petersen | 2021-10-04 23:20:09 -0400 |
commit | 4c32edc350e4bebd93db1d63f506f4f343e23bd1 (patch) | |
tree | 8954db27972edc34f2b2472781cf8d00b2db1529 /drivers/scsi/megaraid | |
parent | e7dcc514a49e74051b869697d5ab0370f6301d57 (diff) |
scsi: megaraid_sas: Add helper functions for irq_context
Adding helper functions for ISR access and release to improve readability.
Link: https://lore.kernel.org/r/20210929124022.24605-3-sumit.saxena@broadcom.com
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/megaraid')
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_fusion.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index eb5ceb75a15e..109782e3ec44 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -3498,6 +3498,41 @@ megasas_complete_r1_command(struct megasas_instance *instance, } /** + * access_irq_context: Access to reply processing + * @irq_context: IRQ context + * + * Synchronize access to reply processing. + * + * Return: true on success, false on failure. + */ +static inline +bool access_irq_context(struct megasas_irq_context *irq_context) +{ + if (!irq_context) + return true; + + if (atomic_add_unless(&irq_context->in_used, 1, 1)) + return true; + + return false; +} + +/** + * release_irq_context: Release reply processing + * @irq_context: IRQ context + * + * Release access of reply processing. + * + * Return: Nothing. + */ +static inline +void release_irq_context(struct megasas_irq_context *irq_context) +{ + if (irq_context) + atomic_dec(&irq_context->in_used); +} + +/** * complete_cmd_fusion - Completes command * @instance: Adapter soft state * @MSIxIndex: MSI number @@ -3530,7 +3565,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) return IRQ_HANDLED; - if (irq_context && !atomic_add_unless(&irq_context->in_used, 1, 1)) + if (!access_irq_context(irq_context)) return 0; desc = fusion->reply_frames_desc[MSIxIndex] + @@ -3544,8 +3579,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) { - if (irq_context) - atomic_dec(&irq_context->in_used); + release_irq_context(irq_context); return IRQ_NONE; } @@ -3663,7 +3697,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, irq_context->irq_line_enable = true; irq_poll_sched(&irq_context->irqpoll); } - atomic_dec(&irq_context->in_used); + release_irq_context(irq_context); return num_completed; } } @@ -3682,8 +3716,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, megasas_check_and_restore_queue_depth(instance); } - if (irq_context) - atomic_dec(&irq_context->in_used); + release_irq_context(irq_context); return num_completed; } |