Skip to content

Commit 2b314e1

Browse files
avri-altman-sndkmartinkpetersen
authored andcommitted
scsi: ufs: core: Remove redundant host_lock calls around UTMRLDBR
There is no need to serialize single read/write calls to the host controller registers. Remove the redundant host_lock calls that protect access to the task management doorbell register: UTMRLDBR. Signed-off-by: Avri Altman <avri.altman@wdc.com> Link: https://lore.kernel.org/r/20241024075033.562562-2-avri.altman@wdc.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 2c73fb1 commit 2b314e1

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

drivers/ufs/core/ufshcd.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,11 +1233,13 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
12331233
static u32 ufshcd_pending_cmds(struct ufs_hba *hba)
12341234
{
12351235
const struct scsi_device *sdev;
1236+
unsigned long flags;
12361237
u32 pending = 0;
12371238

1238-
lockdep_assert_held(hba->host->host_lock);
1239+
spin_lock_irqsave(hba->host->host_lock, flags);
12391240
__shost_for_each_device(sdev, hba->host)
12401241
pending += sbitmap_weight(&sdev->budget_map);
1242+
spin_unlock_irqrestore(hba->host->host_lock, flags);
12411243

12421244
return pending;
12431245
}
@@ -1251,15 +1253,13 @@ static u32 ufshcd_pending_cmds(struct ufs_hba *hba)
12511253
static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba,
12521254
u64 wait_timeout_us)
12531255
{
1254-
unsigned long flags;
12551256
int ret = 0;
12561257
u32 tm_doorbell;
12571258
u32 tr_pending;
12581259
bool timeout = false, do_last_check = false;
12591260
ktime_t start;
12601261

12611262
ufshcd_hold(hba);
1262-
spin_lock_irqsave(hba->host->host_lock, flags);
12631263
/*
12641264
* Wait for all the outstanding tasks/transfer requests.
12651265
* Verify by checking the doorbell registers are clear.
@@ -1280,7 +1280,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba,
12801280
break;
12811281
}
12821282

1283-
spin_unlock_irqrestore(hba->host->host_lock, flags);
12841283
io_schedule_timeout(msecs_to_jiffies(20));
12851284
if (ktime_to_us(ktime_sub(ktime_get(), start)) >
12861285
wait_timeout_us) {
@@ -1292,7 +1291,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba,
12921291
*/
12931292
do_last_check = true;
12941293
}
1295-
spin_lock_irqsave(hba->host->host_lock, flags);
12961294
} while (tm_doorbell || tr_pending);
12971295

12981296
if (timeout) {
@@ -1302,7 +1300,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba,
13021300
ret = -EBUSY;
13031301
}
13041302
out:
1305-
spin_unlock_irqrestore(hba->host->host_lock, flags);
13061303
ufshcd_release(hba);
13071304
return ret;
13081305
}
@@ -7048,12 +7045,13 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
70487045
memcpy(hba->utmrdl_base_addr + task_tag, treq, sizeof(*treq));
70497046
ufshcd_vops_setup_task_mgmt(hba, task_tag, tm_function);
70507047

7051-
/* send command to the controller */
70527048
__set_bit(task_tag, &hba->outstanding_tasks);
7053-
ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL);
70547049

70557050
spin_unlock_irqrestore(host->host_lock, flags);
70567051

7052+
/* send command to the controller */
7053+
ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL);
7054+
70577055
ufshcd_add_tm_upiu_trace(hba, task_tag, UFS_TM_SEND);
70587056

70597057
/* wait until the task management command is completed */

0 commit comments

Comments
 (0)