drm/amd/display: Multi display cause system lag on mode change
authorAric Cyr <aric.cyr@amd.com>
Mon, 24 Aug 2020 02:32:14 +0000 (22:32 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Sep 2020 21:52:41 +0000 (17:52 -0400)
[Why]
DCValidator is created/destroyed repeatedly for cofunctional validation
which causes a lot of memory thrashing, particularly when Driver Verifer
is enabled.

[How]
Implement a basic caching algorithm that will cache DCValidator with a
matching topology.  When a match is found, the DCValidator can be
reused.  If there is no match, a new one will be created and inserted
into the cache if there is space or an unreference entry can be evicted.

Signed-off-by: Aric Cyr <aric.cyr@amd.com>
Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c

index 511ab25..ce5303c 100644 (file)
@@ -1481,13 +1481,8 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
        return true;
 }
 
-struct dc_state *dc_create_state(struct dc *dc)
+static void init_state(struct dc *dc, struct dc_state *context)
 {
-       struct dc_state *context = kvzalloc(sizeof(struct dc_state),
-                                           GFP_KERNEL);
-
-       if (!context)
-               return NULL;
        /* Each context must have their own instance of VBA and in order to
         * initialize and obtain IP and SOC the base DML instance from DC is
         * initially copied into every context
@@ -1495,6 +1490,17 @@ struct dc_state *dc_create_state(struct dc *dc)
 #ifdef CONFIG_DRM_AMD_DC_DCN
        memcpy(&context->bw_ctx.dml, &dc->dml, sizeof(struct display_mode_lib));
 #endif
+}
+
+struct dc_state *dc_create_state(struct dc *dc)
+{
+       struct dc_state *context = kzalloc(sizeof(struct dc_state),
+                                          GFP_KERNEL);
+
+       if (!context)
+               return NULL;
+
+       init_state(dc, context);
 
        kref_init(&context->refcount);