drm/amdgpu: properly abstract scheduler timeout handling
The driver shouldn't mess with the scheduler internals. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Monk.Liu <monk.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
1e24e31f22
commit
0e51a772e2
@ -759,7 +759,6 @@ void amdgpu_job_free_func(struct kref *refcount);
|
|||||||
int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring,
|
int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring,
|
||||||
struct amd_sched_entity *entity, void *owner,
|
struct amd_sched_entity *entity, void *owner,
|
||||||
struct fence **f);
|
struct fence **f);
|
||||||
void amdgpu_job_timeout_func(struct work_struct *work);
|
|
||||||
|
|
||||||
struct amdgpu_ring {
|
struct amdgpu_ring {
|
||||||
struct amdgpu_device *adev;
|
struct amdgpu_device *adev;
|
||||||
|
@ -838,8 +838,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
|
|||||||
p->job = NULL;
|
p->job = NULL;
|
||||||
|
|
||||||
r = amd_sched_job_init(&job->base, &ring->sched,
|
r = amd_sched_job_init(&job->base, &ring->sched,
|
||||||
entity, amdgpu_job_timeout_func,
|
entity, amdgpu_job_free_func,
|
||||||
amdgpu_job_free_func,
|
|
||||||
p->filp, &fence);
|
p->filp, &fence);
|
||||||
if (r) {
|
if (r) {
|
||||||
amdgpu_job_free(job);
|
amdgpu_job_free(job);
|
||||||
|
@ -34,12 +34,13 @@ static void amdgpu_job_free_handler(struct work_struct *ws)
|
|||||||
amd_sched_job_put(&job->base);
|
amd_sched_job_put(&job->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void amdgpu_job_timeout_func(struct work_struct *work)
|
static void amdgpu_job_timedout(struct amd_sched_job *s_job)
|
||||||
{
|
{
|
||||||
struct amdgpu_job *job = container_of(work, struct amdgpu_job, base.work_tdr.work);
|
struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base);
|
||||||
|
|
||||||
DRM_ERROR("ring %s timeout, last signaled seq=%u, last emitted seq=%u\n",
|
DRM_ERROR("ring %s timeout, last signaled seq=%u, last emitted seq=%u\n",
|
||||||
job->base.sched->name,
|
job->base.sched->name,
|
||||||
(uint32_t)atomic_read(&job->ring->fence_drv.last_seq),
|
atomic_read(&job->ring->fence_drv.last_seq),
|
||||||
job->ring->fence_drv.sync_seq);
|
job->ring->fence_drv.sync_seq);
|
||||||
|
|
||||||
amd_sched_job_put(&job->base);
|
amd_sched_job_put(&job->base);
|
||||||
@ -126,8 +127,7 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
r = amd_sched_job_init(&job->base, &ring->sched,
|
r = amd_sched_job_init(&job->base, &ring->sched,
|
||||||
entity, amdgpu_job_timeout_func,
|
entity, amdgpu_job_free_func, owner, &fence);
|
||||||
amdgpu_job_free_func, owner, &fence);
|
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -197,4 +197,5 @@ err:
|
|||||||
const struct amd_sched_backend_ops amdgpu_sched_ops = {
|
const struct amd_sched_backend_ops amdgpu_sched_ops = {
|
||||||
.dependency = amdgpu_job_dependency,
|
.dependency = amdgpu_job_dependency,
|
||||||
.run_job = amdgpu_job_run,
|
.run_job = amdgpu_job_run,
|
||||||
|
.timedout_job = amdgpu_job_timedout,
|
||||||
};
|
};
|
||||||
|
@ -362,6 +362,14 @@ static void amd_sched_job_begin(struct amd_sched_job *s_job)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void amd_sched_job_timedout(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct amd_sched_job *job = container_of(work, struct amd_sched_job,
|
||||||
|
work_tdr.work);
|
||||||
|
|
||||||
|
job->sched->ops->timedout_job(job);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit a job to the job queue
|
* Submit a job to the job queue
|
||||||
*
|
*
|
||||||
@ -384,7 +392,6 @@ void amd_sched_entity_push_job(struct amd_sched_job *sched_job)
|
|||||||
int amd_sched_job_init(struct amd_sched_job *job,
|
int amd_sched_job_init(struct amd_sched_job *job,
|
||||||
struct amd_gpu_scheduler *sched,
|
struct amd_gpu_scheduler *sched,
|
||||||
struct amd_sched_entity *entity,
|
struct amd_sched_entity *entity,
|
||||||
void (*timeout_cb)(struct work_struct *work),
|
|
||||||
void (*free_cb)(struct kref *refcount),
|
void (*free_cb)(struct kref *refcount),
|
||||||
void *owner, struct fence **fence)
|
void *owner, struct fence **fence)
|
||||||
{
|
{
|
||||||
@ -397,7 +404,7 @@ int amd_sched_job_init(struct amd_sched_job *job,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
job->s_fence->s_job = job;
|
job->s_fence->s_job = job;
|
||||||
INIT_DELAYED_WORK(&job->work_tdr, timeout_cb);
|
INIT_DELAYED_WORK(&job->work_tdr, amd_sched_job_timedout);
|
||||||
job->free_callback = free_cb;
|
job->free_callback = free_cb;
|
||||||
|
|
||||||
if (fence)
|
if (fence)
|
||||||
|
@ -108,6 +108,7 @@ static inline struct amd_sched_fence *to_amd_sched_fence(struct fence *f)
|
|||||||
struct amd_sched_backend_ops {
|
struct amd_sched_backend_ops {
|
||||||
struct fence *(*dependency)(struct amd_sched_job *sched_job);
|
struct fence *(*dependency)(struct amd_sched_job *sched_job);
|
||||||
struct fence *(*run_job)(struct amd_sched_job *sched_job);
|
struct fence *(*run_job)(struct amd_sched_job *sched_job);
|
||||||
|
void (*timedout_job)(struct amd_sched_job *sched_job);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum amd_sched_priority {
|
enum amd_sched_priority {
|
||||||
@ -153,7 +154,6 @@ void amd_sched_fence_signal(struct amd_sched_fence *fence);
|
|||||||
int amd_sched_job_init(struct amd_sched_job *job,
|
int amd_sched_job_init(struct amd_sched_job *job,
|
||||||
struct amd_gpu_scheduler *sched,
|
struct amd_gpu_scheduler *sched,
|
||||||
struct amd_sched_entity *entity,
|
struct amd_sched_entity *entity,
|
||||||
void (*timeout_cb)(struct work_struct *work),
|
|
||||||
void (*free_cb)(struct kref* refcount),
|
void (*free_cb)(struct kref* refcount),
|
||||||
void *owner, struct fence **fence);
|
void *owner, struct fence **fence);
|
||||||
static inline void amd_sched_job_get(struct amd_sched_job *job)
|
static inline void amd_sched_job_get(struct amd_sched_job *job)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user