mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 05:31:25 +07:00
IB/uverbs: Replace file->ucontext with file in uverbs_cmd.c
The ucontext isn't needed any more, just pass the uverbs_file directly. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:
parent
6ef1c82821
commit
2cc1e3b809
@ -48,10 +48,10 @@
|
||||
#include "core_priv.h"
|
||||
|
||||
static struct ib_uverbs_completion_event_file *
|
||||
ib_uverbs_lookup_comp_file(int fd, struct ib_ucontext *context)
|
||||
ib_uverbs_lookup_comp_file(int fd, struct ib_uverbs_file *ufile)
|
||||
{
|
||||
struct ib_uobject *uobj = uobj_get_read(UVERBS_OBJECT_COMP_CHANNEL,
|
||||
fd, context);
|
||||
fd, ufile);
|
||||
struct ib_uobject_file *uobj_file;
|
||||
|
||||
if (IS_ERR(uobj))
|
||||
@ -322,7 +322,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
|
||||
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
|
||||
out_len - sizeof(resp));
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_PD, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_PD, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -509,8 +509,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
|
||||
}
|
||||
}
|
||||
|
||||
obj = (struct ib_uxrcd_object *)uobj_alloc(UVERBS_OBJECT_XRCD,
|
||||
file->ucontext);
|
||||
obj = (struct ib_uxrcd_object *)uobj_alloc(UVERBS_OBJECT_XRCD, file);
|
||||
if (IS_ERR(obj)) {
|
||||
ret = PTR_ERR(obj);
|
||||
goto err_tree_mutex_unlock;
|
||||
@ -652,11 +651,11 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_MR, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_MR, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto err_free;
|
||||
@ -748,8 +747,7 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
|
||||
(cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)))
|
||||
return -EINVAL;
|
||||
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle,
|
||||
file->ucontext);
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -767,7 +765,8 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
|
||||
}
|
||||
|
||||
if (cmd.flags & IB_MR_REREG_PD) {
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle,
|
||||
file);
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto put_uobjs;
|
||||
@ -840,11 +839,11 @@ ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof(cmd)))
|
||||
return -EFAULT;
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_MW, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_MW, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto err_free;
|
||||
@ -921,7 +920,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_COMP_CHANNEL, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_COMP_CHANNEL, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -966,14 +965,12 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
|
||||
if (cmd->comp_vector >= file->device->num_comp_vectors)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ,
|
||||
file->ucontext);
|
||||
obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ, file);
|
||||
if (IS_ERR(obj))
|
||||
return obj;
|
||||
|
||||
if (cmd->comp_channel >= 0) {
|
||||
ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel,
|
||||
file->ucontext);
|
||||
ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel, file);
|
||||
if (IS_ERR(ev_file)) {
|
||||
ret = PTR_ERR(ev_file);
|
||||
goto err;
|
||||
@ -1155,7 +1152,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
|
||||
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
|
||||
out_len - sizeof(resp));
|
||||
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext);
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
|
||||
if (!cq)
|
||||
return -EINVAL;
|
||||
|
||||
@ -1220,7 +1217,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext);
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
|
||||
if (!cq)
|
||||
return -EINVAL;
|
||||
|
||||
@ -1267,7 +1264,7 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext);
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
|
||||
if (!cq)
|
||||
return -EINVAL;
|
||||
|
||||
@ -1294,8 +1291,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_CQ, cmd.cq_handle,
|
||||
file->ucontext);
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_CQ, cmd.cq_handle, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -1353,8 +1349,7 @@ static int create_qp(struct ib_uverbs_file *file,
|
||||
if (cmd->qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW))
|
||||
return -EPERM;
|
||||
|
||||
obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP,
|
||||
file->ucontext);
|
||||
obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file);
|
||||
if (IS_ERR(obj))
|
||||
return PTR_ERR(obj);
|
||||
obj->uxrcd = NULL;
|
||||
@ -1364,9 +1359,9 @@ static int create_qp(struct ib_uverbs_file *file,
|
||||
if (cmd_sz >= offsetof(typeof(*cmd), rwq_ind_tbl_handle) +
|
||||
sizeof(cmd->rwq_ind_tbl_handle) &&
|
||||
(cmd->comp_mask & IB_UVERBS_CREATE_QP_MASK_IND_TABLE)) {
|
||||
ind_tbl = uobj_get_obj_read(rwq_ind_table, UVERBS_OBJECT_RWQ_IND_TBL,
|
||||
cmd->rwq_ind_tbl_handle,
|
||||
file->ucontext);
|
||||
ind_tbl = uobj_get_obj_read(rwq_ind_table,
|
||||
UVERBS_OBJECT_RWQ_IND_TBL,
|
||||
cmd->rwq_ind_tbl_handle, file);
|
||||
if (!ind_tbl) {
|
||||
ret = -EINVAL;
|
||||
goto err_put;
|
||||
@ -1392,7 +1387,7 @@ static int create_qp(struct ib_uverbs_file *file,
|
||||
|
||||
if (cmd->qp_type == IB_QPT_XRC_TGT) {
|
||||
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->pd_handle,
|
||||
file->ucontext);
|
||||
file);
|
||||
|
||||
if (IS_ERR(xrcd_uobj)) {
|
||||
ret = -EINVAL;
|
||||
@ -1411,8 +1406,8 @@ static int create_qp(struct ib_uverbs_file *file,
|
||||
cmd->max_recv_sge = 0;
|
||||
} else {
|
||||
if (cmd->is_srq) {
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd->srq_handle,
|
||||
file->ucontext);
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ,
|
||||
cmd->srq_handle, file);
|
||||
if (!srq || srq->srq_type == IB_SRQT_XRC) {
|
||||
ret = -EINVAL;
|
||||
goto err_put;
|
||||
@ -1421,8 +1416,9 @@ static int create_qp(struct ib_uverbs_file *file,
|
||||
|
||||
if (!ind_tbl) {
|
||||
if (cmd->recv_cq_handle != cmd->send_cq_handle) {
|
||||
rcq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd->recv_cq_handle,
|
||||
file->ucontext);
|
||||
rcq = uobj_get_obj_read(
|
||||
cq, UVERBS_OBJECT_CQ,
|
||||
cmd->recv_cq_handle, file);
|
||||
if (!rcq) {
|
||||
ret = -EINVAL;
|
||||
goto err_put;
|
||||
@ -1432,11 +1428,12 @@ static int create_qp(struct ib_uverbs_file *file,
|
||||
}
|
||||
|
||||
if (has_sq)
|
||||
scq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd->send_cq_handle,
|
||||
file->ucontext);
|
||||
scq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ,
|
||||
cmd->send_cq_handle, file);
|
||||
if (!ind_tbl)
|
||||
rcq = rcq ?: scq;
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle,
|
||||
file);
|
||||
if (!pd || (!scq && has_sq)) {
|
||||
ret = -EINVAL;
|
||||
goto err_put;
|
||||
@ -1733,13 +1730,11 @@ ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file,
|
||||
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
|
||||
out_len - sizeof(resp));
|
||||
|
||||
obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP,
|
||||
file->ucontext);
|
||||
obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file);
|
||||
if (IS_ERR(obj))
|
||||
return PTR_ERR(obj);
|
||||
|
||||
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd.pd_handle,
|
||||
file->ucontext);
|
||||
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd.pd_handle, file);
|
||||
if (IS_ERR(xrcd_uobj)) {
|
||||
ret = -EINVAL;
|
||||
goto err_put;
|
||||
@ -1841,7 +1836,7 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
|
||||
goto out;
|
||||
}
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (!qp) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
@ -1946,7 +1941,7 @@ static int modify_qp(struct ib_uverbs_file *file,
|
||||
if (!attr)
|
||||
return -ENOMEM;
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle, file);
|
||||
if (!qp) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
@ -2101,8 +2096,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
|
||||
|
||||
memset(&resp, 0, sizeof resp);
|
||||
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_QP, cmd.qp_handle,
|
||||
file->ucontext);
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -2167,7 +2161,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
|
||||
if (!user_wr)
|
||||
return -ENOMEM;
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (!qp)
|
||||
goto out;
|
||||
|
||||
@ -2203,8 +2197,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
|
||||
goto out_put;
|
||||
}
|
||||
|
||||
ud->ah = uobj_get_obj_read(ah, UVERBS_OBJECT_AH, user_wr->wr.ud.ah,
|
||||
file->ucontext);
|
||||
ud->ah = uobj_get_obj_read(ah, UVERBS_OBJECT_AH,
|
||||
user_wr->wr.ud.ah, file);
|
||||
if (!ud->ah) {
|
||||
kfree(ud);
|
||||
ret = -EINVAL;
|
||||
@ -2438,7 +2432,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
|
||||
if (IS_ERR(wr))
|
||||
return PTR_ERR(wr);
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (!qp)
|
||||
goto out;
|
||||
|
||||
@ -2487,7 +2481,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
|
||||
if (IS_ERR(wr))
|
||||
return PTR_ERR(wr);
|
||||
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file->ucontext);
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
|
||||
if (!srq)
|
||||
goto out;
|
||||
|
||||
@ -2544,11 +2538,11 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
|
||||
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
|
||||
out_len - sizeof(resp));
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_AH, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_AH, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
@ -2632,7 +2626,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (!qp)
|
||||
return -EINVAL;
|
||||
|
||||
@ -2683,7 +2677,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (!qp)
|
||||
return -EINVAL;
|
||||
|
||||
@ -2791,7 +2785,7 @@ static void flow_resources_add(struct ib_uflow_resources *uflow_res,
|
||||
uflow_res->num++;
|
||||
}
|
||||
|
||||
static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext,
|
||||
static int kern_spec_to_ib_spec_action(struct ib_uverbs_file *ufile,
|
||||
struct ib_uverbs_flow_spec *kern_spec,
|
||||
union ib_flow_spec *ib_spec,
|
||||
struct ib_uflow_resources *uflow_res)
|
||||
@ -2820,7 +2814,7 @@ static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext,
|
||||
ib_spec->action.act = uobj_get_obj_read(flow_action,
|
||||
UVERBS_OBJECT_FLOW_ACTION,
|
||||
kern_spec->action.handle,
|
||||
ucontext);
|
||||
ufile);
|
||||
if (!ib_spec->action.act)
|
||||
return -EINVAL;
|
||||
ib_spec->action.size =
|
||||
@ -2838,7 +2832,7 @@ static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext,
|
||||
uobj_get_obj_read(counters,
|
||||
UVERBS_OBJECT_COUNTERS,
|
||||
kern_spec->flow_count.handle,
|
||||
ucontext);
|
||||
ufile);
|
||||
if (!ib_spec->flow_count.counters)
|
||||
return -EINVAL;
|
||||
ib_spec->flow_count.size =
|
||||
@ -3019,7 +3013,7 @@ static int kern_spec_to_ib_spec_filter(struct ib_uverbs_flow_spec *kern_spec,
|
||||
kern_filter_sz, ib_spec);
|
||||
}
|
||||
|
||||
static int kern_spec_to_ib_spec(struct ib_ucontext *ucontext,
|
||||
static int kern_spec_to_ib_spec(struct ib_uverbs_file *ufile,
|
||||
struct ib_uverbs_flow_spec *kern_spec,
|
||||
union ib_flow_spec *ib_spec,
|
||||
struct ib_uflow_resources *uflow_res)
|
||||
@ -3028,7 +3022,7 @@ static int kern_spec_to_ib_spec(struct ib_ucontext *ucontext,
|
||||
return -EINVAL;
|
||||
|
||||
if (kern_spec->type >= IB_FLOW_SPEC_ACTION_TAG)
|
||||
return kern_spec_to_ib_spec_action(ucontext, kern_spec, ib_spec,
|
||||
return kern_spec_to_ib_spec_action(ufile, kern_spec, ib_spec,
|
||||
uflow_res);
|
||||
else
|
||||
return kern_spec_to_ib_spec_filter(kern_spec, ib_spec);
|
||||
@ -3071,18 +3065,17 @@ int ib_uverbs_ex_create_wq(struct ib_uverbs_file *file,
|
||||
if (cmd.comp_mask)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
obj = (struct ib_uwq_object *)uobj_alloc(UVERBS_OBJECT_WQ,
|
||||
file->ucontext);
|
||||
obj = (struct ib_uwq_object *)uobj_alloc(UVERBS_OBJECT_WQ, file);
|
||||
if (IS_ERR(obj))
|
||||
return PTR_ERR(obj);
|
||||
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
|
||||
if (!pd) {
|
||||
err = -EINVAL;
|
||||
goto err_uobj;
|
||||
}
|
||||
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext);
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
|
||||
if (!cq) {
|
||||
err = -EINVAL;
|
||||
goto err_put_pd;
|
||||
@ -3186,8 +3179,7 @@ int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file,
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
resp.response_length = required_resp_len;
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_WQ, cmd.wq_handle,
|
||||
file->ucontext);
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_WQ, cmd.wq_handle, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -3237,7 +3229,7 @@ int ib_uverbs_ex_modify_wq(struct ib_uverbs_file *file,
|
||||
if (cmd.attr_mask > (IB_WQ_STATE | IB_WQ_CUR_STATE | IB_WQ_FLAGS))
|
||||
return -EINVAL;
|
||||
|
||||
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, file->ucontext);
|
||||
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, file);
|
||||
if (!wq)
|
||||
return -EINVAL;
|
||||
|
||||
@ -3331,8 +3323,8 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file,
|
||||
|
||||
for (num_read_wqs = 0; num_read_wqs < num_wq_handles;
|
||||
num_read_wqs++) {
|
||||
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, wqs_handles[num_read_wqs],
|
||||
file->ucontext);
|
||||
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ,
|
||||
wqs_handles[num_read_wqs], file);
|
||||
if (!wq) {
|
||||
err = -EINVAL;
|
||||
goto put_wqs;
|
||||
@ -3341,7 +3333,7 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file,
|
||||
wqs[num_read_wqs] = wq;
|
||||
}
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_RWQ_IND_TBL, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_RWQ_IND_TBL, file);
|
||||
if (IS_ERR(uobj)) {
|
||||
err = PTR_ERR(uobj);
|
||||
goto put_wqs;
|
||||
@ -3504,13 +3496,13 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
|
||||
kern_flow_attr = &cmd.flow_attr;
|
||||
}
|
||||
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_FLOW, file->ucontext);
|
||||
uobj = uobj_alloc(UVERBS_OBJECT_FLOW, file);
|
||||
if (IS_ERR(uobj)) {
|
||||
err = PTR_ERR(uobj);
|
||||
goto err_free_attr;
|
||||
}
|
||||
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext);
|
||||
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
|
||||
if (!qp) {
|
||||
err = -EINVAL;
|
||||
goto err_uobj;
|
||||
@ -3546,8 +3538,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
|
||||
cmd.flow_attr.size > offsetof(struct ib_uverbs_flow_spec, reserved) &&
|
||||
cmd.flow_attr.size >=
|
||||
((struct ib_uverbs_flow_spec *)kern_spec)->size; i++) {
|
||||
err = kern_spec_to_ib_spec(file->ucontext, kern_spec, ib_spec,
|
||||
uflow_res);
|
||||
err = kern_spec_to_ib_spec(file, kern_spec, ib_spec, uflow_res);
|
||||
if (err)
|
||||
goto err_free;
|
||||
|
||||
@ -3644,8 +3635,7 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
|
||||
struct ib_srq_init_attr attr;
|
||||
int ret;
|
||||
|
||||
obj = (struct ib_usrq_object *)uobj_alloc(UVERBS_OBJECT_SRQ,
|
||||
file->ucontext);
|
||||
obj = (struct ib_usrq_object *)uobj_alloc(UVERBS_OBJECT_SRQ, file);
|
||||
if (IS_ERR(obj))
|
||||
return PTR_ERR(obj);
|
||||
|
||||
@ -3654,7 +3644,7 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
|
||||
|
||||
if (cmd->srq_type == IB_SRQT_XRC) {
|
||||
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->xrcd_handle,
|
||||
file->ucontext);
|
||||
file);
|
||||
if (IS_ERR(xrcd_uobj)) {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
@ -3671,15 +3661,15 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
|
||||
}
|
||||
|
||||
if (ib_srq_has_cq(cmd->srq_type)) {
|
||||
attr.ext.cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd->cq_handle,
|
||||
file->ucontext);
|
||||
attr.ext.cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ,
|
||||
cmd->cq_handle, file);
|
||||
if (!attr.ext.cq) {
|
||||
ret = -EINVAL;
|
||||
goto err_put_xrcd;
|
||||
}
|
||||
}
|
||||
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file->ucontext);
|
||||
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file);
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto err_put_cq;
|
||||
@ -3851,7 +3841,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
|
||||
ib_uverbs_init_udata(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
|
||||
out_len);
|
||||
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file->ucontext);
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
|
||||
if (!srq)
|
||||
return -EINVAL;
|
||||
|
||||
@ -3882,7 +3872,7 @@ ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file->ucontext);
|
||||
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
|
||||
if (!srq)
|
||||
return -EINVAL;
|
||||
|
||||
@ -3919,8 +3909,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
|
||||
if (copy_from_user(&cmd, buf, sizeof cmd))
|
||||
return -EFAULT;
|
||||
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_SRQ, cmd.srq_handle,
|
||||
file->ucontext);
|
||||
uobj = uobj_get_write(UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
|
||||
if (IS_ERR(uobj))
|
||||
return PTR_ERR(uobj);
|
||||
|
||||
@ -4098,7 +4087,7 @@ int ib_uverbs_ex_modify_cq(struct ib_uverbs_file *file,
|
||||
if (cmd.attr_mask > IB_CQ_MODERATE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext);
|
||||
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
|
||||
if (!cq)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -56,20 +56,24 @@ static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type,
|
||||
|
||||
#define uobj_get_type(_object) UVERBS_OBJECT(_object).type_attrs
|
||||
|
||||
#define uobj_get_read(_type, _id, _ucontext) \
|
||||
__uobj_get(uobj_get_type(_type), false, (_ucontext)->ufile, _id)
|
||||
#define uobj_get_read(_type, _id, _ufile) \
|
||||
__uobj_get(uobj_get_type(_type), false, _ufile, _id)
|
||||
|
||||
#define uobj_get_obj_read(_object, _type, _id, _ucontext) \
|
||||
({ \
|
||||
struct ib_uobject *__uobj = \
|
||||
__uobj_get(uobj_get_type(_type), \
|
||||
false, (_ucontext)->ufile, _id); \
|
||||
\
|
||||
(struct ib_##_object *)(IS_ERR(__uobj) ? NULL : __uobj->object);\
|
||||
})
|
||||
static inline void *_uobj_get_obj_read(const struct uverbs_obj_type *type,
|
||||
int id, struct ib_uverbs_file *ufile)
|
||||
{
|
||||
struct ib_uobject *uobj = __uobj_get(type, false, ufile, id);
|
||||
|
||||
#define uobj_get_write(_type, _id, _ucontext) \
|
||||
__uobj_get(uobj_get_type(_type), true, (_ucontext)->ufile, _id)
|
||||
if (IS_ERR(uobj))
|
||||
return NULL;
|
||||
return uobj->object;
|
||||
}
|
||||
#define uobj_get_obj_read(_object, _type, _id, _ufile) \
|
||||
((struct ib_##_object *)_uobj_get_obj_read(uobj_get_type(_type), _id, \
|
||||
_ufile))
|
||||
|
||||
#define uobj_get_write(_type, _id, _ufile) \
|
||||
__uobj_get(uobj_get_type(_type), true, _ufile, _id)
|
||||
|
||||
int __uobj_perform_destroy(const struct uverbs_obj_type *type, int id,
|
||||
struct ib_uverbs_file *ufile, int success_res);
|
||||
@ -105,13 +109,12 @@ static inline void uobj_alloc_abort(struct ib_uobject *uobj)
|
||||
}
|
||||
|
||||
static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type,
|
||||
struct ib_ucontext *ucontext)
|
||||
struct ib_uverbs_file *ufile)
|
||||
{
|
||||
return rdma_alloc_begin_uobject(type, ucontext->ufile);
|
||||
return rdma_alloc_begin_uobject(type, ufile);
|
||||
}
|
||||
|
||||
#define uobj_alloc(_type, ucontext) \
|
||||
__uobj_alloc(uobj_get_type(_type), ucontext)
|
||||
#define uobj_alloc(_type, _ufile) __uobj_alloc(uobj_get_type(_type), _ufile)
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user