In-kernel DRM clients map their buffers with drm_client_buffer_vmap*(),
which go through drm_gem_object_funcs.vmap. Tegra only implements vmap
for exported dma-bufs, so drm_gem_vmap() fails with -EOPNOTSUPP and the
drm_log client sets a mode but never draws anything.

Implement the GEM vmap/vunmap callbacks with the existing mapping
helpers, and make the dma-buf callbacks use them.

Signed-off-by: Artur Kowalski <[email protected]>
---
 drivers/gpu/drm/tegra/gem.c | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index f76af733ea79..e52d2ee9f69c 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -293,9 +293,32 @@ static int tegra_bo_iommu_unmap(struct tegra_drm *tegra, 
struct tegra_bo *bo)
        return 0;
 }
 
+static int tegra_bo_vmap(struct drm_gem_object *gem, struct iosys_map *map)
+{
+       struct tegra_bo *bo = to_tegra_bo(gem);
+       void *vaddr;
+
+       vaddr = tegra_bo_mmap(&bo->base);
+       if (IS_ERR(vaddr))
+               return PTR_ERR(vaddr);
+
+       iosys_map_set_vaddr(map, vaddr);
+
+       return 0;
+}
+
+static void tegra_bo_vunmap(struct drm_gem_object *gem, struct iosys_map *map)
+{
+       struct tegra_bo *bo = to_tegra_bo(gem);
+
+       tegra_bo_munmap(&bo->base, map->vaddr);
+}
+
 static const struct drm_gem_object_funcs tegra_gem_object_funcs = {
        .free = tegra_bo_free_object,
        .export = tegra_gem_prime_export,
+       .vmap = tegra_bo_vmap,
+       .vunmap = tegra_bo_vunmap,
        .vm_ops = &tegra_bo_vm_ops,
 };
 
@@ -718,25 +741,12 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, 
struct vm_area_struct *vma)
 
 static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map)
 {
-       struct drm_gem_object *gem = buf->priv;
-       struct tegra_bo *bo = to_tegra_bo(gem);
-       void *vaddr;
-
-       vaddr = tegra_bo_mmap(&bo->base);
-       if (IS_ERR(vaddr))
-               return PTR_ERR(vaddr);
-
-       iosys_map_set_vaddr(map, vaddr);
-
-       return 0;
+       return tegra_bo_vmap(buf->priv, map);
 }
 
 static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct iosys_map *map)
 {
-       struct drm_gem_object *gem = buf->priv;
-       struct tegra_bo *bo = to_tegra_bo(gem);
-
-       tegra_bo_munmap(&bo->base, map->vaddr);
+       tegra_bo_vunmap(buf->priv, map);
 }
 
 static const struct dma_buf_ops tegra_gem_prime_dmabuf_ops = {

---
base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
change-id: 20261128-tegra-drm-map-a729e4d02835

Best regards,
--  
Artur Kowalski <[email protected]>

Reply via email to