drm/amdgpu: Limit vm max ctx number to 4096
authorRex Zhu <Rex.Zhu@amd.com>
Wed, 24 Oct 2018 08:10:33 +0000 (16:10 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Dec 2018 20:21:13 +0000 (15:21 -0500)
driver need to reserve resource for each ctx for
some hw features. so add this limitation.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c

index 5752024..88db3c2 100644 (file)
@@ -164,6 +164,7 @@ extern int amdgpu_si_support;
 extern int amdgpu_cik_support;
 #endif
 
+#define AMDGPU_VM_MAX_NUM_CTX                  4096
 #define AMDGPU_SG_THRESHOLD                    (256*1024*1024)
 #define AMDGPU_DEFAULT_GTT_SIZE_MB             3072ULL /* 3GB by default */
 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS         3000
index 95f4c41..d85184b 100644 (file)
@@ -248,7 +248,7 @@ static int amdgpu_ctx_alloc(struct amdgpu_device *adev,
                return -ENOMEM;
 
        mutex_lock(&mgr->lock);
-       r = idr_alloc(&mgr->ctx_handles, ctx, 1, 0, GFP_KERNEL);
+       r = idr_alloc(&mgr->ctx_handles, ctx, 1, AMDGPU_VM_MAX_NUM_CTX, GFP_KERNEL);
        if (r < 0) {
                mutex_unlock(&mgr->lock);
                kfree(ctx);