Skip to content

Commit 4984eb5

Browse files
shirazsaleemrleon
authored andcommitted
RDMA/irdma: Add missing read barriers
On code inspection, there are many instances in the driver where CEQE and AEQE fields written to by HW are read without guaranteeing that the polarity bit has been read and checked first. Add a read barrier to avoid reordering of loads on the CEQE/AEQE fields prior to checking the polarity bit. Fixes: 3f49d68 ("RDMA/irdma: Implement HW Admin Queue OPs") Signed-off-by: Shiraz Saleem <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent d64b1ee commit 4984eb5

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

drivers/infiniband/hw/irdma/ctrl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3363,6 +3363,9 @@ int irdma_sc_ccq_get_cqe_info(struct irdma_sc_cq *ccq,
33633363
if (polarity != ccq->cq_uk.polarity)
33643364
return -ENOENT;
33653365

3366+
/* Ensure CEQE contents are read after valid bit is checked */
3367+
dma_rmb();
3368+
33663369
get_64bit_val(cqe, 8, &qp_ctx);
33673370
cqp = (struct irdma_sc_cqp *)(unsigned long)qp_ctx;
33683371
info->error = (bool)FIELD_GET(IRDMA_CQ_ERROR, temp);
@@ -4009,13 +4012,17 @@ int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq,
40094012
u8 polarity;
40104013

40114014
aeqe = IRDMA_GET_CURRENT_AEQ_ELEM(aeq);
4012-
get_64bit_val(aeqe, 0, &compl_ctx);
40134015
get_64bit_val(aeqe, 8, &temp);
40144016
polarity = (u8)FIELD_GET(IRDMA_AEQE_VALID, temp);
40154017

40164018
if (aeq->polarity != polarity)
40174019
return -ENOENT;
40184020

4021+
/* Ensure AEQE contents are read after valid bit is checked */
4022+
dma_rmb();
4023+
4024+
get_64bit_val(aeqe, 0, &compl_ctx);
4025+
40194026
print_hex_dump_debug("WQE: AEQ_ENTRY WQE", DUMP_PREFIX_OFFSET, 16, 8,
40204027
aeqe, 16, false);
40214028

drivers/infiniband/hw/irdma/puda.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ static int irdma_puda_poll_info(struct irdma_sc_cq *cq,
230230
if (valid_bit != cq_uk->polarity)
231231
return -ENOENT;
232232

233+
/* Ensure CQE contents are read after valid bit is checked */
234+
dma_rmb();
235+
233236
if (cq->dev->hw_attrs.uk_attrs.hw_rev >= IRDMA_GEN_2)
234237
ext_valid = (bool)FIELD_GET(IRDMA_CQ_EXTCQE, qword3);
235238

@@ -243,6 +246,9 @@ static int irdma_puda_poll_info(struct irdma_sc_cq *cq,
243246
if (polarity != cq_uk->polarity)
244247
return -ENOENT;
245248

249+
/* Ensure ext CQE contents are read after ext valid bit is checked */
250+
dma_rmb();
251+
246252
IRDMA_RING_MOVE_HEAD_NOCHECK(cq_uk->cq_ring);
247253
if (!IRDMA_RING_CURRENT_HEAD(cq_uk->cq_ring))
248254
cq_uk->polarity = !cq_uk->polarity;

drivers/infiniband/hw/irdma/uk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,9 @@ void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq)
15271527
if (polarity != temp)
15281528
break;
15291529

1530+
/* Ensure CQE contents are read after valid bit is checked */
1531+
dma_rmb();
1532+
15301533
get_64bit_val(cqe, 8, &comp_ctx);
15311534
if ((void *)(unsigned long)comp_ctx == q)
15321535
set_64bit_val(cqe, 8, 0);

0 commit comments

Comments
 (0)