diff options
author | Chunming Zhou <David1.Zhou@amd.com> | 2015-12-10 04:34:33 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-12-18 17:29:44 -0500 |
commit | 5b0112356cf9a735632b26ff5f3450e1716c8598 (patch) | |
tree | 12bc09ab704fa9a8e6118f8f83fbab14cf4dc436 | |
parent | a1493cd575678910f90d488069a8a2c41a144fda (diff) |
drm/amdgpu: restrict the sched jobs number to power of two
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index ee121ec2917b..17d1fb12128a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -252,7 +252,7 @@ uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, | |||
252 | unsigned idx = 0; | 252 | unsigned idx = 0; |
253 | struct fence *other = NULL; | 253 | struct fence *other = NULL; |
254 | 254 | ||
255 | idx = seq % amdgpu_sched_jobs; | 255 | idx = seq & (amdgpu_sched_jobs - 1); |
256 | other = cring->fences[idx]; | 256 | other = cring->fences[idx]; |
257 | if (other) { | 257 | if (other) { |
258 | signed long r; | 258 | signed long r; |
@@ -292,7 +292,7 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | |||
292 | return NULL; | 292 | return NULL; |
293 | } | 293 | } |
294 | 294 | ||
295 | fence = fence_get(cring->fences[seq % amdgpu_sched_jobs]); | 295 | fence = fence_get(cring->fences[seq & (amdgpu_sched_jobs - 1)]); |
296 | spin_unlock(&ctx->ring_lock); | 296 | spin_unlock(&ctx->ring_lock); |
297 | 297 | ||
298 | return fence; | 298 | return fence; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 54af6ce7901f..587ff7145361 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -949,6 +949,15 @@ static bool amdgpu_check_pot_argument(int arg) | |||
949 | */ | 949 | */ |
950 | static void amdgpu_check_arguments(struct amdgpu_device *adev) | 950 | static void amdgpu_check_arguments(struct amdgpu_device *adev) |
951 | { | 951 | { |
952 | if (amdgpu_sched_jobs < 4) { | ||
953 | dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n", | ||
954 | amdgpu_sched_jobs); | ||
955 | amdgpu_sched_jobs = 4; | ||
956 | } else if (!amdgpu_check_pot_argument(amdgpu_sched_jobs)){ | ||
957 | dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n", | ||
958 | amdgpu_sched_jobs); | ||
959 | amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs); | ||
960 | } | ||
952 | /* vramlimit must be a power of two */ | 961 | /* vramlimit must be a power of two */ |
953 | if (!amdgpu_check_pot_argument(amdgpu_vram_limit)) { | 962 | if (!amdgpu_check_pot_argument(amdgpu_vram_limit)) { |
954 | dev_warn(adev->dev, "vram limit (%d) must be a power of 2\n", | 963 | dev_warn(adev->dev, "vram limit (%d) must be a power of 2\n", |