From nobody Wed Dec 17 19:05:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFC2AC61D97 for ; Wed, 22 Nov 2023 16:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231358AbjKVQUw (ORCPT ); Wed, 22 Nov 2023 11:20:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231701AbjKVQUn (ORCPT ); Wed, 22 Nov 2023 11:20:43 -0500 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784EF1B8 for ; Wed, 22 Nov 2023 08:20:35 -0800 (PST) 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=6oQ05sxUVSUOtFBVscV1RsI7xjS53GqoZMmDxVRMp58=; b=kL81kjGgJG3ESkR+MXvVpiOJbM eXut4DmzTPdBstrbtpU+KIyTGUEAneMWE6MP9pTwRfNU6i+yHNrqIT0l6mFPb6iKhupmqN3FzaFd8 j7Ob12FgoYyiVz+G0MOY9+aMk5MxH9r1LR7Xfvx4K1JmIhfHivtxvsqp3/8GUssJB4Gc18rzbvn3d Dsp7XACwxeMucz4Zo2F3EbGwIQ8ByobEKuvHHl8wPTWJRpSWb2DvWerEuxVJ8yWdzIdLSO/FoSKrn H20FPZ0ypYyiO3YgXmJ2MFsy1lKwbR62n29BWnGf0p/4uP1Wybqez5ScTQs1LbvkyVDn+tI6rGoDd 56+9y2/w==; Received: from 189-69-166-209.dial-up.telesp.net.br ([189.69.166.209] helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r5pxn-0061lT-KF; Wed, 22 Nov 2023 17:20:32 +0100 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: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, Simon Ser , Rob Clark , Pekka Paalanen , daniel@ffwll.ch, Daniel Stone , =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Randy Dunlap , ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v9 1/4] drm: Refuse to async flip with atomic prop changes Date: Wed, 22 Nov 2023 13:19:38 -0300 Message-ID: <20231122161941.320564-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231122161941.320564-1-andrealmeid@igalia.com> References: <20231122161941.320564-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 exception is the framebuffer ID to flip to. Currently the only plane type supported is the primary one. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Simon Ser --- v9: no changes v8: add a check for plane type, we can only flip primary planes v7: drop the mode_id exception for prop changes --- drivers/gpu/drm/drm_atomic_uapi.c | 52 +++++++++++++++++++++++++++-- drivers/gpu/drm/drm_crtc_internal.h | 2 +- drivers/gpu/drm/drm_mode_object.c | 2 +- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic= _uapi.c index 98d3b10c08ae..ed46133a2dd7 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_ato= mic_state *state, return ret; } =20 +static int drm_atomic_check_prop_changes(int ret, uint64_t old_val, uint64= _t prop_value, + struct drm_property *prop) +{ + if (ret !=3D 0 || old_val !=3D 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; =20 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; } =20 + if (async_flip) { + ret =3D drm_atomic_connector_get_property(connector, connector_state, + prop, &old_val); + ret =3D drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret =3D drm_atomic_connector_set_property(connector, connector_state, file_priv, prop, prop_value); @@ -1044,6 +1066,13 @@ int drm_atomic_set_property(struct drm_atomic_state = *state, break; } =20 + if (async_flip) { + ret =3D drm_atomic_crtc_get_property(crtc, crtc_state, + prop, &old_val); + ret =3D drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret =3D drm_atomic_crtc_set_property(crtc, crtc_state, prop, prop_value); break; @@ -1051,6 +1080,7 @@ int drm_atomic_set_property(struct drm_atomic_state *= state, case DRM_MODE_OBJECT_PLANE: { struct drm_plane *plane =3D obj_to_plane(obj); struct drm_plane_state *plane_state; + struct drm_mode_config *config =3D &plane->dev->mode_config; =20 plane_state =3D drm_atomic_get_plane_state(state, plane); if (IS_ERR(plane_state)) { @@ -1058,6 +1088,21 @@ int drm_atomic_set_property(struct drm_atomic_state = *state, break; } =20 + if (async_flip && prop !=3D config->prop_fb_id) { + ret =3D drm_atomic_plane_get_property(plane, plane_state, + prop, &old_val); + ret =3D drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + + if (async_flip && plane_state->plane->type !=3D DRM_PLANE_TYPE_PRIMARY) { + drm_dbg_atomic(prop->dev, + "[OBJECT:%d] Only primary planes can be changed during async flip\n", + obj->id); + ret =3D -EINVAL; + break; + } + ret =3D drm_atomic_plane_set_property(plane, plane_state, file_priv, prop, prop_value); @@ -1337,6 +1382,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, struct drm_out_fence_state *fence_state; int ret =3D 0; unsigned int i, j, num_fences; + bool async_flip =3D false; =20 /* disallow for drivers not supporting atomic: */ if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) @@ -1450,8 +1496,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, goto out; } =20 - ret =3D drm_atomic_set_property(state, file_priv, - obj, prop, prop_value); + ret =3D 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 6b646e0783be..c05c9ee9c859 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -253,7 +253,7 @@ int drm_atomic_set_property(struct drm_atomic_state *st= ate, 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); =20 diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_o= bject.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 =3D drm_atomic_set_property(state, file_priv, obj, prop, prop_value); + ret =3D drm_atomic_set_property(state, file_priv, obj, prop, prop_value,= false); if (ret) goto out; ret =3D drm_atomic_commit(state); --=20 2.42.1 From nobody Wed Dec 17 19:05:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E707C61D97 for ; Wed, 22 Nov 2023 16:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231301AbjKVQUp (ORCPT ); Wed, 22 Nov 2023 11:20:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbjKVQUn (ORCPT ); Wed, 22 Nov 2023 11:20:43 -0500 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE1659F for ; Wed, 22 Nov 2023 08:20:39 -0800 (PST) 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=F4k94dWeA9E9cnOAfUovq7CO/D9PnaeF/xo2VAuyrQ8=; b=nJBdGwjvU0dNBeukokNJqEIt7q NFXNy1p2tlY4GBZFgTcFSWqROlfrIIN6rZ7Fv/i6Rk5NFGzjEKS94pUIrnDizTttanSJQrW+0ZY2M 0rE4g0GrVr+OO/SUHU+45K8EpMIbFv7CIrB5fN4FSl+ULA0QMv0RFyEeA5MSamvEKMYQmrrKzfJGt wJ2tSDKWa+Zz+uoXQixgEXr/wiRRdg+le9/bvVarqqJIkIe5atEnnnKwoIVhS7FF+hhsymFhYC1Zb en9mBJ6qTNWfs7I0nbkWCwX5u6V0k2A6omOOsr10aFvS56D0zR4/xJHGfY0f9Fsft9RDGzAmgmODI E6wV9pMQ==; Received: from 189-69-166-209.dial-up.telesp.net.br ([189.69.166.209] helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r5pxs-0061lT-RP; Wed, 22 Nov 2023 17:20:37 +0100 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: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, Simon Ser , Rob Clark , Pekka Paalanen , daniel@ffwll.ch, Daniel Stone , =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Randy Dunlap , ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v9 2/4] drm: allow DRM_MODE_PAGE_FLIP_ASYNC for atomic commits Date: Wed, 22 Nov 2023 13:19:39 -0300 Message-ID: <20231122161941.320564-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231122161941.320564-1-andrealmeid@igalia.com> References: <20231122161941.320564-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon Ser If the driver supports it, allow user-space to supply the DRM_MODE_PAGE_FLIP_ASYNC flag to request an async page-flip. Set drm_crtc_state.async_flip accordingly. Document that drivers will reject atomic commits if an async flip isn't possible. This allows user-space to fall back to something else. For instance, Xorg falls back to a blit. Another option is to wait as close to the next vblank as possible before performing the page-flip to reduce latency. Signed-off-by: Simon Ser Reviewed-by: Alex Deucher Co-developed-by: Andr=C3=A9 Almeida Signed-off-by: Andr=C3=A9 Almeida --- v9: dropped atomic_async_page_flip_not_supported --- drivers/gpu/drm/drm_atomic_uapi.c | 25 ++++++++++++++++++++++--- include/uapi/drm/drm_mode.h | 9 +++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic= _uapi.c index ed46133a2dd7..de4265423ddc 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1368,6 +1368,18 @@ static void complete_signaling(struct drm_device *de= v, kfree(fence_state); } =20 +static void +set_async_flip(struct drm_atomic_state *state) +{ + struct drm_crtc *crtc; + struct drm_crtc_state *crtc_state; + int i; + + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { + crtc_state->async_flip =3D true; + } +} + int drm_mode_atomic_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -1409,9 +1421,13 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } =20 if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) { - drm_dbg_atomic(dev, - "commit failed: invalid flag DRM_MODE_PAGE_FLIP_ASYNC\n"); - return -EINVAL; + if (!dev->mode_config.async_page_flip) { + drm_dbg_atomic(dev, + "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported\n"); + return -EINVAL; + } + + async_flip =3D true; } =20 /* can't test and expect an event at the same time. */ @@ -1514,6 +1530,9 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, if (ret) goto out; =20 + if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) + set_async_flip(state); + if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) { ret =3D drm_atomic_check_only(state); } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) { diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 09e7a471ee30..95630f170110 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -957,6 +957,15 @@ struct hdr_output_metadata { * Request that the page-flip is performed as soon as possible, ie. with no * delay due to waiting for vblank. This may cause tearing to be visible on * the screen. + * + * When used with atomic uAPI, the driver will return an error if the hard= ware + * doesn't support performing an asynchronous page-flip for this update. + * User-space should handle this, e.g. by falling back to a regular page-f= lip. + * + * Note, some hardware might need to perform one last synchronous page-flip + * before being able to switch to asynchronous page-flips. As an exception, + * the driver will return success even though that first page-flip is not + * asynchronous. */ #define DRM_MODE_PAGE_FLIP_ASYNC 0x02 #define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4 --=20 2.42.1 From nobody Wed Dec 17 19:05:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C87AC61D9D for ; Wed, 22 Nov 2023 16:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232335AbjKVQU6 (ORCPT ); Wed, 22 Nov 2023 11:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231690AbjKVQUt (ORCPT ); Wed, 22 Nov 2023 11:20:49 -0500 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB262CB for ; Wed, 22 Nov 2023 08:20:44 -0800 (PST) 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=EoeKWmvDXudVDgBjqkb0Elm6Q/W5MOXGYpVoR+3DovU=; b=kBl4FtPD7uxqELbnBF1EFvRV+a h0XRGQqlyMOEtK3X2w9uqu8OrBIb3VOBJVfkG1HK44qZqg6atuvWUtKcNYRmphjdwmcsMGCn2rwcQ OnhSTQ37w9l0hfbx/xPtVeOa3am3Hp9d3JskkauIkxltgk8fpUYk38plfJ7zbzVEGQw0lcizZj0Uu kgGWGUMTUrgNQWYlE/q+ljulSs0gW54d35L8/owlE4+6z7i/I6gCVTljfQAM8yKAljGXE4HgASUW1 GpRh3uDWGZnXvWj/oKfwBn5Moa+z4PHxhVY4EtLTS1P7yjiT1AeBenhjt3lYySY8UNrd+oU6Eq3BD ntc26zpg==; Received: from 189-69-166-209.dial-up.telesp.net.br ([189.69.166.209] helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r5pxy-0061lT-2B; Wed, 22 Nov 2023 17:20:42 +0100 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: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, Simon Ser , Rob Clark , Pekka Paalanen , daniel@ffwll.ch, Daniel Stone , =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Randy Dunlap , ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v9 3/4] drm: introduce DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP Date: Wed, 22 Nov 2023 13:19:40 -0300 Message-ID: <20231122161941.320564-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231122161941.320564-1-andrealmeid@igalia.com> References: <20231122161941.320564-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon Ser This new kernel capability indicates whether async page-flips are supported via the atomic uAPI. DRM clients can use it to check for support before feeding DRM_MODE_PAGE_FLIP_ASYNC to the kernel. Make it clear that DRM_CAP_ASYNC_PAGE_FLIP is for legacy uAPI only. Signed-off-by: Simon Ser Reviewed-by: Andr=C3=A9 Almeida Reviewed-by: Alex Deucher Signed-off-by: Andr=C3=A9 Almeida --- v9: no changes --- --- drivers/gpu/drm/drm_ioctl.c | 4 ++++ include/uapi/drm/drm.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 44fda68c28ae..f461ed862480 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -301,6 +301,10 @@ static int drm_getcap(struct drm_device *dev, void *da= ta, struct drm_file *file_ case DRM_CAP_CRTC_IN_VBLANK_EVENT: req->value =3D 1; break; + case DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP: + req->value =3D drm_core_check_feature(dev, DRIVER_ATOMIC) && + dev->mode_config.async_page_flip; + break; default: return -EINVAL; } diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 8662b5aeea0c..796de831f4a0 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -713,7 +713,8 @@ struct drm_gem_open { /** * DRM_CAP_ASYNC_PAGE_FLIP * - * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC. + * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for legacy + * page-flips. */ #define DRM_CAP_ASYNC_PAGE_FLIP 0x7 /** @@ -773,6 +774,13 @@ struct drm_gem_open { * :ref:`drm_sync_objects`. */ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14 +/** + * DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP + * + * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for atomic + * commits. + */ +#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15 =20 /* DRM_IOCTL_GET_CAP ioctl argument type */ struct drm_get_cap { --=20 2.42.1 From nobody Wed Dec 17 19:05:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26259C61D99 for ; Wed, 22 Nov 2023 16:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235174AbjKVQVF (ORCPT ); Wed, 22 Nov 2023 11:21:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbjKVQU6 (ORCPT ); Wed, 22 Nov 2023 11:20:58 -0500 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC481B8 for ; Wed, 22 Nov 2023 08:20:50 -0800 (PST) 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=LgiP6k4b25j6JdOl1t3vzbWpalkz+TaPG+lRilXJhV0=; b=QUMPjg4YQvQo+GWFK/4494HEuy rDbyp+KIU3owVzNlGUlll01Ecxk0G5hSpLUk1kYdO5RVPKm9qYBlnXSrnFJGx695NoaHrAG842lFe 5UyEqnz66VZR4ydlO49u3LFEtJcAbsLs7DS26s7fFoQavfPZkt8lEFzzjpiwYM0MnCU2QmzdprWZA ImjWX+UpkODk0aIWKOONuZ7SrGKK3p7CT2cNfkl3k4JcUg0BCBSheK67BExi7+rLI0/nZBYbq2pd7 CobE7liFqYjf7kfeVOPgGSJYWs25ygFn0Li48MqB3lL25Hb8SwWMT5g+nUt16DzaqafSSnKTxh09R kybx9Bcg==; Received: from 189-69-166-209.dial-up.telesp.net.br ([189.69.166.209] helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r5py3-0061lT-FC; Wed, 22 Nov 2023 17:20:47 +0100 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: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, Simon Ser , Rob Clark , Pekka Paalanen , daniel@ffwll.ch, Daniel Stone , =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Randy Dunlap , ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org, Pekka Paalanen , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v9 4/4] drm/doc: Define KMS atomic state set Date: Wed, 22 Nov 2023 13:19:41 -0300 Message-ID: <20231122161941.320564-5-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231122161941.320564-1-andrealmeid@igalia.com> References: <20231122161941.320564-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pekka Paalanen Specify how the atomic state is maintained between userspace and kernel, plus the special case for async flips. Signed-off-by: Pekka Paalanen Signed-off-by: Andr=C3=A9 Almeida --- v9: - no changes v8: - no changes v7: - add a note that drivers can make exceptions for ad-hoc prop changes - add a note about flipping the same FB_ID as a no-op --- --- Documentation/gpu/drm-uapi.rst | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 370d820be248..d0693f902a5c 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -570,3 +570,50 @@ dma-buf interoperability =20 Please see Documentation/userspace-api/dma-buf-alloc-exchange.rst for information on how dma-buf is integrated and exposed within DRM. + +KMS atomic state +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +An atomic commit can change multiple KMS properties in an atomic fashion, +without ever applying intermediate or partial state changes. Either the w= hole +commit succeeds or fails, and it will never be applied partially. This is = the +fundamental improvement of the atomic API over the older non-atomic API wh= ich is +referred to as the "legacy API". Applying intermediate state could unexpe= ctedly +fail, cause visible glitches, or delay reaching the final state. + +An atomic commit can be flagged with DRM_MODE_ATOMIC_TEST_ONLY, which mean= s the +complete state change is validated but not applied. Userspace should use = this +flag to validate any state change before asking to apply it. If validation= fails +for any reason, userspace should attempt to fall back to another, perhaps +simpler, final state. This allows userspace to probe for various configur= ations +without causing visible glitches on screen and without the need to undo a +probing change. + +The changes recorded in an atomic commit apply on top the current KMS stat= e in +the kernel. Hence, the complete new KMS state is the complete old KMS stat= e with +the committed property settings done on top. The kernel will try to avoid +no-operation changes, so it is safe for userspace to send redundant proper= ty +settings. However, not every situation allows for no-op changes, due to t= he +need to acquire locks for some attributes. Userspace needs to be aware tha= t some +redundant information might result in oversynchronization issues. No-oper= ation +changes do not count towards actually needed changes, e.g. setting MODE_I= D to a +different blob with identical contents as the current KMS state shall not = be a +modeset on its own. As a special exception for VRR needs, explicitly setti= ng +FB_ID to its current value is not a no-op. + +A "modeset" is a change in KMS state that might enable, disable, or tempor= arily +disrupt the emitted video signal, possibly causing visible glitches on scr= een. A +modeset may also take considerably more time to complete than other kinds = of +changes, and the video sink might also need time to adapt to the new signal +properties. Therefore a modeset must be explicitly allowed with the flag +DRM_MODE_ATOMIC_ALLOW_MODESET. This in combination with +DRM_MODE_ATOMIC_TEST_ONLY allows userspace to determine if a state change = is +likely to cause visible disruption on screen and avoid such changes when e= nd +users do not expect them. + +An atomic commit with the flag DRM_MODE_PAGE_FLIP_ASYNC is allowed to +effectively change only the FB_ID property on any planes. No-operation cha= nges +are ignored as always. Changing any other property will cause the commit t= o be +rejected. Each driver may relax this restriction if they have guarantees t= hat +such property change doesn't cause modesets. Userspace can use TEST_ONLY c= ommits +to query the driver about this. --=20 2.42.1