drm/amd/display: Return context from validate_context
authorHarry Wentland <harry.wentland@amd.com>
Wed, 29 Mar 2017 15:22:05 +0000 (11:22 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 21:24:23 +0000 (17:24 -0400)
This will allow us to carry it from check to commit

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dc.h

index d8718e2ac2075d10f20b4d686b15729184b41c4e..fb3cc57c98d5dc0e9f8d4a2a96378b22922d2833 100644 (file)
@@ -1384,6 +1384,7 @@ int amdgpu_dm_connector_mode_valid(
        /* TODO: Unhardcode stream count */
        struct dc_stream *stream;
        struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
+       struct validate_context *context;
 
        if ((mode->flags & DRM_MODE_FLAG_INTERLACE) ||
                        (mode->flags & DRM_MODE_FLAG_DBLSCAN))
@@ -1418,8 +1419,13 @@ int amdgpu_dm_connector_mode_valid(
        stream->src.height = mode->vdisplay;
        stream->dst = stream->src;
 
-       if (dc_validate_resources(adev->dm.dc, &val_set, 1))
+       context = dc_get_validate_context(adev->dm.dc, &val_set, 1);
+
+       if (context) {
                result = MODE_OK;
+               dc_resource_validate_ctx_destruct(context);
+               dm_free(context);
+       }
 
        dc_stream_release(stream);
 
@@ -2842,6 +2848,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
        struct amdgpu_device *adev = dev->dev_private;
        struct dc *dc = adev->dm.dc;
        bool need_to_validate = false;
+       struct validate_context *context;
 
        ret = drm_atomic_helper_check(dev, state);
 
@@ -3064,15 +3071,20 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
                }
        }
 
-       if (need_to_validate == false || set_count == 0 ||
-               dc_validate_resources(dc, set, set_count))
+       context = dc_get_validate_context(dc, set, set_count);
+
+       if (need_to_validate == false || set_count == 0 || context)
                ret = 0;
 
-       for (i = 0; i < set_count; i++) {
-               for (j = 0; j < set[i].surface_count; j++) {
-                       dc_surface_release(set[i].surfaces[j]);
-               }
+       if (context) {
+               dc_resource_validate_ctx_destruct(context);
+               dm_free(context);
        }
+
+       for (i = 0; i < set_count; i++)
+               for (j = 0; j < set[i].surface_count; j++)
+                       dc_surface_release(set[i].surfaces[j]);
+
        for (i = 0; i < new_stream_count; i++)
                dc_stream_release(new_streams[i]);
 
index 5620fe3611735a4892ceb84cbf4c85049dc4d82a..64b5216fb920aeb61b48a11247e67dec76e2df25 100644 (file)
@@ -635,7 +635,7 @@ static bool is_validation_required(
        return false;
 }
 
-bool dc_validate_resources(
+struct validate_context *dc_get_validate_context(
                const struct dc *dc,
                const struct dc_validation_set set[],
                uint8_t set_count)
@@ -644,31 +644,51 @@ bool dc_validate_resources(
        enum dc_status result = DC_ERROR_UNEXPECTED;
        struct validate_context *context;
 
-       if (!is_validation_required(core_dc, set, set_count))
-               return true;
-
        context = dm_alloc(sizeof(struct validate_context));
        if(context == NULL)
                goto context_alloc_fail;
 
+       if (!is_validation_required(core_dc, set, set_count)) {
+               dc_resource_validate_ctx_copy_construct(core_dc->current_context, context);
+               return context;
+       }
+
        result = core_dc->res_pool->funcs->validate_with_context(
                                                core_dc, set, set_count, context);
 
-       dc_resource_validate_ctx_destruct(context);
-       dm_free(context);
-
 context_alloc_fail:
        if (result != DC_OK) {
                dm_logger_write(core_dc->ctx->logger, LOG_WARNING,
                                "%s:resource validation failed, dc_status:%d\n",
                                __func__,
                                result);
+
+               dc_resource_validate_ctx_destruct(context);
+               dm_free(context);
+               context = NULL;
        }
 
-       return (result == DC_OK);
+       return context;
 
 }
 
+bool dc_validate_resources(
+               const struct dc *dc,
+               const struct dc_validation_set set[],
+               uint8_t set_count)
+{
+       struct validate_context *ctx;
+
+       ctx = dc_get_validate_context(dc, set, set_count);
+       if (ctx) {
+               dc_resource_validate_ctx_destruct(ctx);
+               dm_free(ctx);
+               return true;
+       }
+
+       return false;
+}
+
 bool dc_validate_guaranteed(
                const struct dc *dc,
                const struct dc_stream *stream)
index 7de2080e13edc438aad206195e02482901b15306..1b3fd79ce624acdc41887650f1115f642c0ad6a1 100644 (file)
@@ -505,6 +505,11 @@ struct dc_validation_set {
  * After this call:
  *   No hardware is programmed for call.  Only validation is done.
  */
+struct validate_context *dc_get_validate_context(
+               const struct dc *dc,
+               const struct dc_validation_set set[],
+               uint8_t set_count);
+
 bool dc_validate_resources(
                const struct dc *dc,
                const struct dc_validation_set set[],