From nobody Thu Dec 18 18:00:46 2025 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6CF3194085 for ; Wed, 26 Jun 2024 21:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719438378; cv=none; b=YFwYIQxGxMQ/wjHTjyc/HjTJ25rT22dt81PDrhnpOjPSimxDBGCkyNjWPomvc7gZJaokJhzvpIuWHLSOiLbNuD/+IdbqLdmj3XbBR8inkWpyGyTBnNvdf9FQeqxa3777bSVU3sli8zdEOL1zHk6yKYGjfFJpxqI+wzCodGfOrDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719438378; c=relaxed/simple; bh=Ag9775D+dd0Vesuu0Racpc8vAYyqtYKHV6Q90Qvhm9Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hh9enNJNGfVIOJvFsDaepffGe4jCF1Br4kAJrXa9SJYAmYXPKGZy1x3Rooxta0SSf7Z0dZJbuTBCTRfcuz15z4fXAqVpzuGu4vuMjkukMbZc97x9TJZWeor2zKLcdKmzyvlEUMx/vSbRTBrV/D2wtLihbhM11/PIu7sbXtAhDY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=F7YpDv0n; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F7YpDv0n" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2ec4eefbaf1so64348401fa.1 for ; Wed, 26 Jun 2024 14:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719438374; x=1720043174; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6j1Oqrf688nsM2s31tFHNJb5eIHTmizO9USvB+zJtCc=; b=F7YpDv0nXCSksaGOZ5U4Y6Y9oONeCDCj4HQHS5LYbuw3gqhK4Hv5sKCmccmOGZSjvT j/fjRMvNUe9O38EwXhAKaX3drhXD2Qs/B8Ao5pYQVbNVufZke3nfux11KcZqPuP9i52y +pRkZIog7ITLkXGXJ9zdgZLZAH6n9bgNcW/IYO6ESAxwI3X8FEVfsM/NtoBNOi3tw1oi WXgbDvWun59XWbDl21movsROLWxspbdRp7vzIkE7Xbo6BRRNKXpwJU2jFEhWL78R/0zg dTlL9S1aCGscF1wy2vgH10YBNNFmJKH6NWOYwRj742EhY3Kjc82/9zeMsetDVboA83FQ c8Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719438374; x=1720043174; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6j1Oqrf688nsM2s31tFHNJb5eIHTmizO9USvB+zJtCc=; b=rVNgRmF0yp/IWBZ4M2qmWpvsbuo/ZdIgGWnk/Jz7dudBkTHdPW27PjvTW+zLOfUQsg 6AgXkwyFDihwb6AmflVkJXDonN1xs6Pc4MdzvMSCI/x90SKuM7RXM/79MQNVfPAPYGXK qe/L74DQU2Tv5rJ21adej/hNLMs3IPd9YUSAAhtJso7FNmHY7GePIWcd7sENFBJbPLgU +HncGGn3mekq5+mMBNpGYqQWZnzD1UdyCTTzFro46+4MqawEH00q0dK7p5Eg32ckqVfj eiwVoQ5g8C6hIAoq6UbaojY9MBZ7ScDtRkKJvQ8r9J7uTEIRi2bi9PcZzgP4po1s5A2c xlOA== X-Forwarded-Encrypted: i=1; AJvYcCWZu+QsjgcvztYWmlXg3JtaS+LaYDy5WCsmp5Rudoyd5bfnHtWu0YF4jRESfHcNTW/pZuV/7KNlAJjnrwHvbKFKKf9b+REaWLnO1B6N X-Gm-Message-State: AOJu0YwbDPSnC2VSeBIj7ruUVxYaCSByPp6uMe2DjQVm8XGD/syBHS1z emwhGvorzzdntzKSuuZekKVVk6hvwo4qXXYaE1I2yjaQsNDtPcwF4aLf/d0Rbd0= X-Google-Smtp-Source: AGHT+IG6yvMPKNsxGi6MmnuHK4/BDaw3nTiG9PJA9BoMa9dULCEOV8F6M8pX0zxmK8fUCTEBmwEwQA== X-Received: by 2002:a2e:9684:0:b0:2ec:403e:631a with SMTP id 38308e7fff4ca-2ec5b36b135mr71725221fa.8.1719438374102; Wed, 26 Jun 2024 14:46:14 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ee4a350d96sm23201fa.49.2024.06.26.14.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 14:46:13 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 27 Jun 2024 00:46:05 +0300 Subject: [PATCH v5 11/12] drm/msm/dpu: allow using two SSPP blocks for a single plane Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240627-dpu-virtual-wide-v5-11-5efb90cbb8be@linaro.org> References: <20240627-dpu-virtual-wide-v5-0-5efb90cbb8be@linaro.org> In-Reply-To: <20240627-dpu-virtual-wide-v5-0-5efb90cbb8be@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=10695; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=Ag9775D+dd0Vesuu0Racpc8vAYyqtYKHV6Q90Qvhm9Y=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmfIwZdiH8o53rDtDCEAVYLoLkZeb2ChyTQaBQV mbLBHZtV0aJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZnyMGQAKCRCLPIo+Aiko 1d0ZB/wOEOHT6dUdlcw7cg8/rZRiGI8r69zHcLc12KYHiLXKmaVYLN610BjDoedqWgIzz86bHFM G73GYVDW0ROUDzb/+lT/2vrOdm1cs0zRgbEyz3Hhkb023IOzb7Xc0RGDdaW+fgNRd0/eQQRjRet rWu1QLzu8M9+34kvuN0YYTFpNlZQeAZUzKt9Lf/0Z1XW1s0UKibAr9swDYbBaylnOUNeiWEdrAi VRzkoFRfQ/qBZ2Hr2sLMzkvdGjj/NCuCjYeQhXbvjYdkutvoXion6ssnpigAU6gDaTOTZThlEpw QHBSL5t3Lr6mOGuvqu95Iu8OHrEfkP1HGGPumwExKzxABfrR X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Virtual wide planes give high amount of flexibility, but it is not always enough: In parallel multirect case only the half of the usual width is supported for tiled formats. Thus the whole width of two tiled multirect rectangles can not be greater than max_linewidth, which is not enough for some platforms/compositors. Another example is as simple as wide YUV plane. YUV planes can not use multirect, so currently they are limited to max_linewidth too. Now that the planes are fully virtualized, add support for allocating two SSPP blocks to drive a single DRM plane. This fixes both mentioned cases and allows all planes to go up to 2*max_linewidth (at the cost of making some of the planes unavailable to the user). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 161 ++++++++++++++++++++++----= ---- 1 file changed, 117 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/ms= m/disp/dpu1/dpu_plane.c index c72c65bf55e1..0d9f9216420b 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c @@ -19,7 +19,6 @@ =20 #include "msm_drv.h" #include "dpu_kms.h" -#include "dpu_formats.h" #include "dpu_hw_sspp.h" #include "dpu_hw_util.h" #include "dpu_trace.h" @@ -886,6 +885,28 @@ static int dpu_plane_atomic_check_nopipe(struct drm_pl= ane *plane, return 0; } =20 +static int dpu_plane_is_multirect_parallel_capable(struct dpu_sw_pipe *pip= e, + struct dpu_sw_pipe_cfg *pipe_cfg, + const struct msm_format *fmt, + uint32_t max_linewidth) +{ + if (drm_rect_width(&pipe_cfg->src_rect) !=3D drm_rect_width(&pipe_cfg->ds= t_rect) || + drm_rect_height(&pipe_cfg->src_rect) !=3D drm_rect_height(&pipe_cfg->= dst_rect)) + return false; + + if (pipe_cfg->rotation & DRM_MODE_ROTATE_90) + return false; + + if (MSM_FORMAT_IS_YUV(fmt)) + return false; + + if (MSM_FORMAT_IS_UBWC(fmt) && + drm_rect_width(&pipe_cfg->src_rect) > max_linewidth / 2) + return false; + + return true; +} + static int dpu_plane_atomic_check_pipes(struct drm_plane *plane, struct drm_atomic_state *state, const struct drm_crtc_state *crtc_state) @@ -899,7 +920,6 @@ static int dpu_plane_atomic_check_pipes(struct drm_plan= e *plane, const struct msm_format *fmt; struct dpu_sw_pipe_cfg *pipe_cfg =3D &pstate->pipe_cfg; struct dpu_sw_pipe_cfg *r_pipe_cfg =3D &pstate->r_pipe_cfg; - uint32_t max_linewidth; uint32_t supported_rotations; const struct dpu_sspp_cfg *pipe_hw_caps; const struct dpu_sspp_sub_blks *sblk; @@ -921,8 +941,6 @@ static int dpu_plane_atomic_check_pipes(struct drm_plan= e *plane, =20 fmt =3D msm_framebuffer_format(new_plane_state->fb); =20 - max_linewidth =3D pdpu->catalog->caps->max_linewidth; - supported_rotations =3D DRM_MODE_REFLECT_MASK | DRM_MODE_ROTATE_0; =20 if (pipe_hw_caps->features & BIT(DPU_SSPP_INLINE_ROTATION)) @@ -938,41 +956,6 @@ static int dpu_plane_atomic_check_pipes(struct drm_pla= ne *plane, return ret; =20 if (drm_rect_width(&r_pipe_cfg->src_rect) !=3D 0) { - /* - * In parallel multirect case only the half of the usual width - * is supported for tiled formats. If we are here, we know that - * full width is more than max_linewidth, thus each rect is - * wider than allowed. - */ - if (MSM_FORMAT_IS_UBWC(fmt) && - drm_rect_width(&pipe_cfg->src_rect) > max_linewidth) { - DPU_DEBUG_PLANE(pdpu, "invalid src " DRM_RECT_FMT " line:%u, tiled form= at\n", - DRM_RECT_ARG(&pipe_cfg->src_rect), max_linewidth); - return -E2BIG; - } - - if (drm_rect_width(&pipe_cfg->src_rect) !=3D drm_rect_width(&pipe_cfg->d= st_rect) || - drm_rect_height(&pipe_cfg->src_rect) !=3D drm_rect_height(&pipe_cfg-= >dst_rect) || - (!test_bit(DPU_SSPP_SMART_DMA_V1, &pipe->sspp->cap->features) && - !test_bit(DPU_SSPP_SMART_DMA_V2, &pipe->sspp->cap->features)) || - pipe_cfg->rotation & DRM_MODE_ROTATE_90 || - MSM_FORMAT_IS_YUV(fmt)) { - DPU_DEBUG_PLANE(pdpu, "invalid src " DRM_RECT_FMT " line:%u, can't use = split source\n", - DRM_RECT_ARG(&pipe_cfg->src_rect), max_linewidth); - return -E2BIG; - } - - /* - * Use multirect for wide plane. We do not support dynamic - * assignment of SSPPs, so we know the configuration. - */ - pipe->multirect_index =3D DPU_SSPP_RECT_0; - pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_PARALLEL; - - r_pipe->sspp =3D pipe->sspp; - r_pipe->multirect_index =3D DPU_SSPP_RECT_1; - r_pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_PARALLEL; - ret =3D dpu_plane_atomic_check_pipe(pdpu, r_pipe, r_pipe_cfg, fmt, &crtc_state->adjusted_mode); if (ret) @@ -993,16 +976,16 @@ static int dpu_plane_atomic_check(struct drm_plane *p= lane, struct dpu_kms *dpu_kms =3D _dpu_plane_get_kms(plane); struct dpu_sw_pipe *pipe =3D &pstate->pipe; struct dpu_sw_pipe *r_pipe =3D &pstate->r_pipe; + struct dpu_sw_pipe_cfg *pipe_cfg =3D &pstate->pipe_cfg; + struct dpu_sw_pipe_cfg *r_pipe_cfg =3D &pstate->r_pipe_cfg; const struct drm_crtc_state *crtc_state =3D NULL; =20 if (new_plane_state->crtc) crtc_state =3D drm_atomic_get_new_crtc_state(state, new_plane_state->crtc); =20 - if (pdpu->pipe !=3D SSPP_NONE) { - pipe->sspp =3D dpu_rm_get_sspp(&dpu_kms->rm, pdpu->pipe); - r_pipe->sspp =3D NULL; - } + pipe->sspp =3D dpu_rm_get_sspp(&dpu_kms->rm, pdpu->pipe); + r_pipe->sspp =3D NULL; =20 if (!pipe->sspp) return -EINVAL; @@ -1019,6 +1002,47 @@ static int dpu_plane_atomic_check(struct drm_plane *= plane, r_pipe->multirect_index =3D DPU_SSPP_RECT_SOLO; r_pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_NONE; =20 + if (drm_rect_width(&r_pipe_cfg->src_rect) !=3D 0) { + uint32_t max_linewidth =3D dpu_kms->catalog->caps->max_linewidth; + const struct msm_format *fmt; + + fmt =3D msm_framebuffer_format(new_plane_state->fb); + + /* + * In parallel multirect case only the half of the usual width + * is supported for tiled formats. If we are here, we know that + * full width is more than max_linewidth, thus each rect is + * wider than allowed. + */ + if (MSM_FORMAT_IS_UBWC(fmt) && + drm_rect_width(&pipe_cfg->src_rect) > max_linewidth) { + DPU_DEBUG_PLANE(pdpu, "invalid src " DRM_RECT_FMT " line:%u, tiled form= at\n", + DRM_RECT_ARG(&pipe_cfg->src_rect), max_linewidth); + return -E2BIG; + } + + if (drm_rect_width(&pipe_cfg->src_rect) !=3D drm_rect_width(&pipe_cfg->d= st_rect) || + drm_rect_height(&pipe_cfg->src_rect) !=3D drm_rect_height(&pipe_cfg-= >dst_rect) || + (!test_bit(DPU_SSPP_SMART_DMA_V1, &pipe->sspp->cap->features) && + !test_bit(DPU_SSPP_SMART_DMA_V2, &pipe->sspp->cap->features)) || + pipe_cfg->rotation & DRM_MODE_ROTATE_90 || + MSM_FORMAT_IS_YUV(fmt)) { + DPU_DEBUG_PLANE(pdpu, "invalid src " DRM_RECT_FMT " line:%u, can't use = split source\n", + DRM_RECT_ARG(&pipe_cfg->src_rect), max_linewidth); + return -E2BIG; + } + + /* + * Use multirect for wide plane. We do not support dynamic + * assignment of SSPPs, so we know the configuration. + */ + pipe->multirect_index =3D DPU_SSPP_RECT_0; + pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_PARALLEL; + + r_pipe->multirect_index =3D DPU_SSPP_RECT_1; + r_pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_PARALLEL; + } + return dpu_plane_atomic_check_pipes(plane, state, crtc_state); } =20 @@ -1052,8 +1076,16 @@ static int dpu_plane_virtual_atomic_check(struct drm= _plane *plane, return 0; } =20 - /* force resource reallocation if the format of FB has changed */ + /* + * Force resource reallocation if the format of FB or src/dst have + * changed. We might need to allocate different SSPP or SSPPs for this + * plane than the one used previously. + */ if (!old_plane_state || !old_plane_state->fb || + old_plane_state->src_w !=3D plane_state->src_w || + old_plane_state->src_h !=3D plane_state->src_h || + old_plane_state->src_w !=3D plane_state->src_w || + old_plane_state->crtc_h !=3D plane_state->crtc_h || msm_framebuffer_format(old_plane_state->fb) !=3D msm_framebuffer_format(plane_state->fb)) crtc_state->planes_changed =3D true; @@ -1073,7 +1105,10 @@ static int dpu_plane_virtual_assign_resources(struct= drm_crtc *crtc, 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; const struct msm_format *fmt; + uint32_t max_linewidth; =20 if (plane_state->crtc) crtc_state =3D drm_atomic_get_new_crtc_state(state, @@ -1082,6 +1117,8 @@ static int dpu_plane_virtual_assign_resources(struct = drm_crtc *crtc, pstate =3D to_dpu_plane_state(plane_state); pipe =3D &pstate->pipe; r_pipe =3D &pstate->r_pipe; + pipe_cfg =3D &pstate->pipe_cfg; + r_pipe_cfg =3D &pstate->r_pipe_cfg; =20 pipe->sspp =3D NULL; r_pipe->sspp =3D NULL; @@ -1096,10 +1133,46 @@ static int dpu_plane_virtual_assign_resources(struc= t drm_crtc *crtc, =20 reqs.rot90 =3D drm_rotation_90_or_270(plane_state->rotation); =20 + max_linewidth =3D dpu_kms->catalog->caps->max_linewidth; + pipe->sspp =3D dpu_rm_reserve_sspp(&dpu_kms->rm, global_state, crtc, &req= s); if (!pipe->sspp) return -ENODEV; =20 + if (drm_rect_width(&r_pipe_cfg->src_rect) =3D=3D 0) { + pipe->multirect_index =3D DPU_SSPP_RECT_SOLO; + pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_NONE; + + r_pipe->multirect_index =3D DPU_SSPP_RECT_SOLO; + r_pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_NONE; + + r_pipe->sspp =3D NULL; + } else { + if (dpu_plane_is_multirect_parallel_capable(pipe, pipe_cfg, fmt, max_lin= ewidth) && + 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 =3D pipe->sspp; + + pipe->multirect_index =3D DPU_SSPP_RECT_0; + pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_PARALLEL; + + r_pipe->multirect_index =3D DPU_SSPP_RECT_1; + r_pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_PARALLEL; + } else { + /* multirect is not possible, use two SSPP blocks */ + r_pipe->sspp =3D dpu_rm_reserve_sspp(&dpu_kms->rm, global_state, crtc, = &reqs); + if (!r_pipe->sspp) + return -ENODEV; + + pipe->multirect_index =3D DPU_SSPP_RECT_SOLO; + pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_NONE; + + r_pipe->multirect_index =3D DPU_SSPP_RECT_SOLO; + r_pipe->multirect_mode =3D DPU_SSPP_MULTIRECT_NONE; + } + } + return dpu_plane_atomic_check_pipes(plane, state, crtc_state); } =20 --=20 2.39.2