Re: [PATCH v2 13/14] drm/msm/dpu: support SSPP assignment for quad-pipe case
From: Dmitry Baryshkov
Date: Thu Oct 10 2024 - 09:42:43 EST
On Wed, Oct 09, 2024 at 04:50:26PM GMT, Jun Nie wrote:
> Support SSPP assignment for quad-pipe case with unified method.
> The first 2 pipes can share a set of mixer config and enable
> multi-rect mode if condition is met. It is also the case for
> the later 2 pipes.
>
> Signed-off-by: Jun Nie <jun.nie@xxxxxxxxxx>
> ---
> drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 85 +++++++++++++++----------------
> 1 file changed, 42 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index 480a1b46aba72..23de2ca6fabb0 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -999,7 +999,7 @@ static int dpu_plane_atomic_check_pipes(struct drm_plane *plane,
> pipe = &pstate->pipe[i];
> pipe_cfg = &pstate->pipe_cfg[i];
> if (!pipe_cfg->valid || !pipe->sspp)
> - break;
> + continue;
> DPU_DEBUG_PLANE(pdpu, "pipe %d is in use, validate it\n", i);
> ret = dpu_plane_atomic_check_pipe(pdpu, pipe, pipe_cfg,
> &crtc_state->adjusted_mode,
> @@ -1154,13 +1154,10 @@ static int dpu_plane_virtual_assign_resources(struct drm_crtc *crtc,
> struct dpu_kms *dpu_kms = _dpu_plane_get_kms(plane);
> struct dpu_rm_sspp_requirements reqs;
> struct dpu_plane_state *pstate;
> - struct dpu_sw_pipe *pipe;
> - struct dpu_sw_pipe *r_pipe;
> - struct dpu_sw_pipe_cfg *pipe_cfg;
> - struct dpu_sw_pipe_cfg *r_pipe_cfg;
> + struct dpu_plane *pdpu = to_dpu_plane(plane);
> const struct msm_format *fmt;
> uint32_t max_linewidth;
> - int i;
> + int i, lm_num, lmcfg_id, lmcfg_num;
>
> if (plane_state->crtc)
> crtc_state = drm_atomic_get_new_crtc_state(state,
> @@ -1168,12 +1165,6 @@ static int dpu_plane_virtual_assign_resources(struct drm_crtc *crtc,
>
> pstate = to_dpu_plane_state(plane_state);
>
> - /* loop below code for another pair later */
> - pipe = &pstate->pipe[0];
> - r_pipe = &pstate->pipe[1];
> - pipe_cfg = &pstate->pipe_cfg[0];
> - r_pipe_cfg = &pstate->pipe_cfg[1];
> -
> for (i = 0; i < PIPES_PER_PLANE; i++)
> pstate->pipe[i].sspp = NULL;
>
> @@ -1189,41 +1180,49 @@ static int dpu_plane_virtual_assign_resources(struct drm_crtc *crtc,
>
> max_linewidth = dpu_kms->catalog->caps->max_linewidth;
>
> - pipe->sspp = dpu_rm_reserve_sspp(&dpu_kms->rm, global_state, crtc, &reqs);
> - if (!pipe->sspp)
> - return -ENODEV;
> -
> - if (drm_rect_width(&r_pipe_cfg->src_rect) == 0) {
> - pipe->multirect_index = DPU_SSPP_RECT_SOLO;
> - pipe->multirect_mode = DPU_SSPP_MULTIRECT_NONE;
> -
> - r_pipe->multirect_index = DPU_SSPP_RECT_SOLO;
> - r_pipe->multirect_mode = DPU_SSPP_MULTIRECT_NONE;
> -
> - r_pipe->sspp = NULL;
> - } else {
> - if (dpu_plane_is_multirect_parallel_capable(pipe, pipe_cfg, fmt, max_linewidth) &&
> - dpu_plane_is_multirect_parallel_capable(r_pipe, r_pipe_cfg, fmt, max_linewidth) &&
> - (test_bit(DPU_SSPP_SMART_DMA_V1, &pipe->sspp->cap->features) ||
> - test_bit(DPU_SSPP_SMART_DMA_V2, &pipe->sspp->cap->features))) {
> - r_pipe->sspp = pipe->sspp;
> + lm_num = dpu_crtc_get_lm_num(crtc_state);
> + lmcfg_num = (lm_num + 1) / 2;
> + for (lmcfg_id = 0; lmcfg_id < lmcfg_num; lmcfg_id++) {
> + for (i = lmcfg_id * PIPES_PER_LM_PAIR; i < (lmcfg_id + 1) * PIPES_PER_LM_PAIR; i++) {
> + struct dpu_sw_pipe *pipe = &pstate->pipe[i];
> + struct dpu_sw_pipe *r_pipe = &pstate->pipe[i + 1];
> + struct dpu_sw_pipe_cfg *pipe_cfg = &pstate->pipe_cfg[i];
> + struct dpu_sw_pipe_cfg *r_pipe_cfg = &pstate->pipe_cfg[i + 1];
>
> - pipe->multirect_index = DPU_SSPP_RECT_0;
> - pipe->multirect_mode = DPU_SSPP_MULTIRECT_PARALLEL;
> + if (!pipe_cfg->valid)
> + break;
>
> - r_pipe->multirect_index = DPU_SSPP_RECT_1;
> - r_pipe->multirect_mode = DPU_SSPP_MULTIRECT_PARALLEL;
> - } else {
> - /* multirect is not possible, use two SSPP blocks */
> - r_pipe->sspp = dpu_rm_reserve_sspp(&dpu_kms->rm, global_state, crtc, &reqs);
> - if (!r_pipe->sspp)
> + pipe->sspp = dpu_rm_reserve_sspp(&dpu_kms->rm, global_state, crtc, &reqs);
> + if (!pipe->sspp)
> return -ENODEV;
>
> - pipe->multirect_index = DPU_SSPP_RECT_SOLO;
> - pipe->multirect_mode = DPU_SSPP_MULTIRECT_NONE;
> -
> - r_pipe->multirect_index = DPU_SSPP_RECT_SOLO;
> - r_pipe->multirect_mode = DPU_SSPP_MULTIRECT_NONE;
> + /*
> + * If current pipe is the first pipe in pipe pair, check
> + * multi-rect opportunity for the 2nd pipe in the pair.
> + * SSPP multi-rect mode cross mixer pairs is not supported.
> + */
> + if (!(i % 2) &&
if ((i % PIPES_PER_LM_PAIR == 0) &&
> + r_pipe_cfg->valid &&
> + drm_rect_width(&r_pipe_cfg->src_rect) != 0 &&
> + dpu_plane_is_multirect_parallel_capable(pipe, pipe_cfg, fmt, max_linewidth) &&
> + dpu_plane_is_multirect_parallel_capable(r_pipe, r_pipe_cfg, fmt, max_linewidth) &&
> + (test_bit(DPU_SSPP_SMART_DMA_V1, &pipe->sspp->cap->features) ||
> + test_bit(DPU_SSPP_SMART_DMA_V2, &pipe->sspp->cap->features))) {
> + pipe->multirect_index = DPU_SSPP_RECT_0;
> + pipe->multirect_mode = DPU_SSPP_MULTIRECT_PARALLEL;
> +
> + DPU_DEBUG_PLANE(pdpu, "allocating sspp_%d for pipe %d and set pipe %d as multi-rect\n",
> + pipe->sspp->idx - SSPP_NONE, i, i + 1);
> + r_pipe->sspp = pipe->sspp;
> + r_pipe->multirect_index = DPU_SSPP_RECT_1;
> + r_pipe->multirect_mode = DPU_SSPP_MULTIRECT_PARALLEL;
> + i++;
> + } else {
> + pipe->multirect_index = DPU_SSPP_RECT_SOLO;
> + pipe->multirect_mode = DPU_SSPP_MULTIRECT_NONE;
> + DPU_DEBUG_PLANE(pdpu, "allocating sspp_%d for pipe %d.\n",
> + pipe->sspp->idx - SSPP_NONE, i);
> + }
> }
> }
>
>
> --
> 2.34.1
>
--
With best wishes
Dmitry