drm/rockchip: gem: add begin/end cpu access
authorMark Yao <mark.yao@rock-chips.com>
Thu, 13 Jul 2017 06:57:02 +0000 (14:57 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 13 Jul 2017 10:40:17 +0000 (18:40 +0800)
Change-Id: Ie2c54addcf037cf501edcad76470e5e46c667b7e
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
drivers/gpu/drm/rockchip/rockchip_drm_gem.c
drivers/gpu/drm/rockchip/rockchip_drm_gem.h

index 770a565ec6c5de8c53527cb5f568bc9c3882a4b0..5a201074519c780473927a20cf912b7d45feedf7 100644 (file)
@@ -1273,6 +1273,8 @@ static struct drm_driver rockchip_drm_driver = {
        .gem_prime_vmap         = rockchip_gem_prime_vmap,
        .gem_prime_vunmap       = rockchip_gem_prime_vunmap,
        .gem_prime_mmap         = rockchip_gem_mmap_buf,
+       .gem_prime_begin_cpu_access = rockchip_gem_prime_begin_cpu_access,
+       .gem_prime_end_cpu_access = rockchip_gem_prime_end_cpu_access,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init           = rockchip_drm_debugfs_init,
        .debugfs_cleanup        = rockchip_drm_debugfs_cleanup,
index fa34c17bde4d07ffb4e870c50d9c98248eac59d8..bdb84c4bab9ddd51a47e35a29534c6bdb7743e27 100644 (file)
@@ -983,3 +983,32 @@ void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
 
        /* Nothing to do if allocated by DMA mapping API. */
 }
+
+int rockchip_gem_prime_begin_cpu_access(struct drm_gem_object *obj,
+                                       size_t start, size_t len,
+                                       enum dma_data_direction dir)
+{
+       struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
+       struct drm_device *drm = obj->dev;
+
+       if (!rk_obj->sgt)
+               return 0;
+
+       dma_sync_sg_for_cpu(drm->dev, rk_obj->sgt->sgl,
+                           rk_obj->sgt->nents, dir);
+       return 0;
+}
+
+void rockchip_gem_prime_end_cpu_access(struct drm_gem_object *obj,
+                                  size_t start, size_t len,
+                                  enum dma_data_direction dir)
+{
+       struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
+       struct drm_device *drm = obj->dev;
+
+       if (!rk_obj->sgt)
+               return;
+
+       dma_sync_sg_for_device(drm->dev, rk_obj->sgt->sgl,
+                              rk_obj->sgt->nents, dir);
+}
index 144c519320f9ee543ff7b17a03dbd2cdb4e0d22f..a2b151945b5171156bf6a6f612318f4e9404c0c3 100644 (file)
@@ -101,4 +101,12 @@ int rockchip_gem_cpu_acquire_ioctl(struct drm_device *dev, void* data,
 int rockchip_gem_cpu_release_ioctl(struct drm_device *dev, void* data,
                                   struct drm_file *file_priv);
 
+int rockchip_gem_prime_begin_cpu_access(struct drm_gem_object *obj,
+                                       size_t start, size_t len,
+                                       enum dma_data_direction dir);
+
+void rockchip_gem_prime_end_cpu_access(struct drm_gem_object *obj,
+                                      size_t start, size_t len,
+                                      enum dma_data_direction dir);
+
 #endif /* _ROCKCHIP_DRM_GEM_H */