Commit c0a6b5ec authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe
Browse files

RDMA: Convert RWQ table logic to ib_core allocation scheme

Move struct ib_rwq_ind_table allocation to ib_core.

Link: https://lore.kernel.org/r/20200902081623.746359-3-leon@kernel.org


Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent d18bb3e1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2697,6 +2697,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
	SET_OBJ_SIZE(dev_ops, ib_cq);
	SET_OBJ_SIZE(dev_ops, ib_mw);
	SET_OBJ_SIZE(dev_ops, ib_pd);
	SET_OBJ_SIZE(dev_ops, ib_rwq_ind_table);
	SET_OBJ_SIZE(dev_ops, ib_srq);
	SET_OBJ_SIZE(dev_ops, ib_ucontext);
	SET_OBJ_SIZE(dev_ops, ib_xrcd);
+15 −10
Original line number Diff line number Diff line
@@ -3055,17 +3055,15 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs)
		goto put_wqs;
	}

	init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size;
	init_attr.ind_tbl = wqs;

	rwq_ind_tbl = ib_dev->ops.create_rwq_ind_table(ib_dev, &init_attr,
						       &attrs->driver_udata);

	if (IS_ERR(rwq_ind_tbl)) {
		err = PTR_ERR(rwq_ind_tbl);
	rwq_ind_tbl = rdma_zalloc_drv_obj(ib_dev, ib_rwq_ind_table);
	if (!rwq_ind_tbl) {
		err = -ENOMEM;
		goto err_uobj;
	}

	init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size;
	init_attr.ind_tbl = wqs;

	rwq_ind_tbl->ind_tbl = wqs;
	rwq_ind_tbl->log_ind_tbl_size = init_attr.log_ind_tbl_size;
	rwq_ind_tbl->uobject = uobj;
@@ -3073,6 +3071,11 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs)
	rwq_ind_tbl->device = ib_dev;
	atomic_set(&rwq_ind_tbl->usecnt, 0);

	err = ib_dev->ops.create_rwq_ind_table(rwq_ind_tbl, &init_attr,
					       &attrs->driver_udata);
	if (err)
		goto err_create;

	for (i = 0; i < num_wq_handles; i++)
		rdma_lookup_put_uobject(&wqs[i]->uobject->uevent.uobject,
					UVERBS_LOOKUP_READ);
@@ -3084,6 +3087,8 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs)
	resp.response_length = uverbs_response_length(attrs, sizeof(resp));
	return uverbs_response(attrs, &resp, sizeof(resp));

err_create:
	kfree(rwq_ind_tbl);
err_uobj:
	uobj_alloc_abort(uobj, attrs);
put_wqs:
+10 −2
Original line number Diff line number Diff line
@@ -81,12 +81,20 @@ static int uverbs_free_rwq_ind_tbl(struct ib_uobject *uobject,
{
	struct ib_rwq_ind_table *rwq_ind_tbl = uobject->object;
	struct ib_wq **ind_tbl = rwq_ind_tbl->ind_tbl;
	int ret;
	u32 table_size = (1 << rwq_ind_tbl->log_ind_tbl_size);
	int ret, i;

	if (atomic_read(&rwq_ind_tbl->usecnt))
		return -EBUSY;

	ret = ib_destroy_rwq_ind_table(rwq_ind_tbl);
	ret = rwq_ind_tbl->device->ops.destroy_rwq_ind_table(rwq_ind_tbl);
	if (ib_is_destroy_retryable(ret, why, uobject))
		return ret;

	for (i = 0; i < table_size; i++)
		atomic_dec(&ind_tbl[i]->usecnt);

	kfree(rwq_ind_tbl);
	kfree(ind_tbl);
	return ret;
}
+0 −23
Original line number Diff line number Diff line
@@ -2443,29 +2443,6 @@ int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
}
EXPORT_SYMBOL(ib_modify_wq);

/*
 * ib_destroy_rwq_ind_table - Destroys the specified Indirection Table.
 * @wq_ind_table: The Indirection Table to destroy.
*/
int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *rwq_ind_table)
{
	int err, i;
	u32 table_size = (1 << rwq_ind_table->log_ind_tbl_size);
	struct ib_wq **ind_tbl = rwq_ind_table->ind_tbl;

	if (atomic_read(&rwq_ind_table->usecnt))
		return -EBUSY;

	err = rwq_ind_table->device->ops.destroy_rwq_ind_table(rwq_ind_table);
	if (!err) {
		for (i = 0; i < table_size; i++)
			atomic_dec(&ind_tbl[i]->usecnt);
	}

	return err;
}
EXPORT_SYMBOL(ib_destroy_rwq_ind_table);

int ib_check_mr_status(struct ib_mr *mr, u32 check_mask,
		       struct ib_mr_status *mr_status)
{
+3 −0
Original line number Diff line number Diff line
@@ -2577,6 +2577,9 @@ static const struct ib_device_ops mlx4_ib_dev_wq_ops = {
	.destroy_rwq_ind_table = mlx4_ib_destroy_rwq_ind_table,
	.destroy_wq = mlx4_ib_destroy_wq,
	.modify_wq = mlx4_ib_modify_wq,

	INIT_RDMA_OBJ_SIZE(ib_rwq_ind_table, mlx4_ib_rwq_ind_table,
			   ib_rwq_ind_tbl),
};

static const struct ib_device_ops mlx4_ib_dev_mw_ops = {
Loading