diff options
author | zhanghui <zhanghui31@xiaomi.com> | 2023-06-01 20:46:14 +0800 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2023-06-07 21:20:21 -0400 |
commit | e01d05bbf6348ccd9f5a057280310d78ea9e7b52 (patch) | |
tree | a9872b9eaad25181db50422ef7b36360687bb9fd /drivers/ufs/core/ufshcd-priv.h | |
parent | 72554035b9797e00e68cd866e6cefa7f0b2c6f76 (diff) | |
download | linux-stable-e01d05bbf6348ccd9f5a057280310d78ea9e7b52.tar.gz linux-stable-e01d05bbf6348ccd9f5a057280310d78ea9e7b52.tar.bz2 linux-stable-e01d05bbf6348ccd9f5a057280310d78ea9e7b52.zip |
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 <zhanghui31@xiaomi.com>
Link: https://lore.kernel.org/r/20230601124613.1446-1-zhanghui31@xiaomi.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/ufs/core/ufshcd-priv.h')
-rw-r--r-- | drivers/ufs/core/ufshcd-priv.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index f32c1a874dff..aa88e60ea1f6 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -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) __must_hold(&q->sq_lock) { - u32 mask = q->max_entries - 1; 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); writel(val, q->mcq_sq_tail); } |