diff options
author | Bao D. Nguyen <quic_nguyenb@quicinc.com> | 2023-08-15 18:38:29 -0700 |
---|---|---|
committer | Todd Kjos <tkjos@google.com> | 2023-11-02 22:46:36 +0000 |
commit | 63514c035e7993f87b4a7b26d3cdbfd086bf8ca8 (patch) | |
tree | 971b20a256ea0e8774b25c83668fff52f4ad1410 | |
parent | 7365f11bc6333f4c2f320a030b3b5fc27dc07a2a (diff) | |
download | common-63514c035e7993f87b4a7b26d3cdbfd086bf8ca8.tar.gz |
UPSTREAM: 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.
Bug: 307782690
Bug: 308053135
Change-Id: I4350ac71da051db24923a587db435be2f7b7eebb
(cherry picked from commit d0c89af3130eb4ff962266bb7597690a696f1cbc)
Signed-off-by: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
Link: https://lore.kernel.org/r/ff49c15be205135ed3ec186f3086694c02867dbd.1692149603.git.quic_nguyenb@quicinc.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Fixes: 8d7290348992 ("scsi: ufs: mcq: Add supporting functions for MCQ abort")
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 2799026a2823e505ff230756c87ede4e68f37de1)
-rw-r--r-- | drivers/ufs/core/ufs-mcq.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 64bad535f79f..728a81e32394 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -593,7 +593,6 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba, { struct ufshcd_lrb *lrbp = &hba->lrb[task_tag]; struct utp_transfer_req_desc *utrd; - u32 mask = hwq->max_entries - 1; __le64 cmd_desc_base_addr; bool ret = false; u64 addr, match; @@ -621,7 +620,10 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba, ret = true; goto out; } - sq_head_slot = (sq_head_slot + 1) & mask; + + sq_head_slot++; + if (sq_head_slot == hwq->max_entries) + sq_head_slot = 0; } out: |