diff options
author | Christian König <christian.koenig@amd.com> | 2015-08-25 11:05:36 +0200 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-08-28 15:04:17 -0400 |
commit | e61235db62c5e68e56e59bea62b88f9f3d7a3cf5 (patch) | |
tree | 9f28992f9423cc754e1ea4f94eba149eca96effc /drivers/gpu/drm/amd/scheduler | |
parent | 69bd5bf13a8eccb4db5f26de608556416a56d973 (diff) | |
download | op-kernel-dev-e61235db62c5e68e56e59bea62b88f9f3d7a3cf5.zip op-kernel-dev-e61235db62c5e68e56e59bea62b88f9f3d7a3cf5.tar.gz |
drm/amdgpu: add scheduler dependency callback v2
This way the scheduler doesn't wait in it's work thread any more.
v2: fix race conditions
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/scheduler')
-rw-r--r-- | drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 22 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c index 205cb88..2f5d1f0 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c @@ -192,14 +192,36 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, kfifo_free(&entity->job_queue); } +static void amd_sched_entity_wakeup(struct fence *f, struct fence_cb *cb) +{ + struct amd_sched_entity *entity = + container_of(cb, struct amd_sched_entity, cb); + entity->dependency = NULL; + fence_put(f); + amd_sched_wakeup(entity->scheduler); +} + static struct amd_sched_job * amd_sched_entity_pop_job(struct amd_sched_entity *entity) { + struct amd_gpu_scheduler *sched = entity->scheduler; struct amd_sched_job *job; + if (ACCESS_ONCE(entity->dependency)) + return NULL; + if (!kfifo_out_peek(&entity->job_queue, &job, sizeof(job))) return NULL; + while ((entity->dependency = sched->ops->dependency(job))) { + + if (fence_add_callback(entity->dependency, &entity->cb, + amd_sched_entity_wakeup)) + fence_put(entity->dependency); + else + return NULL; + } + return job; } diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h index e797796..2af0e4d 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h @@ -45,6 +45,8 @@ struct amd_sched_entity { spinlock_t queue_lock; struct amd_gpu_scheduler *scheduler; uint64_t fence_context; + struct fence *dependency; + struct fence_cb cb; }; /** @@ -89,6 +91,7 @@ static inline struct amd_sched_fence *to_amd_sched_fence(struct fence *f) * these functions should be implemented in driver side */ struct amd_sched_backend_ops { + struct fence *(*dependency)(struct amd_sched_job *job); struct fence *(*run_job)(struct amd_sched_job *job); void (*process_job)(struct amd_sched_job *job); }; |