* [PATCH] drm/amdgpu: Add mutex locking to VMID Manager Initialization for Process Isolation
@ 2025-01-10 3:38 Srinivasan Shanmugam
2025-01-10 6:38 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Srinivasan Shanmugam @ 2025-01-10 3:38 UTC (permalink / raw)
To: Christian König, Alex Deucher; +Cc: amd-gfx, 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
Fixes: 96595204195d ("drm/amdgpu: Make enforce_isolation setting per GPU")
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@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);
}
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/amdgpu: Add mutex locking to VMID Manager Initialization for Process Isolation
2025-01-10 3:38 [PATCH] drm/amdgpu: Add mutex locking to VMID Manager Initialization for Process Isolation Srinivasan Shanmugam
@ 2025-01-10 6:38 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2025-01-10 6:38 UTC (permalink / raw)
To: Srinivasan Shanmugam, Alex Deucher; +Cc: amd-gfx
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@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@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);
> }
>
> /**
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-10 6:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 3:38 [PATCH] drm/amdgpu: Add mutex locking to VMID Manager Initialization for Process Isolation Srinivasan Shanmugam
2025-01-10 6:38 ` Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox