Skip to content

Commit d0c89af

Browse files
Bao D. Nguyenmartinkpetersen
Bao D. Nguyen
authored andcommitted
scsi: ufs: mcq: Fix the search/wrap around logic
The search and wrap around logic in the ufshcd_mcq_sqe_search() function does not work correctly when the hwq's queue depth is not a power of two number. Correct it so that any queue depth with a positive integer value within the supported range would work. Signed-off-by: "Bao D. Nguyen" <[email protected]> Link: https://lore.kernel.org/r/ff49c15be205135ed3ec186f3086694c02867dbd.1692149603.git.quic_nguyenb@quicinc.com Reviewed-by: Bart Van Assche <[email protected]> Fixes: 8d72903 ("scsi: ufs: mcq: Add supporting functions for MCQ abort") Signed-off-by: Martin K. Petersen <[email protected]>
1 parent ef222f5 commit d0c89af

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba,
580580
{
581581
struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
582582
struct utp_transfer_req_desc *utrd;
583-
u32 mask = hwq->max_entries - 1;
584583
__le64 cmd_desc_base_addr;
585584
bool ret = false;
586585
u64 addr, match;
@@ -608,7 +607,10 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba,
608607
ret = true;
609608
goto out;
610609
}
611-
sq_head_slot = (sq_head_slot + 1) & mask;
610+
611+
sq_head_slot++;
612+
if (sq_head_slot == hwq->max_entries)
613+
sq_head_slot = 0;
612614
}
613615

614616
out:

0 commit comments

Comments
 (0)