From mboxrd@z Thu Jan 1 00:00:00 1970 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 D908DCD6E75 for ; Thu, 4 Jun 2026 18:05:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9ECF011292D; Thu, 4 Jun 2026 18:05:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="MG8ZL//9"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id E828F112925; Thu, 4 Jun 2026 18:05:52 +0000 (UTC) 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=xDanblzNrKwLMIWCMdcO9/e2GrHOcHnN+e83qP8r5xg=; b=MG8ZL//9yGgx0wlwz0S4BdlORt i3awrnyIRGvnWqC0MRdC1x4N5GjQawwDy41RgxUEFsEOOaG8+yASE/0FO0kkleUE3AFKvRbxI1siP TBjJ7HGIhUQksYI1+3eTW+215xaeTqsAAjlGeWetYerw1o60vxZ/IQrxqVrWulsgdKYfOcB4dFYmN OJ9oXkD+TG2FzNq2E0lXbeMpSFl+bz9ED4PDOSRSMQh6vvkk+1XpV7apDcLIEBh3M6TLI2+R5dbTX uGyhOcUCRwmRrAmy0V/v0RLyL7RD4WT4kXhGwJvZb82XQ55nWmGamfzkl91QgROhiKMXJ0TI/kuyH n5+Zptgg==; 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 1wVCRJ-00Ckqs-Dd; Thu, 04 Jun 2026 20:05:09 +0200 From: Melissa Wen To: airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, simona@ffwll.ch, tzimmermann@suse.de Cc: Alex Hung , Simon Ser , Uma Shankar , Chaitanya Kumar Borah , Xaver Hugl , Pekka Paalanen , Louis Chauvet , Matthew Schwartz , Sebastian Wick , John Harrison , Rodrigo Siqueira , 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 v2 3/3] drm/atomic: reject colorop update from inactive color pipeline Date: Thu, 4 Jun 2026 19:59:07 +0200 Message-ID: <20260604180457.1110110-4-mwen@igalia.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260604180457.1110110-1-mwen@igalia.com> References: <20260604180457.1110110-1-mwen@igalia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" Only allow updates on colorops that are part of an active pipeline, i.e. check if a colorop belongs to the color pipeline of a plane in its current, new or old state. If not, reject the state change of this inactive colorop. Performing this check later in drm_atomic_check_only() to remove the ordering dependency that would exist if done at the time of colorop property setting. Userspace is allowed to change colorops of an active color pipeline, or when activating or deactivating its pipeline in the same commit. However, changes in inactive color pipeline is not allowed. Suggested-by: Chaitanya Kumar Borah Signed-off-by: Melissa Wen --- drivers/gpu/drm/drm_atomic.c | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 464562861408..960b52624deb 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -943,6 +943,55 @@ drm_atomic_add_pipeline_colorops(struct drm_atomic_commit *state, return 0; } +/** + * drm_atomic_colorop_check - check new colorop state + * @new_colorop_state: new colorop state to check + * + * Ensure that the colorop in @new_colorop_state belongs to an active color + * pipeline, i.e. it's in the chain of colorops set to the color_pipeline + * property of current, old or new plane state. + * + * Returns: 0 on success, -EINVAL otherwise. + */ +static int drm_atomic_colorop_check(const struct drm_colorop_state *new_colorop_state) +{ + struct drm_atomic_commit *state = new_colorop_state->state; + struct drm_plane *plane = new_colorop_state->colorop->plane; + struct drm_plane_state *new_plane_state, *old_plane_state; + struct drm_colorop *colorop; + + new_plane_state = drm_atomic_get_new_plane_state(state, plane); + old_plane_state = drm_atomic_get_old_plane_state(state, plane); + + /* No changes in the plane state. Check current-committed plane state */ + if (!new_plane_state) { + for (colorop = plane->state->color_pipeline; colorop; colorop = colorop->next) + if (colorop == new_colorop_state->colorop) + return 0; + return -EINVAL; + } + + if (WARN_ON(!old_plane_state)) + return -EINVAL; + + /* Check if the colorop is active in the new plane state */ + for (colorop = new_plane_state->color_pipeline; colorop; colorop = colorop->next) + if (colorop == new_colorop_state->colorop) + return 0; + + /* Same color pipeline as new; no point walking old. Colorop isn't active */ + if (new_plane_state->color_pipeline == old_plane_state->color_pipeline) + return -EINVAL; + + /* Check if the colorop was active in the old plane state */ + for (colorop = old_plane_state->color_pipeline; colorop; colorop = colorop->next) + if (colorop == new_colorop_state->colorop) + return 0; + + /* Colorop is not part of an active color pipeline. */ + return -EINVAL; +} + static void drm_atomic_colorop_print_state(struct drm_printer *p, const struct drm_colorop_state *state) { @@ -1792,6 +1841,8 @@ int drm_atomic_check_only(struct drm_atomic_commit *state) struct drm_plane *plane; struct drm_plane_state *old_plane_state; struct drm_plane_state *new_plane_state; + struct drm_colorop *colorop; + struct drm_colorop_state *new_colorop_state; struct drm_crtc *crtc; struct drm_crtc_state *old_crtc_state; struct drm_crtc_state *new_crtc_state; @@ -1808,6 +1859,15 @@ int drm_atomic_check_only(struct drm_atomic_commit *state) requested_crtc |= drm_crtc_mask(crtc); } + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + ret = drm_atomic_colorop_check(new_colorop_state); + if (ret) { + drm_dbg_atomic(dev, "[COLOROP:%d:%d] isn't in an active color pipeline.\n", + colorop->base.id, colorop->type); + return ret; + } + } + for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { ret = drm_atomic_plane_check(old_plane_state, new_plane_state); if (ret) { -- 2.53.0