Commit a6db8a33 authored by Junwei Zhang's avatar Junwei Zhang Committed by Alex Deucher

drm/amdgpu: refine the scheduler job type conversion

Use container_of rather than casting.
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDavid Zhou <david1.zhou@amd.com>
Signed-off-by: default avatarJunwei Zhang <Jerry.Zhang@amd.com>
parent 4c7eb91c
...@@ -1277,6 +1277,8 @@ struct amdgpu_job { ...@@ -1277,6 +1277,8 @@ struct amdgpu_job {
struct amdgpu_user_fence uf; struct amdgpu_user_fence uf;
int (*free_job)(struct amdgpu_job *job); 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) static inline u32 amdgpu_get_ib_value(struct amdgpu_cs_parser *p, uint32_t ib_idx, int idx)
{ {
......
...@@ -863,7 +863,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -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; job->free_job = amdgpu_cs_free_job;
mutex_lock(&job->job_lock); 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) { if (r) {
mutex_unlock(&job->job_lock); mutex_unlock(&job->job_lock);
amdgpu_cs_free_job(job); amdgpu_cs_free_job(job);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
static struct fence *amdgpu_sched_dependency(struct amd_sched_job *sched_job) 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); 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) ...@@ -43,7 +43,7 @@ static struct fence *amdgpu_sched_run_job(struct amd_sched_job *sched_job)
DRM_ERROR("job is null\n"); DRM_ERROR("job is null\n");
return NULL; return NULL;
} }
job = (struct amdgpu_job *)sched_job; job = to_amdgpu_job(sched_job);
mutex_lock(&job->job_lock); mutex_lock(&job->job_lock);
r = amdgpu_ib_schedule(job->adev, r = amdgpu_ib_schedule(job->adev,
job->num_ibs, job->num_ibs,
...@@ -94,7 +94,7 @@ int amdgpu_sched_ib_submit_kernel_helper(struct amdgpu_device *adev, ...@@ -94,7 +94,7 @@ int amdgpu_sched_ib_submit_kernel_helper(struct amdgpu_device *adev,
mutex_init(&job->job_lock); mutex_init(&job->job_lock);
job->free_job = free_job; job->free_job = free_job;
mutex_lock(&job->job_lock); 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) { if (r) {
mutex_unlock(&job->job_lock); mutex_unlock(&job->job_lock);
kfree(job); kfree(job);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment