Skip to contentSkip to conversation

IB/ehca: Refactor "maybe missed event" code

PATCH In review Joachim Fenkes 2 participants 3 messages May 24, 2007 – May 29, 2007 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/ehca: Refactor "maybe missed event" code

Refactored Roland's patch so the queue arithmetic is done in a little less lines. Also, moved the spinlock inside the block it's used in.

---
 drivers/infiniband/hw/ehca/ehca_reqs.c |    2 +-
 drivers/infiniband/hw/ehca/ipz_pt_fn.h |   28 ++++++++++------------------
 2 files changed, 11 insertions(+), 19 deletions(-)
drivers/infiniband/hw/ehca/ehca_reqs.c +1 -1
index caec9de..56c4527 100644
@@ -637,7 +637,6 @@ poll_cq_exit0:
 int ehca_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags notify_flags)
 {
 	struct ehca_cq *my_cq = container_of(cq, struct ehca_cq, ib_cq);
-	unsigned long spl_flags;
 	int ret = 0;
 
 	switch (notify_flags & IB_CQ_SOLICITED_MASK) {
@@ -652,6 +651,7 @@ int ehca_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags notify_flags)
 	}
 
 	if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+		unsigned long spl_flags;
 		spin_lock_irqsave(&my_cq->spinlock, spl_flags);
 		ret = ipz_qeit_is_valid(&my_cq->ipz_queue);
 		spin_unlock_irqrestore(&my_cq->spinlock, spl_flags);
drivers/infiniband/hw/ehca/ipz_pt_fn.h +10 -18
index 57f141a..007f088 100644
@@ -105,7 +105,6 @@ void *ipz_qpageit_get_inc(struct ipz_queue *queue);
  * step in struct ipz_queue, will wrap in ringbuffer
  * returns address (kv) of Queue Entry BEFORE increment
  * warning don't use in parallel with ipz_qpageit_get_inc()
- * warning unpredictable results may occur if steps>act_nr_of_queue_entries
  */
 static inline void *ipz_qeit_get_inc(struct ipz_queue *queue)
 {
@@ -121,31 +120,24 @@ static inline void *ipz_qeit_get_inc(struct ipz_queue *queue)
 }
 
 /*
+ * return a bool indicating whether current Queue Entry is valid
+ */
+static inline int ipz_qeit_is_valid(struct ipz_queue *queue)
+{
+	struct ehca_cqe *cqe = ipz_qeit_get(queue);
+	return ((cqe->cqe_flags >> 7) == (queue->toggle_state & 1));
+}
+
+/*
  * return current Queue Entry, increment Queue Entry iterator by one
  * step in struct ipz_queue, will wrap in ringbuffer
  * returns address (kv) of Queue Entry BEFORE increment
  * returns 0 and does not increment, if wrong valid state
  * warning don't use in parallel with ipz_qpageit_get_inc()
- * warning unpredictable results may occur if steps>act_nr_of_queue_entries
  */
 static inline void *ipz_qeit_get_inc_valid(struct ipz_queue *queue)
 {
-	struct ehca_cqe *cqe = ipz_qeit_get(queue);
-	u32 cqe_flags = cqe->cqe_flags;
-
-	if ((cqe_flags >> 7) != (queue->toggle_state & 1))
-		return NULL;
-
-	ipz_qeit_get_inc(queue);
-	return cqe;
-}
-
-static inline int ipz_qeit_is_valid(struct ipz_queue *queue)
-{
-	struct ehca_cqe *cqe = ipz_qeit_get(queue);
-	u32 cqe_flags = cqe->cqe_flags;
-
-	return cqe_flags >> 7 == (queue->toggle_state & 1);
+	return ipz_qeit_is_valid(queue) ? ipz_qeit_get_inc(queue) : NULL;
 }
 
 /*
Signature · 1 line
1.5.2
#1 lore raw

This isn't fixing anything is it? I think it's 2.6.23 material; correct me if I'm wrong.

- R.

#2 lore raw

Roland Dreier <[email protected]> wrote on 24.05.2007 19:40:39:

Quoted 2 lines

This isn't fixing anything is it? I think it's 2.6.23 material; correct me if I'm wrong.

Right, it doesn't fix things, just coalesces some code.

Joachim