Skip to contentSkip to conversation

drm/amdgpu: Set pm_display_cfg in non-dc mode

PATCH In review Rex Zhu 2 participants 2 messages Mar 26, 2018 – Mar 27, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Set pm_display_cfg in non-dc mode

those parameters are needed by powerplay
so we can remove the wrapper cgs interface for
get display info

Change-Id I503decd322837f016a16d6c45602d3d3c9fd953d
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c  | 25 ++++++++++---------------
 3 files changed, 32 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +21 -0
index e997ebbe43..f41bb2a 100644
@@ -115,6 +115,27 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev,
 	pr_cont("\n");
 }
 
+u32 amdgpu_dpm_get_active_display(struct amdgpu_device *adev)
+{
+	struct drm_device *ddev = adev->ddev;
+	struct drm_crtc *crtc;
+	struct amdgpu_crtc *amdgpu_crtc;
+
+	adev->pm.dpm.new_active_crtcs = 0;
+	adev->pm.dpm.new_active_crtc_count = 0;
+	if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
+		list_for_each_entry(crtc,
+				    &ddev->mode_config.crtc_list, head) {
+			amdgpu_crtc = to_amdgpu_crtc(crtc);
+			if (amdgpu_crtc->enabled) {
+				adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id);
+				adev->pm.dpm.new_active_crtc_count++;
+			}
+		}
+	}
+	return 0;
+}
+
 
 u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev)
 {
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1 -0
index 643d008..a1ab096 100644
@@ -482,6 +482,7 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev,
 				struct amdgpu_ps *rps);
 u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
 u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev);
+u32 amdgpu_dpm_get_active_display(struct amdgpu_device *adev);
 bool amdgpu_is_uvd_state(u32 class, u32 class2);
 void amdgpu_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,
 			      u32 *p, u32 *u);
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10 -15
index 361975c..53caf24 100644
@@ -1658,9 +1658,6 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
 
 void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
 {
-	struct drm_device *ddev = adev->ddev;
-	struct drm_crtc *crtc;
-	struct amdgpu_crtc *amdgpu_crtc;
 	int i = 0;
 
 	if (!adev->pm.dpm_enabled)
@@ -1675,22 +1672,20 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
 			amdgpu_fence_wait_empty(ring);
 	}
 
+	mutex_lock(&adev->pm.mutex);
+	amdgpu_dpm_get_active_display(adev);
+	mutex_unlock(&adev->pm.mutex);
+
+	if (!amdgpu_device_has_dc_support(adev)) {
+		adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtcs;
+		adev->pm.pm_display_cfg.vrefresh = amdgpu_dpm_get_vrefresh(adev);
+		adev->pm.pm_display_cfg.min_vblank_time = amdgpu_dpm_get_vblank_time(adev);
+	}
+
 	if (adev->powerplay.pp_funcs->dispatch_tasks) {
 		amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_DISPLAY_CONFIG_CHANGE, NULL);
 	} else {
 		mutex_lock(&adev->pm.mutex);
-		adev->pm.dpm.new_active_crtcs = 0;
-		adev->pm.dpm.new_active_crtc_count = 0;
-		if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
-			list_for_each_entry(crtc,
-					    &ddev->mode_config.crtc_list, head) {
-				amdgpu_crtc = to_amdgpu_crtc(crtc);
-				if (amdgpu_crtc->enabled) {
-					adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id);
-					adev->pm.dpm.new_active_crtc_count++;
-				}
-			}
-		}
 		/* update battery/ac status */
 		if (power_supply_is_system_supplied() > 0)
 			adev->pm.dpm.ac_power = true;
Signature · 6 lines
1.9.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): 1522073464-8175-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

Acked-by
#2 lore raw
Quoted 17 lines · Rex Zhu

those parameters are needed by powerplay
so we can remove the wrapper cgs interface for
get display info

Change-Id I503decd322837f016a16d6c45602d3d3c9fd953d
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c  | 25 ++++++++++---------------
 3 files changed, 32 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +0 -0
index e997ebbe43..f41bb2a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev, · line 118

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +1 -0
@@ -115,6 +115,27 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev,
        pr_cont("\n");
 }
 
+u32 amdgpu_dpm_get_active_display(struct amdgpu_device *adev)

Maybe call this amdgpu_dpm_get_active_displays() since we care about more than one. With that:

Quoted 85 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +20 -0
+{
+       struct drm_device *ddev = adev->ddev;
+       struct drm_crtc *crtc;
+       struct amdgpu_crtc *amdgpu_crtc;
+
+       adev->pm.dpm.new_active_crtcs = 0;
+       adev->pm.dpm.new_active_crtc_count = 0;
+       if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
+               list_for_each_entry(crtc,
+                                   &ddev->mode_config.crtc_list, head) {
+                       amdgpu_crtc = to_amdgpu_crtc(crtc);
+                       if (amdgpu_crtc->enabled) {
+                               adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id);
+                               adev->pm.dpm.new_active_crtc_count++;
+                       }
+               }
+       }
+       return 0;
+}
+
 
 u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev)
 {
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1 -0
index 643d008..a1ab096 100644
@@ -482,6 +482,7 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev,
                                struct amdgpu_ps *rps);
 u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
 u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev);
+u32 amdgpu_dpm_get_active_display(struct amdgpu_device *adev);
 bool amdgpu_is_uvd_state(u32 class, u32 class2);
 void amdgpu_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,
                              u32 *p, u32 *u);
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10 -16
index 361975c..53caf24 100644
@@ -1658,9 +1658,6 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
 
 void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
 {
-       struct drm_device *ddev = adev->ddev;
-       struct drm_crtc *crtc;
-       struct amdgpu_crtc *amdgpu_crtc;
        int i = 0;
 
        if (!adev->pm.dpm_enabled)
@@ -1675,22 +1672,20 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
                        amdgpu_fence_wait_empty(ring);
        }
 
+       mutex_lock(&adev->pm.mutex);
+       amdgpu_dpm_get_active_display(adev);
+       mutex_unlock(&adev->pm.mutex);
+
+       if (!amdgpu_device_has_dc_support(adev)) {
+               adev->pm.pm_display_cfg.num_display = adev->pm.dpm.new_active_crtcs;
+               adev->pm.pm_display_cfg.vrefresh = amdgpu_dpm_get_vrefresh(adev);
+               adev->pm.pm_display_cfg.min_vblank_time = amdgpu_dpm_get_vblank_time(adev);
+       }
+
        if (adev->powerplay.pp_funcs->dispatch_tasks) {
                amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_DISPLAY_CONFIG_CHANGE, NULL);
        } else {
                mutex_lock(&adev->pm.mutex);
-               adev->pm.dpm.new_active_crtcs = 0;
-               adev->pm.dpm.new_active_crtc_count = 0;
-               if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
-                       list_for_each_entry(crtc,
-                                           &ddev->mode_config.crtc_list, head) {
-                               amdgpu_crtc = to_amdgpu_crtc(crtc);
-                               if (amdgpu_crtc->enabled) {
-                                       adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id);
-                                       adev->pm.dpm.new_active_crtc_count++;
-                               }
-                       }
-               }
                /* update battery/ac status */
                if (power_supply_is_system_supplied() > 0)
                        adev->pm.dpm.ac_power = true;
--

1.9.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