aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSomnath Kotur <somnath.kotur@broadcom.com>2017-11-06 11:07:29 -0500
committerDoug Ledford <dledford@redhat.com>2017-11-13 15:53:57 -0500
commit9b40183c08e48f1d26d06d39f29808c9c6037561 (patch)
tree377a0f40b396d2b98a65ae0c2c7979527576b1bd
parent685894dd9bd03b92803fbc72565789713f067d4c (diff)
RDMA/bnxt_re: Add memory barriers when processing CQ/EQ entries
The code determines if the next ring entry is valid before proceeding further to read the rest of the entry. The CPU can re-order and read the rest of the entry first, possibly reading a stale entry, if DMA of a new entry happens right after reading it. Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com> Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/hw/bnxt_re/qplib_fp.c21
-rw-r--r--drivers/infiniband/hw/bnxt_re/qplib_rcfw.c4
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
index a82044dacce0..31ea9f43f7d3 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -292,6 +292,12 @@ static void bnxt_qplib_service_nq(unsigned long data)
292 if (!NQE_CMP_VALID(nqe, raw_cons, hwq->max_elements)) 292 if (!NQE_CMP_VALID(nqe, raw_cons, hwq->max_elements))
293 break; 293 break;
294 294
295 /*
296 * The valid test of the entry must be done first before
297 * reading any further.
298 */
299 dma_rmb();
300
295 type = le16_to_cpu(nqe->info10_type) & NQ_BASE_TYPE_MASK; 301 type = le16_to_cpu(nqe->info10_type) & NQ_BASE_TYPE_MASK;
296 switch (type) { 302 switch (type) {
297 case NQ_BASE_TYPE_CQ_NOTIFICATION: 303 case NQ_BASE_TYPE_CQ_NOTIFICATION:
@@ -1113,6 +1119,11 @@ static void __clean_cq(struct bnxt_qplib_cq *cq, u64 qp)
1113 hw_cqe = &hw_cqe_ptr[CQE_PG(i)][CQE_IDX(i)]; 1119 hw_cqe = &hw_cqe_ptr[CQE_PG(i)][CQE_IDX(i)];
1114 if (!CQE_CMP_VALID(hw_cqe, i, cq_hwq->max_elements)) 1120 if (!CQE_CMP_VALID(hw_cqe, i, cq_hwq->max_elements))
1115 continue; 1121 continue;
1122 /*
1123 * The valid test of the entry must be done first before
1124 * reading any further.
1125 */
1126 dma_rmb();
1116 switch (hw_cqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK) { 1127 switch (hw_cqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK) {
1117 case CQ_BASE_CQE_TYPE_REQ: 1128 case CQ_BASE_CQE_TYPE_REQ:
1118 case CQ_BASE_CQE_TYPE_TERMINAL: 1129 case CQ_BASE_CQE_TYPE_TERMINAL:
@@ -1896,6 +1907,11 @@ static int do_wa9060(struct bnxt_qplib_qp *qp, struct bnxt_qplib_cq *cq,
1896 /* If the next hwcqe is VALID */ 1907 /* If the next hwcqe is VALID */
1897 if (CQE_CMP_VALID(peek_hwcqe, peek_raw_cq_cons, 1908 if (CQE_CMP_VALID(peek_hwcqe, peek_raw_cq_cons,
1898 cq->hwq.max_elements)) { 1909 cq->hwq.max_elements)) {
1910 /*
1911 * The valid test of the entry must be done first before
1912 * reading any further.
1913 */
1914 dma_rmb();
1899 /* If the next hwcqe is a REQ */ 1915 /* If the next hwcqe is a REQ */
1900 if ((peek_hwcqe->cqe_type_toggle & 1916 if ((peek_hwcqe->cqe_type_toggle &
1901 CQ_BASE_CQE_TYPE_MASK) == 1917 CQ_BASE_CQE_TYPE_MASK) ==
@@ -2440,6 +2456,11 @@ int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
2440 if (!CQE_CMP_VALID(hw_cqe, raw_cons, cq->hwq.max_elements)) 2456 if (!CQE_CMP_VALID(hw_cqe, raw_cons, cq->hwq.max_elements))
2441 break; 2457 break;
2442 2458
2459 /*
2460 * The valid test of the entry must be done first before
2461 * reading any further.
2462 */
2463 dma_rmb();
2443 /* From the device's respective CQE format to qplib_wc*/ 2464 /* From the device's respective CQE format to qplib_wc*/
2444 switch (hw_cqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK) { 2465 switch (hw_cqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK) {
2445 case CQ_BASE_CQE_TYPE_REQ: 2466 case CQ_BASE_CQE_TYPE_REQ:
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
index a7b5de3e193c..bb5574adf195 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
@@ -359,6 +359,10 @@ static void bnxt_qplib_service_creq(unsigned long data)
359 creqe = &creq_ptr[get_creq_pg(sw_cons)][get_creq_idx(sw_cons)]; 359 creqe = &creq_ptr[get_creq_pg(sw_cons)][get_creq_idx(sw_cons)];
360 if (!CREQ_CMP_VALID(creqe, raw_cons, creq->max_elements)) 360 if (!CREQ_CMP_VALID(creqe, raw_cons, creq->max_elements))
361 break; 361 break;
362 /* The valid test of the entry must be done first before
363 * reading any further.
364 */
365 dma_rmb();
362 366
363 type = creqe->type & CREQ_BASE_TYPE_MASK; 367 type = creqe->type & CREQ_BASE_TYPE_MASK;
364 switch (type) { 368 switch (type) {