From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C40FBC4361B for ; Wed, 9 Dec 2020 06:45:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B3AA23B7D for ; Wed, 9 Dec 2020 06:45:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728194AbgLIGpO (ORCPT ); Wed, 9 Dec 2020 01:45:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:40126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728176AbgLIGpO (ORCPT ); Wed, 9 Dec 2020 01:45:14 -0500 Date: Wed, 9 Dec 2020 08:44:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607496274; bh=nm1XpRO8wEjXGxSoNUUKePlW/cwmjJV9G1vreS0Qhz8=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=jhkZfbI482puH4s+5IT32A+6rw8/PHQwRZ/pD/pLX7QAKFjPkZrTd8rgOwzxhCB+n +Yxg0N0J7PW1QzqxJhbbiBvj5pkm6/pZZGMlBQzhGuTJuAnYbf12lYMYQ9Sxg/g8as fq+k89Wv27l96EoVjs+6QxD9mN+Dl52Iu783x5Wb+IDQUc9aUOCp7oXsTu2UDk5YOo SDKv5ZijirApwyP3iMpB3kppHGqhi9C9PO45QMhusthXtxkBk5Ek9RYCEgvZ/8pXMc IDZ0ME7t4NwnOVRBtTibulBHCh+BkJZLOfDMjUUjWpuJgT/kQZ6OhWJTBMlfogH6cj 9aLGdDMHd9DWQ== From: Leon Romanovsky To: Jianxin Xiong Cc: linux-rdma@vger.kernel.org, dri-devel@lists.freedesktop.org, Doug Ledford , Jason Gunthorpe , Sumit Semwal , Christian Koenig , Daniel Vetter Subject: Re: [PATCH v14 4/4] RDMA/mlx5: Support dma-buf based userspace memory region Message-ID: <20201209064430.GM4430@unreal> References: <1607467155-92725-1-git-send-email-jianxin.xiong@intel.com> <1607467155-92725-5-git-send-email-jianxin.xiong@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1607467155-92725-5-git-send-email-jianxin.xiong@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Tue, Dec 08, 2020 at 02:39:15PM -0800, Jianxin Xiong wrote: > Implement the new driver method 'reg_user_mr_dmabuf'. Utilize the core > functions to import dma-buf based memory region and update the mappings. > > Add code to handle dma-buf related page fault. > > Signed-off-by: Jianxin Xiong > Reviewed-by: Sean Hefty > Acked-by: Michael J. Ruhl > Acked-by: Christian Koenig > Acked-by: Daniel Vetter > --- > drivers/infiniband/hw/mlx5/main.c | 2 + > drivers/infiniband/hw/mlx5/mlx5_ib.h | 18 +++++ > drivers/infiniband/hw/mlx5/mr.c | 128 +++++++++++++++++++++++++++++++++-- > drivers/infiniband/hw/mlx5/odp.c | 86 +++++++++++++++++++++-- > 4 files changed, 225 insertions(+), 9 deletions(-) <...> > > + > + umem = ib_umem_dmabuf_get(&dev->ib_dev, offset, length, fd, access_flags, > + &mlx5_ib_dmabuf_attach_ops); > + if (IS_ERR(umem)) { > + mlx5_ib_dbg(dev, "umem get failed (%ld)\n", PTR_ERR(umem)); > + return ERR_PTR(PTR_ERR(umem)); return ERR_CAST(umem); > + } <...> > + dma_resv_lock(umem_dmabuf->attach->dmabuf->resv, NULL); > + err = ib_umem_dmabuf_map_pages(umem_dmabuf); > + if (!err) { > + page_size = mlx5_umem_find_best_pgsz(&umem_dmabuf->umem, mkc, > + log_page_size, 0, > + umem_dmabuf->umem.iova); > + if (unlikely(page_size < PAGE_SIZE)) { > + ib_umem_dmabuf_unmap_pages(umem_dmabuf); > + err = -EINVAL; > + } else { > + err = mlx5_ib_update_mr_pas(mr, xlt_flags); > + } > + } > + dma_resv_unlock(umem_dmabuf->attach->dmabuf->resv); Let's write this section in kernel coding style, please dma_resv_lock(umem_dmabuf->attach->dmabuf->resv, NULL); err = ib_umem_dmabuf_map_pages(umem_dmabuf); if (err) { dma_resv_unlock(umem_dmabuf->attach->dmabuf->resv); return err; } ..... Thanks