Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp296544pxb; Wed, 18 Aug 2021 02:37:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTJX0jgERFM4v38fOW3XpWI4VXkiBBwWONmUjqSQm+u1p8uoOM7fE+pGukCBkf8YvhDm8g X-Received: by 2002:a92:d24b:: with SMTP id v11mr5530984ilg.218.1629279431600; Wed, 18 Aug 2021 02:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629279431; cv=none; d=google.com; s=arc-20160816; b=eSxK8t2T4NdiB5HhXm9fPHqZyCmDgwbvX2K+fGbrwaUrXhrC/HYonZ2DEvoZkx0CNZ XVabrDvFY1mRwFZy5/FsINGvCl4h3IEwiKGGuRoAwAzXDosuQNXSiqtH46qULbu5nkAc AaYku76OFQolbC5+3PuQBVnh4B7AY9nd98a929k2ZXhnmrIGqKP4Lbt9q6UHZVDc98qF JoIcZtSyQbNprUS2APYDUxPxkSKEEByFIWOcaOOx3naZF6eH9Lvq+DjyVTBzqTUMdnk+ K6iPNEMtXDW4uUyDq9oTEeAqPuj7NcXYOwkyWmqqPucNorPl+KzTLnRtbdgD/T+rVwtN Ym2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+Xyn/PM5YP2/IFB7tHgsnFcmbLe6blpVJ1aozmlu1ow=; b=qd9aC7QI+jG4em37zc8pTKk50AlDt0qf1c3jTQUu1zHuCMs6/5zHXGj5XW7Bj8SYmp jTLuYjaL3259Tmqoxwwjs2CLMRmw++jO+sCL4n4BcZZD93s/KghGTGezS6ANjPH81ocD uXB8M0WOTrlR8HYgMWlRDe7XPLdKwEqNVYzF9arM3iFTTal2B4v/DVJwOoTRx5+SaXef DI7gaK/eyJZGPy4ghTYc+ncygaliKWt65615Jb7+E1/JTaTF9bXty6ANT5tSO7zzeqZ2 5uqjzyEn1OforUbNIi0VrWnp58tldU0bztrmFWnXYgssHPeEwGV0Aas4DjjAXQl+5rXt c03Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=gykCm02M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si4757694ilt.132.2021.08.18.02.37.00; Wed, 18 Aug 2021 02:37:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=gykCm02M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233784AbhHRJgh (ORCPT + 99 others); Wed, 18 Aug 2021 05:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233271AbhHRJfo (ORCPT ); Wed, 18 Aug 2021 05:35:44 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B52C0617AD for ; Wed, 18 Aug 2021 02:35:03 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 108-20020a9d01750000b029050e5cc11ae3so2443045otu.5 for ; Wed, 18 Aug 2021 02:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+Xyn/PM5YP2/IFB7tHgsnFcmbLe6blpVJ1aozmlu1ow=; b=gykCm02M32GyZzKN1jfPZSs6ksGKG8l2HXfkmk5eKcJSlW5ZG7T0cBaM6blIbOzxSm mE6oC/HNp/hdxXahUd3yM8+s//fCqPmr2cM/b4lDVrkeFWGFD5OhwWzexvIvVZrYSA/o 5RvVMnMJ/nxikIQRWfFHgxPgKIrsz/pQyKHKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+Xyn/PM5YP2/IFB7tHgsnFcmbLe6blpVJ1aozmlu1ow=; b=Kt2fc4AlZkkb3E7YzrHn8BN0Q/t58LQnfGpDBYaTzPot6CVvlm2BWIP1FwSKsLippm bu6gsLzFtZhPZ+39JIL3HjyKsBavnSo6liWC+cX6i08Ez5UWAyw24O1zS+8LvdnKYv6z u+6/uX3B0Ng0i37PzNxEMm4IUTVUy1L+zKmbgOeBCnPLw2ktCSfInVQ52IG4lM8lJdzA gpd3+qlj7emSL7eThjGlJGwCzCFHyVyHoHV89V4C+aJIHVJYH3bi5nFGEp9FV0Px89PF JoTjZ4ytBoeKZh3Omey9RJVTrG+rHGyJofmgkGRLAp/pV43VBBAPQMeHV7fduo5TIG9x LMLg== X-Gm-Message-State: AOAM533OIiYN4fO3h5hyHpySxoC/5gFj6kD+W7NWoeTas7TpyzlAwCSw Jf50/+K1pylVPW+AzcpLCGfr11egOjaLMYRM0e2z4qDZ4dI= X-Received: by 2002:a9d:65da:: with SMTP id z26mr6101976oth.303.1629279302395; Wed, 18 Aug 2021 02:35:02 -0700 (PDT) MIME-Version: 1.0 References: <20210818074352.29950-1-galpress@amazon.com> In-Reply-To: <20210818074352.29950-1-galpress@amazon.com> From: Daniel Vetter Date: Wed, 18 Aug 2021 11:34:51 +0200 Message-ID: Subject: Re: [RFC] Make use of non-dynamic dmabuf in RDMA To: Gal Pressman Cc: Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Doug Ledford , Jason Gunthorpe , "open list:DMA BUFFER SHARING FRAMEWORK" , dri-devel , Linux Kernel Mailing List , linux-rdma , Oded Gabbay , Tomer Tayar , Yossi Leybovich , Alexander Matushevsky , Leon Romanovsky , Jianxin Xiong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 18, 2021 at 9:45 AM Gal Pressman wrote: > > Hey all, > > Currently, the RDMA subsystem can only work with dynamic dmabuf > attachments, which requires the RDMA device to support on-demand-paging > (ODP) which is not common on most devices (only supported by mlx5). > > While the dynamic requirement makes sense for certain GPUs, some devices > (such as habanalabs) have device memory that is always "pinned" and do > not need/use the move_notify operation. > > The motivation of this RFC is to use habanalabs as the dmabuf exporter, > and EFA as the importer to allow for peer2peer access through libibverbs. > > This draft patch changes the dmabuf driver to differentiate between > static/dynamic attachments by looking at the move_notify op instead of > the importer_ops struct, and allowing the peer2peer flag to be enabled > in case of a static exporter. > > Thanks > > Signed-off-by: Gal Pressman Given that habanalabs dma-buf support is very firmly in limbo (at least it's not yet in linux-next or anywhere else) I think you want to solve that problem first before we tackle the additional issue of making p2p work without dynamic dma-buf. Without that it just doesn't make a lot of sense really to talk about solutions here. -Daniel > --- > drivers/dma-buf/dma-buf.c | 5 +++-- > drivers/infiniband/core/umem_dmabuf.c | 2 +- > include/linux/dma-buf.h | 2 +- > 3 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 511fe0d217a0..e3faad8f492c 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -727,7 +727,8 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, > if (WARN_ON(!dmabuf || !dev)) > return ERR_PTR(-EINVAL); > > - if (WARN_ON(importer_ops && !importer_ops->move_notify)) > + if (WARN_ON(importer_ops && !importer_ops->move_notify && > + dma_buf_is_dynamic(attach->dmabuf))) > return ERR_PTR(-EINVAL); > > attach = kzalloc(sizeof(*attach), GFP_KERNEL); > @@ -1048,7 +1049,7 @@ void dma_buf_move_notify(struct dma_buf *dmabuf) > dma_resv_assert_held(dmabuf->resv); > > list_for_each_entry(attach, &dmabuf->attachments, node) > - if (attach->importer_ops) > + if (attach->importer_ops && attach->importer_ops->move_notify) > attach->importer_ops->move_notify(attach); > } > EXPORT_SYMBOL_GPL(dma_buf_move_notify); > diff --git a/drivers/infiniband/core/umem_dmabuf.c b/drivers/infiniband/core/umem_dmabuf.c > index c6e875619fac..c502ae828bd3 100644 > --- a/drivers/infiniband/core/umem_dmabuf.c > +++ b/drivers/infiniband/core/umem_dmabuf.c > @@ -118,7 +118,7 @@ struct ib_umem_dmabuf *ib_umem_dmabuf_get(struct ib_device *device, > if (check_add_overflow(offset, (unsigned long)size, &end)) > return ret; > > - if (unlikely(!ops || !ops->move_notify)) > + if (unlikely(!ops)) > return ret; > > dmabuf = dma_buf_get(fd); > diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h > index efdc56b9d95f..4b2e99012cb1 100644 > --- a/include/linux/dma-buf.h > +++ b/include/linux/dma-buf.h > @@ -473,7 +473,7 @@ static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf) > static inline bool > dma_buf_attachment_is_dynamic(struct dma_buf_attachment *attach) > { > - return !!attach->importer_ops; > + return !!attach->importer_ops->move_notify; > } > > struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, > -- > 2.32.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch