[openib-general] [PATCH] CQ rearm race in IPoIB

ralphc at pathscale.com ralphc at pathscale.com
Fri Mar 17 13:33:23 PST 2006


There is a race in IPoIB where it rearms the CQ by calling
ib_req_notify_cq() followed by ib_poll_cq().  The loop
can call ib_poll_cq() multiple times if new packets arrive
but then fail to rearm the CQ properly.

Signed-off-by: Ralph Campbell <ralphc at pathscale.com>

Index: openib/src/linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- openib/src/linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c     (revision
5870)
+++ openib/src/linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c     (working
copy)
@@ -292,13 +292,20 @@
        struct net_device *dev = (struct net_device *) dev_ptr;
        struct ipoib_dev_priv *priv = netdev_priv(dev);
        int n, i;
+       int retry = 1;

-       ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
-       do {
+       while (1) {
                n = ib_poll_cq(cq, IPOIB_NUM_WC, priv->ibwc);
                for (i = 0; i < n; ++i)
                        ipoib_ib_handle_wc(dev, priv->ibwc + i);
-       } while (n == IPOIB_NUM_WC);
+               if (n <= 0) {
+                       if (!retry)
+                               break;
+                       ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
+                       retry = 0;
+               } else
+                       retry = 1;
+       }
 }

 static inline int post_send(struct ipoib_dev_priv *priv,





More information about the general mailing list