Commit 5bd48c18 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/core: Do not erase the type of ib_cq.uobject

This is a struct ib_ucq_object pointer, instead of using container_of()
all over the place just store it with its actual type.

Link: https://lore.kernel.org/r/1578504126-9400-7-git-send-email-yishaih@mellanox.comSigned-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 4ec1dcfc
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "core_priv.h" #include "core_priv.h"
#include "cma_priv.h" #include "cma_priv.h"
#include "restrack.h" #include "restrack.h"
#include "uverbs.h"
typedef int (*res_fill_func_t)(struct sk_buff*, bool, typedef int (*res_fill_func_t)(struct sk_buff*, bool,
struct rdma_restrack_entry*, uint32_t); struct rdma_restrack_entry*, uint32_t);
...@@ -599,7 +600,7 @@ static int fill_res_cq_entry(struct sk_buff *msg, bool has_cap_net_admin, ...@@ -599,7 +600,7 @@ static int fill_res_cq_entry(struct sk_buff *msg, bool has_cap_net_admin,
goto err; goto err;
if (!rdma_is_kernel_res(res) && if (!rdma_is_kernel_res(res) &&
nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN, nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN,
cq->uobject->context->res.id)) cq->uobject->uevent.uobject.context->res.id))
goto err; goto err;
if (fill_res_name_pid(msg, res)) if (fill_res_name_pid(msg, res))
......
...@@ -1029,7 +1029,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1029,7 +1029,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
goto err_file; goto err_file;
} }
cq->device = ib_dev; cq->device = ib_dev;
cq->uobject = &obj->uevent.uobject; cq->uobject = obj;
cq->comp_handler = ib_uverbs_comp_handler; cq->comp_handler = ib_uverbs_comp_handler;
cq->event_handler = ib_uverbs_cq_event_handler; cq->event_handler = ib_uverbs_cq_event_handler;
cq->cq_context = ev_file ? &ev_file->ev_queue : NULL; cq->cq_context = ev_file ? &ev_file->ev_queue : NULL;
...@@ -1134,7 +1134,8 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs) ...@@ -1134,7 +1134,8 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs)
ret = uverbs_response(attrs, &resp, sizeof(resp)); ret = uverbs_response(attrs, &resp, sizeof(resp));
out: out:
uobj_put_obj_read(cq); rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
return ret; return ret;
} }
...@@ -1217,7 +1218,8 @@ static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs) ...@@ -1217,7 +1218,8 @@ static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs)
ret = uverbs_output_written(attrs, UVERBS_ATTR_CORE_OUT); ret = uverbs_output_written(attrs, UVERBS_ATTR_CORE_OUT);
out_put: out_put:
uobj_put_obj_read(cq); rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
return ret; return ret;
} }
...@@ -1238,8 +1240,8 @@ static int ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs) ...@@ -1238,8 +1240,8 @@ static int ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs)
ib_req_notify_cq(cq, cmd.solicited_only ? ib_req_notify_cq(cq, cmd.solicited_only ?
IB_CQ_SOLICITED : IB_CQ_NEXT_COMP); IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
uobj_put_obj_read(cq); rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
return 0; return 0;
} }
...@@ -1484,9 +1486,11 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1484,9 +1486,11 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
if (pd) if (pd)
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
if (scq) if (scq)
uobj_put_obj_read(scq); rdma_lookup_put_uobject(&scq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
if (rcq && rcq != scq) if (rcq && rcq != scq)
uobj_put_obj_read(rcq); rdma_lookup_put_uobject(&rcq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
if (srq) if (srq)
uobj_put_obj_read(srq); uobj_put_obj_read(srq);
if (ind_tbl) if (ind_tbl)
...@@ -1503,9 +1507,11 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1503,9 +1507,11 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
if (pd) if (pd)
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
if (scq) if (scq)
uobj_put_obj_read(scq); rdma_lookup_put_uobject(&scq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
if (rcq && rcq != scq) if (rcq && rcq != scq)
uobj_put_obj_read(rcq); rdma_lookup_put_uobject(&rcq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
if (srq) if (srq)
uobj_put_obj_read(srq); uobj_put_obj_read(srq);
if (ind_tbl) if (ind_tbl)
...@@ -2980,14 +2986,16 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) ...@@ -2980,14 +2986,16 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
goto err_copy; goto err_copy;
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
uobj_put_obj_read(cq); rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs); rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs);
return 0; return 0;
err_copy: err_copy:
ib_destroy_wq(wq, uverbs_get_cleared_udata(attrs)); ib_destroy_wq(wq, uverbs_get_cleared_udata(attrs));
err_put_cq: err_put_cq:
uobj_put_obj_read(cq); rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
err_put_pd: err_put_pd:
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
err_uobj: err_uobj:
...@@ -3481,7 +3489,8 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3481,7 +3489,8 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
uobj_put_read(xrcd_uobj); uobj_put_read(xrcd_uobj);
if (ib_srq_has_cq(cmd->srq_type)) if (ib_srq_has_cq(cmd->srq_type))
uobj_put_obj_read(attr.ext.cq); rdma_lookup_put_uobject(&attr.ext.cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
uobj_put_obj_read(pd); uobj_put_obj_read(pd);
rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs); rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs);
...@@ -3498,7 +3507,8 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3498,7 +3507,8 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
err_put_cq: err_put_cq:
if (ib_srq_has_cq(cmd->srq_type)) if (ib_srq_has_cq(cmd->srq_type))
uobj_put_obj_read(attr.ext.cq); rdma_lookup_put_uobject(&attr.ext.cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
err_put_xrcd: err_put_xrcd:
if (cmd->srq_type == IB_SRQT_XRC) { if (cmd->srq_type == IB_SRQT_XRC) {
...@@ -3714,8 +3724,8 @@ static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs) ...@@ -3714,8 +3724,8 @@ static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs)
ret = rdma_set_cq_moderation(cq, cmd.attr.cq_count, cmd.attr.cq_period); ret = rdma_set_cq_moderation(cq, cmd.attr.cq_count, cmd.attr.cq_period);
uobj_put_obj_read(cq); rdma_lookup_put_uobject(&cq->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
return ret; return ret;
} }
......
...@@ -408,9 +408,9 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) ...@@ -408,9 +408,9 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
return; return;
} }
uobj = container_of(cq->uobject, struct ib_ucq_object, uevent.uobject); uobj = cq->uobject;
entry->desc.comp.cq_handle = cq->uobject->user_handle; entry->desc.comp.cq_handle = cq->uobject->uevent.uobject.user_handle;
entry->counter = &uobj->comp_events_reported; entry->counter = &uobj->comp_events_reported;
list_add_tail(&entry->list, &ev_queue->event_list); list_add_tail(&entry->list, &ev_queue->event_list);
...@@ -457,8 +457,7 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file, ...@@ -457,8 +457,7 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
{ {
struct ib_uevent_object *uobj = container_of( struct ib_uevent_object *uobj = &event->element.cq->uobject->uevent;
event->element.cq->uobject, struct ib_uevent_object, uobject);
ib_uverbs_async_handler(uobj->uobject.ufile, uobj->uobject.user_handle, ib_uverbs_async_handler(uobj->uobject.ufile, uobj->uobject.user_handle,
event->event, &uobj->event_list, event->event, &uobj->event_list,
......
...@@ -116,7 +116,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( ...@@ -116,7 +116,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
} }
cq->device = ib_dev; cq->device = ib_dev;
cq->uobject = &obj->uevent.uobject; cq->uobject = obj;
cq->comp_handler = ib_uverbs_comp_handler; cq->comp_handler = ib_uverbs_comp_handler;
cq->event_handler = ib_uverbs_cq_event_handler; cq->event_handler = ib_uverbs_cq_event_handler;
cq->cq_context = ev_file ? &ev_file->ev_queue : NULL; cq->cq_context = ev_file ? &ev_file->ev_queue : NULL;
......
...@@ -77,6 +77,8 @@ extern struct workqueue_struct *ib_wq; ...@@ -77,6 +77,8 @@ extern struct workqueue_struct *ib_wq;
extern struct workqueue_struct *ib_comp_wq; extern struct workqueue_struct *ib_comp_wq;
extern struct workqueue_struct *ib_comp_unbound_wq; extern struct workqueue_struct *ib_comp_unbound_wq;
struct ib_ucq_object;
__printf(3, 4) __cold __printf(3, 4) __cold
void ibdev_printk(const char *level, const struct ib_device *ibdev, void ibdev_printk(const char *level, const struct ib_device *ibdev,
const char *format, ...); const char *format, ...);
...@@ -1544,7 +1546,7 @@ enum ib_poll_context { ...@@ -1544,7 +1546,7 @@ enum ib_poll_context {
struct ib_cq { struct ib_cq {
struct ib_device *device; struct ib_device *device;
struct ib_uobject *uobject; struct ib_ucq_object *uobject;
ib_comp_handler comp_handler; ib_comp_handler comp_handler;
void (*event_handler)(struct ib_event *, void *); void (*event_handler)(struct ib_event *, void *);
void *cq_context; void *cq_context;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment