Commit fb7ffeb1 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

parents 69eebed2 95ed644f
Loading
Loading
Loading
Loading
+5 −24
Original line number Diff line number Diff line
@@ -3163,22 +3163,6 @@ int ib_cm_init_qp_attr(struct ib_cm_id *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_device *device)
		return;

	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 *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_device *device)
	write_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);
}

+11 −12
Original line number Diff line number Diff line
@@ -38,8 +38,7 @@
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/init.h>

#include <asm/semaphore.h>
#include <linux/mutex.h>

#include "core_priv.h"

@@ -57,13 +56,13 @@ static LIST_HEAD(device_list);
static LIST_HEAD(client_list);

/*
 * device_sem protects access to both device_list and client_list.
 * device_mutex protects access to both device_list and client_list.
 * There's no real point to using multiple locks or something fancier
 * like an rwsem: we always access both lists, and we're always
 * modifying one list or the other list.  In any case this is not a
 * hot path so there's no point in trying to optimize.
 */
static DECLARE_MUTEX(device_sem);
static DEFINE_MUTEX(device_mutex);

static int ib_device_check_mandatory(struct ib_device *device)
{
@@ -221,7 +220,7 @@ int ib_register_device(struct ib_device *device)
{
	int ret;

	down(&device_sem);
	mutex_lock(&device_mutex);

	if (strchr(device->name, '%')) {
		ret = alloc_name(device->name);
@@ -259,7 +258,7 @@ int ib_register_device(struct ib_device *device)
	}

 out:
	up(&device_sem);
	mutex_unlock(&device_mutex);
	return ret;
}
EXPORT_SYMBOL(ib_register_device);
@@ -276,7 +275,7 @@ void ib_unregister_device(struct ib_device *device)
	struct ib_client_data *context, *tmp;
	unsigned long flags;

	down(&device_sem);
	mutex_lock(&device_mutex);

	list_for_each_entry_reverse(client, &client_list, list)
		if (client->remove)
@@ -284,7 +283,7 @@ void ib_unregister_device(struct ib_device *device)

	list_del(&device->core_list);

	up(&device_sem);
	mutex_unlock(&device_mutex);

	spin_lock_irqsave(&device->client_data_lock, flags);
	list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
@@ -312,14 +311,14 @@ int ib_register_client(struct ib_client *client)
{
	struct ib_device *device;

	down(&device_sem);
	mutex_lock(&device_mutex);

	list_add_tail(&client->list, &client_list);
	list_for_each_entry(device, &device_list, core_list)
		if (client->add && !add_client_context(device, client))
			client->add(device);

	up(&device_sem);
	mutex_unlock(&device_mutex);

	return 0;
}
@@ -339,7 +338,7 @@ void ib_unregister_client(struct ib_client *client)
	struct ib_device *device;
	unsigned long flags;

	down(&device_sem);
	mutex_lock(&device_mutex);

	list_for_each_entry(device, &device_list, core_list) {
		if (client->remove)
@@ -355,7 +354,7 @@ void ib_unregister_client(struct ib_client *client)
	}
	list_del(&client->list);

	up(&device_sem);
	mutex_unlock(&device_mutex);
}
EXPORT_SYMBOL(ib_unregister_client);

+5 −17
Original line number Diff line number Diff line
@@ -445,13 +445,7 @@ static int ib_device_uevent(struct class_device *cdev, char **envp,
		return -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(struct class_device *cdev, char *buf)
static 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);
+12 −11
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <linux/mount.h>
#include <linux/cdev.h>
#include <linux/idr.h>
#include <linux/mutex.h>

#include <asm/uaccess.h>

@@ -113,7 +114,7 @@ static struct ib_client ucm_client = {
	.remove = ib_ucm_remove_one
};

static DECLARE_MUTEX(ctx_id_mutex);
static DEFINE_MUTEX(ctx_id_mutex);
static DEFINE_IDR(ctx_id_table);
static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);

@@ -121,7 +122,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
{
	struct ib_ucm_context *ctx;

	down(&ctx_id_mutex);
	mutex_lock(&ctx_id_mutex);
	ctx = idr_find(&ctx_id_table, id);
	if (!ctx)
		ctx = ERR_PTR(-ENOENT);
@@ -129,7 +130,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
		ctx = ERR_PTR(-EINVAL);
	else
		atomic_inc(&ctx->ref);
	up(&ctx_id_mutex);
	mutex_unlock(&ctx_id_mutex);

	return ctx;
}
@@ -186,9 +187,9 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
		if (!result)
			goto error;

		down(&ctx_id_mutex);
		mutex_lock(&ctx_id_mutex);
		result = idr_get_new(&ctx_id_table, ctx, &ctx->id);
		up(&ctx_id_mutex);
		mutex_unlock(&ctx_id_mutex);
	} while (result == -EAGAIN);

	if (result)
@@ -550,9 +551,9 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
err2:
	ib_destroy_cm_id(ctx->cm_id);
err1:
	down(&ctx_id_mutex);
	mutex_lock(&ctx_id_mutex);
	idr_remove(&ctx_id_table, ctx->id);
	up(&ctx_id_mutex);
	mutex_unlock(&ctx_id_mutex);
	kfree(ctx);
	return result;
}
@@ -572,7 +573,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file,
	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
		return -EFAULT;

	down(&ctx_id_mutex);
	mutex_lock(&ctx_id_mutex);
	ctx = idr_find(&ctx_id_table, cmd.id);
	if (!ctx)
		ctx = ERR_PTR(-ENOENT);
@@ -580,7 +581,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file,
		ctx = ERR_PTR(-EINVAL);
	else
		idr_remove(&ctx_id_table, ctx->id);
	up(&ctx_id_mutex);
	mutex_unlock(&ctx_id_mutex);

	if (IS_ERR(ctx))
		return PTR_ERR(ctx);
@@ -1280,9 +1281,9 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
				 struct ib_ucm_context, file_list);
		up(&file->mutex);

		down(&ctx_id_mutex);
		mutex_lock(&ctx_id_mutex);
		idr_remove(&ctx_id_table, ctx->id);
		up(&ctx_id_mutex);
		mutex_unlock(&ctx_id_mutex);

		ib_destroy_cm_id(ctx->cm_id);
		ib_ucm_cleanup_events(ctx);
+3 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@

#include <linux/kref.h>
#include <linux/idr.h>
#include <linux/mutex.h>

#include <rdma/ib_verbs.h>
#include <rdma/ib_user_verbs.h>
@@ -88,7 +89,7 @@ struct ib_uverbs_event_file {

struct ib_uverbs_file {
	struct kref				ref;
	struct semaphore			mutex;
	struct mutex				mutex;
	struct ib_uverbs_device		       *device;
	struct ib_ucontext		       *ucontext;
	struct ib_event_handler			event_handler;
@@ -131,7 +132,7 @@ struct ib_ucq_object {
	u32			async_events_reported;
};

extern struct semaphore ib_uverbs_idr_mutex;
extern struct mutex ib_uverbs_idr_mutex;
extern struct idr ib_uverbs_pd_idr;
extern struct idr ib_uverbs_mr_idr;
extern struct idr ib_uverbs_mw_idr;
Loading