* [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset @ 2024-01-29 15:56 Alex Deucher 2024-02-12 20:56 ` Deucher, Alexander 0 siblings, 1 reply; 6+ messages in thread From: Alex Deucher @ 2024-01-29 15:56 UTC (permalink / raw) To: amd-gfx; +Cc: Alex Deucher This avoids queries to read registers or query the SMU for telemetry data while the GPU is in reset. This mirrors what we already do for sysfs. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index a2df3025a754..d522e99c6f81 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -607,6 +607,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) int i, found, ret; int ui32_size = sizeof(ui32); + if (amdgpu_in_reset(adev)) + return -EPERM; + if (!info->return_size || !info->return_pointer) return -EINVAL; -- 2.42.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset 2024-01-29 15:56 [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset Alex Deucher @ 2024-02-12 20:56 ` Deucher, Alexander 2024-02-15 7:27 ` Christian König 0 siblings, 1 reply; 6+ messages in thread From: Deucher, Alexander @ 2024-02-12 20:56 UTC (permalink / raw) To: amd-gfx@lists.freedesktop.org [AMD Official Use Only - General] Ping? > -----Original Message----- > From: Deucher, Alexander <Alexander.Deucher@amd.com> > Sent: Monday, January 29, 2024 10:56 AM > To: amd-gfx@lists.freedesktop.org > Cc: Deucher, Alexander <Alexander.Deucher@amd.com> > Subject: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset > > This avoids queries to read registers or query the SMU for telemetry data while > the GPU is in reset. This mirrors what we already do for sysfs. > > Signed-off-by: Alex Deucher <alexander.deucher@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > index a2df3025a754..d522e99c6f81 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > @@ -607,6 +607,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void > *data, struct drm_file *filp) > int i, found, ret; > int ui32_size = sizeof(ui32); > > + if (amdgpu_in_reset(adev)) > + return -EPERM; > + > if (!info->return_size || !info->return_pointer) > return -EINVAL; > > -- > 2.42.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset 2024-02-12 20:56 ` Deucher, Alexander @ 2024-02-15 7:27 ` Christian König 2024-02-15 14:36 ` Alex Deucher 0 siblings, 1 reply; 6+ messages in thread From: Christian König @ 2024-02-15 7:27 UTC (permalink / raw) To: Deucher, Alexander, amd-gfx@lists.freedesktop.org Well using this is in sysfs is a bug to begin with. This would prevent starting new applications and crashing applications which don't expect to get an -EPERM in return here. If we need to make operations mutual exclusive with resets then we need to take the appropriate locks and *not* work around by abusing amdgpu_in_reset(). The functionality of amdgpu_in_reset() is just to check in lower level functions if we are inside the higher level reset thread and *not* protect anybody from concurrent access. I think we should probably completely nuke the underlying flag and using the thread owner of the lock to prevent such an abuse. Regards, Christian. Am 12.02.24 um 21:56 schrieb Deucher, Alexander: > [AMD Official Use Only - General] > > Ping? > >> -----Original Message----- >> From: Deucher, Alexander <Alexander.Deucher@amd.com> >> Sent: Monday, January 29, 2024 10:56 AM >> To: amd-gfx@lists.freedesktop.org >> Cc: Deucher, Alexander <Alexander.Deucher@amd.com> >> Subject: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset >> >> This avoids queries to read registers or query the SMU for telemetry data while >> the GPU is in reset. This mirrors what we already do for sysfs. >> >> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> >> --- >> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >> index a2df3025a754..d522e99c6f81 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >> @@ -607,6 +607,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void >> *data, struct drm_file *filp) >> int i, found, ret; >> int ui32_size = sizeof(ui32); >> >> + if (amdgpu_in_reset(adev)) >> + return -EPERM; >> + >> if (!info->return_size || !info->return_pointer) >> return -EINVAL; >> >> -- >> 2.42.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset 2024-02-15 7:27 ` Christian König @ 2024-02-15 14:36 ` Alex Deucher 2024-02-15 14:43 ` Christian König 0 siblings, 1 reply; 6+ messages in thread From: Alex Deucher @ 2024-02-15 14:36 UTC (permalink / raw) To: Christian König; +Cc: Deucher, Alexander, amd-gfx@lists.freedesktop.org On Thu, Feb 15, 2024 at 2:53 AM Christian König <ckoenig.leichtzumerken@gmail.com> wrote: > > Well using this is in sysfs is a bug to begin with. This would prevent > starting new applications and crashing applications which don't expect > to get an -EPERM in return here. > > If we need to make operations mutual exclusive with resets then we need > to take the appropriate locks and *not* work around by abusing > amdgpu_in_reset(). > > The functionality of amdgpu_in_reset() is just to check in lower level > functions if we are inside the higher level reset thread and *not* > protect anybody from concurrent access. > > I think we should probably completely nuke the underlying flag and using > the thread owner of the lock to prevent such an abuse. Can we land some variant of this for now? It fixes known issues and it's the same behavior we have in sysfs and debugfs already. It's not clear to me how this should best be handled. We basically want to block any access to the GPU (registers, firmwares, etc.) while the GPU is going through a reset. Just locking the reset domain doesn't seem like the right solution. Alex > > Regards, > Christian. > > Am 12.02.24 um 21:56 schrieb Deucher, Alexander: > > [AMD Official Use Only - General] > > > > Ping? > > > >> -----Original Message----- > >> From: Deucher, Alexander <Alexander.Deucher@amd.com> > >> Sent: Monday, January 29, 2024 10:56 AM > >> To: amd-gfx@lists.freedesktop.org > >> Cc: Deucher, Alexander <Alexander.Deucher@amd.com> > >> Subject: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset > >> > >> This avoids queries to read registers or query the SMU for telemetry data while > >> the GPU is in reset. This mirrors what we already do for sysfs. > >> > >> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> > >> --- > >> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ > >> 1 file changed, 3 insertions(+) > >> > >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > >> index a2df3025a754..d522e99c6f81 100644 > >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > >> @@ -607,6 +607,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void > >> *data, struct drm_file *filp) > >> int i, found, ret; > >> int ui32_size = sizeof(ui32); > >> > >> + if (amdgpu_in_reset(adev)) > >> + return -EPERM; > >> + > >> if (!info->return_size || !info->return_pointer) > >> return -EINVAL; > >> > >> -- > >> 2.42.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset 2024-02-15 14:36 ` Alex Deucher @ 2024-02-15 14:43 ` Christian König 2024-02-15 14:46 ` Christian König 0 siblings, 1 reply; 6+ messages in thread From: Christian König @ 2024-02-15 14:43 UTC (permalink / raw) To: Alex Deucher; +Cc: Deucher, Alexander, amd-gfx@lists.freedesktop.org Am 15.02.24 um 15:36 schrieb Alex Deucher: > On Thu, Feb 15, 2024 at 2:53 AM Christian König > <ckoenig.leichtzumerken@gmail.com> wrote: >> Well using this is in sysfs is a bug to begin with. This would prevent >> starting new applications and crashing applications which don't expect >> to get an -EPERM in return here. >> >> If we need to make operations mutual exclusive with resets then we need >> to take the appropriate locks and *not* work around by abusing >> amdgpu_in_reset(). >> >> The functionality of amdgpu_in_reset() is just to check in lower level >> functions if we are inside the higher level reset thread and *not* >> protect anybody from concurrent access. >> >> I think we should probably completely nuke the underlying flag and using >> the thread owner of the lock to prevent such an abuse. > Can we land some variant of this for now? I don't think so, it most likely will break existing use cases. What we might be able to do is to frame this with amdgpu_device_lock_reset_domain() / amdgpu_device_unlock_reset_domain(). > It fixes known issues and it's the same behavior we have in sysfs and debugfs already. Yeah, as I said that is broken to begin with. It's just that for sysfs and debugfs nobody notices. Regards, Christian. > It's not > clear to me how this should best be handled. We basically want to > block any access to the GPU (registers, firmwares, etc.) while the GPU > is going through a reset. Just locking the reset domain doesn't seem > like the right solution. > > Alex > >> Regards, >> Christian. >> >> Am 12.02.24 um 21:56 schrieb Deucher, Alexander: >>> [AMD Official Use Only - General] >>> >>> Ping? >>> >>>> -----Original Message----- >>>> From: Deucher, Alexander <Alexander.Deucher@amd.com> >>>> Sent: Monday, January 29, 2024 10:56 AM >>>> To: amd-gfx@lists.freedesktop.org >>>> Cc: Deucher, Alexander <Alexander.Deucher@amd.com> >>>> Subject: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset >>>> >>>> This avoids queries to read registers or query the SMU for telemetry data while >>>> the GPU is in reset. This mirrors what we already do for sysfs. >>>> >>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> >>>> --- >>>> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ >>>> 1 file changed, 3 insertions(+) >>>> >>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>> index a2df3025a754..d522e99c6f81 100644 >>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>> @@ -607,6 +607,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, void >>>> *data, struct drm_file *filp) >>>> int i, found, ret; >>>> int ui32_size = sizeof(ui32); >>>> >>>> + if (amdgpu_in_reset(adev)) >>>> + return -EPERM; >>>> + >>>> if (!info->return_size || !info->return_pointer) >>>> return -EINVAL; >>>> >>>> -- >>>> 2.42.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset 2024-02-15 14:43 ` Christian König @ 2024-02-15 14:46 ` Christian König 0 siblings, 0 replies; 6+ messages in thread From: Christian König @ 2024-02-15 14:46 UTC (permalink / raw) To: Alex Deucher; +Cc: Deucher, Alexander, amd-gfx@lists.freedesktop.org Am 15.02.24 um 15:43 schrieb Christian König: > Am 15.02.24 um 15:36 schrieb Alex Deucher: >> On Thu, Feb 15, 2024 at 2:53 AM Christian König >> <ckoenig.leichtzumerken@gmail.com> wrote: >>> Well using this is in sysfs is a bug to begin with. This would prevent >>> starting new applications and crashing applications which don't expect >>> to get an -EPERM in return here. >>> >>> If we need to make operations mutual exclusive with resets then we need >>> to take the appropriate locks and *not* work around by abusing >>> amdgpu_in_reset(). >>> >>> The functionality of amdgpu_in_reset() is just to check in lower level >>> functions if we are inside the higher level reset thread and *not* >>> protect anybody from concurrent access. >>> >>> I think we should probably completely nuke the underlying flag and >>> using >>> the thread owner of the lock to prevent such an abuse. >> Can we land some variant of this for now? > > I don't think so, it most likely will break existing use cases. > > What we might be able to do is to frame this with > amdgpu_device_lock_reset_domain() / amdgpu_device_unlock_reset_domain(). > >> It fixes known issues and it's the same behavior we have in sysfs and >> debugfs already. > > Yeah, as I said that is broken to begin with. It's just that for sysfs > and debugfs nobody notices. Wait a second, debugfs is actually doing the right thing in some functions: /* Avoid accidently unparking the sched thread during GPU reset */ r = down_read_killable(&adev->reset_domain->sem); if (r) goto pro_end; ... up_read(&adev->reset_domain->sem); This needs to replace amdgpu_in_reset() in pretty much all debugfs and sysfs function. Probably best to wrap that in some inline amdgpu_reset_* functions and document why those needs to be used. Regards, Christian. > > Regards, > Christian. > >> It's not >> clear to me how this should best be handled. We basically want to >> block any access to the GPU (registers, firmwares, etc.) while the GPU >> is going through a reset. Just locking the reset domain doesn't seem >> like the right solution. >> >> Alex >> >>> Regards, >>> Christian. >>> >>> Am 12.02.24 um 21:56 schrieb Deucher, Alexander: >>>> [AMD Official Use Only - General] >>>> >>>> Ping? >>>> >>>>> -----Original Message----- >>>>> From: Deucher, Alexander <Alexander.Deucher@amd.com> >>>>> Sent: Monday, January 29, 2024 10:56 AM >>>>> To: amd-gfx@lists.freedesktop.org >>>>> Cc: Deucher, Alexander <Alexander.Deucher@amd.com> >>>>> Subject: [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in >>>>> reset >>>>> >>>>> This avoids queries to read registers or query the SMU for >>>>> telemetry data while >>>>> the GPU is in reset. This mirrors what we already do for sysfs. >>>>> >>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> >>>>> --- >>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ >>>>> 1 file changed, 3 insertions(+) >>>>> >>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>>> index a2df3025a754..d522e99c6f81 100644 >>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c >>>>> @@ -607,6 +607,9 @@ int amdgpu_info_ioctl(struct drm_device *dev, >>>>> void >>>>> *data, struct drm_file *filp) >>>>> int i, found, ret; >>>>> int ui32_size = sizeof(ui32); >>>>> >>>>> + if (amdgpu_in_reset(adev)) >>>>> + return -EPERM; >>>>> + >>>>> if (!info->return_size || !info->return_pointer) >>>>> return -EINVAL; >>>>> >>>>> -- >>>>> 2.42.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-15 14:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-01-29 15:56 [PATCH] drm/amdgpu: bail on INFO IOCTL if the GPU is in reset Alex Deucher 2024-02-12 20:56 ` Deucher, Alexander 2024-02-15 7:27 ` Christian König 2024-02-15 14:36 ` Alex Deucher 2024-02-15 14:43 ` Christian König 2024-02-15 14:46 ` Christian König
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.