Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7351540E8E8 for ; Tue, 9 Jun 2026 12:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781007206; cv=none; b=O9EK8xxD23zUuuU9OpWb5WGojVEMSO8NN5LqzK6OKu7Euo39zx2QbeUGaeixYD1lxmFwO1g2XiJn8ClUkQM2j/Eksth9u55uC0ZIAz4tBUIdg/Jp5e74ttauXgXJkA+8FoHPYyp8UmiepzMQf5nrrMSYI+MGcxiEtmx09Hyjha4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781007206; c=relaxed/simple; bh=s7zEUq0x4x6z/SaH72Z6gN2tBs9ICthGMI6RbQB0SD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ESVUO4IQEqfVXtKAHCmFdSiy7gsCEl4AdTXsF+TGbKoWIesuLCCo4yLfJm4Qno/KGonvPb6qI9H9ktSH4eH5rxDmQECLIajwyu/lPrB0nSjX+xWnu98cwgvi323aS6Gq18hsCpEwnMLDpz0RVkwx0xXLLrB2HyOXu1/Ac0UYOKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=LY+kN0aD; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="LY+kN0aD" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RUncSXLy+7iRfo2X0zRCa/to3zvHt7MenW8xfC3Dcgo=; b=LY+kN0aD8ao6obwIMg/eqyOsK/ zE9HWrgKfYpHfjb1Df6IeHm9en0wLHuTMY0r9ReS8WXJ/NzIw7S6RPluCKEoV2Hznqgs8PyWbZ69n I/X15W6QuStdG2ZfMCdC1sb8mBfeIsMJ/PfAYeMEfnzalN56nZzZTMbLjhO333xIRxJg/ZB/Vwqxx uNsgqugLYPdf3W3h9b/QUh7U52E4aRcKg5T8sI9ReX0dSA00XOobMjmV5AAD5r2YVTP6vN0hivXRK Xd+eevPaas7HHgixJzCZnrSjTTx9/Mr+823TeyMV8P2Q39JvQ/10ukXHWyqqTsfITqx+rTcS03U9e +fADhf0g==; Received: from [79.117.146.159] (helo=killbill.home) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wWvJy-00EvWP-Tz; Tue, 09 Jun 2026 14:12:43 +0200 From: Melissa Wen To: airlied@gmail.com, alexander.deucher@amd.com, alex.hung@amd.com, aurabindo.pillai@amd.com, christian.koenig@amd.com, contact@emersion.fr, daniels@collabora.com, harry.wentland@amd.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, simona@ffwll.ch, siqueira@igalia.com, sunpeng.li@amd.com, tzimmermann@suse.de Cc: Uma Shankar , Chaitanya Kumar Borah , Xaver Hugl , Pekka Paalanen , Louis Chauvet , Matthew Schwartz , amd-gfx@lists.freedesktop.org, kernel-dev@igalia.com, Rob Clark , Dmitry Baryshkov , Sean Paul , Marijn Suijten , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v3 1/7] drm/atomic: only add states of active or transient active colorops Date: Tue, 9 Jun 2026 13:51:35 +0200 Message-ID: <20260609121230.1358786-2-mwen@igalia.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609121230.1358786-1-mwen@igalia.com> References: <20260609121230.1358786-1-mwen@igalia.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Only consider affected colorop states those that are part of an active color pipeline or a pipeline that is about to be activated or deactivated in the same atomic commit, i.e., colorop is in the chain of old/new plane color pipeline property. To cover color_pipeline deactivation, remove the condition for plane_state->color_pipeline. Signed-off-by: Melissa Wen --- v2: define a macro to walk in the color pipeline (Alex H.) --- drivers/gpu/drm/drm_atomic.c | 65 +++++++++++++++++++++++++++++++----- include/drm/drm_colorop.h | 3 ++ 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3af1b9cc9a06..464562861408 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -892,6 +892,57 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, return 0; } +/* + * This function walks old and new plane state color pipelines and adds all + * colorops in use by @plane to the atomic configuration @state. This is useful + * when an atomic commit needs to check all currently enabled or about to be + * enabled colorop on @plane, e.g. when changing the mode. This also avoids + * including colorop states that are not part of the atomic state. + * + * Returns: + * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK + * then the w/w mutex code has detected a deadlock and the entire atomic + * sequence must be restarted. All other errors are fatal. + */ +static int +drm_atomic_add_pipeline_colorops(struct drm_atomic_commit *state, + struct drm_plane *plane) +{ + struct drm_colorop *colorop; + struct drm_colorop_state *colorop_state; + struct drm_plane_state *new_plane_state, *old_plane_state; + + new_plane_state = drm_atomic_get_new_plane_state(state, plane); + old_plane_state = drm_atomic_get_old_plane_state(state, plane); + + if (WARN_ON(!new_plane_state || !old_plane_state)) + return -EINVAL; + + drm_dbg_atomic(plane->dev, + "Adding old+new pipeline colorops for [PLANE:%d:%s]\n", + plane->base.id, plane->name); + + drm_for_each_colorop_in_pipeline(colorop, + new_plane_state->color_pipeline) { + colorop_state = drm_atomic_get_colorop_state(state, colorop); + if (IS_ERR(colorop_state)) + return PTR_ERR(colorop_state); + } + + /* Same color pipeline as new; no point walking old. */ + if (new_plane_state->color_pipeline == old_plane_state->color_pipeline) + return 0; + + drm_for_each_colorop_in_pipeline(colorop, + old_plane_state->color_pipeline) { + colorop_state = drm_atomic_get_colorop_state(state, colorop); + if (IS_ERR(colorop_state)) + return PTR_ERR(colorop_state); + } + + return 0; +} + static void drm_atomic_colorop_print_state(struct drm_printer *p, const struct drm_colorop_state *state) { @@ -1671,11 +1722,9 @@ drm_atomic_add_affected_planes(struct drm_atomic_commit *state, if (IS_ERR(plane_state)) return PTR_ERR(plane_state); - if (plane_state->color_pipeline) { - ret = drm_atomic_add_affected_colorops(state, plane); - if (ret) - return ret; - } + ret = drm_atomic_add_pipeline_colorops(state, plane); + if (ret) + return ret; } return 0; } @@ -1687,10 +1736,8 @@ EXPORT_SYMBOL(drm_atomic_add_affected_planes); * @plane: DRM plane * * This function walks the current configuration and adds all colorops - * currently used by @plane to the atomic configuration @state. This is useful - * when an atomic commit also needs to check all currently enabled colorop on - * @plane, e.g. when changing the mode. It's also useful when re-enabling a plane - * to avoid special code to force-enable all colorops. + * currently used by @plane to the atomic configuration @state. It's useful + * when re-enabling a plane to avoid special code to force-enable all colorops. * * Since acquiring a colorop state will always also acquire the w/w mutex of the * current plane for that colorop (if there is any) adding all the colorop states for diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index b4b9e4f558ab..006278e21d49 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -459,6 +459,9 @@ static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop) #define drm_for_each_colorop(colorop, dev) \ list_for_each_entry(colorop, &(dev)->mode_config.colorop_list, head) +#define drm_for_each_colorop_in_pipeline(colorop, pipeline) \ + for ((colorop) = (pipeline); (colorop); (colorop) = (colorop)->next) + /** * drm_get_colorop_type_name - return a string for colorop type * @type: colorop type to compute name of -- 2.53.0