From: Wei Lin Guay Date: Thu, 3 Nov 2016 09:46:22 +0000 (+0100) Subject: sif: cq: sif_poll_cq might not drain cq completely X-Git-Tag: v4.1.12-92~36^2~8 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c2cf0f102632f1fe3531d7beaba5aeb68fbfdaf3;p=users%2Fjedix%2Flinux-maple.git sif: cq: sif_poll_cq might not drain cq completely In a scenario where a duplicate completion is detected, the sif_poll_cq skips the remaining cqes in the cq. This code bug is introduced in commit "sif: sqflush: Handle duplicate completions in poll_cq". Orabug: 25038711 Signed-off-by: Wei Lin Guay Reviewed-by: Knut Omang --- diff --git a/drivers/infiniband/hw/sif/sif_cq.c b/drivers/infiniband/hw/sif/sif_cq.c index 92204edbdb75..545a7fe702fc 100644 --- a/drivers/infiniband/hw/sif/sif_cq.c +++ b/drivers/infiniband/hw/sif/sif_cq.c @@ -871,25 +871,23 @@ int sif_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) polled_value = get_psif_cq_entry__seq_num(cqe); - if (seqno == polled_value) - npolled++; - else + if (seqno != polled_value) break; if (likely(wc)) { - if (unlikely(handle_wc(sdev, cq, cqe, wc) < 0)) { - /* poll_cq should not return < 0. Thus, ignore - * the CQE if it is duplicate, unexpected or wrong - * CQE. - */ - seqno = ++cq_sw->next_seq; - npolled--; - continue; + /* handle_wc == 0 means that it's a valid cqe. + * Thus, increments the npolled and the wc pointer. + */ + if (likely(handle_wc(sdev, cq, cqe, wc) == 0)) { + ++wc; + ++npolled; } - wc++; seqno = ++cq_sw->next_seq; - } else /* peek_cq semantics */ + } else { + /* peek_cq semantics */ ++seqno; + ++npolled; + } cqe = get_cq_entry(cq, seqno); }