Skip to contentSkip to conversation

drm/amdgpu/display: fix logic inversion in program_timing_sync()

PATCH In review Alex Deucher 2 participants 7 messages Jan 10, 2020 – May 28, 2020

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

PATCH 1/1 drm/amdgpu/display: fix logic inversion in program_timing_sync()

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -2
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
 				status->timing_sync_info.master = false;
 
 		}
-		/* remove any other pipes with plane as they have already been synced */
+		/* remove any other pipes without plane as they have already been synced */
 		for (j = j + 1; j < group_size; j++) {
-			if (pipe_set[j]->plane_state) {
+			if (!pipe_set[j]->plane_state) {
 				group_size--;
 				pipe_set[j] = pipe_set[group_size];
 				j--;
Signature · 6 lines
2.24.1

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

Ping?

Quoted 28 lines · Alex Deucher

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -3
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
                                status->timing_sync_info.master = false;
 
                }
-               /* remove any other pipes with plane as they have already been synced */
+               /* remove any other pipes without plane as they have already been synced */
                for (j = j + 1; j < group_size; j++) {
-                       if (pipe_set[j]->plane_state) {
+                       if (!pipe_set[j]->plane_state) {
                                group_size--;
                                pipe_set[j] = pipe_set[group_size];
                                j--;
--
Quoted 2 lines

2.24.1

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

#2 lore raw

Comments inline.

Quoted 21 lines · Alex Deucher

Ping?

Quoted 18 lines · Alex Deucher

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
                                 status->timing_sync_info.master = false;
 
Quoted 3 lines

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1006

Quoted 3 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -1
                 }
-               /* remove any other pipes with plane as they have already been synced */
+               /* remove any other pipes without plane as they have already been synced */

This took a while to wrap my head around but I think I understand what this was originally trying to do.

The original logic seems to have been checking for blanked streams and trying to remove anything that was blanked from the group to try and avoid having to enable timing synchronization.

However, the logic for blanked is *not* the same as having a plane_state. Technically you can drive an OTG without anything connected in the front end and it'll just draw out the back color - which is distinct from having the OTG be blanked.

The problem is really this iteration below:

Quoted 1 line

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1007

Quoted 1 line
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
                 for (j = j + 1; j < group_size; j++) {

There could still be pipes in here (depending on the ordering) that have planes and could be synchronized with the master OTG. I think starting at j + 1 is a mistake for this logic as well.

I wonder if we can just drop this loop altogether. If we add planes or unblank the OTG later then we'll still want the synchronization.

Dymtro, Wenjing - feel free to correct my understanding if I'm mistaken about this.

Regards,
Nicholas Kazlauskas

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -2
-                       if (pipe_set[j]->plane_state) {
+                       if (!pipe_set[j]->plane_state) {
                                 group_size--;
                                 pipe_set[j] = pipe_set[group_size];
                                 j--;
--

2.24.1

Quoted 5 lines

_______________________________________________
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

#3 lore raw
Quoted 49 lines · Nicholas

Comments inline.

Quoted 21 lines · Alex Deucher

Ping?

Quoted 18 lines · Alex Deucher

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
                                 status->timing_sync_info.master = false;
 
Quoted 3 lines

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1006

Quoted 3 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -1
                 }
-               /* remove any other pipes with plane as they have already been synced */
+               /* remove any other pipes without plane as they have already been synced */

This took a while to wrap my head around but I think I understand what this was originally trying to do.

The original logic seems to have been checking for blanked streams and trying to remove anything that was blanked from the group to try and avoid having to enable timing synchronization.

However, the logic for blanked is *not* the same as having a plane_state. Technically you can drive an OTG without anything connected in the front end and it'll just draw out the back color - which is distinct from having the OTG be blanked.

The problem is really this iteration below:

Quoted 1 line

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1007

Quoted 1 line
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
                 for (j = j + 1; j < group_size; j++) {

There could still be pipes in here (depending on the ordering) that have planes and could be synchronized with the master OTG. I think starting at j + 1 is a mistake for this logic as well.

Quoted 5 lines

I wonder if we can just drop this loop altogether. If we add planes or unblank the OTG later then we'll still want the synchronization.

Dymtro, Wenjing - feel free to correct my understanding if I'm mistaken about this.

Ping? Any thoughts on this? It would be nice to get this fixed.

Alex

Quoted 18 lines

Regards,
Nicholas Kazlauskas

Quoted 13 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -2
-                       if (pipe_set[j]->plane_state) {
+                       if (!pipe_set[j]->plane_state) {
                                 group_size--;
                                 pipe_set[j] = pipe_set[group_size];
                                 j--;
--

2.24.1

_______________________________________________
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

#4 lore raw

Ping again?

Alex

Quoted 55 lines · Alex Deucher
Quoted 52 lines · Nicholas

Comments inline.

Quoted 21 lines · Alex Deucher

Ping?

Quoted 18 lines · Alex Deucher

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
                                 status->timing_sync_info.master = false;
 
Quoted 3 lines

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1006

Quoted 3 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -1
                 }
-               /* remove any other pipes with plane as they have already been synced */
+               /* remove any other pipes without plane as they have already been synced */

This took a while to wrap my head around but I think I understand what this was originally trying to do.

The original logic seems to have been checking for blanked streams and trying to remove anything that was blanked from the group to try and avoid having to enable timing synchronization.

However, the logic for blanked is *not* the same as having a plane_state. Technically you can drive an OTG without anything connected in the front end and it'll just draw out the back color - which is distinct from having the OTG be blanked.

The problem is really this iteration below:

Quoted 1 line

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1007

Quoted 1 line
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
                 for (j = j + 1; j < group_size; j++) {

There could still be pipes in here (depending on the ordering) that have planes and could be synchronized with the master OTG. I think starting at j + 1 is a mistake for this logic as well.

I wonder if we can just drop this loop altogether. If we add planes or unblank the OTG later then we'll still want the synchronization.

Quoted 26 lines
Quoted 2 lines

Dymtro, Wenjing - feel free to correct my understanding if I'm mistaken about this.

Ping? Any thoughts on this? It would be nice to get this fixed.

Alex

Quoted 18 lines

Regards,
Nicholas Kazlauskas

Quoted 13 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -2
-                       if (pipe_set[j]->plane_state) {
+                       if (!pipe_set[j]->plane_state) {
                                 group_size--;
                                 pipe_set[j] = pipe_set[group_size];
                                 j--;
--

2.24.1

_______________________________________________
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

#5 lore raw

Can we apply this for now until we can get further analysis on the actual root cause?

Alex

Quoted 87 lines · Alex Deucher

Ping again?

Alex

Quoted 81 lines · Alex Deucher
Quoted 49 lines · Nicholas

Comments inline.

Quoted 21 lines · Alex Deucher

Ping?

Quoted 18 lines · Alex Deucher

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
                                 status->timing_sync_info.master = false;
 
Quoted 3 lines

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1006

Quoted 3 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -1
                 }
-               /* remove any other pipes with plane as they have already been synced */
+               /* remove any other pipes without plane as they have already been synced */

This took a while to wrap my head around but I think I understand what this was originally trying to do.

The original logic seems to have been checking for blanked streams and trying to remove anything that was blanked from the group to try and avoid having to enable timing synchronization.

However, the logic for blanked is *not* the same as having a plane_state. Technically you can drive an OTG without anything connected in the front end and it'll just draw out the back color - which is distinct from having the OTG be blanked.

The problem is really this iteration below:

Quoted 1 line

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1007

Quoted 1 line
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
                 for (j = j + 1; j < group_size; j++) {

There could still be pipes in here (depending on the ordering) that have planes and could be synchronized with the master OTG. I think starting at j + 1 is a mistake for this logic as well.

Quoted 5 lines

I wonder if we can just drop this loop altogether. If we add planes or unblank the OTG later then we'll still want the synchronization.

Dymtro, Wenjing - feel free to correct my understanding if I'm mistaken about this.

Ping? Any thoughts on this? It would be nice to get this fixed.

Alex

Quoted 18 lines

Regards,
Nicholas Kazlauskas

Quoted 13 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -2
-                       if (pipe_set[j]->plane_state) {
+                       if (!pipe_set[j]->plane_state) {
                                 group_size--;
                                 pipe_set[j] = pipe_set[group_size];
                                 j--;
--

2.24.1

_______________________________________________
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

#6 lore raw

I still think we should just drop the reduction loop.

The problem with checking plane_state at all is that this logic will always be broken - plane_state isn't a good indicator of whether the stream is blanked or not since we can leave an OTG running with no planes at all while unblanked.

Regards,
Nicholas Kazlauskas

Quoted 93 lines · Alex Deucher

Can we apply this for now until we can get further analysis on the actual root cause?

Alex

Quoted 87 lines · Alex Deucher

Ping again?

Alex

Quoted 81 lines · Alex Deucher
Quoted 49 lines · Nicholas

Comments inline.

Quoted 21 lines · Alex Deucher

Ping?

Quoted 18 lines · Alex Deucher

It looks like we should be reducing the group size when we don't have a plane rather than when we do.

Fixes 5fc0cbfad45648 ("drm/amd/display: determine if a pipe is synced by plane state")
---
   drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
index 3d89904003f0..01b27726d9c5 100644
@@ -1003,9 +1003,9 @@ static void program_timing_sync(
                                  status->timing_sync_info.master = false;
 
Quoted 3 lines

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1006

Quoted 3 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -1
                  }
-               /* remove any other pipes with plane as they have already been synced */
+               /* remove any other pipes without plane as they have already been synced */

This took a while to wrap my head around but I think I understand what this was originally trying to do.

The original logic seems to have been checking for blanked streams and trying to remove anything that was blanked from the group to try and avoid having to enable timing synchronization.

However, the logic for blanked is *not* the same as having a plane_state. Technically you can drive an OTG without anything connected in the front end and it'll just draw out the back color - which is distinct from having the OTG be blanked.

The problem is really this iteration below:

Quoted 1 line

drivers/gpu/drm/amd/display/dc/core/dc.c static void program_timing_sync( · line 1007

Quoted 1 line
drivers/gpu/drm/amd/display/dc/core/dc.c +0 -0
                  for (j = j + 1; j < group_size; j++) {

There could still be pipes in here (depending on the ordering) that have planes and could be synchronized with the master OTG. I think starting at j + 1 is a mistake for this logic as well.

Quoted 5 lines

I wonder if we can just drop this loop altogether. If we add planes or unblank the OTG later then we'll still want the synchronization.

Dymtro, Wenjing - feel free to correct my understanding if I'm mistaken about this.

Ping? Any thoughts on this? It would be nice to get this fixed.

Alex

Quoted 18 lines

Regards,
Nicholas Kazlauskas

Quoted 13 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -2
-                       if (pipe_set[j]->plane_state) {
+                       if (!pipe_set[j]->plane_state) {
                                  group_size--;
                                  pipe_set[j] = pipe_set[group_size];
                                  j--;
--

2.24.1

_______________________________________________
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