From 8360bd82c93bd22b185eefc77e435b66cb30e9f3 Mon Sep 17 00:00:00 2001 From: GG Hou Date: Tue, 16 May 2023 11:14:36 +0800 Subject: [PATCH] disp: msm: sde: disable CWB in quad pipe Disable CWB in quad pipe for quad LM CWB not supported to avoid out of bound access. Change-Id: I7e64cf132489401f91621ccde31cba68c8076d28 Signed-off-by: GG Hou --- msm/sde/sde_encoder_phys_wb.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/msm/sde/sde_encoder_phys_wb.c b/msm/sde/sde_encoder_phys_wb.c index b59d75e3ed..675695bf9c 100644 --- a/msm/sde/sde_encoder_phys_wb.c +++ b/msm/sde/sde_encoder_phys_wb.c @@ -605,6 +605,13 @@ static void _sde_encoder_phys_wb_setup_cwb(struct sde_encoder_phys *phys_enc, bo return; } + if (crtc->num_mixers > MAX_CWB_PER_CTL_V1) { + SDE_ERROR("[enc:%d wb:%d] %d LM %d CWB case not supported\n", + DRMID(phys_enc->parent), WBID(wb_enc), + crtc->num_mixers, MAX_CWB_PER_CTL_V1); + return; + } + hw_ctl = crtc->mixers[0].hw_ctl; if (hw_ctl && hw_ctl->ops.setup_intf_cfg_v1 && (test_bit(SDE_WB_CWB_CTRL, &hw_wb->caps->features) || @@ -914,7 +921,7 @@ static int _sde_enc_phys_wb_validate_cwb(struct sde_encoder_phys *phys_enc, struct sde_rect wb_roi = {0,}, pu_roi = {0,}; u32 out_width = 0, out_height = 0; const struct sde_format *fmt; - int prog_line, ret = 0; + int num_lm, prog_line, ret = 0; fb = sde_wb_connector_state_get_output_fb(conn_state); if (!fb) { @@ -922,6 +929,12 @@ static int _sde_enc_phys_wb_validate_cwb(struct sde_encoder_phys *phys_enc, return 0; } + num_lm = sde_crtc_get_num_datapath(crtc_state->crtc, conn_state->connector, crtc_state); + if (num_lm > MAX_CWB_PER_CTL_V1) { + SDE_ERROR("%d LM %d CWB case not supported\n", num_lm, MAX_CWB_PER_CTL_V1); + return -EINVAL; + } + fmt = sde_get_sde_format_ext(fb->format->format, fb->modifier); if (!fmt) { SDE_ERROR("unsupported output pixel format:%x\n", fb->format->format);