* [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
@ 2023-04-26 0:48 Chia-I Wu
2023-04-26 2:27 ` Chen, Guchun
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Chia-I Wu @ 2023-04-26 0:48 UTC (permalink / raw)
To: dri-devel
Cc: stable, Alex Deucher, Christian König, Pan, Xinhui,
David Airlie, Daniel Vetter, amd-gfx, linux-kernel
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Cc: stable@vger.kernel.org
---
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.0.634.g4ca3ef3211-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
2023-04-26 0:48 [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED Chia-I Wu
@ 2023-04-26 2:27 ` Chen, Guchun
2023-04-26 2:48 ` Chia-I Wu
2023-04-26 4:58 ` Greg KH
2023-04-26 10:29 ` Christian König
2 siblings, 1 reply; 6+ messages in thread
From: Chen, Guchun @ 2023-04-26 2:27 UTC (permalink / raw)
To: Chia-I Wu, dri-devel@lists.freedesktop.org
Cc: Pan, Xinhui, linux-kernel@vger.kernel.org, stable@vger.kernel.org,
amd-gfx@lists.freedesktop.org, Daniel Vetter, Deucher, Alexander,
David Airlie, Koenig, Christian
From coding style's perspective, this lock/unlock handling should be put into amdgpu_ctx_priority_override.
Regards,
Guchun
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Chia-
> I Wu
> Sent: Wednesday, April 26, 2023 8:48 AM
> To: dri-devel@lists.freedesktop.org
> Cc: Pan, Xinhui <Xinhui.Pan@amd.com>; linux-kernel@vger.kernel.org;
> stable@vger.kernel.org; amd-gfx@lists.freedesktop.org; Daniel Vetter
> <daniel@ffwll.ch>; Deucher, Alexander <Alexander.Deucher@amd.com>;
> David Airlie <airlied@gmail.com>; Koenig, Christian
> <Christian.Koenig@amd.com>
> Subject: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
>
> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> Cc: stable@vger.kernel.org
> ---
> 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.0.634.g4ca3ef3211-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
2023-04-26 2:27 ` Chen, Guchun
@ 2023-04-26 2:48 ` Chia-I Wu
0 siblings, 0 replies; 6+ messages in thread
From: Chia-I Wu @ 2023-04-26 2:48 UTC (permalink / raw)
To: Chen, Guchun
Cc: dri-devel@lists.freedesktop.org, Pan, Xinhui,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
amd-gfx@lists.freedesktop.org, Daniel Vetter, Deucher, Alexander,
David Airlie, Koenig, Christian
On Tue, Apr 25, 2023 at 7:27 PM Chen, Guchun <Guchun.Chen@amd.com> wrote:
>
> From coding style's perspective, this lock/unlock handling should be put into amdgpu_ctx_priority_override.
The locking is to protect mgr->ctx_handles.
>
> Regards,
> Guchun
>
> > -----Original Message-----
> > From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Chia-
> > I Wu
> > Sent: Wednesday, April 26, 2023 8:48 AM
> > To: dri-devel@lists.freedesktop.org
> > Cc: Pan, Xinhui <Xinhui.Pan@amd.com>; linux-kernel@vger.kernel.org;
> > stable@vger.kernel.org; amd-gfx@lists.freedesktop.org; Daniel Vetter
> > <daniel@ffwll.ch>; Deucher, Alexander <Alexander.Deucher@amd.com>;
> > David Airlie <airlied@gmail.com>; Koenig, Christian
> > <Christian.Koenig@amd.com>
> > Subject: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
> >
> > Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> > Cc: stable@vger.kernel.org
> > ---
> > 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.0.634.g4ca3ef3211-goog
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
2023-04-26 0:48 [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED Chia-I Wu
2023-04-26 2:27 ` Chen, Guchun
@ 2023-04-26 4:58 ` Greg KH
2023-04-26 6:31 ` Chia-I Wu
2023-04-26 10:29 ` Christian König
2 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2023-04-26 4:58 UTC (permalink / raw)
To: Chia-I Wu
Cc: dri-devel, stable, Alex Deucher, Christian König,
Pan, Xinhui, David Airlie, Daniel Vetter, amd-gfx, linux-kernel
On Tue, Apr 25, 2023 at 05:48:27PM -0700, Chia-I Wu wrote:
> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> Cc: stable@vger.kernel.org
I know I can not take patches without any changelog text at all, maybe
the DRM developers are more lax, but it's not a good idea at all.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
2023-04-26 4:58 ` Greg KH
@ 2023-04-26 6:31 ` Chia-I Wu
0 siblings, 0 replies; 6+ messages in thread
From: Chia-I Wu @ 2023-04-26 6:31 UTC (permalink / raw)
To: Greg KH
Cc: dri-devel, stable, Alex Deucher, Christian König,
Pan, Xinhui, David Airlie, Daniel Vetter, amd-gfx, linux-kernel
On Tue, Apr 25, 2023 at 9:58 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Apr 25, 2023 at 05:48:27PM -0700, Chia-I Wu wrote:
> > Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> > Cc: stable@vger.kernel.org
>
> I know I can not take patches without any changelog text at all, maybe
> the DRM developers are more lax, but it's not a good idea at all.
Oops, sorry. I've sent out v2 to address both review feedback.
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED
2023-04-26 0:48 [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED Chia-I Wu
2023-04-26 2:27 ` Chen, Guchun
2023-04-26 4:58 ` Greg KH
@ 2023-04-26 10:29 ` Christian König
2 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2023-04-26 10:29 UTC (permalink / raw)
To: Chia-I Wu, dri-devel
Cc: stable, Alex Deucher, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, linux-kernel
Am 26.04.23 um 02:48 schrieb Chia-I Wu:
Good catch, but you need some commit message here. Something like "Need
to hold the lock while iterating the idr to make sure no context is
destroyed." should be sufficient.
Apart from that looks good to me.
Regards,
Christian.
> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> Cc: stable@vger.kernel.org
> ---
> 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-26 10:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-26 0:48 [PATCH] drm/amdgpu: add a missing lock for AMDGPU_SCHED Chia-I Wu
2023-04-26 2:27 ` Chen, Guchun
2023-04-26 2:48 ` Chia-I Wu
2023-04-26 4:58 ` Greg KH
2023-04-26 6:31 ` Chia-I Wu
2023-04-26 10:29 ` 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