From patchwork Sun Dec 22 05:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13918002 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 99C86E77188 for ; Sun, 22 Dec 2024 05:00:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8622A10E22E; Sun, 22 Dec 2024 05:00:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FdLRBPDl"; dkim-atps=neutral Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id F20D910E22E for ; Sun, 22 Dec 2024 05:00:50 +0000 (UTC) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-53df80eeeedso3207238e87.2 for ; Sat, 21 Dec 2024 21:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734843649; x=1735448449; 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=WUHXS68dzii47sCyHoBGO1JrTDTtIN7oWeXHXt5K2JQ=; b=FdLRBPDlJALebWHnQEzU22qjARSwc3myCFCpjyYmxrPgAcOdZ6uAejtCvH2hVMKV/X X2SAU70YStKGGozzEIqJuqXkAHX4UjdkV4AtbWQpo95n7jUXVh5ON14fSCcUiq4y9IQa u+VLcHQZGOOHMadbwx8XclF5tp3r3fOFEoE6+FjLHQWNBMesBgaVc8P+apKnSQVVOyji 1CRoODcAjDiv6WZII1AzRffT33zB39BdQJWe6mTKETdFxjTWvjuJJ4sDcnQ1djKbJs31 biDb6VHDXftEk9Jv2+ka/uFxBEtwCfOuauARp9FtwGK0j//+TrjAPU3Yb5nPLaRd4Up+ BMig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734843649; x=1735448449; 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=WUHXS68dzii47sCyHoBGO1JrTDTtIN7oWeXHXt5K2JQ=; b=WAJWeVB8DFB3Bt1WF/F3LgWl8EsCvho7jnBCGRODG/LGYh+8NbrHo3oAxokXUNw9ZL f/BPTiZhWef6dfy+e9lZriy7CAfG67vDYjALH65GZPRLR63yZIwUJfIKGPmrRt5CP5JW QGE8t9q6Q4rmyFkTBI7degahc0NrdGYpr5z8LIqBpilbNMUcN6IHyt3vBu1bbnUTIrz6 apHMVEM3p6rjvPp5HU97tHGkm0R7eXkiYnbaP02mK3DyMP8xLXDtJ0E3tbZ3scSxI+3x CjuxiTspEPN71fCDh51B4dAVMmTc2NHgVU2EUwDhOgmecyGlu9AmfXD3AtVXC2FJpQfh A9/A== X-Gm-Message-State: AOJu0Yz73WUaK6pWyC5m+cH9/wOGnAHpgoC+wAIttAgH2rkiO49rqGBq FvorJKUut2nnEALvEJThABxz8o5Ks4fG8at3D/6hCiPRYWFk9KEDVuojpsNO+u0= X-Gm-Gg: ASbGncsAQLUG1JiQxga9rYf0YKkWw7aHnzDR800ooKimZ3g2++58tMepp5SBJu/pqWF ho3OmOagEadDi8I9zC6Ll2bMQmdca7JbzFIpYyYhW4ymiy1LLcYgpzGFpCh3dJXyGXKmGikg5Ye zLNa3Zx3CAfO2Hx96TWtNdNwRK9AilqqIAqlypGYcOG2I+dkcbaDyLGrF0UQz8RJqD+iyxQ7hxb R8p9oXkz/KbvIACtiqO68mSEIG8qKkzL/WH94J90ZSqWdIev5/DZrzpdL/X4qFu X-Google-Smtp-Source: AGHT+IF+Pt1nCCP5OVvGkhTdNXEz4B1kunIC5TH+Ahw6Mi+g/aUmHdjgPeeYunkjxCOH1d29CuDaLQ== X-Received: by 2002:a05:6512:31d1:b0:540:1dac:c038 with SMTP id 2adb3069b0e04-54229524fc7mr2631228e87.1.1734843649198; Sat, 21 Dec 2024 21:00:49 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223832c05sm887145e87.276.2024.12.21.21.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 21:00:47 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 22 Dec 2024 07:00:41 +0200 Subject: [PATCH 1/6] drm/atomic-helper: document drm_atomic_helper_check() restrictions MIME-Version: 1.0 Message-Id: <20241222-drm-dirty-modeset-v1-1-0e76a53eceb9@linaro.org> References: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@linaro.org> In-Reply-To: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@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=1373; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=lEzV2DFxHSmrj9mC/gnIKltRLYW/iHK8CYgZvjQpABw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZ5z7nPIekJhdnUK5YoeVX9bvlTyiNvqjiLjxF HpRt+nQbpqJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2ec+wAKCRCLPIo+Aiko 1Wr9B/40R/wzCdA6LcKR5piuLK5GBYyyXYi+7z6d1Ml4lcBIde24q+/8h69RHvVODCvzFYcRG43 RU+/30LCutV5t2i0fS2sc/ZDYUFxAsLkUADrXK9YswlbqT1K3Jscky9S2+TWLxEskNFPwP5GSUI IumfzysS9OagOKAtHinV+1OOi4rARn7NsWyHUOlqiIedR1j+STxpB7D3J/dwHa0EVHjQrl2YTVS MQ+WKXsWgN4uLX0K1jQXgpBSXgVYUyNjvqBEVOqT9GjEGdhPP03CHccy0hZgR93nPCV93pTP4Fg Ao9XIaGu26sfYfQPSBiLeKSV6rEifwYMjU6y0AT9T6Jq2tOk 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 drm_atomic_helper_check() calls drm_atomic_helper_check_modeset() insternally. Document that corresponding restrictions also apply to the drivers that call the former function (as it's easy to miss the documentation for the latter function). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 5186d2114a503701e228e382cc45180b0c578d0c..f26887c3fe8b194137200f9f2426653274c50fda 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1059,6 +1059,15 @@ EXPORT_SYMBOL(drm_atomic_helper_check_planes); * For example enable/disable of a cursor plane which have fixed zpos value * would trigger all other enabled planes to be forced to the state change. * + * IMPORTANT: + * + * As this function calls drm_atomic_helper_check_modeset() internally, its + * restrictions also apply: + * Drivers which set &drm_crtc_state.mode_changed (e.g. in their + * &drm_plane_helper_funcs.atomic_check hooks if a plane update can't be done + * without a full modeset) _must_ call drm_atomic_helper_check_modeset() + * function again after that change. + * * RETURNS: * Zero for success or -errno */ From patchwork Sun Dec 22 05:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13918004 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 16001E7718E for ; Sun, 22 Dec 2024 05:00:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9421E10E2D7; Sun, 22 Dec 2024 05:00:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uhTxINFe"; dkim-atps=neutral Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56D9B10E22E for ; Sun, 22 Dec 2024 05:00:53 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-53e389d8dc7so3314030e87.0 for ; Sat, 21 Dec 2024 21:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734843652; x=1735448452; 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=N19A2AjG3Q/s9SAFMXdSh2+o269dpLqgKum0CI5lc8s=; b=uhTxINFe39O/gv587RjtviTwQsl1aVWI5rAauCsodkM7jw2bg/P03CH9t91E8k31Ct WhjhOXESbEZRqFw4oiZ+Kbz8mgpU07nAZTXMQBLUBbCgpv3r1HH0fL/xTDws6/QjCKO4 qe81HVD/Oe6jqphMq9A4G4xzhGRkt/GbUnDEbUaxvWtnjp1pj7IB7JgyJKqUINTDngpv DhtelQ6+6ZRM6qZ/VuhfJNPq7zXURZjOdmQC9rn8Y7NdJ0kBNZy6PThwnKp+PKivfzjo NXC9mCI9jYpr+HPxxOvQ1Mao09tFlk8wbi922FWLWLr9BT7jVJ416ZXziuavdloT2eLl eyRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734843652; x=1735448452; 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=N19A2AjG3Q/s9SAFMXdSh2+o269dpLqgKum0CI5lc8s=; b=qc2skep4fFHLVqgJu9C5uZnBXnf/L6PnMXpZ3zHGoMy0nJXHZr8hpnYTvX2syIDabm kaidmLwhAudkN984eZaI1rb01eeKIiHxSiy7nOYPb0KxT81CmWdjPsP8qmoLTP6ruXKO +r4Vr68BfPktFn2ZwOqCUgwBMoDRz7y6ds8V94peDJGD4rmvtycokNrw2v5DYRn0n2Va nGQegKgxN6VPhMjaN5XPae5A5ugZEQ0WxxBYMUlcVnHrpus2/c6/umtIXS7HCp1POLD8 5zIgLL6p/wRj4AW101wYZnxaUz8BBdnbhV1KN7A6i4ddd27kXRWfZuDuwIB8hyk4KOwn Uf/Q== X-Gm-Message-State: AOJu0Yzqsi/o4YWqlPZ3ec4gBjKoZy3WUxeh6014dJJSW4MmGtjQ4xJJ WPHwYtCzNYd4n4h7brF+OKT4MRooa2JvH3R6E+VOWJC1vhV5XJzkWjyboi5Mp8k= X-Gm-Gg: ASbGncsLa+zPaxEED7pOW51xP9ZrIO9P3SsuuJpqd4TMGzelDwQ6QjD2vxL5LEaMRcN ALXSloDh/m0JlGoOHzQkPYt3jMRNQQdcxqJuU05JUDfoUVfmMMRiQ03FWjVYqQ0mjYDLZ/8niio iRIhK/vdcGF7Tuf1BEngm3weB/zYdwSSUbHei4aRjfNXJ8oXznwY10IGHnCWut3lagDkY9D48Yp GVLOAudtLmCsrMbdDQVgcwN8x2gee+UOQEXvH6XsLJvHIYVejCM5nmfto0m/v+J X-Google-Smtp-Source: AGHT+IGWOF5L9r9w+Rvx/sxvEH8+CLwrVoF+t4m8SvJw+iSDzew6q+z2eYxXwXHRCkDsVxu6XZXCJg== X-Received: by 2002:a05:6512:e8c:b0:53a:1a81:f006 with SMTP id 2adb3069b0e04-5422953fedcmr3014188e87.31.1734843651614; Sat, 21 Dec 2024 21:00:51 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223832c05sm887145e87.276.2024.12.21.21.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 21:00:50 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 22 Dec 2024 07:00:42 +0200 Subject: [PATCH 2/6] drm/atomic: prepare to check that drivers follow restrictions for needs_modeset MIME-Version: 1.0 Message-Id: <20241222-drm-dirty-modeset-v1-2-0e76a53eceb9@linaro.org> References: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@linaro.org> In-Reply-To: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@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=8180; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=rWS0KFUVLvGb4ozb2+QIr1gzxcTnVRN9cNSrdc5NX8g=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZ5z71Xj3vDZ5ZQ9k5EaVm/6pV22nfsxOppXU8 urExzv+o8yJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2ec+wAKCRCLPIo+Aiko 1eDjCACEaoaRFJsbhJHmjd3uHaWnQCQA3aWQKHzRvFrDf7Em7z0Gao1tpDPETltMg4hGw9imGF/ PtpGBoPGrff7Mf6/fSkZQKcBzyk2nds6Pmm41ImFPilCfg57s70TvJ8b+yRs7SbYd5G+gxE3MYU voHPno59UMWls4TEyjlcckMmilATWZhT4Cj08xSb97FrGuAV9e5lrX4zzr1U3eyh5LCkSiI51XI xi2ZSJf2Kv+8y9J1HtkLW5kPgrILGaBg3asKa4+mIqDhnDxCFNZK1MtdHv6AHrqXUA+gI/jpJit nXQgHSxtMdjeuCSaRaKgyoclkm4lYv7wxwWyAT9xRjrT6Gst 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" Some drivers might fail to follow the restrictions documented for drm_atomic_helper_check_modesets(). In order to catch such an issues, add the drm_atomic_state->dirty_needs_modeset field and check it in drm_atomic_check_only(). Make sure that neither of atomic_check() callbacks can set that field without calling drm_atomic_helper_check_modesets() again. Suggested-by: Simona Vetter Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_atomic.c | 3 ++ drivers/gpu/drm/drm_atomic_helper.c | 77 +++++++++++++++++++++++++++++++++---- include/drm/drm_atomic.h | 10 +++++ 3 files changed, 82 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 9ea2611770f43ce7ccba410406d5f2c528aab022..202e4e64bd31921d0a4d4b86605b501311e14c33 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1449,6 +1449,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state) } } + WARN_RATELIMIT(state->dirty_needs_modeset, + "Driver changed needs_modeset under drm_atomic_helper_check_modeset()"); + if (!state->allow_modeset) { for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { if (drm_atomic_crtc_needs_modeset(new_crtc_state)) { diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index f26887c3fe8b194137200f9f2426653274c50fda..2c62840416f4b807d6a880b5c30ae024a16af528 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -433,6 +433,7 @@ mode_fixup(struct drm_atomic_state *state) for_each_new_connector_in_state(state, connector, new_conn_state, i) { const struct drm_encoder_helper_funcs *funcs; + bool old_needs_modeset = false; struct drm_encoder *encoder; struct drm_bridge *bridge; @@ -451,6 +452,9 @@ mode_fixup(struct drm_atomic_state *state) encoder = new_conn_state->best_encoder; funcs = encoder->helper_private; + if (new_crtc_state) + old_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + bridge = drm_bridge_chain_get_first_bridge(encoder); ret = drm_atomic_bridge_chain_check(bridge, new_crtc_state, @@ -479,6 +483,12 @@ mode_fixup(struct drm_atomic_state *state) return -EINVAL; } } + + if (new_crtc_state) { + bool new_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + + state->dirty_needs_modeset |= (new_needs_modeset != old_needs_modeset); + } } for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { @@ -574,6 +584,36 @@ mode_valid(struct drm_atomic_state *state) return 0; } +static int +connector_atomic_check(struct drm_atomic_state *state, + struct drm_connector *connector, + struct drm_connector_state *old_connector_state, + struct drm_connector_state *new_connector_state) +{ + const struct drm_connector_helper_funcs *funcs = connector->helper_private; + struct drm_crtc_state *new_crtc_state; + bool old_needs_modeset = false; + int ret; + + if (new_connector_state->crtc) + new_crtc_state = drm_atomic_get_new_crtc_state(state, new_connector_state->crtc); + if (new_crtc_state) + old_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + + if (funcs->atomic_check) + ret = funcs->atomic_check(connector, state); + else + ret = 0; + + if (new_crtc_state) { + bool new_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + + state->dirty_needs_modeset |= (new_needs_modeset != old_needs_modeset); + } + + return ret; +} + /** * drm_atomic_helper_check_modeset - validate state object for modeset changes * @dev: DRM device @@ -628,6 +668,8 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, int i, ret; unsigned int connectors_mask = 0, user_connectors_mask = 0; + state->dirty_needs_modeset = false; + for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) user_connectors_mask |= BIT(i); @@ -683,8 +725,6 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, return ret; for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) { - const struct drm_connector_helper_funcs *funcs = connector->helper_private; - WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); /* @@ -710,8 +750,8 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, new_crtc_state->connectors_changed = true; } - if (funcs->atomic_check) - ret = funcs->atomic_check(connector, state); + ret = connector_atomic_check(state, connector, + old_connector_state, new_connector_state); if (ret) { drm_dbg_atomic(dev, "[CONNECTOR:%d:%s] driver check failed\n", @@ -752,13 +792,11 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, * has been called on them when a modeset is forced. */ for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) { - const struct drm_connector_helper_funcs *funcs = connector->helper_private; - if (connectors_mask & BIT(i)) continue; - if (funcs->atomic_check) - ret = funcs->atomic_check(connector, state); + ret = connector_atomic_check(state, connector, + old_connector_state, new_connector_state); if (ret) { drm_dbg_atomic(dev, "[CONNECTOR:%d:%s] driver check failed\n", @@ -994,6 +1032,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev, for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { const struct drm_plane_helper_funcs *funcs; + bool old_needs_modeset = false; WARN_ON(!drm_modeset_is_locked(&plane->mutex)); @@ -1006,6 +1045,12 @@ drm_atomic_helper_check_planes(struct drm_device *dev, if (!funcs || !funcs->atomic_check) continue; + if (new_plane_state->crtc) + new_crtc_state = drm_atomic_get_new_crtc_state(state, + new_plane_state->crtc); + if (new_crtc_state) + old_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + ret = funcs->atomic_check(plane, state); if (ret) { drm_dbg_atomic(plane->dev, @@ -1013,16 +1058,26 @@ drm_atomic_helper_check_planes(struct drm_device *dev, plane->base.id, plane->name); return ret; } + + if (new_crtc_state) { + bool new_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + + state->dirty_needs_modeset |= (new_needs_modeset != old_needs_modeset); + } } for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { const struct drm_crtc_helper_funcs *funcs; + bool old_needs_modeset = false; funcs = crtc->helper_private; if (!funcs || !funcs->atomic_check) continue; + if (new_crtc_state) + old_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + ret = funcs->atomic_check(crtc, state); if (ret) { drm_dbg_atomic(crtc->dev, @@ -1030,6 +1085,12 @@ drm_atomic_helper_check_planes(struct drm_device *dev, crtc->base.id, crtc->name); return ret; } + + if (new_crtc_state) { + bool new_needs_modeset = drm_atomic_crtc_needs_modeset(new_crtc_state); + + state->dirty_needs_modeset |= (new_needs_modeset != old_needs_modeset); + } } return ret; diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 31ca88deb10d262fb3a3f8e14d2afe24f8410cb1..7b0dbd3c8a3df340399a458aaf79263f0fdc24e5 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -408,6 +408,16 @@ struct drm_atomic_state { */ bool duplicated : 1; + /** + * @dirty_needs_modeset: + * + * Indicates whether the drm_atomic_crtc_needs_modeset() changed in an + * unexpected way. Usually this means that driver implements atomic + * helpers using drm_atomic_crtc_needs_modeset(), but mode_changed has + * toggled by one of its atomic_check() callbacks. + */ + bool dirty_needs_modeset : 1; + /** * @planes: * From patchwork Sun Dec 22 05:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13918003 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 13F7DE77188 for ; Sun, 22 Dec 2024 05:00:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 79F8510E2D2; Sun, 22 Dec 2024 05:00:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MSyUtMcF"; dkim-atps=neutral Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id B78E510E2D7 for ; Sun, 22 Dec 2024 05:00:55 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-54024aa9febso3438449e87.1 for ; Sat, 21 Dec 2024 21:00:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734843654; x=1735448454; 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=SPUKe2inYvlgyzg1RdM9z6lWoAQEDWbkCd9hh5ymtmI=; b=MSyUtMcFClOEOico6cZfZ5u+FfK314bRXVtEbMjSANoLl9VuWypHWoOjsixf1YwUnx 90uSZ2HkwWyMSfvZf6HIsIdUFCUWUiqjHFl5jJvkp8sX0LZKwJ1oAvQ4sqQngvHGqZIB h0tyH6CjzuxFlVTB1FqSI4SnVXLjI1Vg0lxRa8909FohXK8zTnoxQAkFZjE3LoQIjXdG l9pNunkPoRe/z9yAgM1IaXN4OzaCkvJPGkgLHbHBjiGumx1zGQ3qP/jnBC0M953DThcv z8ocn9wHBwWSsZkWbC9r1yF1uGDeS3ybTR4+xdcNpvyXhv2HZEnpZ2ZUwFLDYTKGemTk D5Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734843654; x=1735448454; 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=SPUKe2inYvlgyzg1RdM9z6lWoAQEDWbkCd9hh5ymtmI=; b=FSFNYaFElYoGvXc0W2J1GB8XtrdbKkHlD6yDKPFxTTz7fv1DeHSn15uxW1aRHblS3S swdSLqyNRKC5LRnpFjfyEpBSQtHMULLLlh2ggz03QOtDyDVr1vQImeDg7Z7jVX2Gd3Pp rDlZzO/gwH301U8m6OvS6aV/qTx5TqouXFcvpbY8/XtD/xol8ovXmh5h7C65NASCDmox j8Vj4D+MjsEE54BfyguCaklr0gLa5NooBzijAQGGpH7VznUUgc2JMMpWqni7dVATFciR kajO56s+vzGXhzcPEjE1EqbR4VDYuL5hOif57bMPPrC+/QnUwPeVruABP1X+ngW8yUxw uefA== X-Gm-Message-State: AOJu0YwNKTLEU4pV2FHLmtVfLLp+mLu8uGPz9OtrB4vyfxM6dYkjLe3W WhAsmjLOuG89bzBv0tfZPxIadNw/ZyEXUXZ3ALgq1VZRGMoqFsXgNSBPznD/j5Y= X-Gm-Gg: ASbGncuK3qp8PlIXODuuf4eX7Fy9OOZcv5kUvJYiMKdqoU40saGfR6JQDcxqXyjwNY8 4V+MHupNSrRrDND+a+8DPZ7LMWVox/qdeFJKNfRHczOonwRPN0NqP7juB2M/vBOE3WOyscyy5zw hBWCGpVZhJxbsq5f9ktl3A9bOySpgMIiCH4Fbf+HT3vxuAx1/4wqHJdg/w+h6SnRelU+8Lu9R0W 25LxyaZG8QiOgquluXzh7aOZ3crNbQ1SHu0YJI++ebAsP1DEJMflng8ZzVCX/14 X-Google-Smtp-Source: AGHT+IH5FngsI07NNLouagSYBk1lHP+UW7OocB95mR63hfokDbT+bvXmYWVojBL11pLAgTWk4aF61g== X-Received: by 2002:a05:6512:1392:b0:53e:38df:673d with SMTP id 2adb3069b0e04-54229562a01mr2899574e87.43.1734843654003; Sat, 21 Dec 2024 21:00:54 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223832c05sm887145e87.276.2024.12.21.21.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 21:00:52 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 22 Dec 2024 07:00:43 +0200 Subject: [PATCH 3/6] drm/msm/dpu: don't use active in atomic_check() MIME-Version: 1.0 Message-Id: <20241222-drm-dirty-modeset-v1-3-0e76a53eceb9@linaro.org> References: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@linaro.org> In-Reply-To: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@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=2196; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=dBpoTk4s8OfoXgQIHG9q+kMWzF7ACr4fOXNDIEIP2pc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZ5z7MZS6rAhW4DKuCWV9b4WdZ4hjqC6HLAq/i yre35Fm6UKJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2ec+wAKCRCLPIo+Aiko 1YNhB/9hX2wrzJFQ1fwM8icQeBER9azSe4PG8Bpkhfz75DieLiutJPwRQtpOItU+qWqg6WCbESd AFhW4a8ggukt6IuqRscFxzbxnfStjAf2/AAxGGiUjRKmbegN4evvPH5ZuwMVRYHJipxbUjM5dRq DY26GP4KUxfZcN4d8cap0cnUgNxEWBohuAcKFyOWCgnSxUgNoKTOVPzAbLRB/+eOClO0t8tg8lG mu7U1WhfrEEKB7DCcQOb4GQxWfGAazde4EKF39I9VOy3jDXwpFEdA8wWS7KB8Dd6qh4K2Qf6Lmm ngCcXoIiCtGuHQpeqXSzY8TZe2MPU/nrQD2jLanaCowQhYyE 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: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support") Reported-by: Simona Vetter Closes: https://lore.kernel.org/dri-devel/ZtW_S0j5AEr4g0QW@phenom.ffwll.local/ 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 83de7564e2c1fe14fcf8c4f82335cafc937e1b99..d1ccdca6044353f110bf5b507788efe368f223a3 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 Sun Dec 22 05:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13918005 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 287D4E7718D for ; Sun, 22 Dec 2024 05:01:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 86A3410E2CD; Sun, 22 Dec 2024 05:01:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pCUzqQur"; dkim-atps=neutral Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2E17410E2E2 for ; Sun, 22 Dec 2024 05:00:58 +0000 (UTC) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-53e3778bffdso3548814e87.0 for ; Sat, 21 Dec 2024 21:00:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734843656; x=1735448456; 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=NaQTzRa7GyvxraeqI5vqmNWxM0qcr19enSqB7F9pnhg=; b=pCUzqQury6B2qX0YnbdHgF9Lv7hXKGUqefQ+lFzcGKblQLJ1ClJhuMjzAcWd9mYiR9 qlCiS2c+z6I+SskKtteHWWcytoCDd/mj2xmV52/vO4VZItkPJkMHDXgdpCiZNf/kM1SJ 1KO+E4/9b6yebLi1KdigmZOjlFKWSRc3NR999UvKCrjCeExiTEmvKDDERrCyRlNLPe3M TLJPwBANrwqnakyBpO4sJPzfWtAK0L5qf1qVYEg2tkEq79SoAzbSO6LRDz7IsdZ6Gqi0 lPafDR9yKAb5i+4M2rXghk/K2QSLgoYUwa3U+5dN1XudUHyNWcVoundrnz9O3F8zwrPi sgHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734843656; x=1735448456; 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=NaQTzRa7GyvxraeqI5vqmNWxM0qcr19enSqB7F9pnhg=; b=i719abUQfcX6vVH5wOwD8Pv64eMMzOc8NaUeHzCUbvKhP5GJhMkGoFavN+cXwaFpkq +talbNhUrgaxaZPB42H+gCE0de2brooPmtNaGb5C1dQDfYaPT42lGxzcCJwZxFmWtrXF rn9xyufFb0RLXtjSP7/y89VHnjo2L7RS2G7DoXylFa1W+Ma193am18J9MF+wRze6ZVZD OI7WL0bGVVaUyyfKqVhyMXbr4D/BpDyECOdH1Cr+0+GEHOrP+zY+SqYY+VSM7CYezP0d y/RCDg3QyHtaNm2MkbZ/PVdW7AIX+2hHhSsMXgLdpQctBKWXuGzOPLBUuBFPLG5gX5Nl UEcQ== X-Gm-Message-State: AOJu0YwnRayPefhWnVJgQgPrCVhpv8leLVSnlBbCsSuccE9Lr1A1OP2g uMfZ+rWcB/DFYjp8NPwSvSeIugvHtfNMdjvDJJpQ/u3tyXBTwKKHyLLM7uuaajA= X-Gm-Gg: ASbGncsOCriv2qOiW7f6HhxV+egdkk3vW5OWSSMloLkotomi++69ghm//0n+Rlx60G0 U/DVGVXqKxbCuizxIQuObL1xqdgop+Pt0+YxKP56KJQ6BaIkPugqjBiODftSc3ywwN7nanCICuS aFhVFYTVHUn19O1dvO9wpkHEDYnrk9ocpMCqie+tKJzK06+lrV+pkWQzegnIR252r62l31HQ3Sv X4Yx73ITQwbfBMDYS3rtpB4edmwoAvHm4SAqCChhUL0KuJ0r7ZTLKSob5Eee6fi X-Google-Smtp-Source: AGHT+IFCHLgrjc5HUCgWghQmBMEv8FeLcEj5wjWCG0Y3qFK+eTqcI2LEnkuQNFWTsXWjWCzbF72i7Q== X-Received: by 2002:a05:6512:1241:b0:540:2122:fad7 with SMTP id 2adb3069b0e04-54229524544mr2818968e87.6.1734843656392; Sat, 21 Dec 2024 21:00:56 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223832c05sm887145e87.276.2024.12.21.21.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 21:00:55 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 22 Dec 2024 07:00:44 +0200 Subject: [PATCH 4/6] drm/msm/dpu: move needs_cdm setting to dpu_encoder_get_topology() MIME-Version: 1.0 Message-Id: <20241222-drm-dirty-modeset-v1-4-0e76a53eceb9@linaro.org> References: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@linaro.org> In-Reply-To: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@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=3602; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=o0B+a1EF4We4PO2V9bfhp7XNttccav9liOTM6iCtHpk=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZ5z7H7lKvmpQPT9gsq35qp8BXSedRa8X6iFH/ oDbcZTeZZCJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2ec+wAKCRCLPIo+Aiko 1V30CACrnY9yBGk9zsTN2C4/b/4NS4qlZM6+sC2Y/1tiUbIK5OOelFJxlAU9YUwhFjh3IDXOHen 96VjYP4WOWeys786HTLeSzgDqoyfN1nh4HPZKyTruv8bnO4HOC+smWKvHJp7y0HOB4J7sVMNQHq /eBJ+zFbkuUUdpTiYwysNHbZHZqfQyXoUAqckbsq5eb9Ah+uqo6JnYRxH2cDZGg7fuvI+b1ia6G 7soSXXUPF4As4NiokQVNEFyq7wT1N9hYgm9zhXfEWF5p/c691qcz70X9taEA+xsz3b7Q0R/RAC3 oRClP3Z3LB3u5boHLR8PSbvh0oDS/eo0nAb6NLszMP47KqxO 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). 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 d1ccdca6044353f110bf5b507788efe368f223a3..88690191a9c9485e052d37749d1b61f50328916e 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 Sun Dec 22 05:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13918007 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 2904CE77188 for ; Sun, 22 Dec 2024 05:01:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A34AF10E1FE; Sun, 22 Dec 2024 05:01:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EYgk1xb8"; dkim-atps=neutral Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by gabe.freedesktop.org (Postfix) with ESMTPS id ADF2E10E2FD for ; Sun, 22 Dec 2024 05:00:59 +0000 (UTC) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-5401bd6cdb7so3532083e87.2 for ; Sat, 21 Dec 2024 21:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734843658; x=1735448458; 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=1PPE+DKsFPu1B8MZdgtx/UyAZ7+JrfrkZtB47k/Sbl8=; b=EYgk1xb8iJibr0HLOF4Au2z5+Fxo3264G1s5EKpZgut5YFv5MQ6Sy3/L6dOdaqOjex d5gs+Q8jgnF7LfvtN2Ijp1hq8Srv5T6qI8t05iVr6QsfuhxGMsKo4hwtx+unGvT5UVFn 5OjarSOzcUhMu3znTyBboJ0GMmpr5oMsr3DRVsEHQ9wYcWjUDp+qUBJ9JeS1hUZMejIA tM9JZo1pIXmbSu3RlRiBbjllRz4ZKac4isd71EZWEgbOAcYELHEvR+l0TGtY2skakqbL +YD1hPFeOQ7kHraBfxfQlpa7gICcnoP/9xZWVocKc2jVZaa3AL5pLYTXi8VdRLa5pcVU upDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734843658; x=1735448458; 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=1PPE+DKsFPu1B8MZdgtx/UyAZ7+JrfrkZtB47k/Sbl8=; b=nv0+XjQyy0QQfhUrIAEoJG7IOjOsa4t+zNsK81+BV97ecwak+H/EC0qQp6Q1TMNpH6 kk9+RUBSU7EIc04DjB2XxWQ+TVLiSRRUMqT+ja0V6hwz3drdumWAcGgUSDKNNT0VacKO Cbi8UjRunph7Hk395Tjb2iWWMgVFmPUtYvZcvjudK45svEQCZPUBXfl48Jt0VBGS5LFY fQq8rAGHBiH8v0gEd5aNPLnxZzXPbmcKIowy01/TV5WCEzepztVjLSddVZOjTRz+TB4i 18AmMl/od+7RVmoOg4DJQ3tqqHYqY3op62c8h/nkGhhUcQQoM8duDQcBfdeTc0asiSLJ 63uw== X-Gm-Message-State: AOJu0Yx4/xKs27R9UGtfqTZQvEjAGyjx9g/KL0CL4gJR0oSGwEuKXmsA DiMkvITurXJitl3Lmp+nb4cupjJ67bKXUCxZPqzuGISCdFsE2hkf/wD4RkplJ0g= X-Gm-Gg: ASbGncu5JRI3E9G0HXhN9XhblXZowLEKbu01ExuRE2UTgu+Emtkq4A5P5ocNmAJTOMV KDvZpsp0ud3ZNYUKMaLiPn3j+SmHdUxWeUoJhGGcP9FLBVYQnDXk/rveLyy79nxytwD9S6lbJNk A3y4A1ROKQjhn+tb1qcwnhs1mwQWmSRwwfLPgZc+imBFApCyRXvgow2RxOOaGdwt+TF+lnVzhWk Ylj0UVx1Qnj54KPB6xgYCcywpuTM1yYvvy6ZYrdgHpfxIcZ1gs8INzjPvY471f3 X-Google-Smtp-Source: AGHT+IH+eDvaVhNnPNnX4zWTkXTtQclana7wLSRQrkIgq8aEDb+XrV3w0l4HgTPorE4qdZ+Lvklo7Q== X-Received: by 2002:a05:6512:1594:b0:540:25a6:c390 with SMTP id 2adb3069b0e04-542295302ebmr2158713e87.23.1734843657997; Sat, 21 Dec 2024 21:00:57 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223832c05sm887145e87.276.2024.12.21.21.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 21:00:56 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 22 Dec 2024 07:00:45 +0200 Subject: [PATCH 5/6] drm/msm/dpu: simplify dpu_encoder_get_topology() interface MIME-Version: 1.0 Message-Id: <20241222-drm-dirty-modeset-v1-5-0e76a53eceb9@linaro.org> References: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@linaro.org> In-Reply-To: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@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=2208; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=SDNJAbezzZSsnq7fpawYXa2xRvPpUEjnL/Cth4qzNd8=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZ5z71T2yv4R9UPEPMcmIkEaIwmjnLl7Y7eQrO nscMp6Tu6SJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2ec+wAKCRCLPIo+Aiko 1duyB/4rfKOpjGWq0scuzKBQewFm9Dx24jvzo3P+DhpeytyRxLzingB/T0inzmmrQOQpwKiWfio D0jnRNBHfATPbKdu4OiS6Ki+k+1wH8XzuaK9H1/7DYTAWvssLTPZf+ICqjiMg1/fMVvGUEPforl 6todMfQE7PWAwSCBq+AvLLppjwzKnr4LPlvWprhU0JjkJameNpPMoYw75JklyVFZF52HgKktBdE 4YvP3+1DV8EVV2PLOTBqbI5FiINVobD2NbQUdj2uOWPN0/K5NOgiPeFbIb24a52wyKwcbO7XIg1 IkHrr/ZnBzUs4KQ3Rza6ZJjqFgfe+2R46XD4LIAeqHeJh8G0 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. 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 88690191a9c9485e052d37749d1b61f50328916e..209e6fb605b2d8724935b62001032e7d39540366 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 Sun Dec 22 05:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13918006 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 833E1E77188 for ; Sun, 22 Dec 2024 05:01:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C455510E2E2; Sun, 22 Dec 2024 05:01:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ZG1Ju+rF"; dkim-atps=neutral Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2908410E2E2 for ; Sun, 22 Dec 2024 05:01:02 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5401e6efffcso3868891e87.3 for ; Sat, 21 Dec 2024 21:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734843660; x=1735448460; 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=8Z+rBahjAbnRzsWwhl3RN6A6WwHfHM88b39CtT7CZn0=; b=ZG1Ju+rFTbeoZC106zlpOuUuCdB7T2qRQazBdRlOyTPo7RXWLV2jTuB/pzV+9oa23G RC7iMk6hWGpriSECI1IMjcB/VkYxBcML5FQIa8QcroGUNP8k6KVwGsc0/UVD/Glkyytv N+iufowQv5Z8K2L3GXSp51OG6Lwc8jB2g1YmwDiUk7H2I9wJAfZD5u1OAPKGsYQ+Wmk9 k2pG3nzI5Pm4YhzJoRIH0Os59ZWa+z+zuQW6Rc0gbB1YN3hQw87YfbCeCEstD6ZZm8e7 lJU64dHrSWzJvXN0K0cqN2OGsOPuStSDn7li4+8hfmgvaY/T7NuJUWRCBIwiiIMlbbmY aU7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734843660; x=1735448460; 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=8Z+rBahjAbnRzsWwhl3RN6A6WwHfHM88b39CtT7CZn0=; b=dnkCfEgrMeRsG9kjgB6ZiaZOlzdwGem8YaEDp6E+/0nXQwfEF6b5ck0KRmLbqFBAWs szNhrNHex15BSWVoje5Qz4Sno7g3mJVRY2qwRg6Nar+MVLdUkynvppGNIlQLsIXiTA1M IqBGkW/5azYhvWEbiIK3/oottcdFYG3wj2LIOrGxc8kqMrUzAPDccMfTn6E/pVnftqq9 alJyy1cHM8olTNJlgXVB24YNSi/OuYcf6ZClcO7Tz/bSZVCMzncOAF0BiVOfHYqXG2O0 bYNq/iF45EG66EV52vn4sDdvNvfXMyUSZm2RcF5Ru82RBziDFFt07srXqdysL9HREVnU s1Eg== X-Gm-Message-State: AOJu0YxJwpu90PZPP7+IVAJMUrEakcsKyzbQGRhk4M3XLztigQp3fb4i iPDnYdsGOO6tR3Exqypsh8Eva0NyYi+pj515AJafXwzhX8iPKLn79GVvS9PWJKE= X-Gm-Gg: ASbGncs3b813CNW+t92kHvIgeSsidUDLMje6vWH/PZ/Vuar0jLDwmOBoCze3RTlmtC0 xA/ydVqdz10WoUfrV47xVUFDy7Lum2pDl0DAqJKpTHzvBgmjRhqUG4rSy21ag04PWL5/bql12uH foc3n9ZH1f1JVDxM7OHRaFAMN8SCtZ24TkwT0Liz0bByvIOkvUDsgxQr34cioUVgQUSd+wa+eir lF0xbEq855nSaPtfcoASvJ8CEsoHNDnFIW5+B/fw7hdoleYTrSuudDXy4XEONVl X-Google-Smtp-Source: AGHT+IG9PLc2TgcP5V5DNr8mxT3YMz7GDwhcZ2v5XDciS5lADg8+jcgwoscaaLV0JLE5hmtyxk69hg== X-Received: by 2002:a05:6512:1055:b0:542:232a:7b2c with SMTP id 2adb3069b0e04-54229548e22mr2561331e87.29.1734843660430; Sat, 21 Dec 2024 21:01:00 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54223832c05sm887145e87.276.2024.12.21.21.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 21:00:59 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 22 Dec 2024 07:00:46 +0200 Subject: [PATCH 6/6] drm/msm/dpu: don't set crtc_state->mode_changed from atomic_check() MIME-Version: 1.0 Message-Id: <20241222-drm-dirty-modeset-v1-6-0e76a53eceb9@linaro.org> References: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@linaro.org> In-Reply-To: <20241222-drm-dirty-modeset-v1-0-0e76a53eceb9@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=7162; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=DYgtDJQPVbedGxDbDp9oOhz2z6FzJGN9bVgSpfs5T1A=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnZ5z8q5ZLE91hpI9bKURtnooCKOkRd5GgQ1zBl zIpLTUQ90aJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2ec/AAKCRCLPIo+Aiko 1YdFB/9Tz+IdZGx7nLZX9BeA60xx2fLspau9frJKY4ko3gNUUbQU/cwT136wnAD1ttr9w1J2Qr5 JjbKLIeY7wZMujTDAZEGbftU/AxzoO4wv/RLT19oZjTUfaHEY6CputmywtH75xjAh2J1GozOxwL cczIqw7M/abx+wncedvtjA9yao+zXq46ZJaIui07sbmn17EQ4oMx7DUuAuMweOq9auMCMhTY2Gl A6zs1jORwpjWrBJOoGRsXwSkLNBFgad2oUtwqdoWOecRlT7XIoT12p16dRxwS3YfoJHRixmFMkN 6PNecUwIQSZ3xPz51fnT7xA4C2oi6yq3ve+Eelxerl7s2QCk 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/ 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 209e6fb605b2d8724935b62001032e7d39540366..b7c3aa8d0e2ca58091deacdeaccb0819d2bf045c 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 dae8a94d3366abfb8937d5f44d8968f1d0691c2d..e2d822f7d785dc0debcb28595029a3e2050b0cf4 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); @@ -1049,6 +1074,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.