Skip to content

Commit cbf4890

Browse files
Harry Wentlandalexdeucher
authored andcommitted
drm/amd/display: Don't treat wb connector as physical in create_validate_stream_for_sink
Don't try to operate on a drm_wb_connector as an amdgpu_dm_connector. While dereferencing aconnector->base will "work" it's wrong and might lead to unknown bad things. Just... don't. Reviewed-by: Alex Hung <[email protected]> Signed-off-by: Harry Wentland <[email protected]> Signed-off-by: Roman Li <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent c488967 commit cbf4890

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7456,12 +7456,12 @@ static enum dc_status dm_validate_stream_and_context(struct dc *dc,
74567456
}
74577457

74587458
struct dc_stream_state *
7459-
create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
7459+
create_validate_stream_for_sink(struct drm_connector *connector,
74607460
const struct drm_display_mode *drm_mode,
74617461
const struct dm_connector_state *dm_state,
74627462
const struct dc_stream_state *old_stream)
74637463
{
7464-
struct drm_connector *connector = &aconnector->base;
7464+
struct amdgpu_dm_connector *aconnector = NULL;
74657465
struct amdgpu_device *adev = drm_to_adev(connector->dev);
74667466
struct dc_stream_state *stream;
74677467
const struct drm_connector_state *drm_state = dm_state ? &dm_state->base : NULL;
@@ -7472,8 +7472,12 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
74727472
if (!dm_state)
74737473
return NULL;
74747474

7475-
if (aconnector->dc_link->connector_signal == SIGNAL_TYPE_HDMI_TYPE_A ||
7476-
aconnector->dc_link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER)
7475+
if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
7476+
aconnector = to_amdgpu_dm_connector(connector);
7477+
7478+
if (aconnector &&
7479+
(aconnector->dc_link->connector_signal == SIGNAL_TYPE_HDMI_TYPE_A ||
7480+
aconnector->dc_link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER))
74777481
bpc_limit = 8;
74787482

74797483
do {
@@ -7485,10 +7489,11 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
74857489
break;
74867490
}
74877491

7488-
if (aconnector->base.connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
7492+
dc_result = dc_validate_stream(adev->dm.dc, stream);
7493+
7494+
if (!aconnector) /* writeback connector */
74897495
return stream;
74907496

7491-
dc_result = dc_validate_stream(adev->dm.dc, stream);
74927497
if (dc_result == DC_OK && stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
74937498
dc_result = dm_dp_mst_is_port_support_mode(aconnector, stream);
74947499

@@ -7518,7 +7523,7 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
75187523
__func__, __LINE__);
75197524

75207525
aconnector->force_yuv420_output = true;
7521-
stream = create_validate_stream_for_sink(aconnector, drm_mode,
7526+
stream = create_validate_stream_for_sink(connector, drm_mode,
75227527
dm_state, old_stream);
75237528
aconnector->force_yuv420_output = false;
75247529
}
@@ -7533,6 +7538,9 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec
75337538
struct dc_sink *dc_sink;
75347539
/* TODO: Unhardcode stream count */
75357540
struct dc_stream_state *stream;
7541+
/* we always have an amdgpu_dm_connector here since we got
7542+
* here via the amdgpu_dm_connector_helper_funcs
7543+
*/
75367544
struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
75377545

75387546
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) ||
@@ -7557,7 +7565,7 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec
75577565

75587566
drm_mode_set_crtcinfo(mode, 0);
75597567

7560-
stream = create_validate_stream_for_sink(aconnector, mode,
7568+
stream = create_validate_stream_for_sink(connector, mode,
75617569
to_dm_connector_state(connector->state),
75627570
NULL);
75637571
if (stream) {
@@ -10608,7 +10616,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
1060810616
if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
1060910617
goto skip_modeset;
1061010618

10611-
new_stream = create_validate_stream_for_sink(aconnector,
10619+
new_stream = create_validate_stream_for_sink(connector,
1061210620
&new_crtc_state->mode,
1061310621
dm_new_conn_state,
1061410622
dm_old_crtc_state->stream);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ int amdgpu_dm_process_dmub_set_config_sync(struct dc_context *ctx, unsigned int
996996
struct set_config_cmd_payload *payload, enum set_config_status *operation_result);
997997

998998
struct dc_stream_state *
999-
create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
999+
create_validate_stream_for_sink(struct drm_connector *connector,
10001000
const struct drm_display_mode *drm_mode,
10011001
const struct dm_connector_state *dm_state,
10021002
const struct dc_stream_state *old_stream);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,23 +1625,21 @@ int pre_validate_dsc(struct drm_atomic_state *state,
16251625

16261626
if (ind >= 0) {
16271627
struct drm_connector *connector;
1628-
struct amdgpu_dm_connector *aconnector;
16291628
struct drm_connector_state *drm_new_conn_state;
16301629
struct dm_connector_state *dm_new_conn_state;
16311630
struct dm_crtc_state *dm_old_crtc_state;
16321631

16331632
connector =
16341633
amdgpu_dm_find_first_crtc_matching_connector(state,
16351634
state->crtcs[ind].ptr);
1636-
aconnector = to_amdgpu_dm_connector(connector);
16371635
drm_new_conn_state =
16381636
drm_atomic_get_new_connector_state(state,
1639-
&aconnector->base);
1637+
connector);
16401638
dm_new_conn_state = to_dm_connector_state(drm_new_conn_state);
16411639
dm_old_crtc_state = to_dm_crtc_state(state->crtcs[ind].old_state);
16421640

16431641
local_dc_state->streams[i] =
1644-
create_validate_stream_for_sink(aconnector,
1642+
create_validate_stream_for_sink(connector,
16451643
&state->crtcs[ind].new_state->mode,
16461644
dm_new_conn_state,
16471645
dm_old_crtc_state->stream);

0 commit comments

Comments
 (0)