IB/mthca: fix page shift calculation in mthca_reg_phys_mr()
Subsystems (2)
PATCH 1/7 IB/mthca: fix page shift calculation in mthca_reg_phys_mr()
For all pages except possibly the last one, the byte beyond the buffer end must be page aligned. Therefore, when computing the page shift to use, OR the end addresses of the buffers as well as the start addresses into the mask we check.
---
drivers/infiniband/hw/mthca/mthca_provider.c | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-)
6627fa662e86c400284b64c13661fdf6bff05983
drivers/infiniband/hw/mthca/mthca_provider.c +7 -11
@@ -783,24 +783,20 @@ static struct ib_mr *mthca_reg_phys_mr(sif ((*iova_start & ~PAGE_MASK ) != (buffer_list[0 ].addr & ~PAGE_MASK ))return ERR_PTR (-EINVAL ); -if (num_phys_buf >1 && - ((buffer_list[0 ].addr + buffer_list[0 ].size) & ~PAGE_MASK )) -return ERR_PTR (-EINVAL ); - mask =0 ; total_size =0 ;for (i =0 ; i < num_phys_buf; ++i) { -if (i !=0 && buffer_list[i].addr & ~PAGE_MASK ) -return ERR_PTR (-EINVAL ); -if (i !=0 && i != num_phys_buf -1 && - (buffer_list[i].size & ~PAGE_MASK )) -return ERR_PTR (-EINVAL ); +if (i !=0 ) + mask |= buffer_list[i].addr; +if (i != num_phys_buf -1 ) + mask |= buffer_list[i].addr + buffer_list[i].size; total_size += buffer_list[i].size; -if (i >0 ) - mask |= buffer_list[i].addr; } +if (mask & ~PAGE_MASK ) +return ERR_PTR (-EINVAL ); +/* Find largest page shift we can use to cover buffers */ for (shift =PAGE_SHIFT ; shift <31 ; ++shift)if (num_phys_buf >1 ) {
Signature · 1 line
1.0.7
PATCH 2/7 IB/mthca: prevent event queue overrun
I am seeing EQ overruns in SDP stress tests: if the CQ completion handler arms a CQ, this could generate more EQEs, so that EQ will never get empty and consumer index will never get updated.
This is similiar to what we have with command interface:
/*
* cmd_event() may add more commands.
* The card will think the queue has overflowed if
* we don't tell it we've been processing events. */
However, for completion events, we *don't* want to update the consumer index on each event. So, perform EQ doorbell coalescing: allocate EQs with some spare EQEs, and update once we run out of them.
The value 0x80 was selected to avoid any performance impact.
---
drivers/infiniband/hw/mthca/mthca_eq.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
92898522e3ee1a0ba54140aad1974d9e868f74ae
drivers/infiniband/hw/mthca/mthca_eq.c +15 -13
@@ -45,6 +45,7 @@enum {MTHCA_NUM_ASYNC_EQE =0x80 ,MTHCA_NUM_CMD_EQE =0x80 , +MTHCA_NUM_SPARE_EQE =0x80 ,MTHCA_EQ_ENTRY_SIZE =0x20 };
@@ -277,11 +278,10 @@ static int mthca_eq_int(struct mthca_dev {struct mthca_eqe *eqe;int disarm_cqn; -int eqes_found =0 ; +int eqes_found =0 ; +int set_ci =0 ;while ((eqe =next_eqe_sw (eq))) { -int set_ci =0 ; -/* * Make sure we read EQ entry contents after we've * checked the ownership bit.
@@ -345,12 +345,6 @@ static int mthca_eq_int(struct mthca_devbe16_to_cpu (eqe->event.cmd.token), eqe->event.cmd.status, be64_to_cpu(eqe->event.cmd.out_param)); -/* -* cmd_event() may add more commands. -* The card will think the queue has overflowed if -* we don't tell it we've been processing events. -*/ - set_ci =1 ;break ;case MTHCA_EVENT_TYPE_PORT_CHANGE :
@@ -385,8 +379,16 @@ static int mthca_eq_int(struct mthca_devset_eqe_hw (eqe); ++eq->cons_index; eqes_found =1 ; + ++set_ci; -if (unlikely (set_ci)) { +/* +* The HCA will think the queue has overflowed if we +* don't tell it we've been processing events. We +* create our EQs with MTHCA_NUM_SPARE_EQE extra +* entries, so we must update our consumer index at +* least that often. +*/ +if (unlikely (set_ci >=MTHCA_NUM_SPARE_EQE )) {/* * Conditional on hca_type is OK here because * this is a rare case, not the fast path.
@@ -862,19 +864,19 @@ int __devinit mthca_init_eq_table(struct intr = (dev->mthca_flags &MTHCA_FLAG_MSI ) ?128 : dev->eq_table.inta_pin; - err =mthca_create_eq (dev, dev->limits.num_cqs, + err =mthca_create_eq (dev, dev->limits.num_cqs +MTHCA_NUM_SPARE_EQE , (dev->mthca_flags &MTHCA_FLAG_MSI_X ) ?128 : intr, &dev->eq_table.eq[MTHCA_EQ_COMP ]);if (err) goto err_out_unmap; - err =mthca_create_eq (dev,MTHCA_NUM_ASYNC_EQE , + err =mthca_create_eq (dev,MTHCA_NUM_ASYNC_EQE +MTHCA_NUM_SPARE_EQE , (dev->mthca_flags &MTHCA_FLAG_MSI_X ) ?129 : intr, &dev->eq_table.eq[MTHCA_EQ_ASYNC ]);if (err) goto err_out_comp; - err =mthca_create_eq (dev,MTHCA_NUM_CMD_EQE , + err =mthca_create_eq (dev,MTHCA_NUM_CMD_EQE +MTHCA_NUM_SPARE_EQE , (dev->mthca_flags &MTHCA_FLAG_MSI_X ) ?130 : intr, &dev->eq_table.eq[MTHCA_EQ_CMD ]);if (err)
Signature · 1 line
1.0.7
PATCH 3/7 IB/mthca: kzalloc conversions
Convert kmalloc()/memset(,0,) pairs to kzalloc().
---
drivers/infiniband/hw/mthca/mthca_provider.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
105e50a5e8f184af31daffce4d7bfd7771fe213f
drivers/infiniband/hw/mthca/mthca_provider.c +4 -8
@@ -55,7 +55,7 @@ static int mthca_query_device(struct ib_u8 status; - in_mad =kmalloc (sizeof *in_mad,GFP_KERNEL ); + in_mad =kzalloc (sizeof *in_mad,GFP_KERNEL ); out_mad =kmalloc (sizeof *out_mad,GFP_KERNEL );if (!in_mad || !out_mad) goto out;
@@ -64,7 +64,6 @@ static int mthca_query_device(struct ib_ props->fw_ver = mdev->fw_ver; -memset (in_mad,0 ,sizeof *in_mad); in_mad->base_version =1 ; in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; in_mad->class_version =1 ;
@@ -128,14 +127,13 @@ static int mthca_query_port(struct ib_deint err = -ENOMEM ;u8 status; - in_mad =kmalloc (sizeof *in_mad,GFP_KERNEL ); + in_mad =kzalloc (sizeof *in_mad,GFP_KERNEL ); out_mad =kmalloc (sizeof *out_mad,GFP_KERNEL );if (!in_mad || !out_mad) goto out;memset (props,0 ,sizeof *props); -memset (in_mad,0 ,sizeof *in_mad); in_mad->base_version =1 ; in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; in_mad->class_version =1 ;
@@ -220,12 +218,11 @@ static int mthca_query_pkey(struct ib_deint err = -ENOMEM ;u8 status; - in_mad =kmalloc (sizeof *in_mad,GFP_KERNEL ); + in_mad =kzalloc (sizeof *in_mad,GFP_KERNEL ); out_mad =kmalloc (sizeof *out_mad,GFP_KERNEL );if (!in_mad || !out_mad) goto out; -memset (in_mad,0 ,sizeof *in_mad); in_mad->base_version =1 ; in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; in_mad->class_version =1 ;
@@ -259,12 +256,11 @@ static int mthca_query_gid(struct ib_devint err = -ENOMEM ;u8 status; - in_mad =kmalloc (sizeof *in_mad,GFP_KERNEL ); + in_mad =kzalloc (sizeof *in_mad,GFP_KERNEL ); out_mad =kmalloc (sizeof *out_mad,GFP_KERNEL );if (!in_mad || !out_mad) goto out; -memset (in_mad,0 ,sizeof *in_mad); in_mad->base_version =1 ; in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; in_mad->class_version =1 ;
Signature · 1 line
1.0.7
PATCH 4/7 IB/mthca: Factor common MAD initialization code
Factor out common code for initializing MAD packets, which is shared by many query routines in mthca_provider.c, into init_query_mad().
add/remove: 1/0 grow/shrink: 0/4 up/down: 16/-44 (-28)
function old new deltainit_query_mad - 16 +16
mthca_query_port 521 518 -3 mthca_query_pkey 301 294 -7 mthca_query_device 648 641 -7 mthca_query_gid 453 426 -27
---
drivers/infiniband/hw/mthca/mthca_provider.c | 52 +++++++++++--------------- 1 files changed, 22 insertions(+), 30 deletions(-)
87635b71b544563f29050a9cecaa12b5d2a3e34a
drivers/infiniband/hw/mthca/mthca_provider.c +22 -30
@@ -45,6 +45,14 @@#include "mthca_user.h" #include "mthca_memfree.h" +static void init_query_mad (struct ib_smp *mad) +{ + mad->base_version =1 ; + mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; + mad->class_version =1 ; + mad->method =IB_MGMT_METHOD_GET ; +} +static int mthca_query_device (struct ib_device *ibdev,struct ib_device_attr *props) {
@@ -64,11 +72,8 @@ static int mthca_query_device(struct ib_ props->fw_ver = mdev->fw_ver; - in_mad->base_version =1 ; - in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; - in_mad->class_version =1 ; - in_mad->method =IB_MGMT_METHOD_GET ; - in_mad->attr_id =IB_SMP_ATTR_NODE_INFO ; +init_query_mad (in_mad); + in_mad->attr_id =IB_SMP_ATTR_NODE_INFO ; err = mthca_MAD_IFC(mdev, 1, 1, 1, NULL, NULL, in_mad, out_mad,
@@ -134,12 +139,9 @@ static int mthca_query_port(struct ib_dememset (props,0 ,sizeof *props); - in_mad->base_version =1 ; - in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; - in_mad->class_version =1 ; - in_mad->method =IB_MGMT_METHOD_GET ; - in_mad->attr_id =IB_SMP_ATTR_PORT_INFO ; - in_mad->attr_mod =cpu_to_be32 (port); +init_query_mad (in_mad); + in_mad->attr_id =IB_SMP_ATTR_PORT_INFO ; + in_mad->attr_mod =cpu_to_be32 (port); err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad,
@@ -223,12 +225,9 @@ static int mthca_query_pkey(struct ib_deif (!in_mad || !out_mad) goto out; - in_mad->base_version =1 ; - in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; - in_mad->class_version =1 ; - in_mad->method =IB_MGMT_METHOD_GET ; - in_mad->attr_id =IB_SMP_ATTR_PKEY_TABLE ; - in_mad->attr_mod =cpu_to_be32 (index /32 ); +init_query_mad (in_mad); + in_mad->attr_id =IB_SMP_ATTR_PKEY_TABLE ; + in_mad->attr_mod =cpu_to_be32 (index /32 ); err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad,
@@ -261,12 +260,9 @@ static int mthca_query_gid(struct ib_devif (!in_mad || !out_mad) goto out; - in_mad->base_version =1 ; - in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; - in_mad->class_version =1 ; - in_mad->method =IB_MGMT_METHOD_GET ; - in_mad->attr_id =IB_SMP_ATTR_PORT_INFO ; - in_mad->attr_mod =cpu_to_be32 (port); +init_query_mad (in_mad); + in_mad->attr_id =IB_SMP_ATTR_PORT_INFO ; + in_mad->attr_mod =cpu_to_be32 (port); err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad,
@@ -280,13 +276,9 @@ static int mthca_query_gid(struct ib_devmemcpy (gid->raw, out_mad->data +8 ,8 ); -memset (in_mad,0 ,sizeof *in_mad); - in_mad->base_version =1 ; - in_mad->mgmt_class =IB_MGMT_CLASS_SUBN_LID_ROUTED ; - in_mad->class_version =1 ; - in_mad->method =IB_MGMT_METHOD_GET ; - in_mad->attr_id =IB_SMP_ATTR_GUID_INFO ; - in_mad->attr_mod =cpu_to_be32 (index /8 ); +init_query_mad (in_mad); + in_mad->attr_id =IB_SMP_ATTR_GUID_INFO ; + in_mad->attr_mod =cpu_to_be32 (index /8 ); err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad,
Signature · 1 line
1.0.7
PATCH 5/7 IB: Add node_guid to struct ib_device
Add a node_guid field to struct ib_device. It is the responsibility of the low-level driver to initialize this field before registering a device with the midlayer. Convert everyone to looking at this field instead of calling ib_query_device() when all they want is the node GUID, and remove the node_guid field from struct ib_device_attr.
---
drivers/infiniband/core/cm.c | 29 +++---------------- drivers/infiniband/core/sysfs.c | 22 +++----------- drivers/infiniband/core/uverbs_cmd.c | 2 + drivers/infiniband/hw/mthca/mthca_provider.c | 40 +++++++++++++++++++++++++- drivers/infiniband/ulp/srp/ib_srp.c | 23 +++------------ include/rdma/ib_verbs.h | 2 + 6 files changed, 54 insertions(+), 64 deletions(-)
cf311cd49a78f1e431787068cc31d29d06a415e6
drivers/infiniband/core/cm.c +5 -24
@@ -3163,22 +3163,6 @@ int ib_cm_init_qp_attr(struct ib_cm_id * }EXPORT_SYMBOL (ib_cm_init_qp_attr); -static __be64 cm_get_ca_guid (struct ib_device *device) -{ -struct ib_device_attr *device_attr; -__be64 guid; -int ret; - - device_attr =kmalloc (sizeof *device_attr,GFP_KERNEL ); -if (!device_attr) -return 0 ; - - ret =ib_query_device (device, device_attr); - guid = ret ?0 : device_attr->node_guid; -kfree (device_attr); -return guid; -} -static void cm_add_one (struct ib_device *device) {struct cm_device *cm_dev;
@@ -3200,9 +3184,7 @@ static void cm_add_one(struct ib_devicereturn ; cm_dev->device = device; - cm_dev->ca_guid =cm_get_ca_guid (device); -if (!cm_dev->ca_guid) - goto error1; + cm_dev->ca_guid = device->node_guid;set_bit (IB_MGMT_METHOD_SEND , reg_req.method_mask);for (i =1 ; i <= device->phys_port_cnt; i++) {
@@ -3217,11 +3199,11 @@ static void cm_add_one(struct ib_device cm_recv_handler, port);if (IS_ERR (port->mad_agent)) - goto error2; + goto error1; ret =ib_modify_port (device, i,0 , &port_modify);if (ret) - goto error3; + goto error2; }ib_set_client_data (device, &cm_client, cm_dev);
@@ -3230,9 +3212,9 @@ static void cm_add_one(struct ib_devicewrite_unlock_irqrestore (&cm.device_lock, flags);return ; -error3: -ib_unregister_mad_agent (port->mad_agent); error2: +ib_unregister_mad_agent (port->mad_agent); +error1: port_modify.set_port_cap_mask =0 ; port_modify.clr_port_cap_mask =IB_PORT_CM_SUP ;while (--i) {
@@ -3240,7 +3222,6 @@ error2:ib_modify_port (device, port->port_num,0 , &port_modify);ib_unregister_mad_agent (port->mad_agent); } -error1:kfree (cm_dev); }
drivers/infiniband/core/sysfs.c +5 -17
@@ -445,13 +445,7 @@ static int ib_device_uevent(struct classreturn -ENOMEM ;/* -* It might be nice to pass the node GUID with the event, but -* right now the only way to get it is to query the device -* provider, and this can crash during device removal because -* we are will be running after driver removal has started. -* We could add a node_guid field to struct ib_device, or we -* could just let userspace read the node GUID from sysfs when -* devices are added. +* It would be nice to pass the node GUID with the event... */ envp[i] =NULL ;
@@ -623,21 +617,15 @@ static ssize_t show_sys_image_guid(strucstatic ssize_t show_node_guid (struct class_device *cdev,char *buf) { struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); -struct ib_device_attr attr; -ssize_t ret;if (!ibdev_is_alive (dev))return -ENODEV ; - ret =ib_query_device (dev, &attr); -if (ret) -return ret; -return sprintf (buf,"%04x:%04x:%04x:%04x\n" , -be16_to_cpu (((__be16 *) &attr.node_guid)[0 ]), -be16_to_cpu (((__be16 *) &attr.node_guid)[1 ]), -be16_to_cpu (((__be16 *) &attr.node_guid)[2 ]), -be16_to_cpu (((__be16 *) &attr.node_guid)[3 ])); +be16_to_cpu (((__be16 *) &dev->node_guid)[0 ]), +be16_to_cpu (((__be16 *) &dev->node_guid)[1 ]), +be16_to_cpu (((__be16 *) &dev->node_guid)[2 ]), +be16_to_cpu (((__be16 *) &dev->node_guid)[3 ])); } static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
drivers/infiniband/core/uverbs_cmd.c +1 -1
@@ -157,7 +157,7 @@ ssize_t ib_uverbs_query_device(struct ibmemset (&resp,0 ,sizeof resp); resp.fw_ver = attr.fw_ver; - resp.node_guid = attr.node_guid; + resp.node_guid = file->device->ib_dev->node_guid; resp.sys_image_guid = attr.sys_image_guid; resp.max_mr_size = attr.max_mr_size; resp.page_size_cap = attr.page_size_cap;
drivers/infiniband/hw/mthca/mthca_provider.c +38 -2
@@ -33,7 +33,7 @@* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * -* $Id: mthca_provider.c 1397 2004-12-28 05:09:00Z roland $ +* $Id: mthca_provider.c 4859 2006-01-09 21:55:10Z roland $ */ #include <rdma/ib_smi.h>
@@ -91,7 +91,6 @@ static int mthca_query_device(struct ib_ props->vendor_part_id =be16_to_cpup ((__be16 *) (out_mad->data +30 )); props->hw_ver =be32_to_cpup ((__be32 *) (out_mad->data +32 ));memcpy (&props->sys_image_guid, out_mad->data +4 ,8 ); -memcpy (&props->node_guid, out_mad->data +12 ,8 ); props->max_mr_size = ~0ull ; props->page_size_cap = mdev->limits.page_size_cap;
@@ -1054,11 +1053,48 @@ static struct class_device_attribute *mt &class_device_attr_board_id }; +static int mthca_init_node_data (struct mthca_dev *dev) +{ +struct ib_smp *in_mad =NULL ; +struct ib_smp *out_mad =NULL ; +int err = -ENOMEM ; +u8 status; + + in_mad =kzalloc (sizeof *in_mad,GFP_KERNEL ); + out_mad =kmalloc (sizeof *out_mad,GFP_KERNEL ); +if (!in_mad || !out_mad) + goto out; + +init_query_mad (in_mad); + in_mad->attr_id =IB_SMP_ATTR_NODE_INFO ; + + err =mthca_MAD_IFC (dev,1 ,1 , +1 ,NULL ,NULL , in_mad, out_mad, + &status); +if (err) + goto out; +if (status) { + err = -EINVAL ; + goto out; + } + +memcpy (&dev->ib_dev.node_guid, out_mad->data +12 ,8 ); + +out: +kfree (in_mad); +kfree (out_mad); +return err; +} +int mthca_register_device (struct mthca_dev *dev) {int ret;int i; + ret =mthca_init_node_data (dev); +if (ret) +return ret; +strlcpy (dev->ib_dev.name,"mthca%d" ,IB_DEVICE_NAME_MAX ); dev->ib_dev.owner =THIS_MODULE ;
drivers/infiniband/ulp/srp/ib_srp.c +4 -19
@@ -1516,8 +1516,7 @@ static ssize_t show_port(struct class_de static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); -static struct srp_host *srp_add_port (struct ib_device *device, -__be64 node_guid,u8 port) +static struct srp_host *srp_add_port (struct ib_device *device,u8 port) {struct srp_host *host;
@@ -1532,7 +1531,7 @@ static struct srp_host *srp_add_port(str host->port = port; host->initiator_port_id[7 ] = port; -memcpy (host->initiator_port_id +8 , &node_guid,8 ); +memcpy (host->initiator_port_id +8 , &device->node_guid,8 ); host->pd =ib_alloc_pd (device);if (IS_ERR (host->pd))
@@ -1580,22 +1579,11 @@ static void srp_add_one(struct ib_device {struct list_head *dev_list;struct srp_host *host; -struct ib_device_attr *dev_attr;int s, e, p; - dev_attr =kmalloc (sizeof *dev_attr,GFP_KERNEL ); -if (!dev_attr) -return ; - -if (ib_query_device (device, dev_attr)) { - printk(KERN_WARNING PFX "Couldn't query node GUID for %s.\n", - device->name); - goto out; - } - dev_list =kmalloc (sizeof *dev_list,GFP_KERNEL );if (!dev_list) - goto out; +return ;INIT_LIST_HEAD (dev_list);
@@ -1608,15 +1596,12 @@ static void srp_add_one(struct ib_device }for (p = s; p <= e; ++p) { - host =srp_add_port (device, dev_attr->node_guid, p); + host =srp_add_port (device, p);if (host)list_add_tail (&host->list, dev_list); }ib_set_client_data (device, &srp_client, dev_list); - -out: -kfree (dev_attr); }static void srp_remove_one (struct ib_device *device)
include/rdma/ib_verbs.h +1 -1
@@ -88,7 +88,6 @@ enum ib_atomic_cap {struct ib_device_attr {u64 fw_ver; -__be64 node_guid;__be64 sys_image_guid;u64 max_mr_size;u64 page_size_cap;
@@ -951,6 +950,7 @@ struct ib_device {u64 uverbs_cmd_mask;int uverbs_abi_ver; +__be64 node_guid;u8 node_type;u8 phys_port_cnt; };
Signature · 1 line
1.0.7
PATCH 6/7 IPoIB: Fix error path in ipoib_mcast_dev_flush()
Don't leak memory on allocation failure for broadcast mcast group. Also, print a warning to match handling for other mcast groups.
---
drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
70b4c8cdc168bb5d18e23fd205c4ede1b756a8b2
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +5 -3
@@ -780,9 +780,11 @@ void ipoib_mcast_dev_flush(struct net_de &priv->multicast_tree);list_add_tail (&priv->broadcast->list, &remove_list); - } - - priv->broadcast = nmcast; + priv->broadcast = nmcast; + }else +ipoib_warn (priv,"could not reallocate broadcast group " +IPOIB_GID_FMT "\n" , +IPOIB_GID_ARG (priv->broadcast->mcmember.mgid)); }spin_unlock_irqrestore (&priv->lock, flags);
Signature · 1 line
1.0.7
PATCH 7/7 IPoIB: Fix address handle refcounting for multicast groups
Multiple ipoib_neigh structures on mcast->neigh_list may point to the same ah. This means that ipoib_mcast_free() can't just make a list of ah structs to free, since this might end up trying to add the same ah to the list more than once. Handle this in ipoib_multicast.c in the same way as it is handled in ipoib_main.c for struct ipoib_path.
---
drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
97460df37ea3335ca11562568932c9f9facfecdb
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +7 -6
@@ -97,8 +97,6 @@ static void ipoib_mcast_free(struct ipoistruct ipoib_dev_priv *priv =netdev_priv (dev);struct ipoib_neigh *neigh, *tmp;unsigned long flags; -LIST_HEAD (ah_list); -struct ipoib_ah *ah, *tah; ipoib_dbg_mcast(netdev_priv(dev), "deleting multicast group " IPOIB_GID_FMT "\n",
@@ -107,8 +105,14 @@ static void ipoib_mcast_free(struct ipoispin_lock_irqsave (&priv->lock, flags);list_for_each_entry_safe (neigh, tmp, &mcast->neigh_list, list) { +/* +* It's safe to call ipoib_put_ah() inside priv->lock +* here, because we know that mcast->ah will always +* hold one more reference, so ipoib_put_ah() will +* never do more than decrement the ref count. +*/ if (neigh->ah) -list_add_tail (&neigh->ah->list, &ah_list); +ipoib_put_ah (neigh->ah); *to_ipoib_neigh (neigh->neighbour) =NULL ; neigh->neighbour->ops->destructor =NULL ;kfree (neigh);
@@ -116,9 +120,6 @@ static void ipoib_mcast_free(struct ipoispin_unlock_irqrestore (&priv->lock, flags); -list_for_each_entry_safe (ah, tah, &ah_list, list) -ipoib_put_ah (ah); -if (mcast->ah)ipoib_put_ah (mcast->ah);
Signature · 1 line
1.0.7