On 12/19/25 14:42, Tvrtko Ursulin wrote:
> There is no need for an arbitrary limit to number of contexts userspace
> can be allowed to create. Remove the AMDGPU_VM_MAX_NUM_CTX (4096) and
> allow for full 32-bit of handles to be allocated.
> 
> Signed-off-by: Tvrtko Ursulin <[email protected]>
> Suggested-by: Christian König <[email protected]>

Reviewed-by: Christian König <[email protected]>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 -
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 6 +++---
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 9f9774f58ce1..80dba6276aa8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -274,7 +274,6 @@ extern int amdgpu_rebar;
>  extern int amdgpu_wbrf;
>  extern int amdgpu_user_queue;
>  
> -#define AMDGPU_VM_MAX_NUM_CTX                        4096
>  #define AMDGPU_SG_THRESHOLD                  (256*1024*1024)
>  #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS               3000
>  #define AMDGPU_MAX_USEC_TIMEOUT                      100000  /* 100 ms */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index 41c05358d86d..dd1e562dbaed 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -484,14 +484,14 @@ static int amdgpu_ctx_alloc(struct amdgpu_device *adev,
>               return -ENOMEM;
>  
>       mutex_lock(&mgr->lock);
> -     r = idr_alloc(&mgr->ctx_handles, ctx, 1, AMDGPU_VM_MAX_NUM_CTX, 
> GFP_KERNEL);
> -     if (r < 0) {
> +     *id = 1;
> +     r = idr_alloc_u32(&mgr->ctx_handles, ctx, id, UINT_MAX, GFP_KERNEL);
> +     if (r) {
>               mutex_unlock(&mgr->lock);
>               kfree(ctx);
>               return r;
>       }
>  
> -     *id = (uint32_t)r;
>       r = amdgpu_ctx_init(mgr, priority, filp, ctx);
>       if (r) {
>               idr_remove(&mgr->ctx_handles, *id);

Reply via email to