aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorMike Marciniszyn <mike.marciniszyn@intel.com>2012-07-16 13:11:06 -0400
committerRoland Dreier <roland@purestorage.com>2012-07-17 13:18:37 -0400
commit1fb9fed6d48960fec3ad8c97fed9aa16c9557091 (patch)
tree1ad8f9170aa4940aba1a3ba7d7d471a918a88420 /drivers/infiniband/hw
parent7e23017704172cb6508cb365eb2cae7335e5da71 (diff)
IB/qib: Fix QP RCU sparse warnings
Commit af061a644a0e ("IB/qib: Use RCU for qpn lookup") introduced sparse warnings. This patch corrects those issues. Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/qib/qib_iba7322.c12
-rw-r--r--drivers/infiniband/hw/qib/qib_mad.c12
-rw-r--r--drivers/infiniband/hw/qib/qib_qp.c35
-rw-r--r--drivers/infiniband/hw/qib/qib_verbs.c23
-rw-r--r--drivers/infiniband/hw/qib/qib_verbs.h14
5 files changed, 61 insertions, 35 deletions
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index c881e744c091..78e85503c509 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2008, 2009, 2010 QLogic Corporation. All rights reserved. 2 * Copyright (c) 2012 Intel Corporation. All rights reserved.
3 * Copyright (c) 2008 - 2012 QLogic Corporation. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
@@ -49,6 +50,7 @@
49#include "qib_qsfp.h" 50#include "qib_qsfp.h"
50 51
51#include "qib_mad.h" 52#include "qib_mad.h"
53#include "qib_verbs.h"
52 54
53static void qib_setup_7322_setextled(struct qib_pportdata *, u32); 55static void qib_setup_7322_setextled(struct qib_pportdata *, u32);
54static void qib_7322_handle_hwerrors(struct qib_devdata *, char *, size_t); 56static void qib_7322_handle_hwerrors(struct qib_devdata *, char *, size_t);
@@ -5151,15 +5153,11 @@ static void try_7322_ipg(struct qib_pportdata *ppd)
5151 goto retry; 5153 goto retry;
5152 5154
5153 if (!ibp->smi_ah) { 5155 if (!ibp->smi_ah) {
5154 struct ib_ah_attr attr;
5155 struct ib_ah *ah; 5156 struct ib_ah *ah;
5156 5157
5157 memset(&attr, 0, sizeof attr); 5158 ah = qib_create_qp0_ah(ibp, be16_to_cpu(IB_LID_PERMISSIVE));
5158 attr.dlid = be16_to_cpu(IB_LID_PERMISSIVE);
5159 attr.port_num = ppd->port;
5160 ah = ib_create_ah(ibp->qp0->ibqp.pd, &attr);
5161 if (IS_ERR(ah)) 5159 if (IS_ERR(ah))
5162 ret = -EINVAL; 5160 ret = PTR_ERR(ah);
5163 else { 5161 else {
5164 send_buf->ah = ah; 5162 send_buf->ah = ah;
5165 ibp->smi_ah = to_iah(ah); 5163 ibp->smi_ah = to_iah(ah);
diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index 43390217a026..6e20b58b90b6 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation. 2 * Copyright (c) 2012 Intel Corporation. All rights reserved.
3 * All rights reserved. 3 * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
@@ -90,14 +90,10 @@ static void qib_send_trap(struct qib_ibport *ibp, void *data, unsigned len)
90 if (!ibp->sm_ah) { 90 if (!ibp->sm_ah) {
91 if (ibp->sm_lid != be16_to_cpu(IB_LID_PERMISSIVE)) { 91 if (ibp->sm_lid != be16_to_cpu(IB_LID_PERMISSIVE)) {
92 struct ib_ah *ah; 92 struct ib_ah *ah;
93 struct ib_ah_attr attr;
94 93
95 memset(&attr, 0, sizeof attr); 94 ah = qib_create_qp0_ah(ibp, ibp->sm_lid);
96 attr.dlid = ibp->sm_lid;
97 attr.port_num = ppd_from_ibp(ibp)->port;
98 ah = ib_create_ah(ibp->qp0->ibqp.pd, &attr);
99 if (IS_ERR(ah)) 95 if (IS_ERR(ah))
100 ret = -EINVAL; 96 ret = PTR_ERR(ah);
101 else { 97 else {
102 send_buf->ah = ah; 98 send_buf->ah = ah;
103 ibp->sm_ah = to_iah(ah); 99 ibp->sm_ah = to_iah(ah);
diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c
index 693041b076f0..4850d03870c2 100644
--- a/drivers/infiniband/hw/qib/qib_qp.c
+++ b/drivers/infiniband/hw/qib/qib_qp.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation. 2 * Copyright (c) 2012 Intel Corporation. All rights reserved.
3 * All rights reserved. 3 * Copyright (c) 2006 - 2012 QLogic Corporation. * All rights reserved.
4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
@@ -250,23 +250,33 @@ static void remove_qp(struct qib_ibdev *dev, struct qib_qp *qp)
250 250
251 spin_lock_irqsave(&dev->qpt_lock, flags); 251 spin_lock_irqsave(&dev->qpt_lock, flags);
252 252
253 if (ibp->qp0 == qp) { 253 if (rcu_dereference_protected(ibp->qp0,
254 lockdep_is_held(&dev->qpt_lock)) == qp) {
254 atomic_dec(&qp->refcount); 255 atomic_dec(&qp->refcount);
255 rcu_assign_pointer(ibp->qp0, NULL); 256 rcu_assign_pointer(ibp->qp0, NULL);
256 } else if (ibp->qp1 == qp) { 257 } else if (rcu_dereference_protected(ibp->qp1,
258 lockdep_is_held(&dev->qpt_lock)) == qp) {
257 atomic_dec(&qp->refcount); 259 atomic_dec(&qp->refcount);
258 rcu_assign_pointer(ibp->qp1, NULL); 260 rcu_assign_pointer(ibp->qp1, NULL);
259 } else { 261 } else {
260 struct qib_qp *q, **qpp; 262 struct qib_qp *q;
263 struct qib_qp __rcu **qpp;
261 264
262 qpp = &dev->qp_table[n]; 265 qpp = &dev->qp_table[n];
263 for (; (q = *qpp) != NULL; qpp = &q->next) 266 q = rcu_dereference_protected(*qpp,
267 lockdep_is_held(&dev->qpt_lock));
268 for (; q; qpp = &q->next) {
264 if (q == qp) { 269 if (q == qp) {
265 atomic_dec(&qp->refcount); 270 atomic_dec(&qp->refcount);
266 rcu_assign_pointer(*qpp, qp->next); 271 *qpp = qp->next;
267 qp->next = NULL; 272 rcu_assign_pointer(qp->next, NULL);
273 q = rcu_dereference_protected(*qpp,
274 lockdep_is_held(&dev->qpt_lock));
268 break; 275 break;
269 } 276 }
277 q = rcu_dereference_protected(*qpp,
278 lockdep_is_held(&dev->qpt_lock));
279 }
270 } 280 }
271 281
272 spin_unlock_irqrestore(&dev->qpt_lock, flags); 282 spin_unlock_irqrestore(&dev->qpt_lock, flags);
@@ -302,10 +312,12 @@ unsigned qib_free_all_qps(struct qib_devdata *dd)
302 312
303 spin_lock_irqsave(&dev->qpt_lock, flags); 313 spin_lock_irqsave(&dev->qpt_lock, flags);
304 for (n = 0; n < dev->qp_table_size; n++) { 314 for (n = 0; n < dev->qp_table_size; n++) {
305 qp = dev->qp_table[n]; 315 qp = rcu_dereference_protected(dev->qp_table[n],
316 lockdep_is_held(&dev->qpt_lock));
306 rcu_assign_pointer(dev->qp_table[n], NULL); 317 rcu_assign_pointer(dev->qp_table[n], NULL);
307 318
308 for (; qp; qp = qp->next) 319 for (; qp; qp = rcu_dereference_protected(qp->next,
320 lockdep_is_held(&dev->qpt_lock)))
309 qp_inuse++; 321 qp_inuse++;
310 } 322 }
311 spin_unlock_irqrestore(&dev->qpt_lock, flags); 323 spin_unlock_irqrestore(&dev->qpt_lock, flags);
@@ -337,7 +349,8 @@ struct qib_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn)
337 unsigned n = qpn_hash(dev, qpn); 349 unsigned n = qpn_hash(dev, qpn);
338 350
339 rcu_read_lock(); 351 rcu_read_lock();
340 for (qp = dev->qp_table[n]; rcu_dereference(qp); qp = qp->next) 352 for (qp = rcu_dereference(dev->qp_table[n]); qp;
353 qp = rcu_dereference(qp->next))
341 if (qp->ibqp.qp_num == qpn) 354 if (qp->ibqp.qp_num == qpn)
342 break; 355 break;
343 } 356 }
diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c
index 59cdea345a82..03ace0650a8f 100644
--- a/drivers/infiniband/hw/qib/qib_verbs.c
+++ b/drivers/infiniband/hw/qib/qib_verbs.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation. 2 * Copyright (c) 2012 Intel Corporation. All rights reserved.
3 * All rights reserved. 3 * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
@@ -1845,6 +1845,23 @@ bail:
1845 return ret; 1845 return ret;
1846} 1846}
1847 1847
1848struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid)
1849{
1850 struct ib_ah_attr attr;
1851 struct ib_ah *ah = ERR_PTR(-EINVAL);
1852 struct qib_qp *qp0;
1853
1854 memset(&attr, 0, sizeof attr);
1855 attr.dlid = dlid;
1856 attr.port_num = ppd_from_ibp(ibp)->port;
1857 rcu_read_lock();
1858 qp0 = rcu_dereference(ibp->qp0);
1859 if (qp0)
1860 ah = ib_create_ah(qp0->ibqp.pd, &attr);
1861 rcu_read_unlock();
1862 return ah;
1863}
1864
1848/** 1865/**
1849 * qib_destroy_ah - destroy an address handle 1866 * qib_destroy_ah - destroy an address handle
1850 * @ibah: the AH to destroy 1867 * @ibah: the AH to destroy
@@ -2060,7 +2077,7 @@ int qib_register_ib_device(struct qib_devdata *dd)
2060 spin_lock_init(&dev->lk_table.lock); 2077 spin_lock_init(&dev->lk_table.lock);
2061 dev->lk_table.max = 1 << ib_qib_lkey_table_size; 2078 dev->lk_table.max = 1 << ib_qib_lkey_table_size;
2062 lk_tab_size = dev->lk_table.max * sizeof(*dev->lk_table.table); 2079 lk_tab_size = dev->lk_table.max * sizeof(*dev->lk_table.table);
2063 dev->lk_table.table = (struct qib_mregion **) 2080 dev->lk_table.table = (struct qib_mregion __rcu **)
2064 __get_free_pages(GFP_KERNEL, get_order(lk_tab_size)); 2081 __get_free_pages(GFP_KERNEL, get_order(lk_tab_size));
2065 if (dev->lk_table.table == NULL) { 2082 if (dev->lk_table.table == NULL) {
2066 ret = -ENOMEM; 2083 ret = -ENOMEM;
diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h
index 1293133f28cb..61fad05328ca 100644
--- a/drivers/infiniband/hw/qib/qib_verbs.h
+++ b/drivers/infiniband/hw/qib/qib_verbs.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation. 2 * Copyright (c) 2012 Intel Corporation. All rights reserved.
3 * All rights reserved. 3 * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
@@ -420,7 +420,7 @@ struct qib_qp {
420 /* read mostly fields above and below */ 420 /* read mostly fields above and below */
421 struct ib_ah_attr remote_ah_attr; 421 struct ib_ah_attr remote_ah_attr;
422 struct ib_ah_attr alt_ah_attr; 422 struct ib_ah_attr alt_ah_attr;
423 struct qib_qp *next; /* link list for QPN hash table */ 423 struct qib_qp __rcu *next; /* link list for QPN hash table */
424 struct qib_swqe *s_wq; /* send work queue */ 424 struct qib_swqe *s_wq; /* send work queue */
425 struct qib_mmap_info *ip; 425 struct qib_mmap_info *ip;
426 struct qib_ib_header *s_hdr; /* next packet header to send */ 426 struct qib_ib_header *s_hdr; /* next packet header to send */
@@ -659,8 +659,8 @@ struct qib_opcode_stats {
659}; 659};
660 660
661struct qib_ibport { 661struct qib_ibport {
662 struct qib_qp *qp0; 662 struct qib_qp __rcu *qp0;
663 struct qib_qp *qp1; 663 struct qib_qp __rcu *qp1;
664 struct ib_mad_agent *send_agent; /* agent for SMI (traps) */ 664 struct ib_mad_agent *send_agent; /* agent for SMI (traps) */
665 struct qib_ah *sm_ah; 665 struct qib_ah *sm_ah;
666 struct qib_ah *smi_ah; 666 struct qib_ah *smi_ah;
@@ -743,7 +743,7 @@ struct qib_ibdev {
743 struct list_head memwait; /* list for wait kernel memory */ 743 struct list_head memwait; /* list for wait kernel memory */
744 struct list_head txreq_free; 744 struct list_head txreq_free;
745 struct timer_list mem_timer; 745 struct timer_list mem_timer;
746 struct qib_qp **qp_table; 746 struct qib_qp __rcu **qp_table;
747 struct qib_pio_header *pio_hdrs; 747 struct qib_pio_header *pio_hdrs;
748 dma_addr_t pio_hdrs_phys; 748 dma_addr_t pio_hdrs_phys;
749 /* list of QPs waiting for RNR timer */ 749 /* list of QPs waiting for RNR timer */
@@ -937,6 +937,8 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
937 937
938int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr); 938int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
939 939
940struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid);
941
940void qib_rc_rnr_retry(unsigned long arg); 942void qib_rc_rnr_retry(unsigned long arg);
941 943
942void qib_rc_send_complete(struct qib_qp *qp, struct qib_ib_header *hdr); 944void qib_rc_send_complete(struct qib_qp *qp, struct qib_ib_header *hdr);