diff options
| author | Christian König <christian.koenig@amd.com> | 2015-09-08 14:22:31 -0400 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2015-09-23 17:23:39 -0400 |
| commit | 4f839a243d3b0d8b1a14f4778a87ec4d8ddbf15f (patch) | |
| tree | 856d9a22af55ae4e8347c14c3d60cd235e79da72 /drivers/gpu/drm/amd/scheduler | |
| parent | 5ec92a7692872d656cffe010920fb49c4f51d75f (diff) | |
drm/amdgpu: more scheduler cleanups v2
Embed the scheduler into the ring structure instead of allocating it.
Use the ring name directly instead of the id.
v2: rebased, whitespace cleanup
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Chunming Zhou<david1.zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/scheduler')
| -rw-r--r-- | drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h | 8 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 37 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 20 |
3 files changed, 26 insertions, 39 deletions
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h b/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h index a1f4ece58a24..144f50acc971 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h +++ b/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h | |||
| @@ -16,21 +16,21 @@ TRACE_EVENT(amd_sched_job, | |||
| 16 | TP_ARGS(sched_job), | 16 | TP_ARGS(sched_job), |
| 17 | TP_STRUCT__entry( | 17 | TP_STRUCT__entry( |
| 18 | __field(struct amd_sched_entity *, entity) | 18 | __field(struct amd_sched_entity *, entity) |
| 19 | __field(u32, ring_id) | 19 | __field(const char *, name) |
| 20 | __field(u32, job_count) | 20 | __field(u32, job_count) |
| 21 | __field(int, hw_job_count) | 21 | __field(int, hw_job_count) |
| 22 | ), | 22 | ), |
| 23 | 23 | ||
| 24 | TP_fast_assign( | 24 | TP_fast_assign( |
| 25 | __entry->entity = sched_job->s_entity; | 25 | __entry->entity = sched_job->s_entity; |
| 26 | __entry->ring_id = sched_job->sched->ring_id; | 26 | __entry->name = sched_job->sched->name; |
| 27 | __entry->job_count = kfifo_len( | 27 | __entry->job_count = kfifo_len( |
| 28 | &sched_job->s_entity->job_queue) / sizeof(sched_job); | 28 | &sched_job->s_entity->job_queue) / sizeof(sched_job); |
| 29 | __entry->hw_job_count = atomic_read( | 29 | __entry->hw_job_count = atomic_read( |
| 30 | &sched_job->sched->hw_rq_count); | 30 | &sched_job->sched->hw_rq_count); |
| 31 | ), | 31 | ), |
| 32 | TP_printk("entity=%p, ring=%u, job count:%u, hw job count:%d", | 32 | TP_printk("entity=%p, ring=%s, job count:%u, hw job count:%d", |
| 33 | __entry->entity, __entry->ring_id, __entry->job_count, | 33 | __entry->entity, __entry->name, __entry->job_count, |
| 34 | __entry->hw_job_count) | 34 | __entry->hw_job_count) |
| 35 | ); | 35 | ); |
| 36 | #endif | 36 | #endif |
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c index ec4842e58fd7..3697eeeecf82 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | |||
| @@ -381,56 +381,45 @@ static int amd_sched_main(void *param) | |||
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | /** | 383 | /** |
| 384 | * Create a gpu scheduler | 384 | * Init a gpu scheduler instance |
| 385 | * | 385 | * |
| 386 | * @sched The pointer to the scheduler | ||
| 386 | * @ops The backend operations for this scheduler. | 387 | * @ops The backend operations for this scheduler. |
| 387 | * @ring The the ring id for the scheduler. | ||
| 388 | * @hw_submissions Number of hw submissions to do. | 388 | * @hw_submissions Number of hw submissions to do. |
| 389 | * @name Name used for debugging | ||
| 389 | * | 390 | * |
| 390 | * Return the pointer to scheduler for success, otherwise return NULL | 391 | * Return 0 on success, otherwise error code. |
| 391 | */ | 392 | */ |
| 392 | struct amd_gpu_scheduler *amd_sched_create(struct amd_sched_backend_ops *ops, | 393 | int amd_sched_init(struct amd_gpu_scheduler *sched, |
| 393 | unsigned ring, unsigned hw_submission, | 394 | struct amd_sched_backend_ops *ops, |
| 394 | void *priv) | 395 | unsigned hw_submission, const char *name) |
| 395 | { | 396 | { |
| 396 | struct amd_gpu_scheduler *sched; | ||
| 397 | |||
| 398 | sched = kzalloc(sizeof(struct amd_gpu_scheduler), GFP_KERNEL); | ||
| 399 | if (!sched) | ||
| 400 | return NULL; | ||
| 401 | |||
| 402 | sched->ops = ops; | 397 | sched->ops = ops; |
| 403 | sched->ring_id = ring; | ||
| 404 | sched->hw_submission_limit = hw_submission; | 398 | sched->hw_submission_limit = hw_submission; |
| 405 | sched->priv = priv; | 399 | sched->name = name; |
| 406 | snprintf(sched->name, sizeof(sched->name), "amdgpu[%d]", ring); | ||
| 407 | amd_sched_rq_init(&sched->sched_rq); | 400 | amd_sched_rq_init(&sched->sched_rq); |
| 408 | amd_sched_rq_init(&sched->kernel_rq); | 401 | amd_sched_rq_init(&sched->kernel_rq); |
| 409 | 402 | ||
| 410 | init_waitqueue_head(&sched->wake_up_worker); | 403 | init_waitqueue_head(&sched->wake_up_worker); |
| 411 | init_waitqueue_head(&sched->job_scheduled); | 404 | init_waitqueue_head(&sched->job_scheduled); |
| 412 | atomic_set(&sched->hw_rq_count, 0); | 405 | atomic_set(&sched->hw_rq_count, 0); |
| 406 | |||
| 413 | /* Each scheduler will run on a seperate kernel thread */ | 407 | /* Each scheduler will run on a seperate kernel thread */ |
| 414 | sched->thread = kthread_run(amd_sched_main, sched, sched->name); | 408 | sched->thread = kthread_run(amd_sched_main, sched, sched->name); |
| 415 | if (IS_ERR(sched->thread)) { | 409 | if (IS_ERR(sched->thread)) { |
| 416 | DRM_ERROR("Failed to create scheduler for id %d.\n", ring); | 410 | DRM_ERROR("Failed to create scheduler for %s.\n", name); |
| 417 | kfree(sched); | 411 | return PTR_ERR(sched->thread); |
| 418 | return NULL; | ||
| 419 | } | 412 | } |
| 420 | 413 | ||
| 421 | return sched; | 414 | return 0; |
| 422 | } | 415 | } |
| 423 | 416 | ||
| 424 | /** | 417 | /** |
| 425 | * Destroy a gpu scheduler | 418 | * Destroy a gpu scheduler |
| 426 | * | 419 | * |
| 427 | * @sched The pointer to the scheduler | 420 | * @sched The pointer to the scheduler |
| 428 | * | ||
| 429 | * return 0 if succeed. -1 if failed. | ||
| 430 | */ | 421 | */ |
| 431 | int amd_sched_destroy(struct amd_gpu_scheduler *sched) | 422 | void amd_sched_fini(struct amd_gpu_scheduler *sched) |
| 432 | { | 423 | { |
| 433 | kthread_stop(sched->thread); | 424 | kthread_stop(sched->thread); |
| 434 | kfree(sched); | ||
| 435 | return 0; | ||
| 436 | } | 425 | } |
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h index 89d977dd30ac..80b64dc22214 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | |||
| @@ -101,23 +101,21 @@ struct amd_sched_backend_ops { | |||
| 101 | * One scheduler is implemented for each hardware ring | 101 | * One scheduler is implemented for each hardware ring |
| 102 | */ | 102 | */ |
| 103 | struct amd_gpu_scheduler { | 103 | struct amd_gpu_scheduler { |
| 104 | struct task_struct *thread; | 104 | struct amd_sched_backend_ops *ops; |
| 105 | uint32_t hw_submission_limit; | ||
| 106 | const char *name; | ||
| 105 | struct amd_sched_rq sched_rq; | 107 | struct amd_sched_rq sched_rq; |
| 106 | struct amd_sched_rq kernel_rq; | 108 | struct amd_sched_rq kernel_rq; |
| 107 | atomic_t hw_rq_count; | ||
| 108 | struct amd_sched_backend_ops *ops; | ||
| 109 | uint32_t ring_id; | ||
| 110 | wait_queue_head_t wake_up_worker; | 109 | wait_queue_head_t wake_up_worker; |
| 111 | wait_queue_head_t job_scheduled; | 110 | wait_queue_head_t job_scheduled; |
| 112 | uint32_t hw_submission_limit; | 111 | atomic_t hw_rq_count; |
| 113 | char name[20]; | 112 | struct task_struct *thread; |
| 114 | void *priv; | ||
| 115 | }; | 113 | }; |
| 116 | 114 | ||
| 117 | struct amd_gpu_scheduler * | 115 | int amd_sched_init(struct amd_gpu_scheduler *sched, |
| 118 | amd_sched_create(struct amd_sched_backend_ops *ops, | 116 | struct amd_sched_backend_ops *ops, |
| 119 | uint32_t ring, uint32_t hw_submission, void *priv); | 117 | uint32_t hw_submission, const char *name); |
| 120 | int amd_sched_destroy(struct amd_gpu_scheduler *sched); | 118 | void amd_sched_fini(struct amd_gpu_scheduler *sched); |
| 121 | 119 | ||
| 122 | int amd_sched_entity_init(struct amd_gpu_scheduler *sched, | 120 | int amd_sched_entity_init(struct amd_gpu_scheduler *sched, |
| 123 | struct amd_sched_entity *entity, | 121 | struct amd_sched_entity *entity, |
