From 112d2aa334899a17b4a5fba7c23cab91c9d36aac Mon Sep 17 00:00:00 2001 From: Mark Yao Date: Wed, 18 Jan 2017 12:50:40 +0800 Subject: [PATCH] drm/rockchip: logo: add iommu map size for logo buffer iommu mapping Fix bug: iova 0x0(logo buffer) unmap fail: iommu: unaligned: iova 0x0 size 0xa5638 min_pagesz 0x1000 then cause iova 0x0 mmap fail: iova: 0x0000000000000000 already mapped to 0x00000000f5c00000 cannot remap to phys: 0x00000000d6c6f000 prot: 0x3 Change-Id: I77443e9dba98aa6141aa44a42880b1cccc04043b Signed-off-by: Mark Yao --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++-- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index cbd133eb25aa..4c58306c606f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -162,8 +162,10 @@ static int init_loader_memory(struct drm_device *drm_dev) logo->dma_addr = logo->mm.start; - if (iommu_map_sg(private->domain, logo->dma_addr, sgt->sgl, - sgt->nents, prot) < size) { + logo->iommu_map_size = iommu_map_sg(private->domain, + logo->dma_addr, sgt->sgl, + sgt->nents, prot); + if (logo->iommu_map_size < size) { DRM_ERROR("failed to map buffer"); ret = -ENOMEM; goto err_remove_node; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 8ddc21eadc39..8a8d67381e74 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -102,6 +102,7 @@ struct rockchip_logo { dma_addr_t dma_addr; phys_addr_t start; phys_addr_t size; + size_t iommu_map_size; int count; }; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index 7bb9e787bf41..9b8d15b1e267 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -67,7 +67,7 @@ static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb) if (private && private->domain) { iommu_unmap(private->domain, logo->dma_addr, - logo->size); + logo->iommu_map_size); drm_mm_remove_node(&logo->mm); } else { dma_unmap_sg(fb->dev->dev, logo->sgt->sgl, -- 2.34.1