aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChunming Zhou <David1.Zhou@amd.com>2015-11-05 02:23:09 -0500
committerAlex Deucher <alexander.deucher@amd.com>2015-12-02 15:54:33 -0500
commitd033a6de80054139b4358db12cf6bb8d6cf58853 (patch)
tree10a1d10028b74702abea494cb5e029747696dbd5 /drivers/gpu
parentccba7691a580a0967f60a512473ce699b9edac0d (diff)
drm/amd: abstract kernel rq and normal rq to priority of run queue
Allows us to set priorities in the scheduler. Signed-off-by: Chunming Zhou <David1.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c11
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c2
-rw-r--r--drivers/gpu/drm/amd/scheduler/gpu_scheduler.c14
-rw-r--r--drivers/gpu/drm/amd/scheduler/gpu_scheduler.h9
5 files changed, 23 insertions, 15 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 1799973e7744..5f975030bb72 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1044,7 +1044,7 @@ struct amdgpu_ctx_mgr {
1044 struct idr ctx_handles; 1044 struct idr ctx_handles;
1045}; 1045};
1046 1046
1047int amdgpu_ctx_init(struct amdgpu_device *adev, bool kernel, 1047int amdgpu_ctx_init(struct amdgpu_device *adev, enum amd_sched_priority pri,
1048 struct amdgpu_ctx *ctx); 1048 struct amdgpu_ctx *ctx);
1049void amdgpu_ctx_fini(struct amdgpu_ctx *ctx); 1049void amdgpu_ctx_fini(struct amdgpu_ctx *ctx);
1050 1050
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index fec65f01c031..c1f2308b4115 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -25,7 +25,7 @@
25#include <drm/drmP.h> 25#include <drm/drmP.h>
26#include "amdgpu.h" 26#include "amdgpu.h"
27 27
28int amdgpu_ctx_init(struct amdgpu_device *adev, bool kernel, 28int amdgpu_ctx_init(struct amdgpu_device *adev, enum amd_sched_priority pri,
29 struct amdgpu_ctx *ctx) 29 struct amdgpu_ctx *ctx)
30{ 30{
31 unsigned i, j; 31 unsigned i, j;
@@ -42,10 +42,9 @@ int amdgpu_ctx_init(struct amdgpu_device *adev, bool kernel,
42 /* create context entity for each ring */ 42 /* create context entity for each ring */
43 for (i = 0; i < adev->num_rings; i++) { 43 for (i = 0; i < adev->num_rings; i++) {
44 struct amd_sched_rq *rq; 44 struct amd_sched_rq *rq;
45 if (kernel) 45 if (pri >= AMD_SCHED_MAX_PRIORITY)
46 rq = &adev->rings[i]->sched.kernel_rq; 46 return -EINVAL;
47 else 47 rq = &adev->rings[i]->sched.sched_rq[pri];
48 rq = &adev->rings[i]->sched.sched_rq;
49 r = amd_sched_entity_init(&adev->rings[i]->sched, 48 r = amd_sched_entity_init(&adev->rings[i]->sched,
50 &ctx->rings[i].entity, 49 &ctx->rings[i].entity,
51 rq, amdgpu_sched_jobs); 50 rq, amdgpu_sched_jobs);
@@ -103,7 +102,7 @@ static int amdgpu_ctx_alloc(struct amdgpu_device *adev,
103 return r; 102 return r;
104 } 103 }
105 *id = (uint32_t)r; 104 *id = (uint32_t)r;
106 r = amdgpu_ctx_init(adev, false, ctx); 105 r = amdgpu_ctx_init(adev, AMD_SCHED_PRIORITY_NORMAL, ctx);
107 mutex_unlock(&mgr->lock); 106 mutex_unlock(&mgr->lock);
108 107
109 return r; 108 return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 58cb6987b078..84775964b138 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1528,7 +1528,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
1528 return r; 1528 return r;
1529 } 1529 }
1530 1530
1531 r = amdgpu_ctx_init(adev, true, &adev->kernel_ctx); 1531 r = amdgpu_ctx_init(adev, AMD_SCHED_PRIORITY_KERNEL, &adev->kernel_ctx);
1532 if (r) { 1532 if (r) {
1533 dev_err(adev->dev, "failed to create kernel context (%d).\n", r); 1533 dev_err(adev->dev, "failed to create kernel context (%d).\n", r);
1534 return r; 1534 return r;
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
index 651129f2ec1d..e13b7a013a40 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@ -348,14 +348,17 @@ static struct amd_sched_entity *
348amd_sched_select_entity(struct amd_gpu_scheduler *sched) 348amd_sched_select_entity(struct amd_gpu_scheduler *sched)
349{ 349{
350 struct amd_sched_entity *entity; 350 struct amd_sched_entity *entity;
351 int i;
351 352
352 if (!amd_sched_ready(sched)) 353 if (!amd_sched_ready(sched))
353 return NULL; 354 return NULL;
354 355
355 /* Kernel run queue has higher priority than normal run queue*/ 356 /* Kernel run queue has higher priority than normal run queue*/
356 entity = amd_sched_rq_select_entity(&sched->kernel_rq); 357 for (i = 0; i < AMD_SCHED_MAX_PRIORITY; i++) {
357 if (entity == NULL) 358 entity = amd_sched_rq_select_entity(&sched->sched_rq[i]);
358 entity = amd_sched_rq_select_entity(&sched->sched_rq); 359 if (entity)
360 break;
361 }
359 362
360 return entity; 363 return entity;
361} 364}
@@ -477,12 +480,13 @@ int amd_sched_init(struct amd_gpu_scheduler *sched,
477 struct amd_sched_backend_ops *ops, 480 struct amd_sched_backend_ops *ops,
478 unsigned hw_submission, long timeout, const char *name) 481 unsigned hw_submission, long timeout, const char *name)
479{ 482{
483 int i;
480 sched->ops = ops; 484 sched->ops = ops;
481 sched->hw_submission_limit = hw_submission; 485 sched->hw_submission_limit = hw_submission;
482 sched->name = name; 486 sched->name = name;
483 sched->timeout = timeout; 487 sched->timeout = timeout;
484 amd_sched_rq_init(&sched->sched_rq); 488 for (i = 0; i < AMD_SCHED_MAX_PRIORITY; i++)
485 amd_sched_rq_init(&sched->kernel_rq); 489 amd_sched_rq_init(&sched->sched_rq[i]);
486 490
487 init_waitqueue_head(&sched->wake_up_worker); 491 init_waitqueue_head(&sched->wake_up_worker);
488 init_waitqueue_head(&sched->job_scheduled); 492 init_waitqueue_head(&sched->job_scheduled);
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
index a0f0ae53aacd..9403145d7bee 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
@@ -104,6 +104,12 @@ struct amd_sched_backend_ops {
104 struct fence *(*run_job)(struct amd_sched_job *sched_job); 104 struct fence *(*run_job)(struct amd_sched_job *sched_job);
105}; 105};
106 106
107enum amd_sched_priority {
108 AMD_SCHED_PRIORITY_KERNEL = 0,
109 AMD_SCHED_PRIORITY_NORMAL,
110 AMD_SCHED_MAX_PRIORITY
111};
112
107/** 113/**
108 * One scheduler is implemented for each hardware ring 114 * One scheduler is implemented for each hardware ring
109*/ 115*/
@@ -112,8 +118,7 @@ struct amd_gpu_scheduler {
112 uint32_t hw_submission_limit; 118 uint32_t hw_submission_limit;
113 long timeout; 119 long timeout;
114 const char *name; 120 const char *name;
115 struct amd_sched_rq sched_rq; 121 struct amd_sched_rq sched_rq[AMD_SCHED_MAX_PRIORITY];
116 struct amd_sched_rq kernel_rq;
117 wait_queue_head_t wake_up_worker; 122 wait_queue_head_t wake_up_worker;
118 wait_queue_head_t job_scheduled; 123 wait_queue_head_t job_scheduled;
119 atomic_t hw_rq_count; 124 atomic_t hw_rq_count;