Skip to contentSkip to conversation

drm/sched: Make drm_sched_entity_kill() a public function

PATCH Superseded Philipp Stanner 2 participants 3 messages Apr 14

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Philipp Stanner

author maintainer
#0 lore raw

PATCH 1/2 drm/sched: Make drm_sched_entity_kill() a public function

Some drivers do not care on teardown whether the last jobs pending in an entity are actually executed before teardown completed. For such scenarios, drm_sched_entity_flush() is not the ideal function.

Make drm_sched_entity_kill() public for that use-case and update the documentation.

---
 drivers/gpu/drm/scheduler/sched_entity.c | 13 +++++++++++--
 include/drm/gpu_scheduler.h              |  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +11 -2
index 61a4818cc87b..16c525b26c08 100644
@@ -267,8 +267,16 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,
 	schedule_work(&job->work);
 }
 
-/* Remove the entity from the scheduler and kill all pending jobs */
-static void drm_sched_entity_kill(struct drm_sched_entity *entity)
+/**
+ * drm_sched_entity_kill - kill an entities pending jobs and remove it
+ * @entity: the entity to kill
+ *
+ * Removes the entity from the scheduler and kills all pending jobs.
+ *
+ * This function should be used over drm_sched_entity_flush() if it is not
+ * desired to actually wait for all pending jobs to finish.
+ */
+void drm_sched_entity_kill(struct drm_sched_entity *entity)
 {
 	struct drm_sched_job *job;
 	struct dma_fence *prev;
@@ -306,6 +314,7 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)
 	}
 	dma_fence_put(prev);
 }
+EXPORT_SYMBOL(drm_sched_entity_kill);
 
 /**
  * drm_sched_entity_flush - Flush a context entity
include/drm/gpu_scheduler.h +1 -0
index 53417baebd49..d61c19e78182 100644
@@ -693,6 +693,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
 			  unsigned int num_sched_list,
 			  atomic_t *guilty);
 long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout);
+void drm_sched_entity_kill(struct drm_sched_entity *entity);
 void drm_sched_entity_fini(struct drm_sched_entity *entity);
 void drm_sched_entity_destroy(struct drm_sched_entity *entity);
 void drm_sched_entity_set_priority(struct drm_sched_entity *entity,
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 2/2 drm/nouveau: Fix double call to drm_sched_entity_fini()

nouveau_abi16_chan_fini() does invoke drm_sched_entity_fini() twice:
Once directly, and a second time through nouveau_sched_destroy().

That's likely undesired behavior and might be a bug since drm_sched_entity_fini() decrements reference counts.

Fix the issue by using the appropriate function, drm_sched_entity_flush(), to ensure that the entity becomes idle.

Fixes 9a0c32d698c1 ("drm/nouveau: don't fini scheduler if not initialized")
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_abi16.c +1 -1
index 7860877d909b..291203121f0c 100644
@@ -176,7 +176,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
 
 	/* Cancel all jobs from the entity's queue. */
 	if (chan->sched)
-		drm_sched_entity_fini(&chan->sched->entity);
+		drm_sched_entity_kill(&chan->sched->entity);
 
 	if (chan->chan)
 		nouveau_channel_idle(chan->chan);
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH 2/2] drm/nouveau: Fix double call to drm_sched_entity_fini()

Quoted 9 lines · Philipp Stanner

nouveau_abi16_chan_fini() does invoke drm_sched_entity_fini() twice:
Once directly, and a second time through nouveau_sched_destroy().

That's likely undesired behavior and might be a bug since drm_sched_entity_fini() decrements reference counts.

Fix the issue by using the appropriate function, drm_sched_entity_flush(), to ensure that the entity becomes idle.

Your commit message says drm_sched_entity_flush but the commit uses drm_sched_entity_kill.

Quoted 24 lines
Fixes 9a0c32d698c1 ("drm/nouveau: don't fini scheduler if not initialized")
---
 drivers/gpu/drm/nouveau/nouveau_abi16.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_abi16.c +1 -2
index 7860877d909b..291203121f0c 100644
@@ -176,7 +176,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
 
        /* Cancel all jobs from the entity's queue. */
        if (chan->sched)
-               drm_sched_entity_fini(&chan->sched->entity);
+               drm_sched_entity_kill(&chan->sched->entity);
 
        if (chan->chan)
                nouveau_channel_idle(chan->chan);
--

2.49.0