Skip to content

Commit

Permalink
drm/shmem-helpers: vunmap: Don't put pages for dma-buf
Browse files Browse the repository at this point in the history
dma-buf importing was reworked in commit 7d2cd72
("drm/shmem-helpers: Simplify dma-buf importing"). Before that commit
drm_gem_shmem_prime_import_sg_table() did set ->pages_use_count=1 and
drm_gem_shmem_vunmap_locked() could call drm_gem_shmem_put_pages()
unconditionally. Now without the use count set, put pages is called also
on dma-bufs. Fix this by only putting pages if it's not imported.

Signed-off-by: Noralf Trønnes <[email protected]>
Fixes: 7d2cd72 ("drm/shmem-helpers: Simplify dma-buf importing")
Cc: Daniel Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Acked-by: Thomas Zimmermann <[email protected]>
Tested-by: Thomas Zimmermann <[email protected]>
Signed-off-by: Thomas Zimmermann <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
notro authored and Thomas Zimmermann committed Feb 25, 2021
1 parent c129b49 commit cdea725
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/gpu/drm/drm_gem_shmem_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,14 @@ static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
if (--shmem->vmap_use_count > 0)
return;

if (obj->import_attach)
if (obj->import_attach) {
dma_buf_vunmap(obj->import_attach->dmabuf, map);
else
} else {
vunmap(shmem->vaddr);
drm_gem_shmem_put_pages(shmem);
}

shmem->vaddr = NULL;
drm_gem_shmem_put_pages(shmem);
}

/*
Expand Down

0 comments on commit cdea725

Please sign in to comment.