Skip to content

Commit 3a5a597

Browse files
committed
drm/udl: Don't call get/put_pages on imported dma-buf
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. Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Sean Paul <sean@poorly.run> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200511093554.211493-6-daniel.vetter@ffwll.ch
1 parent d323bb4 commit 3a5a597

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/gpu/drm/udl/udl_gem.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,31 @@ static void *udl_gem_object_vmap(struct drm_gem_object *obj)
4646
if (shmem->vmap_use_count++ > 0)
4747
goto out;
4848

49-
ret = drm_gem_shmem_get_pages(shmem);
50-
if (ret)
51-
goto err_zero_use;
52-
53-
if (obj->import_attach)
49+
if (obj->import_attach) {
5450
shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
55-
else
51+
} else {
52+
ret = drm_gem_shmem_get_pages(shmem);
53+
if (ret)
54+
goto err;
55+
5656
shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
5757
VM_MAP, PAGE_KERNEL);
5858

59+
if (!shmem->vaddr)
60+
drm_gem_shmem_put_pages(shmem);
61+
}
62+
5963
if (!shmem->vaddr) {
6064
DRM_DEBUG_KMS("Failed to vmap pages\n");
6165
ret = -ENOMEM;
62-
goto err_put_pages;
66+
goto err;
6367
}
6468

6569
out:
6670
mutex_unlock(&shmem->vmap_lock);
6771
return shmem->vaddr;
6872

69-
err_put_pages:
70-
drm_gem_shmem_put_pages(shmem);
71-
err_zero_use:
73+
err:
7274
shmem->vmap_use_count = 0;
7375
mutex_unlock(&shmem->vmap_lock);
7476
return ERR_PTR(ret);

0 commit comments

Comments
 (0)