All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix deadlock during gpu reset
@ 2021-01-11 19:55 Bhawanpreet Lakha
  2021-01-11 20:22 ` Kazlauskas, Nicholas
  0 siblings, 1 reply; 3+ messages in thread
From: Bhawanpreet Lakha @ 2021-01-11 19:55 UTC (permalink / raw)
  To: nicholas.kazlauskas, Guchun.Chen, alexander.deucher
  Cc: Bhawanpreet Lakha, amd-gfx

[Why]
during idle optimizations we acquire the dc_lock, this lock is also
acquired during gpu_reset so we end up hanging the system due to a
deadlock

[How]
If we are in gpu reset dont acquire the dc lock, as we already have it

Fixes: 06d5652541c3 ("drm/amd/display: enable idle optimizations for linux (MALL stutter)")
Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 99c7f9eb44aa..2170e1b2d32c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5556,7 +5556,8 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
 	if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
 		return -EBUSY;
 
-	mutex_lock(&dm->dc_lock);
+	if (!amdgpu_in_reset(adev))
+		mutex_lock(&dm->dc_lock);
 
 	if (enable)
 		dm->active_vblank_irq_count++;
@@ -5568,7 +5569,8 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
 
 	DRM_DEBUG_DRIVER("Allow idle optimizations (MALL): %d\n", dm->active_vblank_irq_count == 0);
 
-	mutex_unlock(&dm->dc_lock);
+	if (!amdgpu_in_reset(adev))
+		mutex_unlock(&dm->dc_lock);
 
 	return 0;
 }
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd/display: Fix deadlock during gpu reset
  2021-01-11 19:55 [PATCH] drm/amd/display: Fix deadlock during gpu reset Bhawanpreet Lakha
@ 2021-01-11 20:22 ` Kazlauskas, Nicholas
  2021-01-11 20:23   ` Lakha, Bhawanpreet
  0 siblings, 1 reply; 3+ messages in thread
From: Kazlauskas, Nicholas @ 2021-01-11 20:22 UTC (permalink / raw)
  To: Bhawanpreet Lakha, Guchun.Chen, alexander.deucher; +Cc: amd-gfx

On 2021-01-11 2:55 p.m., Bhawanpreet Lakha wrote:
> [Why]
> during idle optimizations we acquire the dc_lock, this lock is also
> acquired during gpu_reset so we end up hanging the system due to a
> deadlock
> 
> [How]
> If we are in gpu reset dont acquire the dc lock, as we already have it

Are we sure this is the behavior we want?

I think if we are in GPU reset then we shouldn't be attempting to modify 
idle optimization state at all, ie. return early if amdgpu_in_reset.

The calls around the locks are working around bad policy.

Regards,
Nicholas Kazlauskas

> 
> Fixes: 06d5652541c3 ("drm/amd/display: enable idle optimizations for linux (MALL stutter)")
> Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 99c7f9eb44aa..2170e1b2d32c 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5556,7 +5556,8 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
>   	if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
>   		return -EBUSY;
>   
> -	mutex_lock(&dm->dc_lock);
> +	if (!amdgpu_in_reset(adev))
> +		mutex_lock(&dm->dc_lock);
>   
>   	if (enable)
>   		dm->active_vblank_irq_count++;
> @@ -5568,7 +5569,8 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
>   
>   	DRM_DEBUG_DRIVER("Allow idle optimizations (MALL): %d\n", dm->active_vblank_irq_count == 0);
>   
> -	mutex_unlock(&dm->dc_lock);
> +	if (!amdgpu_in_reset(adev))
> +		mutex_unlock(&dm->dc_lock);
>   
>   	return 0;
>   }
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd/display: Fix deadlock during gpu reset
  2021-01-11 20:22 ` Kazlauskas, Nicholas
@ 2021-01-11 20:23   ` Lakha, Bhawanpreet
  0 siblings, 0 replies; 3+ messages in thread
From: Lakha, Bhawanpreet @ 2021-01-11 20:23 UTC (permalink / raw)
  To: Kazlauskas, Nicholas, Chen, Guchun, Deucher, Alexander; +Cc: amd-gfx


[-- Attachment #1.1: Type: text/plain, Size: 2406 bytes --]

[AMD Official Use Only - Internal Distribution Only]

right, that makes more sense. I will post a v2 shortly
________________________________
From: Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com>
Sent: January 11, 2021 3:22 PM
To: Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/amd/display: Fix deadlock during gpu reset

On 2021-01-11 2:55 p.m., Bhawanpreet Lakha wrote:
> [Why]
> during idle optimizations we acquire the dc_lock, this lock is also
> acquired during gpu_reset so we end up hanging the system due to a
> deadlock
>
> [How]
> If we are in gpu reset dont acquire the dc lock, as we already have it

Are we sure this is the behavior we want?

I think if we are in GPU reset then we shouldn't be attempting to modify
idle optimization state at all, ie. return early if amdgpu_in_reset.

The calls around the locks are working around bad policy.

Regards,
Nicholas Kazlauskas

>
> Fixes: 06d5652541c3 ("drm/amd/display: enable idle optimizations for linux (MALL stutter)")
> Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 99c7f9eb44aa..2170e1b2d32c 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5556,7 +5556,8 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
>        if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
>                return -EBUSY;
>
> -     mutex_lock(&dm->dc_lock);
> +     if (!amdgpu_in_reset(adev))
> +             mutex_lock(&dm->dc_lock);
>
>        if (enable)
>                dm->active_vblank_irq_count++;
> @@ -5568,7 +5569,8 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
>
>        DRM_DEBUG_DRIVER("Allow idle optimizations (MALL): %d\n", dm->active_vblank_irq_count == 0);
>
> -     mutex_unlock(&dm->dc_lock);
> +     if (!amdgpu_in_reset(adev))
> +             mutex_unlock(&dm->dc_lock);
>
>        return 0;
>   }
>


[-- Attachment #1.2: Type: text/html, Size: 4246 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-11 20:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 19:55 [PATCH] drm/amd/display: Fix deadlock during gpu reset Bhawanpreet Lakha
2021-01-11 20:22 ` Kazlauskas, Nicholas
2021-01-11 20:23   ` Lakha, Bhawanpreet

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.