mirror of
https://github.com/torvalds/linux.git
synced 2026-04-30 20:42:33 -04:00
drm/amdgpu: abstract amdgpu_job for scheduler
Signed-off-by: Chunming Zhou <david1.zhou@amd.com> Reviewed-by: Christian K?nig <christian.koenig@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
6055f37afd
commit
bb977d3711
@@ -282,30 +282,18 @@ int amd_sched_entity_fini(struct amd_gpu_scheduler *sched,
|
||||
* scheduler consum some queued command.
|
||||
* -1 other fail.
|
||||
*/
|
||||
int amd_sched_push_job(struct amd_gpu_scheduler *sched,
|
||||
struct amd_sched_entity *c_entity,
|
||||
void *data,
|
||||
struct amd_sched_fence **fence)
|
||||
int amd_sched_push_job(struct amd_sched_job *sched_job)
|
||||
{
|
||||
struct amd_sched_job *job;
|
||||
|
||||
struct amd_sched_fence *fence =
|
||||
amd_sched_fence_create(sched_job->s_entity);
|
||||
if (!fence)
|
||||
return -EINVAL;
|
||||
job = kzalloc(sizeof(struct amd_sched_job), GFP_KERNEL);
|
||||
if (!job)
|
||||
return -ENOMEM;
|
||||
job->sched = sched;
|
||||
job->s_entity = c_entity;
|
||||
job->data = data;
|
||||
*fence = amd_sched_fence_create(c_entity);
|
||||
if ((*fence) == NULL) {
|
||||
kfree(job);
|
||||
return -EINVAL;
|
||||
}
|
||||
fence_get(&(*fence)->base);
|
||||
job->s_fence = *fence;
|
||||
while (kfifo_in_spinlocked(&c_entity->job_queue, &job, sizeof(void *),
|
||||
&c_entity->queue_lock) != sizeof(void *)) {
|
||||
fence_get(&fence->base);
|
||||
sched_job->s_fence = fence;
|
||||
while (kfifo_in_spinlocked(&sched_job->s_entity->job_queue,
|
||||
&sched_job, sizeof(void *),
|
||||
&sched_job->s_entity->queue_lock) !=
|
||||
sizeof(void *)) {
|
||||
/**
|
||||
* Current context used up all its IB slots
|
||||
* wait here, or need to check whether GPU is hung
|
||||
@@ -313,8 +301,8 @@ int amd_sched_push_job(struct amd_gpu_scheduler *sched,
|
||||
schedule();
|
||||
}
|
||||
/* first job wake up scheduler */
|
||||
if ((kfifo_len(&c_entity->job_queue) / sizeof(void *)) == 1)
|
||||
wake_up_interruptible(&sched->wait_queue);
|
||||
if ((kfifo_len(&sched_job->s_entity->job_queue) / sizeof(void *)) == 1)
|
||||
wake_up_interruptible(&sched_job->sched->wait_queue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -333,10 +321,8 @@ static void amd_sched_process_job(struct fence *f, struct fence_cb *cb)
|
||||
list_del(&sched_job->list);
|
||||
atomic64_dec(&sched->hw_rq_count);
|
||||
spin_unlock_irqrestore(&sched->queue_lock, flags);
|
||||
|
||||
sched->ops->process_job(sched, sched_job);
|
||||
fence_put(&sched_job->s_fence->base);
|
||||
kfree(sched_job);
|
||||
sched->ops->process_job(sched, sched_job);
|
||||
wake_up_interruptible(&sched->wait_queue);
|
||||
}
|
||||
|
||||
@@ -359,7 +345,9 @@ static int amd_sched_main(void *param)
|
||||
r = kfifo_out(&c_entity->job_queue, &job, sizeof(void *));
|
||||
if (r != sizeof(void *))
|
||||
continue;
|
||||
r = sched->ops->prepare_job(sched, c_entity, job);
|
||||
r = 0;
|
||||
if (sched->ops->prepare_job)
|
||||
r = sched->ops->prepare_job(sched, c_entity, job);
|
||||
if (!r) {
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&sched->queue_lock, flags);
|
||||
|
||||
Reference in New Issue
Block a user