Skip to contentSkip to conversation

drm/panthor: Handle errors returned by drm_sched_entity_init()

PATCH In review Boris Brezillon 2 participants 4 messages Oct 31, 2025 – Nov 3, 2025

Subsystems (3)
lore
Share & tools
lore

Boris Brezillon

author maintainer
#0 lore raw

PATCH v2 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.

v2:
- Add R-b

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 4216913ad7c9..33e04208db31 100644
@@ -3430,6 +3430,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 v2 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 in group_create_queue(). Make sure we don't call drm_sched_entity_destroy() on an entity that hasn't been initialized.

v2:
- Fix typos
- Add R-b

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 33e04208db31..e0f5b9171320 100644
@@ -913,7 +913,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
maintainer Reviewed-by on v2 2/2
#2 lore raw

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

Quoted 5 lines · Boris Brezillon

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

Quoted 7 lines

v2:
- Fix typos
- Add R-b

Fixes 7d9c3442b02a ("drm/panthor: Defer scheduler entitiy destruction to queue release")

Best regards,
Liviu

Quoted 21 lines
---
 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 33e04208db31..e0f5b9171320 100644
@@ -913,7 +913,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
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
maintainer
#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.

v2:
- Add R-b

Hi,

Pushed the series to drm-misc-next but edited the commit messages to drop the v2 text.

Best regards,
Liviu

Quoted 24 lines
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 4216913ad7c9..33e04208db31 100644
@@ -3430,6 +3430,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!  /
  ---------------
    ¯\_(ツ)_/¯