diff options
author | Andres Rodriguez <andresx7@gmail.com> | 2017-06-06 20:20:38 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-10-09 16:30:24 -0400 |
commit | c23be4ae1d50e8d93f805de7ae3e8ea49a4ad781 (patch) | |
tree | 82fa44444feb8ca722f7f2ce40abf7d897f8ba05 | |
parent | f3d19bf80d6c7bfe5922c09604a402ef176da41f (diff) |
drm/amdgpu: add plumbing for ctx priority changes v2
Introduce amdgpu_ctx_priority_override(). A mechanism to override a
context's priority.
An override can be terminated by setting the override to
AMD_SCHED_PRIORITY_UNSET.
v2: change refcounted interface for a direct set
Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 29 |
2 files changed, 34 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 715ce4863bc8..951c8db01412 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -735,7 +735,9 @@ struct amdgpu_ctx { | |||
735 | spinlock_t ring_lock; | 735 | spinlock_t ring_lock; |
736 | struct dma_fence **fences; | 736 | struct dma_fence **fences; |
737 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; | 737 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; |
738 | bool preamble_presented; | 738 | bool preamble_presented; |
739 | enum amd_sched_priority init_priority; | ||
740 | enum amd_sched_priority override_priority; | ||
739 | }; | 741 | }; |
740 | 742 | ||
741 | struct amdgpu_ctx_mgr { | 743 | struct amdgpu_ctx_mgr { |
@@ -752,6 +754,8 @@ int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, | |||
752 | struct dma_fence *fence, uint64_t *seq); | 754 | struct dma_fence *fence, uint64_t *seq); |
753 | struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | 755 | struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, |
754 | struct amdgpu_ring *ring, uint64_t seq); | 756 | struct amdgpu_ring *ring, uint64_t seq); |
757 | void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, | ||
758 | enum amd_sched_priority priority); | ||
755 | 759 | ||
756 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, | 760 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, |
757 | struct drm_file *filp); | 761 | struct drm_file *filp); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 29eebdc30a4c..d2ef24f4b56d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -72,6 +72,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, | |||
72 | } | 72 | } |
73 | 73 | ||
74 | ctx->reset_counter = atomic_read(&adev->gpu_reset_counter); | 74 | ctx->reset_counter = atomic_read(&adev->gpu_reset_counter); |
75 | ctx->init_priority = priority; | ||
76 | ctx->override_priority = AMD_SCHED_PRIORITY_UNSET; | ||
75 | 77 | ||
76 | /* create context entity for each ring */ | 78 | /* create context entity for each ring */ |
77 | for (i = 0; i < adev->num_rings; i++) { | 79 | for (i = 0; i < adev->num_rings; i++) { |
@@ -362,6 +364,33 @@ struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | |||
362 | return fence; | 364 | return fence; |
363 | } | 365 | } |
364 | 366 | ||
367 | void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, | ||
368 | enum amd_sched_priority priority) | ||
369 | { | ||
370 | int i; | ||
371 | struct amdgpu_device *adev = ctx->adev; | ||
372 | struct amd_sched_rq *rq; | ||
373 | struct amd_sched_entity *entity; | ||
374 | struct amdgpu_ring *ring; | ||
375 | enum amd_sched_priority ctx_prio; | ||
376 | |||
377 | ctx->override_priority = priority; | ||
378 | |||
379 | ctx_prio = (ctx->override_priority == AMD_SCHED_PRIORITY_UNSET) ? | ||
380 | ctx->init_priority : ctx->override_priority; | ||
381 | |||
382 | for (i = 0; i < adev->num_rings; i++) { | ||
383 | ring = adev->rings[i]; | ||
384 | entity = &ctx->rings[i].entity; | ||
385 | rq = &ring->sched.sched_rq[ctx_prio]; | ||
386 | |||
387 | if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ) | ||
388 | continue; | ||
389 | |||
390 | amd_sched_entity_set_rq(entity, rq); | ||
391 | } | ||
392 | } | ||
393 | |||
365 | void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr) | 394 | void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr) |
366 | { | 395 | { |
367 | mutex_init(&mgr->lock); | 396 | mutex_init(&mgr->lock); |