]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amdgpu: refine the scheduler job type conversion
authorJunwei Zhang <Jerry.Zhang@amd.com>
Wed, 9 Sep 2015 01:21:19 +0000 (09:21 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 23 Sep 2015 21:23:36 +0000 (17:23 -0400)
Use container_of rather than casting.

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: David Zhou <david1.zhou@amd.com>
Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c

index 58fe9fab8192985c138156410002d48a68b3d42a..dbe061bf88cc22fb5f4a8444220c8cd23992e36d 100644 (file)
@@ -1277,6 +1277,8 @@ struct amdgpu_job {
        struct amdgpu_user_fence uf;
        int (*free_job)(struct amdgpu_job *job);
 };
+#define to_amdgpu_job(sched_job)               \
+               container_of((sched_job), struct amdgpu_job, base)
 
 static inline u32 amdgpu_get_ib_value(struct amdgpu_cs_parser *p, uint32_t ib_idx, int idx)
 {
index 4c1698861c428bbf5e7c16be4f6f3375944951fc..546968a83b08ffba7db794579a438d0507aa61f5 100644 (file)
@@ -863,7 +863,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 
                job->free_job = amdgpu_cs_free_job;
                mutex_lock(&job->job_lock);
-               r = amd_sched_entity_push_job((struct amd_sched_job *)job);
+               r = amd_sched_entity_push_job(&job->base);
                if (r) {
                        mutex_unlock(&job->job_lock);
                        amdgpu_cs_free_job(job);
index af1a3dabd1903ecab0891d20ad26c5dab20e2e30..58408da122c5b6251b12db85b20688bfa2a8ec5c 100644 (file)
@@ -29,7 +29,7 @@
 
 static struct fence *amdgpu_sched_dependency(struct amd_sched_job *sched_job)
 {
-       struct amdgpu_job *job = (struct amdgpu_job *)sched_job;
+       struct amdgpu_job *job = to_amdgpu_job(sched_job);
        return amdgpu_sync_get_fence(&job->ibs->sync);
 }
 
@@ -43,7 +43,7 @@ static struct fence *amdgpu_sched_run_job(struct amd_sched_job *sched_job)
                DRM_ERROR("job is null\n");
                return NULL;
        }
-       job = (struct amdgpu_job *)sched_job;
+       job = to_amdgpu_job(sched_job);
        mutex_lock(&job->job_lock);
        r = amdgpu_ib_schedule(job->adev,
                               job->num_ibs,
@@ -94,7 +94,7 @@ int amdgpu_sched_ib_submit_kernel_helper(struct amdgpu_device *adev,
                mutex_init(&job->job_lock);
                job->free_job = free_job;
                mutex_lock(&job->job_lock);
-               r = amd_sched_entity_push_job((struct amd_sched_job *)job);
+               r = amd_sched_entity_push_job(&job->base);
                if (r) {
                        mutex_unlock(&job->job_lock);
                        kfree(job);