diff options
| author | Christian König <christian.koenig@amd.com> | 2016-02-03 13:44:52 +0100 | 
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2016-02-10 14:17:18 -0500 | 
| commit | 50838c8cc413de8da39c4c216ae05410845d5a44 (patch) | |
| tree | 1a7f94a784593e9da9a02d801f28d46ac4dbafa7 /drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | |
| parent | 4acabfe3793eb9bf89f71cc0cef23dfb2a812916 (diff) | |
drm/amdgpu: add proper job alloc/free functions
And use them in the CS instead of allocating IBs and jobs separately.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 33 | 
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c index 76a1f823d983..10d098e33707 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c @@ -28,6 +28,39 @@  #include "amdgpu.h"  #include "amdgpu_trace.h" +int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, +		     struct amdgpu_job **job) +{ +	size_t size = sizeof(struct amdgpu_job); + +	if (num_ibs == 0) +		return -EINVAL; + +	size += sizeof(struct amdgpu_ib) * num_ibs; + +	*job = kzalloc(size, GFP_KERNEL); +	if (!*job) +		return -ENOMEM; + +	(*job)->adev = adev; +	(*job)->ibs = (void *)&(*job)[1]; +	(*job)->num_ibs = num_ibs; +	(*job)->free_job = NULL; + +	return 0; +} + +void amdgpu_job_free(struct amdgpu_job *job) +{ +	unsigned i; + +	for (i = 0; i < job->num_ibs; ++i) +		amdgpu_ib_free(job->adev, &job->ibs[i]); + +	amdgpu_bo_unref(&job->uf.bo); +	/* TODO: Free the job structure here as well */ +} +  static struct fence *amdgpu_sched_dependency(struct amd_sched_job *sched_job)  {  	struct amdgpu_job *job = to_amdgpu_job(sched_job);  | 
