Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8aee74c8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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/cm: Improve local id allocation
  IPoIB/cm: Fix SRQ WR leak
  IB/ipoib: Fix typos in error messages
  IB/mlx4: Check if SRQ is full when posting receive
  IB/mlx4: Pass send queue sizes from userspace to kernel
  IB/mlx4: Fix check of opcode in mlx4_ib_post_send()
  mlx4_core: Fix array overrun in dump_dev_cap_flags()
  IB/mlx4: Fix RESET to RESET and RESET to ERROR transitions
  IB/mthca: Fix RESET to ERROR transition
  IB/mlx4: Set GRH:HopLimit when sending globally routed MADs
  IB/mthca: Set GRH:HopLimit when building MLX headers
  IB/mlx4: Fix check of max_qp_dest_rdma in modify QP
  IB/mthca: Fix use-after-free on device restart
  IB/ehca: Return proper error code if register_mr fails
  IPoIB: Handle P_Key table reordering
  IB/core: Use start_port() and end_port()
  IB/core: Add helpers for uncached GID and P_Key searches
  IB/ipath: Fix potential deadlock with multicast spinlocks
  IB/core: Free umem when mm is already gone
parents 080e8927 9f81036c
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -306,7 +306,9 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
	do {
	do {
		spin_lock_irqsave(&cm.lock, flags);
		spin_lock_irqsave(&cm.lock, flags);
		ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
		ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
					next_id++, &id);
					next_id, &id);
		if (!ret)
			next_id = ((unsigned) id + 1) & MAX_ID_MASK;
		spin_unlock_irqrestore(&cm.lock, flags);
		spin_unlock_irqrestore(&cm.lock, flags);
	} while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
	} while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );


+127 −8
Original line number Original line Diff line number Diff line
@@ -150,6 +150,18 @@ static int alloc_name(char *name)
	return 0;
	return 0;
}
}


static int start_port(struct ib_device *device)
{
	return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
}


static int end_port(struct ib_device *device)
{
	return (device->node_type == RDMA_NODE_IB_SWITCH) ?
		0 : device->phys_port_cnt;
}

/**
/**
 * ib_alloc_device - allocate an IB device struct
 * ib_alloc_device - allocate an IB device struct
 * @size:size of structure to allocate
 * @size:size of structure to allocate
@@ -209,6 +221,45 @@ static int add_client_context(struct ib_device *device, struct ib_client *client
	return 0;
	return 0;
}
}


static int read_port_table_lengths(struct ib_device *device)
{
	struct ib_port_attr *tprops = NULL;
	int num_ports, ret = -ENOMEM;
	u8 port_index;

	tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
	if (!tprops)
		goto out;

	num_ports = end_port(device) - start_port(device) + 1;

	device->pkey_tbl_len = kmalloc(sizeof *device->pkey_tbl_len * num_ports,
				       GFP_KERNEL);
	device->gid_tbl_len = kmalloc(sizeof *device->gid_tbl_len * num_ports,
				      GFP_KERNEL);
	if (!device->pkey_tbl_len || !device->gid_tbl_len)
		goto err;

	for (port_index = 0; port_index < num_ports; ++port_index) {
		ret = ib_query_port(device, port_index + start_port(device),
					tprops);
		if (ret)
			goto err;
		device->pkey_tbl_len[port_index] = tprops->pkey_tbl_len;
		device->gid_tbl_len[port_index]  = tprops->gid_tbl_len;
	}

	ret = 0;
	goto out;

err:
	kfree(device->gid_tbl_len);
	kfree(device->pkey_tbl_len);
out:
	kfree(tprops);
	return ret;
}

/**
/**
 * ib_register_device - Register an IB device with IB core
 * ib_register_device - Register an IB device with IB core
 * @device:Device to register
 * @device:Device to register
@@ -240,10 +291,19 @@ int ib_register_device(struct ib_device *device)
	spin_lock_init(&device->event_handler_lock);
	spin_lock_init(&device->event_handler_lock);
	spin_lock_init(&device->client_data_lock);
	spin_lock_init(&device->client_data_lock);


	ret = read_port_table_lengths(device);
	if (ret) {
		printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
		       device->name);
		goto out;
	}

	ret = ib_device_register_sysfs(device);
	ret = ib_device_register_sysfs(device);
	if (ret) {
	if (ret) {
		printk(KERN_WARNING "Couldn't register device %s with driver model\n",
		printk(KERN_WARNING "Couldn't register device %s with driver model\n",
		       device->name);
		       device->name);
		kfree(device->gid_tbl_len);
		kfree(device->pkey_tbl_len);
		goto out;
		goto out;
	}
	}


@@ -285,6 +345,9 @@ void ib_unregister_device(struct ib_device *device)


	list_del(&device->core_list);
	list_del(&device->core_list);


	kfree(device->gid_tbl_len);
	kfree(device->pkey_tbl_len);

	mutex_unlock(&device_mutex);
	mutex_unlock(&device_mutex);


	spin_lock_irqsave(&device->client_data_lock, flags);
	spin_lock_irqsave(&device->client_data_lock, flags);
@@ -507,10 +570,7 @@ int ib_query_port(struct ib_device *device,
		  u8 port_num,
		  u8 port_num,
		  struct ib_port_attr *port_attr)
		  struct ib_port_attr *port_attr)
{
{
	if (device->node_type == RDMA_NODE_IB_SWITCH) {
	if (port_num < start_port(device) || port_num > end_port(device))
		if (port_num)
			return -EINVAL;
	} else if (port_num < 1 || port_num > device->phys_port_cnt)
		return -EINVAL;
		return -EINVAL;


	return device->query_port(device, port_num, port_attr);
	return device->query_port(device, port_num, port_attr);
@@ -582,10 +642,7 @@ int ib_modify_port(struct ib_device *device,
		   u8 port_num, int port_modify_mask,
		   u8 port_num, int port_modify_mask,
		   struct ib_port_modify *port_modify)
		   struct ib_port_modify *port_modify)
{
{
	if (device->node_type == RDMA_NODE_IB_SWITCH) {
	if (port_num < start_port(device) || port_num > end_port(device))
		if (port_num)
			return -EINVAL;
	} else if (port_num < 1 || port_num > device->phys_port_cnt)
		return -EINVAL;
		return -EINVAL;


	return device->modify_port(device, port_num, port_modify_mask,
	return device->modify_port(device, port_num, port_modify_mask,
@@ -593,6 +650,68 @@ int ib_modify_port(struct ib_device *device,
}
}
EXPORT_SYMBOL(ib_modify_port);
EXPORT_SYMBOL(ib_modify_port);


/**
 * ib_find_gid - Returns the port number and GID table index where
 *   a specified GID value occurs.
 * @device: The device to query.
 * @gid: The GID value to search for.
 * @port_num: The port number of the device where the GID value was found.
 * @index: The index into the GID table where the GID was found.  This
 *   parameter may be NULL.
 */
int ib_find_gid(struct ib_device *device, union ib_gid *gid,
		u8 *port_num, u16 *index)
{
	union ib_gid tmp_gid;
	int ret, port, i;

	for (port = start_port(device); port <= end_port(device); ++port) {
		for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) {
			ret = ib_query_gid(device, port, i, &tmp_gid);
			if (ret)
				return ret;
			if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
				*port_num = port;
				if (index)
					*index = i;
				return 0;
			}
		}
	}

	return -ENOENT;
}
EXPORT_SYMBOL(ib_find_gid);

/**
 * ib_find_pkey - Returns the PKey table index where a specified
 *   PKey value occurs.
 * @device: The device to query.
 * @port_num: The port number of the device to search for the PKey.
 * @pkey: The PKey value to search for.
 * @index: The index into the PKey table where the PKey was found.
 */
int ib_find_pkey(struct ib_device *device,
		 u8 port_num, u16 pkey, u16 *index)
{
	int ret, i;
	u16 tmp_pkey;

	for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
		ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
		if (ret)
			return ret;

		if (pkey == tmp_pkey) {
			*index = i;
			return 0;
		}
	}

	return -ENOENT;
}
EXPORT_SYMBOL(ib_find_pkey);

static int __init ib_core_init(void)
static int __init ib_core_init(void)
{
{
	int ret;
	int ret;
+3 −1
Original line number Original line Diff line number Diff line
@@ -210,8 +210,10 @@ void ib_umem_release(struct ib_umem *umem)
	__ib_umem_release(umem->context->device, umem, 1);
	__ib_umem_release(umem->context->device, umem, 1);


	mm = get_task_mm(current);
	mm = get_task_mm(current);
	if (!mm)
	if (!mm) {
		kfree(umem);
		return;
		return;
	}


	diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
	diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;


+2 −5
Original line number Original line Diff line number Diff line
@@ -2050,13 +2050,10 @@ int ehca_mrmw_map_hrc_alloc(const u64 hipz_rc)
	switch (hipz_rc) {
	switch (hipz_rc) {
	case H_SUCCESS:	             /* successful completion */
	case H_SUCCESS:	             /* successful completion */
		return 0;
		return 0;
	case H_ADAPTER_PARM:         /* invalid adapter handle */
	case H_RT_PARM:              /* invalid resource type */
	case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */
	case H_NOT_ENOUGH_RESOURCES: /* insufficient resources */
	case H_MLENGTH_PARM:         /* invalid memory length */
	case H_MEM_ACCESS_PARM:      /* invalid access controls */
	case H_CONSTRAINED:          /* resource constraint */
	case H_CONSTRAINED:          /* resource constraint */
		return -EINVAL;
	case H_NO_MEM:
		return -ENOMEM;
	case H_BUSY:                 /* long busy */
	case H_BUSY:                 /* long busy */
		return -EBUSY;
		return -EBUSY;
	default:
	default:
+7 −9
Original line number Original line Diff line number Diff line
@@ -165,10 +165,9 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
{
{
	struct rb_node **n = &mcast_tree.rb_node;
	struct rb_node **n = &mcast_tree.rb_node;
	struct rb_node *pn = NULL;
	struct rb_node *pn = NULL;
	unsigned long flags;
	int ret;
	int ret;


	spin_lock_irqsave(&mcast_lock, flags);
	spin_lock_irq(&mcast_lock);


	while (*n) {
	while (*n) {
		struct ipath_mcast *tmcast;
		struct ipath_mcast *tmcast;
@@ -228,7 +227,7 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
	ret = 0;
	ret = 0;


bail:
bail:
	spin_unlock_irqrestore(&mcast_lock, flags);
	spin_unlock_irq(&mcast_lock);


	return ret;
	return ret;
}
}
@@ -289,17 +288,16 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
	struct ipath_mcast *mcast = NULL;
	struct ipath_mcast *mcast = NULL;
	struct ipath_mcast_qp *p, *tmp;
	struct ipath_mcast_qp *p, *tmp;
	struct rb_node *n;
	struct rb_node *n;
	unsigned long flags;
	int last = 0;
	int last = 0;
	int ret;
	int ret;


	spin_lock_irqsave(&mcast_lock, flags);
	spin_lock_irq(&mcast_lock);


	/* Find the GID in the mcast table. */
	/* Find the GID in the mcast table. */
	n = mcast_tree.rb_node;
	n = mcast_tree.rb_node;
	while (1) {
	while (1) {
		if (n == NULL) {
		if (n == NULL) {
			spin_unlock_irqrestore(&mcast_lock, flags);
			spin_unlock_irq(&mcast_lock);
			ret = -EINVAL;
			ret = -EINVAL;
			goto bail;
			goto bail;
		}
		}
@@ -334,7 +332,7 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
		break;
		break;
	}
	}


	spin_unlock_irqrestore(&mcast_lock, flags);
	spin_unlock_irq(&mcast_lock);


	if (p) {
	if (p) {
		/*
		/*
@@ -348,9 +346,9 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
		atomic_dec(&mcast->refcount);
		atomic_dec(&mcast->refcount);
		wait_event(mcast->wait, !atomic_read(&mcast->refcount));
		wait_event(mcast->wait, !atomic_read(&mcast->refcount));
		ipath_mcast_free(mcast);
		ipath_mcast_free(mcast);
		spin_lock(&dev->n_mcast_grps_lock);
		spin_lock_irq(&dev->n_mcast_grps_lock);
		dev->n_mcast_grps_allocated--;
		dev->n_mcast_grps_allocated--;
		spin_unlock(&dev->n_mcast_grps_lock);
		spin_unlock_irq(&dev->n_mcast_grps_lock);
	}
	}


	ret = 0;
	ret = 0;
Loading