Skip to contentSkip to conversation

RDMA/vmw_pvrdma: Report CQ missed events

PATCH In review Adit Ranadive 3 participants 5 messages Aug 10, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/vmw_pvrdma: Report CQ missed events

From: Bryan Tan <[email protected]>

There is a chance of a race between arming the CQ and receiving completions. By reporting CQ missed events any ULPs should poll again to get the completions.

Fixes 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +15 -0
index 69bda61..f4ab5fa 100644
@@ -65,12 +65,27 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
 	struct pvrdma_dev *dev = to_vdev(ibcq->device);
 	struct pvrdma_cq *cq = to_vcq(ibcq);
 	u32 val = cq->cq_handle;
+	unsigned long flags;
 
 	val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
 		PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
 
+	spin_lock_irqsave(&cq->cq_lock, flags);
+
 	pvrdma_write_uar_cq(dev, val);
 
+	if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+		unsigned int head;
+
+		if (pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+					     cq->ibcq.cqe, &head)) {
+			spin_unlock_irqrestore(&cq->cq_lock, flags);
+			return 1;
+		}
+	}
+
+	spin_unlock_irqrestore(&cq->cq_lock, flags);
+
 	return 0;
 }
 
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 26 lines · Adit Ranadive

From: Bryan Tan <[email protected]>

There is a chance of a race between arming the CQ and receiving completions. By reporting CQ missed events any ULPs should poll again to get the completions.

Fixes 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +1 -0
index 69bda61..f4ab5fa 100644
@@ -65,12 +65,27 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
 	struct pvrdma_dev *dev = to_vdev(ibcq->device);
 	struct pvrdma_cq *cq = to_vcq(ibcq);
 	u32 val = cq->cq_handle;
+	unsigned long flags;
 
 	val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
 		PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;

drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c int pvrdma_req_notify_cq(struct ib_cq *ibcq, · line 81

Quoted 10 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +7 -0
 
+	spin_lock_irqsave(&cq->cq_lock, flags);
+
 	pvrdma_write_uar_cq(dev, val);
 
+	if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+		unsigned int head;
+
+		if (pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+					     cq->ibcq.cqe, &head)) {

The pvrdma_idx_ring_has_data function can return PVRDMA_INVALID_IDX (-1).

Quoted 17 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +7 -1
+			spin_unlock_irqrestore(&cq->cq_lock, flags);
+			return 1;
+		}
+	}
+
+	spin_unlock_irqrestore(&cq->cq_lock, flags);
+
 	return 0;
 }
 
--

2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by
#6 lore raw
In reply to a message not in the archive
Quoted 33 lines · Adit Ranadive

From: Bryan Tan <[email protected]>

There is a chance of a race between arming the CQ and receiving completions. By reporting CQ missed events any ULPs should poll again to get the completions.

Fixes 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +5 -0
index 69bda61..f4ab5fa 100644
@@ -65,12 +65,27 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
 	struct pvrdma_dev *dev = to_vdev(ibcq->device);
 	struct pvrdma_cq *cq = to_vcq(ibcq);
 	u32 val = cq->cq_handle;
+	unsigned long flags;
 
 	val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
 		PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
 
+	spin_lock_irqsave(&cq->cq_lock, flags);
+
 	pvrdma_write_uar_cq(dev, val);
 
+	if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+		unsigned int head;

drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c int pvrdma_req_notify_cq(struct ib_cq *ibcq, · line 88

Quoted 10 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +10 -0
+
+		if (pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+					     cq->ibcq.cqe, &head)) {
+			spin_unlock_irqrestore(&cq->cq_lock, flags);
+			return 1;
+		}
+	}
+
+	spin_unlock_irqrestore(&cq->cq_lock, flags);
+
Quoted 10 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +0 -0
 	return 0;
 }
 
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive
Quoted 32 lines · Leon Romanovsky
Quoted 31 lines · Adit Ranadive

From: Bryan Tan <[email protected]>

There is a chance of a race between arming the CQ and receiving completions. By reporting CQ missed events any ULPs should poll again to get the completions.

Fixes 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +3 -0
index 69bda61..f4ab5fa 100644
@@ -65,12 +65,27 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
 	struct pvrdma_dev *dev = to_vdev(ibcq->device);
 	struct pvrdma_cq *cq = to_vcq(ibcq);
 	u32 val = cq->cq_handle;
+	unsigned long flags;
 
 	val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
 		PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
 
+	spin_lock_irqsave(&cq->cq_lock, flags);
+
 	pvrdma_write_uar_cq(dev, val);
 
Quoted 7 lines

drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c int pvrdma_req_notify_cq(struct ib_cq *ibcq, · line 81

Quoted 5 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +5 -0
+	if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+		unsigned int head;
+
+		if (pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+					     cq->ibcq.cqe, &head)) {

The pvrdma_idx_ring_has_data function can return PVRDMA_INVALID_IDX (-1).

I believe that the case of PVRDMA_INVALID_IDX is only due to some bug. I do not think it is an expected behaviour, it means that ring is corrupted, am i right Adit?

Quoted 11 lines
Quoted 11 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +7 -0
+			spin_unlock_irqrestore(&cq->cq_lock, flags);
+			return 1;
+		}
+	}
+
+	spin_unlock_irqrestore(&cq->cq_lock, flags);
+
 	return 0;
 }
 
Quoted 7 lines
Quoted 7 lines

--
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 41 lines · Leon Romanovsky
Quoted 32 lines · Adit Ranadive
Quoted 31 lines

From: Bryan Tan <[email protected]>

There is a chance of a race between arming the CQ and receiving completions. By reporting CQ missed events any ULPs should poll again to get the completions.

Fixes 29c8d9eba550 ("IB: Add vmw_pvrdma driver")

---
  drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 15 +++++++++++++++

  1 file changed, 15 insertions(+)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +1 -0
index 69bda61..f4ab5fa 100644
@@ -65,12 +65,27 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
       struct pvrdma_dev *dev = to_vdev(ibcq->device);
       struct pvrdma_cq *cq = to_vcq(ibcq);
       u32 val = cq->cq_handle;
+   unsigned long flags;
 

      val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ? PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;

+   spin_lock_irqsave(&cq->cq_lock, flags);
+
      pvrdma_write_uar_cq(dev, val);

Quoted 7 lines
Quoted 5 lines

+   if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+           unsigned int head;
+
+           if (pvrdma_idx_ring_has_data(&cq->ring_state->rx, +                                        cq->ibcq.cqe, &head)) {

The pvrdma_idx_ring_has_data function can return PVRDMA_INVALID_IDX (-1).

Quoted 3 lines

I believe that the case of PVRDMA_INVALID_IDX is only due to some bug. I do not think it is an expected behaviour, it means that ring is corrupted, am i right Adit?

Thanks Leon, Yuval. While hitting the INVALID_IDX is really rare (we haven't hit it ever in our internal testing), we should check this for consistency purposes. Look for a v1.

- Adit--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html