Skip to content

Commit

Permalink
drm/rockchip: avoid duplicate mappings for IOMMU devices
Browse files Browse the repository at this point in the history
If a buffer is allocated with alloc_kmap, then it is vmap'd on creation
and there is no reason to map it again in rockchip_gem_prime_vmap() when
the existing mapping can be used.

Signed-off-by: John Keeping <[email protected]>
Signed-off-by: Heiko Stuebner <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
johnkeeping authored and mmind committed Feb 5, 2023
1 parent 582212e commit 0020d4c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/gpu/drm/rockchip/rockchip_drm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,14 @@ int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);

if (rk_obj->pages) {
void *vaddr = vmap(rk_obj->pages, rk_obj->num_pages, VM_MAP,
pgprot_writecombine(PAGE_KERNEL));
void *vaddr;

if (rk_obj->kvaddr)
vaddr = rk_obj->kvaddr;
else
vaddr = vmap(rk_obj->pages, rk_obj->num_pages, VM_MAP,
pgprot_writecombine(PAGE_KERNEL));

if (!vaddr)
return -ENOMEM;
iosys_map_set_vaddr(map, vaddr);
Expand All @@ -540,7 +546,8 @@ void rockchip_gem_prime_vunmap(struct drm_gem_object *obj,
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);

if (rk_obj->pages) {
vunmap(map->vaddr);
if (map->vaddr != rk_obj->kvaddr)
vunmap(map->vaddr);
return;
}

Expand Down

0 comments on commit 0020d4c

Please sign in to comment.