drm/amdgpu: change ring priority after pushing the job (v2)
authorChristian König <christian.koenig@amd.com>
Mon, 16 Jul 2018 12:58:48 +0000 (14:58 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 18 Jul 2018 21:18:44 +0000 (16:18 -0500)
Pushing a job can change the ring assignment of an entity.

v2: squash in:
"drm/amdgpu: fix job priority handling" (Christian)

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

index 72dc9b36b937f9a9f29d40b891a1a9643ecce177..7c5cc33d0cda06d8cc93127a7374c1132ae3152c 100644 (file)
@@ -1209,6 +1209,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 {
        struct amdgpu_ring *ring = p->ring;
        struct drm_sched_entity *entity = &p->ctx->rings[ring->idx].entity;
+       enum drm_sched_priority priority;
        struct amdgpu_job *job;
        unsigned i;
        uint64_t seq;
@@ -1256,11 +1257,14 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
        job->uf_sequence = seq;
 
        amdgpu_job_free_resources(job);
-       amdgpu_ring_priority_get(p->ring, job->base.s_priority);
 
        trace_amdgpu_cs_ioctl(job);
+       priority = job->base.s_priority;
        drm_sched_entity_push_job(&job->base, entity);
 
+       ring = to_amdgpu_ring(entity->sched);
+       amdgpu_ring_priority_get(ring, priority);
+
        ttm_eu_fence_buffer_objects(&p->ticket, &p->validated, p->fence);
        amdgpu_mn_unlock(p->mn);
 
index 42a4764d728e8a2a0b5ec357039b6ad1fecbe6e6..5a2c26a85984560a75d5ac01f2768b0a0984884e 100644 (file)
@@ -126,7 +126,8 @@ void amdgpu_job_free(struct amdgpu_job *job)
 int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,
                      void *owner, struct dma_fence **f)
 {
-       struct amdgpu_ring *ring = to_amdgpu_ring(entity->sched);
+       enum drm_sched_priority priority;
+       struct amdgpu_ring *ring;
        int r;
 
        if (!f)
@@ -139,9 +140,12 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,
        job->owner = owner;
        *f = dma_fence_get(&job->base.s_fence->finished);
        amdgpu_job_free_resources(job);
-       amdgpu_ring_priority_get(ring, job->base.s_priority);
+       priority = job->base.s_priority;
        drm_sched_entity_push_job(&job->base, entity);
 
+       ring = to_amdgpu_ring(entity->sched);
+       amdgpu_ring_priority_get(ring, priority);
+
        return 0;
 }