Skip to contentSkip to conversation

drm/amd: Introduce additional IPS debug flags

PATCH Superseded [email protected] 2 participants 7 messages Aug 16, 2024 – Aug 19, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/5 drm/amd: Introduce additional IPS debug flags

From: Leo Li <[email protected]>

[Why]

Idle power states (IPS) describe levels of power-gating within DCN. DM and DC is responsible for ensuring that we are out of IPS before any DCN programming happens. Any DCN programming while we're in IPS leads to undefined behavior (mostly hangs).

Because IPS intersects with all display features, the ability to disable IPS by default while ironing out the known issues is desired. However, disabing it completely will cause important features such as s0ix entry to fail.

Therefore, more granular IPS debug flags are desired.

[How]

Extend the dc debug mask bits to include the available list of IPS debug flags.

All the flags should work as documented, with the exception of IPS_DISABLE_DYNAMIC. It requires dm changes which will be done in later changes.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 ++
 drivers/gpu/drm/amd/include/amd_shared.h      | 59 ++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -0
index dd8353283bda3..a18ecf8607232 100644
@@ -1864,6 +1864,12 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
 	if (amdgpu_dc_debug_mask & DC_DISABLE_IPS)
 		init_data.flags.disable_ips = DMUB_IPS_DISABLE_ALL;
+	else if (amdgpu_dc_debug_mask & DC_DISABLE_IPS_DYNAMIC)
+		init_data.flags.disable_ips = DMUB_IPS_DISABLE_DYNAMIC;
+	else if (amdgpu_dc_debug_mask & DC_DISABLE_IPS2_DYNAMIC)
+		init_data.flags.disable_ips = DMUB_IPS_RCG_IN_ACTIVE_IPS2_IN_OFF;
+	else if (amdgpu_dc_debug_mask & DC_FORCE_IPS_ENABLE)
+		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
 	else
 		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
 
drivers/gpu/drm/amd/include/amd_shared.h +58 -1

84 lines not on this page · raw message

Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 2/5 drm/amd/display: Go through dm for allow_idle_optimizations

From: Leo Li <[email protected]>

[Why]

In preparation for enabling IPS debug flags that require DM changes, a common entry point for allowing DC idle optimisations is needed.

[How]

Create an alias in DM for dc_allow_idle_optimizations(). Change all calls to it into dm_allow_idle_optimizations().

No functional changes are intended.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    | 16 ++++++++++++----
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h    |  6 ++++++
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c   |  8 ++++----
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c    |  2 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c    |  2 +-
 5 files changed, 24 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +12 -4
index a18ecf8607232..2efa9f6e23015 100644
@@ -246,6 +246,14 @@ static void handle_hpd_rx_irq(void *param);
 static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
 				 struct drm_crtc_state *new_crtc_state);
+
+void dm_allow_idle_optimizations_internal(struct dc *dc,
+					  bool allow,
+					  char const *caller_name)
+{
+	dc_allow_idle_optimizations_internal(dc, allow, caller_name);
+}
+
 /*
  * dm_vblank_get_counter
  *
@@ -296,7 +304,7 @@ static int dm_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc,
 	}
 
 	if (dc && dc->caps.ips_support && dc->idle_optimizations_allowed)
-		dc_allow_idle_optimizations(dc, false);
+		dm_allow_idle_optimizations(dc, false);
 
 	/*
 	 * TODO rework base driver to use values directly.
@@ -2883,7 +2891,7 @@ static int dm_suspend(void *handle)
 	if (amdgpu_in_reset(adev)) {
 		mutex_lock(&dm->dc_lock);
 
-		dc_allow_idle_optimizations(adev->dm.dc, false);
+		dm_allow_idle_optimizations(adev->dm.dc, false);
 
 		dm->cached_dc_state = dc_state_create_copy(dm->dc->current_state);
 
@@ -2911,7 +2919,7 @@ static int dm_suspend(void *handle)
 	hpd_rx_irq_work_suspend(dm);
 
 	if (adev->dm.dc->caps.ips_support)
-		dc_allow_idle_optimizations(adev->dm.dc, true);
+		dm_allow_idle_optimizations(adev->dm.dc, true);
 
 	dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
 	dc_dmub_srv_set_power_state(dm->dc->ctx->dmub_srv, DC_ACPI_CM_POWER_STATE_D3);
@@ -9421,7 +9429,7 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
 
 	/* Allow idle optimization when vblank count is 0 for display off */
 	if (dm->active_vblank_irq_count == 0)
-		dc_allow_idle_optimizations(dm->dc, true);
+		dm_allow_idle_optimizations(dm->dc, true);
 	mutex_unlock(&dm->dc_lock);
 
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +6 -0
index 2d7755e2b6c32..3fc3c12b3a4a1 100644
@@ -1007,4 +1007,10 @@ void *dm_allocate_gpu_mem(struct amdgpu_device *adev,
 
 bool amdgpu_dm_is_headless(struct amdgpu_device *adev);
 
+void dm_allow_idle_optimizations_internal(struct dc *dc,
+					  bool allow,
+					  char const *caller_name);
+#define dm_allow_idle_optimizations(dc, allow) \
+	dm_allow_idle_optimizations_internal(dc, allow, __func__)
+
 #endif /* __AMDGPU_DM_H__ */
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c +4 -4
index a2cf2c066a76d..5b0d426ad50db 100644
@@ -203,7 +203,7 @@ static void amdgpu_dm_idle_worker(struct work_struct *work)
 			mutex_unlock(&idle_work->dm->dc_lock);
 			break;
 		}
-		dc_allow_idle_optimizations(idle_work->dm->dc, false);
+		dm_allow_idle_optimizations(idle_work->dm->dc, false);
 
 		mutex_unlock(&idle_work->dm->dc_lock);
 		fsleep(HPD_DETECTION_TIME_uS);
@@ -216,7 +216,7 @@ static void amdgpu_dm_idle_worker(struct work_struct *work)
 		}
 
 		if (idle_work->enable)
-			dc_allow_idle_optimizations(idle_work->dm->dc, true);
+			dm_allow_idle_optimizations(idle_work->dm->dc, true);
 		mutex_unlock(&idle_work->dm->dc_lock);
 	}
 	idle_work->dm->idle_workqueue->running = false;
@@ -253,7 +253,7 @@ static void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work)
 
 	if (dm->active_vblank_irq_count > 0) {
 		DRM_DEBUG_KMS("Allow idle optimizations (MALL): false\n");
-		dc_allow_idle_optimizations(dm->dc, false);
+		dm_allow_idle_optimizations(dm->dc, false);
 	}
 
 	/*
@@ -275,7 +275,7 @@ static void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work)
 
 	if (dm->active_vblank_irq_count == 0) {
 		DRM_DEBUG_KMS("Allow idle optimizations (MALL): true\n");
-		dc_allow_idle_optimizations(dm->dc, true);
+		dm_allow_idle_optimizations(dm->dc, true);
 	}
 
 	mutex_unlock(&dm->dc_lock);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c +1 -1
index 3390f0d8420a0..48a4c493a70a0 100644
@@ -730,7 +730,7 @@ static inline int dm_irq_state(struct amdgpu_device *adev,
 	st = (state == AMDGPU_IRQ_STATE_ENABLE);
 
 	if (dc && dc->caps.ips_support && dc->idle_optimizations_allowed)
-		dc_allow_idle_optimizations(dc, false);
+		dm_allow_idle_optimizations(dc, false);
 
 	dc_interrupt_set(adev->dm.dc, irq_source, st);
 	return 0;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c +1 -1
index f40240aafe988..fdf1d4c7b9300 100644
@@ -192,7 +192,7 @@ void amdgpu_dm_psr_enable(struct dc_stream_state *stream)
 	dc_link_set_psr_allow_active(link, &psr_enable, false, false, &power_opt);
 
 	if (link->ctx->dc->caps.ips_support)
-		dc_allow_idle_optimizations(link->ctx->dc, true);
+		dm_allow_idle_optimizations(link->ctx->dc, true);
 }
 
 /*
Signature · 1 line
2.46.0
author maintainer
#2 lore raw

PATCH 3/5 drm/amd/display: Go through dm for exit_ips_for_hw_access

In reply to [email protected]

From: Leo Li <[email protected]>

[Why]

dc_exit_ips_for_hw_access() is the same as dc_allow_idle_optimizations(), but with a check on whether IPS is supported by the ASIC.

[How]

Let's also pipe it through the dm function introduced by the previous change.

No functional changes are intended.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 31 ++++++++++++-------
 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +20 -11
index 2efa9f6e23015..c99cff3650f14 100644
@@ -3092,7 +3092,7 @@ static int dm_resume(void *handle)
 	struct dc_commit_streams_params commit_params = {};
 
 	if (dm->dc->caps.ips_support) {
-		dc_dmub_srv_apply_idle_power_optimizations(dm->dc, false);
+		dm_allow_idle_optimizations(dm->dc, false);
 	}
 
 	if (amdgpu_in_reset(adev)) {
@@ -3141,7 +3141,8 @@ static int dm_resume(void *handle)
 
 		commit_params.streams = dc_state->streams;
 		commit_params.stream_count = dc_state->stream_count;
-		dc_exit_ips_for_hw_access(dm->dc);
+		if (dm->dc->caps.ips_support)
+			dm_allow_idle_optimizations(dm->dc, false);
 		WARN_ON(!dc_commit_streams(dm->dc, &commit_params));
 
 		dm_gpureset_commit_state(dm->cached_dc_state, dm);
@@ -3214,7 +3215,8 @@ static int dm_resume(void *handle)
 			emulated_link_detect(aconnector->dc_link);
 		} else {
 			mutex_lock(&dm->dc_lock);
-			dc_exit_ips_for_hw_access(dm->dc);
+			if (dm->dc->caps.ips_support)
+				dm_allow_idle_optimizations(dm->dc, false);
 			dc_link_detect(aconnector->dc_link, DETECT_REASON_RESUMEFROMS3S4);
 			mutex_unlock(&dm->dc_lock);
 		}
@@ -3589,7 +3591,8 @@ static void handle_hpd_irq_helper(struct amdgpu_dm_connector *aconnector)
 			drm_kms_helper_connector_hotplug_event(connector);
 	} else {
 		mutex_lock(&adev->dm.dc_lock);
-		dc_exit_ips_for_hw_access(dc);
+		if (dc->caps.ips_support)
+			dm_allow_idle_optimizations(dc, false);
 		ret = dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD);
 		mutex_unlock(&adev->dm.dc_lock);
 		if (ret) {
@@ -3739,7 +3742,8 @@ static void handle_hpd_rx_irq(void *param)
 			bool ret = false;
 
 			mutex_lock(&adev->dm.dc_lock);
-			dc_exit_ips_for_hw_access(dc);
+			if (dc->caps.ips_support)
+				dm_allow_idle_optimizations(dc, false);
 			ret = dc_link_detect(dc_link, DETECT_REASON_HPDRX);
 			mutex_unlock(&adev->dm.dc_lock);
 
@@ -4946,7 +4950,8 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
 			bool ret = false;
 
 			mutex_lock(&dm->dc_lock);
-			dc_exit_ips_for_hw_access(dm->dc);
+			if (dm->dc->caps.ips_support)
+				dm_allow_idle_optimizations(dm->dc, false);
 			ret = dc_link_detect(link, DETECT_REASON_BOOT);
 			mutex_unlock(&dm->dc_lock);
 
@@ -9349,7 +9354,8 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
 
 			memset(&position, 0, sizeof(position));
 			mutex_lock(&dm->dc_lock);
-			dc_exit_ips_for_hw_access(dm->dc);
+			if (dm->dc->caps.ips_support)
+				dm_allow_idle_optimizations(dm->dc, false);
 			dc_stream_program_cursor_position(dm_old_crtc_state->stream, &position);
 			mutex_unlock(&dm->dc_lock);
 		}
@@ -9424,7 +9430,8 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
 
 	dm_enable_per_frame_crtc_master_sync(dc_state);
 	mutex_lock(&dm->dc_lock);
-	dc_exit_ips_for_hw_access(dm->dc);
+	if (dm->dc->caps.ips_support)
+		dm_allow_idle_optimizations(dm->dc, false);
 	WARN_ON(!dc_commit_streams(dm->dc, &params));
 
 	/* Allow idle optimization when vblank count is 0 for display off */
@@ -9793,7 +9800,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		     sizeof(*dummy_updates), dm_plane_layer_index_cmp, NULL);
 
 		mutex_lock(&dm->dc_lock);
-		dc_exit_ips_for_hw_access(dm->dc);
+		if (dm->dc->caps.ips_support)
+			dm_allow_idle_optimizations(dm->dc, false);
 		dc_update_planes_and_stream(dm->dc,
 					    dummy_updates,
 					    status->plane_count,
@@ -12159,8 +12167,9 @@ void amdgpu_dm_trigger_timing_sync(struct drm_device *dev)
 
 static inline void amdgpu_dm_exit_ips_for_hw_access(struct dc *dc)
 {
-	if (dc->ctx->dmub_srv && !dc->ctx->dmub_srv->idle_exit_counter)
-		dc_exit_ips_for_hw_access(dc);
+	if (dc->ctx->dmub_srv && dc->caps.ips_support &&
+	    !dc->ctx->dmub_srv->idle_exit_counter)
+		dm_allow_idle_optimizations(dc, false);
 }
 
 void dm_write_reg_func(const struct dc_context *ctx, uint32_t address,
Signature · 1 line
2.46.0
author maintainer
#3 lore raw

PATCH 4/5 drm/amd/display: Implement DMUB_IPS_DISABLE_DYNAMIC

In reply to [email protected]

From: Leo Li <[email protected]>

[Why]

The IPS_DISABLE_DYNAMIC configuration disables IPS in all cases except for when the driver is put into d3 for s0ix.

[How]

Now that we have a common entry point into dc_allow_idle_optimizations from dm, implement said configuration there.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 42 +++++++++++++++----
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  5 ++-
 2 files changed, 39 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +35 -7
index c99cff3650f14..f9b5966746c73 100644
@@ -247,10 +247,38 @@ static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
 				 struct drm_crtc_state *new_crtc_state);
 
+/**
+ * dm_allow_idle_optimizations_internal() - Allow or disallow idle state entry
+ * @dc: pointer to display core struct
+ * @allow: If true, DC is allowed to go into idle power states. If false, DC
+ * will immediately exit idle power states
+ * @suspend_resume_path: Set to true if the caller is part of the suspend or
+ * resume path
+ * @caller_name: Function name of the caller - for debugging purposes
+ *
+ * Debug flags are considered in this function, so any DM callers should go
+ * thorugh this rather than call dc/dmcub interfaces directly.
+ */
 void dm_allow_idle_optimizations_internal(struct dc *dc,
 					  bool allow,
+					  bool suspend_resume_path,
 					  char const *caller_name)
 {
+	/*
+	 * We can early-return here if IPS support exists, and DISABLE_ALL debug
+	 * flag is set.
+	 *
+	 * We also need special handling for IPS_DISABLE_DYNAMIC in DM to allow
+	 * IPS only for the suspend/resume call path.
+	 *
+	 * The rest of the debug flags are handled in `dc_dmub_srv_notify_idle`,
+	 * which if IPS is supported, will eventually be called.
+	 */
+	if (dc->caps.ips_support &&
+	    (dc->config.disable_ips == DMUB_IPS_DISABLE_ALL ||
+	    (!suspend_resume_path && dc->config.disable_ips == DMUB_IPS_DISABLE_DYNAMIC)))
+		return;
+
 	dc_allow_idle_optimizations_internal(dc, allow, caller_name);
 }
 
@@ -2891,7 +2919,7 @@ static int dm_suspend(void *handle)
 	if (amdgpu_in_reset(adev)) {
 		mutex_lock(&dm->dc_lock);
 
-		dm_allow_idle_optimizations(adev->dm.dc, false);
+		dm_allow_idle_optimizations_suspend(adev->dm.dc, false);
 
 		dm->cached_dc_state = dc_state_create_copy(dm->dc->current_state);
 
@@ -2918,8 +2946,9 @@ static int dm_suspend(void *handle)
 
 	hpd_rx_irq_work_suspend(dm);
 
+	/* IPS2 entry is required for standby */
 	if (adev->dm.dc->caps.ips_support)
-		dm_allow_idle_optimizations(adev->dm.dc, true);
+		dm_allow_idle_optimizations_suspend(adev->dm.dc, true);
 
 	dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
 	dc_dmub_srv_set_power_state(dm->dc->ctx->dmub_srv, DC_ACPI_CM_POWER_STATE_D3);
@@ -3091,9 +3120,8 @@ static int dm_resume(void *handle)
 	bool need_hotplug = false;
 	struct dc_commit_streams_params commit_params = {};
 
-	if (dm->dc->caps.ips_support) {
-		dm_allow_idle_optimizations(dm->dc, false);
-	}
+	if (dm->dc->caps.ips_support)
+		dm_allow_idle_optimizations_suspend(dm->dc, false);
 
 	if (amdgpu_in_reset(adev)) {
 		dc_state = dm->cached_dc_state;
@@ -3142,7 +3170,7 @@ static int dm_resume(void *handle)
 		commit_params.streams = dc_state->streams;
 		commit_params.stream_count = dc_state->stream_count;
 		if (dm->dc->caps.ips_support)
-			dm_allow_idle_optimizations(dm->dc, false);
+			dm_allow_idle_optimizations_suspend(dm->dc, false);
 		WARN_ON(!dc_commit_streams(dm->dc, &commit_params));
 
 		dm_gpureset_commit_state(dm->cached_dc_state, dm);
@@ -3216,7 +3244,7 @@ static int dm_resume(void *handle)
 		} else {
 			mutex_lock(&dm->dc_lock);
 			if (dm->dc->caps.ips_support)
-				dm_allow_idle_optimizations(dm->dc, false);
+				dm_allow_idle_optimizations_suspend(dm->dc, false);
 			dc_link_detect(aconnector->dc_link, DETECT_REASON_RESUMEFROMS3S4);
 			mutex_unlock(&dm->dc_lock);
 		}
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +4 -1
index 3fc3c12b3a4a1..da7283c67b13c 100644
@@ -1009,8 +1009,11 @@ bool amdgpu_dm_is_headless(struct amdgpu_device *adev);
 
 void dm_allow_idle_optimizations_internal(struct dc *dc,
 					  bool allow,
+					  bool suspend_resume_path,
 					  char const *caller_name);
 #define dm_allow_idle_optimizations(dc, allow) \
-	dm_allow_idle_optimizations_internal(dc, allow, __func__)
+	dm_allow_idle_optimizations_internal(dc, allow, false, __func__)
+#define dm_allow_idle_optimizations_suspend(dc, allow) \
+	dm_allow_idle_optimizations_internal(dc, allow, true, __func__)
 
 #endif /* __AMDGPU_DM_H__ */
Signature · 1 line
2.46.0
author maintainer
#4 lore raw

PATCH 5/5 drm/amd/display: Default to DMUB_IPS_DISABLE_DYNAMIC

In reply to [email protected]

From: Leo Li <[email protected]>

[Why]

There are currently known backlight and abm issues when IPS is enabled on DCN35.

While the issues are being ironed out, let's default to IPS_DISABLE_DYNAMIC so users will not experience hangs. When the issues are resolved, this patch should be reverted.

[How]

Set the default IPS config to DMUB_IPS_DISABLE_DYNAMIC

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index f9b5966746c73..b1794ced82172 100644
@@ -1907,7 +1907,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 	else if (amdgpu_dc_debug_mask & DC_FORCE_IPS_ENABLE)
 		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
 	else
-		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
+		init_data.flags.disable_ips = DMUB_IPS_DISABLE_DYNAMIC;
 
 	init_data.flags.disable_ips_in_vpb = 0;
 
Signature · 1 line
2.46.0
maintainer
#5 lore raw
In reply to [email protected]
Quoted 62 lines · On 2024-08-16 18:57, [email protected] wrote:

From: Leo Li <[email protected]>

[Why]

Idle power states (IPS) describe levels of power-gating within DCN. DM and DC is responsible for ensuring that we are out of IPS before any DCN programming happens. Any DCN programming while we're in IPS leads to undefined behavior (mostly hangs).

Because IPS intersects with all display features, the ability to disable IPS by default while ironing out the known issues is desired. However, disabing it completely will cause important features such as s0ix entry to fail.

Therefore, more granular IPS debug flags are desired.

[How]

Extend the dc debug mask bits to include the available list of IPS debug flags.

All the flags should work as documented, with the exception of IPS_DISABLE_DYNAMIC. It requires dm changes which will be done in later changes.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 ++
 drivers/gpu/drm/amd/include/amd_shared.h      | 59 ++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -0
index dd8353283bda3..a18ecf8607232 100644
@@ -1864,6 +1864,12 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
 	if (amdgpu_dc_debug_mask & DC_DISABLE_IPS)
 		init_data.flags.disable_ips = DMUB_IPS_DISABLE_ALL;
+	else if (amdgpu_dc_debug_mask & DC_DISABLE_IPS_DYNAMIC)
+		init_data.flags.disable_ips = DMUB_IPS_DISABLE_DYNAMIC;
+	else if (amdgpu_dc_debug_mask & DC_DISABLE_IPS2_DYNAMIC)
+		init_data.flags.disable_ips = DMUB_IPS_RCG_IN_ACTIVE_IPS2_IN_OFF;
+	else if (amdgpu_dc_debug_mask & DC_FORCE_IPS_ENABLE)
+		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
 	else
 		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
 
drivers/gpu/drm/amd/include/amd_shared.h +1 -1
index f5b725f10a7ce..6c12ca954a53e 100644
@@ -61,7 +61,7 @@ enum amd_apu_flags {
 * acquires the list of IP blocks for the GPU in use on initialization.
 * It can then operate on this list to perform standard driver operations
 * such as: init, fini, suspend, resume, etc.
-* 
+*
 *
 * IP block implementations are named using the following convention:
 * <functionality>_v<version> (E.g.: gfx_v6_0).

drivers/gpu/drm/amd/include/amd_shared.h enum DC_FEATURE_MASK { · line 258

Quoted 8 lines
drivers/gpu/drm/amd/include/amd_shared.h +4 -0
@@ -251,19 +251,76 @@ enum DC_FEATURE_MASK {
 	DC_REPLAY_MASK = (1 << 9), //0x200, disabled by default for dcn < 3.1.4
 };
 
+/**
+ * enum DC_DEBUG_MASK - Bits that are useful for debugging the display driver.
+ */
 enum DC_DEBUG_MASK {
+	/* @DC_DISABLE_PIPE_SPLIT: If set, disable pipe-splitting */

This function has a kernel doc but these enum docs are not using /**. Would be nice to fix that. Not sure if we're generating kernel docs for this enum.

Harry

Quoted 68 lines
drivers/gpu/drm/amd/include/amd_shared.h +53 -0
 	DC_DISABLE_PIPE_SPLIT = 0x1,
+
+	/* @DC_DISABLE_STUTTER: If set, disable memory stutter mode */
 	DC_DISABLE_STUTTER = 0x2,
+
+	/* @DC_DISABLE_DSC: If set, disable display stream compression */
 	DC_DISABLE_DSC = 0x4,
+
+	/*
+	 * @DC_DISABLE_CLOCK_GATING: If set, disable clock gating optimizations
+	 */
 	DC_DISABLE_CLOCK_GATING = 0x8,
+
+	/* @DC_DISABLE_PSR: If set, disable Panel self refresh v1 and PSR-SU */
 	DC_DISABLE_PSR = 0x10,
+
+	/*
+	 * @DC_FORCE_SUBVP_MCLK_SWITCH: If set, force mclk switch in subvp, even
+	 * if mclk switch in vblank is possible
+	 */
 	DC_FORCE_SUBVP_MCLK_SWITCH = 0x20,
+
+	/* @DC_DISABLE_MPO: If set, disable multi-plane offloading */
 	DC_DISABLE_MPO = 0x40,
+
+	/* @DC_ENABLE_DPIA_TRACE: If set, enable trace logging for DPIA */
 	DC_ENABLE_DPIA_TRACE = 0x80,
+
+	/*
+	 * @DC_ENABLE_DML2: If set, force usage of DML2, even if the DCN version
+	 * does not default to it.
+	 */
 	DC_ENABLE_DML2 = 0x100,
+
+	/* @DC_DISABLE_PSR_SU: If set, disable PSR SU */
 	DC_DISABLE_PSR_SU = 0x200,
+
+	/* @DC_DISABLE_REPLAY: If set, disable Panel Replay */
 	DC_DISABLE_REPLAY = 0x400,
+
+	/*
+	 * @DC_DISABLE_IPS: If set, disable all Idle Power States, all the time.
+	 * If more than one IPS debug bit is set, the lowest bit takes
+	 * precedence. For example, if DC_FORCE_IPS_ENABLE and
+	 * DC_DISABLE_IPS_DYNAMIC are set, then DC_DISABLE_IPS_DYNAMIC takes
+	 * precedence.
+	 */
 	DC_DISABLE_IPS = 0x800,
+
+	/*
+	 * @DC_DISABLE_IPS_DYNAMIC: If set, disable all IPS, all the time,
+	 * *except* when driver goes into suspend.
+	 */
+	DC_DISABLE_IPS_DYNAMIC = 0x1000,
+
+	/*
+	 * @DC_DISABLE_IPS2_DYNAMIC: If set, disable IPS2 (IPS1 allowed) if
+	 * there is an enabled display. Otherwise, enable all IPS.
+	 */
+	DC_DISABLE_IPS2_DYNAMIC = 0x2000,
+
+	/*
+	 * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the time.
+	 */
+	DC_FORCE_IPS_ENABLE = 0x4000,
 };
 
 enum amd_dpm_forced_level;
author maintainer
#6 lore raw
Quoted 78 lines · Harry Wentland
Quoted 62 lines · On 2024-08-16 18:57, [email protected] wrote:

From: Leo Li <[email protected]>

[Why]

Idle power states (IPS) describe levels of power-gating within DCN. DM and DC is responsible for ensuring that we are out of IPS before any DCN programming happens. Any DCN programming while we're in IPS leads to undefined behavior (mostly hangs).

Because IPS intersects with all display features, the ability to disable IPS by default while ironing out the known issues is desired. However, disabing it completely will cause important features such as s0ix entry to fail.

Therefore, more granular IPS debug flags are desired.

[How]

Extend the dc debug mask bits to include the available list of IPS debug flags.

All the flags should work as documented, with the exception of IPS_DISABLE_DYNAMIC. It requires dm changes which will be done in later changes.

---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 ++
  drivers/gpu/drm/amd/include/amd_shared.h      | 59 ++++++++++++++++++-
  2 files changed, 64 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -0
index dd8353283bda3..a18ecf8607232 100644
@@ -1864,6 +1864,12 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
  	if (amdgpu_dc_debug_mask & DC_DISABLE_IPS)
  		init_data.flags.disable_ips = DMUB_IPS_DISABLE_ALL;
+	else if (amdgpu_dc_debug_mask & DC_DISABLE_IPS_DYNAMIC)
+		init_data.flags.disable_ips = DMUB_IPS_DISABLE_DYNAMIC;
+	else if (amdgpu_dc_debug_mask & DC_DISABLE_IPS2_DYNAMIC)
+		init_data.flags.disable_ips = DMUB_IPS_RCG_IN_ACTIVE_IPS2_IN_OFF;
+	else if (amdgpu_dc_debug_mask & DC_FORCE_IPS_ENABLE)
+		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
  	else
  		init_data.flags.disable_ips = DMUB_IPS_ENABLE;
 
drivers/gpu/drm/amd/include/amd_shared.h +1 -1
index f5b725f10a7ce..6c12ca954a53e 100644
@@ -61,7 +61,7 @@ enum amd_apu_flags {
  * acquires the list of IP blocks for the GPU in use on initialization.
  * It can then operate on this list to perform standard driver operations
  * such as: init, fini, suspend, resume, etc.
-*
+*
  *
  * IP block implementations are named using the following convention:
  * <functionality>_v<version> (E.g.: gfx_v6_0).

drivers/gpu/drm/amd/include/amd_shared.h enum DC_FEATURE_MASK { · line 258

Quoted 8 lines
drivers/gpu/drm/amd/include/amd_shared.h +4 -0
@@ -251,19 +251,76 @@ enum DC_FEATURE_MASK {
  	DC_REPLAY_MASK = (1 << 9), //0x200, disabled by default for dcn < 3.1.4
  };
 
+/**
+ * enum DC_DEBUG_MASK - Bits that are useful for debugging the display driver.
+ */
  enum DC_DEBUG_MASK {
+	/* @DC_DISABLE_PIPE_SPLIT: If set, disable pipe-splitting */

This function has a kernel doc but these enum docs are not using /**. Would be nice to fix that. Not sure if we're generating kernel docs for this enum.

Quoted 1 line

Harry

Ack, htmldoc didn't generate the docs for these. v2 incoming.
- Leo

Quoted 70 lines
Quoted 69 lines
drivers/gpu/drm/amd/include/amd_shared.h +53 -0
  	DC_DISABLE_PIPE_SPLIT = 0x1,
+
+	/* @DC_DISABLE_STUTTER: If set, disable memory stutter mode */
  	DC_DISABLE_STUTTER = 0x2,
+
+	/* @DC_DISABLE_DSC: If set, disable display stream compression */
  	DC_DISABLE_DSC = 0x4,
+
+	/*
+	 * @DC_DISABLE_CLOCK_GATING: If set, disable clock gating optimizations
+	 */
  	DC_DISABLE_CLOCK_GATING = 0x8,
+
+	/* @DC_DISABLE_PSR: If set, disable Panel self refresh v1 and PSR-SU */
  	DC_DISABLE_PSR = 0x10,
+
+	/*
+	 * @DC_FORCE_SUBVP_MCLK_SWITCH: If set, force mclk switch in subvp, even
+	 * if mclk switch in vblank is possible
+	 */
  	DC_FORCE_SUBVP_MCLK_SWITCH = 0x20,
+
+	/* @DC_DISABLE_MPO: If set, disable multi-plane offloading */
  	DC_DISABLE_MPO = 0x40,
+
+	/* @DC_ENABLE_DPIA_TRACE: If set, enable trace logging for DPIA */
  	DC_ENABLE_DPIA_TRACE = 0x80,
+
+	/*
+	 * @DC_ENABLE_DML2: If set, force usage of DML2, even if the DCN version
+	 * does not default to it.
+	 */
  	DC_ENABLE_DML2 = 0x100,
+
+	/* @DC_DISABLE_PSR_SU: If set, disable PSR SU */
  	DC_DISABLE_PSR_SU = 0x200,
+
+	/* @DC_DISABLE_REPLAY: If set, disable Panel Replay */
  	DC_DISABLE_REPLAY = 0x400,
+
+	/*
+	 * @DC_DISABLE_IPS: If set, disable all Idle Power States, all the time.
+	 * If more than one IPS debug bit is set, the lowest bit takes
+	 * precedence. For example, if DC_FORCE_IPS_ENABLE and
+	 * DC_DISABLE_IPS_DYNAMIC are set, then DC_DISABLE_IPS_DYNAMIC takes
+	 * precedence.
+	 */
  	DC_DISABLE_IPS = 0x800,
+
+	/*
+	 * @DC_DISABLE_IPS_DYNAMIC: If set, disable all IPS, all the time,
+	 * *except* when driver goes into suspend.
+	 */
+	DC_DISABLE_IPS_DYNAMIC = 0x1000,
+
+	/*
+	 * @DC_DISABLE_IPS2_DYNAMIC: If set, disable IPS2 (IPS1 allowed) if
+	 * there is an enabled display. Otherwise, enable all IPS.
+	 */
+	DC_DISABLE_IPS2_DYNAMIC = 0x2000,
+
+	/*
+	 * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the time.
+	 */
+	DC_FORCE_IPS_ENABLE = 0x4000,
  };
 
  enum amd_dpm_forced_level;