Skip to content

Commit e01d05b

Browse files
zhanghui31martinkpetersen
authored andcommitted
scsi: ufs: core: Fix ufshcd_inc_sq_tail() function bug
When qdepth is not power of 2, not every bit of the mask is 1, so in sq_tail_slot some bits will be cleared unexpectedly. Signed-off-by: zhanghui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7255403 commit e01d05b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/ufs/core/ufshcd-priv.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,11 @@ static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, u8
369369
static inline void ufshcd_inc_sq_tail(struct ufs_hw_queue *q)
370370
__must_hold(&q->sq_lock)
371371
{
372-
u32 mask = q->max_entries - 1;
373372
u32 val;
374373

375-
q->sq_tail_slot = (q->sq_tail_slot + 1) & mask;
374+
q->sq_tail_slot++;
375+
if (q->sq_tail_slot == q->max_entries)
376+
q->sq_tail_slot = 0;
376377
val = q->sq_tail_slot * sizeof(struct utp_transfer_req_desc);
377378
writel(val, q->mcq_sq_tail);
378379
}

0 commit comments

Comments
 (0)