From: Jianxin Xiong <jianxin.xiong@intel.com>
To: linux-rdma@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: Jianxin Xiong <jianxin.xiong@intel.com>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Christian Koenig <christian.koenig@amd.com>,
Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH v8 5/5] dma-buf: Reject attach request from importers that use dma_virt_ops
Date: Thu, 5 Nov 2020 14:48:09 -0800 [thread overview]
Message-ID: <1604616489-69267-6-git-send-email-jianxin.xiong@intel.com> (raw)
In-Reply-To: <1604616489-69267-1-git-send-email-jianxin.xiong@intel.com>
dma_virt_ops is used by virtual devices that map pages / scatterlists to
virtual addresses for CPU access instead of performing DMA. This is not
the intended use of dma_buf_attach() and dma_buf_map_attachment(). CPU
access of dma-buf should use dma_buf_vmap() and related functions.
Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
---
drivers/dma-buf/dma-buf.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 9a054fb5..ba2b877 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -686,6 +686,11 @@ struct dma_buf_attachment *
if (WARN_ON(importer_ops && !importer_ops->move_notify))
return ERR_PTR(-EINVAL);
+#ifdef CONFIG_DMA_VIRT_OPS
+ if (dev->dma_ops == &dma_virt_ops)
+ return ERR_PTR(-EINVAL);
+#endif
+
attach = kzalloc(sizeof(*attach), GFP_KERNEL);
if (!attach)
return ERR_PTR(-ENOMEM);
--
1.8.3.1
prev parent reply other threads:[~2020-11-05 22:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 22:48 [PATCH v8 0/5] RDMA: Add dma-buf support Jianxin Xiong
2020-11-05 22:48 ` [PATCH v8 1/5] RDMA/umem: Support importing dma-buf as user memory region Jianxin Xiong
2020-11-06 0:08 ` Jason Gunthorpe
2020-11-06 16:34 ` Xiong, Jianxin
2020-11-06 16:39 ` Jason Gunthorpe
2020-11-06 17:01 ` Xiong, Jianxin
2020-11-10 14:14 ` Daniel Vetter
2020-11-10 14:27 ` Jason Gunthorpe
2020-11-10 14:44 ` Daniel Vetter
2020-11-10 17:23 ` Xiong, Jianxin
2020-11-05 22:48 ` [PATCH v8 2/5] RDMA/core: Add device method for registering dma-buf based " Jianxin Xiong
2020-11-05 22:48 ` [PATCH v8 3/5] RDMA/uverbs: Add uverbs command for dma-buf based MR registration Jianxin Xiong
2020-11-06 0:13 ` Jason Gunthorpe
2020-11-06 16:20 ` Xiong, Jianxin
2020-11-06 16:37 ` Jason Gunthorpe
2020-11-05 22:48 ` [PATCH v8 4/5] RDMA/mlx5: Support dma-buf based userspace memory region Jianxin Xiong
2020-11-06 0:25 ` Jason Gunthorpe
2020-11-06 1:11 ` Xiong, Jianxin
2020-11-06 12:48 ` Jason Gunthorpe
2020-11-06 16:10 ` Xiong, Jianxin
2020-11-05 22:48 ` Jianxin Xiong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1604616489-69267-6-git-send-email-jianxin.xiong@intel.com \
--to=jianxin.xiong@intel.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox