Commit aed15309 authored by Mikita Lipski's avatar Mikita Lipski Committed by Alex Deucher

drm/amd/display: Release fake sink

If connector doesn't have a sink, fake sink is created, but
never released as it assumed that its destroyed with the
stream it is used for. But now sink is released before the
stream maintaing refcount consistency.

This way we also avoid assigning anything to connector keeping
all the operation local.
Signed-off-by: default avatarMikita Lipski <mikita.lipski@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 2b6199a1
...@@ -2310,27 +2310,22 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode, ...@@ -2310,27 +2310,22 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode,
} }
} }
static int create_fake_sink(struct amdgpu_dm_connector *aconnector) static struct dc_sink *
create_fake_sink(struct amdgpu_dm_connector *aconnector)
{ {
struct dc_sink *sink = NULL;
struct dc_sink_init_data sink_init_data = { 0 }; struct dc_sink_init_data sink_init_data = { 0 };
struct dc_sink *sink = NULL;
sink_init_data.link = aconnector->dc_link; sink_init_data.link = aconnector->dc_link;
sink_init_data.sink_signal = aconnector->dc_link->connector_signal; sink_init_data.sink_signal = aconnector->dc_link->connector_signal;
sink = dc_sink_create(&sink_init_data); sink = dc_sink_create(&sink_init_data);
if (!sink) { if (!sink) {
DRM_ERROR("Failed to create sink!\n"); DRM_ERROR("Failed to create sink!\n");
return -ENOMEM; return NULL;
} }
sink->sink_signal = SIGNAL_TYPE_VIRTUAL; sink->sink_signal = SIGNAL_TYPE_VIRTUAL;
aconnector->fake_enable = true;
aconnector->dc_sink = sink; return sink;
aconnector->dc_link->local_sink = sink;
return 0;
} }
static void set_multisync_trigger_params( static void set_multisync_trigger_params(
...@@ -2393,7 +2388,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -2393,7 +2388,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
struct dc_stream_state *stream = NULL; struct dc_stream_state *stream = NULL;
struct drm_display_mode mode = *drm_mode; struct drm_display_mode mode = *drm_mode;
bool native_mode_found = false; bool native_mode_found = false;
struct dc_sink *sink = NULL;
if (aconnector == NULL) { if (aconnector == NULL) {
DRM_ERROR("aconnector is NULL!\n"); DRM_ERROR("aconnector is NULL!\n");
return stream; return stream;
...@@ -2411,15 +2406,18 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -2411,15 +2406,18 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
return stream; return stream;
} }
if (create_fake_sink(aconnector)) sink = create_fake_sink(aconnector);
if (!sink)
return stream; return stream;
} else {
sink = aconnector->dc_sink;
} }
stream = dc_create_stream_for_sink(aconnector->dc_sink); stream = dc_create_stream_for_sink(sink);
if (stream == NULL) { if (stream == NULL) {
DRM_ERROR("Failed to create stream for sink!\n"); DRM_ERROR("Failed to create stream for sink!\n");
return stream; goto finish;
} }
list_for_each_entry(preferred_mode, &aconnector->base.modes, head) { list_for_each_entry(preferred_mode, &aconnector->base.modes, head) {
...@@ -2458,12 +2456,15 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -2458,12 +2456,15 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
fill_audio_info( fill_audio_info(
&stream->audio_info, &stream->audio_info,
drm_connector, drm_connector,
aconnector->dc_sink); sink);
update_stream_signal(stream); update_stream_signal(stream);
if (dm_state && dm_state->freesync_capable) if (dm_state && dm_state->freesync_capable)
stream->ignore_msa_timing_param = true; stream->ignore_msa_timing_param = true;
finish:
if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL)
dc_sink_release(sink);
return stream; return stream;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment