Skip to contentSkip to conversation

drm/amd/display: Fix deadlock with display during hanged ring recovery.

PATCH In review Andrey Grodzovsky 4 participants 18 messages Feb 13, 2019 – Feb 14, 2019 14 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Fix deadlock with display during hanged ring recovery.

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -6
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 			 */
 			abo = gem_to_amdgpu_bo(fb->obj[0]);
 			r = amdgpu_bo_reserve(abo, true);
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
 				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
 			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1550084295-30360-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 36 lines · Andrey Grodzovsky

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
  1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -6
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
  			 */
  			abo = gem_to_amdgpu_bo(fb->obj[0]);
  			r = amdgpu_bo_reserve(abo, true);
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
  				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4822

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
  			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 

Is it safe that we're just continuing like this? It's probably better to just unreserve the buffer and continue to the next plane, no?

Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 8bd8afe3-1691-f760-55d9-9dba48223d58-5C7GfCeVMHo@public.gmane.org

#4 lore raw
Quoted 44 lines · Nicholas
Quoted 43 lines · Andrey Grodzovsky

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

---
   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
   1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -6
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
   			 */
   			abo = gem_to_amdgpu_bo(fb->obj[0]);
   			r = amdgpu_bo_reserve(abo, true);
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
   				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4822

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
   			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 

Is it safe that we're just continuing like this? It's probably better to just unreserve the buffer and continue to the next plane, no?

Nicholas Kazlauskas

As far as I see it should be safe as you are simply flipping to a buffer for which rendering hasn't finished (or stack actually in this case) so you might see visual corruption but that the least of your problems if after 5s the BO still not finalized for presentation, the system is already probably in very bad shape. Also, in case we do want to  do error handling we should also take care of  amdgpu_bo_reserve failure just before that.

Andrey

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 27f52783-3060-c41a-69b3-102ba6cd8f7e-5C7GfCeVMHo@public.gmane.org

Reviewed-by Nicholas Kazlauskas
#6 lore raw
Quoted 62 lines · Andrey
Quoted 44 lines · Nicholas
Quoted 43 lines · Andrey Grodzovsky

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

---
    drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
    1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -6
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
    			 */
    			abo = gem_to_amdgpu_bo(fb->obj[0]);
    			r = amdgpu_bo_reserve(abo, true);
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
    				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4822

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
    			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 

Is it safe that we're just continuing like this? It's probably better to just unreserve the buffer and continue to the next plane, no?

Nicholas Kazlauskas

As far as I see it should be safe as you are simply flipping to a buffer for which rendering hasn't finished (or stack actually in this case) so you might see visual corruption but that the least of your problems if after 5s the BO still not finalized for presentation, the system is already probably in very bad shape. Also, in case we do want to  do error handling we should also take care of  amdgpu_bo_reserve failure just before that.

Quoted 3 lines

Andrey

Yeah, I guess this whole blocks needs to be cleaned up in that case. This is a good first step at least. Technically reservation_object_wait_timeout_rcu will return < 0 when it's been interrupted too as an error code but I guess that will just be silently ignored here.

If you want you can change the condition to:

if (unlikely(r >= 0))
DRM_ERROR("Waiting for FB fence failed: id=%d res=%d\n",
plane->id, r);

But with or without that change this patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 18a6f51e-2966-21b1-3c16-fc24a927d996-5C7GfCeVMHo@public.gmane.org

#8 lore raw
Quoted 70 lines · Nicholas
Quoted 60 lines · Andrey
Quoted 44 lines · Nicholas
Quoted 43 lines · Andrey Grodzovsky

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

---
     drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
     1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -6
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
     			 */
     			abo = gem_to_amdgpu_bo(fb->obj[0]);
     			r = amdgpu_bo_reserve(abo, true);
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
     				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4822

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
     			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 

Is it safe that we're just continuing like this? It's probably better to just unreserve the buffer and continue to the next plane, no?

Nicholas Kazlauskas

As far as I see it should be safe as you are simply flipping to a buffer for which rendering hasn't finished (or stack actually in this case) so you might see visual corruption but that the least of your problems if after 5s the BO still not finalized for presentation, the system is already probably in very bad shape. Also, in case we do want to  do error handling we should also take care of  amdgpu_bo_reserve failure just before that.

Quoted 3 lines

Andrey

Yeah, I guess this whole blocks needs to be cleaned up in that case. This is a good first step at least. Technically reservation_object_wait_timeout_rcu will return < 0 when it's been interrupted too as an error code but I guess that will just be silently ignored here.

Quoted 5 lines

If you want you can change the condition to:

if (unlikely(r >= 0))
DRM_ERROR("Waiting for FB fence failed: id=%d res=%d\n",
plane->id, r);

Note that reservation_object_wait_timeout_rcu has a flag 'bool intr: if true, do interruptible wait', we set it to false since the code in case of flip runs form the kernel worker thread and not from IOCTL meaning we are not in user mode context and hence are not going to recieve user signals (cannot be interrupted). So the only values we can recieve here are either 0 for time out or val > 0 for wait that completed before time out value.

Andrey

Quoted 4 lines

But with or without that change this patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 4831d6dd-ac93-de4f-cb36-0ad14406d5e4-5C7GfCeVMHo@public.gmane.org

Reviewed-by Nicholas Kazlauskas
#10 lore raw
Quoted 87 lines · Andrey
Quoted 70 lines · Nicholas
Quoted 60 lines · Andrey
Quoted 44 lines · Nicholas
Quoted 43 lines · Andrey Grodzovsky

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

---
      drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
      1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -6
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
      			 */
      			abo = gem_to_amdgpu_bo(fb->obj[0]);
      			r = amdgpu_bo_reserve(abo, true);
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
      				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4822

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
      			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 

Is it safe that we're just continuing like this? It's probably better to just unreserve the buffer and continue to the next plane, no?

Nicholas Kazlauskas

As far as I see it should be safe as you are simply flipping to a buffer for which rendering hasn't finished (or stack actually in this case) so you might see visual corruption but that the least of your problems if after 5s the BO still not finalized for presentation, the system is already probably in very bad shape. Also, in case we do want to  do error handling we should also take care of  amdgpu_bo_reserve failure just before that.

Quoted 3 lines

Andrey

Yeah, I guess this whole blocks needs to be cleaned up in that case. This is a good first step at least. Technically reservation_object_wait_timeout_rcu will return < 0 when it's been interrupted too as an error code but I guess that will just be silently ignored here.

Quoted 5 lines

If you want you can change the condition to:

if (unlikely(r >= 0))
DRM_ERROR("Waiting for FB fence failed: id=%d res=%d\n",
plane->id, r);

Note that reservation_object_wait_timeout_rcu has a flag 'bool intr: if true, do interruptible wait', we set it to false since the code in case of flip runs form the kernel worker thread and not from IOCTL meaning we are not in user mode context and hence are not going to recieve user signals (cannot be interrupted). So the only values we can recieve here are either 0 for time out or val > 0 for wait that completed before time out value.

Quoted 1 line

Andrey

Oh, right.

This patch is good as-is then.

Quoted 10 lines
Quoted 5 lines

But with or without that change this patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw
In reply to a message not in the archive

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 11 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++------
  1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4804

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
  			 */
  			abo = gem_to_amdgpu_bo(fb->obj[0]);
  			r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -3
-			if (unlikely(r != 0)) {
+			if (unlikely(r != 0))
  				DRM_ERROR("failed to reserve buffer before flip\n");
-				WARN_ON(1);
-			}
 

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4814

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -3
-			/* Wait for all fences on this FB */
-			WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
-										    MAX_SCHEDULE_TIMEOUT) < 0);
+			/*
+			 * Wait for all fences on this FB. Do limited wait to avoid
+			 * deadlock during GPU reset when this fence will not signal
+			 * but we hold reservation lock for the BO.
+			 */
+			r = reservation_object_wait_timeout_rcu(abo->tbo.resv,
+								true, false,

Does this waiting happen in a work item or process context? If it's process context we should actually try to wait interruptible here.

Regards,
Christian.

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 4822

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -0
+								msecs_to_jiffies(5000));
+			if (unlikely(r == 0))
+				DRM_ERROR("Waiting for fences timed out.");
+
+
 
  			amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 6d7c7f89-be6e-6ecb-f0ee-b6e1e7256fa0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#13 lore raw
Quoted 19 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 7 lines

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------

  1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 14 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct 
 drm_atomic_state *state,
                */
               abo = gem_to_amdgpu_bo(fb->obj[0]);
               r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

Quoted 19 lines
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -3
-            if (unlikely(r != 0)) {
+            if (unlikely(r != 0))
                   DRM_ERROR("failed to reserve buffer before flip\n");
-                WARN_ON(1);
-            }

  -            /* Wait for all fences on this FB */
- WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false,
- MAX_SCHEDULE_TIMEOUT) < 0);

Quoted 8 lines

+            /*
+             * Wait for all fences on this FB. Do limited wait to avoid +             * deadlock during GPU reset when this fence will not signal
+             * but we hold reservation lock for the BO.
+             */
+            r = reservation_object_wait_timeout_rcu(abo->tbo.resv, +                                true, false,

Quoted 2 lines

Does this waiting happen in a work item or process context? If it's process context we should actually try to wait interruptible here.

Work item only.

Andrey

Quoted 11 lines

Regards,
Christian.

Quoted 6 lines

+ msecs_to_jiffies(5000));
+            if (unlikely(r == 0))
+                DRM_ERROR("Waiting for fences timed out.");

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
+
+

                amdgpu_bo_get_tiling_flags(abo, &tiling_flags);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): cdab804c-a280-68f8-c202-c52ce4e49cab-5C7GfCeVMHo@public.gmane.org

#15 lore raw
Quoted 36 lines · Andrey
Quoted 19 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 7 lines
---
   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
   1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 14 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                */
               abo = gem_to_amdgpu_bo(fb->obj[0]);
               r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

Nicholas Kazlauskas

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -5
-            if (unlikely(r != 0)) {
+            if (unlikely(r != 0))
                   DRM_ERROR("failed to reserve buffer before flip\n");
-                WARN_ON(1);
-            }
   -            /* Wait for all fences on this FB */
- WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true,
 false,
- MAX_SCHEDULE_TIMEOUT) < 0);
+            /*
+             * Wait for all fences on this FB. Do limited wait to avoid
+             * deadlock during GPU reset when this fence will not

signal
+             * but we hold reservation lock for the BO. +             */
+            r = reservation_object_wait_timeout_rcu(abo->tbo.resv, +                                true, false,

Quoted 20 lines
Quoted 2 lines

Does this waiting happen in a work item or process context? If it's process context we should actually try to wait interruptible here.

Work item only.

Andrey

Quoted 11 lines

Regards,
Christian.

Quoted 6 lines

+ msecs_to_jiffies(5000));
+            if (unlikely(r == 0))
+                DRM_ERROR("Waiting for fences timed out.");

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
+
+
                 amdgpu_bo_get_tiling_flags(abo, &tiling_flags);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 77ebbb4b-9241-e947-eb26-f18d6b808c37-5C7GfCeVMHo@public.gmane.org

#17 lore raw
Quoted 34 lines · Nicholas
Quoted 31 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
    drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
    1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                 */
                abo = gem_to_amdgpu_bo(fb->obj[0]);
                r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

Quoted 7 lines

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

Nicholas Kazlauskas

I don't think so, first of all we only hold the reservation during the wait for fences and then release it, secondly, BO reservation is a thin wrapper around ttm_bo_reserve which just protects the ttm BO internal structures and removes the BO from eviction list.

I think you can try to remove it and run some stress testing to see there is no visible corruption.

Andrey

Quoted 30 lines
Quoted 30 lines
Quoted 19 lines
Quoted 14 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -5
-            if (unlikely(r != 0)) {
+            if (unlikely(r != 0))
                    DRM_ERROR("failed to reserve buffer before flip\n");
-                WARN_ON(1);
-            }
    -            /* Wait for all fences on this FB */
- WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true,
 false,
- MAX_SCHEDULE_TIMEOUT) < 0);
+            /*
+             * Wait for all fences on this FB. Do limited wait to avoid
+             * deadlock during GPU reset when this fence will not
Quoted 5 lines

signal
+             * but we hold reservation lock for the BO. +             */
+            r = reservation_object_wait_timeout_rcu(abo->tbo.resv, +                                true, false,

Quoted 2 lines

Does this waiting happen in a work item or process context? If it's process context we should actually try to wait interruptible here.

Work item only.

Andrey

Quoted 3 lines

Regards,
Christian.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Quoted 6 lines

+ msecs_to_jiffies(5000));
+            if (unlikely(r == 0))
+                DRM_ERROR("Waiting for fences timed out.");

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
+
+
                  amdgpu_bo_get_tiling_flags(abo, &tiling_flags);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#18 lore raw
In reply to a message not in the archive
Quoted 36 lines · Nicholas
Quoted 35 lines · Andrey
Quoted 33 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 13 lines
---
   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
   1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                */
               abo = gem_to_amdgpu_bo(fb->obj[0]);
               r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 8 lines
Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): d330ee3b-e719-7f6b-a855-ebbbf01994a3-otUistvHUpPR7s880joybQ@public.gmane.org

#20 lore raw
Quoted 35 lines · Michel Dänzer
Quoted 34 lines · Nicholas
Quoted 33 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
    drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
    1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                 */
                abo = gem_to_amdgpu_bo(fb->obj[0]);
                r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

Quoted 7 lines
Quoted 5 lines

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 2 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): cc83fb8a-4249-376a-63ef-dc3b88a3c862-5C7GfCeVMHo@public.gmane.org

#22 lore raw
Quoted 42 lines · Andrey
Quoted 40 lines · Michel Dänzer
Quoted 39 lines · Nicholas
Quoted 31 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
     drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
     1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                  */
                 abo = gem_to_amdgpu_bo(fb->obj[0]);
                 r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

Quoted 11 lines
Quoted 2 lines

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 2 lines

I'm not worried about the buffer moving so much as I am about userspace changing the tiling flags by calling the IOCTL. Can that happen when it's pinned?

Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1eec4f49-2115-2633-8e3d-db891cf727d4-5C7GfCeVMHo@public.gmane.org

#24 lore raw
Quoted 55 lines · Nicholas
Quoted 42 lines · Andrey
Quoted 40 lines · Michel Dänzer
Quoted 39 lines · Nicholas
Quoted 31 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
     drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
     1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                  */
                 abo = gem_to_amdgpu_bo(fb->obj[0]);
                 r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

Quoted 11 lines
Quoted 2 lines

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 2 lines
Quoted 3 lines

I'm not worried about the buffer moving so much as I am about userspace changing the tiling flags by calling the IOCTL. Can that happen when it's pinned?

Even assuming it can theoretically, that would be a "doctor, it hurts if I do this" kind of userspace problem. :) Userspace has to set the correct tiling flags before submitting the flip, and then can't change them until the BO stops being scanned out.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#25 lore raw
In reply to a message not in the archive
Quoted 51 lines · Nicholas
Quoted 41 lines · Andrey
Quoted 40 lines · Michel Dänzer
Quoted 39 lines · Nicholas
Quoted 31 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
      drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
      1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                   */
                  abo = gem_to_amdgpu_bo(fb->obj[0]);
                  r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

Quoted 9 lines
Quoted 2 lines

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 1 line
Quoted 5 lines

I'm not worried about the buffer moving so much as I am about userspace changing the tiling flags by calling the IOCTL. Can that happen when it's pinned?

Nicholas Kazlauskas

In any case this has nothing to do with reserving the BO.

Andrey

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 42887844-6f67-5e2e-046c-13fd0525428b-5C7GfCeVMHo@public.gmane.org

#27 lore raw
Quoted 57 lines · Andrey
Quoted 55 lines · Nicholas
Quoted 41 lines · Andrey
Quoted 40 lines · Michel Dänzer
Quoted 39 lines · Nicholas
Quoted 31 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
       drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
       1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                    */
                   abo = gem_to_amdgpu_bo(fb->obj[0]);
                   r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

Quoted 2 lines

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

Quoted 9 lines
Quoted 2 lines

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 1 line

I'm not worried about the buffer moving so much as I am about userspace changing the tiling flags by calling the IOCTL. Can that happen when it's pinned?

Quoted 7 lines
Quoted 1 line

Nicholas Kazlauskas

In any case this has nothing to do with reserving the BO.

Andrey

Technically it does? See the function:

void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags)

{
	lockdep_assert_held(&bo->tbo.resv->lock.base);

	if (tiling_flags)
		*tiling_flags = bo->tiling_flags;
}

Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 4ecdbe95-cf1b-8178-8eb6-de27dbf6be3f-5C7GfCeVMHo@public.gmane.org

#29 lore raw
Quoted 64 lines · Nicholas
Quoted 50 lines · Andrey
Quoted 49 lines · Nicholas
Quoted 48 lines · Andrey
Quoted 35 lines · Michel Dänzer
Quoted 34 lines · Nicholas
Quoted 33 lines · Andrey
Quoted 17 lines · Christian König

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
        drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
        1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                     */
                    abo = gem_to_amdgpu_bo(fb->obj[0]);
                    r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

Quoted 7 lines
Quoted 5 lines

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 10 lines
Quoted 5 lines

I'm not worried about the buffer moving so much as I am about userspace changing the tiling flags by calling the IOCTL. Can that happen when it's pinned?

Nicholas Kazlauskas

In any case this has nothing to do with reserving the BO.

Andrey

Technically it does? See the function:

void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags)

Quoted 8 lines
{
	lockdep_assert_held(&bo->tbo.resv->lock.base);

	if (tiling_flags)
		*tiling_flags = bo->tiling_flags;
}

Nicholas Kazlauskas

What I meant that it has nothing to do with this BO reservation in the flip code while waiting for fences. Seems it's dafe to remove it.

Andrey

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): de93512a-2fb8-55ec-85f2-9cb145cc2130-5C7GfCeVMHo@public.gmane.org

#31 lore raw

Am 14.02.19 um 20:03 schrieb Grodzovsky, Andrey:

Quoted 68 lines · Nicholas
Quoted 67 lines · Andrey
Quoted 50 lines · Nicholas
Quoted 49 lines · Andrey
Quoted 48 lines · Michel Dänzer
Quoted 35 lines · Nicholas
Quoted 34 lines · Andrey
Quoted 33 lines · Christian König
Quoted 17 lines

Am 13.02.19 um 19:58 schrieb Andrey Grodzovsky:

Quoted 7 lines

When ring hang happens amdgpu_dm_commit_planes during flip is holding the BO reserved and then stack waiting for fences to signal in reservation_object_wait_timeout_rcu (which won't signal because there was a hnag). Then when we try to shutdown display block during reset recovery from drm_atomic_helper_suspend we also try to reserve the BO from dm_plane_helper_cleanup_fb ending in deadlock.
Also remove useless WARN_ON

Well it is good that you pointed this out, but there are more problems than just waiting wile the BO is reserved here.

Quoted 6 lines
---
         drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19
+++++++++++++------
         1 file changed, 13 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct · line 4805

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index acc4ff8..f8dec36 100644
@@ -4802,14 +4802,21 @@ static void amdgpu_dm_commit_planes(struct
 drm_atomic_state *state,
                      */
                     abo = gem_to_amdgpu_bo(fb->obj[0]);
                     r = amdgpu_bo_reserve(abo, true);

Well why do we reserve the BO in the first place? As the name indicates reservation_object_wait_timeout_rcu() just uses rcu to wait for the BO to be idle, no need to actually reserve it at all.

That a good point, I honestly can't remember any more why it's here... It does look unnecessary given that we are not validating the BO here.

Quoted 7 lines
Quoted 5 lines

I think we reserve it to grab the tiling flags to update the plane address (and some other bits of the plane state with a patch I'm currently working on). I'm guessing that we still need the reservation so nothing else tries to grab it after it becomes idle, but I'm not overly familiar with that bit.

The BO is already pinned at this point, isn't it? That's enough to prevent it from moving, no reservation needed.

Yes, agree.

Andrey

Quoted 10 lines
Quoted 5 lines

I'm not worried about the buffer moving so much as I am about userspace changing the tiling flags by calling the IOCTL. Can that happen when it's pinned?

Nicholas Kazlauskas

In any case this has nothing to do with reserving the BO.

Andrey

Technically it does? See the function:

void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags)

{
	lockdep_assert_held(&bo->tbo.resv->lock.base);
Quoted 7 lines
Quoted 5 lines
	if (tiling_flags)
		*tiling_flags = bo->tiling_flags;
}

Nicholas Kazlauskas

What I meant that it has nothing to do with this BO reservation in the flip code while waiting for fences. Seems it's dafe to remove it.

Yeah, agree. That looks actually quite superfluous to me.

Following up on Michel's argument you would actually need to keep the BO reserved until the scanout is completed when you really want to prevent that the tilling flags don't change.

I would just completely drop that function and access bo->tilling_flags directly here.

Christian.

Quoted 8 lines

Andrey

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx