drm/scheduler: fix setting the priorty for entities (v2)
authorChristian König <christian.koenig@amd.com>
Wed, 1 Aug 2018 14:22:39 +0000 (16:22 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 27 Aug 2018 16:10:00 +0000 (11:10 -0500)
Since we now deal with multiple rq we need to update all of them, not
just the current one.

v2: Trivial: Removed unused variable (Alex)

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
drivers/gpu/drm/scheduler/gpu_scheduler.c
include/drm/gpu_scheduler.h

index df69657610460a81104a343fff489a3c1695856e..02d563cfb4a7344c4e787248ef3858d3bccc4242 100644 (file)
@@ -394,7 +394,6 @@ void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx,
 {
        int i;
        struct amdgpu_device *adev = ctx->adev;
-       struct drm_sched_rq *rq;
        struct drm_sched_entity *entity;
        struct amdgpu_ring *ring;
        enum drm_sched_priority ctx_prio;
@@ -407,12 +406,11 @@ void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx,
        for (i = 0; i < adev->num_rings; i++) {
                ring = adev->rings[i];
                entity = &ctx->rings[i].entity;
-               rq = &ring->sched.sched_rq[ctx_prio];
 
                if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ)
                        continue;
 
-               drm_sched_entity_set_rq(entity, rq);
+               drm_sched_entity_set_priority(entity, ctx_prio);
        }
 }
 
index 08fa5b65acaf4239fbe49b181698e59b9f915a3f..695a9643f046aa633ab728796122a8b7a32047db 100644 (file)
@@ -416,29 +416,39 @@ static void drm_sched_entity_clear_dep(struct dma_fence *f, struct dma_fence_cb
 }
 
 /**
- * drm_sched_entity_set_rq - Sets the run queue for an entity
+ * drm_sched_entity_set_rq_priority - helper for drm_sched_entity_set_priority
+ */
+static void drm_sched_entity_set_rq_priority(struct drm_sched_rq **rq,
+                                            enum drm_sched_priority priority)
+{
+       *rq = &(*rq)->sched->sched_rq[priority];
+}
+
+/**
+ * drm_sched_entity_set_priority - Sets priority of the entity
  *
  * @entity: scheduler entity
- * @rq: scheduler run queue
+ * @priority: scheduler priority
  *
- * Sets the run queue for an entity and removes the entity from the previous
- * run queue in which was present.
+ * Update the priority of runqueus used for the entity.
  */
-void drm_sched_entity_set_rq(struct drm_sched_entity *entity,
-                            struct drm_sched_rq *rq)
+void drm_sched_entity_set_priority(struct drm_sched_entity *entity,
+                                  enum drm_sched_priority priority)
 {
-       if (entity->rq == rq)
-               return;
-
-       BUG_ON(!rq);
+       unsigned int i;
 
        spin_lock(&entity->rq_lock);
+
+       for (i = 0; i < entity->num_rq_list; ++i)
+               drm_sched_entity_set_rq_priority(&entity->rq_list[i], priority);
+
        drm_sched_rq_remove_entity(entity->rq, entity);
-       entity->rq = rq;
-       drm_sched_rq_add_entity(rq, entity);
+       drm_sched_entity_set_rq_priority(&entity->rq, priority);
+       drm_sched_rq_add_entity(entity->rq, entity);
+
        spin_unlock(&entity->rq_lock);
 }
-EXPORT_SYMBOL(drm_sched_entity_set_rq);
+EXPORT_SYMBOL(drm_sched_entity_set_priority);
 
 /**
  * drm_sched_dependency_optimized
index 0c4cfe689d4c26db3803bfbc4e06b42b4d1eedd8..22c0f88f7d8f750535a11b3f9a90ef9af301f512 100644 (file)
@@ -298,9 +298,8 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity);
 void drm_sched_entity_destroy(struct drm_sched_entity *entity);
 void drm_sched_entity_push_job(struct drm_sched_job *sched_job,
                               struct drm_sched_entity *entity);
-void drm_sched_entity_set_rq(struct drm_sched_entity *entity,
-                            struct drm_sched_rq *rq);
-
+void drm_sched_entity_set_priority(struct drm_sched_entity *entity,
+                                  enum drm_sched_priority priority);
 struct drm_sched_fence *drm_sched_fence_create(
        struct drm_sched_entity *s_entity, void *owner);
 void drm_sched_fence_scheduled(struct drm_sched_fence *fence);