[PATCH] drm/amdgpu: Add mutex locking to VMID Manager Initialization for Process Isolation

Christian König christian.koenig at amd.com
Fri Jan 10 06:38:48 UTC 2025


Am 10.01.25 um 04:38 schrieb Srinivasan Shanmugam:
> This commit adds mutex locking to the `amdgpu_vmid_mgr_init` function.
> By acquiring and releasing the `enforce_isolation_mutex`, so that it now
> safely allocates reserved VMIDs, which is important for enforcing
> isolation between different GPU processes.
>
> Mutex ensures that the process of allocating VMIDs is done
> correctly and without interference

That is unnecessary.

The VMID mgr is only initialized during driver load and at that moment 
the enforce isolation setting should be static.

Regards,
Christian.

>
> Fixes: 96595204195d ("drm/amdgpu: Make enforce_isolation setting per GPU")
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> index 8e712a11aba5..6ae835a7f031 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> @@ -602,10 +602,12 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
>   		}
>   	}
>   	/* alloc a default reserved vmid to enforce isolation */
> +	mutex_lock(&adev->enforce_isolation_mutex);
>   	for (i = 0; i < (adev->xcp_mgr ? adev->xcp_mgr->num_xcps : 1); i++) {
>   		if (adev->enforce_isolation[i])
>   			amdgpu_vmid_alloc_reserved(adev, AMDGPU_GFXHUB(i));
>   	}
> +	mutex_unlock(&adev->enforce_isolation_mutex);
>   }
>   
>   /**



More information about the amd-gfx mailing list