Commit 5b011235 authored by Chunming Zhou's avatar Chunming Zhou Committed by Alex Deucher

drm/amdgpu: restrict the sched jobs number to power of two

Signed-off-by: default avatarChunming Zhou <David1.Zhou@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
parent a1493cd5
...@@ -252,7 +252,7 @@ uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, ...@@ -252,7 +252,7 @@ uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring,
unsigned idx = 0; unsigned idx = 0;
struct fence *other = NULL; struct fence *other = NULL;
idx = seq % amdgpu_sched_jobs; idx = seq & (amdgpu_sched_jobs - 1);
other = cring->fences[idx]; other = cring->fences[idx];
if (other) { if (other) {
signed long r; signed long r;
...@@ -292,7 +292,7 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, ...@@ -292,7 +292,7 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
return NULL; return NULL;
} }
fence = fence_get(cring->fences[seq % amdgpu_sched_jobs]); fence = fence_get(cring->fences[seq & (amdgpu_sched_jobs - 1)]);
spin_unlock(&ctx->ring_lock); spin_unlock(&ctx->ring_lock);
return fence; return fence;
......
...@@ -949,6 +949,15 @@ static bool amdgpu_check_pot_argument(int arg) ...@@ -949,6 +949,15 @@ static bool amdgpu_check_pot_argument(int arg)
*/ */
static void amdgpu_check_arguments(struct amdgpu_device *adev) static void amdgpu_check_arguments(struct amdgpu_device *adev)
{ {
if (amdgpu_sched_jobs < 4) {
dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n",
amdgpu_sched_jobs);
amdgpu_sched_jobs = 4;
} else if (!amdgpu_check_pot_argument(amdgpu_sched_jobs)){
dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n",
amdgpu_sched_jobs);
amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs);
}
/* vramlimit must be a power of two */ /* vramlimit must be a power of two */
if (!amdgpu_check_pot_argument(amdgpu_vram_limit)) { if (!amdgpu_check_pot_argument(amdgpu_vram_limit)) {
dev_warn(adev->dev, "vram limit (%d) must be a power of 2\n", dev_warn(adev->dev, "vram limit (%d) must be a power of 2\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment