aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/mad_priv.h
diff options
context:
space:
mode:
authorwilly@infradead.org <willy@infradead.org>2018-06-13 05:34:03 -0700
committerJason Gunthorpe <jgg@mellanox.com>2018-06-18 11:22:54 -0600
commit9a41e38a467c06a0c48369970ce5a9f790edd64d (patch)
tree382d5e0923c4a76b8884e5b1407a818b9d5986ac /drivers/infiniband/core/mad_priv.h
parentIDR: Expose the XArray lock (diff)
downloadlinux-dev-9a41e38a467c06a0c48369970ce5a9f790edd64d.tar.xz
linux-dev-9a41e38a467c06a0c48369970ce5a9f790edd64d.zip
IB/mad: Use IDR for agent IDs
Allocate agent IDs from a global IDR instead of an atomic variable. This eliminates the possibility of reusing an ID which is already in use after 4 billion registrations. We limit the assigned ID to be less than 2^24 as the mlx4 driver uses the most significant byte of the agent ID to store the slave number. Users unlucky enough to see a collision between agent numbers and slave numbers see messages like: mlx4_ib: egress mad has non-null tid msb:1 class:4 slave:0 and the MAD layer stops working. We look up the agent under protection of the RCU lock, which means we have to free the agent using kfree_rcu, and only increment the reference counter if it is not 0. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Reported-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com> Acked-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Tested-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/mad_priv.h')
-rw-r--r--drivers/infiniband/core/mad_priv.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index 28669f6419e1..d84ae1671898 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -89,7 +89,6 @@ struct ib_rmpp_segment {
};
struct ib_mad_agent_private {
- struct list_head agent_list;
struct ib_mad_agent agent;
struct ib_mad_reg_req *reg_req;
struct ib_mad_qp_info *qp_info;
@@ -105,7 +104,10 @@ struct ib_mad_agent_private {
struct list_head rmpp_list;
atomic_t refcount;
- struct completion comp;
+ union {
+ struct completion comp;
+ struct rcu_head rcu;
+ };
};
struct ib_mad_snoop_private {
@@ -203,7 +205,6 @@ struct ib_mad_port_private {
spinlock_t reg_lock;
struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
- struct list_head agent_list;
struct workqueue_struct *wq;
struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
};