This patch releases all staled connections, otherwise all statled connections
will remain untill the nodes down or IPoIB module being removed. It causes 
waste lots of resource in the long run.

Signed-off-by: Shirley Ma <xma@us.ibm.com>
---------------------

 drivers/infiniband/ulp/ipoib/ipoib_cm.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index ae67379..442dd49 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -61,6 +61,7 @@ MODULE_PARM_DESC(cm_data_debug_level,
 
 #define IPOIB_CM_RX_UPDATE_TIME (256 * HZ)
 #define IPOIB_CM_RX_TIMEOUT     (2 * 256 * HZ)
+#define IPOIB_CM_RX_DRAIN	(60 * HZ)
 #define IPOIB_CM_RX_DELAY       (3 * 256 * HZ)
 #define IPOIB_CM_RX_UPDATE_MASK (0x3)
 
@@ -1343,6 +1344,15 @@ static void ipoib_cm_stale_task(struct work_struct *work)
 	int ret;
 
 	spin_lock_irq(&priv->lock);
+	/* wait for the CQ drain, and clean up stale connections */
+	while (!list_empty(&priv->cm.rx_error_list)) {
+		/* List is sorted by LRU, start from tail,
+		 * stop when we see a recently used entry */
+		p = list_entry(priv->cm.rx_error_list.prev, typeof(*p), list);
+		if (time_before_eq(jiffies, p->jiffies + IPOIB_CM_RX_DRAIN))
+			break;
+		list_move(&p->list, &priv->cm.rx_reap_list);
+	}
 	while (!list_empty(&priv->cm.passive_ids)) {
 		/* List is sorted by LRU, start from tail,
 		 * stop when we see a recently used entry */
