* [PATCH v3] drm/amdgpu: add a missing lock for AMDGPU_SCHED
@ 2023-04-26 22:54 Chia-I Wu
2023-04-27 18:50 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Chia-I Wu @ 2023-04-26 22:54 UTC (permalink / raw)
To: dri-devel
Cc: Christian König, Alex Deucher, Pan, Xinhui, David Airlie,
Daniel Vetter, Andres Rodriguez, amd-gfx, linux-kernel
mgr->ctx_handles should be protected by mgr->lock.
v2: improve commit message
v3: add a Fixes tag
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Fixes: 52c6a62c64fac ("drm/amdgpu: add interface for editing a foreign process's priority v3")
---
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
index e9b45089a28a6..863b2a34b2d64 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
@@ -38,6 +38,7 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
{
struct fd f = fdget(fd);
struct amdgpu_fpriv *fpriv;
+ struct amdgpu_ctx_mgr *mgr;
struct amdgpu_ctx *ctx;
uint32_t id;
int r;
@@ -51,8 +52,11 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
return r;
}
- idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
+ mgr = &fpriv->ctx_mgr;
+ mutex_lock(&mgr->lock);
+ idr_for_each_entry(&mgr->ctx_handles, ctx, id)
amdgpu_ctx_priority_override(ctx, priority);
+ mutex_unlock(&mgr->lock);
fdput(f);
return 0;
--
2.40.1.495.gc816e09b53d-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] drm/amdgpu: add a missing lock for AMDGPU_SCHED
2023-04-26 22:54 [PATCH v3] drm/amdgpu: add a missing lock for AMDGPU_SCHED Chia-I Wu
@ 2023-04-27 18:50 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2023-04-27 18:50 UTC (permalink / raw)
To: Chia-I Wu
Cc: dri-devel, Pan, Xinhui, linux-kernel, amd-gfx, Andres Rodriguez,
Daniel Vetter, Alex Deucher, David Airlie, Christian König
Applied. Thanks!
Alex
On Wed, Apr 26, 2023 at 6:55 PM Chia-I Wu <olvaffe@gmail.com> wrote:
>
> mgr->ctx_handles should be protected by mgr->lock.
>
> v2: improve commit message
> v3: add a Fixes tag
>
> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Fixes: 52c6a62c64fac ("drm/amdgpu: add interface for editing a foreign process's priority v3")
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
> index e9b45089a28a6..863b2a34b2d64 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
> @@ -38,6 +38,7 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
> {
> struct fd f = fdget(fd);
> struct amdgpu_fpriv *fpriv;
> + struct amdgpu_ctx_mgr *mgr;
> struct amdgpu_ctx *ctx;
> uint32_t id;
> int r;
> @@ -51,8 +52,11 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
> return r;
> }
>
> - idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id)
> + mgr = &fpriv->ctx_mgr;
> + mutex_lock(&mgr->lock);
> + idr_for_each_entry(&mgr->ctx_handles, ctx, id)
> amdgpu_ctx_priority_override(ctx, priority);
> + mutex_unlock(&mgr->lock);
>
> fdput(f);
> return 0;
> --
> 2.40.1.495.gc816e09b53d-goog
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-27 18:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-26 22:54 [PATCH v3] drm/amdgpu: add a missing lock for AMDGPU_SCHED Chia-I Wu
2023-04-27 18:50 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox