drm/scheduler: Add drm_sched_job_cleanup
Subsystems (7)
PATCH 1/1 drm/scheduler: Add drm_sched_job_cleanup
This patch adds a new API to clean up the scheduler job resources. This is primarliy needed in cases the job was created but was not queued to the scheduler queue. Additionally with this change, the layer which creates the scheduler job also gets to free up the job's resources and this entails moving the dma_fence_put(finished_fence) to the drivers ops free handler routines.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++ drivers/gpu/drm/etnaviv/etnaviv_sched.c | 3 +++ drivers/gpu/drm/scheduler/sched_entity.c | 1 - drivers/gpu/drm/scheduler/sched_main.c | 12 +++++++++++- drivers/gpu/drm/v3d/v3d_sched.c | 2 ++ include/drm/gpu_scheduler.h | 1 + 7 files changed, 20 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -2
@@ -1260,8 +1260,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,return 0 ; error_abort: -dma_fence_put (&job->base.s_fence->finished); - job->base.s_fence =NULL ; +drm_sched_job_cleanup (&job->base);amdgpu_mn_unlock (p->mn); error_unlock:
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
@@ -112,6 +112,8 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job)struct amdgpu_ring *ring =to_amdgpu_ring (s_job->sched);struct amdgpu_job *job =to_amdgpu_job (s_job); +drm_sched_job_cleanup (s_job); +amdgpu_ring_priority_put (ring, s_job->s_priority);dma_fence_put (job->fence);amdgpu_sync_free (&job->sync);
drivers/gpu/drm/etnaviv/etnaviv_sched.c +3 -0
@@ -127,6 +127,8 @@ static void etnaviv_sched_free_job(struct drm_sched_job *sched_job) {struct etnaviv_gem_submit *submit =to_etnaviv_submit (sched_job); +drm_sched_job_cleanup (sched_job); +etnaviv_submit_put (submit); }
@@ -159,6 +161,7 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity, submit->out_fence,0 , INT_MAX, GFP_KERNEL);if (submit->out_fence_id <0 ) { +drm_sched_job_cleanup (&submit->sched_job); ret = -ENOMEM ; goto out_unlock; }
drivers/gpu/drm/scheduler/sched_entity.c +0 -1
@@ -204,7 +204,6 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,drm_sched_fence_finished (job->s_fence);WARN_ON (job->s_fence->parent); -dma_fence_put (&job->s_fence->finished); job->sched->ops->free_job (job); }
drivers/gpu/drm/scheduler/sched_main.c +11 -1
@@ -220,7 +220,6 @@ static void drm_sched_job_finish(struct work_struct *work)drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); -dma_fence_put (&s_job->s_fence->finished); sched->ops->free_job (s_job); }
@@ -424,6 +423,17 @@ int drm_sched_job_init(struct drm_sched_job *job,EXPORT_SYMBOL (drm_sched_job_init);/** +* drm_sched_job_cleanup - clean up scheduler job resources +* +* @job: scheduler job to clean up +*/ +void drm_sched_job_cleanup (struct drm_sched_job *job) +{ +dma_fence_put (&job->s_fence->finished); +} +EXPORT_SYMBOL (drm_sched_job_cleanup); + +/** * drm_sched_ready - is the scheduler ready * * @sched: scheduler instance
drivers/gpu/drm/v3d/v3d_sched.c +2 -0
@@ -35,6 +35,8 @@ {struct v3d_job *job =to_v3d_job (sched_job); +drm_sched_job_cleanup (sched_job); +v3d_exec_put (job->exec); }
include/drm/gpu_scheduler.h +1 -0
@@ -293,6 +293,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner); +void drm_sched_job_cleanup (struct drm_sched_job *job);void drm_sched_wakeup (struct drm_gpu_scheduler *sched);void drm_sched_hw_job_reset (struct drm_gpu_scheduler *sched,struct drm_sched_job *job);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): 1540551965-22215-1-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Am 26.10.18 um 13:06 schrieb Sharat Masetty:
Quoted 91 lines
This patch adds a new API to clean up the scheduler job resources. This is primarliy needed in cases the job was created but was not queued to the scheduler queue. Additionally with this change, the layer which creates the scheduler job also gets to free up the job's resources and this entails moving the
dma_fence_put(finished_fence)to the drivers ops free handler routines.Signed-off-by Sharat Masetty <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++ drivers/gpu/drm/etnaviv/etnaviv_sched.c | 3 +++ drivers/gpu/drm/scheduler/sched_entity.c | 1 - drivers/gpu/drm/scheduler/sched_main.c | 12 +++++++++++- drivers/gpu/drm/v3d/v3d_sched.c | 2 ++ include/drm/gpu_scheduler.h | 1 + 7 files changed, 20 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-2@@ -1260,8 +1260,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,return 0 ; error_abort: -dma_fence_put (&job->base.s_fence->finished); - job->base.s_fence =NULL ; +drm_sched_job_cleanup (&job->base);amdgpu_mn_unlock (p->mn); error_unlock:drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-0@@ -112,6 +112,8 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job)struct amdgpu_ring *ring =to_amdgpu_ring (s_job->sched);struct amdgpu_job *job =to_amdgpu_job (s_job); +drm_sched_job_cleanup (s_job); +amdgpu_ring_priority_put (ring, s_job->s_priority);dma_fence_put (job->fence);amdgpu_sync_free (&job->sync);drivers/gpu/drm/etnaviv/etnaviv_sched.c +3
-0@@ -127,6 +127,8 @@ static void etnaviv_sched_free_job(struct drm_sched_job *sched_job) {struct etnaviv_gem_submit *submit =to_etnaviv_submit (sched_job); +drm_sched_job_cleanup (sched_job); +etnaviv_submit_put (submit); }@@ -159,6 +161,7 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity, submit->out_fence,0 , INT_MAX, GFP_KERNEL);if (submit->out_fence_id <0 ) { +drm_sched_job_cleanup (&submit->sched_job); ret = -ENOMEM ; goto out_unlock; }drivers/gpu/drm/scheduler/sched_entity.c +0
-1@@ -204,7 +204,6 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,drm_sched_fence_finished (job->s_fence);WARN_ON (job->s_fence->parent); -dma_fence_put (&job->s_fence->finished); job->sched->ops->free_job (job); }drivers/gpu/drm/scheduler/sched_main.c +0
-1@@ -220,7 +220,6 @@ static void drm_sched_job_finish(struct work_struct *work)drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); -dma_fence_put (&s_job->s_fence->finished); sched->ops->free_job (s_job); }
drivers/gpu/drm/scheduler/sched_main.c int drm_sched_job_init(struct drm_sched_job *job, · line 432
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_main.c +7
-0@@ -424,6 +423,17 @@ int drm_sched_job_init(struct drm_sched_job *job,EXPORT_SYMBOL (drm_sched_job_init);/** +* drm_sched_job_cleanup - clean up scheduler job resources +* +* @job: scheduler job to clean up +*/ +void drm_sched_job_cleanup (struct drm_sched_job *job) +{ +dma_fence_put (&job->s_fence->finished);
Please set job->s_fence to NULL here or otherwise we could try to free it again in some code paths.
Apart from that looks good to me,
Christian.
Quoted 25 lines
drivers/gpu/drm/scheduler/sched_main.c +4
-0+} +EXPORT_SYMBOL (drm_sched_job_cleanup); + +/** * drm_sched_ready - is the scheduler ready * * @sched: scheduler instance drivers/gpu/drm/v3d/v3d_sched.c +2
-0@@ -35,6 +35,8 @@ {struct v3d_job *job =to_v3d_job (sched_job); +drm_sched_job_cleanup (sched_job); +v3d_exec_put (job->exec); }include/drm/gpu_scheduler.h +0
-0
include/drm/gpu_scheduler.h int drm_sched_init(struct drm_gpu_scheduler *sched, · line 299
Quoted 7 lines
include/drm/gpu_scheduler.h +1
-0@@ -293,6 +293,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,int drm_sched_job_init (struct drm_sched_job *job,struct drm_sched_entity *entity,void *owner); +void drm_sched_job_cleanup (struct drm_sched_job *job);void drm_sched_wakeup (struct drm_gpu_scheduler *sched);void drm_sched_hw_job_reset (struct drm_gpu_scheduler *sched,struct drm_sched_job *job);
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno