Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "drm/vc4: hdmi: Remove drm_encoder->crtc usage"

This reverts commit 27da370e0fb343a0baf308f503bb3e5dcdfe3362.

Sudip Mukherjee reports that this broke pulseaudio with a NULL pointer
dereference in vc4_hdmi_audio_prepare(), bisected it to this commit, and
confirmed that a revert fixed the problem.

Revert the problematic commit until fixed.

Link: https://lore.kernel.org/all/CADVatmPB9-oKd=ypvj25UYysVo6EZhQ6bCM7EvztQBMyiZfAyw@mail.gmail.com/
Link: https://lore.kernel.org/all/CADVatmN5EpRshGEPS_JozbFQRXg5w_8LFB3OMP1Ai-ghxd3w4g@mail.gmail.com/
Reported-and-tested-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Emma Anholt <emma@anholt.net>
Cc: Dave Airlie <airlied@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+13 -27
+13 -27
drivers/gpu/drm/vc4/vc4_hdmi.c
··· 432 432 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); 433 433 struct drm_connector *connector = &vc4_hdmi->connector; 434 434 struct drm_connector_state *cstate = connector->state; 435 - struct drm_crtc *crtc = cstate->crtc; 435 + struct drm_crtc *crtc = encoder->crtc; 436 436 const struct drm_display_mode *mode = &crtc->state->adjusted_mode; 437 437 union hdmi_infoframe frame; 438 438 int ret; ··· 537 537 538 538 static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder) 539 539 { 540 + struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; 540 541 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 541 - struct drm_connector *connector = &vc4_hdmi->connector; 542 - struct drm_connector_state *cstate = connector->state; 543 - struct drm_crtc *crtc = cstate->crtc; 544 - struct drm_display_mode *mode = &crtc->state->adjusted_mode; 545 542 546 543 if (!vc4_hdmi_supports_scrambling(encoder, mode)) 547 544 return; ··· 559 562 static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder) 560 563 { 561 564 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 562 - struct drm_connector *connector = &vc4_hdmi->connector; 563 - struct drm_connector_state *cstate = connector->state; 565 + struct drm_crtc *crtc = encoder->crtc; 564 566 565 567 /* 566 - * At boot, connector->state will be NULL. Since we don't know the 568 + * At boot, encoder->crtc will be NULL. Since we don't know the 567 569 * state of the scrambler and in order to avoid any 568 570 * inconsistency, let's disable it all the time. 569 571 */ 570 - if (cstate && !vc4_hdmi_supports_scrambling(encoder, &cstate->crtc->mode)) 572 + if (crtc && !vc4_hdmi_supports_scrambling(encoder, &crtc->mode)) 571 573 return; 572 574 573 - if (cstate && !vc4_hdmi_mode_needs_scrambling(&cstate->crtc->mode)) 575 + if (crtc && !vc4_hdmi_mode_needs_scrambling(&crtc->mode)) 574 576 return; 575 577 576 578 if (delayed_work_pending(&vc4_hdmi->scrambling_work)) ··· 891 895 vc4_hdmi_encoder_get_connector_state(encoder, state); 892 896 struct vc4_hdmi_connector_state *vc4_conn_state = 893 897 conn_state_to_vc4_hdmi_conn_state(conn_state); 894 - struct drm_crtc_state *crtc_state = 895 - drm_atomic_get_new_crtc_state(state, conn_state->crtc); 896 - struct drm_display_mode *mode = &crtc_state->adjusted_mode; 898 + struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; 897 899 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 898 900 unsigned long bvb_rate, pixel_rate, hsm_rate; 899 901 int ret; ··· 985 991 static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder, 986 992 struct drm_atomic_state *state) 987 993 { 988 - struct drm_connector_state *conn_state = 989 - vc4_hdmi_encoder_get_connector_state(encoder, state); 990 - struct drm_crtc_state *crtc_state = 991 - drm_atomic_get_new_crtc_state(state, conn_state->crtc); 992 - struct drm_display_mode *mode = &crtc_state->adjusted_mode; 994 + struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; 993 995 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); 994 996 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 995 997 ··· 1008 1018 static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, 1009 1019 struct drm_atomic_state *state) 1010 1020 { 1011 - struct drm_connector_state *conn_state = 1012 - vc4_hdmi_encoder_get_connector_state(encoder, state); 1013 - struct drm_crtc_state *crtc_state = 1014 - drm_atomic_get_new_crtc_state(state, conn_state->crtc); 1015 - struct drm_display_mode *mode = &crtc_state->adjusted_mode; 1021 + struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; 1016 1022 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 1017 1023 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); 1018 1024 bool hsync_pos = mode->flags & DRM_MODE_FLAG_PHSYNC; ··· 1196 1210 1197 1211 static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi, unsigned int samplerate) 1198 1212 { 1199 - struct drm_connector *connector = &vc4_hdmi->connector; 1200 - struct drm_crtc *crtc = connector->state->crtc; 1213 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; 1214 + struct drm_crtc *crtc = encoder->crtc; 1201 1215 const struct drm_display_mode *mode = &crtc->state->adjusted_mode; 1202 1216 u32 n, cts; 1203 1217 u64 tmp; ··· 1230 1244 static int vc4_hdmi_audio_startup(struct device *dev, void *data) 1231 1245 { 1232 1246 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); 1233 - struct drm_connector *connector = &vc4_hdmi->connector; 1247 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base; 1234 1248 1235 1249 /* 1236 1250 * If the HDMI encoder hasn't probed, or the encoder is 1237 1251 * currently in DVI mode, treat the codec dai as missing. 1238 1252 */ 1239 - if (!connector->state || !(HDMI_READ(HDMI_RAM_PACKET_CONFIG) & 1253 + if (!encoder->crtc || !(HDMI_READ(HDMI_RAM_PACKET_CONFIG) & 1240 1254 VC4_HDMI_RAM_PACKET_ENABLE)) 1241 1255 return -ENODEV; 1242 1256