Skip to content

Commit 0cc5fb4

Browse files
committed
drm/shmem-helpers: Don't call get/put_pages on imported dma-buf in vmap
There's no direct harm, because for the shmem helpers these are noops on imported buffers. The trouble is in the locks these take - I want to change dma_buf_vmap locking, and so need to make sure that we only ever take certain locks on one side of the dma-buf interface: Either for exporters, or for importers. v2: Change the control flow less compared to what's there (Thomas) Tested-by: Boris Brezillon <boris.brezillon@collabora.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Rob Herring <robh@kernel.org> Cc: Noralf Trønnes <noralf@tronnes.org> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200514202256.490926-1-daniel.vetter@ffwll.ch
1 parent 3a5a597 commit 0cc5fb4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/gpu/drm/drm_gem_shmem_helper.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem)
252252
if (shmem->vmap_use_count++ > 0)
253253
return shmem->vaddr;
254254

255-
ret = drm_gem_shmem_get_pages(shmem);
256-
if (ret)
257-
goto err_zero_use;
258-
259255
if (obj->import_attach) {
260256
shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
261257
} else {
262258
pgprot_t prot = PAGE_KERNEL;
263259

260+
ret = drm_gem_shmem_get_pages(shmem);
261+
if (ret)
262+
goto err_zero_use;
263+
264264
if (!shmem->map_cached)
265265
prot = pgprot_writecombine(prot);
266266
shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
@@ -276,7 +276,8 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem)
276276
return shmem->vaddr;
277277

278278
err_put_pages:
279-
drm_gem_shmem_put_pages(shmem);
279+
if (!obj->import_attach)
280+
drm_gem_shmem_put_pages(shmem);
280281
err_zero_use:
281282
shmem->vmap_use_count = 0;
282283

0 commit comments

Comments
 (0)