[PATCH 3/3] drm/amdgpu: add sched sync for amdgpu job

zhoucm1 david1.zhou at amd.com
Wed May 10 01:58:33 UTC 2017



On 2017年05月09日 19:16, Christian König wrote:
> What's the background of this change? E.g. why it is needed?
price question, maybe I should describe more in patch comment, I think 
this is an improvement for previous patch, the sched_sync is to store 
fence that could be skipped as scheduled, when job is executed, we 
didn't need pipeline_sync if all fences in sched_sync are signalled, 
otherwise insert pipeline_sync still.

Regards,
David Zhou
>
> Christian.
>
> Am 09.05.2017 um 10:14 schrieb Chunming Zhou:
>> Change-Id: I26d3a2794272ba94b25753d4bf367326d12f6939
>> Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 6 +++++-
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++-
>>   3 files changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index 787acd7..ef018bf 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -1162,6 +1162,7 @@ struct amdgpu_job {
>>       struct amdgpu_vm    *vm;
>>       struct amdgpu_ring    *ring;
>>       struct amdgpu_sync    sync;
>> +    struct amdgpu_sync    sched_sync;
>>       struct amdgpu_ib    *ibs;
>>       struct fence        *fence; /* the hw fence */
>>       uint32_t        preamble_status;
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
>> index 2c6624d..d7f75bc 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
>> @@ -167,8 +167,12 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, 
>> unsigned num_ibs,
>>           return r;
>>       }
>>   -    if (ring->funcs->emit_pipeline_sync && job && 
>> job->need_pipeline_sync)
>> +    if (ring->funcs->emit_pipeline_sync && job &&
>> +        (tmp = amdgpu_sync_get_fence(&job->sched_sync))) {
>> +        job->need_pipeline_sync = true;
>>           amdgpu_ring_emit_pipeline_sync(ring);
>> +        fence_put(tmp);
>> +    }
>>       if (vm) {
>>           amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go 
>> too fast than DE */
>>   diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
>> index cfa97ab..fa0c8b1 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
>> @@ -60,6 +60,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, 
>> unsigned num_ibs,
>>       (*job)->need_pipeline_sync = false;
>>         amdgpu_sync_create(&(*job)->sync);
>> +    amdgpu_sync_create(&(*job)->sched_sync);
>>         return 0;
>>   }
>> @@ -98,6 +99,7 @@ static void amdgpu_job_free_cb(struct amd_sched_job 
>> *s_job)
>>         fence_put(job->fence);
>>       amdgpu_sync_free(&job->sync);
>> +    amdgpu_sync_free(&job->sched_sync);
>>       kfree(job);
>>   }
>>   @@ -107,6 +109,7 @@ void amdgpu_job_free(struct amdgpu_job *job)
>>         fence_put(job->fence);
>>       amdgpu_sync_free(&job->sync);
>> +    amdgpu_sync_free(&job->sched_sync);
>>       kfree(job);
>>   }
>>   @@ -154,7 +157,7 @@ static struct fence 
>> *amdgpu_job_dependency(struct amd_sched_job *sched_job)
>>       }
>>         if (amd_sched_dependency_optimized(fence, sched_job->s_entity))
>> -        job->need_pipeline_sync = true;
>> +        amdgpu_sync_fence(job->adev, &job->sched_sync, fence);
>>         return fence;
>>   }
>
>



More information about the amd-gfx mailing list