OSDN Git Service

drm/amd/display: enable idle optimizations for linux (MALL stutter)
authorBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Thu, 30 Jul 2020 21:03:49 +0000 (17:03 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 Jan 2021 16:34:51 +0000 (11:34 -0500)
[Why]
We can only use this feature when the display is idle. When active vblank
irq count is 0 we know all the displays are idle.

[How]
-Add a active vblank irq counter
-Update the counter when we enable/disable vblank irq
-if vblank irq count is 0 we can consider mall stutter

Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Nick Kazlauskas <Nicholas.Kazlauskas@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

index 419d089..98f6f7e 100644 (file)
@@ -5413,6 +5413,7 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
        struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
        struct amdgpu_device *adev = drm_to_adev(crtc->dev);
        struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
+       struct amdgpu_display_manager *dm = &adev->dm;
        int rc = 0;
 
        if (enable) {
@@ -5428,7 +5429,25 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
                return rc;
 
        irq_source = IRQ_TYPE_VBLANK + acrtc->otg_inst;
-       return dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY;
+
+       if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
+               return -EBUSY;
+
+       mutex_lock(&dm->dc_lock);
+
+       if (enable)
+               dm->active_vblank_irq_count++;
+       else
+               dm->active_vblank_irq_count--;
+
+       dc_allow_idle_optimizations(
+               adev->dm.dc, dm->active_vblank_irq_count == 0 ? true : false);
+
+       DRM_DEBUG_DRIVER("Allow idle optimizations (MALL): %d\n", dm->active_vblank_irq_count == 0);
+
+       mutex_unlock(&dm->dc_lock);
+
+       return 0;
 }
 
 static int dm_enable_vblank(struct drm_crtc *crtc)
index 2ee6edb..f084e2f 100644 (file)
@@ -336,6 +336,13 @@ struct amdgpu_display_manager {
         */
        const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
 
+       /**
+        * @active_vblank_irq_count
+        *
+        * number of currently active vblank irqs
+        */
+       uint32_t active_vblank_irq_count;
+
 #ifdef CONFIG_DEBUG_FS
        /**
         * @crc_win_x_start_property: