[PATCH 2/4] scsi: ufs: core: Make use of guard(spinlock)
From: Avri Altman
Date: Tue Apr 16 2024 - 06:24:44 EST
Replace open-coded handling with cleanup.h guard(spinlock) and
scoped_guard(spinlock, ...).
Signed-off-by: Avri Altman <avri.altman@xxxxxxx>
---
drivers/ufs/core/ufshcd.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 6e35b597dfb5..92ac6a358365 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -132,6 +132,7 @@ MODULE_PARM_DESC(use_mcq_mode, "Control MCQ mode for controllers starting from U
} while (0)
#define SERIALIZE_HOST_IRQSAVE(hba) guard(spinlock_irqsave)(hba->host->host_lock)
+#define SERIALIZE_HOST(hba) guard(spinlock)(hba->host->host_lock)
int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
const char *prefix)
@@ -2291,11 +2292,11 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag,
struct utp_transfer_req_desc *src = lrbp->utr_descriptor_ptr;
struct utp_transfer_req_desc *dest;
- spin_lock(&hwq->sq_lock);
- dest = hwq->sqe_base_addr + hwq->sq_tail_slot;
- memcpy(dest, src, utrd_size);
- ufshcd_inc_sq_tail(hwq);
- spin_unlock(&hwq->sq_lock);
+ scoped_guard(spinlock, &hwq->sq_lock) {
+ dest = hwq->sqe_base_addr + hwq->sq_tail_slot;
+ memcpy(dest, src, utrd_size);
+ ufshcd_inc_sq_tail(hwq);
+ }
} else {
scoped_guard(spinlock_irqsave, &hba->outstanding_lock) {
if (hba->vops && hba->vops->setup_xfer_req)
@@ -5446,7 +5447,8 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
{
irqreturn_t retval = IRQ_NONE;
- spin_lock(hba->host->host_lock);
+ SERIALIZE_HOST(hba);
+
if (ufshcd_is_auto_hibern8_error(hba, intr_status))
hba->errors |= (UFSHCD_UIC_HIBERN8_MASK & intr_status);
@@ -5470,7 +5472,6 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
if (retval == IRQ_HANDLED)
ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
UFS_CMD_COMP);
- spin_unlock(hba->host->host_lock);
return retval;
}
@@ -6786,7 +6787,8 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status)
bool queue_eh_work = false;
irqreturn_t retval = IRQ_NONE;
- spin_lock(hba->host->host_lock);
+ SERIALIZE_HOST(hba);
+
hba->errors |= UFSHCD_ERROR_MASK & intr_status;
if (hba->errors & INT_FATAL_ERRORS) {
@@ -6845,7 +6847,7 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status)
*/
hba->errors = 0;
hba->uic_error = 0;
- spin_unlock(hba->host->host_lock);
+
return retval;
}
--
2.42.0