Skip to contentSkip to conversation

drm/panthor: Handle errors returned by drm_sched_entity_init()

PATCH Superseded Boris Brezillon 3 participants 4 messages Oct 30, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Boris Brezillon

author maintainer
#0 lore raw

PATCH 1/2 drm/panthor: Handle errors returned by drm_sched_entity_init()

In practice it's not going to fail because we're passing the current sanity checks done by drm_sched_entity_init(), and that's the only reason it would return an error, but better safe than sorry.

Fixes de8548813824 ("drm/panthor: Add the scheduler logical block")
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/panthor/panthor_sched.c +2 -0
index df76653e649a..a0a31aa6c6bc 100644
@@ -3380,6 +3380,8 @@ group_create_queue(struct panthor_group *group,
 
 	drm_sched = &queue->scheduler;
 	ret = drm_sched_entity_init(&queue->entity, 0, &drm_sched, 1, NULL);
+	if (ret)
+		goto err_free_queue;
 
 	return queue;
 
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH 2/2 drm/panthor: Fix group_free_queue() for partially initialized queues

group_free_queue() can be called on a partially initialized queue object if something fails group_create_queue(). Make sure we don't call drm_sched_entity_destroy() on a entity that hasn't been initialized.

Fixes 7d9c3442b02a ("drm/panthor: Defer scheduler entitiy destruction to queue release")
---
 drivers/gpu/drm/panthor/panthor_sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +2 -1
index a0a31aa6c6bc..552542f70cab 100644
@@ -886,7 +886,8 @@ static void group_free_queue(struct panthor_group *group, struct panthor_queue *
 	if (IS_ERR_OR_NULL(queue))
 		return;
 
-	drm_sched_entity_destroy(&queue->entity);
+	if (queue->entity.fence_context)
+		drm_sched_entity_destroy(&queue->entity);
 
 	if (queue->scheduler.ops)
 		drm_sched_fini(&queue->scheduler);
Signature · 1 line
2.51.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/panthor: Fix group_free_queue() for partially initialized queues

Quoted 26 lines · Boris Brezillon

group_free_queue() can be called on a partially initialized queue object if something fails group_create_queue(). Make sure we don't call drm_sched_entity_destroy() on a entity that hasn't been initialized.

Fixes 7d9c3442b02a ("drm/panthor: Defer scheduler entitiy destruction to queue release")
---
 drivers/gpu/drm/panthor/panthor_sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +2 -2
index a0a31aa6c6bc..552542f70cab 100644
@@ -886,7 +886,8 @@ static void group_free_queue(struct panthor_group *group, struct panthor_queue *
 	if (IS_ERR_OR_NULL(queue))
 		return;
 
-	drm_sched_entity_destroy(&queue->entity);
+	if (queue->entity.fence_context)
+		drm_sched_entity_destroy(&queue->entity);
 
 	if (queue->scheduler.ops)
 		drm_sched_fini(&queue->scheduler);
--
Quoted 1 line

2.51.0

Adrian Larumbe

maintainer Reviewed-by on v1 1/2
#3 lore raw
In reply to Boris Brezillon
Quoted 6 lines · Boris Brezillon

In practice it's not going to fail because we're passing the current sanity checks done by drm_sched_entity_init(), and that's the only reason it would return an error, but better safe than sorry.

Fixes de8548813824 ("drm/panthor: Add the scheduler logical block")

For the whole series:

Best regards,
Liviu

Quoted 20 lines
---
 drivers/gpu/drm/panthor/panthor_sched.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/panthor/panthor_sched.c +2 -0
index df76653e649a..a0a31aa6c6bc 100644
@@ -3380,6 +3380,8 @@ group_create_queue(struct panthor_group *group,
 
 	drm_sched = &queue->scheduler;
 	ret = drm_sched_entity_init(&queue->entity, 0, &drm_sched, 1, NULL);
+	if (ret)
+		goto err_free_queue;
 
 	return queue;
 
Signature · 1 line
2.51.0
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯