On 03/12/2026 14:01, Tvrtko Ursulin wrote:
Start checking drm_sched_entity_init() return value in preparation of
making that API a bit stricter.

No functional change intended as the failure path should never trigger in
this driver.

Sashiko raised a good point, it can still fail on memory allocation failures. Need to rewrite the commit message and add the below tags.

Signed-off-by: Tvrtko Ursulin <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Russell King <[email protected]>
Cc: Christian Gmeiner <[email protected]>
Cc: [email protected]

Fixes: fd177135f0e6 ("drm/sched: Account entity GPU time")
Cc: <[email protected]> # v7.2+

Regards,

Tvrtko

---
Compile tested only.
---
  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 22 +++++++++++++++-------
  1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 7bd7aef723c3..53003c31d7f9 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -83,21 +83,29 @@ static int etnaviv_open(struct drm_device *dev, struct 
drm_file *file)
        }
for (i = 0; i < ETNA_MAX_PIPES; i++) {
-               struct etnaviv_gpu *gpu = priv->gpu[i];
                struct drm_gpu_scheduler *sched;
- if (gpu) {
-                       sched = &gpu->sched;
-                       drm_sched_entity_init(&ctx->sched_entity[i],
-                                             DRM_SCHED_PRIORITY_NORMAL, &sched,
-                                             1, NULL);
-               }
+               if (!priv->gpu[i])
+                       continue;
+
+               sched = &priv->gpu[i]->sched;
+               ret = drm_sched_entity_init(&ctx->sched_entity[i],
+                                           DRM_SCHED_PRIORITY_NORMAL,
+                                           &sched, 1, NULL);
+               if (ret)
+                       goto out_entity;
        }
file->driver_priv = ctx; return 0; +out_entity:
+       while (i--) {
+               if (priv->gpu[i])
+                       drm_sched_entity_destroy(&ctx->sched_entity[i]);
+       }
+       etnaviv_iommu_context_put(ctx->mmu);
  out_id:
        xa_erase(&priv->active_contexts, ctx->id);
  out_free:

Reply via email to