drm/etnaviv: drop GPU initialized property
authorLucas Stach <l.stach@pengutronix.de>
Wed, 7 Jun 2023 13:02:22 +0000 (15:02 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Wed, 13 Mar 2024 06:58:56 +0000 (15:58 +0900)
Now that it is only used to track the driver internal state of
the MMU global and cmdbuf objects, we can get rid of this property
by making the free/finit functions of those objects safe to call
on an uninitialized object.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
(cherry picked from commit e44f708a9e7bcf88a7ba3b6f2f15121c7681057c)
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.h
drivers/gpu/drm/etnaviv/etnaviv_mmu.c

index 9dc20d892c15cce50ffe480cdb72723743c0217b..721d633aece9d4c81f0019e4c55884f26ee61c60 100644 (file)
@@ -121,6 +121,9 @@ void etnaviv_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf)
        int order = order_base_2(ALIGN(cmdbuf->size, SUBALLOC_GRANULE) /
                                 SUBALLOC_GRANULE);
 
+       if (!suballoc)
+               return;
+
        mutex_lock(&suballoc->lock);
        bitmap_release_region(suballoc->granule_map,
                              cmdbuf->suballoc_offset / SUBALLOC_GRANULE,
index 363947a8e85f9bcdfc19671e6c6f5a793d55bccc..8ff3e7d11f380a0e2401e943afebee03a7f95fbc 100644 (file)
@@ -866,8 +866,6 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
        pm_runtime_mark_last_busy(gpu->dev);
        pm_runtime_put_autosuspend(gpu->dev);
 
-       gpu->initialized = true;
-
        return 0;
 
 fail:
@@ -1796,11 +1794,8 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
        if (gpu->mmu_context)
                etnaviv_iommu_context_put(gpu->mmu_context);
 
-       if (gpu->initialized) {
-               etnaviv_cmdbuf_free(&gpu->buffer);
-               etnaviv_iommu_global_fini(gpu);
-               gpu->initialized = false;
-       }
+       etnaviv_cmdbuf_free(&gpu->buffer);
+       etnaviv_iommu_global_fini(gpu);
 
        gpu->drm = NULL;
        idr_destroy(&gpu->fence_idr);
index 5acd06f993d365d05cbb18f5f4ff0bea77266c8d..9502152929adcc5c7900c3e7b76d018628b298ca 100644 (file)
@@ -110,7 +110,6 @@ struct etnaviv_gpu {
        struct mutex sched_lock;
        struct drm_gpu_scheduler sched;
        enum etnaviv_gpu_state state;
-       bool initialized;
 
        /* 'ring'-buffer: */
        struct etnaviv_cmdbuf buffer;
index 67bdce5326c6e3a3b6efb3da787e3c58ed22f4b8..4fa72567183a8e138683f8c072c219974e1befa8 100644 (file)
@@ -553,6 +553,9 @@ void etnaviv_iommu_global_fini(struct etnaviv_gpu *gpu)
        struct etnaviv_drm_private *priv = gpu->drm->dev_private;
        struct etnaviv_iommu_global *global = priv->mmu_global;
 
+       if (!global)
+               return;
+
        if (--global->use > 0)
                return;