diff mbox series

drm/rockchip: avoid duplicate mappings for IOMMU devices

Message ID 20221110172415.2853420-1-john@metanate.com (mailing list archive)
State New, archived
Headers show
Series drm/rockchip: avoid duplicate mappings for IOMMU devices | expand

Commit Message

John Keeping Nov. 10, 2022, 5:24 p.m. UTC
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 <john@metanate.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Heiko Stübner Feb. 5, 2023, 2:56 p.m. UTC | #1
On Thu, 10 Nov 2022 17:24:14 +0000, John Keeping wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] drm/rockchip: avoid duplicate mappings for IOMMU devices
      commit: 0020d4cfa3eea0e5fad23af49411217da854fc83

Best regards,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 6edb7c52cb3d..c9507d27f0ba 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -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);
@@ -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;
 	}