aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-03-18 02:44:31 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-18 02:44:31 -0400
commit2f633928cbba8a5858bb39b11e7219a41b0fbef5 (patch)
tree9a82f4b7f2c3afe4b0208d8e44ea61bae90a7d22 /drivers/infiniband
parent5e226e4d9016daee170699f8a4188a5505021756 (diff)
parentbde4f8fa8db2abd5ac9c542d76012d0fedab050f (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/cm.c3
-rw-r--r--drivers/infiniband/core/fmr_pool.c38
-rw-r--r--drivers/infiniband/core/iwcm.c5
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_mem.c10
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_common.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c28
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mad.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c13
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_registers.h2
-rw-r--r--drivers/infiniband/hw/nes/nes.c2
-rw-r--r--drivers/infiniband/hw/nes/nes.h15
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c15
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c13
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c10
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c9
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c9
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c2
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c47
22 files changed, 133 insertions, 109 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index b10ade92efed..4df405157086 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3759,6 +3759,7 @@ static void cm_remove_one(struct ib_device *device)
3759 port = cm_dev->port[i-1]; 3759 port = cm_dev->port[i-1];
3760 ib_modify_port(device, port->port_num, 0, &port_modify); 3760 ib_modify_port(device, port->port_num, 0, &port_modify);
3761 ib_unregister_mad_agent(port->mad_agent); 3761 ib_unregister_mad_agent(port->mad_agent);
3762 flush_workqueue(cm.wq);
3762 cm_remove_port_fs(port); 3763 cm_remove_port_fs(port);
3763 } 3764 }
3764 kobject_put(&cm_dev->dev_obj); 3765 kobject_put(&cm_dev->dev_obj);
@@ -3813,6 +3814,7 @@ static void __exit ib_cm_cleanup(void)
3813 cancel_delayed_work(&timewait_info->work.work); 3814 cancel_delayed_work(&timewait_info->work.work);
3814 spin_unlock_irq(&cm.lock); 3815 spin_unlock_irq(&cm.lock);
3815 3816
3817 ib_unregister_client(&cm_client);
3816 destroy_workqueue(cm.wq); 3818 destroy_workqueue(cm.wq);
3817 3819
3818 list_for_each_entry_safe(timewait_info, tmp, &cm.timewait_list, list) { 3820 list_for_each_entry_safe(timewait_info, tmp, &cm.timewait_list, list) {
@@ -3820,7 +3822,6 @@ static void __exit ib_cm_cleanup(void)
3820 kfree(timewait_info); 3822 kfree(timewait_info);
3821 } 3823 }
3822 3824
3823 ib_unregister_client(&cm_client);
3824 class_unregister(&cm_class); 3825 class_unregister(&cm_class);
3825 idr_destroy(&cm.local_id_table); 3826 idr_destroy(&cm.local_id_table);
3826} 3827}
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
index 7f00347364f7..06d502c06a4d 100644
--- a/drivers/infiniband/core/fmr_pool.c
+++ b/drivers/infiniband/core/fmr_pool.c
@@ -139,7 +139,7 @@ static inline struct ib_pool_fmr *ib_fmr_cache_lookup(struct ib_fmr_pool *pool,
139static void ib_fmr_batch_release(struct ib_fmr_pool *pool) 139static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
140{ 140{
141 int ret; 141 int ret;
142 struct ib_pool_fmr *fmr, *next; 142 struct ib_pool_fmr *fmr;
143 LIST_HEAD(unmap_list); 143 LIST_HEAD(unmap_list);
144 LIST_HEAD(fmr_list); 144 LIST_HEAD(fmr_list);
145 145
@@ -158,20 +158,6 @@ static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
158#endif 158#endif
159 } 159 }
160 160
161 /*
162 * The free_list may hold FMRs that have been put there
163 * because they haven't reached the max_remap count.
164 * Invalidate their mapping as well.
165 */
166 list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
167 if (fmr->remap_count == 0)
168 continue;
169 hlist_del_init(&fmr->cache_node);
170 fmr->remap_count = 0;
171 list_add_tail(&fmr->fmr->list, &fmr_list);
172 list_move(&fmr->list, &unmap_list);
173 }
174
175 list_splice(&pool->dirty_list, &unmap_list); 161 list_splice(&pool->dirty_list, &unmap_list);
176 INIT_LIST_HEAD(&pool->dirty_list); 162 INIT_LIST_HEAD(&pool->dirty_list);
177 pool->dirty_len = 0; 163 pool->dirty_len = 0;
@@ -384,6 +370,11 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
384 370
385 i = 0; 371 i = 0;
386 list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) { 372 list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) {
373 if (fmr->remap_count) {
374 INIT_LIST_HEAD(&fmr_list);
375 list_add_tail(&fmr->fmr->list, &fmr_list);
376 ib_unmap_fmr(&fmr_list);
377 }
387 ib_dealloc_fmr(fmr->fmr); 378 ib_dealloc_fmr(fmr->fmr);
388 list_del(&fmr->list); 379 list_del(&fmr->list);
389 kfree(fmr); 380 kfree(fmr);
@@ -407,8 +398,23 @@ EXPORT_SYMBOL(ib_destroy_fmr_pool);
407 */ 398 */
408int ib_flush_fmr_pool(struct ib_fmr_pool *pool) 399int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
409{ 400{
410 int serial = atomic_inc_return(&pool->req_ser); 401 int serial;
402 struct ib_pool_fmr *fmr, *next;
403
404 /*
405 * The free_list holds FMRs that may have been used
406 * but have not been remapped enough times to be dirty.
407 * Put them on the dirty list now so that the cleanup
408 * thread will reap them too.
409 */
410 spin_lock_irq(&pool->pool_lock);
411 list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
412 if (fmr->remap_count > 0)
413 list_move(&fmr->list, &pool->dirty_list);
414 }
415 spin_unlock_irq(&pool->pool_lock);
411 416
417 serial = atomic_inc_return(&pool->req_ser);
412 wake_up_process(pool->thread); 418 wake_up_process(pool->thread);
413 419
414 if (wait_event_interruptible(pool->force_wait, 420 if (wait_event_interruptible(pool->force_wait,
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 223b1aa7d92b..81c9195b512a 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -839,6 +839,7 @@ static void cm_work_handler(struct work_struct *_work)
839 unsigned long flags; 839 unsigned long flags;
840 int empty; 840 int empty;
841 int ret = 0; 841 int ret = 0;
842 int destroy_id;
842 843
843 spin_lock_irqsave(&cm_id_priv->lock, flags); 844 spin_lock_irqsave(&cm_id_priv->lock, flags);
844 empty = list_empty(&cm_id_priv->work_list); 845 empty = list_empty(&cm_id_priv->work_list);
@@ -857,9 +858,9 @@ static void cm_work_handler(struct work_struct *_work)
857 destroy_cm_id(&cm_id_priv->id); 858 destroy_cm_id(&cm_id_priv->id);
858 } 859 }
859 BUG_ON(atomic_read(&cm_id_priv->refcount)==0); 860 BUG_ON(atomic_read(&cm_id_priv->refcount)==0);
861 destroy_id = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
860 if (iwcm_deref_id(cm_id_priv)) { 862 if (iwcm_deref_id(cm_id_priv)) {
861 if (test_bit(IWCM_F_CALLBACK_DESTROY, 863 if (destroy_id) {
862 &cm_id_priv->flags)) {
863 BUG_ON(!list_empty(&cm_id_priv->work_list)); 864 BUG_ON(!list_empty(&cm_id_priv->work_list));
864 free_cm_id(cm_id_priv); 865 free_cm_id(cm_id_priv);
865 } 866 }
diff --git a/drivers/infiniband/hw/cxgb3/iwch_mem.c b/drivers/infiniband/hw/cxgb3/iwch_mem.c
index 73bfd1656f86..b8797c66676d 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_mem.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_mem.c
@@ -136,14 +136,8 @@ int build_phys_page_list(struct ib_phys_buf *buffer_list,
136 136
137 /* Find largest page shift we can use to cover buffers */ 137 /* Find largest page shift we can use to cover buffers */
138 for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift)) 138 for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift))
139 if (num_phys_buf > 1) { 139 if ((1ULL << *shift) & mask)
140 if ((1ULL << *shift) & mask) 140 break;
141 break;
142 } else
143 if (1ULL << *shift >=
144 buffer_list[0].size +
145 (buffer_list[0].addr & ((1ULL << *shift) - 1)))
146 break;
147 141
148 buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1); 142 buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1);
149 buffer_list[0].addr &= ~0ull << *shift; 143 buffer_list[0].addr &= ~0ull << *shift;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index df1838f8f94d..b2ea9210467f 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -189,7 +189,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve
189 return ERR_PTR(-ENOMEM); 189 return ERR_PTR(-ENOMEM);
190 } 190 }
191 chp->rhp = rhp; 191 chp->rhp = rhp;
192 chp->ibcq.cqe = (1 << chp->cq.size_log2) - 1; 192 chp->ibcq.cqe = 1 << chp->cq.size_log2;
193 spin_lock_init(&chp->lock); 193 spin_lock_init(&chp->lock);
194 atomic_set(&chp->refcnt, 1); 194 atomic_set(&chp->refcnt, 1);
195 init_waitqueue_head(&chp->wait); 195 init_waitqueue_head(&chp->wait);
@@ -819,8 +819,11 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
819 kfree(qhp); 819 kfree(qhp);
820 return ERR_PTR(-ENOMEM); 820 return ERR_PTR(-ENOMEM);
821 } 821 }
822
822 attrs->cap.max_recv_wr = rqsize - 1; 823 attrs->cap.max_recv_wr = rqsize - 1;
823 attrs->cap.max_send_wr = sqsize; 824 attrs->cap.max_send_wr = sqsize;
825 attrs->cap.max_inline_data = T3_MAX_INLINE;
826
824 qhp->rhp = rhp; 827 qhp->rhp = rhp;
825 qhp->attr.pd = php->pdid; 828 qhp->attr.pd = php->pdid;
826 qhp->attr.scq = ((struct iwch_cq *) attrs->send_cq)->cq.cqid; 829 qhp->attr.scq = ((struct iwch_cq *) attrs->send_cq)->cq.cqid;
diff --git a/drivers/infiniband/hw/ipath/ipath_common.h b/drivers/infiniband/hw/ipath/ipath_common.h
index 414621095540..591901aab6b7 100644
--- a/drivers/infiniband/hw/ipath/ipath_common.h
+++ b/drivers/infiniband/hw/ipath/ipath_common.h
@@ -75,7 +75,7 @@
75#define IPATH_IB_LINKDOWN 0 75#define IPATH_IB_LINKDOWN 0
76#define IPATH_IB_LINKARM 1 76#define IPATH_IB_LINKARM 1
77#define IPATH_IB_LINKACTIVE 2 77#define IPATH_IB_LINKACTIVE 2
78#define IPATH_IB_LINKINIT 3 78#define IPATH_IB_LINKDOWN_ONLY 3
79#define IPATH_IB_LINKDOWN_SLEEP 4 79#define IPATH_IB_LINKDOWN_SLEEP 4
80#define IPATH_IB_LINKDOWN_DISABLE 5 80#define IPATH_IB_LINKDOWN_DISABLE 5
81#define IPATH_IB_LINK_LOOPBACK 6 /* enable local loopback */ 81#define IPATH_IB_LINK_LOOPBACK 6 /* enable local loopback */
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index d5ff6ca2db30..ca4d0acc6786 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -851,8 +851,7 @@ void ipath_disarm_piobufs(struct ipath_devdata *dd, unsigned first,
851 * -ETIMEDOUT state can have multiple states set, for any of several 851 * -ETIMEDOUT state can have multiple states set, for any of several
852 * transitions. 852 * transitions.
853 */ 853 */
854static int ipath_wait_linkstate(struct ipath_devdata *dd, u32 state, 854int ipath_wait_linkstate(struct ipath_devdata *dd, u32 state, int msecs)
855 int msecs)
856{ 855{
857 dd->ipath_state_wanted = state; 856 dd->ipath_state_wanted = state;
858 wait_event_interruptible_timeout(ipath_state_wait, 857 wait_event_interruptible_timeout(ipath_state_wait,
@@ -1656,8 +1655,8 @@ void ipath_cancel_sends(struct ipath_devdata *dd, int restore_sendctrl)
1656static void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) 1655static void ipath_set_ib_lstate(struct ipath_devdata *dd, int which)
1657{ 1656{
1658 static const char *what[4] = { 1657 static const char *what[4] = {
1659 [0] = "DOWN", 1658 [0] = "NOP",
1660 [INFINIPATH_IBCC_LINKCMD_INIT] = "INIT", 1659 [INFINIPATH_IBCC_LINKCMD_DOWN] = "DOWN",
1661 [INFINIPATH_IBCC_LINKCMD_ARMED] = "ARMED", 1660 [INFINIPATH_IBCC_LINKCMD_ARMED] = "ARMED",
1662 [INFINIPATH_IBCC_LINKCMD_ACTIVE] = "ACTIVE" 1661 [INFINIPATH_IBCC_LINKCMD_ACTIVE] = "ACTIVE"
1663 }; 1662 };
@@ -1672,9 +1671,9 @@ static void ipath_set_ib_lstate(struct ipath_devdata *dd, int which)
1672 (dd, dd->ipath_kregs->kr_ibcstatus) >> 1671 (dd, dd->ipath_kregs->kr_ibcstatus) >>
1673 INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) & 1672 INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) &
1674 INFINIPATH_IBCS_LINKTRAININGSTATE_MASK]); 1673 INFINIPATH_IBCS_LINKTRAININGSTATE_MASK]);
1675 /* flush all queued sends when going to DOWN or INIT, to be sure that 1674 /* flush all queued sends when going to DOWN to be sure that
1676 * they don't block MAD packets */ 1675 * they don't block MAD packets */
1677 if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT) 1676 if (linkcmd == INFINIPATH_IBCC_LINKCMD_DOWN)
1678 ipath_cancel_sends(dd, 1); 1677 ipath_cancel_sends(dd, 1);
1679 1678
1680 ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl, 1679 ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl,
@@ -1687,6 +1686,13 @@ int ipath_set_linkstate(struct ipath_devdata *dd, u8 newstate)
1687 int ret; 1686 int ret;
1688 1687
1689 switch (newstate) { 1688 switch (newstate) {
1689 case IPATH_IB_LINKDOWN_ONLY:
1690 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKCMD_DOWN <<
1691 INFINIPATH_IBCC_LINKCMD_SHIFT);
1692 /* don't wait */
1693 ret = 0;
1694 goto bail;
1695
1690 case IPATH_IB_LINKDOWN: 1696 case IPATH_IB_LINKDOWN:
1691 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_POLL << 1697 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_POLL <<
1692 INFINIPATH_IBCC_LINKINITCMD_SHIFT); 1698 INFINIPATH_IBCC_LINKINITCMD_SHIFT);
@@ -1709,16 +1715,6 @@ int ipath_set_linkstate(struct ipath_devdata *dd, u8 newstate)
1709 ret = 0; 1715 ret = 0;
1710 goto bail; 1716 goto bail;
1711 1717
1712 case IPATH_IB_LINKINIT:
1713 if (dd->ipath_flags & IPATH_LINKINIT) {
1714 ret = 0;
1715 goto bail;
1716 }
1717 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKCMD_INIT <<
1718 INFINIPATH_IBCC_LINKCMD_SHIFT);
1719 lstate = IPATH_LINKINIT;
1720 break;
1721
1722 case IPATH_IB_LINKARM: 1718 case IPATH_IB_LINKARM:
1723 if (dd->ipath_flags & IPATH_LINKARMED) { 1719 if (dd->ipath_flags & IPATH_LINKARMED) {
1724 ret = 0; 1720 ret = 0;
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 4cc0f95ea877..ecf3f7ff7717 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -767,6 +767,7 @@ void ipath_kreceive(struct ipath_portdata *);
767int ipath_setrcvhdrsize(struct ipath_devdata *, unsigned); 767int ipath_setrcvhdrsize(struct ipath_devdata *, unsigned);
768int ipath_reset_device(int); 768int ipath_reset_device(int);
769void ipath_get_faststats(unsigned long); 769void ipath_get_faststats(unsigned long);
770int ipath_wait_linkstate(struct ipath_devdata *, u32, int);
770int ipath_set_linkstate(struct ipath_devdata *, u8); 771int ipath_set_linkstate(struct ipath_devdata *, u8);
771int ipath_set_mtu(struct ipath_devdata *, u16); 772int ipath_set_mtu(struct ipath_devdata *, u16);
772int ipath_set_lid(struct ipath_devdata *, u32, u8); 773int ipath_set_lid(struct ipath_devdata *, u32, u8);
diff --git a/drivers/infiniband/hw/ipath/ipath_mad.c b/drivers/infiniband/hw/ipath/ipath_mad.c
index d98d5f103700..b34b91d3723a 100644
--- a/drivers/infiniband/hw/ipath/ipath_mad.c
+++ b/drivers/infiniband/hw/ipath/ipath_mad.c
@@ -555,10 +555,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
555 /* FALLTHROUGH */ 555 /* FALLTHROUGH */
556 case IB_PORT_DOWN: 556 case IB_PORT_DOWN:
557 if (lstate == 0) 557 if (lstate == 0)
558 if (get_linkdowndefaultstate(dd)) 558 lstate = IPATH_IB_LINKDOWN_ONLY;
559 lstate = IPATH_IB_LINKDOWN_SLEEP;
560 else
561 lstate = IPATH_IB_LINKDOWN;
562 else if (lstate == 1) 559 else if (lstate == 1)
563 lstate = IPATH_IB_LINKDOWN_SLEEP; 560 lstate = IPATH_IB_LINKDOWN_SLEEP;
564 else if (lstate == 2) 561 else if (lstate == 2)
@@ -568,6 +565,8 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
568 else 565 else
569 goto err; 566 goto err;
570 ipath_set_linkstate(dd, lstate); 567 ipath_set_linkstate(dd, lstate);
568 ipath_wait_linkstate(dd, IPATH_LINKINIT | IPATH_LINKARMED |
569 IPATH_LINKACTIVE, 1000);
571 break; 570 break;
572 case IB_PORT_ARMED: 571 case IB_PORT_ARMED:
573 ipath_set_linkstate(dd, IPATH_IB_LINKARM); 572 ipath_set_linkstate(dd, IPATH_IB_LINKARM);
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 80dc623cee40..087ed3166479 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -329,8 +329,9 @@ struct ipath_qp *ipath_lookup_qpn(struct ipath_qp_table *qpt, u32 qpn)
329/** 329/**
330 * ipath_reset_qp - initialize the QP state to the reset state 330 * ipath_reset_qp - initialize the QP state to the reset state
331 * @qp: the QP to reset 331 * @qp: the QP to reset
332 * @type: the QP type
332 */ 333 */
333static void ipath_reset_qp(struct ipath_qp *qp) 334static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
334{ 335{
335 qp->remote_qpn = 0; 336 qp->remote_qpn = 0;
336 qp->qkey = 0; 337 qp->qkey = 0;
@@ -342,7 +343,7 @@ static void ipath_reset_qp(struct ipath_qp *qp)
342 qp->s_psn = 0; 343 qp->s_psn = 0;
343 qp->r_psn = 0; 344 qp->r_psn = 0;
344 qp->r_msn = 0; 345 qp->r_msn = 0;
345 if (qp->ibqp.qp_type == IB_QPT_RC) { 346 if (type == IB_QPT_RC) {
346 qp->s_state = IB_OPCODE_RC_SEND_LAST; 347 qp->s_state = IB_OPCODE_RC_SEND_LAST;
347 qp->r_state = IB_OPCODE_RC_SEND_LAST; 348 qp->r_state = IB_OPCODE_RC_SEND_LAST;
348 } else { 349 } else {
@@ -414,7 +415,7 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
414 wc.wr_id = qp->r_wr_id; 415 wc.wr_id = qp->r_wr_id;
415 wc.opcode = IB_WC_RECV; 416 wc.opcode = IB_WC_RECV;
416 wc.status = err; 417 wc.status = err;
417 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1); 418 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1);
418 } 419 }
419 wc.status = IB_WC_WR_FLUSH_ERR; 420 wc.status = IB_WC_WR_FLUSH_ERR;
420 421
@@ -534,7 +535,7 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
534 535
535 switch (new_state) { 536 switch (new_state) {
536 case IB_QPS_RESET: 537 case IB_QPS_RESET:
537 ipath_reset_qp(qp); 538 ipath_reset_qp(qp, ibqp->qp_type);
538 break; 539 break;
539 540
540 case IB_QPS_ERR: 541 case IB_QPS_ERR:
@@ -647,7 +648,7 @@ int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
647 attr->port_num = 1; 648 attr->port_num = 1;
648 attr->timeout = qp->timeout; 649 attr->timeout = qp->timeout;
649 attr->retry_cnt = qp->s_retry_cnt; 650 attr->retry_cnt = qp->s_retry_cnt;
650 attr->rnr_retry = qp->s_rnr_retry; 651 attr->rnr_retry = qp->s_rnr_retry_cnt;
651 attr->alt_port_num = 0; 652 attr->alt_port_num = 0;
652 attr->alt_timeout = 0; 653 attr->alt_timeout = 0;
653 654
@@ -839,7 +840,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
839 goto bail_qp; 840 goto bail_qp;
840 } 841 }
841 qp->ip = NULL; 842 qp->ip = NULL;
842 ipath_reset_qp(qp); 843 ipath_reset_qp(qp, init_attr->qp_type);
843 break; 844 break;
844 845
845 default: 846 default:
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index 459e46e2c016..40f3e37d7adc 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -1196,6 +1196,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1196 list_move_tail(&qp->timerwait, 1196 list_move_tail(&qp->timerwait,
1197 &dev->pending[dev->pending_index]); 1197 &dev->pending[dev->pending_index]);
1198 spin_unlock(&dev->pending_lock); 1198 spin_unlock(&dev->pending_lock);
1199
1200 if (opcode == OP(RDMA_READ_RESPONSE_MIDDLE))
1201 qp->s_retry = qp->s_retry_cnt;
1202
1199 /* 1203 /*
1200 * Update the RDMA receive state but do the copy w/o 1204 * Update the RDMA receive state but do the copy w/o
1201 * holding the locks and blocking interrupts. 1205 * holding the locks and blocking interrupts.
diff --git a/drivers/infiniband/hw/ipath/ipath_registers.h b/drivers/infiniband/hw/ipath/ipath_registers.h
index 6d2a17f9c1da..92ad73a7fff0 100644
--- a/drivers/infiniband/hw/ipath/ipath_registers.h
+++ b/drivers/infiniband/hw/ipath/ipath_registers.h
@@ -185,7 +185,7 @@
185#define INFINIPATH_IBCC_LINKINITCMD_SLEEP 3 185#define INFINIPATH_IBCC_LINKINITCMD_SLEEP 3
186#define INFINIPATH_IBCC_LINKINITCMD_SHIFT 16 186#define INFINIPATH_IBCC_LINKINITCMD_SHIFT 16
187#define INFINIPATH_IBCC_LINKCMD_MASK 0x3ULL 187#define INFINIPATH_IBCC_LINKCMD_MASK 0x3ULL
188#define INFINIPATH_IBCC_LINKCMD_INIT 1 /* move to 0x11 */ 188#define INFINIPATH_IBCC_LINKCMD_DOWN 1 /* move to 0x11 */
189#define INFINIPATH_IBCC_LINKCMD_ARMED 2 /* move to 0x21 */ 189#define INFINIPATH_IBCC_LINKCMD_ARMED 2 /* move to 0x21 */
190#define INFINIPATH_IBCC_LINKCMD_ACTIVE 3 /* move to 0x31 */ 190#define INFINIPATH_IBCC_LINKCMD_ACTIVE 3 /* move to 0x31 */
191#define INFINIPATH_IBCC_LINKCMD_SHIFT 18 191#define INFINIPATH_IBCC_LINKCMD_SHIFT 18
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 7f8853b44ee1..b2112f5a422f 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -567,12 +567,12 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
567 567
568 /* Init the adapter */ 568 /* Init the adapter */
569 nesdev->nesadapter = nes_init_adapter(nesdev, hw_rev); 569 nesdev->nesadapter = nes_init_adapter(nesdev, hw_rev);
570 nesdev->nesadapter->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
571 if (!nesdev->nesadapter) { 570 if (!nesdev->nesadapter) {
572 printk(KERN_ERR PFX "Unable to initialize adapter.\n"); 571 printk(KERN_ERR PFX "Unable to initialize adapter.\n");
573 ret = -ENOMEM; 572 ret = -ENOMEM;
574 goto bail5; 573 goto bail5;
575 } 574 }
575 nesdev->nesadapter->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
576 576
577 /* nesdev->base_doorbell_index = 577 /* nesdev->base_doorbell_index =
578 nesdev->nesadapter->pd_config_base[PCI_FUNC(nesdev->pcidev->devfn)]; */ 578 nesdev->nesadapter->pd_config_base[PCI_FUNC(nesdev->pcidev->devfn)]; */
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index fd57e8a1582f..a48b288618ec 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -285,6 +285,21 @@ struct nes_device {
285}; 285};
286 286
287 287
288static inline __le32 get_crc_value(struct nes_v4_quad *nes_quad)
289{
290 u32 crc_value;
291 crc_value = crc32c(~0, (void *)nes_quad, sizeof (struct nes_v4_quad));
292
293 /*
294 * With commit ef19454b ("[LIB] crc32c: Keep intermediate crc
295 * state in cpu order"), behavior of crc32c changes on
296 * big-endian platforms. Our algorithm expects the previous
297 * behavior; otherwise we have RDMA connection establishment
298 * issue on big-endian.
299 */
300 return cpu_to_le32(crc_value);
301}
302
288static inline void 303static inline void
289set_wqe_64bit_value(__le32 *wqe_words, u32 index, u64 value) 304set_wqe_64bit_value(__le32 *wqe_words, u32 index, u64 value)
290{ 305{
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index bd5cfeaac203..39adb267fb15 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -370,11 +370,11 @@ int schedule_nes_timer(struct nes_cm_node *cm_node, struct sk_buff *skb,
370 int ret = 0; 370 int ret = 0;
371 u32 was_timer_set; 371 u32 was_timer_set;
372 372
373 if (!cm_node)
374 return -EINVAL;
373 new_send = kzalloc(sizeof(*new_send), GFP_ATOMIC); 375 new_send = kzalloc(sizeof(*new_send), GFP_ATOMIC);
374 if (!new_send) 376 if (!new_send)
375 return -1; 377 return -1;
376 if (!cm_node)
377 return -EINVAL;
378 378
379 /* new_send->timetosend = currenttime */ 379 /* new_send->timetosend = currenttime */
380 new_send->retrycount = NES_DEFAULT_RETRYS; 380 new_send->retrycount = NES_DEFAULT_RETRYS;
@@ -947,6 +947,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
947 nes_debug(NES_DBG_CM, "destroying listener (%p)\n", listener); 947 nes_debug(NES_DBG_CM, "destroying listener (%p)\n", listener);
948 948
949 kfree(listener); 949 kfree(listener);
950 listener = NULL;
950 ret = 0; 951 ret = 0;
951 cm_listens_destroyed++; 952 cm_listens_destroyed++;
952 } else { 953 } else {
@@ -2319,6 +2320,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2319 struct iw_cm_event cm_event; 2320 struct iw_cm_event cm_event;
2320 struct nes_hw_qp_wqe *wqe; 2321 struct nes_hw_qp_wqe *wqe;
2321 struct nes_v4_quad nes_quad; 2322 struct nes_v4_quad nes_quad;
2323 u32 crc_value;
2322 int ret; 2324 int ret;
2323 2325
2324 ibqp = nes_get_qp(cm_id->device, conn_param->qpn); 2326 ibqp = nes_get_qp(cm_id->device, conn_param->qpn);
@@ -2435,8 +2437,8 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2435 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2437 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
2436 2438
2437 /* Produce hash key */ 2439 /* Produce hash key */
2438 nesqp->hte_index = cpu_to_be32( 2440 crc_value = get_crc_value(&nes_quad);
2439 crc32c(~0, (void *)&nes_quad, sizeof(nes_quad)) ^ 0xffffffff); 2441 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
2440 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n", 2442 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n",
2441 nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask); 2443 nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask);
2442 2444
@@ -2750,6 +2752,7 @@ void cm_event_connected(struct nes_cm_event *event)
2750 struct iw_cm_event cm_event; 2752 struct iw_cm_event cm_event;
2751 struct nes_hw_qp_wqe *wqe; 2753 struct nes_hw_qp_wqe *wqe;
2752 struct nes_v4_quad nes_quad; 2754 struct nes_v4_quad nes_quad;
2755 u32 crc_value;
2753 int ret; 2756 int ret;
2754 2757
2755 /* get all our handles */ 2758 /* get all our handles */
@@ -2827,8 +2830,8 @@ void cm_event_connected(struct nes_cm_event *event)
2827 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2830 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
2828 2831
2829 /* Produce hash key */ 2832 /* Produce hash key */
2830 nesqp->hte_index = cpu_to_be32( 2833 crc_value = get_crc_value(&nes_quad);
2831 crc32c(~0, (void *)&nes_quad, sizeof(nes_quad)) ^ 0xffffffff); 2834 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
2832 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, After CRC = 0x%08X\n", 2835 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, After CRC = 0x%08X\n",
2833 nesqp->hte_index, nesqp->hte_index & nesadapter->hte_index_mask); 2836 nesqp->hte_index, nesqp->hte_index & nesadapter->hte_index_mask);
2834 2837
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 7c4c0fbf0abd..49e53e4c1ebe 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -156,15 +156,14 @@ static void nes_nic_tune_timer(struct nes_device *nesdev)
156 156
157 spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags); 157 spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags);
158 158
159 if (shared_timer->cq_count_old < cq_count) { 159 if (shared_timer->cq_count_old <= cq_count)
160 if (cq_count > shared_timer->threshold_low) 160 shared_timer->cq_direction_downward = 0;
161 shared_timer->cq_direction_downward=0; 161 else
162 }
163 if (shared_timer->cq_count_old >= cq_count)
164 shared_timer->cq_direction_downward++; 162 shared_timer->cq_direction_downward++;
165 shared_timer->cq_count_old = cq_count; 163 shared_timer->cq_count_old = cq_count;
166 if (shared_timer->cq_direction_downward > NES_NIC_CQ_DOWNWARD_TREND) { 164 if (shared_timer->cq_direction_downward > NES_NIC_CQ_DOWNWARD_TREND) {
167 if (cq_count <= shared_timer->threshold_low) { 165 if (cq_count <= shared_timer->threshold_low &&
166 shared_timer->threshold_low > 4) {
168 shared_timer->threshold_low = shared_timer->threshold_low/2; 167 shared_timer->threshold_low = shared_timer->threshold_low/2;
169 shared_timer->cq_direction_downward=0; 168 shared_timer->cq_direction_downward=0;
170 nesdev->currcq_count = 0; 169 nesdev->currcq_count = 0;
@@ -1728,7 +1727,6 @@ int nes_napi_isr(struct nes_device *nesdev)
1728 nesdev->int_req &= ~NES_INT_TIMER; 1727 nesdev->int_req &= ~NES_INT_TIMER;
1729 nes_write32(nesdev->regs+NES_INTF_INT_MASK, ~(nesdev->intf_int_req)); 1728 nes_write32(nesdev->regs+NES_INTF_INT_MASK, ~(nesdev->intf_int_req));
1730 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req); 1729 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req);
1731 nesadapter->tune_timer.timer_in_use_old = 0;
1732 } 1730 }
1733 nesdev->deepcq_count = 0; 1731 nesdev->deepcq_count = 0;
1734 return 1; 1732 return 1;
@@ -1867,7 +1865,6 @@ void nes_dpc(unsigned long param)
1867 nesdev->int_req &= ~NES_INT_TIMER; 1865 nesdev->int_req &= ~NES_INT_TIMER;
1868 nes_write32(nesdev->regs + NES_INTF_INT_MASK, ~(nesdev->intf_int_req)); 1866 nes_write32(nesdev->regs + NES_INTF_INT_MASK, ~(nesdev->intf_int_req));
1869 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req); 1867 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req);
1870 nesdev->nesadapter->tune_timer.timer_in_use_old = 0;
1871 } else { 1868 } else {
1872 nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff|(~nesdev->int_req)); 1869 nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff|(~nesdev->int_req));
1873 } 1870 }
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 1e10df550c9e..b7e2844f096b 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -962,7 +962,7 @@ struct nes_arp_entry {
962#define DEFAULT_JUMBO_NES_QL_LOW 12 962#define DEFAULT_JUMBO_NES_QL_LOW 12
963#define DEFAULT_JUMBO_NES_QL_TARGET 40 963#define DEFAULT_JUMBO_NES_QL_TARGET 40
964#define DEFAULT_JUMBO_NES_QL_HIGH 128 964#define DEFAULT_JUMBO_NES_QL_HIGH 128
965#define NES_NIC_CQ_DOWNWARD_TREND 8 965#define NES_NIC_CQ_DOWNWARD_TREND 16
966 966
967struct nes_hw_tune_timer { 967struct nes_hw_tune_timer {
968 //u16 cq_count; 968 //u16 cq_count;
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 4dafbe16e82a..a651e9d9f0ef 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -929,7 +929,7 @@ static struct ib_pd *nes_alloc_pd(struct ib_device *ibdev,
929 NES_MAX_USER_DB_REGIONS, nesucontext->first_free_db); 929 NES_MAX_USER_DB_REGIONS, nesucontext->first_free_db);
930 nes_debug(NES_DBG_PD, "find_first_zero_biton doorbells returned %u, mapping pd_id %u.\n", 930 nes_debug(NES_DBG_PD, "find_first_zero_biton doorbells returned %u, mapping pd_id %u.\n",
931 nespd->mmap_db_index, nespd->pd_id); 931 nespd->mmap_db_index, nespd->pd_id);
932 if (nespd->mmap_db_index > NES_MAX_USER_DB_REGIONS) { 932 if (nespd->mmap_db_index >= NES_MAX_USER_DB_REGIONS) {
933 nes_debug(NES_DBG_PD, "mmap_db_index > MAX\n"); 933 nes_debug(NES_DBG_PD, "mmap_db_index > MAX\n");
934 nes_free_resource(nesadapter, nesadapter->allocated_pds, pd_num); 934 nes_free_resource(nesadapter, nesadapter->allocated_pds, pd_num);
935 kfree(nespd); 935 kfree(nespd);
@@ -1327,7 +1327,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1327 (long long unsigned int)req.user_wqe_buffers); 1327 (long long unsigned int)req.user_wqe_buffers);
1328 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); 1328 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num);
1329 kfree(nesqp->allocated_buffer); 1329 kfree(nesqp->allocated_buffer);
1330 return ERR_PTR(-ENOMEM); 1330 return ERR_PTR(-EFAULT);
1331 } 1331 }
1332 } 1332 }
1333 1333
@@ -1674,6 +1674,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1674 } 1674 }
1675 nes_debug(NES_DBG_CQ, "CQ Virtual Address = %08lX, size = %u.\n", 1675 nes_debug(NES_DBG_CQ, "CQ Virtual Address = %08lX, size = %u.\n",
1676 (unsigned long)req.user_cq_buffer, entries); 1676 (unsigned long)req.user_cq_buffer, entries);
1677 err = 1;
1677 list_for_each_entry(nespbl, &nes_ucontext->cq_reg_mem_list, list) { 1678 list_for_each_entry(nespbl, &nes_ucontext->cq_reg_mem_list, list) {
1678 if (nespbl->user_base == (unsigned long )req.user_cq_buffer) { 1679 if (nespbl->user_base == (unsigned long )req.user_cq_buffer) {
1679 list_del(&nespbl->list); 1680 list_del(&nespbl->list);
@@ -1686,7 +1687,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1686 if (err) { 1687 if (err) {
1687 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); 1688 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
1688 kfree(nescq); 1689 kfree(nescq);
1689 return ERR_PTR(err); 1690 return ERR_PTR(-EFAULT);
1690 } 1691 }
1691 1692
1692 pbl_entries = nespbl->pbl_size >> 3; 1693 pbl_entries = nespbl->pbl_size >> 3;
@@ -1831,9 +1832,6 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1831 spin_unlock_irqrestore(&nesdev->cqp.lock, flags); 1832 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1832 } 1833 }
1833 } 1834 }
1834 nes_debug(NES_DBG_CQ, "iWARP CQ%u create timeout expired, major code = 0x%04X,"
1835 " minor code = 0x%04X\n",
1836 nescq->hw_cq.cq_number, cqp_request->major_code, cqp_request->minor_code);
1837 if (!context) 1835 if (!context)
1838 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, 1836 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem,
1839 nescq->hw_cq.cq_pbase); 1837 nescq->hw_cq.cq_pbase);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 52b1bebfa744..2490b2d79dbb 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -38,6 +38,7 @@
38#include <net/icmp.h> 38#include <net/icmp.h>
39#include <linux/icmpv6.h> 39#include <linux/icmpv6.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/vmalloc.h>
41 42
42#include "ipoib.h" 43#include "ipoib.h"
43 44
@@ -637,6 +638,7 @@ static inline int post_send(struct ipoib_dev_priv *priv,
637 priv->tx_sge[0].addr = addr; 638 priv->tx_sge[0].addr = addr;
638 priv->tx_sge[0].length = len; 639 priv->tx_sge[0].length = len;
639 640
641 priv->tx_wr.num_sge = 1;
640 priv->tx_wr.wr_id = wr_id | IPOIB_OP_CM; 642 priv->tx_wr.wr_id = wr_id | IPOIB_OP_CM;
641 643
642 return ib_post_send(tx->qp, &priv->tx_wr, &bad_wr); 644 return ib_post_send(tx->qp, &priv->tx_wr, &bad_wr);
@@ -1030,13 +1032,13 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
1030 struct ipoib_dev_priv *priv = netdev_priv(p->dev); 1032 struct ipoib_dev_priv *priv = netdev_priv(p->dev);
1031 int ret; 1033 int ret;
1032 1034
1033 p->tx_ring = kzalloc(ipoib_sendq_size * sizeof *p->tx_ring, 1035 p->tx_ring = vmalloc(ipoib_sendq_size * sizeof *p->tx_ring);
1034 GFP_KERNEL);
1035 if (!p->tx_ring) { 1036 if (!p->tx_ring) {
1036 ipoib_warn(priv, "failed to allocate tx ring\n"); 1037 ipoib_warn(priv, "failed to allocate tx ring\n");
1037 ret = -ENOMEM; 1038 ret = -ENOMEM;
1038 goto err_tx; 1039 goto err_tx;
1039 } 1040 }
1041 memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring);
1040 1042
1041 p->qp = ipoib_cm_create_tx_qp(p->dev, p); 1043 p->qp = ipoib_cm_create_tx_qp(p->dev, p);
1042 if (IS_ERR(p->qp)) { 1044 if (IS_ERR(p->qp)) {
@@ -1077,6 +1079,7 @@ err_id:
1077 ib_destroy_qp(p->qp); 1079 ib_destroy_qp(p->qp);
1078err_qp: 1080err_qp:
1079 p->qp = NULL; 1081 p->qp = NULL;
1082 vfree(p->tx_ring);
1080err_tx: 1083err_tx:
1081 return ret; 1084 return ret;
1082} 1085}
@@ -1127,7 +1130,7 @@ timeout:
1127 if (p->qp) 1130 if (p->qp)
1128 ib_destroy_qp(p->qp); 1131 ib_destroy_qp(p->qp);
1129 1132
1130 kfree(p->tx_ring); 1133 vfree(p->tx_ring);
1131 kfree(p); 1134 kfree(p);
1132} 1135}
1133 1136
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index f96477a8ca5a..57282048865c 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -41,6 +41,7 @@
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/kernel.h> 43#include <linux/kernel.h>
44#include <linux/vmalloc.h>
44 45
45#include <linux/if_arp.h> /* For ARPHRD_xxx */ 46#include <linux/if_arp.h> /* For ARPHRD_xxx */
46 47
@@ -887,13 +888,13 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
887 goto out; 888 goto out;
888 } 889 }
889 890
890 priv->tx_ring = kzalloc(ipoib_sendq_size * sizeof *priv->tx_ring, 891 priv->tx_ring = vmalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
891 GFP_KERNEL);
892 if (!priv->tx_ring) { 892 if (!priv->tx_ring) {
893 printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n", 893 printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n",
894 ca->name, ipoib_sendq_size); 894 ca->name, ipoib_sendq_size);
895 goto out_rx_ring_cleanup; 895 goto out_rx_ring_cleanup;
896 } 896 }
897 memset(priv->tx_ring, 0, ipoib_sendq_size * sizeof *priv->tx_ring);
897 898
898 /* priv->tx_head, tx_tail & tx_outstanding are already 0 */ 899 /* priv->tx_head, tx_tail & tx_outstanding are already 0 */
899 900
@@ -903,7 +904,7 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
903 return 0; 904 return 0;
904 905
905out_tx_ring_cleanup: 906out_tx_ring_cleanup:
906 kfree(priv->tx_ring); 907 vfree(priv->tx_ring);
907 908
908out_rx_ring_cleanup: 909out_rx_ring_cleanup:
909 kfree(priv->rx_ring); 910 kfree(priv->rx_ring);
@@ -928,7 +929,7 @@ void ipoib_dev_cleanup(struct net_device *dev)
928 ipoib_ib_dev_cleanup(dev); 929 ipoib_ib_dev_cleanup(dev);
929 930
930 kfree(priv->rx_ring); 931 kfree(priv->rx_ring);
931 kfree(priv->tx_ring); 932 vfree(priv->tx_ring);
932 933
933 priv->rx_ring = NULL; 934 priv->rx_ring = NULL;
934 priv->tx_ring = NULL; 935 priv->tx_ring = NULL;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 2628339e3a99..31a53c5bcb13 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -650,7 +650,7 @@ void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
650 */ 650 */
651 spin_lock(&priv->lock); 651 spin_lock(&priv->lock);
652 652
653 if (!test_bit(IPOIB_MCAST_STARTED, &priv->flags) || 653 if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags) ||
654 !priv->broadcast || 654 !priv->broadcast ||
655 !test_bit(IPOIB_MCAST_FLAG_ATTACHED, &priv->broadcast->flags)) { 655 !test_bit(IPOIB_MCAST_FLAG_ATTACHED, &priv->broadcast->flags)) {
656 ++dev->stats.tx_dropped; 656 ++dev->stats.tx_dropped;
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 714b8db02b29..993f0a8ff28f 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -237,36 +237,32 @@ static int iser_free_ib_conn_res(struct iser_conn *ib_conn)
237static 237static
238struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id) 238struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id)
239{ 239{
240 struct list_head *p_list; 240 struct iser_device *device;
241 struct iser_device *device = NULL;
242 241
243 mutex_lock(&ig.device_list_mutex); 242 mutex_lock(&ig.device_list_mutex);
244 243
245 p_list = ig.device_list.next; 244 list_for_each_entry(device, &ig.device_list, ig_list)
246 while (p_list != &ig.device_list) {
247 device = list_entry(p_list, struct iser_device, ig_list);
248 /* find if there's a match using the node GUID */ 245 /* find if there's a match using the node GUID */
249 if (device->ib_device->node_guid == cma_id->device->node_guid) 246 if (device->ib_device->node_guid == cma_id->device->node_guid)
250 break; 247 goto inc_refcnt;
251 }
252 248
253 if (device == NULL) { 249 device = kzalloc(sizeof *device, GFP_KERNEL);
254 device = kzalloc(sizeof *device, GFP_KERNEL); 250 if (device == NULL)
255 if (device == NULL) 251 goto out;
256 goto out; 252
257 /* assign this device to the device */ 253 /* assign this device to the device */
258 device->ib_device = cma_id->device; 254 device->ib_device = cma_id->device;
259 /* init the device and link it into ig device list */ 255 /* init the device and link it into ig device list */
260 if (iser_create_device_ib_res(device)) { 256 if (iser_create_device_ib_res(device)) {
261 kfree(device); 257 kfree(device);
262 device = NULL; 258 device = NULL;
263 goto out; 259 goto out;
264 }
265 list_add(&device->ig_list, &ig.device_list);
266 } 260 }
267out: 261 list_add(&device->ig_list, &ig.device_list);
268 BUG_ON(device == NULL); 262
263inc_refcnt:
269 device->refcount++; 264 device->refcount++;
265out:
270 mutex_unlock(&ig.device_list_mutex); 266 mutex_unlock(&ig.device_list_mutex);
271 return device; 267 return device;
272} 268}
@@ -372,6 +368,12 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id)
372 int ret; 368 int ret;
373 369
374 device = iser_device_find_by_ib_device(cma_id); 370 device = iser_device_find_by_ib_device(cma_id);
371 if (!device) {
372 iser_err("device lookup/creation failed\n");
373 iser_connect_error(cma_id);
374 return;
375 }
376
375 ib_conn = (struct iser_conn *)cma_id->context; 377 ib_conn = (struct iser_conn *)cma_id->context;
376 ib_conn->device = device; 378 ib_conn->device = device;
377 379
@@ -380,7 +382,6 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id)
380 iser_err("resolve route failed: %d\n", ret); 382 iser_err("resolve route failed: %d\n", ret);
381 iser_connect_error(cma_id); 383 iser_connect_error(cma_id);
382 } 384 }
383 return;
384} 385}
385 386
386static void iser_route_handler(struct rdma_cm_id *cma_id) 387static void iser_route_handler(struct rdma_cm_id *cma_id)