Skip to contentSkip to conversation

Support mclk switching when monitors are in sync

PATCH In review Alex Deucher 2 participants 7 messages Aug 22, 2019 4 messages not in the archive

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

cover Support mclk switching when monitors are in sync

This patch set enables mclk switching with multiple monitors when all monitors are sync. Normally mclk switching is not available with multiple monitors because the vblank timing does not line up. However, if the timing is identical, the display driver can sync up the displays in some cases. Check for these cases and allow mclk switch when possible.

Alex Deucher (3):
drm/amdgpu/powerplay/smu7: enable mclk switching if monitors are
synced
drm/amdgpu/powerplay/vega10: enable mclk switching if monitors are
synced
drm/amd/display: update bw_calcs to take pipe sync into account (v2)

 .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 49 ++++++++++++++++++-
 .../gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  |  7 +--
 .../drm/amd/powerplay/hwmgr/vega10_hwmgr.c    |  3 +-
 3 files changed, 53 insertions(+), 6 deletions(-)
Signature · 6 lines
2.20.1

_______________________________________________
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): 20190822153645.3296-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/3 drm/amdgpu/powerplay/smu7: enable mclk switching if monitors are synced

If DC has synced the displays, we can enable mclk switching to save power.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +4 -3
index 3c1084de5d59..34f95e0e3ea4 100644
@@ -2956,9 +2956,10 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
 	if (hwmgr->display_config->num_display == 0)
 		disable_mclk_switching = false;
 	else
-		disable_mclk_switching = ((1 < hwmgr->display_config->num_display) ||
-					  disable_mclk_switching_for_frame_lock ||
-					  smu7_vblank_too_short(hwmgr, hwmgr->display_config->min_vblank_time));
+		disable_mclk_switching = ((1 < hwmgr->display_config->num_display) &&
+					  !hwmgr->display_config->multi_monitor_in_sync) ||
+			disable_mclk_switching_for_frame_lock ||
+			smu7_vblank_too_short(hwmgr, hwmgr->display_config->min_vblank_time);
 
 	sclk = smu7_ps->performance_levels[0].engine_clock;
 	mclk = smu7_ps->performance_levels[0].memory_clock;
Signature · 6 lines
2.20.1

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

PATCH 2/3 drm/amdgpu/powerplay/vega10: enable mclk switching if monitors are synced

In reply to a message not in the archive

If DC has synced the displays, we can enable mclk switching to save power.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +2 -1
index 948c54cb9c5d..d08493b67b67 100644
@@ -3220,7 +3220,8 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
 	if (hwmgr->display_config->num_display == 0)
 		disable_mclk_switching = false;
 	else
-		disable_mclk_switching = (hwmgr->display_config->num_display > 1) ||
+		disable_mclk_switching = ((1 < hwmgr->display_config->num_display) &&
+					  !hwmgr->display_config->multi_monitor_in_sync) ||
 			disable_mclk_switching_for_frame_lock ||
 			disable_mclk_switching_for_vr ||
 			force_mclk_high;
Signature · 6 lines
2.20.1

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

PATCH 3/3 drm/amd/display: update bw_calcs to take pipe sync into account (v2)

In reply to a message not in the archive

Properly set all_displays_in_sync so that when the data is propagated to powerplay, it's set properly and we can enable mclk switching when all monitors are in sync.

v2: fix logic, clean up

---
 .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 49 ++++++++++++++++++-
 1 file changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +47 -2
index 9f12e21f8b9b..8d904647fb0f 100644
@@ -25,6 +25,7 @@
 
 #include <linux/slab.h>
 
+#include "resource.h"
 #include "dm_services.h"
 #include "dce_calcs.h"
 #include "dc.h"
@@ -2977,6 +2978,50 @@ static void populate_initial_data(
 	data->number_of_displays = num_displays;
 }
 
+static bool all_displays_in_sync(const struct pipe_ctx pipe[],
+				 int pipe_count,
+				 uint32_t number_of_displays)
+{
+	const struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL };
+	int group_size = 1;
+	int i, j;
+
+	for (i = 0; i < pipe_count; i++) {
+		if (!pipe[i].stream)
+			continue;
+
+		unsynced_pipes[i] = &pipe[i];
+	}
+
+	for (i = 0; i < pipe_count; i++) {
+		const struct pipe_ctx *pipe_set[MAX_PIPES];
+
+		if (!unsynced_pipes[i])
+			continue;
+
+		pipe_set[0] = unsynced_pipes[i];
+		unsynced_pipes[i] = NULL;
+
+		/* Add tg to the set, search rest of the tg's for ones with
+		 * same timing, add all tgs with same timing to the group
+		 */
+		for (j = i + 1; j < pipe_count; j++) {
+			if (!unsynced_pipes[j])
+				continue;
+
+			if (resource_are_streams_timing_synchronizable(
+					unsynced_pipes[j]->stream,
+					pipe_set[0]->stream)) {
+				pipe_set[group_size] = unsynced_pipes[j];
+				unsynced_pipes[j] = NULL;
+				group_size++;
+			}
+		}
+	}
+
+	return (group_size == number_of_displays) ? true : false;
+}
+
 /**
  * Return:
  *	true -	Display(s) configuration supported.
@@ -2998,8 +3043,8 @@ bool bw_calcs(struct dc_context *ctx,
 
 	populate_initial_data(pipe, pipe_count, data);
 
-	/*TODO: this should be taken out calcs output and assigned during timing sync for pplib use*/
-	calcs_output->all_displays_in_sync = false;
+	calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count,
+								  data->number_of_displays);
 
 	if (data->number_of_displays != 0) {
 		uint8_t yclk_lvl, sclk_lvl;
Signature · 6 lines
2.20.1

_______________________________________________
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): 20190822153645.3296-4-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#6 lore raw

Re: [PATCH 3/3] drm/amd/display: update bw_calcs to take pipe sync into account (v2)

Quoted 27 lines · Alex Deucher

Properly set all_displays_in_sync so that when the data is propagated to powerplay, it's set properly and we can enable mclk switching when all monitors are in sync.

v2: fix logic, clean up

---
  .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 49 ++++++++++++++++++-
  1 file changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +1 -0
index 9f12e21f8b9b..8d904647fb0f 100644
@@ -25,6 +25,7 @@
 
  #include <linux/slab.h>
 
+#include "resource.h"
  #include "dm_services.h"
  #include "dce_calcs.h"
  #include "dc.h"
@@ -2977,6 +2978,50 @@ static void populate_initial_data(
  	data->number_of_displays = num_displays;
  }
 

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c static void populate_initial_data( · line 2990

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +10 -0
+static bool all_displays_in_sync(const struct pipe_ctx pipe[],
+				 int pipe_count,
+				 uint32_t number_of_displays)
+{
+	const struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL };
+	int group_size = 1;
+	int i, j;
+
+	for (i = 0; i < pipe_count; i++) {
+		if (!pipe[i].stream)

This bit differs from program_timing_sync, but since this is for dce and we don't do pipe split or MPO I think it's probably fine that you're not checking top_pipe here.

Wouldn't hurt to have that logic here though.

Quoted 22 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +22 -0
+			continue;
+
+		unsynced_pipes[i] = &pipe[i];
+	}
+
+	for (i = 0; i < pipe_count; i++) {
+		const struct pipe_ctx *pipe_set[MAX_PIPES];
+
+		if (!unsynced_pipes[i])
+			continue;
+
+		pipe_set[0] = unsynced_pipes[i];
+		unsynced_pipes[i] = NULL;
+
+		/* Add tg to the set, search rest of the tg's for ones with
+		 * same timing, add all tgs with same timing to the group
+		 */
+		for (j = i + 1; j < pipe_count; j++) {
+			if (!unsynced_pipes[j])
+				continue;
+
+			if (resource_are_streams_timing_synchronizable(

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c static void populate_initial_data( · line 3022

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +10 -0
+					unsynced_pipes[j]->stream,
+					pipe_set[0]->stream)) {
+				pipe_set[group_size] = unsynced_pipes[j];
+				unsynced_pipes[j] = NULL;
+				group_size++;
+			}
+		}
+	}
+
+	return (group_size == number_of_displays) ? true : false;

I think this logic is functional but it looks incorrect at first glance because group_size doesn't get reset. What ends up happening is the first pipe of each group doesn't get added to group_size.

I feel that this would be more clear as:

static bool all_displays_in_sync(const struct pipe_ctx pipe[], int pipe_count)

{
	const struct pipe_ctx *active_pipes[MAX_PIPES];
	int i, num_active_pipes = 0;

	for (i = 0; i < pipe_count; i++) {
		if (!pipe[i].stream || pipe[i].top_pipe)
			continue;

		active_pipes[num_active_pipes++] = &pipe[i];
	}

	if (!num_active_pipes)
		return false;

	for (i = 1; i < num_active_pipes; ++i)
		if (!resource_are_streams_timing_synchronizable(
			    active_pipes[0]->stream, active_pipes[i]->stream))
			return false;

	return true;
}

But I haven't tested this.

Nicholas Kazlauskas

Quoted 7 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2 -0
+}
+
  /**
   * Return:
   *	true -	Display(s) configuration supported.

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c bool bw_calcs(struct dc_context *ctx, · line 3050

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2 -2
@@ -2998,8 +3043,8 @@ bool bw_calcs(struct dc_context *ctx,
 
  	populate_initial_data(pipe, pipe_count, data);
 
-	/*TODO: this should be taken out calcs output and assigned during timing sync for pplib use*/
-	calcs_output->all_displays_in_sync = false;
+	calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count,
+								  data->number_of_displays);
 
  	if (data->number_of_displays != 0) {
  		uint8_t yclk_lvl, sclk_lvl;

_______________________________________________
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): 6c011b85-27c8-4ff5-12b5-4d034878c916-5C7GfCeVMHo@public.gmane.org

#8 lore raw

Re: [PATCH 3/3] drm/amd/display: update bw_calcs to take pipe sync into account (v2)

Quoted 44 lines · Nicholas
Quoted 27 lines · Alex Deucher

Properly set all_displays_in_sync so that when the data is propagated to powerplay, it's set properly and we can enable mclk switching when all monitors are in sync.

v2: fix logic, clean up

---
  .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 49 ++++++++++++++++++-
  1 file changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +1 -0
index 9f12e21f8b9b..8d904647fb0f 100644
@@ -25,6 +25,7 @@
 
  #include <linux/slab.h>
 
+#include "resource.h"
  #include "dm_services.h"
  #include "dce_calcs.h"
  #include "dc.h"
@@ -2977,6 +2978,50 @@ static void populate_initial_data(
      data->number_of_displays = num_displays;
  }
 

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c static void populate_initial_data( · line 2990

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +10 -0
+static bool all_displays_in_sync(const struct pipe_ctx pipe[],
+                              int pipe_count,
+                              uint32_t number_of_displays)
+{
+     const struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL };
+     int group_size = 1;
+     int i, j;
+
+     for (i = 0; i < pipe_count; i++) {
+             if (!pipe[i].stream)

This bit differs from program_timing_sync, but since this is for dce and we don't do pipe split or MPO I think it's probably fine that you're not checking top_pipe here.

Quoted 2 lines

Wouldn't hurt to have that logic here though.

I had checked for top_pipe here originally, but it was always NULL so unsynced_pipes never got populated. Maybe that is not populated properly at this point?

Quoted 55 lines
Quoted 22 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +22 -0
+                     continue;
+
+             unsynced_pipes[i] = &pipe[i];
+     }
+
+     for (i = 0; i < pipe_count; i++) {
+             const struct pipe_ctx *pipe_set[MAX_PIPES];
+
+             if (!unsynced_pipes[i])
+                     continue;
+
+             pipe_set[0] = unsynced_pipes[i];
+             unsynced_pipes[i] = NULL;
+
+             /* Add tg to the set, search rest of the tg's for ones with
+              * same timing, add all tgs with same timing to the group
+              */
+             for (j = i + 1; j < pipe_count; j++) {
+                     if (!unsynced_pipes[j])
+                             continue;
+
+                     if (resource_are_streams_timing_synchronizable(

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c static void populate_initial_data( · line 3022

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +10 -0
+                                     unsynced_pipes[j]->stream,
+                                     pipe_set[0]->stream)) {
+                             pipe_set[group_size] = unsynced_pipes[j];
+                             unsynced_pipes[j] = NULL;
+                             group_size++;
+                     }
+             }
+     }
+
+     return (group_size == number_of_displays) ? true : false;

I think this logic is functional but it looks incorrect at first glance because group_size doesn't get reset. What ends up happening is the first pipe of each group doesn't get added to group_size.

I feel that this would be more clear as:

static bool all_displays_in_sync(const struct pipe_ctx pipe[], int pipe_count)

{
        const struct pipe_ctx *active_pipes[MAX_PIPES];
        int i, num_active_pipes = 0;

        for (i = 0; i < pipe_count; i++) {
                if (!pipe[i].stream || pipe[i].top_pipe)
                        continue;

                active_pipes[num_active_pipes++] = &pipe[i];
        }

        if (!num_active_pipes)
                return false;
Quoted 7 lines
        for (i = 1; i < num_active_pipes; ++i)
                if (!resource_are_streams_timing_synchronizable(
                            active_pipes[0]->stream, active_pipes[i]->stream))
                        return false;

        return true;
}

Yes, that's much cleaner. Thanks!

Alex

Quoted 15 lines

But I haven't tested this.

Nicholas Kazlauskas

Quoted 9 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2 -0
+}
+
  /**
   * Return:
   *  true -  Display(s) configuration supported.
@@ -2998,8 +3043,8 @@ bool bw_calcs(struct dc_context *ctx,
 
      populate_initial_data(pipe, pipe_count, data);
 
Quoted 9 lines

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c bool bw_calcs(struct dc_context *ctx, · line 3050

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2 -2
-     /*TODO: this should be taken out calcs output and assigned during timing sync for pplib use*/
-     calcs_output->all_displays_in_sync = false;
+     calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count,
+                                                               data->number_of_displays);
 
      if (data->number_of_displays != 0) {
              uint8_t yclk_lvl, sclk_lvl;

_______________________________________________
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): CADnq5_MmDXmchA=WoQpKzkFp0+WpVDSOoBMqqo8pppB9ky_AvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw

Re: [PATCH 3/3] drm/amd/display: update bw_calcs to take pipe sync into account (v2)

Quoted 46 lines · Alex Deucher
Quoted 44 lines · Nicholas
Quoted 27 lines · Alex Deucher

Properly set all_displays_in_sync so that when the data is propagated to powerplay, it's set properly and we can enable mclk switching when all monitors are in sync.

v2: fix logic, clean up

---
   .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 49 ++++++++++++++++++-
   1 file changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +1 -0
index 9f12e21f8b9b..8d904647fb0f 100644
@@ -25,6 +25,7 @@
 
   #include <linux/slab.h>
 
+#include "resource.h"
   #include "dm_services.h"
   #include "dce_calcs.h"
   #include "dc.h"
@@ -2977,6 +2978,50 @@ static void populate_initial_data(
       data->number_of_displays = num_displays;
   }
 

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c static void populate_initial_data( · line 2990

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +10 -0
+static bool all_displays_in_sync(const struct pipe_ctx pipe[],
+                              int pipe_count,
+                              uint32_t number_of_displays)
+{
+     const struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL };
+     int group_size = 1;
+     int i, j;
+
+     for (i = 0; i < pipe_count; i++) {
+             if (!pipe[i].stream)

This bit differs from program_timing_sync, but since this is for dce and we don't do pipe split or MPO I think it's probably fine that you're not checking top_pipe here.

Quoted 6 lines
Quoted 2 lines

Wouldn't hurt to have that logic here though.

I had checked for top_pipe here originally, but it was always NULL so unsynced_pipes never got populated. Maybe that is not populated properly at this point?

The presence of a top_pipe on a pipe indicates that the pipe is part of a blending chain. A NULL top_pipe value indicates that the current pipe is the top of the chain.

It should be NULL for all pipes on DCE ASICs.

Nicholas Kazlauskas

Quoted 61 lines
Quoted 61 lines
Quoted 23 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +22 -0
+                     continue;
+
+             unsynced_pipes[i] = &pipe[i];
+     }
+
+     for (i = 0; i < pipe_count; i++) {
+             const struct pipe_ctx *pipe_set[MAX_PIPES];
+
+             if (!unsynced_pipes[i])
+                     continue;
+
+             pipe_set[0] = unsynced_pipes[i];
+             unsynced_pipes[i] = NULL;
+
+             /* Add tg to the set, search rest of the tg's for ones with
+              * same timing, add all tgs with same timing to the group
+              */
+             for (j = i + 1; j < pipe_count; j++) {
+                     if (!unsynced_pipes[j])
+                             continue;
+
+                     if (resource_are_streams_timing_synchronizable(

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c static void populate_initial_data( · line 3022

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +10 -0
+                                     unsynced_pipes[j]->stream,
+                                     pipe_set[0]->stream)) {
+                             pipe_set[group_size] = unsynced_pipes[j];
+                             unsynced_pipes[j] = NULL;
+                             group_size++;
+                     }
+             }
+     }
+
+     return (group_size == number_of_displays) ? true : false;

I think this logic is functional but it looks incorrect at first glance because group_size doesn't get reset. What ends up happening is the first pipe of each group doesn't get added to group_size.

I feel that this would be more clear as:

static bool all_displays_in_sync(const struct pipe_ctx pipe[], int pipe_count)

{
         const struct pipe_ctx *active_pipes[MAX_PIPES];
         int i, num_active_pipes = 0;

         for (i = 0; i < pipe_count; i++) {
                 if (!pipe[i].stream || pipe[i].top_pipe)
                         continue;

                 active_pipes[num_active_pipes++] = &pipe[i];
         }

         if (!num_active_pipes)
                 return false;

         for (i = 1; i < num_active_pipes; ++i)
                 if (!resource_are_streams_timing_synchronizable(
                             active_pipes[0]->stream, active_pipes[i]->stream))
                         return false;
Quoted 31 lines
Quoted 2 lines
         return true;
}

Yes, that's much cleaner. Thanks!

Alex

Quoted 24 lines

But I haven't tested this.

Nicholas Kazlauskas

Quoted 17 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +4 -2
+}
+
   /**
    * Return:
    *  true -  Display(s) configuration supported.
@@ -2998,8 +3043,8 @@ bool bw_calcs(struct dc_context *ctx,
 
       populate_initial_data(pipe, pipe_count, data);
 
-     /*TODO: this should be taken out calcs output and assigned during timing sync for pplib use*/
-     calcs_output->all_displays_in_sync = false;
+     calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count,
+                                                               data->number_of_displays);
 
       if (data->number_of_displays != 0) {
               uint8_t yclk_lvl, sclk_lvl;

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