Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3034558rdg; Tue, 17 Oct 2023 02:31:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAA+F42AG0Ja+7+DA2eEu713xbao+Yp4yq/qXeZp815plNshTHK8vuXiKZ7g2Sryq7MEMZ X-Received: by 2002:a05:6a00:2d8d:b0:6be:11ac:98a5 with SMTP id fb13-20020a056a002d8d00b006be11ac98a5mr1415443pfb.27.1697535085533; Tue, 17 Oct 2023 02:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697535085; cv=none; d=google.com; s=arc-20160816; b=Y+idrvX3JzBmWE0GVJp/fVReZwrSEIlyuEyVz2C+EADSKm4c0Jiu0kTXUXpUpfSOGY IhUAqCF1/P5CzIbVLBod+TFcvgreWhQwvBur8cuWbJcG1d7ooZt9xq0kL8sv5ZYPpWaM LWiQGt4SDeMKOUX/Kz+w63ND6hyYRlluQ/g8IqZmVAFs6Wr1OSDkxuH45Omq9RW1ICJJ 3d16AI2dtRCCdGnteKQEshiYn9NQSn0ZdZZjOhDfzxAg7jHiOx1IUHaPCXNcFEiB4Cjp LY8POOXvQ+I2Ws4/a1zoYy2zSvJtCpXk4Nsd1fC7Npu4BYg37fCos3zGpbJf8is5ZpMZ 0z3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vm+ljfEhFhjrjIw4zm0LotRIHN51OK9AcAjrUqL/uug=; fh=SJQ48KwEv1Wk78SyBTKjV1EcFj2vZ5p6XYIidAE2t8E=; b=VfLqM7fYzZVxiMKDqJY3L98bEnNmolDV999gnPC4vH8x9/ClCpZ2zaYeNBr33l6T// XV5yZbTbB+33vYva2WXhVDKETIGymFAsMXrbqHYXnSES7Tk9QK87IHlkSOC3jdy0HCWI BQ7ZNs+3LlmqSQxpbGQzeRhO4kYJAHBFdaJ4Oq58iPOwWu8fLC+deaa5E02XZ0bOKUel 4mWqhgw2TmbuaQO68Q1Ezi+WvTyr/u+INg97sMoKyNgQQ+oa4ifw+nkpqg2eeIc16y1m qzsp3OJVxHGTdj8YjRCpTWSK4ul9kOY59avwilYEcdNfhyWjgh+vvMcJu0ZR0TLUWkpF Ahqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=LDEAw1TB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bw39-20020a056a0204a700b00584b9d0ff80si1571386pgb.127.2023.10.17.02.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=LDEAw1TB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2944C80A97D6; Tue, 17 Oct 2023 02:31:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234806AbjJQJaM (ORCPT + 99 others); Tue, 17 Oct 2023 05:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234973AbjJQJ3g (ORCPT ); Tue, 17 Oct 2023 05:29:36 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD83719A2 for ; Tue, 17 Oct 2023 02:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: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=vm+ljfEhFhjrjIw4zm0LotRIHN51OK9AcAjrUqL/uug=; b=LDEAw1TBBCX+xvLXxECpeYVXvO SrGFT5XvOtDhJRdHco1B60fsDabwWh9krImXucmkHRzpg2nUV/U00IReax3zGWwr9qK3FlnfuwD5q Lr8L0KKDbZT5Hx8JcjIkR7PUnhsG4BbbJAi2rlqWRP+fK5kWfaz+plJmWMQFD1m4a9NkIR5ggSG1A ZQTCbMxDY4P3QGpaD/MlnC0l6a+whSpsqCQTeosow20m6Jrps7Fth+w4AAGjHMFOyHJ7PezaUdhXM pQpoB3YgFU6tCQImZceRRDDzjFnRd4e/3NbBz5CL1AU0GVvbg6LvrXXS5wneGJwRvVMAN9fdwWSQN qgQ0Qo4A==; Received: from 167.red-81-39-185.dynamicip.rima-tde.net ([81.39.185.167] helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qsgNd-001ODF-TD; Tue, 17 Oct 2023 11:28:49 +0200 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: pierre-eric.pelloux-prayer@amd.com, =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , =?UTF-8?q?Michel=20D=C3=A4nzer?= , "Randy Dunlap" , "Pekka Paalanen" , hwentlan@amd.com, kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, joshua@froggi.es, Simon Ser , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v7 4/6] drm: Refuse to async flip with atomic prop changes Date: Tue, 17 Oct 2023 11:28:35 +0200 Message-ID: <20231017092837.32428-5-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231017092837.32428-1-andrealmeid@igalia.com> References: <20231017092837.32428-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 02:31:22 -0700 (PDT) Given that prop changes may lead to modesetting, which would defeat the fast path of the async flip, refuse any atomic prop change for async flips in atomic API. The only exceptions are the framebuffer ID to flip to and the mode ID, that could be referring to an identical mode. Signed-off-by: André Almeida --- v7: drop the mode_id exception for prop changes --- drivers/gpu/drm/drm_atomic_uapi.c | 47 +++++++++++++++++++++++++++-- drivers/gpu/drm/drm_crtc_internal.h | 2 +- drivers/gpu/drm/drm_mode_object.c | 2 +- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index a15121e75a0a..b358de1bf4e7 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1006,13 +1006,28 @@ int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state, return ret; } +static int drm_atomic_check_prop_changes(int ret, uint64_t old_val, uint64_t prop_value, + struct drm_property *prop) +{ + if (ret != 0 || old_val != prop_value) { + drm_dbg_atomic(prop->dev, + "[PROP:%d:%s] No prop can be changed during async flip\n", + prop->base.id, prop->name); + return -EINVAL; + } + + return 0; +} + int drm_atomic_set_property(struct drm_atomic_state *state, struct drm_file *file_priv, struct drm_mode_object *obj, struct drm_property *prop, - uint64_t prop_value) + uint64_t prop_value, + bool async_flip) { struct drm_mode_object *ref; + uint64_t old_val; int ret; if (!drm_property_change_valid_get(prop, prop_value, &ref)) @@ -1029,6 +1044,13 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } + if (async_flip) { + ret = drm_atomic_connector_get_property(connector, connector_state, + prop, &old_val); + ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret = drm_atomic_connector_set_property(connector, connector_state, file_priv, prop, prop_value); @@ -1037,6 +1059,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state, case DRM_MODE_OBJECT_CRTC: { struct drm_crtc *crtc = obj_to_crtc(obj); struct drm_crtc_state *crtc_state; + struct drm_mode_config *config = &crtc->dev->mode_config; crtc_state = drm_atomic_get_crtc_state(state, crtc); if (IS_ERR(crtc_state)) { @@ -1044,6 +1067,13 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } + if (async_flip) { + ret = drm_atomic_crtc_get_property(crtc, crtc_state, + prop, &old_val); + ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret = drm_atomic_crtc_set_property(crtc, crtc_state, prop, prop_value); break; @@ -1051,6 +1081,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state, case DRM_MODE_OBJECT_PLANE: { struct drm_plane *plane = obj_to_plane(obj); struct drm_plane_state *plane_state; + struct drm_mode_config *config = &plane->dev->mode_config; plane_state = drm_atomic_get_plane_state(state, plane); if (IS_ERR(plane_state)) { @@ -1058,6 +1089,13 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } + if (async_flip && prop != config->prop_fb_id) { + ret = drm_atomic_plane_get_property(plane, plane_state, + prop, &old_val); + ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret = drm_atomic_plane_set_property(plane, plane_state, file_priv, prop, prop_value); @@ -1349,6 +1387,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, struct drm_out_fence_state *fence_state; int ret = 0; unsigned int i, j, num_fences; + bool async_flip = false; /* disallow for drivers not supporting atomic: */ if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) @@ -1385,6 +1424,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported with atomic\n"); return -EINVAL; } + + async_flip = true; } /* can't test and expect an event at the same time. */ @@ -1469,8 +1510,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, goto out; } - ret = drm_atomic_set_property(state, file_priv, - obj, prop, prop_value); + ret = drm_atomic_set_property(state, file_priv, obj, + prop, prop_value, async_flip); if (ret) { drm_mode_object_put(obj); goto out; diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 8556c3b3ff88..a4c2ea33b1ef 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -251,7 +251,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state, struct drm_file *file_priv, struct drm_mode_object *obj, struct drm_property *prop, - uint64_t prop_value); + uint64_t prop_value, bool async_flip); int drm_atomic_get_property(struct drm_mode_object *obj, struct drm_property *property, uint64_t *val); diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index ac0d2ce3f870..0e8355063eee 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -538,7 +538,7 @@ static int set_property_atomic(struct drm_mode_object *obj, obj_to_connector(obj), prop_value); } else { - ret = drm_atomic_set_property(state, file_priv, obj, prop, prop_value); + ret = drm_atomic_set_property(state, file_priv, obj, prop, prop_value, false); if (ret) goto out; ret = drm_atomic_commit(state); -- 2.42.0