aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-05-24 11:55:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-24 11:55:12 -0400
commitda8bacf6d59288ef3e41389db24886c928dcbd33 (patch)
tree35d2739fb57a760dca1c9413a6814d6d2be8e295
parent67e3812426efbe62dd765eed9895cd3098def948 (diff)
parent09b74de9fff056a0a4058a0f14508acba89ea6fc (diff)
Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
* 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband: IB/ipath: deref correct pointer when using kernel SMA IB/ipath: fix null deref during rdma ops IB/ipath: register as IB device owner IB/ipath: enable PE800 receive interrupts on user ports IB/ipath: enable GPIO interrupt on HT-460 IB/ipath: fix NULL dereference during cleanup IB/ipath: replace uses of LIST_POISON IB/ipath: fix reporting of driver version to userspace IB/ipath: don't modify QP if changes fail IB/ipath: fix spinlock recursion bug
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c22
-rw-r--r--drivers/infiniband/hw/ipath/ipath_eeprom.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ht400.c21
-rw-r--r--drivers/infiniband/hw/ipath/ipath_init_chip.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_keys.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_layer.c12
-rw-r--r--drivers/infiniband/hw/ipath/ipath_pe800.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c64
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c15
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ruc.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c7
13 files changed, 92 insertions, 75 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 3697edafd6d2..dddcdae736ac 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -1905,19 +1905,19 @@ static void __exit infinipath_cleanup(void)
1905 } else 1905 } else
1906 ipath_dbg("irq is 0, not doing free_irq " 1906 ipath_dbg("irq is 0, not doing free_irq "
1907 "for unit %u\n", dd->ipath_unit); 1907 "for unit %u\n", dd->ipath_unit);
1908 dd->pcidev = NULL;
1909 }
1910 1908
1911 /* 1909 /*
1912 * we check for NULL here, because it's outside the kregbase 1910 * we check for NULL here, because it's outside
1913 * check, and we need to call it after the free_irq. Thus 1911 * the kregbase check, and we need to call it
1914 * it's possible that the function pointers were never 1912 * after the free_irq. Thus it's possible that
1915 * initialized. 1913 * the function pointers were never initialized.
1916 */ 1914 */
1917 if (dd->ipath_f_cleanup) 1915 if (dd->ipath_f_cleanup)
1918 /* clean up chip-specific stuff */ 1916 /* clean up chip-specific stuff */
1919 dd->ipath_f_cleanup(dd); 1917 dd->ipath_f_cleanup(dd);
1920 1918
1919 dd->pcidev = NULL;
1920 }
1921 spin_lock_irqsave(&ipath_devs_lock, flags); 1921 spin_lock_irqsave(&ipath_devs_lock, flags);
1922 } 1922 }
1923 1923
diff --git a/drivers/infiniband/hw/ipath/ipath_eeprom.c b/drivers/infiniband/hw/ipath/ipath_eeprom.c
index f11a900e8cd7..a2f1ceafcca9 100644
--- a/drivers/infiniband/hw/ipath/ipath_eeprom.c
+++ b/drivers/infiniband/hw/ipath/ipath_eeprom.c
@@ -505,11 +505,10 @@ static u8 flash_csum(struct ipath_flash *ifp, int adjust)
505 * ipath_get_guid - get the GUID from the i2c device 505 * ipath_get_guid - get the GUID from the i2c device
506 * @dd: the infinipath device 506 * @dd: the infinipath device
507 * 507 *
508 * When we add the multi-chip support, we will probably have to add 508 * We have the capability to use the ipath_nguid field, and get
509 * the ability to use the number of guids field, and get the guid from 509 * the guid from the first chip's flash, to use for all of them.
510 * the first chip's flash, to use for all of them.
511 */ 510 */
512void ipath_get_guid(struct ipath_devdata *dd) 511void ipath_get_eeprom_info(struct ipath_devdata *dd)
513{ 512{
514 void *buf; 513 void *buf;
515 struct ipath_flash *ifp; 514 struct ipath_flash *ifp;
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index c347191f02bf..ada267e41f6c 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -139,7 +139,7 @@ static int ipath_get_base_info(struct ipath_portdata *pd,
139 kinfo->spi_piosize = dd->ipath_ibmaxlen; 139 kinfo->spi_piosize = dd->ipath_ibmaxlen;
140 kinfo->spi_mtu = dd->ipath_ibmaxlen; /* maxlen, not ibmtu */ 140 kinfo->spi_mtu = dd->ipath_ibmaxlen; /* maxlen, not ibmtu */
141 kinfo->spi_port = pd->port_port; 141 kinfo->spi_port = pd->port_port;
142 kinfo->spi_sw_version = IPATH_USER_SWVERSION; 142 kinfo->spi_sw_version = IPATH_KERN_SWVERSION;
143 kinfo->spi_hw_version = dd->ipath_revision; 143 kinfo->spi_hw_version = dd->ipath_revision;
144 144
145 if (copy_to_user(ubase, kinfo, sizeof(*kinfo))) 145 if (copy_to_user(ubase, kinfo, sizeof(*kinfo)))
@@ -1224,6 +1224,10 @@ static unsigned int ipath_poll(struct file *fp,
1224 1224
1225 if (tail == head) { 1225 if (tail == head) {
1226 set_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag); 1226 set_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag);
1227 if(dd->ipath_rhdrhead_intr_off) /* arm rcv interrupt */
1228 (void)ipath_write_ureg(dd, ur_rcvhdrhead,
1229 dd->ipath_rhdrhead_intr_off
1230 | head, pd->port_port);
1227 poll_wait(fp, &pd->port_wait, pt); 1231 poll_wait(fp, &pd->port_wait, pt);
1228 1232
1229 if (test_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag)) { 1233 if (test_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag)) {
diff --git a/drivers/infiniband/hw/ipath/ipath_ht400.c b/drivers/infiniband/hw/ipath/ipath_ht400.c
index 4652435998f3..fac0a2b74de2 100644
--- a/drivers/infiniband/hw/ipath/ipath_ht400.c
+++ b/drivers/infiniband/hw/ipath/ipath_ht400.c
@@ -607,7 +607,12 @@ static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,
607 case 4: /* Ponderosa is one of the bringup boards */ 607 case 4: /* Ponderosa is one of the bringup boards */
608 n = "Ponderosa"; 608 n = "Ponderosa";
609 break; 609 break;
610 case 5: /* HT-460 original production board */ 610 case 5:
611 /*
612 * HT-460 original production board; two production levels, with
613 * different serial number ranges. See ipath_ht_early_init() for
614 * case where we enable IPATH_GPIO_INTR for later serial # range.
615 */
611 n = "InfiniPath_HT-460"; 616 n = "InfiniPath_HT-460";
612 break; 617 break;
613 case 6: 618 case 6:
@@ -642,7 +647,7 @@ static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,
642 if (n) 647 if (n)
643 snprintf(name, namelen, "%s", n); 648 snprintf(name, namelen, "%s", n);
644 649
645 if (dd->ipath_majrev != 3 || dd->ipath_minrev != 2) { 650 if (dd->ipath_majrev != 3 || (dd->ipath_minrev < 2 || dd->ipath_minrev > 3)) {
646 /* 651 /*
647 * This version of the driver only supports the HT-400 652 * This version of the driver only supports the HT-400
648 * Rev 3.2 653 * Rev 3.2
@@ -1520,6 +1525,18 @@ static int ipath_ht_early_init(struct ipath_devdata *dd)
1520 */ 1525 */
1521 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 1526 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
1522 INFINIPATH_S_ABORT); 1527 INFINIPATH_S_ABORT);
1528
1529 ipath_get_eeprom_info(dd);
1530 if(dd->ipath_boardrev == 5 && dd->ipath_serial[0] == '1' &&
1531 dd->ipath_serial[1] == '2' && dd->ipath_serial[2] == '8') {
1532 /*
1533 * Later production HT-460 has same changes as HT-465, so
1534 * can use GPIO interrupts. They have serial #'s starting
1535 * with 128, rather than 112.
1536 */
1537 dd->ipath_flags |= IPATH_GPIO_INTR;
1538 dd->ipath_flags &= ~IPATH_POLL_RX_INTR;
1539 }
1523 return 0; 1540 return 0;
1524} 1541}
1525 1542
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index 16f640e1c16e..dc83250d26a6 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -879,7 +879,6 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
879 879
880done: 880done:
881 if (!ret) { 881 if (!ret) {
882 ipath_get_guid(dd);
883 *dd->ipath_statusp |= IPATH_STATUS_CHIP_PRESENT; 882 *dd->ipath_statusp |= IPATH_STATUS_CHIP_PRESENT;
884 if (!dd->ipath_f_intrsetup(dd)) { 883 if (!dd->ipath_f_intrsetup(dd)) {
885 /* now we can enable all interrupts from the chip */ 884 /* now we can enable all interrupts from the chip */
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index e6507f8115bc..5d92d57b6f54 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -650,7 +650,7 @@ u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32 *);
650void ipath_init_pe800_funcs(struct ipath_devdata *); 650void ipath_init_pe800_funcs(struct ipath_devdata *);
651/* init HT-400-specific func */ 651/* init HT-400-specific func */
652void ipath_init_ht400_funcs(struct ipath_devdata *); 652void ipath_init_ht400_funcs(struct ipath_devdata *);
653void ipath_get_guid(struct ipath_devdata *); 653void ipath_get_eeprom_info(struct ipath_devdata *);
654u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg); 654u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg);
655 655
656/* 656/*
diff --git a/drivers/infiniband/hw/ipath/ipath_keys.c b/drivers/infiniband/hw/ipath/ipath_keys.c
index aa33b0e9f2f6..5ae8761f9dd2 100644
--- a/drivers/infiniband/hw/ipath/ipath_keys.c
+++ b/drivers/infiniband/hw/ipath/ipath_keys.c
@@ -136,9 +136,7 @@ int ipath_lkey_ok(struct ipath_lkey_table *rkt, struct ipath_sge *isge,
136 ret = 1; 136 ret = 1;
137 goto bail; 137 goto bail;
138 } 138 }
139 spin_lock(&rkt->lock);
140 mr = rkt->table[(sge->lkey >> (32 - ib_ipath_lkey_table_size))]; 139 mr = rkt->table[(sge->lkey >> (32 - ib_ipath_lkey_table_size))];
141 spin_unlock(&rkt->lock);
142 if (unlikely(mr == NULL || mr->lkey != sge->lkey)) { 140 if (unlikely(mr == NULL || mr->lkey != sge->lkey)) {
143 ret = 0; 141 ret = 0;
144 goto bail; 142 goto bail;
@@ -184,8 +182,6 @@ bail:
184 * @acc: access flags 182 * @acc: access flags
185 * 183 *
186 * Return 1 if successful, otherwise 0. 184 * Return 1 if successful, otherwise 0.
187 *
188 * The QP r_rq.lock should be held.
189 */ 185 */
190int ipath_rkey_ok(struct ipath_ibdev *dev, struct ipath_sge_state *ss, 186int ipath_rkey_ok(struct ipath_ibdev *dev, struct ipath_sge_state *ss,
191 u32 len, u64 vaddr, u32 rkey, int acc) 187 u32 len, u64 vaddr, u32 rkey, int acc)
@@ -196,9 +192,7 @@ int ipath_rkey_ok(struct ipath_ibdev *dev, struct ipath_sge_state *ss,
196 size_t off; 192 size_t off;
197 int ret; 193 int ret;
198 194
199 spin_lock(&rkt->lock);
200 mr = rkt->table[(rkey >> (32 - ib_ipath_lkey_table_size))]; 195 mr = rkt->table[(rkey >> (32 - ib_ipath_lkey_table_size))];
201 spin_unlock(&rkt->lock);
202 if (unlikely(mr == NULL || mr->lkey != rkey)) { 196 if (unlikely(mr == NULL || mr->lkey != rkey)) {
203 ret = 0; 197 ret = 0;
204 goto bail; 198 goto bail;
diff --git a/drivers/infiniband/hw/ipath/ipath_layer.c b/drivers/infiniband/hw/ipath/ipath_layer.c
index 9cb5258ffed9..9ec4ac77b87f 100644
--- a/drivers/infiniband/hw/ipath/ipath_layer.c
+++ b/drivers/infiniband/hw/ipath/ipath_layer.c
@@ -872,12 +872,13 @@ static void copy_io(u32 __iomem *piobuf, struct ipath_sge_state *ss,
872 update_sge(ss, len); 872 update_sge(ss, len);
873 length -= len; 873 length -= len;
874 } 874 }
875 /* Update address before sending packet. */
876 update_sge(ss, length);
875 /* must flush early everything before trigger word */ 877 /* must flush early everything before trigger word */
876 ipath_flush_wc(); 878 ipath_flush_wc();
877 __raw_writel(last, piobuf); 879 __raw_writel(last, piobuf);
878 /* be sure trigger word is written */ 880 /* be sure trigger word is written */
879 ipath_flush_wc(); 881 ipath_flush_wc();
880 update_sge(ss, length);
881} 882}
882 883
883/** 884/**
@@ -943,17 +944,18 @@ int ipath_verbs_send(struct ipath_devdata *dd, u32 hdrwords,
943 if (likely(ss->num_sge == 1 && len <= ss->sge.length && 944 if (likely(ss->num_sge == 1 && len <= ss->sge.length &&
944 !((unsigned long)ss->sge.vaddr & (sizeof(u32) - 1)))) { 945 !((unsigned long)ss->sge.vaddr & (sizeof(u32) - 1)))) {
945 u32 w; 946 u32 w;
947 u32 *addr = (u32 *) ss->sge.vaddr;
946 948
949 /* Update address before sending packet. */
950 update_sge(ss, len);
947 /* Need to round up for the last dword in the packet. */ 951 /* Need to round up for the last dword in the packet. */
948 w = (len + 3) >> 2; 952 w = (len + 3) >> 2;
949 __iowrite32_copy(piobuf, ss->sge.vaddr, w - 1); 953 __iowrite32_copy(piobuf, addr, w - 1);
950 /* must flush early everything before trigger word */ 954 /* must flush early everything before trigger word */
951 ipath_flush_wc(); 955 ipath_flush_wc();
952 __raw_writel(((u32 *) ss->sge.vaddr)[w - 1], 956 __raw_writel(addr[w - 1], piobuf + w - 1);
953 piobuf + w - 1);
954 /* be sure trigger word is written */ 957 /* be sure trigger word is written */
955 ipath_flush_wc(); 958 ipath_flush_wc();
956 update_sge(ss, len);
957 ret = 0; 959 ret = 0;
958 goto bail; 960 goto bail;
959 } 961 }
diff --git a/drivers/infiniband/hw/ipath/ipath_pe800.c b/drivers/infiniband/hw/ipath/ipath_pe800.c
index 6318067ab5ec..02e8c75b24f6 100644
--- a/drivers/infiniband/hw/ipath/ipath_pe800.c
+++ b/drivers/infiniband/hw/ipath/ipath_pe800.c
@@ -1180,6 +1180,8 @@ static int ipath_pe_early_init(struct ipath_devdata *dd)
1180 */ 1180 */
1181 dd->ipath_rhdrhead_intr_off = 1ULL<<32; 1181 dd->ipath_rhdrhead_intr_off = 1ULL<<32;
1182 1182
1183 ipath_get_eeprom_info(dd);
1184
1183 return 0; 1185 return 0;
1184} 1186}
1185 1187
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 18890716db1e..9f8855d970c8 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -375,10 +375,10 @@ static void ipath_error_qp(struct ipath_qp *qp)
375 375
376 spin_lock(&dev->pending_lock); 376 spin_lock(&dev->pending_lock);
377 /* XXX What if its already removed by the timeout code? */ 377 /* XXX What if its already removed by the timeout code? */
378 if (qp->timerwait.next != LIST_POISON1) 378 if (!list_empty(&qp->timerwait))
379 list_del(&qp->timerwait); 379 list_del_init(&qp->timerwait);
380 if (qp->piowait.next != LIST_POISON1) 380 if (!list_empty(&qp->piowait))
381 list_del(&qp->piowait); 381 list_del_init(&qp->piowait);
382 spin_unlock(&dev->pending_lock); 382 spin_unlock(&dev->pending_lock);
383 383
384 wc.status = IB_WC_WR_FLUSH_ERR; 384 wc.status = IB_WC_WR_FLUSH_ERR;
@@ -427,6 +427,7 @@ static void ipath_error_qp(struct ipath_qp *qp)
427int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 427int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
428 int attr_mask) 428 int attr_mask)
429{ 429{
430 struct ipath_ibdev *dev = to_idev(ibqp->device);
430 struct ipath_qp *qp = to_iqp(ibqp); 431 struct ipath_qp *qp = to_iqp(ibqp);
431 enum ib_qp_state cur_state, new_state; 432 enum ib_qp_state cur_state, new_state;
432 unsigned long flags; 433 unsigned long flags;
@@ -443,6 +444,19 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
443 attr_mask)) 444 attr_mask))
444 goto inval; 445 goto inval;
445 446
447 if (attr_mask & IB_QP_AV)
448 if (attr->ah_attr.dlid == 0 ||
449 attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE)
450 goto inval;
451
452 if (attr_mask & IB_QP_PKEY_INDEX)
453 if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd))
454 goto inval;
455
456 if (attr_mask & IB_QP_MIN_RNR_TIMER)
457 if (attr->min_rnr_timer > 31)
458 goto inval;
459
446 switch (new_state) { 460 switch (new_state) {
447 case IB_QPS_RESET: 461 case IB_QPS_RESET:
448 ipath_reset_qp(qp); 462 ipath_reset_qp(qp);
@@ -457,13 +471,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
457 471
458 } 472 }
459 473
460 if (attr_mask & IB_QP_PKEY_INDEX) { 474 if (attr_mask & IB_QP_PKEY_INDEX)
461 struct ipath_ibdev *dev = to_idev(ibqp->device);
462
463 if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd))
464 goto inval;
465 qp->s_pkey_index = attr->pkey_index; 475 qp->s_pkey_index = attr->pkey_index;
466 }
467 476
468 if (attr_mask & IB_QP_DEST_QPN) 477 if (attr_mask & IB_QP_DEST_QPN)
469 qp->remote_qpn = attr->dest_qp_num; 478 qp->remote_qpn = attr->dest_qp_num;
@@ -479,12 +488,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
479 if (attr_mask & IB_QP_ACCESS_FLAGS) 488 if (attr_mask & IB_QP_ACCESS_FLAGS)
480 qp->qp_access_flags = attr->qp_access_flags; 489 qp->qp_access_flags = attr->qp_access_flags;
481 490
482 if (attr_mask & IB_QP_AV) { 491 if (attr_mask & IB_QP_AV)
483 if (attr->ah_attr.dlid == 0 ||
484 attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE)
485 goto inval;
486 qp->remote_ah_attr = attr->ah_attr; 492 qp->remote_ah_attr = attr->ah_attr;
487 }
488 493
489 if (attr_mask & IB_QP_PATH_MTU) 494 if (attr_mask & IB_QP_PATH_MTU)
490 qp->path_mtu = attr->path_mtu; 495 qp->path_mtu = attr->path_mtu;
@@ -499,11 +504,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
499 qp->s_rnr_retry_cnt = qp->s_rnr_retry; 504 qp->s_rnr_retry_cnt = qp->s_rnr_retry;
500 } 505 }
501 506
502 if (attr_mask & IB_QP_MIN_RNR_TIMER) { 507 if (attr_mask & IB_QP_MIN_RNR_TIMER)
503 if (attr->min_rnr_timer > 31)
504 goto inval;
505 qp->s_min_rnr_timer = attr->min_rnr_timer; 508 qp->s_min_rnr_timer = attr->min_rnr_timer;
506 }
507 509
508 if (attr_mask & IB_QP_QKEY) 510 if (attr_mask & IB_QP_QKEY)
509 qp->qkey = attr->qkey; 511 qp->qkey = attr->qkey;
@@ -710,10 +712,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
710 init_attr->qp_type == IB_QPT_RC ? 712 init_attr->qp_type == IB_QPT_RC ?
711 ipath_do_rc_send : ipath_do_uc_send, 713 ipath_do_rc_send : ipath_do_uc_send,
712 (unsigned long)qp); 714 (unsigned long)qp);
713 qp->piowait.next = LIST_POISON1; 715 INIT_LIST_HEAD(&qp->piowait);
714 qp->piowait.prev = LIST_POISON2; 716 INIT_LIST_HEAD(&qp->timerwait);
715 qp->timerwait.next = LIST_POISON1;
716 qp->timerwait.prev = LIST_POISON2;
717 qp->state = IB_QPS_RESET; 717 qp->state = IB_QPS_RESET;
718 qp->s_wq = swq; 718 qp->s_wq = swq;
719 qp->s_size = init_attr->cap.max_send_wr + 1; 719 qp->s_size = init_attr->cap.max_send_wr + 1;
@@ -734,7 +734,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
734 ipath_reset_qp(qp); 734 ipath_reset_qp(qp);
735 735
736 /* Tell the core driver that the kernel SMA is present. */ 736 /* Tell the core driver that the kernel SMA is present. */
737 if (qp->ibqp.qp_type == IB_QPT_SMI) 737 if (init_attr->qp_type == IB_QPT_SMI)
738 ipath_layer_set_verbs_flags(dev->dd, 738 ipath_layer_set_verbs_flags(dev->dd,
739 IPATH_VERBS_KERNEL_SMA); 739 IPATH_VERBS_KERNEL_SMA);
740 break; 740 break;
@@ -783,10 +783,10 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
783 783
784 /* Make sure the QP isn't on the timeout list. */ 784 /* Make sure the QP isn't on the timeout list. */
785 spin_lock_irqsave(&dev->pending_lock, flags); 785 spin_lock_irqsave(&dev->pending_lock, flags);
786 if (qp->timerwait.next != LIST_POISON1) 786 if (!list_empty(&qp->timerwait))
787 list_del(&qp->timerwait); 787 list_del_init(&qp->timerwait);
788 if (qp->piowait.next != LIST_POISON1) 788 if (!list_empty(&qp->piowait))
789 list_del(&qp->piowait); 789 list_del_init(&qp->piowait);
790 spin_unlock_irqrestore(&dev->pending_lock, flags); 790 spin_unlock_irqrestore(&dev->pending_lock, flags);
791 791
792 /* 792 /*
@@ -855,10 +855,10 @@ void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc)
855 855
856 spin_lock(&dev->pending_lock); 856 spin_lock(&dev->pending_lock);
857 /* XXX What if its already removed by the timeout code? */ 857 /* XXX What if its already removed by the timeout code? */
858 if (qp->timerwait.next != LIST_POISON1) 858 if (!list_empty(&qp->timerwait))
859 list_del(&qp->timerwait); 859 list_del_init(&qp->timerwait);
860 if (qp->piowait.next != LIST_POISON1) 860 if (!list_empty(&qp->piowait))
861 list_del(&qp->piowait); 861 list_del_init(&qp->piowait);
862 spin_unlock(&dev->pending_lock); 862 spin_unlock(&dev->pending_lock);
863 863
864 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1); 864 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1);
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index a4055ca00614..493b1821a934 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -57,7 +57,7 @@ static void ipath_init_restart(struct ipath_qp *qp, struct ipath_swqe *wqe)
57 qp->s_len = wqe->length - len; 57 qp->s_len = wqe->length - len;
58 dev = to_idev(qp->ibqp.device); 58 dev = to_idev(qp->ibqp.device);
59 spin_lock(&dev->pending_lock); 59 spin_lock(&dev->pending_lock);
60 if (qp->timerwait.next == LIST_POISON1) 60 if (list_empty(&qp->timerwait))
61 list_add_tail(&qp->timerwait, 61 list_add_tail(&qp->timerwait,
62 &dev->pending[dev->pending_index]); 62 &dev->pending[dev->pending_index]);
63 spin_unlock(&dev->pending_lock); 63 spin_unlock(&dev->pending_lock);
@@ -356,7 +356,7 @@ static inline int ipath_make_rc_req(struct ipath_qp *qp,
356 if ((int)(qp->s_psn - qp->s_next_psn) > 0) 356 if ((int)(qp->s_psn - qp->s_next_psn) > 0)
357 qp->s_next_psn = qp->s_psn; 357 qp->s_next_psn = qp->s_psn;
358 spin_lock(&dev->pending_lock); 358 spin_lock(&dev->pending_lock);
359 if (qp->timerwait.next == LIST_POISON1) 359 if (list_empty(&qp->timerwait))
360 list_add_tail(&qp->timerwait, 360 list_add_tail(&qp->timerwait,
361 &dev->pending[dev->pending_index]); 361 &dev->pending[dev->pending_index]);
362 spin_unlock(&dev->pending_lock); 362 spin_unlock(&dev->pending_lock);
@@ -726,8 +726,8 @@ void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc)
726 */ 726 */
727 dev = to_idev(qp->ibqp.device); 727 dev = to_idev(qp->ibqp.device);
728 spin_lock(&dev->pending_lock); 728 spin_lock(&dev->pending_lock);
729 if (qp->timerwait.next != LIST_POISON1) 729 if (!list_empty(&qp->timerwait))
730 list_del(&qp->timerwait); 730 list_del_init(&qp->timerwait);
731 spin_unlock(&dev->pending_lock); 731 spin_unlock(&dev->pending_lock);
732 732
733 if (wqe->wr.opcode == IB_WR_RDMA_READ) 733 if (wqe->wr.opcode == IB_WR_RDMA_READ)
@@ -886,8 +886,8 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode)
886 * just won't find anything to restart if we ACK everything. 886 * just won't find anything to restart if we ACK everything.
887 */ 887 */
888 spin_lock(&dev->pending_lock); 888 spin_lock(&dev->pending_lock);
889 if (qp->timerwait.next != LIST_POISON1) 889 if (!list_empty(&qp->timerwait))
890 list_del(&qp->timerwait); 890 list_del_init(&qp->timerwait);
891 spin_unlock(&dev->pending_lock); 891 spin_unlock(&dev->pending_lock);
892 892
893 /* 893 /*
@@ -1194,8 +1194,7 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1194 IB_WR_RDMA_READ)) 1194 IB_WR_RDMA_READ))
1195 goto ack_done; 1195 goto ack_done;
1196 spin_lock(&dev->pending_lock); 1196 spin_lock(&dev->pending_lock);
1197 if (qp->s_rnr_timeout == 0 && 1197 if (qp->s_rnr_timeout == 0 && !list_empty(&qp->timerwait))
1198 qp->timerwait.next != LIST_POISON1)
1199 list_move_tail(&qp->timerwait, 1198 list_move_tail(&qp->timerwait,
1200 &dev->pending[dev->pending_index]); 1199 &dev->pending[dev->pending_index]);
1201 spin_unlock(&dev->pending_lock); 1200 spin_unlock(&dev->pending_lock);
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
index eb81424b3c5b..d38f4f3cfd1d 100644
--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
@@ -435,7 +435,7 @@ void ipath_no_bufs_available(struct ipath_qp *qp, struct ipath_ibdev *dev)
435 unsigned long flags; 435 unsigned long flags;
436 436
437 spin_lock_irqsave(&dev->pending_lock, flags); 437 spin_lock_irqsave(&dev->pending_lock, flags);
438 if (qp->piowait.next == LIST_POISON1) 438 if (list_empty(&qp->piowait))
439 list_add_tail(&qp->piowait, &dev->piowait); 439 list_add_tail(&qp->piowait, &dev->piowait);
440 spin_unlock_irqrestore(&dev->pending_lock, flags); 440 spin_unlock_irqrestore(&dev->pending_lock, flags);
441 /* 441 /*
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index cb9e387c301f..28fdbdaa789d 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -464,7 +464,7 @@ static void ipath_ib_timer(void *arg)
464 last = &dev->pending[dev->pending_index]; 464 last = &dev->pending[dev->pending_index];
465 while (!list_empty(last)) { 465 while (!list_empty(last)) {
466 qp = list_entry(last->next, struct ipath_qp, timerwait); 466 qp = list_entry(last->next, struct ipath_qp, timerwait);
467 list_del(&qp->timerwait); 467 list_del_init(&qp->timerwait);
468 qp->timer_next = resend; 468 qp->timer_next = resend;
469 resend = qp; 469 resend = qp;
470 atomic_inc(&qp->refcount); 470 atomic_inc(&qp->refcount);
@@ -474,7 +474,7 @@ static void ipath_ib_timer(void *arg)
474 qp = list_entry(last->next, struct ipath_qp, timerwait); 474 qp = list_entry(last->next, struct ipath_qp, timerwait);
475 if (--qp->s_rnr_timeout == 0) { 475 if (--qp->s_rnr_timeout == 0) {
476 do { 476 do {
477 list_del(&qp->timerwait); 477 list_del_init(&qp->timerwait);
478 tasklet_hi_schedule(&qp->s_task); 478 tasklet_hi_schedule(&qp->s_task);
479 if (list_empty(last)) 479 if (list_empty(last))
480 break; 480 break;
@@ -554,7 +554,7 @@ static int ipath_ib_piobufavail(void *arg)
554 while (!list_empty(&dev->piowait)) { 554 while (!list_empty(&dev->piowait)) {
555 qp = list_entry(dev->piowait.next, struct ipath_qp, 555 qp = list_entry(dev->piowait.next, struct ipath_qp,
556 piowait); 556 piowait);
557 list_del(&qp->piowait); 557 list_del_init(&qp->piowait);
558 tasklet_hi_schedule(&qp->s_task); 558 tasklet_hi_schedule(&qp->s_task);
559 } 559 }
560 spin_unlock_irqrestore(&dev->pending_lock, flags); 560 spin_unlock_irqrestore(&dev->pending_lock, flags);
@@ -951,6 +951,7 @@ static void *ipath_register_ib_device(int unit, struct ipath_devdata *dd)
951 idev->dd = dd; 951 idev->dd = dd;
952 952
953 strlcpy(dev->name, "ipath%d", IB_DEVICE_NAME_MAX); 953 strlcpy(dev->name, "ipath%d", IB_DEVICE_NAME_MAX);
954 dev->owner = THIS_MODULE;
954 dev->node_guid = ipath_layer_get_guid(dd); 955 dev->node_guid = ipath_layer_get_guid(dd);
955 dev->uverbs_abi_ver = IPATH_UVERBS_ABI_VERSION; 956 dev->uverbs_abi_ver = IPATH_UVERBS_ABI_VERSION;
956 dev->uverbs_cmd_mask = 957 dev->uverbs_cmd_mask =