drm/tegra: Map cmdbuf once for reloc processing
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 18 Nov 2019 10:35:22 +0000 (11:35 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 25 Nov 2019 21:36:01 +0000 (22:36 +0100)
A few reasons to drop kmap:

- For native objects all we do is look at obj->vaddr anyway, so might
  as well not call functions for every page.

- Reloc-processing on dma-buf is ... questionable.

- Plus most dma-buf that bother kernel cpu mmaps give you at least
  vmap, much less kmaps. And all the ones relevant for arm-soc are
  again doing a obj->vaddr game anyway, there's no real kmap going on
  on arm it seems.

Plus this seems to be the only real in-tree user of dma_buf_kmap, and
I'd like to get rid of that.

Reviewed-by: Thierry Reding <treding@nvidia.com>
Tested-by: Thierry Reding <treding@nvidia.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20191118103536.17675-2-daniel.vetter@ffwll.ch
drivers/gpu/host1x/job.c

index eaa5c33..fb36d37 100644 (file)
@@ -186,8 +186,7 @@ unpin:
 
 static int do_relocs(struct host1x_job *job, struct host1x_job_gather *g)
 {
-       u32 last_page = ~0;
-       void *cmdbuf_page_addr = NULL;
+       void *cmdbuf_addr = NULL;
        struct host1x_bo *cmdbuf = g->bo;
        unsigned int i;
 
@@ -209,28 +208,22 @@ static int do_relocs(struct host1x_job *job, struct host1x_job_gather *g)
                        goto patch_reloc;
                }
 
-               if (last_page != reloc->cmdbuf.offset >> PAGE_SHIFT) {
-                       if (cmdbuf_page_addr)
-                               host1x_bo_kunmap(cmdbuf, last_page,
-                                                cmdbuf_page_addr);
+               if (!cmdbuf_addr) {
+                       cmdbuf_addr = host1x_bo_mmap(cmdbuf);
 
-                       cmdbuf_page_addr = host1x_bo_kmap(cmdbuf,
-                                       reloc->cmdbuf.offset >> PAGE_SHIFT);
-                       last_page = reloc->cmdbuf.offset >> PAGE_SHIFT;
-
-                       if (unlikely(!cmdbuf_page_addr)) {
+                       if (unlikely(!cmdbuf_addr)) {
                                pr_err("Could not map cmdbuf for relocation\n");
                                return -ENOMEM;
                        }
                }
 
-               target = cmdbuf_page_addr + (reloc->cmdbuf.offset & ~PAGE_MASK);
+               target = cmdbuf_addr + reloc->cmdbuf.offset;
 patch_reloc:
                *target = reloc_addr;
        }
 
-       if (cmdbuf_page_addr)
-               host1x_bo_kunmap(cmdbuf, last_page, cmdbuf_page_addr);
+       if (cmdbuf_addr)
+               host1x_bo_munmap(cmdbuf, cmdbuf_addr);
 
        return 0;
 }