]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amd/display: Refactor dc_state creation into a function.
authorLeo (Sunpeng) Li <sunpeng.li@amd.com>
Thu, 7 Sep 2017 20:46:34 +0000 (16:46 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 22:16:47 +0000 (18:16 -0400)
For less repetition and easy debugging.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@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/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dc.h

index 17e9bf7a2ebb8e1b2c84a50f8c0bd23e13462e03..776bd4a1fecc18652afc5887a4860d59fd6509be 100644 (file)
@@ -702,13 +702,11 @@ dm_atomic_state_alloc(struct drm_device *dev)
                goto fail;
 
        /* copy existing configuration */
-       new_ctx = dm_alloc(sizeof(*new_ctx));
+       new_ctx = dc_create_state();
 
        if (!new_ctx)
                goto fail;
 
-       atomic_inc(&new_ctx->ref_count);
-
        dc_resource_validate_ctx_copy_construct_current(dc, new_ctx);
 
        state->context = new_ctx;
index 10126d9a72338a394f53a46ec7a7b992a520ba27..8a6bd2917799df2484366b59787a4608df2bc08c 100644 (file)
@@ -497,15 +497,13 @@ static bool construct(struct dc *dc,
                goto fail;
        }
 
-       dc->current_context = dm_alloc(sizeof(*dc->current_context));
+       dc->current_context = dc_create_state();
 
        if (!dc->current_context) {
                dm_error("%s: failed to create validate ctx\n", __func__);
                goto fail;
        }
 
-       atomic_inc(&dc->current_context->ref_count);
-
        dc_ctx->cgs_device = init_params->cgs_device;
        dc_ctx->driver_context = init_params->driver;
        dc_ctx->dc = dc;
@@ -1162,6 +1160,17 @@ bool dc_commit_planes_to_stream(
        return true;
 }
 
+struct validate_context *dc_create_state(void)
+{
+       struct validate_context *context = dm_alloc(sizeof(struct validate_context));
+
+       if (!context)
+               return NULL;
+
+       atomic_inc(&context->ref_count);
+       return context;
+}
+
 void dc_retain_validate_context(struct validate_context *context)
 {
        ASSERT(atomic_read(&context->ref_count) > 0);
@@ -1442,12 +1451,10 @@ void dc_update_planes_and_stream(struct dc *dc,
                        new_planes[i] = srf_updates[i].surface;
 
                /* initialize scratch memory for building context */
-               context = dm_alloc(sizeof(*context));
+               context = dc_create_state();
                if (context == NULL)
                                goto context_alloc_fail;
 
-               atomic_inc(&context->ref_count);
-
                dc_resource_validate_ctx_copy_construct(
                                core_dc->current_context, context);
 
index 2b4fc661624351734297c822531dc2f40fc12ac4..928d2a0501eb47f5abd7c853de9f02cae5321238 100644 (file)
@@ -732,6 +732,7 @@ enum surface_update_type dc_check_update_surfaces_for_stream(
                const struct dc_stream_status *stream_status);
 
 
+struct validate_context *dc_create_state(void);
 void dc_retain_validate_context(struct validate_context *context);
 void dc_release_validate_context(struct validate_context *context);