Re: [PATCH 7/8] drm/etnaviv: drop GPU initialized property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lucas

Am Mi., 7. Juni 2023 um 15:02 Uhr schrieb Lucas Stach <l.stach@xxxxxxxxxxxxxx>:
>
> 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@xxxxxxxxxxxxxx>

Reviewed-by: Christian Gmeiner <cgmeiner@xxxxxxxxxx>

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c | 3 +++
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c    | 9 ++-------
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.h    | 1 -
>  drivers/gpu/drm/etnaviv/etnaviv_mmu.c    | 3 +++
>  4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c b/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
> index 9dc20d892c15..721d633aece9 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
> @@ -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,
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 96cbb290b869..e62761032afe 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -868,8 +868,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:
> @@ -1797,11 +1795,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;
>         xa_destroy(&gpu->user_fences);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> index 33ecc1bf84b1..a4a9253f0d52 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
> @@ -114,7 +114,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;
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
> index 67bdce5326c6..4fa72567183a 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
> @@ -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;
>
> --
> 2.39.2
>


-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux