]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/scheduler: Add drm_sched_job_cleanup
authorSharat Masetty <smasetty@codeaurora.org>
Mon, 29 Oct 2018 09:32:28 +0000 (15:02 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 5 Nov 2018 19:21:27 +0000 (14:21 -0500)
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 <smasetty@codeaurora.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
drivers/gpu/drm/etnaviv/etnaviv_sched.c
drivers/gpu/drm/scheduler/sched_entity.c
drivers/gpu/drm/scheduler/sched_main.c
drivers/gpu/drm/v3d/v3d_sched.c
include/drm/gpu_scheduler.h

index 663043c8f0f5710244cb4bc787a8cd19fc076b50..5d768f95de24f5175b294386858ecad0d0d6c469 100644 (file)
@@ -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:
index 755f733bf0d9517591f945e931a116cb0ae2c4ac..e0af44fd6a0cf7b52c266400510a857b74ea5efa 100644 (file)
@@ -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);
index f8c5f1e6c5e29faa073b03a3b6d4663853e5d896..88b2768d91c9f10f44577bcd348e0589b526b551 100644 (file)
@@ -125,6 +125,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);
 }
 
@@ -157,6 +159,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;
        }
index ba54c30a466e05e2e31ea8bf938c24cb07b1a180..4463d3826ecbec0432ee363087c8e6d1f86755cc 100644 (file)
@@ -211,7 +211,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);
 }
 
index 6b2fd49334f7c3952b81376b4533970a0128597a..18ebbb05762e99c0706aeba369c8d3d0baeafda7 100644 (file)
@@ -233,7 +233,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);
 }
 
@@ -440,6 +439,18 @@ 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);
+       job->s_fence = NULL;
+}
+EXPORT_SYMBOL(drm_sched_job_cleanup);
+
 /**
  * drm_sched_ready - is the scheduler ready
  *
index 80b641ffc3be78a1dcd597b4ba32af64ce67adde..445b2ef0330346e49e744c035bec3a18940b7e85 100644 (file)
@@ -35,6 +35,8 @@ v3d_job_free(struct drm_sched_job *sched_job)
 {
        struct v3d_job *job = to_v3d_job(sched_job);
 
+       drm_sched_job_cleanup(sched_job);
+
        v3d_exec_put(job->exec);
 }
 
index 4ae192a21c3fe9a9e85871edff8ed185788e271d..926379d53484ace11b5e05be242a3c53a296574a 100644 (file)
@@ -296,6 +296,7 @@ void drm_sched_fini(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);