dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Li <Samuel.Li-5C7GfCeVMHo@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: "Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 1/3] drm/prime: forward begin_cpu_access callback to drivers
Date: Fri, 15 Dec 2017 11:28:02 -0500	[thread overview]
Message-ID: <1513355282-20248-1-git-send-email-Samuel.Li@amd.com> (raw)

From: Christian König <christian.koenig@amd.com>

Allow drivers to implement their own begin_cpu_access callback.

Change-Id: I97709b42b9351a04ee7e01106107a87bc56ea258
Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/drm_prime.c | 13 +++++++++++++
 include/drm/drm_drv.h       |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 8de93a2..b4b0e64 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -346,6 +346,18 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
 }
 EXPORT_SYMBOL(drm_gem_dmabuf_release);
 
+static int drm_gem_dmabuf_begin_cpu_access(struct dma_buf *dma_buf,
+					    enum dma_data_direction direction)
+{
+	struct drm_gem_object *obj = dma_buf->priv;
+	struct drm_device *dev = obj->dev;
+
+	if (!dev->driver->gem_prime_begin_cpu_access)
+		return 0;
+
+	return dev->driver->gem_prime_begin_cpu_access(obj, direction);
+}
+
 static void *drm_gem_dmabuf_vmap(struct dma_buf *dma_buf)
 {
 	struct drm_gem_object *obj = dma_buf->priv;
@@ -403,6 +415,7 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops =  {
 	.map_dma_buf = drm_gem_map_dma_buf,
 	.unmap_dma_buf = drm_gem_unmap_dma_buf,
 	.release = drm_gem_dmabuf_release,
+	.begin_cpu_access = drm_gem_dmabuf_begin_cpu_access,
 	.map = drm_gem_dmabuf_kmap,
 	.map_atomic = drm_gem_dmabuf_kmap_atomic,
 	.unmap = drm_gem_dmabuf_kunmap,
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 412e83a..1fbf298 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -475,6 +475,8 @@ struct drm_driver {
 				struct drm_device *dev,
 				struct dma_buf_attachment *attach,
 				struct sg_table *sgt);
+	int (*gem_prime_begin_cpu_access)(struct drm_gem_object *obj,
+					   enum dma_data_direction direction);
 	void *(*gem_prime_vmap)(struct drm_gem_object *obj);
 	void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
 	int (*gem_prime_mmap)(struct drm_gem_object *obj,
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

             reply	other threads:[~2017-12-15 16:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15 16:28 Samuel Li [this message]
     [not found] ` <1513355282-20248-1-git-send-email-Samuel.Li-5C7GfCeVMHo@public.gmane.org>
2017-12-16  5:40   ` [PATCH 1/3] drm/prime: forward begin_cpu_access callback to drivers kbuild test robot
2017-12-16  6:29 ` kbuild test robot
2017-12-20 17:20 ` Li, Samuel
2017-12-20 19:43   ` Daniel Vetter
2017-12-20 19:54     ` Christian König
     [not found]       ` <4c0df435-913c-7569-591b-f15c212bc249-5C7GfCeVMHo@public.gmane.org>
2017-12-21 10:04         ` Daniel Vetter

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=1513355282-20248-1-git-send-email-Samuel.Li@amd.com \
    --to=samuel.li-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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