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

drm: Add valid clones check

Check that all encoders attached to a given CRTC are valid
possible_clones of each other.

Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241216-concurrent-wb-v4-3-fe220297a7f0@quicinc.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

authored by

Jessica Zhang and committed by
Dmitry Baryshkov
41b4b11d 5a6e8c36

+28
+28
drivers/gpu/drm/drm_atomic_helper.c
··· 574 574 return 0; 575 575 } 576 576 577 + static int drm_atomic_check_valid_clones(struct drm_atomic_state *state, 578 + struct drm_crtc *crtc) 579 + { 580 + struct drm_encoder *drm_enc; 581 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, 582 + crtc); 583 + 584 + drm_for_each_encoder_mask(drm_enc, crtc->dev, crtc_state->encoder_mask) { 585 + if (!drm_enc->possible_clones) { 586 + DRM_DEBUG("enc%d possible_clones is 0\n", drm_enc->base.id); 587 + continue; 588 + } 589 + 590 + if ((crtc_state->encoder_mask & drm_enc->possible_clones) != 591 + crtc_state->encoder_mask) { 592 + DRM_DEBUG("crtc%d failed valid clone check for mask 0x%x\n", 593 + crtc->base.id, crtc_state->encoder_mask); 594 + return -EINVAL; 595 + } 596 + } 597 + 598 + return 0; 599 + } 600 + 577 601 /** 578 602 * drm_atomic_helper_check_modeset - validate state object for modeset changes 579 603 * @dev: DRM device ··· 767 743 return ret; 768 744 769 745 ret = drm_atomic_add_affected_planes(state, crtc); 746 + if (ret != 0) 747 + return ret; 748 + 749 + ret = drm_atomic_check_valid_clones(state, crtc); 770 750 if (ret != 0) 771 751 return ret; 772 752 }