Skip to contentSkip to conversation

Support mclk switching when monitors are in sync (v2)

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

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

cover Support mclk switching when monitors are in sync (v2)

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 (4):
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 (v3) drm/amdgpu/display: add flag for multi-display mclk switching

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  3 ++
 .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 33 +++++++++++++++++--
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 +-
 drivers/gpu/drm/amd/include/amd_shared.h      |  1 +
 .../gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  |  7 ++--
 .../drm/amd/powerplay/hwmgr/vega10_hwmgr.c    |  3 +-
 6 files changed, 42 insertions(+), 7 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): 20190822193050.3107-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/4 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/4 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/4 drm/amd/display: update bw_calcs to take pipe sync into account (v3)

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
v3: check for blending chains, simplify logic

---
 .../gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 30 +++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +28 -2
index 9f12e21f8b9b..eca681d9d7f5 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,32 @@ 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)
+{
+	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;
+}
+
 /**
  * Return:
  *	true -	Display(s) configuration supported.
@@ -2998,8 +3025,7 @@ 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);
 
 	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
#5 lore raw

PATCH 4/4 drm/amdgpu/display: add flag for multi-display mclk switching

In reply to a message not in the archive

Add a dcfeaturemask flag for mclk switching. Disable by default; enable once the feature has seen more testing.

Set amdgpu.dcfeaturemask=2 on the kernel command line in grub to enable this.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
 drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 5 ++++-
 drivers/gpu/drm/amd/display/dc/dc.h               | 2 +-
 drivers/gpu/drm/amd/include/amd_shared.h          | 1 +
 4 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
index 45298269744d..cb86ccf48bd9 100644
@@ -694,6 +694,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 	if (amdgpu_dc_feature_mask & DC_FBC_MASK)
 		init_data.flags.fbc_support = true;
 
+	if (amdgpu_dc_feature_mask & DC_MULTI_MON_PP_MCLK_SWITCH_MASK)
+		init_data.flags.multi_mon_pp_mclk_switch = true;
+
 	init_data.flags.power_down_display_on_boot = true;
 
 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +4 -1
index eca681d9d7f5..a1d49256fab7 100644
@@ -3025,7 +3025,10 @@ bool bw_calcs(struct dc_context *ctx,
 
 	populate_initial_data(pipe, pipe_count, data);
 
-	calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count);
+	if (ctx->dc->config.multi_mon_pp_mclk_switch)
+		calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count);
+	else
+		calcs_output->all_displays_in_sync = false;
 
 	if (data->number_of_displays != 0) {
 		uint8_t yclk_lvl, sclk_lvl;
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
index 3ef269f82478..5d4a2a9228f0 100644
@@ -220,7 +220,7 @@ struct dc_config {
 	bool power_down_display_on_boot;
 	bool edp_not_connected;
 	bool forced_clocks;
-
+	bool multi_mon_pp_mclk_switch;
 };
 
 enum visual_confirm {
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
index a0a7211438f2..8889aaceec60 100644
@@ -142,6 +142,7 @@ enum PP_FEATURE_MASK {
 
 enum DC_FEATURE_MASK {
 	DC_FBC_MASK = 0x1,
+	DC_MULTI_MON_PP_MCLK_SWITCH_MASK = 0x2,
 };
 
 enum amd_dpm_forced_level;
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): 20190822193050.3107-5-alexander.deucher-5C7GfCeVMHo@public.gmane.org

Reviewed-by Nicholas Kazlauskas
#7 lore raw

Re: [PATCH 4/4] drm/amdgpu/display: add flag for multi-display mclk switching

Quoted 7 lines · Alex Deucher

Add a dcfeaturemask flag for mclk switching. Disable by default; enable once the feature has seen more testing.

Set amdgpu.dcfeaturemask=2 on the kernel command line in grub to enable this.

Patches 3 and 4 are

Quoted 56 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
  drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 5 ++++-
  drivers/gpu/drm/amd/display/dc/dc.h               | 2 +-
  drivers/gpu/drm/amd/include/amd_shared.h          | 1 +
  4 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
index 45298269744d..cb86ccf48bd9 100644
@@ -694,6 +694,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
  	if (amdgpu_dc_feature_mask & DC_FBC_MASK)
  		init_data.flags.fbc_support = true;
 
+	if (amdgpu_dc_feature_mask & DC_MULTI_MON_PP_MCLK_SWITCH_MASK)
+		init_data.flags.multi_mon_pp_mclk_switch = true;
+
  	init_data.flags.power_down_display_on_boot = true;
 
  #ifdef CONFIG_DRM_AMD_DC_DCN2_0
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +4 -1
index eca681d9d7f5..a1d49256fab7 100644
@@ -3025,7 +3025,10 @@ bool bw_calcs(struct dc_context *ctx,
 
  	populate_initial_data(pipe, pipe_count, data);
 
-	calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count);
+	if (ctx->dc->config.multi_mon_pp_mclk_switch)
+		calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count);
+	else
+		calcs_output->all_displays_in_sync = false;
 
  	if (data->number_of_displays != 0) {
  		uint8_t yclk_lvl, sclk_lvl;
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
index 3ef269f82478..5d4a2a9228f0 100644
@@ -220,7 +220,7 @@ struct dc_config {
  	bool power_down_display_on_boot;
  	bool edp_not_connected;
  	bool forced_clocks;
-
+	bool multi_mon_pp_mclk_switch;
  };
 
  enum visual_confirm {
drivers/gpu/drm/amd/include/amd_shared.h +0 -0
index a0a7211438f2..8889aaceec60 100644

drivers/gpu/drm/amd/include/amd_shared.h enum PP_FEATURE_MASK { · line 148

Quoted 7 lines
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -142,6 +142,7 @@ enum PP_FEATURE_MASK {
 
  enum DC_FEATURE_MASK {
  	DC_FBC_MASK = 0x1,
+	DC_MULTI_MON_PP_MCLK_SWITCH_MASK = 0x2,
  };
 
  enum amd_dpm_forced_level;

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

#8 lore raw

RE: [PATCH 4/4] drm/amdgpu/display: add flag for multi-display mclk switching

In reply to a message not in the archive

Patch1, 2 are reviewed-by: Evan Quan <[email protected]> Patch 3,4 are acked-by: Evan Quan <[email protected]>

Quoted 89 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, August 23, 2019 3:31 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu/display: add flag for multi-display mclk switching

Add a dcfeaturemask flag for mclk switching. Disable by default; enable once the feature has seen more testing.

Set amdgpu.dcfeaturemask=2 on the kernel command line in grub to enable this.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c  | 5 ++++-
 drivers/gpu/drm/amd/display/dc/dc.h               | 2 +-
 drivers/gpu/drm/amd/include/amd_shared.h          | 1 +
 4 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
index 45298269744d..cb86ccf48bd9 100644
@@ -694,6 +694,9 @@ static int amdgpu_dm_init(struct amdgpu_device
 *adev)
 	if (amdgpu_dc_feature_mask & DC_FBC_MASK)
 		init_data.flags.fbc_support = true;
 
+	if (amdgpu_dc_feature_mask &
 DC_MULTI_MON_PP_MCLK_SWITCH_MASK)
+		init_data.flags.multi_mon_pp_mclk_switch = true;
+
 	init_data.flags.power_down_display_on_boot = true;

#ifdef CONFIG_DRM_AMD_DC_DCN2_0

drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +4 -1
index eca681d9d7f5..a1d49256fab7 100644
@@ -3025,7 +3025,10 @@ bool bw_calcs(struct dc_context *ctx,
 
 	populate_initial_data(pipe, pipe_count, data);
 
-	calcs_output->all_displays_in_sync = all_displays_in_sync(pipe,
 pipe_count);
+	if (ctx->dc->config.multi_mon_pp_mclk_switch)
+		calcs_output->all_displays_in_sync =
 all_displays_in_sync(pipe, pipe_count);
+	else
+		calcs_output->all_displays_in_sync = false;
 
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +0 -0
 	if (data->number_of_displays != 0) {
 		uint8_t yclk_lvl, sclk_lvl;
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
index 3ef269f82478..5d4a2a9228f0 100644
@@ -220,7 +220,7 @@ struct dc_config {
 	bool power_down_display_on_boot;
 	bool edp_not_connected;
 	bool forced_clocks;
-
+	bool multi_mon_pp_mclk_switch;
 };
 
 enum visual_confirm {
drivers/gpu/drm/amd/include/amd_shared.h +1 -1
index a0a7211438f2..8889aaceec60 100644
@@ -142,6 +142,7 @@ enum PP_FEATURE_MASK {
 
 enum DC_FEATURE_MASK {
 	DC_FBC_MASK = 0x1,
+	DC_MULTI_MON_PP_MCLK_SWITCH_MASK = 0x2,
 };
 
 enum amd_dpm_forced_level;
--

2.20.1

Quoted 4 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