diff options
author | Christian König <christian.koenig@amd.com> | 2016-02-03 07:44:52 -0500 |
---|---|---|
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 @@ | |||
28 | #include "amdgpu.h" | 28 | #include "amdgpu.h" |
29 | #include "amdgpu_trace.h" | 29 | #include "amdgpu_trace.h" |
30 | 30 | ||
31 | int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, | ||
32 | struct amdgpu_job **job) | ||
33 | { | ||
34 | size_t size = sizeof(struct amdgpu_job); | ||
35 | |||
36 | if (num_ibs == 0) | ||
37 | return -EINVAL; | ||
38 | |||
39 | size += sizeof(struct amdgpu_ib) * num_ibs; | ||
40 | |||
41 | *job = kzalloc(size, GFP_KERNEL); | ||
42 | if (!*job) | ||
43 | return -ENOMEM; | ||
44 | |||
45 | (*job)->adev = adev; | ||
46 | (*job)->ibs = (void *)&(*job)[1]; | ||
47 | (*job)->num_ibs = num_ibs; | ||
48 | (*job)->free_job = NULL; | ||
49 | |||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | void amdgpu_job_free(struct amdgpu_job *job) | ||
54 | { | ||
55 | unsigned i; | ||
56 | |||
57 | for (i = 0; i < job->num_ibs; ++i) | ||
58 | amdgpu_ib_free(job->adev, &job->ibs[i]); | ||
59 | |||
60 | amdgpu_bo_unref(&job->uf.bo); | ||
61 | /* TODO: Free the job structure here as well */ | ||
62 | } | ||
63 | |||
31 | static struct fence *amdgpu_sched_dependency(struct amd_sched_job *sched_job) | 64 | static struct fence *amdgpu_sched_dependency(struct amd_sched_job *sched_job) |
32 | { | 65 | { |
33 | struct amdgpu_job *job = to_amdgpu_job(sched_job); | 66 | struct amdgpu_job *job = to_amdgpu_job(sched_job); |