Commit e01d05bb authored by zhanghui's avatar zhanghui Committed by Martin K. Petersen

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: default avatarzhanghui <zhanghui31@xiaomi.com>
Link: https://lore.kernel.org/r/20230601124613.1446-1-zhanghui31@xiaomi.comReviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 72554035
...@@ -369,10 +369,11 @@ static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, u8 ...@@ -369,10 +369,11 @@ static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, u8
static inline void ufshcd_inc_sq_tail(struct ufs_hw_queue *q) static inline void ufshcd_inc_sq_tail(struct ufs_hw_queue *q)
__must_hold(&q->sq_lock) __must_hold(&q->sq_lock)
{ {
u32 mask = q->max_entries - 1;
u32 val; u32 val;
q->sq_tail_slot = (q->sq_tail_slot + 1) & mask; q->sq_tail_slot++;
if (q->sq_tail_slot == q->max_entries)
q->sq_tail_slot = 0;
val = q->sq_tail_slot * sizeof(struct utp_transfer_req_desc); val = q->sq_tail_slot * sizeof(struct utp_transfer_req_desc);
writel(val, q->mcq_sq_tail); writel(val, q->mcq_sq_tail);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment