From 2ba5e1d68173143ee9d55b59c7ac364887267e74 Mon Sep 17 00:00:00 2001 From: Chaoyi Chen Date: Wed, 25 Sep 2024 09:34:14 +0800 Subject: [PATCH] drm/rockchip: gem: Set size of the allocated object when create gem We may want to know how many size of a gem object is allocated, but this size in rockchip_gem_object for no-IOMMU devices will not be set. There are two ways to use rockchip GEMs, one is to create GEMs via DRM, and the other is to import buffer created by other devices via DMA-BUF and map it. For no-IOMMU devices, neither of them will set the buffer size. Let's set the size in rockchip_gem_object when we create a new rockchip gem. Fixes: c1c9524d3f8a ("drm/rockchip: debugfs: optimize dump buffer file name and size") Change-Id: I396bf60a0d49d6f703044f9d354aa37312c9cc82 Signed-off-by: Chaoyi Chen --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 7b52a92bdd6a..862c50d94c97 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -67,8 +67,6 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj) iommu_flush_iotlb_all(private->domain); - rk_obj->size = ret; - return 0; err_remove_node: @@ -731,6 +729,7 @@ rockchip_gem_create_with_handle(struct drm_file *file_priv, return ERR_CAST(rk_obj); obj = &rk_obj->base; + rk_obj->size = size; /* * allocate a id of idr table where the obj is registered @@ -863,6 +862,7 @@ rockchip_gem_prime_import_sg_table(struct drm_device *drm, goto err_free_rk_obj; } + rk_obj->size = attach->dmabuf->size; rk_obj->num_pages = rk_obj->base.size >> PAGE_SHIFT; rk_obj->pages = drm_calloc_large(rk_obj->num_pages, sizeof(*rk_obj->pages)); if (!rk_obj->pages) {