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: 13917995 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 153B3487BF for ; Sun, 22 Dec 2024 05:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843652; cv=none; b=oYS2yD1/8eAbKPaJdhcQcBuraRjoFb1b7w5sa07XCckSWgZMOmmgN4j/7SZjoBcAjWOoAEznJ4SPBwdKHAQakfRhAxj36oVz56LDThYPDcM0HO6Zki9YhU4wSB2cpOjU1kSEBtBz7dhpilF/z9Qx83+fHFEP25leuQvT6Yl6fZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843652; c=relaxed/simple; bh=lEzV2DFxHSmrj9mC/gnIKltRLYW/iHK8CYgZvjQpABw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lL3TiMn0AG79dr/TtjR+ePqKPQz/ukhNWSZX6wgr5n3YN5nQIL/5RUg3gM+40VlPClRjdq7uvQcC2G68aHc5fqnCEO6QePZuPlfFqPWBhtko0JklXrYtBQ7gd1MTvddnzkCizWrvZH3Jz4rkgGfpnYERrnWFYSOorCDI48l+8ic= 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=DdxV+KUa; arc=none smtp.client-ip=209.85.167.54 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="DdxV+KUa" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-54024ecc33dso3873217e87.0 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=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=WUHXS68dzii47sCyHoBGO1JrTDTtIN7oWeXHXt5K2JQ=; b=DdxV+KUad3CUYhwfgEjbNe9hmQxJU+olBcwMSESaCkzYC0FFAEp7cZo9kzXkWnAteO StKlYreroI5/nieUMa1ZWVjHT0SCfXawl4ik/WnHAXAYLunfuIKJpVlgFx2Ri23mbV2z HUIEh7i6gQxG9CGxiPBQmKmiV6CwZFC4ZRPSDBz4vQGCx8GkE8uwH9GdhzYXB7QFb67V 2IjQdg95ECd4MlSczLzfguHLSkj9ERlzL8OzT5MXWgAlTdDQKFDHmCS0HD0sQAeI9Nrs xWoz122742JzlNVDBcM2Vj9jFdsqnau207RiVa3xvUUNW/ONQbg60AzGSYvOEfT8pKfu rgig== 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=cd8eGk8YgcAQtw/b+fttT+glMhjIu2I+bobLhs2dhLF/TTw3QIHyl4GnbSqvHgTfTJ qbo4lJ/qHzWo4fDIXPL13stPyH7nX3KZT08Ej+fkeydL0ZrLwUcuS+0KLyAvtnQrMgjJ 4G45wjWD++qXrsGHMEoI5gc4SJJXH0zN8wMFvkkfJen3O6JWdblm3V9OgVSbymBo5Maa g3F+gYUURCpShmB4OiJvCSPKdKhXWodH9UaFXCl0l7GjYtFG7Y5LjhoJa8d9qqfVwxs3 o4HfUg7xY2C7ryZl/A3qNcNtZPYVcGjwhijxzal+C1nZZdW049D+oTOpwMg8nb2q1AFZ C8Jw== X-Forwarded-Encrypted: i=1; AJvYcCWv906d5wGlCVccQlMLO7OQkvKd61PS+Ep1yZpkywwXk+EfpGLi8EROAkLcDFvsWvVC2mcJ0SdnPFL7Y6iH@vger.kernel.org X-Gm-Message-State: AOJu0Yxq1tEaahLvogVOdBeWA54ZGNYCobaAYO3CRDtKwi8m7sEIzgB4 s9j6bX8UL80s7LH3cCMZdHyk/fwrBIaz9vLwUJsHlYPoKvTmMuPvECDwvlyuEpg= X-Gm-Gg: ASbGnctH2QPFCKOvYL2Wm2juJFo2g+/MbX4efR6g1olTOsfP3iJkBvxy0n5Mmpw4JAQ aaAYosEXqS+F1p4gSUMSqGJTDuEaiPVnIzO/A8tSv9E/15FOcE6sxUXyZFORrdv83LCRi0c5qfw JQxv4WBSR9OZmrn2DEtozcwh6gCE/NwoRlW3sY8LELAo6zk+XAbQHfEixhZamsWzPBlRsvZ9sUD 63VPZwTg779/cVKL5vZFxfa1pjbYJ73iVqWZW6ZnA0SSKYMlTh7AHMGP1ybhYL4 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 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13917996 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 80283487BF for ; Sun, 22 Dec 2024 05:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843655; cv=none; b=ttJcZxIE5rbxMKB8dmwl+5JsYV+S6Sqxgp6Oce0CuTUphDn/Qk2gWEDrTaOE9W7Z4CtFBej+Izdj7pm6Yr6IrdLxr1xPRdOJgpzFJf/+UBrOuMxBxa/tJOjTSLzmg02DEjTVo3mfFar7NIIzyPIkzTLL9y+lSKRASV9ywL/gUKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843655; c=relaxed/simple; bh=rWS0KFUVLvGb4ozb2+QIr1gzxcTnVRN9cNSrdc5NX8g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QIEhgb5mhpxu6Y+XQsYUl+qWBh2cjLZqOsOEIwMJuOXeucAXL9NGNCodweZNIVzQibpX5G2V+IaxAKC+lq/F3QVrZfzyjAS69Mxe3/kzPm0s1CBCzvQtvd0ToDRFPTAlD8JsyO08x5O48VvN0efnp+sqgyZa3ssIjIA7N7VFyUw= 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=FbTxft04; arc=none smtp.client-ip=209.85.167.46 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="FbTxft04" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-53f757134cdso3424395e87.2 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=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=N19A2AjG3Q/s9SAFMXdSh2+o269dpLqgKum0CI5lc8s=; b=FbTxft04DfJd+OpbwFNw25w9u3UiLZqRfS2+49ZmQCCfOZ67vRYK4/WCK5QvFGM7rT 5J+AiN8G6STVoDBtGc111JpWwJk5mjqzj0g7xUUbsGHuBp4c8iR9g9gl4DyamImpGz46 QckdxTQXVQBsBpo15FoRiRVPC3lWDSrmlhTNmWu6HTQKTP2sivayS24CWrNRHDUM5hoO x9DHL/elA/CFbMybiZ7okoEwB5rjzIjtxAWIs54Qss0/KokhOnCAfI9pS9IOxmSFkdiB RYRViIlvqWzcu6yj/TOFrNVNg3zAWpJRlD3KcccBySYxhQELPYTp/LaSO4iKumTA/yRd hpJQ== 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=No7GmFY5MoylpS+rM0eb9Na/7t6trUR04oP8EUOHNED5CDDTfUW9HgjViRBm3u6b9a jQW9DnmwL6DxLF/ByyFLVKp6ORqmQ12DMYA7f5FneMm9U+Xv6Ug/gmYwfgu2cqOxiLvh 5tjXT9uwRF3/DXteGtcyaETt5EpUNtIIxYs0WmyyBudBtlqQKLUqJlz5TWZBqTwue5Kx gFndxgFsYywYQV14an4GzxYwl3paDd/YtHjZeT9C7fx6wkfwMwyRTCb9f+y9yKB0TPpq wi752PHT/cEZtSATfelBH6nLkZHZGDMA7r1CYeZgbj6slakIPND8Zu8vCsxGicrnWXzX R1PA== X-Forwarded-Encrypted: i=1; AJvYcCVfXQX7mwWG4VIDSAqTEgToW76dgD367YkGa4I6P8wSR7kv6e9O8Gw4zDK9DjDTRC5TsisvpXeUPg8YlkkO@vger.kernel.org X-Gm-Message-State: AOJu0Yz6ewXOwZelqTYplty34waBO2ifgQLnVRQxIRfvfSns2vQa8Xa/ HwF95RUZAxXg4am4EKsdnafadvp7OlQ70XGCpMcYU5F7YSFEoPvcEmk2vyC2mk4= X-Gm-Gg: ASbGncu0+kbdKcNL3DXwErqErMwxLa3utZMdlyWjKPLBS7qy+VaUoYo7AB4UZAU6cYr wUeVcGy+URZoiyzyhUw5EQvrtTjB7u5ObLyV/OYKEG1Hf7CgIv2YzUZpbW7XD/gL4GE/aBBFnjD LaClJcW+itOxhQTcfsahpheYRC7Totv7xXsAqboRIrOZf60l4lfMzm4vv3WLdDee7Qg5xim2wdn hsqKNwCOeTvqTjIzQAO4k1KWfzVb1ebmMk3bl6wnA4t8BbBqBJYJIAipZ7WqJW0 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 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13917997 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 CE0DA155747 for ; Sun, 22 Dec 2024 05:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843657; cv=none; b=ALMwYph9eoHIZnQeGRN8+RD0tD28CHkA8OL3WzJM9GnHwiEcWsi7iZWcCH0P3aloZ3RSkQXe6g2RMXzx1upnHYcXdbgTRlNpSEX98dB+D7OjH8dhf2IBB6J+iYZRV3kwrf7GfzFucLjdGP4TgZfP/gaDRMVOozJsieuxcMFmz6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843657; c=relaxed/simple; bh=dBpoTk4s8OfoXgQIHG9q+kMWzF7ACr4fOXNDIEIP2pc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uUwxgFBcwvCykAAaARxY3PlOVr0gpuqIHvOMnyFnyeOj2ZGLU3OcC+np+qoO51+LSEVWmx6kdIGpefz6D60MXUm5Dpe/T1YQR6mOtKfe62b6NS9h/mRUkaU/byQVPUJKHta8LXqBaFULgx4oJckoxqCtznHZzzMkoqaKP5a1NSk= 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=w4N/OPIy; arc=none smtp.client-ip=209.85.167.50 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="w4N/OPIy" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-54024aa9febso3438451e87.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=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=SPUKe2inYvlgyzg1RdM9z6lWoAQEDWbkCd9hh5ymtmI=; b=w4N/OPIyF8ScdhmvCkfH/DXID6gzc7nz8JC2TXeihLPEqI8+WUcN9Mgnn/k84kAxzv 5DGVaJ8cWOesRLpdcx9Gl7JygNok+r9RTemo4XOIpaPurwZF01WC4c0F9jpegWwClz3d gSJPgVZH7G9x2A/BLkg8rT4sVtONreVrnwHU/ark1BhmddE7UpP+jaHbU73wCWa01bvP 5mOmriaeUjjra5lOcIGLYlQ2WmcigcZmubeEmc58Cb2tBqD5/oiMyoeCaehK4KSc+q27 AQZfcf2xkEk4MpC9WrC7K3Z7fwTODTciNhD+6SCR2cJTSuf03fC3+BTfywacuA01x/kZ njEg== 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=Mb3ycRWg1dWx3Do/CQ/wNDCq6hgGD4wJq8YphSk50p/vFB9Ot/d+kC/w8rsgm9qWDU 1/f2BPt4Z4Mw+ls4pt3PMZIYwI00tGPSlqUhnpi62199e9+VQkJaH7AoUfHpq9hqcvSs htYhKY2+W4XBu8Bt/RQqjGCHzUvWsywqU1BYze7nZ2bqWm+Y98FPcUvD/kByIaLOtImL e9L81qBaGPJFM4tBJKG2hKkga51cHgz3w5xgs7Jazy5ZfeCw7XzjxVL4cvQhNAATskST jzymmJBzEw84V+tGQ2uKIBEuaxdr/9X20fPVbQxoQWn32vAnJO+GA79THygl110BLavu EXqQ== X-Forwarded-Encrypted: i=1; AJvYcCVk9d5dHN+NDgk4to5gvfDcTTgwyT5JSighb1LD7aMfCuhDoBn3VfzC/qi/J3EwK8qawV4m30iW6+AkSxeO@vger.kernel.org X-Gm-Message-State: AOJu0YxfdrQayVklVTzfmdyHTdXMpuLz1661jnIRK1hqBHuJjqHEHgoW 2mILmggGpTA8cVSQxLZDH/nHtbOnWMteG47L+t0qINeFD4RbhTh0fiVWpoXYpqQ= X-Gm-Gg: ASbGncvMaMaTH3skHkVAYMC5INg10fX6r+wUDpZ/MVyZH/aFYpCNXttTs22Yg1/7+lQ 2NL+bwlKccGLAM0xnSviyUKfwGwoRNnx19p5uqc+qnS3HSDMf0qhjIYazmVchRk8qiraJV8rMy1 uNgDzC1Zp+F7G30TiEr+ju2JnDtmhM4TS0e0/tu63Iyk7y3Ihzig6Ggw/IxanVqBqX6YwLLue47 8iF/BWWFd8IejswWaUB/VnAmif/jOHoDS+jRZ2zNfPbmd/jMGSpS0rt1/0OPS28 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() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13917998 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 4666215B97D for ; Sun, 22 Dec 2024 05:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843660; cv=none; b=phxYxlfVxSae/4NT9EbAombwCwe7b4YlsBMi1NfRXfLjjv7lzI1bIQ3dhPPF5pFg8X2J2bv3qkECWAURr9ts4JBmK9y+387uBWjliBMy21GQAooBXwjcey7524/JU2sld7SHrr6HJILQcGiCwOYh+1i5oJlGFgJXKYcXcpPcvP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843660; c=relaxed/simple; bh=o0B+a1EF4We4PO2V9bfhp7XNttccav9liOTM6iCtHpk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ex6FrwrYzwLCt1xEPx8kefR92lKMx0CYkz6TlAQqN8NldhnussvwX4+3LBYB+DtMVNpI2zuI7IVAdcufvPn1CN8hXN0ynqS3mlosVwR1zhEpwoSfcJO/Loq/s4+YfDyOqHH1AN25xLaRBHxpgPSTklqSxq2ec5gBaXUO3B6LK0k= 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=ABjtYV/i; arc=none smtp.client-ip=209.85.167.41 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="ABjtYV/i" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5401ab97206so3204955e87.3 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=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=NaQTzRa7GyvxraeqI5vqmNWxM0qcr19enSqB7F9pnhg=; b=ABjtYV/iOfEAUO7oG+hgJio4+InVFxC2tpAe50CEVyoZLS7T2eHikPP1f9trimSrbY LPNHZuxHOzrSs9zh52YLwY2bnHDhtNnzi2WiiPbC6qQvN7JXcskV9UA6VBzswLhFpfpp XPgx5yUYVn+b5LN+AmkPOdfKvGgVNpUCVRvL6Y4JgxkzUy6cWy1coaQ39JF9fVsvGaM+ Cbef+qGGUiML3LDOlyhVDXATk6jEGZEXinV8hfwuC2+t90CenGOa9fOyU2WLasJqMYKd BB/C7ArkqUnzXF22atlbQH+Q19pkFkP56hQ7T24b8Jszz3ov3GfRcpyeMmBPCcHCkSrq 10iQ== 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=BZLdR9WCAKesbUe4Zr+XblTtux70gUtjaXAq80ZkZFRh6ZObjOufoeDx56GI+SNHYh 1SJLcx9NrcpPXmY1Mev3KHRfFepJBOCeLQUbZ7Q/vdRAomDiM6e89RYuxXLLlsgTC2Z2 b1c5vqDHHcjJhyO9dc6OgOuuLpVUpfGAlmHaRZyDD8ZmKVPv3+0uj+JXn23doR0mJsu8 1qSTeusq9M8Ik04rQV3zVpQZH+rdzToVSiBplUf/91oMLzt7CxHSJmLfq3vAVnkagf+R 821vzWr13IJvU70LhvznmIek3VTMYCCHS3seNC5wwLyBGEI47iaNeazNibFDVataY0N0 4ZSQ== X-Forwarded-Encrypted: i=1; AJvYcCWbLA/3Tht8OX8Oac3d5dNxOi4wqIJt69stIMtdaI4l0ON+UijUoshL5Cj++NL/+IG7BCN9zhQIVgwMj/23@vger.kernel.org X-Gm-Message-State: AOJu0YxcUgw1TnAMp6lAU6mA0hOipHqXL2hv0ZQOIvt1hGOqfpLZJxhL OX+B5lKdaUV5l3lYivMWEP9iSbpjps/XiWXmHb3ED8E/fXlZlZHsEg1BiVZb31c= X-Gm-Gg: ASbGncs3NKA1hqN8QCmE4Hc5ocfkE17wPHj4nmluosjUulZGgcnsmYSetwYobYt2Ro5 P/zolTG+eHBF3UO3io6QFc0ONuIAgfKfcjYIe+ORdl5ZLw3NJyxPiyDABYN2n/INRpACEJ0OzQN wPOlYw/x8Zdk2xHWLp8jHJNIFSeKgNsbHSF1D+e5nWetTtlnTURbeGNVeUV5p0mgQcu5yB664GQ Cc5PJgTW+7UJgYpUOo+o69P3BO7QcyJnR96A8adyXyM2ebS0TclUsKObte7++RV 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() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13917999 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 DA88A16C684 for ; Sun, 22 Dec 2024 05:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843661; cv=none; b=Sv8qFmN3u+WL7/Y3abl9gdv+2I2oVwRBM06QX/COBvoeTEbx570K6Fpd0GmHKbnIAb6FQWg+vrbvy0IL4ggYh5pv8MdNn0HjovQU6pPw0TIHvle/DRyjZ8qzZr0uVh+iKuOnFGfe2BrtEWy4xibtvFoUJc7rMQEBEAPYcJDLX4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843661; c=relaxed/simple; bh=SDNJAbezzZSsnq7fpawYXa2xRvPpUEjnL/Cth4qzNd8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BbKWBI7ZiLL4snmhsHlKH27mJTzXlRBiDq8lTYsHIYozxHTjBDZ4rKI6ExoPYXMVRmqFYsgJRlxnmMvzRmPDlZsVmgJHaz9O9OOIWYpxRu2aiURcQKtws162bVTCGVD5euJnx20eI8P8ndStjmnu5WgM5QYKcA9wkyqBm5Yjo7Y= 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=EjJHGDXl; arc=none smtp.client-ip=209.85.167.47 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="EjJHGDXl" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-53e399e3310so3626537e87.1 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=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=1PPE+DKsFPu1B8MZdgtx/UyAZ7+JrfrkZtB47k/Sbl8=; b=EjJHGDXls7MJoxyFa9LE7FLh4wjhlktH1/1EIDLljwK4bQvRvy+TPhg8MGiP2qXoT/ twRtSZGBGFph3gTj1ihC4bIfphLImmJDPVGW3x2oDm9SyrCNt+DYSphwsRMVxrlIS4Bm 2TpAboZKBoFV8HgyhnynDifwrRe7NTFi22EwXkpDevfEctZ1OAoBwevBgeVgWXkIw+Ow RQh4ZHllWNE92aD+tBhy0cVZhRGl6cnP77O8YJ4wySsM+em26aeXH6+qYAQpFObL3YjP i8nGRiSUk5AwFW/ga+dG6i3CHzHRgkFOcKap3WsmWN06vC0mua/bS7ds/2u6i9Nhfsbr XWkw== 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=DLqQNXNowptXrb/KOEl4tlE6s+UvaMPmxfSEAlIYrTJcntQq59o8Ikf0aBf8Y8EUNF 7A2gFsp5o42OLJ8fXYijd1lEIkPugYGWMWcamDvmolkRU1RUmGvCdcsaXvAsOJsdX18B q298/MbEZsfYBPha/lWhNURxXGeztCV5YMAGTyuNQB6zKX8zAJbJefOnKte3/Ots7Q6Z ZpLzRsYDRV/j1nsKb8ngC3/LThNMT3ipc1CCFB74UDTsgr9ixZ0Q9RCi938FL8lKStxb 3rQwj+h2kOW5qB5Fyoe3YTBlh6SAJEQX8eCd2lZpeuVo1SvH93ph0JFW6JWg6zqo//y4 cCGA== X-Forwarded-Encrypted: i=1; AJvYcCWNKoPGP5Cc4ceVZfSRzpeDYV1Wox5hMf4nv+w4emOU+EfSPf18TsGCilqnQrKpFjlA3IPQipDhog7AHvQn@vger.kernel.org X-Gm-Message-State: AOJu0Yz1HVRwt7V+heY//fmx2qAWVk+niFsVkZIMYCy2p8rpGr2sQP3S Wi8YBIQmPFdpn0G9vefSKbCRSNgvFlOawVzTJ/zpIY5W+kWlplLzNc51y8WOflc= X-Gm-Gg: ASbGncuQeBLJn5yst1OIxRi/ERi36psGC0RmdZ2v9EfNh5gqHbZCREhi47yJ31TKiAR YSpTz8mNsGM1r7af+LoLeAHi/yXc3/TBzMlQJYcJiUFxo061Vnzl+omKvQCZzklTuUZsvrSC/rh Y3WrE06ubtwFbPTf1xow/EbYmpb8jQoRt0dGKwfMJ3e5G65sYbNnsMzHIy+UatDZ5njXZWvETtQ 0GJDN6hp3CL67oH88MJE6CK2cDkpnbvutZqN9KRVEgKQpRHMVslJUHJYg+R/v9u 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 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13918000 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 417DD17BB25 for ; Sun, 22 Dec 2024 05:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843664; cv=none; b=dD/ZcGk8Ek8UvORbzVS/W43Bo6RE/NPGPnMihf62vozNmB2+NHsJBg1ejvq0deQ01EEa6BGU6uJg4RZtOboQbc8CTfTZO3t+XEz9RIWwezJg4PQIjP7cULIeXMxvTTLX5cu91b93OQW4SvCHpV1rtdNddOaWGlKQGEzT6AVS2/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734843664; c=relaxed/simple; bh=DYgtDJQPVbedGxDbDp9oOhz2z6FzJGN9bVgSpfs5T1A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XUQK9SbvWQm21SkMgKQdNKqo4eARm7/8R861At/eYft/kcsaxaVhv0Ebb1UJs780yymCMqZY2aAvBqqO3/QIBpGTdyImsTV4ac1vc9ufBCo/hP/9m+QOpHOXddDXHlUttBFTEWuzlOtNvtluyiywHW+IIk/O3hd1vg2PMKrV/WQ= 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=bPwXlRJ3; arc=none smtp.client-ip=209.85.167.42 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="bPwXlRJ3" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-540215984f0so3311558e87.1 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=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=8Z+rBahjAbnRzsWwhl3RN6A6WwHfHM88b39CtT7CZn0=; b=bPwXlRJ3XEd8H+3mQxuZEdrb8fZuERNmVROQzSXVVn6aV21HK3GXN5j8QXJ9mSWaqX 5TkT8eQssHeTjPB6T9pK2Ume2jVv9LyrUxR3K5elA3KJUBXVmSMGnZPRYtOd2aynzN5L XRuYQYTTDs7D1bTHDXA6Pk7DTtDxEs8fSjrqeCv4+I8FDLfmGydzuQbJzkskfO1mQ48T VaTfq9FSF8xPrwxcmoBbHWs5L/UeKSwnYxmrM9ezJoRXFnPxQq61ZskKqVZW0VrJOD7M H588oc39/VIxCHPOPVYPA5P0wO5D2w4Lbf7oSYe5CKQ5N/LytHJa4UbPuaCCBm7k5wUi WM/Q== 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=v5OkzEmkh2pjt6fSErmDqzFq+6vCsdJno353qcmePBKN/HXJkHt3obPr67//FESbMM tCRe6QsatEOmPFRRJALuCvkeUtoiJ329ymhNLhhAPBDEeQlfh8YxO8+0DhuBKpOoMv/c gKZPf8wmx82ShA313WeYt/xjDlWktU411dvqTFFPbDHz6ohdG+N8dRLz/kE8dNAqJyZI v9lpx1Pxco/NgOd0f7FsggeChgjeZtsywMjzQjWyxMKdLhWZZwTO/1fxKphP+OWKeABi MnK37hhPU0oJbtwZ10E7Bm+ZH8yl7gTiewYHm2Qyn/ebuAcvUaMWh1APqD1B4WGWAevC ml8Q== X-Forwarded-Encrypted: i=1; AJvYcCW53L9e3KyD5mEbYmzk0c8r0xKK0sip9iagvZC6+ZeOQm9XnLFX9V+dRMgHNeGvkxxifKU4Oj2nrJQRZEk8@vger.kernel.org X-Gm-Message-State: AOJu0YxD4e2X3V+YdLuoXrwPKLMxepYOY9BomC5oA7FXZm9u8xmy7b2z q4QNfU/sZJ6tN2lZ85UFfinRkEcpvO0W+F/n/8iJGvaolv0q1Bnkup8hlfwS8Zw= X-Gm-Gg: ASbGncuy6fID0h00IpUZfa1PxzvPY2yKezEVvOm4lL+hDGVFSBVlABODSJgGbk+7tBs KrNT7PXwBdH1Mu2Sgr5iL9SAHqbnbJEro0ppORwV7TYyDYokbXpa0tdKp50342EwaLltW/rWVki JvwsV1CxJVIvK/RgqVNYDffTnRY26sxg0rBzcUSiXf6wOkQu8fXJQQW40PJ4+HZD0ht9of9aJ0L O7p1uzmhZGK+uwU3WG22hrhXfd7dhQk6QzDz8FyiM6yqy5eejSqFWMc9JfiviZg 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() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.