Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/ehca: Refactor "maybe missed event" code

Refactor the ehca changes from commit ed23a727 ("IB: Return "maybe
missed event" hint from ib_req_notify_cq()") so the queue arithmetic
is done in slightly fewer lines. Also, move the spinlock flags into
the block they're used in.

Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Joachim Fenkes and committed by
Roland Dreier
fffba373 1bae4dbf

+11 -19
+1 -1
drivers/infiniband/hw/ehca/ehca_reqs.c
··· 637 637 int ehca_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags notify_flags) 638 638 { 639 639 struct ehca_cq *my_cq = container_of(cq, struct ehca_cq, ib_cq); 640 - unsigned long spl_flags; 641 640 int ret = 0; 642 641 643 642 switch (notify_flags & IB_CQ_SOLICITED_MASK) { ··· 651 652 } 652 653 653 654 if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) { 655 + unsigned long spl_flags; 654 656 spin_lock_irqsave(&my_cq->spinlock, spl_flags); 655 657 ret = ipz_qeit_is_valid(&my_cq->ipz_queue); 656 658 spin_unlock_irqrestore(&my_cq->spinlock, spl_flags);
+10 -18
drivers/infiniband/hw/ehca/ipz_pt_fn.h
··· 105 105 * step in struct ipz_queue, will wrap in ringbuffer 106 106 * returns address (kv) of Queue Entry BEFORE increment 107 107 * warning don't use in parallel with ipz_qpageit_get_inc() 108 - * warning unpredictable results may occur if steps>act_nr_of_queue_entries 109 108 */ 110 109 static inline void *ipz_qeit_get_inc(struct ipz_queue *queue) 111 110 { ··· 120 121 } 121 122 122 123 /* 124 + * return a bool indicating whether current Queue Entry is valid 125 + */ 126 + static inline int ipz_qeit_is_valid(struct ipz_queue *queue) 127 + { 128 + struct ehca_cqe *cqe = ipz_qeit_get(queue); 129 + return ((cqe->cqe_flags >> 7) == (queue->toggle_state & 1)); 130 + } 131 + 132 + /* 123 133 * return current Queue Entry, increment Queue Entry iterator by one 124 134 * step in struct ipz_queue, will wrap in ringbuffer 125 135 * returns address (kv) of Queue Entry BEFORE increment 126 136 * returns 0 and does not increment, if wrong valid state 127 137 * warning don't use in parallel with ipz_qpageit_get_inc() 128 - * warning unpredictable results may occur if steps>act_nr_of_queue_entries 129 138 */ 130 139 static inline void *ipz_qeit_get_inc_valid(struct ipz_queue *queue) 131 140 { 132 - struct ehca_cqe *cqe = ipz_qeit_get(queue); 133 - u32 cqe_flags = cqe->cqe_flags; 134 - 135 - if ((cqe_flags >> 7) != (queue->toggle_state & 1)) 136 - return NULL; 137 - 138 - ipz_qeit_get_inc(queue); 139 - return cqe; 140 - } 141 - 142 - static inline int ipz_qeit_is_valid(struct ipz_queue *queue) 143 - { 144 - struct ehca_cqe *cqe = ipz_qeit_get(queue); 145 - u32 cqe_flags = cqe->cqe_flags; 146 - 147 - return cqe_flags >> 7 == (queue->toggle_state & 1); 141 + return ipz_qeit_is_valid(queue) ? ipz_qeit_get_inc(queue) : NULL; 148 142 } 149 143 150 144 /*