[PATCH 1/3] drm/prime: forward begin_cpu_access callback to drivers
Samuel Li
Samuel.Li at amd.com
Fri Dec 15 16:28:02 UTC 2017
From: Christian König <christian.koenig at amd.com>
Allow drivers to implement their own begin_cpu_access callback.
Change-Id: I97709b42b9351a04ee7e01106107a87bc56ea258
Signed-off-by: Christian König <christian.koenig at 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
More information about the amd-gfx
mailing list