Commit 620d3f81 authored by Jason Gunthorpe's avatar Jason Gunthorpe

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

This is a struct ib_uqp_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-8-git-send-email-yishaih@mellanox.comSigned-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 5bd48c18
...@@ -321,7 +321,7 @@ static inline struct ib_qp *_ib_create_qp(struct ib_device *dev, ...@@ -321,7 +321,7 @@ static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
struct ib_pd *pd, struct ib_pd *pd,
struct ib_qp_init_attr *attr, struct ib_qp_init_attr *attr,
struct ib_udata *udata, struct ib_udata *udata,
struct ib_uobject *uobj) struct ib_uqp_object *uobj)
{ {
enum ib_qp_type qp_type = attr->qp_type; enum ib_qp_type qp_type = attr->qp_type;
struct ib_qp *qp; struct ib_qp *qp;
......
...@@ -1424,7 +1424,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1424,7 +1424,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
qp = ib_create_qp(pd, &attr); qp = ib_create_qp(pd, &attr);
else else
qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata, qp = _ib_create_qp(device, pd, &attr, &attrs->driver_udata,
&obj->uevent.uobject); obj);
if (IS_ERR(qp)) { if (IS_ERR(qp)) {
ret = PTR_ERR(qp); ret = PTR_ERR(qp);
...@@ -1457,7 +1457,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1457,7 +1457,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
atomic_inc(&ind_tbl->usecnt); atomic_inc(&ind_tbl->usecnt);
} else { } else {
/* It is done in _ib_create_qp for other QP types */ /* It is done in _ib_create_qp for other QP types */
qp->uobject = &obj->uevent.uobject; qp->uobject = obj;
} }
obj->uevent.uobject.object = qp; obj->uevent.uobject.object = qp;
...@@ -1628,7 +1628,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs) ...@@ -1628,7 +1628,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs)
obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject); obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
atomic_inc(&obj->uxrcd->refcnt); atomic_inc(&obj->uxrcd->refcnt);
qp->uobject = &obj->uevent.uobject; qp->uobject = obj;
uobj_put_read(xrcd_uobj); uobj_put_read(xrcd_uobj);
rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs); rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs);
...@@ -1693,7 +1693,8 @@ static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs) ...@@ -1693,7 +1693,8 @@ static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs)
ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr); ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr);
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
if (ret) if (ret)
goto out; goto out;
...@@ -1930,7 +1931,8 @@ static int modify_qp(struct uverbs_attr_bundle *attrs, ...@@ -1930,7 +1931,8 @@ static int modify_qp(struct uverbs_attr_bundle *attrs,
&attrs->driver_udata); &attrs->driver_udata);
release_qp: release_qp:
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
out: out:
kfree(attr); kfree(attr);
...@@ -2194,7 +2196,8 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs) ...@@ -2194,7 +2196,8 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs)
ret = ret2; ret = ret2;
out_put: out_put:
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
while (wr) { while (wr) {
if (is_ud && ud_wr(wr)->ah) if (is_ud && ud_wr(wr)->ah)
...@@ -2336,7 +2339,8 @@ static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs) ...@@ -2336,7 +2339,8 @@ static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs)
resp.bad_wr = 0; resp.bad_wr = 0;
ret = qp->device->ops.post_recv(qp->real_qp, wr, &bad_wr); ret = qp->device->ops.post_recv(qp->real_qp, wr, &bad_wr);
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
if (ret) { if (ret) {
for (next = wr; next; next = next->next) { for (next = wr; next; next = next->next) {
++resp.bad_wr; ++resp.bad_wr;
...@@ -2517,7 +2521,7 @@ static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs) ...@@ -2517,7 +2521,7 @@ static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs)
if (!qp) if (!qp)
return -EINVAL; return -EINVAL;
obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject); obj = qp->uobject;
mutex_lock(&obj->mcast_lock); mutex_lock(&obj->mcast_lock);
list_for_each_entry(mcast, &obj->mcast_list, list) list_for_each_entry(mcast, &obj->mcast_list, list)
...@@ -2544,7 +2548,8 @@ static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs) ...@@ -2544,7 +2548,8 @@ static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs)
out_put: out_put:
mutex_unlock(&obj->mcast_lock); mutex_unlock(&obj->mcast_lock);
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
return ret; return ret;
} }
...@@ -2566,7 +2571,7 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs) ...@@ -2566,7 +2571,7 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs)
if (!qp) if (!qp)
return -EINVAL; return -EINVAL;
obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject); obj = qp->uobject;
mutex_lock(&obj->mcast_lock); mutex_lock(&obj->mcast_lock);
list_for_each_entry(mcast, &obj->mcast_list, list) list_for_each_entry(mcast, &obj->mcast_list, list)
...@@ -2587,7 +2592,8 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs) ...@@ -2587,7 +2592,8 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs)
out_put: out_put:
mutex_unlock(&obj->mcast_lock); mutex_unlock(&obj->mcast_lock);
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
return ret; return ret;
} }
...@@ -3339,7 +3345,8 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) ...@@ -3339,7 +3345,8 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs)
if (err) if (err)
goto err_copy; goto err_copy;
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
kfree(flow_attr); kfree(flow_attr);
if (cmd.flow_attr.num_of_specs) if (cmd.flow_attr.num_of_specs)
kfree(kern_flow_attr); kfree(kern_flow_attr);
...@@ -3353,7 +3360,8 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) ...@@ -3353,7 +3360,8 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs)
err_free_flow_attr: err_free_flow_attr:
kfree(flow_attr); kfree(flow_attr);
err_put: err_put:
uobj_put_obj_read(qp); rdma_lookup_put_uobject(&qp->uobject->uevent.uobject,
UVERBS_LOOKUP_READ);
err_uobj: err_uobj:
uobj_alloc_abort(uobj, attrs); uobj_alloc_abort(uobj, attrs);
err_free_attr: err_free_attr:
......
...@@ -472,8 +472,7 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr) ...@@ -472,8 +472,7 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
if (!event->element.qp->uobject) if (!event->element.qp->uobject)
return; return;
uobj = container_of(event->element.qp->uobject, uobj = &event->element.qp->uobject->uevent;
struct ib_uevent_object, uobject);
ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle, ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
event->event, &uobj->event_list, event->event, &uobj->event_list,
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#define IB_FW_VERSION_NAME_MAX ETHTOOL_FWVERS_LEN #define IB_FW_VERSION_NAME_MAX ETHTOOL_FWVERS_LEN
struct ib_umem_odp; struct ib_umem_odp;
struct ib_uqp_object;
extern struct workqueue_struct *ib_wq; extern struct workqueue_struct *ib_wq;
extern struct workqueue_struct *ib_comp_wq; extern struct workqueue_struct *ib_comp_wq;
...@@ -1735,7 +1736,7 @@ struct ib_qp { ...@@ -1735,7 +1736,7 @@ struct ib_qp {
atomic_t usecnt; atomic_t usecnt;
struct list_head open_list; struct list_head open_list;
struct ib_qp *real_qp; struct ib_qp *real_qp;
struct ib_uobject *uobject; struct ib_uqp_object *uobject;
void (*event_handler)(struct ib_event *, void *); void (*event_handler)(struct ib_event *, void *);
void *qp_context; void *qp_context;
/* sgid_attrs associated with the AV's */ /* sgid_attrs associated with the AV's */
......
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