From patchwork Wed Aug 21 14:21:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC80D14DE for ; Wed, 21 Aug 2019 14:22:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D7CF233A2 for ; Wed, 21 Aug 2019 14:22:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="c1miVC4n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729644AbfHUOWS (ORCPT ); Wed, 21 Aug 2019 10:22:18 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44480 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729510AbfHUOWR (ORCPT ); Wed, 21 Aug 2019 10:22:17 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEFjR087566; Wed, 21 Aug 2019 14:21:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=Qw9u255V0LZtYmC8noIjdcbppfsew0dXGdWzpu2/4ro=; b=c1miVC4nPKdU/ambzkJqeq4rJNcyFRt89/h8Tp3ejxSHEkQPa74eK9xEabLFmpx80WwL KNBDXJHIQ0hZL+7yVvgr9zKAEODLA82HKXAvzL2Tx+1QV/aMu2WcwoOJdd9aYQQmh3Na V2rL+cxLk8gB/6CBipQxIt6ajlhkUGmPo7ardeqdUCPW76X+dAnGa5y2ulNnubziC/kb BYM/+sDr/yqCJjcybxxVhQg+yigQbFf2f5n+BAKO4U5aZrXuUUyDNPLD+Iv1nYgCd3R3 ZFPNewjAPaa2+ZtWIcFDCevo1qXh4rYmnP+f6P760fDsFJ1Sj/T0xmYGP3J18wc4SrBI ig== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2ue9hpnuv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:21:49 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEIcFU104004; Wed, 21 Aug 2019 14:21:48 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2ug26a39hu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:21:48 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LELkOJ010379; Wed, 21 Aug 2019 14:21:46 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:21:45 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 01/24] RDMA/uverbs: uobj_get_obj_read should return the ib_uobject Date: Wed, 21 Aug 2019 17:21:02 +0300 Message-Id: <20190821142125.5706-2-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch The uobject pointer will be removed from ib_x (ib_pd, ib_mr,...) objects. uobj_get_obj_read and uobj_put_obj_read macros were constructed with the assumption that ib_x can figure the uobject in mind. Fix this wrong assumption. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs_cmd.c | 125 ++++++++++++++++++++------- include/rdma/uverbs_std_types.h | 8 +- 2 files changed, 98 insertions(+), 35 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 7ddd0e5bc6b3..b0dc301918bf 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -37,6 +37,7 @@ #include #include #include +#include #include @@ -711,6 +712,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) struct ib_uverbs_reg_mr cmd; struct ib_uverbs_reg_mr_resp resp; struct ib_uobject *uobj; + struct ib_uobject *pduobj; struct ib_pd *pd; struct ib_mr *mr; int ret; @@ -731,7 +733,8 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) if (IS_ERR(uobj)) return PTR_ERR(uobj); - pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs); + pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs, + &pduobj); if (!pd) { ret = -EINVAL; goto err_free; @@ -799,6 +802,7 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) struct ib_pd *old_pd; int ret; struct ib_uobject *uobj; + struct ib_uobject *pduobj = NULL; ret = uverbs_request(attrs, &cmd, sizeof(cmd)); if (ret) @@ -831,7 +835,7 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) if (cmd.flags & IB_MR_REREG_PD) { pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, - attrs); + attrs, &pduobj); if (!pd) { ret = -EINVAL; goto put_uobjs; @@ -885,6 +889,7 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs) struct ib_uverbs_alloc_mw cmd; struct ib_uverbs_alloc_mw_resp resp; struct ib_uobject *uobj; + struct ib_uobject *pduobj; struct ib_pd *pd; struct ib_mw *mw; int ret; @@ -898,7 +903,8 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs) if (IS_ERR(uobj)) return PTR_ERR(uobj); - pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs); + pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs, + &pduobj); if (!pd) { ret = -EINVAL; goto err_free; @@ -1117,6 +1123,7 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_resize_cq cmd; struct ib_uverbs_resize_cq_resp resp = {}; + struct ib_uobject *cquobj; struct ib_cq *cq; int ret = -EINVAL; @@ -1124,7 +1131,8 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs) if (ret) return ret; - cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs); + cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs, + &cquobj); if (!cq) return -EINVAL; @@ -1177,6 +1185,7 @@ static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs) struct ib_uverbs_poll_cq_resp resp; u8 __user *header_ptr; u8 __user *data_ptr; + struct ib_uobject *cquobj; struct ib_cq *cq; struct ib_wc wc; int ret; @@ -1185,7 +1194,8 @@ static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs) if (ret) return ret; - cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs); + cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs, + &cquobj); if (!cq) return -EINVAL; @@ -1226,6 +1236,7 @@ static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs) static int ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_req_notify_cq cmd; + struct ib_uobject *cquobj; struct ib_cq *cq; int ret; @@ -1233,7 +1244,8 @@ static int ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs) if (ret) return ret; - cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs); + cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs, + &cquobj); if (!cq) return -EINVAL; @@ -1276,16 +1288,21 @@ static int create_qp(struct uverbs_attr_bundle *attrs, { struct ib_uqp_object *obj; struct ib_device *device; + struct ib_uobject *pd_uobj = ERR_PTR(-ENOENT); struct ib_pd *pd = NULL; struct ib_xrcd *xrcd = NULL; struct ib_uobject *xrcd_uobj = ERR_PTR(-ENOENT); + struct ib_uobject *scq_uobj = ERR_PTR(-ENOENT); + struct ib_uobject *rcq_uobj = ERR_PTR(-ENOENT); struct ib_cq *scq = NULL, *rcq = NULL; + struct ib_uobject *srq_uobj = ERR_PTR(-ENOENT); struct ib_srq *srq = NULL; struct ib_qp *qp; struct ib_qp_init_attr attr = {}; struct ib_uverbs_ex_create_qp_resp resp; int ret; struct ib_rwq_ind_table *ind_tbl = NULL; + struct ib_uobject *ind_tbl_uobj = ERR_PTR(-ENOENT); bool has_sq = true; struct ib_device *ib_dev; @@ -1303,7 +1320,8 @@ static int create_qp(struct uverbs_attr_bundle *attrs, if (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, attrs); + cmd->rwq_ind_tbl_handle, attrs, + &ind_tbl_uobj); if (!ind_tbl) { ret = -EINVAL; goto err_put; @@ -1342,7 +1360,8 @@ static int create_qp(struct uverbs_attr_bundle *attrs, } else { if (cmd->is_srq) { srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, - cmd->srq_handle, attrs); + cmd->srq_handle, attrs, + &srq_uobj); if (!srq || srq->srq_type == IB_SRQT_XRC) { ret = -EINVAL; goto err_put; @@ -1353,7 +1372,8 @@ static int create_qp(struct uverbs_attr_bundle *attrs, if (cmd->recv_cq_handle != cmd->send_cq_handle) { rcq = uobj_get_obj_read( cq, UVERBS_OBJECT_CQ, - cmd->recv_cq_handle, attrs); + cmd->recv_cq_handle, attrs, + &rcq_uobj); if (!rcq) { ret = -EINVAL; goto err_put; @@ -1364,11 +1384,12 @@ static int create_qp(struct uverbs_attr_bundle *attrs, if (has_sq) scq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, - cmd->send_cq_handle, attrs); + cmd->send_cq_handle, attrs, + &scq_uobj); if (!ind_tbl) rcq = rcq ?: scq; pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, - attrs); + attrs, &pd_uobj); if (!pd || (!scq && has_sq)) { ret = -EINVAL; goto err_put; @@ -1663,6 +1684,7 @@ static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_query_qp cmd; struct ib_uverbs_query_qp_resp resp; + struct ib_uobject *qpuobj; struct ib_qp *qp; struct ib_qp_attr *attr; struct ib_qp_init_attr *init_attr; @@ -1679,7 +1701,8 @@ static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs) goto out; } - qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); + qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs, + &qpuobj); if (!qp) { ret = -EINVAL; goto out; @@ -1776,6 +1799,7 @@ static int modify_qp(struct uverbs_attr_bundle *attrs, struct ib_uverbs_ex_modify_qp *cmd) { struct ib_qp_attr *attr; + struct ib_uobject *qpuobj; struct ib_qp *qp; int ret; @@ -1784,7 +1808,7 @@ static int modify_qp(struct uverbs_attr_bundle *attrs, return -ENOMEM; qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle, - attrs); + attrs, &qpuobj); if (!qp) { ret = -EINVAL; goto out; @@ -2018,6 +2042,7 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs) struct ib_uverbs_send_wr *user_wr; struct ib_send_wr *wr = NULL, *last, *next; const struct ib_send_wr *bad_wr; + struct ib_uobject *qpuobj; struct ib_qp *qp; int i, sg_ind; int is_ud; @@ -2045,7 +2070,8 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs) if (!user_wr) return -ENOMEM; - qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); + qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs, + &qpuobj); if (!qp) { ret = -EINVAL; goto out; @@ -2068,6 +2094,7 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs) if (is_ud) { struct ib_ud_wr *ud; + struct ib_uobject *uobj; if (user_wr->opcode != IB_WR_SEND && user_wr->opcode != IB_WR_SEND_WITH_IMM) { @@ -2083,7 +2110,8 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs) } ud->ah = uobj_get_obj_read(ah, UVERBS_OBJECT_AH, - user_wr->wr.ud.ah, attrs); + user_wr->wr.ud.ah, attrs, + &uobj); if (!ud->ah) { kfree(ud); ret = -EINVAL; @@ -2308,6 +2336,7 @@ static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs) struct ib_uverbs_post_recv_resp resp; struct ib_recv_wr *wr, *next; const struct ib_recv_wr *bad_wr; + struct ib_uobject *qpuobj; struct ib_qp *qp; int ret, ret2; struct uverbs_req_iter iter; @@ -2321,7 +2350,8 @@ static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs) if (IS_ERR(wr)) return PTR_ERR(wr); - qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); + qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs, + &qpuobj); if (!qp) { ret = -EINVAL; goto out; @@ -2358,6 +2388,7 @@ static int ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs) struct ib_uverbs_post_srq_recv_resp resp; struct ib_recv_wr *wr, *next; const struct ib_recv_wr *bad_wr; + struct ib_uobject *srquobj; struct ib_srq *srq; int ret, ret2; struct uverbs_req_iter iter; @@ -2371,7 +2402,8 @@ static int ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs) if (IS_ERR(wr)) return PTR_ERR(wr); - srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs); + srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs, + &srquobj); if (!srq) { ret = -EINVAL; goto out; @@ -2408,6 +2440,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) struct ib_uverbs_create_ah cmd; struct ib_uverbs_create_ah_resp resp; struct ib_uobject *uobj; + struct ib_uobject *pduobj; struct ib_pd *pd; struct ib_ah *ah; struct rdma_ah_attr attr = {}; @@ -2427,7 +2460,8 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) goto err; } - pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs); + pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs, + &pduobj); if (!pd) { ret = -EINVAL; goto err; @@ -2497,6 +2531,7 @@ static int ib_uverbs_destroy_ah(struct uverbs_attr_bundle *attrs) static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_attach_mcast cmd; + struct ib_uobject *qpuobj; struct ib_qp *qp; struct ib_uqp_object *obj; struct ib_uverbs_mcast_entry *mcast; @@ -2506,7 +2541,8 @@ static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs) if (ret) return ret; - qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); + qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs, + &qpuobj); if (!qp) return -EINVAL; @@ -2546,6 +2582,7 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_detach_mcast cmd; struct ib_uqp_object *obj; + struct ib_uobject *qpuobj; struct ib_qp *qp; struct ib_uverbs_mcast_entry *mcast; int ret; @@ -2555,7 +2592,8 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs) if (ret) return ret; - qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); + qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs, + &qpuobj); if (!qp) return -EINVAL; @@ -2665,6 +2703,8 @@ static int kern_spec_to_ib_spec_action(struct uverbs_attr_bundle *attrs, union ib_flow_spec *ib_spec, struct ib_uflow_resources *uflow_res) { + struct ib_uobject *uobj; + ib_spec->type = kern_spec->type; switch (ib_spec->type) { case IB_FLOW_SPEC_ACTION_TAG: @@ -2689,7 +2729,7 @@ static int kern_spec_to_ib_spec_action(struct uverbs_attr_bundle *attrs, ib_spec->action.act = uobj_get_obj_read(flow_action, UVERBS_OBJECT_FLOW_ACTION, kern_spec->action.handle, - attrs); + attrs, &uobj); if (!ib_spec->action.act) return -EINVAL; ib_spec->action.size = @@ -2707,7 +2747,7 @@ static int kern_spec_to_ib_spec_action(struct uverbs_attr_bundle *attrs, uobj_get_obj_read(counters, UVERBS_OBJECT_COUNTERS, kern_spec->flow_count.handle, - attrs); + attrs, &uobj); if (!ib_spec->flow_count.counters) return -EINVAL; ib_spec->flow_count.size = @@ -2909,6 +2949,8 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) struct ib_uverbs_ex_create_wq_resp resp = {}; struct ib_uwq_object *obj; int err = 0; + struct ib_uobject *cquobj; + struct ib_uobject *pduobj; struct ib_cq *cq; struct ib_pd *pd; struct ib_wq *wq; @@ -2927,13 +2969,15 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) if (IS_ERR(obj)) return PTR_ERR(obj); - pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs); + pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs, + &pduobj); if (!pd) { err = -EINVAL; goto err_uobj; } - cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs); + cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs, + &cquobj); if (!cq) { err = -EINVAL; goto err_put_pd; @@ -3025,6 +3069,7 @@ static int ib_uverbs_ex_destroy_wq(struct uverbs_attr_bundle *attrs) static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_ex_modify_wq cmd; + struct ib_uobject *wquobj; struct ib_wq *wq; struct ib_wq_attr wq_attr = {}; int ret; @@ -3039,7 +3084,8 @@ static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs) 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, attrs); + wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, attrs, + &wquobj); if (!wq) return -EINVAL; @@ -3104,8 +3150,11 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs) for (num_read_wqs = 0; num_read_wqs < num_wq_handles; num_read_wqs++) { + struct ib_uobject *uobj; + wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, - wqs_handles[num_read_wqs], attrs); + wqs_handles[num_read_wqs], attrs, + &uobj); if (!wq) { err = -EINVAL; goto put_wqs; @@ -3166,6 +3215,7 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs) err_free: kfree(wqs_handles); kfree(wqs); + return err; } @@ -3193,6 +3243,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) struct ib_flow *flow_id; struct ib_uverbs_flow_attr *kern_flow_attr; struct ib_flow_attr *flow_attr; + struct ib_uobject *qpuobj; struct ib_qp *qp; struct ib_uflow_resources *uflow_res; struct ib_uverbs_flow_spec_hdr *kern_spec; @@ -3256,7 +3307,8 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) goto err_free_attr; } - qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); + qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs, + &qpuobj); if (!qp) { err = -EINVAL; goto err_uobj; @@ -3371,6 +3423,8 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, { struct ib_uverbs_create_srq_resp resp; struct ib_usrq_object *obj; + struct ib_uobject *cquobj = ERR_PTR(-ENOENT); + struct ib_uobject *pduobj; struct ib_pd *pd; struct ib_srq *srq; struct ib_uobject *uninitialized_var(xrcd_uobj); @@ -3406,14 +3460,15 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, if (ib_srq_has_cq(cmd->srq_type)) { attr.ext.cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, - cmd->cq_handle, attrs); + cmd->cq_handle, attrs, &cquobj); if (!attr.ext.cq) { ret = -EINVAL; goto err_put_xrcd; } } - pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, attrs); + pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, attrs, + &pduobj); if (!pd) { ret = -EINVAL; goto err_put_cq; @@ -3542,6 +3597,7 @@ static int ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs) static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_modify_srq cmd; + struct ib_uobject *srquobj; struct ib_srq *srq; struct ib_srq_attr attr; int ret; @@ -3550,7 +3606,8 @@ static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs) if (ret) return ret; - srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs); + srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs, + &srquobj); if (!srq) return -EINVAL; @@ -3570,6 +3627,7 @@ static int ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs) struct ib_uverbs_query_srq cmd; struct ib_uverbs_query_srq_resp resp; struct ib_srq_attr attr; + struct ib_uobject *srquobj; struct ib_srq *srq; int ret; @@ -3577,7 +3635,8 @@ static int ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs) if (ret) return ret; - srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs); + srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs, + &srquobj); if (!srq) return -EINVAL; @@ -3689,6 +3748,7 @@ static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs) static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_ex_modify_cq cmd; + struct ib_uobject *cquobj; struct ib_cq *cq; int ret; @@ -3702,7 +3762,8 @@ static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs) if (cmd.attr_mask > IB_CQ_MODERATE) return -EOPNOTSUPP; - cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs); + cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs, + &cquobj); if (!cq) return -EINVAL; diff --git a/include/rdma/uverbs_std_types.h b/include/rdma/uverbs_std_types.h index 05eabfd5d0d3..578e5c28bc1c 100644 --- a/include/rdma/uverbs_std_types.h +++ b/include/rdma/uverbs_std_types.h @@ -64,9 +64,11 @@ static inline void *_uobj_get_obj_read(struct ib_uobject *uobj) return NULL; return uobj->object; } -#define uobj_get_obj_read(_object, _type, _id, _attrs) \ - ((struct ib_##_object *)_uobj_get_obj_read( \ - uobj_get_read(_type, _id, _attrs))) +#define uobj_get_obj_read(_object, _type, _id, _attrs, _uobj) \ +({ \ + *_uobj = uobj_get_read(_type, _id, _attrs); \ + ((struct ib_##_object *)_uobj_get_obj_read(*_uobj)); \ +}) #define uobj_get_write(_type, _id, _attrs) \ rdma_lookup_get_uobject(uobj_get_type(_attrs, _type), (_attrs)->ufile, \ From patchwork Wed Aug 21 14:21:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FEC013A4 for ; Wed, 21 Aug 2019 14:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5484922D6D for ; Wed, 21 Aug 2019 14:22:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="evXg8NAG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729297AbfHUOWX (ORCPT ); Wed, 21 Aug 2019 10:22:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59706 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729367AbfHUOWX (ORCPT ); Wed, 21 Aug 2019 10:22:23 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEGuT063018; Wed, 21 Aug 2019 14:21:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=XJ76EAhWr1LGc676v9PENYEutqtgReMttyV7cQAy8K4=; b=evXg8NAG5DGOIRDcn4Abrewi2ojVR65eqdOM+UN9SwvIBP3jMV+Q6cz4GaWmfibp09th CnfQ3N0XjgaoegAihphXyjqToPYffAtVcqJHEZSEEBns1pqf02N8thcLOBlNqgwDxCSv cW8pbXdsNBS2K/Hpwz7CgTLqDRG/XIqrDxM3lMNDKHpw+hAYBUorQQMzDKKiqyUDurDq Lpfd7snJtvIdur33gR1Gnx4WlNDDNs40SXcA/krnjJ1n4NPyIDaceh/clFQ5nCZqfLVE 8Gwlel2wGkoYdlQA7IZqXFdhx+LLbknmeQJ5rbd+gqhdQ7BmzvElK5AJbItrs5x9pm/Y 0Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp3px-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:21:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEI5QF001563; Wed, 21 Aug 2019 14:21:54 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2uh2q4jv75-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:21:53 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LELqLe010423; Wed, 21 Aug 2019 14:21:52 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:21:51 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 02/24] RDMA/uverbs: Delete the macro uobj_put_obj_read Date: Wed, 21 Aug 2019 17:21:03 +0300 Message-Id: <20190821142125.5706-3-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch The macro uobj_put_obj_read assumes an existence of a member with the name uobject on each HW object. Since this member is about to be delete we shouldn't use this macro, instead use uobj_put_read and delete uobj_put_obj_read. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs_cmd.c | 92 ++++++++++++++-------------- include/rdma/uverbs_std_types.h | 3 - 2 files changed, 46 insertions(+), 49 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index b0dc301918bf..204a93305f1c 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -778,7 +778,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) if (ret) goto err_copy; - uobj_put_obj_read(pd); + uobj_put_read(pduobj); return uobj_alloc_commit(uobj, attrs); @@ -786,7 +786,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) ib_dereg_mr_user(mr, uverbs_get_cleared_udata(attrs)); err_put: - uobj_put_obj_read(pd); + uobj_put_read(pduobj); err_free: uobj_alloc_abort(uobj, attrs); @@ -864,7 +864,7 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) put_uobj_pd: if (cmd.flags & IB_MR_REREG_PD) - uobj_put_obj_read(pd); + uobj_put_read(pduobj); put_uobjs: uobj_put_write(uobj); @@ -936,13 +936,13 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs) if (ret) goto err_copy; - uobj_put_obj_read(pd); + uobj_put_read(pduobj); return uobj_alloc_commit(uobj, attrs); err_copy: uverbs_dealloc_mw(mw); err_put: - uobj_put_obj_read(pd); + uobj_put_read(pduobj); err_free: uobj_alloc_abort(uobj, attrs); return ret; @@ -1144,7 +1144,7 @@ static int ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs) ret = uverbs_response(attrs, &resp, sizeof(resp)); out: - uobj_put_obj_read(cq); + uobj_put_read(cquobj); return ret; } @@ -1229,7 +1229,7 @@ static int ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs) ret = uverbs_output_written(attrs, UVERBS_ATTR_CORE_OUT); out_put: - uobj_put_obj_read(cq); + uobj_put_read(cquobj); return ret; } @@ -1252,7 +1252,7 @@ static int ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs) ib_req_notify_cq(cq, cmd.solicited_only ? IB_CQ_SOLICITED : IB_CQ_NEXT_COMP); - uobj_put_obj_read(cq); + uobj_put_read(cquobj); return 0; } @@ -1505,15 +1505,15 @@ static int create_qp(struct uverbs_attr_bundle *attrs, } if (pd) - uobj_put_obj_read(pd); + uobj_put_read(pd_uobj); if (scq) - uobj_put_obj_read(scq); + uobj_put_read(scq_uobj); if (rcq && rcq != scq) - uobj_put_obj_read(rcq); + uobj_put_read(rcq_uobj); if (srq) - uobj_put_obj_read(srq); + uobj_put_read(srq_uobj); if (ind_tbl) - uobj_put_obj_read(ind_tbl); + uobj_put_read(ind_tbl_uobj); return uobj_alloc_commit(&obj->uevent.uobject, attrs); err_cb: @@ -1523,15 +1523,15 @@ static int create_qp(struct uverbs_attr_bundle *attrs, if (!IS_ERR(xrcd_uobj)) uobj_put_read(xrcd_uobj); if (pd) - uobj_put_obj_read(pd); + uobj_put_read(pd_uobj); if (scq) - uobj_put_obj_read(scq); + uobj_put_read(scq_uobj); if (rcq && rcq != scq) - uobj_put_obj_read(rcq); + uobj_put_read(rcq_uobj); if (srq) - uobj_put_obj_read(srq); + uobj_put_read(srq_uobj); if (ind_tbl) - uobj_put_obj_read(ind_tbl); + uobj_put_read(ind_tbl_uobj); uobj_alloc_abort(&obj->uevent.uobject, attrs); return ret; @@ -1710,7 +1710,7 @@ static int ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs) ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr); - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); if (ret) goto out; @@ -1948,7 +1948,7 @@ static int modify_qp(struct uverbs_attr_bundle *attrs, &attrs->driver_udata); release_qp: - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); out: kfree(attr); @@ -2216,11 +2216,11 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs) ret = ret2; out_put: - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); while (wr) { if (is_ud && ud_wr(wr)->ah) - uobj_put_obj_read(ud_wr(wr)->ah); + uobj_put_read(ud_wr(wr)->ah->uobject); next = wr->next; kfree(wr); wr = next; @@ -2360,7 +2360,7 @@ static int ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs) resp.bad_wr = 0; ret = qp->device->ops.post_recv(qp->real_qp, wr, &bad_wr); - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); if (ret) { for (next = wr; next; next = next->next) { ++resp.bad_wr; @@ -2412,7 +2412,7 @@ static int ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs) resp.bad_wr = 0; ret = srq->device->ops.post_srq_recv(srq, wr, &bad_wr); - uobj_put_obj_read(srq); + uobj_put_read(srquobj); if (ret) for (next = wr; next; next = next->next) { @@ -2501,7 +2501,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) if (ret) goto err_copy; - uobj_put_obj_read(pd); + uobj_put_read(pduobj); return uobj_alloc_commit(uobj, attrs); err_copy: @@ -2509,7 +2509,7 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) uverbs_get_cleared_udata(attrs)); err_put: - uobj_put_obj_read(pd); + uobj_put_read(pduobj); err: uobj_alloc_abort(uobj, attrs); @@ -2573,7 +2573,7 @@ static int ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs) out_put: mutex_unlock(&obj->mcast_lock); - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); return ret; } @@ -2618,7 +2618,7 @@ static int ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs) out_put: mutex_unlock(&obj->mcast_lock); - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); return ret; } @@ -2737,7 +2737,7 @@ static int kern_spec_to_ib_spec_action(struct uverbs_attr_bundle *attrs, flow_resources_add(uflow_res, IB_FLOW_SPEC_ACTION_HANDLE, ib_spec->action.act); - uobj_put_obj_read(ib_spec->action.act); + uobj_put_read(uobj); break; case IB_FLOW_SPEC_ACTION_COUNT: if (kern_spec->flow_count.size != @@ -2755,7 +2755,7 @@ static int kern_spec_to_ib_spec_action(struct uverbs_attr_bundle *attrs, flow_resources_add(uflow_res, IB_FLOW_SPEC_ACTION_COUNT, ib_spec->flow_count.counters); - uobj_put_obj_read(ib_spec->flow_count.counters); + uobj_put_read(uobj); break; default: return -EINVAL; @@ -3022,16 +3022,16 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) if (err) goto err_copy; - uobj_put_obj_read(pd); - uobj_put_obj_read(cq); + uobj_put_read(pduobj); + uobj_put_read(cquobj); return uobj_alloc_commit(&obj->uevent.uobject, attrs); err_copy: ib_destroy_wq(wq, uverbs_get_cleared_udata(attrs)); err_put_cq: - uobj_put_obj_read(cq); + uobj_put_read(cquobj); err_put_pd: - uobj_put_obj_read(pd); + uobj_put_read(pduobj); err_uobj: uobj_alloc_abort(&obj->uevent.uobject, attrs); @@ -3097,7 +3097,7 @@ static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs) } ret = wq->device->ops.modify_wq(wq, &wq_attr, cmd.attr_mask, &attrs->driver_udata); - uobj_put_obj_read(wq); + uobj_put_read(wquobj); return ret; } @@ -3201,7 +3201,7 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs) kfree(wqs_handles); for (j = 0; j < num_read_wqs; j++) - uobj_put_obj_read(wqs[j]); + uobj_put_read(wqs[j]->uobject); return uobj_alloc_commit(uobj, attrs); @@ -3211,7 +3211,7 @@ static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs) uobj_alloc_abort(uobj, attrs); put_wqs: for (j = 0; j < num_read_wqs; j++) - uobj_put_obj_read(wqs[j]); + uobj_put_read(wqs[j]->uobject); err_free: kfree(wqs_handles); kfree(wqs); @@ -3380,7 +3380,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) if (err) goto err_copy; - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); kfree(flow_attr); if (cmd.flow_attr.num_of_specs) kfree(kern_flow_attr); @@ -3393,7 +3393,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) err_free_flow_attr: kfree(flow_attr); err_put: - uobj_put_obj_read(qp); + uobj_put_read(qpuobj); err_uobj: uobj_alloc_abort(uobj, attrs); err_free_attr: @@ -3532,9 +3532,9 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, uobj_put_read(xrcd_uobj); if (ib_srq_has_cq(cmd->srq_type)) - uobj_put_obj_read(attr.ext.cq); + uobj_put_read(cquobj); - uobj_put_obj_read(pd); + uobj_put_read(pduobj); return uobj_alloc_commit(&obj->uevent.uobject, attrs); err_copy: @@ -3543,11 +3543,11 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, err_free: kfree(srq); err_put: - uobj_put_obj_read(pd); + uobj_put_read(pduobj); err_put_cq: if (ib_srq_has_cq(cmd->srq_type)) - uobj_put_obj_read(attr.ext.cq); + uobj_put_read(cquobj); err_put_xrcd: if (cmd->srq_type == IB_SRQT_XRC) { @@ -3617,7 +3617,7 @@ static int ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs) ret = srq->device->ops.modify_srq(srq, &attr, cmd.attr_mask, &attrs->driver_udata); - uobj_put_obj_read(srq); + uobj_put_read(srquobj); return ret; } @@ -3642,7 +3642,7 @@ static int ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs) ret = ib_query_srq(srq, &attr); - uobj_put_obj_read(srq); + uobj_put_read(srquobj); if (ret) return ret; @@ -3769,7 +3769,7 @@ 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); - uobj_put_obj_read(cq); + uobj_put_read(cquobj); return ret; } diff --git a/include/rdma/uverbs_std_types.h b/include/rdma/uverbs_std_types.h index 578e5c28bc1c..02641a3241e3 100644 --- a/include/rdma/uverbs_std_types.h +++ b/include/rdma/uverbs_std_types.h @@ -98,9 +98,6 @@ static inline void uobj_put_read(struct ib_uobject *uobj) rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_READ); } -#define uobj_put_obj_read(_obj) \ - uobj_put_read((_obj)->uobject) - static inline void uobj_put_write(struct ib_uobject *uobj) { rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); From patchwork Wed Aug 21 14:21:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F296A14DE for ; Wed, 21 Aug 2019 14:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C640A22D6D for ; Wed, 21 Aug 2019 14:22:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="amFVAWe1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729484AbfHUOW1 (ORCPT ); Wed, 21 Aug 2019 10:22:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44772 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfHUOW1 (ORCPT ); Wed, 21 Aug 2019 10:22:27 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEF3s087562; Wed, 21 Aug 2019 14:22:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=viZ0rpJhtreNNatRCsPHwnK5It+ZresIydLMQiXle/U=; b=amFVAWe1HpLZ+XSBANzS3K++vtElHKv127+QabbXpQg+nwRmLIpm6wxlmZe5ENuwi8AX ZHJuqacoi2tHPkKsHI+VgPotya+zfOKNBXvxohmdM6NbsAyalOcR0S0FtWBFfN/XVcst 0mFvF2uR8RuFrvSYAcuAPNNAbN844Bf5SydPpfebj6+PvxCZvLYAVCIhiPHkIgo7Fl/o 778o1e4QbQDkK2V4RgkMItTC40vvpG33Orpu74KRYKNIGnj6hmUcHWi/2A3ltSVSdpKK ldjntPM6VyJzdaxU6N0x2dVVB4PXJmgDKxTUDwvSytMpcGGzPp3HPnQjrWhEQ/zIkKvu Eg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2ue9hpnuw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:00 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEIZ6w094298; Wed, 21 Aug 2019 14:22:00 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2ugj7py7r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:00 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LELwT5014580; Wed, 21 Aug 2019 14:21:58 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:21:57 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 03/24] RDMA/nldev: ib_pd can be pointed by multiple ib_ucontext Date: Wed, 21 Aug 2019 17:21:04 +0300 Message-Id: <20190821142125.5706-4-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch In shared object model ib_pd can belong to 1 or more ib_ucontext. Fix the nldev code so it could report multiple context ids. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/nldev.c | 127 +++++++++++++++++++++++++++++-- include/uapi/rdma/rdma_netlink.h | 3 + 2 files changed, 125 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index e287b71a1cfd..7ad23a6607f7 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -41,6 +41,7 @@ #include "core_priv.h" #include "cma_priv.h" #include "restrack.h" +#include "uverbs.h" /* * Sort array elements by the netlink attribute name @@ -141,6 +142,8 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { [RDMA_NLDEV_ATTR_UVERBS_DRIVER_ID] = { .type = NLA_U32 }, [RDMA_NLDEV_NET_NS_FD] = { .type = NLA_U32 }, [RDMA_NLDEV_SYS_ATTR_NETNS_MODE] = { .type = NLA_U8 }, + [RDMA_NLDEV_ATTR_RES_CTX] = { .type = NLA_NESTED }, + [RDMA_NLDEV_ATTR_RES_CTX_ENTRY] = { .type = NLA_NESTED }, }; static int put_driver_name_print_type(struct sk_buff *msg, const char *name, @@ -611,11 +614,84 @@ static int fill_res_mr_entry(struct sk_buff *msg, bool has_cap_net_admin, err: return -EMSGSIZE; } +struct context_id { + struct list_head list; + u32 id; +}; + +static void pd_context(struct ib_pd *pd, struct list_head *list, int *count) +{ + struct ib_device *device = pd->device; + struct rdma_restrack_entry *res; + struct rdma_restrack_root *rt; + struct ib_uverbs_file *ufile; + struct ib_ucontext *ucontext; + struct ib_uobject *uobj; + unsigned long flags; + unsigned long id; + bool found; + + rt = &device->res[RDMA_RESTRACK_CTX]; + + xa_lock(&rt->xa); + + xa_for_each(&rt->xa, id, res) { + if (!rdma_is_visible_in_pid_ns(res)) + continue; + + if (!rdma_restrack_get(res)) + continue; + + xa_unlock(&rt->xa); + + ucontext = container_of(res, struct ib_ucontext, res); + ufile = ucontext->ufile; + found = false; + + /* See locking requirements in struct ib_uverbs_file */ + down_read(&ufile->hw_destroy_rwsem); + spin_lock_irqsave(&ufile->uobjects_lock, flags); + + list_for_each_entry(uobj, &ufile->uobjects, list) { + if (uobj->object == pd) { + found = true; + goto found; + } + } + +found: spin_unlock_irqrestore(&ufile->uobjects_lock, flags); + up_read(&ufile->hw_destroy_rwsem); + + if (found) { + struct context_id *ctx_id = + kmalloc(sizeof(*ctx_id), GFP_KERNEL); + + if (WARN_ON_ONCE(!ctx_id)) + goto next; + + ctx_id->id = ucontext->res.id; + list_add(&ctx_id->list, list); + (*count)++; + } + +next: rdma_restrack_put(res); + xa_lock(&rt->xa); + } + + xa_unlock(&rt->xa); +} + static int fill_res_pd_entry(struct sk_buff *msg, bool has_cap_net_admin, struct rdma_restrack_entry *res, uint32_t port) { struct ib_pd *pd = container_of(res, struct ib_pd, res); struct ib_device *dev = pd->device; + struct nlattr *table_attr = NULL; + struct nlattr *entry_attr = NULL; + struct context_id *ctx_id; + struct context_id *tmp; + LIST_HEAD(pd_context_ids); + int ctx_count = 0; if (has_cap_net_admin) { if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY, @@ -633,10 +709,38 @@ static int fill_res_pd_entry(struct sk_buff *msg, bool has_cap_net_admin, if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PDN, res->id)) goto err; - if (!rdma_is_kernel_res(res) && - nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN, - pd->uobject->context->res.id)) - goto err; + if (!rdma_is_kernel_res(res)) { + pd_context(pd, &pd_context_ids, &ctx_count); + if (ctx_count == 1) { + /* user pd, not shared */ + ctx_id = list_first_entry(&pd_context_ids, + struct context_id, list); + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN, + ctx_id->id)) + goto err; + } else if (ctx_count > 1) { + /* user pd, shared */ + table_attr = nla_nest_start(msg, + RDMA_NLDEV_ATTR_RES_CTX); + if (!table_attr) + goto err; + + list_for_each_entry(ctx_id, &pd_context_ids, list) { + entry_attr = nla_nest_start(msg, + RDMA_NLDEV_ATTR_RES_CTX_ENTRY); + if (!entry_attr) + goto err; + if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN, + ctx_id->id)) + goto err; + nla_nest_end(msg, entry_attr); + entry_attr = NULL; + } + + nla_nest_end(msg, table_attr); + table_attr = NULL; + } + } if (fill_res_name_pid(msg, res)) goto err; @@ -644,9 +748,22 @@ static int fill_res_pd_entry(struct sk_buff *msg, bool has_cap_net_admin, if (fill_res_entry(dev, msg, res)) goto err; + list_for_each_entry_safe(ctx_id, tmp, &pd_context_ids, list) + kfree(ctx_id); + return 0; -err: return -EMSGSIZE; +err: + if (entry_attr) + nla_nest_end(msg, entry_attr); + + if (table_attr) + nla_nest_end(msg, table_attr); + + list_for_each_entry_safe(ctx_id, tmp, &pd_context_ids, list) + kfree(ctx_id); + + return -EMSGSIZE; } static int fill_stat_counter_mode(struct sk_buff *msg, diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h index 8e277783fa96..7fbbfb07f071 100644 --- a/include/uapi/rdma/rdma_netlink.h +++ b/include/uapi/rdma/rdma_netlink.h @@ -525,6 +525,9 @@ enum rdma_nldev_attr { */ RDMA_NLDEV_ATTR_DEV_DIM, /* u8 */ + RDMA_NLDEV_ATTR_RES_CTX, /* nested table */ + RDMA_NLDEV_ATTR_RES_CTX_ENTRY, /* nested table */ + /* * Always the end */ From patchwork Wed Aug 21 14:21:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF6EF14DE for ; Wed, 21 Aug 2019 14:22:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B30F422D6D for ; Wed, 21 Aug 2019 14:22:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lzS1lkVe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729367AbfHUOWZ (ORCPT ); Wed, 21 Aug 2019 10:22:25 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37864 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729646AbfHUOWY (ORCPT ); Wed, 21 Aug 2019 10:22:24 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEMAQ077937; Wed, 21 Aug 2019 14:22:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=W7/pUu22+A8c1nExIS3YuA36jEctFTpHfpteDc9MWXI=; b=lzS1lkVeiyy0D8ffVo9g1lkKB7rxbaX0MAweWDP7nsupje3+rWZ1T8h0pmLWcMwzlJv1 /yzKzrLDz/24/mDVRZAbzBHlw4/nqQ6P6QSmPv9oX82Uxu5lohhJHU3Bj+snFSwS4jnF mq6Fg7QouH6w5MRZM8rBEpYZDysq+1KFjirKTr2kZ8ePEkwTMPx+QNba4G2JH0aGTpiM CdfbzJUNAMA8OghgTUEqGyWP1y5+hElVtKzmSgrft9ZJnJjnuYnTniURFFEKdK1IB35i bw64YimlREHnDRbTopn/J6FMqxCyg+BnWedvoO1xQH1YiXQj7VjRSM6CIjUESxGlR91k rA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uea7qwxfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:06 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEIY58094263; Wed, 21 Aug 2019 14:22:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2ugj7py7uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:06 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LEM3J7014627; Wed, 21 Aug 2019 14:22:04 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:03 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 04/24] IB/{core,hw}: ib_pd should not have ib_uobject pointer Date: Wed, 21 Aug 2019 17:21:05 +0300 Message-Id: <20190821142125.5706-5-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch As a preparation step to shared PD, where ib_pd object will be pointed by one or more ib_uobjects, remove ib_uobject pointer from ib_pd struct. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs_cmd.c | 1 - drivers/infiniband/core/verbs.c | 1 - drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 1 - drivers/infiniband/hw/mlx5/main.c | 1 - drivers/infiniband/hw/mthca/mthca_qp.c | 3 ++- include/rdma/ib_verbs.h | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 204a93305f1c..d1f0c04f0ae8 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -432,7 +432,6 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs) } pd->device = ib_dev; - pd->uobject = uobj; pd->__internal_mr = NULL; atomic_set(&pd->usecnt, 0); pd->res.type = RDMA_RESTRACK_PD; diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index f974b6854224..1d0215c1a504 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -263,7 +263,6 @@ struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags, return ERR_PTR(-ENOMEM); pd->device = device; - pd->uobject = NULL; pd->__internal_mr = NULL; atomic_set(&pd->usecnt, 0); pd->flags = flags; diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index 0ff5f9617639..bd4a09b2ec1e 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c @@ -760,7 +760,6 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) free_mr->mr_free_pd = to_hr_pd(pd); free_mr->mr_free_pd->ibpd.device = &hr_dev->ib_dev; - free_mr->mr_free_pd->ibpd.uobject = NULL; free_mr->mr_free_pd->ibpd.__internal_mr = NULL; atomic_set(&free_mr->mr_free_pd->ibpd.usecnt, 0); diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 98e566acb746..93db6d4c7da4 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -4937,7 +4937,6 @@ static int create_dev_resources(struct mlx5_ib_resources *devr) return -ENOMEM; devr->p0->device = ibdev; - devr->p0->uobject = NULL; atomic_set(&devr->p0->usecnt, 0); ret = mlx5_ib_alloc_pd(devr->p0, NULL); diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index d04c245359eb..b1a9169e3af6 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -956,7 +956,8 @@ static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int d static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size) { /* We don't support inline data for kernel QPs (yet). */ - return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; + return !rdma_is_kernel_res(&pd->ibpd.res) ? + max_data_size - MTHCA_INLINE_HEADER_SIZE : 0; } static void mthca_adjust_qp_caps(struct mthca_dev *dev, diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 391499008a22..7b429b2e7cf6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1509,7 +1509,6 @@ struct ib_pd { u32 local_dma_lkey; u32 flags; struct ib_device *device; - struct ib_uobject *uobject; atomic_t usecnt; /* count all resources */ u32 unsafe_global_rkey; From patchwork Wed Aug 21 14:21:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E36613A4 for ; Wed, 21 Aug 2019 14:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C39B22D6D for ; Wed, 21 Aug 2019 14:22:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="a1l6JjQL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729366AbfHUOWe (ORCPT ); Wed, 21 Aug 2019 10:22:34 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38048 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfHUOWd (ORCPT ); Wed, 21 Aug 2019 10:22:33 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEHrL077884; Wed, 21 Aug 2019 14:22:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=GppTcegOZNSFGJx1fZ1VJ8VchLWZNXF7yVI4JCwVViI=; b=a1l6JjQL3srCpIrankLXfRjpiqTxJXo28adF9cq/IdDuPV48M+YJ9b40i9XhztQBMaaE LQUuQkT+wx0TzeNmdnOq1rZrizuU+85cPYtZbR+Iz0suG0FsL2FeVuvQu+AHcwQjeSyr UDK/9yXOh0n/LAHB7i+Zu4K5ErjGxAicSCfhwd4y3QKwuz9wuBHRcZSAtjI6a8ROguRy hOY1v8FLlrGYBH1YIBs5ToI5xB5zWwLXmDK92Ywe0dzMXe1sPFghiOkuVxXC+HubmSaV T2jkUoES8rJE7w4PnXreYur7llRbI/juxLLegdKlIooSzMGNzRDSQ0S6nrtxv7bpbef2 Tg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2uea7qwxh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEIV5q182086; Wed, 21 Aug 2019 14:22:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2ugj7qgdq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:14 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LEM9oX016984; Wed, 21 Aug 2019 14:22:10 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:09 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 05/24] IB/core: ib_uobject need HW object reference count Date: Wed, 21 Aug 2019 17:21:06 +0300 Message-Id: <20190821142125.5706-6-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch This new refcnt will points to the refcnt member of the HW object and will behaves as expected by refcnt, i.e. will be increased and decreased as a result of usage changes and will destroy the object when reaches to zero. For a non-shared object refcnt will remain NULL. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/rdma_core.c | 23 +++++++++++++++++++++-- include/rdma/ib_verbs.h | 7 +++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c index ccf4d069c25c..651625f632d7 100644 --- a/drivers/infiniband/core/rdma_core.c +++ b/drivers/infiniband/core/rdma_core.c @@ -516,7 +516,26 @@ static int __must_check destroy_hw_idr_uobject(struct ib_uobject *uobj, const struct uverbs_obj_idr_type *idr_type = container_of(uobj->uapi_object->type_attrs, struct uverbs_obj_idr_type, type); - int ret = idr_type->destroy_object(uobj, why, attrs); + static DEFINE_MUTEX(lock); + int ret, count; + + mutex_lock(&lock); + + if (uobj->refcnt) { + count = atomic_dec_return(uobj->refcnt); + WARN_ON(count < 0); /* use after free! */ + if (count) { + mutex_unlock(&lock); + goto skip; + } + } + + ret = idr_type->destroy_object(uobj, why, attrs); + + if (ret) + atomic_inc(uobj->refcnt); + + mutex_unlock(&lock); /* * We can only fail gracefully if the user requested to destroy the @@ -525,7 +544,7 @@ static int __must_check destroy_hw_idr_uobject(struct ib_uobject *uobj, */ if (ib_is_destroy_retryable(ret, why, uobj)) return ret; - +skip: if (why == RDMA_REMOVE_ABORT) return 0; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 7b429b2e7cf6..7e69866fc419 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1496,6 +1496,13 @@ struct ib_uobject { struct rcu_head rcu; /* kfree_rcu() overhead */ const struct uverbs_api_object *uapi_object; + + /* + * ib_X HW object sharing support + * - NULL for HW objects that are not shareable + * - Pointer to ib_X reference counter for shareable HW objects + */ + atomic_t *refcnt; /* ib_X object ref count */ }; struct ib_udata { From patchwork Wed Aug 21 14:21:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 425BF14DE for ; Wed, 21 Aug 2019 14:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FE09233A1 for ; Wed, 21 Aug 2019 14:22:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Z/zvsYF2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729419AbfHUOWp (ORCPT ); Wed, 21 Aug 2019 10:22:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60130 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfHUOWp (ORCPT ); Wed, 21 Aug 2019 10:22:45 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEGqM063028; Wed, 21 Aug 2019 14:22:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=ybhLgSGVLJ67m4QDxTOeSAqQDsQJq+m/uygR3hR2iRA=; b=Z/zvsYF2RdvlbLwWUmW/hMr4V4beXwEWTm/2Pg/cYIhJ9tbya0mIZdN8vwrAUW7xxtxg EGcfgfqkL4j/+k14ReoCNqx1gJOVFWB9HWSqN5ogZ9CWFrYJQhya454ofWYK8Dnbzuz6 /m5lZV5G76Sf8USjh1ksKtVZuGclIBVts0hZs3363C5zxQHCyBD8Zi0kGcomIUOw/7sm wnXZ8mrs/2LP9RaIhO1Rdwxhsvtido+06bIqvP4akRyho8h2XMMpz+QS9nVCASc4JOxs OWxmoE5c+stpjMy5mS26Qx6tihnlTohDWMRW8ZvFutL9n4nCF77UtqjbmbfwBx1pKqro jQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2ue90tp3tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:19 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEIaa2094365; Wed, 21 Aug 2019 14:22:18 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2ugj7py818-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:17 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LEMFLT014800; Wed, 21 Aug 2019 14:22:15 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:15 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 06/24] IB/uverbs: Helper function to initialize ufile member of uverbs_attr_bundle Date: Wed, 21 Aug 2019 17:21:07 +0300 Message-Id: <20190821142125.5706-7-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Helper function to initialize ufile member of structure uverbs_attr_bundle. This helper produce structure uverbs_attr_bundle that is safe for the below operations on the given ufile: - uobj_get_[read|write] - uobj_alloc_commit - uobj_alloc_abort The last 2 ops are more complicated. Abort for example triggers the below which pass the uverbs_attr_bundle driver_udata down to the drivers level: uobj_alloc_abort rdma_alloc_abort_uobject uverbs_destroy_uobject uobj->uapi_object->type_class->destroy_hw destroy_hw_idr_uobject idr_type->destroy_object uverbs_free_pd ib_dealloc_pd_user pd->device->ops.dealloc_pd mlx4_ib_dealloc_pd For more information about the potential issues, please see commit f89adedaf3fe ("RDMA/uverbs: Initialize udata struct on destroy flows") Cc: Gal Pressman Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs_cmd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index d1f0c04f0ae8..4f42f9732dca 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -3773,6 +3773,24 @@ static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs) return ret; } +/** + * uverbs_init_attrs_ufile - Helper function to create minimal + * uverbs_attr_bundle out of ib_uverbs_file that is suitable + * for the below operations: + * + * - uobj_get_[read|write] + * - uobj_alloc_commit + * - uobj_alloc_abort + */ +static void uverbs_init_attrs_ufile(struct uverbs_attr_bundle *attrs_bundle, + struct ib_uverbs_file *ufile) +{ + *attrs_bundle = (struct uverbs_attr_bundle) { + .ufile = ufile, + .context = ufile->ucontext, + }; +} + /* * Describe the input structs for write(). Some write methods have an input * only struct, most have an input and output. If the struct has an output then From patchwork Wed Aug 21 14:21:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EE1813A4 for ; Wed, 21 Aug 2019 14:22:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40F40233A2 for ; Wed, 21 Aug 2019 14:22:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="G5QAXBhh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729298AbfHUOWu (ORCPT ); Wed, 21 Aug 2019 10:22:50 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60270 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfHUOWu (ORCPT ); Wed, 21 Aug 2019 10:22:50 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEFbx062990; Wed, 21 Aug 2019 14:22:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=Bw5rBVMtFc/wy4cPAyGoP+bM791bvmcREz2jMYPokbQ=; b=G5QAXBhhZbet9kbUtQvhJT/6pQqBXXaD91waaKbRUrHMTeaHz5z1ujJZ5NYP9/ECNchn AqmL4cD74Z67lfRwl1ngRMnf1uMUCyg9xAUXAVuln1VRZhdc8zwFpXBz+kYICu2lu7Mb Cu5xidsdkw4pycHRwtjsE6uSmXPEL6Y64shF1nGXFOKfO+qvnlLwWEuTC5zQbCItvFnc k64eHfCD5Gcdg2OrHT7CPke4IDQFMZERkwbM82wLgIcUln3sT36RtbmpPTjIyHNkumVK s7rx2+MTKHVfB0O/HO2mJnuQicwoKF54SAVf2JBIjsAo9l1Ec5HFxltgqxNGJ9/isaMG ZA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp3u4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:25 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEI5uh001562; Wed, 21 Aug 2019 14:22:25 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2uh2q4jvq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:24 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEMMxm031044; Wed, 21 Aug 2019 14:22:22 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:21 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 07/24] IB/uverbs: Add context import lock/unlock helper Date: Wed, 21 Aug 2019 17:21:08 +0300 Message-Id: <20190821142125.5706-8-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch The lock/unlock helpers will be used in every import verb. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs.h | 2 + drivers/infiniband/core/uverbs_cmd.c | 73 +++++++++++++++++++++++++++ drivers/infiniband/core/uverbs_main.c | 1 + 3 files changed, 76 insertions(+) diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 1e5aeb39f774..cf76336cb460 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -163,6 +163,8 @@ struct ib_uverbs_file { struct page *disassociate_page; struct xarray idr; + + struct file *filp; }; struct ib_uverbs_event { diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 4f42f9732dca..21f0a1a986f4 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -43,6 +43,7 @@ #include #include +#include #include "rdma_core.h" #include "uverbs.h" @@ -3791,6 +3792,78 @@ static void uverbs_init_attrs_ufile(struct uverbs_attr_bundle *attrs_bundle, }; } +/* ib_uverbs_import_lock - Function which gathers code that is + * common in the import verbs. + * + * This function guarntee that both source and destination files are + * protected from race with vfs close. The current file is protected + * from such race because verb is executed in a system-call context. + * The other file is protected by 'fget'. This function also ensures + * that ib_uobject identified by the type & handle is locked for read. + * + * Callers of this helper must also call ib_uverbs_import_unlock + * to undo any locking performed by this helper. + */ +static int ib_uverbs_import_lock(struct uverbs_attr_bundle *attrs, + int fd, u16 type, u32 handle, + struct ib_uobject **uobj, + struct file **filep, + struct ib_uverbs_file **ufile) +{ + struct ib_uverbs_file *file = attrs->ufile; + struct ib_uverbs_device *dev = file->device; + struct uverbs_attr_bundle fd_attrs; + struct ib_uverbs_device *fd_dev; + int ret = 0; + + *filep = fget(fd); + if (!*filep) + return -EINVAL; + + /* check uverbs ops exist */ + if ((*filep)->f_op != file->filp->f_op) { + ret = -EINVAL; + goto file; + } + + *ufile = (*filep)->private_data; + fd_dev = (*ufile)->device; + + /* check that both files belong to same ib_device */ + if (dev != fd_dev) { + ret = -EINVAL; + goto file; + } + + uverbs_init_attrs_ufile(&fd_attrs, *ufile); + + *uobj = uobj_get_read(type, handle, &fd_attrs); + if (IS_ERR(*uobj)) { + ret = -EINVAL; + goto file; + } + + /* verify ib_object is shareable */ + if (!(*uobj)->refcnt) { + ret = -EINVAL; + goto uobj; + } + + return 0; +uobj: + uobj_put_read(*uobj); +file: + fput(*filep); + return ret; +} + +static void ib_uverbs_import_unlock(struct ib_uobject *uobj, + struct file *filep) +{ + uobj_put_read(uobj); + fput(filep); +} + /* * Describe the input structs for write(). Some write methods have an input * only struct, most have an input and output. If the struct has an output then diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 02b57240176c..e42a9b5c38b2 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -1095,6 +1095,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) mutex_init(&file->umap_lock); INIT_LIST_HEAD(&file->umaps); + file->filp = filp; filp->private_data = file; list_add_tail(&file->list, &dev->uverbs_file_list); mutex_unlock(&dev->lists_mutex); From patchwork Wed Aug 21 14:21:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8080414DE for ; Wed, 21 Aug 2019 14:23:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DD3B2339F for ; Wed, 21 Aug 2019 14:23:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aNxfrev1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728822AbfHUOXx (ORCPT ); Wed, 21 Aug 2019 10:23:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:39964 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728763AbfHUOXx (ORCPT ); Wed, 21 Aug 2019 10:23:53 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENUbS086665; Wed, 21 Aug 2019 14:23:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=hxQ7v0ZAlsn4Kc8VCMu3kQCTjzQEaIaEBjFcEOYAzw0=; b=aNxfrev1CpgoxMg2mS3J/HwG1HP30JFCtg4+m8VpXSKKfPVyH0/Xu5EYvEp0OgUJTjXu Mhoy7z3uBxWCJ50SaVDPlAdZYarWaEa8Ktgw3AKTI/akXpGvggp4tvsoLQavKczs8EZX mATHZyrO8mmxO3bFWMqSq4oNhUpK3cb1EgQh3A3Ma1jDiCihQ6YadELTegcs+8FyLHgd ZrHbGszTg6NOzUNJiXS7ux8Gz7NV6+oCKdENUL7x2wcBh4AdGYvlf3SQggq1J+b0616c nuYlSxvHC4cMV6cEDTfrKqgEyq2RVuUFEZvcjdt/KDjUlJ2Wj10/MMo03pkCKiFG0dLB Lg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2uea7qwxq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:30 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMqa6017052; Wed, 21 Aug 2019 14:23:27 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2uh2q4jwr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:27 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LEMRE4014977; Wed, 21 Aug 2019 14:22:28 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:27 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 08/24] IB/verbs: Prototype of HW object clone callback Date: Wed, 21 Aug 2019 17:21:09 +0300 Message-Id: <20190821142125.5706-9-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Define prototype for clone callback. The clone callback is used by the driver layer to supply the uverbs a way to clone IB HW object driver data to rdma-core user space provider. The clone callback is used when new IB HW object is created and every time it is imported to some ib_ucontext. Drivers that wish to enable share of some IB HW object (ib_pd, ib_mr, etc..) must supply valid clone callback for that type. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch Signed-off-by: Yuval Shaia --- include/rdma/ib_verbs.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 7e69866fc419..542b3cb2d943 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2265,6 +2265,18 @@ struct iw_cm_conn_param; #define DECLARE_RDMA_OBJ_SIZE(ib_struct) size_t size_##ib_struct +/* + * Prototype for IB HW object clone callback + * + * Define prototype for clone callback. The clone callback is used + * by the driver layer to supply the uverbs a way to clone IB HW + * object driver data to rdma-core user space provider. The clone + * callback is used when new IB HW object is created and every time + * it is imported to some ib_ucontext. + */ +#define clone_callback(ib_type) \ + int (*clone_##ib_type)(struct ib_udata *udata, struct ib_type *obj) + /** * struct ib_device_ops - InfiniBand device operations * This structure defines all the InfiniBand device operations, providers will @@ -2575,6 +2587,9 @@ struct ib_device_ops { */ int (*counter_update_stats)(struct rdma_counter *counter); + /* Object sharing callbacks */ + clone_callback(ib_pd); + DECLARE_RDMA_OBJ_SIZE(ib_ah); DECLARE_RDMA_OBJ_SIZE(ib_cq); DECLARE_RDMA_OBJ_SIZE(ib_pd); @@ -2582,6 +2597,17 @@ struct ib_device_ops { DECLARE_RDMA_OBJ_SIZE(ib_ucontext); }; +/* Implementation of trivial clone callback */ +#define trivial_clone_callback(ib_type) \ +static inline int trivial_clone_##ib_type(struct ib_udata *udata, \ + struct ib_type *obj) \ +{ \ + return 0; \ +} + +/* Shared IB HW object support */ +trivial_clone_callback(ib_pd); + struct ib_core_device { /* device must be the first element in structure until, * union of ib_core_device and device exists in ib_device. From patchwork Wed Aug 21 14:21:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF15B13A4 for ; Wed, 21 Aug 2019 14:24:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D33922D6D for ; Wed, 21 Aug 2019 14:24:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="l34rM54R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729229AbfHUOYS (ORCPT ); Wed, 21 Aug 2019 10:24:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34366 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728964AbfHUOYR (ORCPT ); Wed, 21 Aug 2019 10:24:17 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENWeZ071704; Wed, 21 Aug 2019 14:23:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=FaBDk7OSAkmSxY+zCV3PrdymypidNY6nBNO/RUmgDts=; b=l34rM54RxVWotMXKY1j0xwzc9WEOXXiDZlMFxEPze9Q5qqcMMWERSP4nSbeLFFfAsBZJ eguxQ1xA/Wy4c4yqN3pFIkwIKIoRi3dX9krc27xTIQ4Iv8o7jjZ44v4M3vm+0uro5uON 4Y1vFZ7dRRUrQukZeIsMY2V+lJvcQNIsIj1xOG38/icMyZjaUU1NaYWx+mH1yeggMhyI GSlNkWmxeRdmqQEn0RejM39yfNdl+u8EWNb8jpBPtNqyGRXY7NZYzQnqm5RHqwBjna/I 7DEl1xhB1c7F33uryqOSVpinnkx8RVgeXBPrLcCQf3XFqNQjr+s+RbqvAx6bP3h83Tvi 1A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2ue90tp45c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:54 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENPmu194344; Wed, 21 Aug 2019 14:23:54 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2ugj7qgdya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:53 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEMX8o010898; Wed, 21 Aug 2019 14:22:33 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:33 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 09/24] IB/core: Install clone ib_pd in device ops Date: Wed, 21 Aug 2019 17:21:10 +0300 Message-Id: <20190821142125.5706-10-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Install clone_ib_pd in the device ops. Signed-off-by: Yuval Shaia --- drivers/infiniband/core/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 8892862fb759..8d90e429441f 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2626,6 +2626,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) SET_DEVICE_OP(dev_ops, set_vf_guid); SET_DEVICE_OP(dev_ops, set_vf_link_state); SET_DEVICE_OP(dev_ops, unmap_fmr); + SET_DEVICE_OP(dev_ops, clone_ib_pd); SET_OBJ_SIZE(dev_ops, ib_ah); SET_OBJ_SIZE(dev_ops, ib_cq); From patchwork Wed Aug 21 14:21:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AD2B13A4 for ; Wed, 21 Aug 2019 14:39:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 790E422D6D for ; Wed, 21 Aug 2019 14:39:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JuemfpMN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729366AbfHUOje (ORCPT ); Wed, 21 Aug 2019 10:39:34 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:56240 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729239AbfHUOje (ORCPT ); Wed, 21 Aug 2019 10:39:34 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEd52C086578; Wed, 21 Aug 2019 14:39:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=AL22DhFQL2h05YrnNk4vkx3QgpPetCGoFZEW2DTQpi8=; b=JuemfpMNGJT6YTb0PrELnp5tfdoytSf63TNkh+b610K8jBiAj8SrkzusHB9eRELRZumd VWiHUbKl7pSVfQ/nPhZtUBIDL0J035v1Ti0RkWMQhB2HyNzqs2/MrUlNZe5jf9t2DHm/ C6E2+bcbDLQpQv38nZ4DVJ5kldN2unrA5d4UXr25aOZwvvDqxrxwvdcLse+hM301wlug 1xvyDMgVJ4McL6DQ7IwpMaEMv6MecRBlrwMkQ1A7zQOS/zzrF3o/znwpWrsDI1VbMYRY ub7qU05mak0cEQeM8HweyYfMpQsio5YDmZ4Nx1vNslx2inp9Jx0Pyrhh/P+LtyydDfAI uQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2ue90tp7b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:39:04 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEd1jG045262; Wed, 21 Aug 2019 14:39:04 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2ugj7qguw0-87 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:39:03 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEMdJP031263; Wed, 21 Aug 2019 14:22:39 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:38 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 10/24] IB/mlx4: Add implementation of clone_pd callback Date: Wed, 21 Aug 2019 17:21:11 +0300 Message-Id: <20190821142125.5706-11-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210159 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210159 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Copy mlx4 ib_pd to user-space. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/hw/mlx4/main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 8d2f1e38b891..6baf52d988ed 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -1179,6 +1179,13 @@ static int mlx4_ib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) } } +static int mlx4_ib_clone_pd(struct ib_udata *udata, struct ib_pd *ibpd) +{ + struct mlx4_ib_pd *pd = to_mpd(ibpd); + + return udata ? ib_copy_to_udata(udata, &pd->pdn, sizeof(__u32)) : 0; +} + static int mlx4_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) { struct mlx4_ib_pd *pd = to_mpd(ibpd); @@ -1189,10 +1196,12 @@ static int mlx4_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) if (err) return err; - if (udata && ib_copy_to_udata(udata, &pd->pdn, sizeof(__u32))) { + err = mlx4_ib_clone_pd(udata, ibpd); + if (err) { mlx4_pd_free(to_mdev(ibdev)->dev, pd->pdn); return -EFAULT; } + return 0; } @@ -2565,6 +2574,9 @@ static const struct ib_device_ops mlx4_ib_dev_ops = { .rereg_user_mr = mlx4_ib_rereg_user_mr, .resize_cq = mlx4_ib_resize_cq, + /* Object sharing callbacks */ + .clone_ib_pd = mlx4_ib_clone_pd, + INIT_RDMA_OBJ_SIZE(ib_ah, mlx4_ib_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, mlx4_ib_cq, ibcq), INIT_RDMA_OBJ_SIZE(ib_pd, mlx4_ib_pd, ibpd), From patchwork Wed Aug 21 14:21:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7CE014DE for ; Wed, 21 Aug 2019 14:23:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96367233A1 for ; Wed, 21 Aug 2019 14:23:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Hj7su8Ri" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729339AbfHUOXK (ORCPT ); Wed, 21 Aug 2019 10:23:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60740 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbfHUOXJ (ORCPT ); Wed, 21 Aug 2019 10:23:09 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEbWw063203; Wed, 21 Aug 2019 14:22:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=vk2LYfndXmI8k5pWaqinBWS5l81xac9OZSb+63HN7Mk=; b=Hj7su8RiFxYIiD6lQhBa42S3igVjZiqSdpQIqLmPzm/TNzrmwEuNBhQDcRsAklH61vd9 Eg6y077KJw1zlHYqUwE/gzZVznWtq0EcFvU9m4vLV9bd//l5LrCmE1vHKuTyYNUNv858 CWHB35CiZ1PDs7fDGde1g/7rvqolPZWrFNYnapxd4CwV2rFspXzSqCPro9O7ULI/HM6p A56qTrU2E+zNfaZPBUG+Nb1KJSEGBo0aBfWxqkBdFxou3MfLChaJGMWAJVoAo2El0pL2 GkSYCPKU984St3W7RmXAZY+E2WFw2Nm9dMA0HDgUnvpZbw+GCrJlrnP+0ywK7rQryVe4 KQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ue90tp3v5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:47 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMYbp115048; Wed, 21 Aug 2019 14:22:46 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2ug26a3aay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:46 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEMjfc011046; Wed, 21 Aug 2019 14:22:45 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:44 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 11/24] IB/mlx5: Add implementation of clone_pd callback Date: Wed, 21 Aug 2019 17:21:12 +0300 Message-Id: <20190821142125.5706-12-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Copy mlx5 ib_pd to user-space. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/hw/mlx5/main.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 93db6d4c7da4..63beee644b46 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -2464,11 +2464,24 @@ int mlx5_ib_dealloc_dm(struct ib_dm *ibdm, struct uverbs_attr_bundle *attrs) return 0; } +static int mlx5_ib_clone_pd(struct ib_udata *udata, struct ib_pd *ibpd) +{ + struct mlx5_ib_pd *pd = to_mpd(ibpd); + struct mlx5_ib_alloc_pd_resp resp; + int ret = 0; + + if (udata) { + resp.pdn = pd->pdn; + ret = ib_copy_to_udata(udata, &resp, sizeof(resp)); + } + + return ret; +} + static int mlx5_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) { struct mlx5_ib_pd *pd = to_mpd(ibpd); struct ib_device *ibdev = ibpd->device; - struct mlx5_ib_alloc_pd_resp resp; int err; u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {}; u32 in[MLX5_ST_SZ_DW(alloc_pd_in)] = {}; @@ -2486,12 +2499,11 @@ static int mlx5_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) pd->pdn = MLX5_GET(alloc_pd_out, out, pd); pd->uid = uid; - if (udata) { - resp.pdn = pd->pdn; - if (ib_copy_to_udata(udata, &resp, sizeof(resp))) { - mlx5_cmd_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn, uid); - return -EFAULT; - } + + err = mlx5_ib_clone_pd(udata, ibpd); + if (err) { + mlx5_cmd_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn, uid); + return err; } return 0; @@ -6338,6 +6350,9 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { .rereg_user_mr = mlx5_ib_rereg_user_mr, .resize_cq = mlx5_ib_resize_cq, + /* Object sharing callbacks */ + .clone_ib_pd = mlx5_ib_clone_pd, + INIT_RDMA_OBJ_SIZE(ib_ah, mlx5_ib_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, mlx5_ib_cq, ibcq), INIT_RDMA_OBJ_SIZE(ib_pd, mlx5_ib_pd, ibpd), From patchwork Wed Aug 21 14:21:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106975 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E387013A4 for ; Wed, 21 Aug 2019 14:23:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C24742339F for ; Wed, 21 Aug 2019 14:23:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="O3dw0zkC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728502AbfHUOXT (ORCPT ); Wed, 21 Aug 2019 10:23:19 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60910 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbfHUOXT (ORCPT ); Wed, 21 Aug 2019 10:23:19 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEGjF063005; Wed, 21 Aug 2019 14:22:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=bk/Pph3NxhDkIuaXqS2hPm5wCXjqFUE71S0vwqVO4sE=; b=O3dw0zkCDYwWh/GowJH+jPbnUdpeZJYsXUV5NCFLBKu0mClQZ9iPurSvWuinITGT1d+k QTxrFhcEU4pUz8Ao3irHjs0SZBcLPevy0dF3a/BYp/ul7rTlBE16b3baZdSePTIfq8V/ s1SPRr8T5cVdhkbQE/4G4wfZ/ZvARmvVsAfc1OJFHs63H2rLTprG4pa1pa2Vq09rbWFh zNZTVIzAsviSxlXCfW5Px3OJO6Y2pRd8i1lrDTpOHnqhMdOYn2LYpd7SskyJMYvcvBKp 41/TYA0Hgd/vHxlfFGn52kuRzuRKfBc0qj219OMB8Lz1N/mV+jmV+KbpUNNTXg2D60zA Bg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp3vs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:55 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMqWn017152; Wed, 21 Aug 2019 14:22:54 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2uh2q4jw2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:22:54 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LEMool015290; Wed, 21 Aug 2019 14:22:51 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:50 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 12/24] RDMA/rxe: Add implementation of clone_pd callback Date: Wed, 21 Aug 2019 17:21:13 +0300 Message-Id: <20190821142125.5706-13-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Copy rxe ib_pd to user-space. Signed-off-by: Shamir Rabinovitch Signed-off-by: Yuval Shaia Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/sw/rxe/rxe_verbs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 623129f27f5a..415ac9d3b504 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1148,6 +1148,9 @@ static const struct ib_device_ops rxe_dev_ops = { .req_notify_cq = rxe_req_notify_cq, .resize_cq = rxe_resize_cq, + /* Object sharing callbacks */ + .clone_ib_pd = trivial_clone_ib_pd, + INIT_RDMA_OBJ_SIZE(ib_ah, rxe_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, rxe_cq, ibcq), INIT_RDMA_OBJ_SIZE(ib_pd, rxe_pd, ibpd), From patchwork Wed Aug 21 14:21:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9D3114DE for ; Wed, 21 Aug 2019 14:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97B6322D6D for ; Wed, 21 Aug 2019 14:24:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hgUIxnEY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729220AbfHUOYG (ORCPT ); Wed, 21 Aug 2019 10:24:06 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47128 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbfHUOYF (ORCPT ); Wed, 21 Aug 2019 10:24:05 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENU9Y096318; Wed, 21 Aug 2019 14:23:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=QTwoZmuyHs6Q89b1YUw6drGatd0oTOdtmHNU0OkH720=; b=hgUIxnEYleziend8I/3YTu21MbkWm44VOsWTugbOc14JOHZ3elnbBda2tZv9sWvX95s8 r348EwDkxqV7SUSG718J6wtE1jTbuqxBNdvCYD2l2LuyrSCitT6pR6/A5oars/+nQqfP 2JTccGHDDj4lcynaoYk7sFael/t7zWp0Pn7gaqjxs1OTcJWjgTfr982FUfPJ3sFK6PcO sZ8E44r0rOEv5ZMqfNDQsnT7I67iyq35reW3dY3/EYfaAeFooZT1EQRGoawZhthrrqAk r7M3rK1OexTubDpjUPukma3G9/WdyB0CPG6xvZlnSu6cKcdFuFu/golmtYEDWpmdrSDW Ag== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2ue9hpnva2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:44 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENRDM194557; Wed, 21 Aug 2019 14:23:43 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2ugj7qgeu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:43 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEMutI011105; Wed, 21 Aug 2019 14:22:56 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:22:56 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 13/24] IB/uverbs: Add clone reference counting to ib_pd Date: Wed, 21 Aug 2019 17:21:14 +0300 Message-Id: <20190821142125.5706-14-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch To keep track of shared object life time add ref count to ib_pd Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs_cmd.c | 3 +++ include/rdma/ib_verbs.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 21f0a1a986f4..5800d7e0992a 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -436,12 +436,15 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs) pd->__internal_mr = NULL; atomic_set(&pd->usecnt, 0); pd->res.type = RDMA_RESTRACK_PD; + /* number of uobj using this ib_pd */ + atomic_set(&pd->refcnt, 1); ret = ib_dev->ops.alloc_pd(pd, &attrs->driver_udata); if (ret) goto err_alloc; uobj->object = pd; + uobj->refcnt = &pd->refcnt; memset(&resp, 0, sizeof resp); resp.pd_handle = uobj->id; rdma_restrack_uadd(&pd->res); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 542b3cb2d943..e3ce38aa89b6 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1525,6 +1525,9 @@ struct ib_pd { */ struct ib_mr *__internal_mr; struct rdma_restrack_entry res; + + /* number of uobj using this ib_pd */ + atomic_t refcnt; }; struct ib_xrcd { From patchwork Wed Aug 21 14:21:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107003 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E83214DE for ; Wed, 21 Aug 2019 14:24:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 418F322D6D for ; Wed, 21 Aug 2019 14:24:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="rN4PYYFX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729148AbfHUOYA (ORCPT ); Wed, 21 Aug 2019 10:24:00 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34028 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbfHUOYA (ORCPT ); Wed, 21 Aug 2019 10:24:00 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENWvo071722; Wed, 21 Aug 2019 14:23:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=3gydsN7QeISUqK9TuzvoNnCWwpMrgE7fXbYWGR56EjA=; b=rN4PYYFXjiuoYgeRvQnPTx8I95XK/gJe4cP3Er2aR/DX6cwKHvRf06xkj9md+T4RtTq0 MbH9IoCAJ8uajXP3L2D50fX15Sq+4PscfT36UHB3lGgaQ62q7iFycGIQVvdi4IESx0z6 O8RF2OWMXIRUojI9IYR3vpOZrdEiawTw6S/gqRkUjvyTJ0tgZW0YF0SAk+wozaFEFiRi OZGRFQRGQsCu+emqUFee0gNjFAs470tItxzL0YtDAPsLCiw26hsn5Xgth6KWcGkyv3hF MpsT4cEl0li6zJUlLkWbnSYOTc3uZIN3jmuLZuYhEUiMY+KTcBmy1y07CMvJ/aQ2ol1O ng== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp414-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:32 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMph8017017; Wed, 21 Aug 2019 14:23:31 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2uh2q4jwvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:31 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEN2RQ031530; Wed, 21 Aug 2019 14:23:02 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:02 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 14/24] IB/uverbs: Add PD import verb Date: Wed, 21 Aug 2019 17:21:15 +0300 Message-Id: <20190821142125.5706-15-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Implementation of new verb which enable to import ib_pd object. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs_cmd.c | 95 ++++++++++++++++++++++++++++ include/uapi/rdma/ib_user_verbs.h | 14 ++++ 2 files changed, 109 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 5800d7e0992a..08f39adb3a9d 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -3867,6 +3867,96 @@ static void ib_uverbs_import_unlock(struct ib_uobject *uobj, fput(filep); } +static void ib_uverbs_clone_ib_pd(union ib_uverbs_import_fr_fd_resp *resp, + struct ib_pd *pd, + __u32 handle) +{ + resp->alloc_pd.pd_handle = handle; +} + +static int ib_uverbs_import_ib_pd(struct uverbs_attr_bundle *attrs) +{ + union ib_uverbs_import_fr_fd_resp resp = {0}; + struct ib_uobject *src_uobj = NULL; + struct ib_uobject *dst_uobj = NULL; + struct ib_uverbs_import_fr_fd cmd; + struct ib_uverbs_file *src_file; + struct ib_device *ibdev; + struct ib_pd *pd; + struct file *filep; + int ret; + + ret = uverbs_request(attrs, &cmd, sizeof(cmd)); + if (ret) + return ret; + + ret = ib_uverbs_import_lock(attrs, cmd.fd, UVERBS_OBJECT_PD, + cmd.handle, &src_uobj, &filep, + &src_file); + if (ret) + return ret; + + pd = src_uobj->object; + + dst_uobj = uobj_alloc(UVERBS_OBJECT_PD, attrs, &ibdev); + if (IS_ERR(dst_uobj)) { + ret = -ENOMEM; + goto uobj; + } + + if (!ibdev->ops.clone_ib_pd) { + ret = -EINVAL; + goto uobj; + } + + dst_uobj->object = src_uobj->object; + dst_uobj->refcnt = src_uobj->refcnt; + + if (WARN_ON(!atomic_inc_not_zero(src_uobj->refcnt))) { + ret = -EINVAL; + goto uobj; + } + + ret = ibdev->ops.clone_ib_pd(&attrs->driver_udata, pd); + if (ret) + goto uobj; + + ib_uverbs_clone_ib_pd(&resp, dst_uobj->object, dst_uobj->id); + + ret = uverbs_response(attrs, &resp, sizeof(resp)); + if (ret) + goto uobj; + + ret = uobj_alloc_commit(dst_uobj, attrs); + + ib_uverbs_import_unlock(src_uobj, filep); + + return ret; + +uobj: + if (!IS_ERR_OR_NULL(dst_uobj)) + uobj_alloc_abort(dst_uobj, attrs); + + return ret; +} + +static int ib_uverbs_import_fr_fd(struct uverbs_attr_bundle *attrs) +{ + struct ib_uverbs_import_fr_fd cmd; + int ret; + + ret = uverbs_request(attrs, &cmd, sizeof(cmd)); + if (ret) + return ret; + + switch (cmd.type) { + case UVERBS_OBJECT_PD: + return ib_uverbs_import_ib_pd(attrs); + } + + return -EINVAL; +} + /* * Describe the input structs for write(). Some write methods have an input * only struct, most have an input and output. If the struct has an output then @@ -3999,6 +4089,11 @@ const struct uapi_definition uverbs_def_write_intf[] = { UAPI_DEF_WRITE_IO(struct ib_uverbs_query_port, struct ib_uverbs_query_port_resp), UAPI_DEF_METHOD_NEEDS_FN(query_port)), + DECLARE_UVERBS_WRITE( + IB_USER_VERBS_CMD_IMPORT_FR_FD, + ib_uverbs_import_fr_fd, + UAPI_DEF_WRITE_IO(struct ib_uverbs_import_fr_fd, + union ib_uverbs_import_fr_fd_resp)), DECLARE_UVERBS_WRITE_EX( IB_USER_VERBS_EX_CMD_QUERY_DEVICE, ib_uverbs_ex_query_device, diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 0474c7400268..4274c40bcff8 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -88,6 +88,7 @@ enum ib_uverbs_write_cmds { IB_USER_VERBS_CMD_CLOSE_XRCD, IB_USER_VERBS_CMD_CREATE_XSRQ, IB_USER_VERBS_CMD_OPEN_QP, + IB_USER_VERBS_CMD_IMPORT_FR_FD, }; enum { @@ -1299,6 +1300,19 @@ struct ib_uverbs_ex_modify_cq { __u32 reserved; }; +/* object sharing support */ +struct ib_uverbs_import_fr_fd { + __u64 response; + __u32 fd; + __u32 handle; + __u16 type; + __u8 reserved[6]; +}; + +union ib_uverbs_import_fr_fd_resp { + struct ib_uverbs_alloc_pd_resp alloc_pd; +}; + #define IB_DEVICE_NAME_MAX 64 #endif /* IB_USER_VERBS_H */ From patchwork Wed Aug 21 14:21:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D835413A4 for ; Wed, 21 Aug 2019 14:23:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B62D72339F for ; Wed, 21 Aug 2019 14:23:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BVBXzECh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728608AbfHUOXh (ORCPT ); Wed, 21 Aug 2019 10:23:37 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33308 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbfHUOXg (ORCPT ); Wed, 21 Aug 2019 10:23:36 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEFsI062991; Wed, 21 Aug 2019 14:23:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=R2KKciNByZNFZithYv0UD7UBCH/zBmalgOIGM4aVm3s=; b=BVBXzEChr8GwHqAGfms/wMaFY+W1CNHH9rdLmECGDoxyR7x8ZXcVVBQRigdi4FwEKe9q XYzq3q26TC3aWlCkNWy4A4+J2ezozkGpOlArp7H52M3n15mPfmaaSofXRj0gxAh+ud5t KWzzqEe273sAKQNPtzLiAN90nZFMbuKkV6W0Mkl088uHHXy3AWhzIvJzsNuvpiWD2eaN dM9TWwcMwQrZthGGJj/iYGNNdvV+qvIo2P1aFoCBXt6CHob+0+Q0whUgJW8D698ORnkU pJpYeQG1lvA8+QWywLoLrUvOSomR9H+afIyJj4l6+nG/rN0zZzzIAbVAr+w2vueN9OrC AA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp3xd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:10 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMqC8017043; Wed, 21 Aug 2019 14:23:10 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2uh2q4jwf2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:09 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LEN8jl011205; Wed, 21 Aug 2019 14:23:08 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:08 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 15/24] IB/mlx4: Enable import from FD verb Date: Wed, 21 Aug 2019 17:21:16 +0300 Message-Id: <20190821142125.5706-16-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Turn on import_fr_fd bit in uverbs command mask. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/hw/mlx4/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 6baf52d988ed..d0eef7e2d5a3 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -2693,7 +2693,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) | (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | (1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) | - (1ull << IB_USER_VERBS_CMD_OPEN_QP); + (1ull << IB_USER_VERBS_CMD_OPEN_QP) | + (1ull << IB_USER_VERBS_CMD_IMPORT_FR_FD); ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_ops); ibdev->ib_dev.uverbs_ex_cmd_mask |= From patchwork Wed Aug 21 14:21:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106985 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73CC614DE for ; Wed, 21 Aug 2019 14:23:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51632233A1 for ; Wed, 21 Aug 2019 14:23:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JG1d7i3i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729079AbfHUOXq (ORCPT ); Wed, 21 Aug 2019 10:23:46 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33618 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbfHUOXq (ORCPT ); Wed, 21 Aug 2019 10:23:46 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEFN3062989; Wed, 21 Aug 2019 14:23:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=FL5SoY8IrY+A+BFwky31ndEsxAJS7eJCT/KR5/jwLIU=; b=JG1d7i3ifENWs9y/ssf+CayVULi2V/rqfkVQtroxs/sgLxqNB9XTZhU81hcrBIoDRMa+ xcNLwrwzO5YgNbFXwepo75zypjjdly+IQIUDXnRfQxlr6f40B0uv6HdJM9pjYzhvP6I7 YdXOLIKjM4jQLSJln9atTAwwi0F+Wst5kQv60YqCLw79Rs4BK6JoLqCQPozXewGyChJP C+3FwYLNphvRjH2urEyp6vm9bRSuYwHdKZclRSf8QSOiHZfVU0v5cMVTRlt7AYFDehny FLlC3SAilTVQMLZyZ/Qr8lmuIcdZSHjIsNVyQpTe2RiY84nv5MnF9oG/ndw9YCpFAm1u Pg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ue90tp3xy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:17 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMZ7I115247; Wed, 21 Aug 2019 14:23:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2ug26a3at5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:17 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LENElI031578; Wed, 21 Aug 2019 14:23:14 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:13 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 16/24] IB/mlx5: Enable import from FD verb Date: Wed, 21 Aug 2019 17:21:17 +0300 Message-Id: <20190821142125.5706-17-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Turn on import_fr_fd bit in uverbs command mask. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/hw/mlx5/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 63beee644b46..89ba3330d2ef 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -6423,7 +6423,8 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev) (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) | (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | (1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) | - (1ull << IB_USER_VERBS_CMD_OPEN_QP); + (1ull << IB_USER_VERBS_CMD_OPEN_QP) | + (1ull << IB_USER_VERBS_CMD_IMPORT_FR_FD); dev->ib_dev.uverbs_ex_cmd_mask = (1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE) | (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ) | From patchwork Wed Aug 21 14:21:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106987 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2B9F13A4 for ; Wed, 21 Aug 2019 14:23:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DD00233A1 for ; Wed, 21 Aug 2019 14:23:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="AY5Ngd0w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729073AbfHUOXq (ORCPT ); Wed, 21 Aug 2019 10:23:46 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33614 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728822AbfHUOXq (ORCPT ); Wed, 21 Aug 2019 10:23:46 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEEITh063038; Wed, 21 Aug 2019 14:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=Xfh2xlkLWZctFbBIkER8ysw+kCloyDg4XzdZTy2DdhQ=; b=AY5Ngd0wNYbyrChPmcyFjsmI2ou1kmTTK+se6jg+ml5v2KaYdXjo5rAjBnfz0FpTHIne lZvMdy49uKGljH+Cf3j40/P7qeo2SGK9AyyInGEctNuIR8PZYKuP8j1TyaT801fTpbb4 /wJVTFlO/x4rLVAI7quYo61HIauvwRQy5LSqdaS/tXB6/NMysuQCKHaQJDEPfNFnyas5 aDa2SQG0tDZcklwPRXPaoez/MbkefS8S2mupKlbLG8uiuclZDvDwP5quCcqXy/0RsJap aPjtXs42ReKAqERYEDxC8zRKrhYbiDAYSGyHvrB11vX5V3m03iP2W79O3pqs7qfIcOiI aw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp3y8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:22 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMpkS017031; Wed, 21 Aug 2019 14:23:22 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2uh2q4jwm3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:22 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LENK5P015515; Wed, 21 Aug 2019 14:23:20 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:19 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Shamir Rabinovitch Subject: [PATCH v1 17/24] RDMA/rxe: Enable import from FD verb Date: Wed, 21 Aug 2019 17:21:18 +0300 Message-Id: <20190821142125.5706-18-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210157 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shamir Rabinovitch Turn on import_fr_fd bit in uverbs command mask. Signed-off-by: Shamir Rabinovitch Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/sw/rxe/rxe_verbs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 415ac9d3b504..3c4a0b89f28f 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1208,6 +1208,7 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name) | BIT_ULL(IB_USER_VERBS_CMD_DESTROY_AH) | BIT_ULL(IB_USER_VERBS_CMD_ATTACH_MCAST) | BIT_ULL(IB_USER_VERBS_CMD_DETACH_MCAST) + | BIT_ULL(IB_USER_VERBS_CMD_IMPORT_FR_FD) ; ib_set_device_ops(dev, &rxe_dev_ops); From patchwork Wed Aug 21 14:21:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106995 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BBE514DE for ; Wed, 21 Aug 2019 14:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A4832339F for ; Wed, 21 Aug 2019 14:23:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="p3yziPv2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729114AbfHUOX6 (ORCPT ); Wed, 21 Aug 2019 10:23:58 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40094 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728763AbfHUOX6 (ORCPT ); Wed, 21 Aug 2019 10:23:58 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENW83086763; Wed, 21 Aug 2019 14:23:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=fNlWbrKfg81SqvFGiyhtRRDnDGEnlnD2h+oOjjo45jw=; b=p3yziPv2eKEpAWBdL+IODg1H+iDvOZ0VeFmh9J91UKdrssYSULC2DdCystnFcpG88IRP Ll8GpgidqHI+lygaSdxNfBuL65jwVG3uwFSJ4S8MZ1vMVMIUXb9JwKxvoln91ZwsPrkc jdrqYxRHQOsv12GSfWBeuhxUZTOTJTRgp2bLS8+kr98+4MBkdS05XchQabw8KqLuCofx 5CaKsIOBsdR8t04hrQqOowHqCKutqtoJQi2yLz0dALaREAi/roQQfOoWiAaVOiIgJzCr 6xXAPM0L5oSU0RXHD7Z4zKEF1eUqVTJk/rVAvQ6fLnTA3IVI6hVqmzILnzM7eRSOisL6 tQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2uea7qwxrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:33 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMq9e017101; Wed, 21 Aug 2019 14:23:32 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2uh2q4jwvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:32 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LENPKJ011373; Wed, 21 Aug 2019 14:23:25 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:25 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 18/24] IB/core: ib_mr should not have ib_uobject pointer Date: Wed, 21 Aug 2019 17:21:19 +0300 Message-Id: <20190821142125.5706-19-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org As a preparation step to shared MR, where ib_mr object will be pointed by one or more ib_uobjects, remove ib_uobject pointer from ib_mr struct. Signed-off-by: Yuval Shaia --- drivers/infiniband/core/uverbs_cmd.c | 1 - drivers/infiniband/core/uverbs_std_types_mr.c | 1 - drivers/infiniband/core/verbs.c | 3 --- include/rdma/ib_verbs.h | 3 ++- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 08f39adb3a9d..25eab9dc9cad 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -765,7 +765,6 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) mr->type = IB_MR_TYPE_USER; mr->dm = NULL; mr->sig_attrs = NULL; - mr->uobject = uobj; atomic_inc(&pd->usecnt); mr->res.type = RDMA_RESTRACK_MR; rdma_restrack_uadd(&mr->res); diff --git a/drivers/infiniband/core/uverbs_std_types_mr.c b/drivers/infiniband/core/uverbs_std_types_mr.c index c1286a52dc84..5219af8960a3 100644 --- a/drivers/infiniband/core/uverbs_std_types_mr.c +++ b/drivers/infiniband/core/uverbs_std_types_mr.c @@ -130,7 +130,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)( mr->pd = pd; mr->type = IB_MR_TYPE_DM; mr->dm = dm; - mr->uobject = uobj; atomic_inc(&pd->usecnt); atomic_inc(&dm->usecnt); diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 1d0215c1a504..a7722d54869e 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -299,7 +299,6 @@ struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags, mr->device = pd->device; mr->pd = pd; mr->type = IB_MR_TYPE_DMA; - mr->uobject = NULL; mr->need_inval = false; pd->__internal_mr = mr; @@ -2035,7 +2034,6 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type, mr->device = pd->device; mr->pd = pd; mr->dm = NULL; - mr->uobject = NULL; atomic_inc(&pd->usecnt); mr->need_inval = false; mr->res.type = RDMA_RESTRACK_MR; @@ -2088,7 +2086,6 @@ struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd, mr->device = pd->device; mr->pd = pd; mr->dm = NULL; - mr->uobject = NULL; atomic_inc(&pd->usecnt); mr->need_inval = false; mr->res.type = RDMA_RESTRACK_MR; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index e3ce38aa89b6..877932305ea7 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1785,7 +1785,6 @@ struct ib_mr { enum ib_mr_type type; bool need_inval; union { - struct ib_uobject *uobject; /* user */ struct list_head qp_entry; /* FR */ }; @@ -2592,6 +2591,7 @@ struct ib_device_ops { /* Object sharing callbacks */ clone_callback(ib_pd); + clone_callback(ib_mr); DECLARE_RDMA_OBJ_SIZE(ib_ah); DECLARE_RDMA_OBJ_SIZE(ib_cq); @@ -2610,6 +2610,7 @@ static inline int trivial_clone_##ib_type(struct ib_udata *udata, \ /* Shared IB HW object support */ trivial_clone_callback(ib_pd); +trivial_clone_callback(ib_mr); struct ib_core_device { /* device must be the first element in structure until, From patchwork Wed Aug 21 14:21:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11106997 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77AA91813 for ; Wed, 21 Aug 2019 14:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55CE6233A1 for ; Wed, 21 Aug 2019 14:23:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GcK0wE1A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728763AbfHUOX6 (ORCPT ); Wed, 21 Aug 2019 10:23:58 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33952 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbfHUOX6 (ORCPT ); Wed, 21 Aug 2019 10:23:58 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENXta071769; Wed, 21 Aug 2019 14:23:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=3GD1IWHpw3E16VbeOgFWA8/q5iZirKAQ2PQieBcHWu0=; b=GcK0wE1AXsylrE14SRYChQ4y20nlzO0RjWjkyMiybznpD/NVIbfusrG5FnSklqofyQTw ct95uNspF1ynLij8Hyj1uASvuTwIwNkeX7Lj73bbSfP4jBuBcCiin7kBCpO2+7UZt4u4 Now2hVv9ZT1fat5Fp4WR4NkNjIzh9HrvThKEzR5nB4TRPxj2hy+iSS8r+RSTXHwrT43m qLcwP5Q2/A66wK1n/Ug0L5zkHUDcUvnBQDfoK9enMaWvNS9EQhLg6gaWzfZ2QDsyFQ4R koMw5AAyuKQJPiMxorMi2xaRYMw58Qu0ACKO9W24UZIxSr5NBmGBW5BUPX6fNRrfPqHl iA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2ue90tp434-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:38 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENUOR106795; Wed, 21 Aug 2019 14:23:37 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2ugj7py95q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:37 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LENVgU011411; Wed, 21 Aug 2019 14:23:31 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:30 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 19/24] IB/core: Install clone ib_mr in device ops Date: Wed, 21 Aug 2019 17:21:20 +0300 Message-Id: <20190821142125.5706-20-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Install clone_ib_mr in the device ops. Signed-off-by: Yuval Shaia --- drivers/infiniband/core/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 8d90e429441f..e2e3ed4a3d0a 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2627,6 +2627,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) SET_DEVICE_OP(dev_ops, set_vf_link_state); SET_DEVICE_OP(dev_ops, unmap_fmr); SET_DEVICE_OP(dev_ops, clone_ib_pd); + SET_DEVICE_OP(dev_ops, clone_ib_mr); SET_OBJ_SIZE(dev_ops, ib_ah); SET_OBJ_SIZE(dev_ops, ib_cq); From patchwork Wed Aug 21 14:21:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEB3114DE for ; Wed, 21 Aug 2019 14:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD24A233A1 for ; Wed, 21 Aug 2019 14:24:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pOrf5WOy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729184AbfHUOYE (ORCPT ); Wed, 21 Aug 2019 10:24:04 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34084 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbfHUOYD (ORCPT ); Wed, 21 Aug 2019 10:24:03 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENWvq071722; Wed, 21 Aug 2019 14:23:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=MvNPO4dpKeDdmtzLKonZjiC3Ub3LV1ByRCK+eujaa08=; b=pOrf5WOyPxQrat1953XiRDNFPVrZIfS5sy2lFs0htQ9nqGvVDlwKRkfGJnTrpcAyq3eo lZ2DXkpoAwvyN4DEWSkIZrqgFtE5EOFACI415fHoP0qnmusak5DegqjMlwkrUGFj5XcR +/V9e7H0PCXPqs3zYdcufMAQkPVK3KBQBHhqNYL+wHc1HIXHZgt0n5hgDSIE4f1PzVjl ScgfE67fsTqH1bMe0gdQ4sxAXU8gNUMvotZBU9d7F839PtHXjTHbR3/jlDfHYSHnNiAu RaM95OLw5yij1DJy23t74GW1odjgH8yWL58T4atqP7mWZvTAVuhsy/sFrBISWkERcw/A 5A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ue90tp43g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMq50017078; Wed, 21 Aug 2019 14:23:40 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2uh2q4jx5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:40 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LENc1A015788; Wed, 21 Aug 2019 14:23:38 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:37 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 20/24] IB/mlx4: Add implementation of clone_pd callback Date: Wed, 21 Aug 2019 17:21:21 +0300 Message-Id: <20190821142125.5706-21-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org No special handling in for object cloning, utilize the trivial implementation. Signed-off-by: Yuval Shaia --- drivers/infiniband/hw/mlx4/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index d0eef7e2d5a3..3192284a85ca 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -2576,6 +2576,7 @@ static const struct ib_device_ops mlx4_ib_dev_ops = { /* Object sharing callbacks */ .clone_ib_pd = mlx4_ib_clone_pd, + .clone_ib_mr = trivial_clone_ib_mr, INIT_RDMA_OBJ_SIZE(ib_ah, mlx4_ib_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, mlx4_ib_cq, ibcq), From patchwork Wed Aug 21 14:21:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107015 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E13D814DE for ; Wed, 21 Aug 2019 14:24:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEBED233FC for ; Wed, 21 Aug 2019 14:24:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="e9fJ1yqE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729204AbfHUOYM (ORCPT ); Wed, 21 Aug 2019 10:24:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40478 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728964AbfHUOYM (ORCPT ); Wed, 21 Aug 2019 10:24:12 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENU1Q086653; Wed, 21 Aug 2019 14:23:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=eBT243lfDQ3yxgXSEgGiXjsS3ep2rvLt4aWX7krSYkc=; b=e9fJ1yqE0DAs++cUFWEMM0nkzNXd5aggl5iAxzBEggtcDdcuWfvZtWSjUXTAOj0qpmtr SVDCswpV9W9/BZTC5cX0cEHyZas1GauzcX/CkdfcR33acXLDeVlBJr6b6x+OISV/grPb hy60ytN58g4yRcoNzm/2PVPyQ01NZ7eK5iToTkVrBrH6FxuY5sKtFdIalozQksK1Sje5 UIbxHbj2+J+EohHkIaLKR9zdC4wdl4tJJm9h48+ZkkOLNQ9i7zM8MldJrra2V2x+zzHh mma1PXrk9/T30oizA+dwJ3QLcPPTwyyTu6K+Fpivz5Nruc32d+KWQg9y6OEUIRnk3Iuv Ug== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2uea7qwxu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:45 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMYOs115054; Wed, 21 Aug 2019 14:23:44 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2ug26a3bh6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:44 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LENh9q031870; Wed, 21 Aug 2019 14:23:43 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:43 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 21/24] IB/mlx5: Add implementation of clone_pd callback Date: Wed, 21 Aug 2019 17:21:22 +0300 Message-Id: <20190821142125.5706-22-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org No special handling in for object cloning, utilize the trivial implementation. Signed-off-by: Yuval Shaia --- drivers/infiniband/hw/mlx5/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 89ba3330d2ef..79eef45167bd 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -6352,6 +6352,7 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { /* Object sharing callbacks */ .clone_ib_pd = mlx5_ib_clone_pd, + .clone_ib_mr = trivial_clone_ib_mr, INIT_RDMA_OBJ_SIZE(ib_ah, mlx5_ib_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, mlx5_ib_cq, ibcq), From patchwork Wed Aug 21 14:21:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107013 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE0C413A4 for ; Wed, 21 Aug 2019 14:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC1CD22D6D for ; Wed, 21 Aug 2019 14:24:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mcmh4fw2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729086AbfHUOYH (ORCPT ); Wed, 21 Aug 2019 10:24:07 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47150 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbfHUOYH (ORCPT ); Wed, 21 Aug 2019 10:24:07 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENU9a096318; Wed, 21 Aug 2019 14:23:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=K7BgwGf7KnKFTXUzsrmZWFfIHOf64JCc3F7iGU883Rs=; b=mcmh4fw2Rh/ziunipYKiEZbJBDLc3yfXNIWTqyoAf9TpkNnKCs4zp5lxyzcBMUZmpU4T c8KzxIAmBbtuYnuFnOnCnHYZhpNjwziouUizelVLqpIkM8sBJ4jBE7/UWpDsDp1iZTox LhFI1w8/+vavHnBdiE1mJoO7SU5o3NhFJzGiFnm4tx+kgoutFytfFky1DmSsk+yO/MWc dn32jYJ4yIBJDrGQ45gcFAV6VL/bpkZaDTJZ+QaHl6tZSeVKquRJ9wS0rJgP2SaS1xGV hlBLCVxsU6iOXGZKy9WN0XSFAemTkedh3drG/A+Egcc/RrMYcKSG6uKLkfB8os2IMcBc 6A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2ue9hpnvb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:51 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMZCK115188; Wed, 21 Aug 2019 14:23:50 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2ug26a3bkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:50 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LENndV031946; Wed, 21 Aug 2019 14:23:49 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:48 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 22/24] RDMA/rxe: Add implementation of clone_pd callback Date: Wed, 21 Aug 2019 17:21:23 +0300 Message-Id: <20190821142125.5706-23-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org No special handling in for object cloning, utilize the trivial implementation. Signed-off-by: Yuval Shaia --- drivers/infiniband/sw/rxe/rxe_verbs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 3c4a0b89f28f..ec2cade76372 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1150,6 +1150,7 @@ static const struct ib_device_ops rxe_dev_ops = { /* Object sharing callbacks */ .clone_ib_pd = trivial_clone_ib_pd, + .clone_ib_mr = trivial_clone_ib_mr, INIT_RDMA_OBJ_SIZE(ib_ah, rxe_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, rxe_cq, ibcq), From patchwork Wed Aug 21 14:21:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 072A21813 for ; Wed, 21 Aug 2019 14:24:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D70E82339F for ; Wed, 21 Aug 2019 14:24:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IRARvdbT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728964AbfHUOYS (ORCPT ); Wed, 21 Aug 2019 10:24:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40654 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729221AbfHUOYR (ORCPT ); Wed, 21 Aug 2019 10:24:17 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENUB7086634; Wed, 21 Aug 2019 14:23:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=OSdMwoQnxUe3oXlreY1YQcGPEPndBKsBlIiB7WW83SM=; b=IRARvdbT5zMq8R/rp0nCAJ+94UGdpjN9UGqvkqgwUsYzQZTqStRw1Ao9ImX/lmyLM1lm Cz04M7xtCA8mmChzlOcxkKZ6cwZ16Boo9GYyQeegFUsGpKXvPvovp9QGQlGl9QwQiTZN s8p9GERmKpdIK3zhHyoy371bFOe1NMSK3Cm9CFGYQ/nfdEup8pViRIqhvhUE95c43ljM qe68lUwwtuOoyN5FO9QqfnbkU4ZWj+zKmZyZNgCRkssYxbtd9UYjIG66yWzZQWYtk/Nc isHre+o7iiqZiKGHieHkX7oYbtTx2N5DsHt136IA7nAYT2khB8e4D+Zuzm1og9ieH/p9 HA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2uea7qwxvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:56 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LEMqXN017152; Wed, 21 Aug 2019 14:23:56 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2uh2q4jxcg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:23:55 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7LENsqQ031990; Wed, 21 Aug 2019 14:23:54 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:23:54 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 23/24] IB/uverbs: Add clone reference counting to ib_mr Date: Wed, 21 Aug 2019 17:21:24 +0300 Message-Id: <20190821142125.5706-24-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org To keep track of shared object life time add ref count to ib_mr Signed-off-by: Yuval Shaia --- drivers/infiniband/core/uverbs_cmd.c | 2 ++ include/rdma/ib_verbs.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 25eab9dc9cad..92f04e7360b6 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -768,8 +768,10 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) atomic_inc(&pd->usecnt); mr->res.type = RDMA_RESTRACK_MR; rdma_restrack_uadd(&mr->res); + atomic_set(&mr->refcnt, 1); uobj->object = mr; + uobj->refcnt = &mr->refcnt; memset(&resp, 0, sizeof resp); resp.lkey = mr->lkey; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 877932305ea7..80fd78b3b654 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1794,6 +1794,9 @@ struct ib_mr { * Implementation details of the RDMA core, don't use in drivers: */ struct rdma_restrack_entry res; + + /* number of uobj using this ib_pd */ + atomic_t refcnt; }; struct ib_mw { From patchwork Wed Aug 21 14:21:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 11107029 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B793E14DE for ; Wed, 21 Aug 2019 14:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A34A2339F for ; Wed, 21 Aug 2019 14:24:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ERps7v3Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729352AbfHUOYd (ORCPT ); Wed, 21 Aug 2019 10:24:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40946 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728724AbfHUOYb (ORCPT ); Wed, 21 Aug 2019 10:24:31 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENVYu086699; Wed, 21 Aug 2019 14:24:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=RfAdhnost4bMej9JuUi7DlfUHMtpa23/Q9xe2PERx28=; b=ERps7v3Qre3rQaAM2A7q9qeNYF0rJlijSFucP/Gt3QL92joaGb0C+e78BJBUJEqfYT5M njiwT1hNehozJmWpEoI+gfHsSWyLJtXj5SZCDDFwpPzk7b000+ty4x4BhXF464KPY6sY Sm2pMr5NT63UkePNDd8BlUqabKUZ3nt5OwUeM04WnsMYOQoW1d0Y7UE6OrZP653bHRh7 9bap4c4HnVWT1ZgsDsdJCO9Lu7+Dq68zXDwXLFPqWLhKT/aqgZZK5Zse6bv2YDxOJkE0 cdLJyaER2LywPyfZTy8GzH1rXB6mr4jP3wEu+KMAPoGbFQx8GYgH68WXHBfZqcKLz7sG 8g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2uea7qwxwm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:24:03 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7LENRIc194596; Wed, 21 Aug 2019 14:24:03 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2ugj7qgfbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2019 14:24:02 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7LEO0kS015958; Wed, 21 Aug 2019 14:24:00 GMT Received: from host5.lan (/77.138.183.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2019 07:24:00 -0700 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, monis@mellanox.com, parav@mellanox.com, danielj@mellanox.com, kamalheib1@gmail.com, markz@mellanox.com, swise@opengridcomputing.com, shamir.rabinovitch@oracle.com, johannes.berg@intel.com, willy@infradead.org, michaelgur@mellanox.com, markb@mellanox.com, yuval.shaia@oracle.com, dan.carpenter@oracle.com, bvanassche@acm.org, maxg@mellanox.com, israelr@mellanox.com, galpress@amazon.com, denisd@mellanox.com, yuvalav@mellanox.com, dennis.dalessandro@intel.com, will@kernel.org, ereza@mellanox.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Subject: [PATCH v1 24/24] IB/uverbs: Add MR import verb Date: Wed, 21 Aug 2019 17:21:25 +0300 Message-Id: <20190821142125.5706-25-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821142125.5706-1-yuval.shaia@oracle.com> References: <20190821142125.5706-1-yuval.shaia@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9355 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908210158 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Implementation of new verb which enable to import ib_mr object. Signed-off-by: Yuval Shaia --- drivers/infiniband/core/uverbs_cmd.c | 79 ++++++++++++++++++++++++++++ include/uapi/rdma/ib_user_verbs.h | 1 + 2 files changed, 80 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 92f04e7360b6..5aaa6a7e129f 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -3875,6 +3875,15 @@ static void ib_uverbs_clone_ib_pd(union ib_uverbs_import_fr_fd_resp *resp, resp->alloc_pd.pd_handle = handle; } +static void ib_uverbs_clone_ib_mr(union ib_uverbs_import_fr_fd_resp *resp, + struct ib_mr *mr, + __u32 handle) +{ + resp->reg_mr.lkey = mr->lkey; + resp->reg_mr.rkey = mr->rkey; + resp->reg_mr.mr_handle = handle; +} + static int ib_uverbs_import_ib_pd(struct uverbs_attr_bundle *attrs) { union ib_uverbs_import_fr_fd_resp resp = {0}; @@ -3941,6 +3950,74 @@ static int ib_uverbs_import_ib_pd(struct uverbs_attr_bundle *attrs) return ret; } +static int ib_uverbs_import_ib_mr(struct uverbs_attr_bundle *attrs) +{ + union ib_uverbs_import_fr_fd_resp resp = {0}; + struct ib_uobject *src_uobj = NULL; + struct ib_uobject *dst_uobj = NULL; + struct ib_uverbs_import_fr_fd cmd; + struct ib_uverbs_file *src_file; + struct ib_device *ibdev; + struct ib_mr *mr; + struct file *filep; + int ret; + + ret = uverbs_request(attrs, &cmd, sizeof(cmd)); + if (ret) + return ret; + + ret = ib_uverbs_import_lock(attrs, cmd.fd, UVERBS_OBJECT_MR, + cmd.handle, &src_uobj, &filep, + &src_file); + if (ret) + return ret; + + mr = src_uobj->object; + + dst_uobj = uobj_alloc(UVERBS_OBJECT_MR, attrs, &ibdev); + if (IS_ERR(dst_uobj)) { + ret = -ENOMEM; + goto uobj; + } + + if (!ibdev->ops.clone_ib_mr) { + ret = -EINVAL; + goto uobj; + } + + dst_uobj->object = src_uobj->object; + dst_uobj->refcnt = src_uobj->refcnt; + + if (WARN_ON(!atomic_inc_not_zero(src_uobj->refcnt))) { + ret = -EINVAL; + goto uobj; + } + + ret = ibdev->ops.clone_ib_mr(&attrs->driver_udata, mr); + if (ret) + goto uobj; + + ib_uverbs_clone_ib_mr(&resp, dst_uobj->object, dst_uobj->id); + + ret = uverbs_response(attrs, &resp, sizeof(resp)); + if (ret) + goto uobj; + + ret = uobj_alloc_commit(dst_uobj, attrs); + + ib_uverbs_import_unlock(src_uobj, filep); + + return ret; + +uobj: + ib_uverbs_import_unlock(src_uobj, filep); + + if (!IS_ERR_OR_NULL(dst_uobj)) + uobj_alloc_abort(dst_uobj, attrs); + + return ret; +} + static int ib_uverbs_import_fr_fd(struct uverbs_attr_bundle *attrs) { struct ib_uverbs_import_fr_fd cmd; @@ -3953,6 +4030,8 @@ static int ib_uverbs_import_fr_fd(struct uverbs_attr_bundle *attrs) switch (cmd.type) { case UVERBS_OBJECT_PD: return ib_uverbs_import_ib_pd(attrs); + case UVERBS_OBJECT_MR: + return ib_uverbs_import_ib_mr(attrs); } return -EINVAL; diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 4274c40bcff8..cfd1a734d5f3 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -1311,6 +1311,7 @@ struct ib_uverbs_import_fr_fd { union ib_uverbs_import_fr_fd_resp { struct ib_uverbs_alloc_pd_resp alloc_pd; + struct ib_uverbs_reg_mr_resp reg_mr; }; #define IB_DEVICE_NAME_MAX 64