Skip to content

Commit 2fc3984

Browse files
minwooimmartinkpetersen
authored andcommitted
scsi: ufs: mcq: Fix missing argument 'hba' in MCQ_OPR_OFFSET_n
The MCQ_OPR_OFFSET_n macro takes 'hba' in the caller context without receiving 'hba' instance as an argument. To prevent potential bugs in future use cases, add an argument 'hba'. Fixes: 2468da6 ("scsi: ufs: core: mcq: Configure operation and runtime interface") Cc: Asutosh Das <[email protected]> Signed-off-by: Minwoo Im <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 23646f0 commit 2fc3984

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
231231

232232
/* Operation and runtime registers configuration */
233233
#define MCQ_CFG_n(r, i) ((r) + MCQ_QCFG_SIZE * (i))
234-
#define MCQ_OPR_OFFSET_n(p, i) \
235-
(hba->mcq_opr[(p)].offset + hba->mcq_opr[(p)].stride * (i))
236234

237235
static void __iomem *mcq_opr_base(struct ufs_hba *hba,
238236
enum ufshcd_mcq_opr n, int i)
@@ -343,10 +341,10 @@ void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba)
343341
ufsmcq_writelx(hba, upper_32_bits(hwq->sqe_dma_addr),
344342
MCQ_CFG_n(REG_SQUBA, i));
345343
/* Submission Queue Doorbell Address Offset */
346-
ufsmcq_writelx(hba, MCQ_OPR_OFFSET_n(OPR_SQD, i),
344+
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_SQD, i),
347345
MCQ_CFG_n(REG_SQDAO, i));
348346
/* Submission Queue Interrupt Status Address Offset */
349-
ufsmcq_writelx(hba, MCQ_OPR_OFFSET_n(OPR_SQIS, i),
347+
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_SQIS, i),
350348
MCQ_CFG_n(REG_SQISAO, i));
351349

352350
/* Completion Queue Lower Base Address */
@@ -356,10 +354,10 @@ void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba)
356354
ufsmcq_writelx(hba, upper_32_bits(hwq->cqe_dma_addr),
357355
MCQ_CFG_n(REG_CQUBA, i));
358356
/* Completion Queue Doorbell Address Offset */
359-
ufsmcq_writelx(hba, MCQ_OPR_OFFSET_n(OPR_CQD, i),
357+
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_CQD, i),
360358
MCQ_CFG_n(REG_CQDAO, i));
361359
/* Completion Queue Interrupt Status Address Offset */
362-
ufsmcq_writelx(hba, MCQ_OPR_OFFSET_n(OPR_CQIS, i),
360+
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_CQIS, i),
363361
MCQ_CFG_n(REG_CQISAO, i));
364362

365363
/* Save the base addresses for quicker access */

include/ufs/ufshcd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,12 @@ static inline bool is_mcq_enabled(struct ufs_hba *hba)
11351135
return hba->mcq_enabled;
11361136
}
11371137

1138+
static inline unsigned int ufshcd_mcq_opr_offset(struct ufs_hba *hba,
1139+
enum ufshcd_mcq_opr opr, int idx)
1140+
{
1141+
return hba->mcq_opr[opr].offset + hba->mcq_opr[opr].stride * idx;
1142+
}
1143+
11381144
#ifdef CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE
11391145
static inline size_t ufshcd_sg_entry_size(const struct ufs_hba *hba)
11401146
{

0 commit comments

Comments
 (0)