drm/amd/display: Release dm_state->context when state is cleared.
authorAndrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Tue, 11 Jul 2017 18:42:57 +0000 (14:42 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 22:15:04 +0000 (18:15 -0400)
Handling a use case of TEST_ONLY request from DRM where commit is
not goiing to be called. We need to release the allocated dc_validate_context
in this case.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@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_types.c

index 63d23c6..e16e871 100644 (file)
@@ -653,12 +653,35 @@ dm_atomic_state_alloc(struct drm_device *dev)
        return &state->base;
 }
 
+static void
+dm_atomic_state_clear(struct drm_atomic_state *state)
+{
+       struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
+
+       if (dm_state->context) {
+               dc_release_validate_context(dm_state->context);
+               dm_state->context = NULL;
+       }
+
+       drm_atomic_state_default_clear(state);
+}
+
+static void
+dm_atomic_state_alloc_free(struct drm_atomic_state *state)
+{
+       struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
+       drm_atomic_state_default_release(state);
+       kfree(dm_state);
+}
+
 static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
        .fb_create = amdgpu_user_framebuffer_create,
        .output_poll_changed = amdgpu_output_poll_changed,
        .atomic_check = amdgpu_dm_atomic_check,
        .atomic_commit = amdgpu_dm_atomic_commit,
        .atomic_state_alloc = dm_atomic_state_alloc,
+       .atomic_state_clear = dm_atomic_state_clear,
+       .atomic_state_free = dm_atomic_state_alloc_free
 };
 
 static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
index 248b397..af4de57 100644 (file)
@@ -3144,6 +3144,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
                if (ret)
                        goto fail_planes;
 
+               WARN_ON(dm_state->context);
                dm_state->context = dc_get_validate_context(dc, set, set_count);
                if (!dm_state->context) {
                        ret = -EINVAL;