From patchwork Thu Jan 23 12:43:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13948238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CD94C02182 for ; Thu, 23 Jan 2025 12:45:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E3CE10E7FD; Thu, 23 Jan 2025 12:45:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BbSgp1fg"; dkim-atps=neutral Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC6BB10E7FD for ; Thu, 23 Jan 2025 12:45:00 +0000 (UTC) Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-30615661f98so8373781fa.2 for ; Thu, 23 Jan 2025 04:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737636299; x=1738241099; darn=lists.freedesktop.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=zWl/mrUuu5iSDDnMWnDf6mIxagIYPOHoQVKnYJ6xmpc=; b=BbSgp1fgqchrvBM/UVkQaKf5BYGZhmq1Vp5NP75kUONmU8QVXgBjfvDGPrzBgkP1PY fnDuOpRW9ZmFXxa5HYp1VGbI8shKArZYl2rzpnfftsVOw+sxO+IYELoaoGtSFllR69Dk GSuw0n0zCLmBSnN4RdSMgx2Hg1bujuNL9uhyUbVqGPEPYf3ygNgl/6hTNRhzVVqU0TGh QXkjPvNpyXaVxi5ZCvmDvspK3onfjm0LSwyRXsbOoIjrtE4TzfFLajZktk7UfNCq9PDL pJib7azYuCK8wukN4vAd/VA4gzjnOcPfTCSycZOD4PhJwq5ISdB4yJt6KxbWGqMCqUjt Op9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737636299; x=1738241099; 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=zWl/mrUuu5iSDDnMWnDf6mIxagIYPOHoQVKnYJ6xmpc=; b=iyhnsqw6nd3JtmpisZ8lEKImUHkPdAA70Q2m0Zrc/RiCiIUm6jPiH1izJycImfMcY0 XJ2tz87883k2didg2KW3NH8LIypMBQrEwCUMKa6vi5UrmQF0iihG1dLNK8tQaDGWM2NF /WWUBOFSYXHC1BHk/A0L0bdFxFu0YSEGSBezYjaFsd9Sg/QMdXyEyv9g+AJWv3KGXeIr qeTUDX8YyS6g1AB6KQyTqc/2eESNwdZxI04y89lHokeYiTDyBXijAHwRkkctdRxSOW34 FovKxCYI77NDk0mAkhVCvKyBcv1cvSMdJF54OrTeJdjY/hONfIt1lwO65SwsHdzi2bIB baSw== X-Gm-Message-State: AOJu0YzL01fd5VNgTMMM98zjVwvT+0hMq/ly3LYVaKILk2gA8Te6ADrO DPGGdG6GqUR6MlRtRSUUhsU4RME/kLeUzev7mOrMX9vrBb+xguZ6dGj4ftxeLkQ= X-Gm-Gg: ASbGncvDQCrrel7xY06UbtOEw/+UZOnx8oMy78mPXwD4qwrTKGxouRFkA0DaxtflgSH fWK8FxSOHIEhPEI7soh2cu6OAUBeYf0Nx1oiJKao/V9xcygS1iccNGE5buP2UF40rxU6+8Yw6QZ V6U5/00m6aQ3WS8PGLIvfmhiNR2a49rWEJMKJSz2LVjsYK4b/PZTB/5coHhgC10Un2MLRzkx7Ce ar8uxalP9eo9cdmo0YgrGCzn+kg3I7//j09TRhT/5esRmzXeDnksfdsgJ6wnWw3OQ+XSuBQm3q7 FZHlt7uN1HLB X-Google-Smtp-Source: AGHT+IH5IcSIZSra8LNFX06NTWLQF49L8vuXLlXRQh+G8XpZMvxMtaLUd8nrGDGk8rwkOVFCuslUyw== X-Received: by 2002:a05:651c:b0a:b0:300:31db:a77c with SMTP id 38308e7fff4ca-3072cb66636mr95637551fa.29.1737636299239; Thu, 23 Jan 2025 04:44:59 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a4ed6f3sm30351661fa.86.2025.01.23.04.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 04:44:57 -0800 (PST) From: Dmitry Baryshkov Date: Thu, 23 Jan 2025 14:43:33 +0200 Subject: [PATCH v2 1/4] drm/msm/dpu: don't use active in atomic_check() MIME-Version: 1.0 Message-Id: <20250123-drm-dirty-modeset-v2-1-bbfd3a6cd1a4@linaro.org> References: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> In-Reply-To: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Chandan Uddaraju , Jeykumar Sankaran , Jordan Crouse , Sravanthi Kollukuduru Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Archit Taneja , Rajesh Yadav , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Simona Vetter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2323; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=6FHiK9uSt3de2pV2Wxfa/Fv4p/tQ6hl+nIDAnUNBki8=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnkjnGZW1iNAEucAxcOXqyOyw158iAcmY8raCT8 0H4hgMFpe2JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5I5xgAKCRCLPIo+Aiko 1brHB/93op8onAUXr5fU2A91buXHuSnIU4NV07hLC1vcebijvhJa1lT5ijFMMW5lkFVva1FJraK lTMyHGLBKOQVPBInM0u4bJPw23lqTdKT29bvGzjNNqkVjTrQFlQ3jlqGWBVqkqbLC8tEdP0oZlz eHJtnIddkK/uiP/gugYSZysBeHZMaXbYGczZg6LzXAE6ZIOiwVw8f5eIPLnYExHgLSw+qrHo4fd vo57FzUtE7M2eEEtJzTKaiDKfDVuEuLVjPA7ANYeNi7eUmY6tkvVo60tBnB2VvHPLlmGcewJG4M gg6BZn4vxqTEFxE3zWgCnOtwraczzavKlUDfWCb/XymzDNhL X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver isn't supposed to consult crtc_state->active/active_check for resource allocation. Instead all resources should be allocated if crtc_state->enabled is set. Stop consulting active / active_changed in order to determine whether the hardware resources should be (re)allocated. Fixes: ccc862b957c6 ("drm/msm/dpu: Fix reservation failures in modeset") Reported-by: Simona Vetter Closes: https://lore.kernel.org/dri-devel/ZtW_S0j5AEr4g0QW@phenom.ffwll.local/ Reviewed-by: Simona Vetter Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 4 ---- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index 7191b1a6d41b3a96f956d199398f12b2923e8c82..65e33eba61726929b740831c95330756b2817e28 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -1264,10 +1264,6 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc, DRM_DEBUG_ATOMIC("%s: check\n", dpu_crtc->name); - /* force a full mode set if active state changed */ - if (crtc_state->active_changed) - crtc_state->mode_changed = true; - if (cstate->num_mixers) { rc = _dpu_crtc_check_and_setup_lm_bounds(crtc, crtc_state); if (rc) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 5172ab4dea995a154cd88d05c3842d7425fc34ce..9aacd3b5bcf808c5712bf797a48484e297386c1c 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -793,12 +793,11 @@ static int dpu_encoder_virt_atomic_check( crtc_state->mode_changed = true; /* * Release and Allocate resources on every modeset - * Dont allocate when active is false. */ if (drm_atomic_crtc_needs_modeset(crtc_state)) { dpu_rm_release(global_state, drm_enc); - if (!crtc_state->active_changed || crtc_state->enable) + if (crtc_state->enable) ret = dpu_rm_reserve(&dpu_kms->rm, global_state, drm_enc, crtc_state, &topology); if (!ret) From patchwork Thu Jan 23 12:43:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13948239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3084C02182 for ; Thu, 23 Jan 2025 12:45:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 35CE610E7FF; Thu, 23 Jan 2025 12:45:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A24sduoZ"; dkim-atps=neutral Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 887B810E800 for ; Thu, 23 Jan 2025 12:45:02 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-540215984f0so942611e87.1 for ; Thu, 23 Jan 2025 04:45:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737636301; x=1738241101; darn=lists.freedesktop.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=dGG1s1S8D3eBzGHQyK9YTyucSj2Qt8yK2qJGvoIIk2c=; b=A24sduoZSdP+FnujIXK0h2SKD8Qq0qI6vX7Ozq1juu8IRsdYY2sJ4mLOvgvUnkMTqU volPHT9dgGnUTy9GznNn7GKDiNXGPmjOtyIEiQBViPMXxPjqV5YYwPS5+/fmKSKMd443 WIdaaA0UHJhERCz1xtdvz0SR5m9lQ93vmhBbvX+UwUmDnw9wfg1UrHxsuS4RAu8zfVkq /RxjsqaaH/bcsXjjCIZi07OeljjDPM10uo8f5GBEXnjl5leGqHecpbTY+dlgcazOZyZb ttX1Eouvv+LxabSDfTTahQsrE4s+PpThrKKuTKV0iEVuhhoBm5vmI22H/1qjs+MGOR61 JelQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737636301; x=1738241101; 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=dGG1s1S8D3eBzGHQyK9YTyucSj2Qt8yK2qJGvoIIk2c=; b=SzQ9HN3snTQt2UgCQ2JEf4dBR3DMb0fuvtuwZLq/RkwlGw7MzJtxzHW1cv/Fd3EljM EI0uGWpeOh6JTT8yVEItBnVYW2n7Mm70aHX06M8acXx1W66Dt/JGhPxXdtiSyN3KZ1D0 wYe+PgY1qpdjayWCotJx9bsyLz5jJmavbem67Y06vgIYtFdnSTqxnJg1IvqPm0Y6VLRE lH2NzE9ls4KRylFzH3sglA+GhRmzHH3f2lrZp5HCgd9/CzVt17+SnNy/26Kqqb4g3kVq M8ynrokzXN9tcRH3nQkikydXAXEsG/34ayTlLNFyHzLXFFB8HwX3FQgKERWUrKSLk6dt RIXA== X-Gm-Message-State: AOJu0YxLvRaNBqKPldA6qBV61g0DtlEtfP7rB8HU66Z0fX3mrpk14NiW 9vsw0ngDiyBJfw1Vo2kwCfZgtaP3faPf/1MAnLlnf6TMryNAUckmgPOdMw5vneU= X-Gm-Gg: ASbGncsANYIutUX2jXpcp7K6WmE1whzP4sToDAHXqMR7uy1RZ8zvVo5EnRFcglJBo7S 02z/kgNfDgUech7yLxQl1Krt5QChhqtU9dsF9eg8Y3m5IVMIPa0pBtjw13HP2U9u9oghDt+w+XF ZP72VOZa/JfIGZZuxg38u8OkpR6F5TCXdfUXuKjk8w2/h1tlKpqoGcC4gLNjURLHjSn4JsOEhEQ 4st2wcgTqnbX3xk+jscYrp/J15WV0gb9x8+DM22vGQBJTa32bwelWKgV/FALz0DxuA4JIc7ZaeC QyTK2fNgq4ZV X-Google-Smtp-Source: AGHT+IEc3fFogjnD5/4R2Bf8a7GwLgIkwuzc+D1oUKDeQls5NYh149P1sZOUsIA8lUqhtjnEtev08Q== X-Received: by 2002:ac2:4570:0:b0:540:2542:d89a with SMTP id 2adb3069b0e04-5439c288152mr7747160e87.52.1737636300767; Thu, 23 Jan 2025 04:45:00 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a4ed6f3sm30351661fa.86.2025.01.23.04.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 04:45:00 -0800 (PST) From: Dmitry Baryshkov Date: Thu, 23 Jan 2025 14:43:34 +0200 Subject: [PATCH v2 2/4] drm/msm/dpu: move needs_cdm setting to dpu_encoder_get_topology() MIME-Version: 1.0 Message-Id: <20250123-drm-dirty-modeset-v2-2-bbfd3a6cd1a4@linaro.org> References: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> In-Reply-To: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Chandan Uddaraju , Jeykumar Sankaran , Jordan Crouse , Sravanthi Kollukuduru Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Archit Taneja , Rajesh Yadav , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Simona Vetter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3658; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=9zVeq6fbBs87RymcRg/e2kjiz2Fyvfkzu2Dc7p8G1oo=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnkjnGQQwX2/92m28UDkxPgHsjijqmj3l0C61CP AJaqUsuPNuJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5I5xgAKCRCLPIo+Aiko 1aPUB/wJz/4RT6wQtzDjjYlvwIs+lCHplpQm8SAQzmtOd0QvhldFakRolrA8jhX141F8kesTbWU 69JPnlE8fSAql+i/0C+bUlttsx1rLhdm+Gfh9igYykbkhvNBzYjS3tiqZNKTjLJwTmcUcKtQ82d EVc8iyVdH6bxVVBjBK9ANniX+kooBCheFePAUIWpE7UMmO/zHDD7s/tjbhFKI9aVJqy0x6XsR+0 dLFer5EfYXrvXHg43BqhnYcEqXg+pZ9I3OYk+NLLN8caFgz9MfnGc4cLFXXkt8TpNCsxsu5jleD Npo53pNQFkPsDdZVxsw/YlmzDSlbpUtiYT0Bjm0U+iHtWgwt X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As a preparation for calling dpu_encoder_get_topology() from different places, move the code setting topology->needs_cdm to that function (instead of patching topology separately). Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 41 ++++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 9aacd3b5bcf808c5712bf797a48484e297386c1c..5dc2e0585de1337601a0426795d2c8f2806ccd10 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -652,8 +652,11 @@ static struct msm_display_topology dpu_encoder_get_topology( struct dpu_kms *dpu_kms, struct drm_display_mode *mode, struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, struct drm_dsc_config *dsc) { + struct msm_drm_private *priv = dpu_enc->base.dev->dev_private; + struct msm_display_info *disp_info = &dpu_enc->disp_info; struct msm_display_topology topology = {0}; int i, intf_count = 0; @@ -696,6 +699,23 @@ static struct msm_display_topology dpu_encoder_get_topology( topology.num_intf = 1; } + /* + * Use CDM only for writeback or DP at the moment as other interfaces cannot handle it. + * If writeback itself cannot handle cdm for some reason it will fail in its atomic_check() + * earlier. + */ + if (disp_info->intf_type == INTF_WB && conn_state->writeback_job) { + struct drm_framebuffer *fb; + + fb = conn_state->writeback_job->fb; + + if (fb && MSM_FORMAT_IS_YUV(msm_framebuffer_format(fb))) + topology.needs_cdm = true; + } else if (disp_info->intf_type == INTF_DP) { + if (msm_dp_is_yuv_420_enabled(priv->dp[disp_info->h_tile_instance[0]], mode)) + topology.needs_cdm = true; + } + return topology; } @@ -743,9 +763,7 @@ static int dpu_encoder_virt_atomic_check( struct dpu_kms *dpu_kms; struct drm_display_mode *adj_mode; struct msm_display_topology topology; - struct msm_display_info *disp_info; struct dpu_global_state *global_state; - struct drm_framebuffer *fb; struct drm_dsc_config *dsc; int ret = 0; @@ -759,7 +777,6 @@ static int dpu_encoder_virt_atomic_check( DPU_DEBUG_ENC(dpu_enc, "\n"); priv = drm_enc->dev->dev_private; - disp_info = &dpu_enc->disp_info; dpu_kms = to_dpu_kms(priv->kms); adj_mode = &crtc_state->adjusted_mode; global_state = dpu_kms_get_global_state(crtc_state->state); @@ -770,22 +787,8 @@ static int dpu_encoder_virt_atomic_check( dsc = dpu_encoder_get_dsc_config(drm_enc); - topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode, crtc_state, dsc); - - /* - * Use CDM only for writeback or DP at the moment as other interfaces cannot handle it. - * If writeback itself cannot handle cdm for some reason it will fail in its atomic_check() - * earlier. - */ - if (disp_info->intf_type == INTF_WB && conn_state->writeback_job) { - fb = conn_state->writeback_job->fb; - - if (fb && MSM_FORMAT_IS_YUV(msm_framebuffer_format(fb))) - topology.needs_cdm = true; - } else if (disp_info->intf_type == INTF_DP) { - if (msm_dp_is_yuv_420_enabled(priv->dp[disp_info->h_tile_instance[0]], adj_mode)) - topology.needs_cdm = true; - } + topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode, crtc_state, conn_state, + dsc); if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) crtc_state->mode_changed = true; From patchwork Thu Jan 23 12:43:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13948241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 704D0C0218B for ; Thu, 23 Jan 2025 12:45:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DBE6210E802; Thu, 23 Jan 2025 12:45:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="t/S0bNJt"; dkim-atps=neutral Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1F6010E801 for ; Thu, 23 Jan 2025 12:45:03 +0000 (UTC) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-30225b2586cso20405571fa.0 for ; Thu, 23 Jan 2025 04:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737636302; x=1738241102; darn=lists.freedesktop.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=4vF0qbcrlUHMns+leDnByN9gAa2CtmYb+mw9y9wF8iU=; b=t/S0bNJtFLIslBO3Cyfd1HitLZRxubDy+/zygUdN93UxkAiBoHlaIpIYj+NqvLldop SfUb3hYPjl6RDJQI4r4VptG4fmv6QNmFsob1e9fZhcGiiK2IkJXBDvFHceQBGAZxmLur 7+n8Lw1QkigAw4HPVsxTs/jyCFi2+lMq61w7vkAfv7dF3Zu/h43mHj0YpT9VW3rxFr5R UtMbcBffHaUAORNaVTUMPaKSASAB+SmVMX+e/vLgP0J11W3Z3BeSPOIoMCVQiu0lmGAP WZZEnTdeGk9bOXCjKnNBGGHFvcjUGkRvrW31dugw+FqfnzcFH/R4BYdyqwvzNSoVc4ln AhaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737636302; x=1738241102; 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=4vF0qbcrlUHMns+leDnByN9gAa2CtmYb+mw9y9wF8iU=; b=CiBK7tUxAIHfUAR2YcuFOmcw9yZiXsftL0Laihi5WbyHMyLlmy7tUaIZBcwm5zVfuG 1KQnJHmo7MjFpcIq/ZmNWAnzDUMLF6mJwqZEs6MO0Bjsu2Opd0O9K4gH6b6ZOEWbdyU4 ocbfqAYsHJO5evxVwGoHgGailgMgbPd02VkKmrP3d95jhyag8oya/HsqjLJfX7SduWDm AazvEvWjMmipssvFqoYEf9uUVJaHrzFN6fWtM0n7xhD+WiOd4YzmJPTpP2FTIFXZZt6f 80oby/jOs78HZhV1CKmtkpkliv0gCl1pBG0D/iLqW1k/l5Ep8WMq/dR3A0pUhNyB1NIs 0pUg== X-Gm-Message-State: AOJu0Yx7c90ue8CZnr097M8PZ0B1Ono9s+Wwp7anHFlCXIJJiQ/Ndb+h 9Fkd60uh8p2i7MNV6MK5W4k0zMY8waB72yWmDIVv6mRH9o9EICbouo1ijAzWnb8= X-Gm-Gg: ASbGncsXtqutzu1Xw1IJT963U6oYzoYoNetYgf9siqV3KIDQNcWVgHRv7+pK9ipBvd4 +rOe7oANLdL7PaGdn91D/JqvWw2bu2yPAYEFv5LPAWixTQaCjgACHyJ2iRakq1ugzSNDpnvhH9Z 39aL4fl6e0GomneJUlsb5/2SQiP4saJvNWyk/EjDIH2YMNVcZOSv9GfEna0iWilmAykuY/mOOxq 6buaNcUYr36Z6suziLMrbYzcVpzUX1LJVnwlHFQLMUTr/bO3e0xsKBYnd/jP/zSpJFc9jXHsWZX F3RDuDdmyC2l X-Google-Smtp-Source: AGHT+IHfHG9O5X1llYskqSd6JQCpl9Yb2Ept1YS83FF6LDGIK5pJeawqROTCwXIQP6rC+URwkRuOjA== X-Received: by 2002:a2e:b5cf:0:b0:302:2cb3:bb1d with SMTP id 38308e7fff4ca-30761bdd3d7mr7826681fa.12.1737636302270; Thu, 23 Jan 2025 04:45:02 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a4ed6f3sm30351661fa.86.2025.01.23.04.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 04:45:01 -0800 (PST) From: Dmitry Baryshkov Date: Thu, 23 Jan 2025 14:43:35 +0200 Subject: [PATCH v2 3/4] drm/msm/dpu: simplify dpu_encoder_get_topology() interface MIME-Version: 1.0 Message-Id: <20250123-drm-dirty-modeset-v2-3-bbfd3a6cd1a4@linaro.org> References: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> In-Reply-To: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Chandan Uddaraju , Jeykumar Sankaran , Jordan Crouse , Sravanthi Kollukuduru Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Archit Taneja , Rajesh Yadav , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Simona Vetter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2264; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=pI8jt/Gg0nWGsVNN0M+A+HMbfSuoINnuOGtnWy2LNDQ=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ/oky2MKZhXySS3cvArifmwRFeu084Kz/31hv6VsytTww jkjfXEnozELAyMXg6yYIotPQcvUmE3JYR92TK2HGcTKBDKFgYtTACaitZX9f7HD3ws+xzjNY22N L/2XVW3Qnc5ftXqB6Y61F6cfenfkp+6fdv9fzgsjdZ/Gpa5L6X7gyDllw+PNRy9e4i25tP1rcau oeu7VAN0fFXuK1RL4c6+rB0Ut2av29odicvKh8q7Jk9X+a3X2CvqFlBV2rJ5ld9hdf+apqhbpgJ /b3tv2C909rRE84WR1gtlXmwVJt/13F3W2fXg27/bXA5t7+qVEfydxhNmLFgaFSB7s8bsvLP43Z Zdon1GkdFT5C7lNzBnCj/zOzc843OjA5xzamXI/PjxvDn/S2pdL/PwncB/q+hYqVPBhacjkd5pc q05ERP5d+XfPlZmBujxzvne8WNb2V3pRaRrLNW+l7Q1VAA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As a preparation for calling dpu_encoder_get_topology() from different code paths, simplify its calling interface, obtaining some data pointers internally instead passing them via arguments. Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 5dc2e0585de1337601a0426795d2c8f2806ccd10..fe139c49823674adf980db5faa3f2acd4c9c20dd 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -649,14 +649,14 @@ struct drm_dsc_config *dpu_encoder_get_dsc_config(struct drm_encoder *drm_enc) static struct msm_display_topology dpu_encoder_get_topology( struct dpu_encoder_virt *dpu_enc, - struct dpu_kms *dpu_kms, struct drm_display_mode *mode, struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state, - struct drm_dsc_config *dsc) + struct drm_connector_state *conn_state) { struct msm_drm_private *priv = dpu_enc->base.dev->dev_private; struct msm_display_info *disp_info = &dpu_enc->disp_info; + struct dpu_kms *dpu_kms = to_dpu_kms(priv->kms); + struct drm_dsc_config *dsc = dpu_encoder_get_dsc_config(&dpu_enc->base); struct msm_display_topology topology = {0}; int i, intf_count = 0; @@ -764,7 +764,6 @@ static int dpu_encoder_virt_atomic_check( struct drm_display_mode *adj_mode; struct msm_display_topology topology; struct dpu_global_state *global_state; - struct drm_dsc_config *dsc; int ret = 0; if (!drm_enc || !crtc_state || !conn_state) { @@ -785,10 +784,7 @@ static int dpu_encoder_virt_atomic_check( trace_dpu_enc_atomic_check(DRMID(drm_enc)); - dsc = dpu_encoder_get_dsc_config(drm_enc); - - topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode, crtc_state, conn_state, - dsc); + topology = dpu_encoder_get_topology(dpu_enc, adj_mode, crtc_state, conn_state); if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) crtc_state->mode_changed = true; From patchwork Thu Jan 23 12:43:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13948240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39D6BC0218B for ; Thu, 23 Jan 2025 12:45:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6ABF10E805; Thu, 23 Jan 2025 12:45:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yp41U//3"; dkim-atps=neutral Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id E271A10E801 for ; Thu, 23 Jan 2025 12:45:04 +0000 (UTC) Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-306007227d3so8746271fa.0 for ; Thu, 23 Jan 2025 04:45:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737636303; x=1738241103; darn=lists.freedesktop.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=zWSHW1AJoo6oeAbFU6nV7ox9IaMy4zb6Gnw53tdjyIM=; b=yp41U//3qQaR0zSokdH6+oEboDZvewr+LUYUPZCH+cCJHnIHoTbsJjMHKer23ipQEh z56PvN85BRdc5zDvpocQe/Vfl4S3BuetRafwl3cxB7fpW5sGfGrICnamMkGaOaTuIGmV IWPVdnt+NMuBMG1cP8tPIfRxGtvWfcEIgrwHk6c7fJqRcqOr20ErofHhDLG4NRE64CHu sVBw2GXwspGBM+ETG0byIP+9QPBST8m1eiwnkFNfiVnjT4nv38b7i03Y6KcELLgH8V4Y mrcBNxwHOoYc/SggeMphVCmD8Q+40ypubytxIyfqRx4yZiRWD56qrXuLn9c1W/w2LQxH mDjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737636303; x=1738241103; 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=zWSHW1AJoo6oeAbFU6nV7ox9IaMy4zb6Gnw53tdjyIM=; b=uXg6p1pI4KGSUmBA7TDp+rmvKMJxVe4vfKaC4PDlMqrjMq/Au3jUhc/z2v8ulkMtSh uCquRhduJBV9N1tmlhZ7uzKS1Aw1AtxBMpbh2Mgp7pSLn6KCju2iyz8Rq65ckO6TXy8f F/zmSX9iMOZZM+cVqeVAWoRY+OxEoxFLOIL2on+Kol7qR/0YSLsziVmH4/5hI6Hxq1os on28yRELgFuSag6S01t1d12SL6lUmlX2jhJ4psBQfmeey1TyB3PbPDrPb0zBeiGEdLTA 6SKlrkRh08+o/RQExr9qX3L527UKYvv8WLcK+5Onz8Fboy1gGkzVfphOrR7kCfIYvvdP UsAQ== X-Gm-Message-State: AOJu0YyF979lRhF9m9YlXqbZ2IDE2Mi8yFTTk2yZQpU7A82l6U3LE9f9 V/c4Q+qbLbv12sEO6PAOMxLbWReWUh/V8XWSH5Zq+8Jtp9gljBWczMC5pbtEwdg= X-Gm-Gg: ASbGncslvkrWjD8tvm2I9/Zt+v979LQb+2xecKfPeZdn46QHvu9J51zA+qEcAuxAEhk LSqaVDgo5wocxH39HpfTRbKD9d+9ZB9Ta9MZ+93sZCBN5dhT7y1l5qTjJ2ZtTy4b0ukFdEzgCAP 5UX04UUBW8Q0XS/5XpUn2xrs9J64UiUmAKlt3XkU5VDa115AII+hhyaX9432rPjgU/dif32xwcw dP46Wn1IUoYfFmW3ks1KIcgEPCUZaTr0AbWlfvOX7FYy+wXNUEfgwUFfJJEjIB17l2Hwe7XMy9q 5QFJL3Zqtlsd X-Google-Smtp-Source: AGHT+IE12Ap5wyBvC7HL6i+gKbbzFkPkeoSGT9gE9o+mFgIB89+q5WLPBpsNBRDOdCKVJU5k1SiThg== X-Received: by 2002:a05:651c:896:b0:306:10d6:28b3 with SMTP id 38308e7fff4ca-3072ca5da94mr103081071fa.1.1737636303052; Thu, 23 Jan 2025 04:45:03 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a4ed6f3sm30351661fa.86.2025.01.23.04.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 04:45:02 -0800 (PST) From: Dmitry Baryshkov Date: Thu, 23 Jan 2025 14:43:36 +0200 Subject: [PATCH v2 4/4] drm/msm/dpu: don't set crtc_state->mode_changed from atomic_check() MIME-Version: 1.0 Message-Id: <20250123-drm-dirty-modeset-v2-4-bbfd3a6cd1a4@linaro.org> References: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> In-Reply-To: <20250123-drm-dirty-modeset-v2-0-bbfd3a6cd1a4@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Chandan Uddaraju , Jeykumar Sankaran , Jordan Crouse , Sravanthi Kollukuduru Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Archit Taneja , Rajesh Yadav , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Simona Vetter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7218; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=ywj2QbrIUOhbEqfzeGCGI+2h2YoIF5PaEJb2YvtBcdI=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnkjnH5EQ38UX1kFV3dYaP67laFRQ78Drnr8J+p ZgzDnFl7GWJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5I5xwAKCRCLPIo+Aiko 1ZxrB/9W3LpBM1MAETuxxqocvZvwhLTJUljEwK3X1NWFwIEAH7If2Ts2Bm7q+C0BgxqciObi0s4 YKnHN0XiPZM9luNynljyJAO2STnmmdOLIWKfCpK/MByVWrS+NHvRNQg66EpIs+S6hv/Y5hzbEZZ eija4PHE1PlAA9NfQKbuuamPKjM5lXki8FcVmRv65y/HNiMAoxfmeEw8BvW+TkPnvhwYAvG3Z9L 20ZnkhDapHmnneJUiIx/5fmqaG3I1/ePPOmx/Kji8HxqFhBt2XvK/axm1MH0O/mCyHhevJ5OeWd jyCDSgsjDOCu9m3MTaDh8jTjZGqK83CaSByWX6yDO2WPZ0HW X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The MSM driver uses drm_atomic_helper_check() which mandates that none of the atomic_check() callbacks toggles crtc_state->mode_changed. Perform corresponding check before calling the drm_atomic_helper_check() function. Fixes: 8b45a26f2ba9 ("drm/msm/dpu: reserve cdm blocks for writeback in case of YUV output") Reported-by: Simona Vetter Closes: https://lore.kernel.org/dri-devel/ZtW_S0j5AEr4g0QW@phenom.ffwll.local/ Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 32 +++++++++++++++++++++++++---- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 4 ++++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 26 +++++++++++++++++++++++ drivers/gpu/drm/msm/msm_atomic.c | 13 +++++++++++- drivers/gpu/drm/msm/msm_kms.h | 7 +++++++ 5 files changed, 77 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index fe139c49823674adf980db5faa3f2acd4c9c20dd..a24fedb5ba4f1c84777b71c669bac0241acdd421 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -753,6 +753,34 @@ static void dpu_encoder_assign_crtc_resources(struct dpu_kms *dpu_kms, cstate->num_mixers = num_lm; } +/** + * dpu_encoder_virt_check_mode_changed: check if full modeset is required + * @drm_enc: Pointer to drm encoder structure + * @crtc_state: Corresponding CRTC state to be checked + * @conn_state: Corresponding Connector's state to be checked + * + * Check if the changes in the object properties demand full mode set. + */ +int dpu_encoder_virt_check_mode_changed(struct drm_encoder *drm_enc, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); + struct msm_display_topology topology; + + DPU_DEBUG_ENC(dpu_enc, "\n"); + + /* Using mode instead of adjusted_mode as it wasn't computed yet */ + topology = dpu_encoder_get_topology(dpu_enc, &crtc_state->mode, crtc_state, conn_state); + + if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) + crtc_state->mode_changed = true; + else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm) + crtc_state->mode_changed = true; + + return 0; +} + static int dpu_encoder_virt_atomic_check( struct drm_encoder *drm_enc, struct drm_crtc_state *crtc_state, @@ -786,10 +814,6 @@ static int dpu_encoder_virt_atomic_check( topology = dpu_encoder_get_topology(dpu_enc, adj_mode, crtc_state, conn_state); - if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; - else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; /* * Release and Allocate resources on every modeset */ diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h index 92b5ee390788d16e85e195a664417896a2bf1cae..da133ee4701a329f566f6f9a7255f2f6d050f891 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h @@ -88,4 +88,8 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc, bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc); +int dpu_encoder_virt_check_mode_changed(struct drm_encoder *drm_enc, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state); + #endif /* __DPU_ENCODER_H__ */ diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 97e9cb8c2b099f4757169cadf7e941148d2bfb16..9748d24b3ffde45992d28b697a88db5992b00c69 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -446,6 +446,31 @@ static void dpu_kms_disable_commit(struct msm_kms *kms) pm_runtime_put_sync(&dpu_kms->pdev->dev); } +static int dpu_kms_check_mode_changed(struct msm_kms *kms, struct drm_atomic_state *state) +{ + struct drm_crtc_state *new_crtc_state; + struct drm_connector *connector; + struct drm_connector_state *new_conn_state; + int i; + + for_each_new_connector_in_state(state, connector, new_conn_state, i) { + struct drm_encoder *encoder; + + WARN_ON(!!new_conn_state->best_encoder != !!new_conn_state->crtc); + + if (!new_conn_state->crtc || !new_conn_state->best_encoder) + continue; + + new_crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc); + + encoder = new_conn_state->best_encoder; + + dpu_encoder_virt_check_mode_changed(encoder, new_crtc_state, new_conn_state); + } + + return 0; +} + static void dpu_kms_flush_commit(struct msm_kms *kms, unsigned crtc_mask) { struct dpu_kms *dpu_kms = to_dpu_kms(kms); @@ -1062,6 +1087,7 @@ static const struct msm_kms_funcs kms_funcs = { .irq = dpu_core_irq, .enable_commit = dpu_kms_enable_commit, .disable_commit = dpu_kms_disable_commit, + .check_mode_changed = dpu_kms_check_mode_changed, .flush_commit = dpu_kms_flush_commit, .wait_flush = dpu_kms_wait_flush, .complete_commit = dpu_kms_complete_commit, diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c index a7a2384044ffdb13579cc9a10f56f8de9beca761..364df245e3a209094782ca1b47b752a729b32a5b 100644 --- a/drivers/gpu/drm/msm/msm_atomic.c +++ b/drivers/gpu/drm/msm/msm_atomic.c @@ -183,10 +183,16 @@ static unsigned get_crtc_mask(struct drm_atomic_state *state) int msm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) { + struct msm_drm_private *priv = dev->dev_private; + struct msm_kms *kms = priv->kms; struct drm_crtc_state *old_crtc_state, *new_crtc_state; struct drm_crtc *crtc; - int i; + int i, ret = 0; + /* + * FIXME: stop setting allow_modeset and move this check to the DPU + * driver. + */ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { if ((old_crtc_state->ctm && !new_crtc_state->ctm) || @@ -196,6 +202,11 @@ int msm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) } } + if (kms && kms->funcs && kms->funcs->check_mode_changed) + ret = kms->funcs->check_mode_changed(kms, state); + if (ret) + return ret; + return drm_atomic_helper_check(dev, state); } diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h index e60162744c669773b6e5aef824a173647626ab4e..ec2a75af89b09754faef1a07adc9338f7d78161e 100644 --- a/drivers/gpu/drm/msm/msm_kms.h +++ b/drivers/gpu/drm/msm/msm_kms.h @@ -59,6 +59,13 @@ struct msm_kms_funcs { void (*enable_commit)(struct msm_kms *kms); void (*disable_commit)(struct msm_kms *kms); + /** + * @check_mode_changed: + * + * Verify if the commit requires a full modeset on one of CRTCs. + */ + int (*check_mode_changed)(struct msm_kms *kms, struct drm_atomic_state *state); + /** * Prepare for atomic commit. This is called after any previous * (async or otherwise) commit has completed.