drm/atomic: introduce PAGE_FLIP_EVENT property
Subsystems (2)
PATCH 1/1 drm/atomic: introduce PAGE_FLIP_EVENT property
Currently user-space can only request page-flip events for all CRTCs included in an atomic commit. This is cumbersome with multi-CRTC commits: when moving a plane from a different CRTC, or when disabling a plane, user-space has no way to opt-out of the page-flip events.
Additionally, page-flip events are invalid for already-disable planes, so user-space needs to add special cases [1]. Libraries cannot add planes to the commit without risking causing unexpected page-flip events for the compositor [2]. Figuring out what CRTCs get implicitly included in a commit is non-trivial [3].
Introduce a new PAGE_FLIP_EVENT CRTC property so that user-space can select explicitly which CRTCs will get page-flip events. The property is very similar to IN_FENCE_FD/OUT_FENCE_PTR: it always reads as zero, and 1 can be written to request an event.
A user-space implementation is available at [4].
[1]: https://github.com/ValveSoftware/gamescope/blob/67fcb3aebae0ae1eb2d1cff60f29e6d9fe1d128f/src/Backends/DRMBackend.cpp#L2897
[2]: https://gitlab.freedesktop.org/emersion/libliftoff/-/merge_requests/85
[3]: https://lore.kernel.org/dri-devel/[email protected]/
[4]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5387
--- drivers/gpu/drm/drm_atomic_uapi.c | 17 +++++++++++++++-- drivers/gpu/drm/drm_crtc.c | 7 +++++++ drivers/gpu/drm/drm_mode_config.c | 6 ++++++ include/drm/drm_crtc.h | 6 ++++++ include/drm/drm_mode_config.h | 4 ++++ 5 files changed, 38 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +15 -2
@@ -466,6 +466,14 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,return -EFAULT ;set_out_fence_for_crtc (state->state, crtc, fence_ptr); + }else if (property == config->prop_page_flip_event) { +if (val !=1 ) { +drm_dbg_atomic (crtc->dev, +"[CRTC:%d:%s] PAGE_FLIP_EVENT can only be set to 1" , + crtc->base.id, crtc->name); +return -EINVAL ; + } + state->page_flip_event_requested = val; }else if (property == crtc->scaling_filter_property) { state->scaling_filter = val; }else if (property == crtc->sharpness_strength_property) {
@@ -507,6 +515,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc, *val = state->background_color; else if (property == config->prop_out_fence_ptr) *val = 0; + else if (property == config->prop_page_flip_event) + *val = 0; else if (property == crtc->scaling_filter_property) *val = state->scaling_filter; else if (property == crtc->sharpness_strength_property)
@@ -1385,6 +1395,7 @@ static int prepare_signaling(struct drm_device *dev,struct drm_connector *conn;struct drm_connector_state *conn_state;int i, c =0 , ret; +bool page_flip_event_requested;if (arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )return 0 ;
@@ -1392,9 +1403,11 @@ static int prepare_signaling(struct drm_device *dev,for_each_new_crtc_in_state (state, crtc, crtc_state, i) {s32 __user *fence_ptr; + page_flip_event_requested = arg->flags &DRM_MODE_PAGE_FLIP_EVENT || + crtc_state->page_flip_event_requested; fence_ptr =get_out_fence_for_crtc (crtc_state->state, crtc); -if (arg->flags &DRM_MODE_PAGE_FLIP_EVENT || fence_ptr) { +if (page_flip_event_requested || fence_ptr) {struct drm_pending_vblank_event *e; e =create_vblank_event (crtc, arg->user_data);
@@ -1404,7 +1417,7 @@ static int prepare_signaling(struct drm_device *dev, crtc_state->event = e; } -if (arg->flags &DRM_MODE_PAGE_FLIP_EVENT ) { +if (page_flip_event_requested) {struct drm_pending_vblank_event *e = crtc_state->event;if (!file_priv)
drivers/gpu/drm/drm_crtc.c +7 -0
@@ -248,6 +248,11 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)* The sharpness effect takes place post blending on the final composed output. * If the feature is disabled, the content remains same without any sharpening effect * and when this feature is applied, it enhances the clarity of the content. +* PAGE_FLIP_EVENT: +* Atomic property for requesting a page-flip event on this CRTC. +* +* The value of this property is an integer value which always reads as +* zero and can be written with 1 to request the event. */ __printf (6 ,0 )
@@ -322,6 +327,8 @@ static int __drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc * config->prop_out_fence_ptr, 0);drm_object_attach_property (&crtc->base, config->prop_vrr_enabled,0 ); +drm_object_attach_property (&crtc->base, + config->prop_page_flip_event,0 ); }return 0 ;
drivers/gpu/drm/drm_mode_config.c +6 -0
@@ -496,6 +496,12 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)return -ENOMEM ; dev->mode_config.prop_out_fence_ptr = prop; + prop =drm_property_create_range (dev,DRM_MODE_PROP_ATOMIC , +"PAGE_FLIP_EVENT" ,0 ,1 ); +if (!prop) +return -ENOMEM ; + dev->mode_config.prop_page_flip_event = prop; + prop =drm_property_create_object (dev,DRM_MODE_PROP_ATOMIC ,"CRTC_ID" ,DRM_MODE_OBJECT_CRTC );if (!prop)
include/drm/drm_crtc.h +6 -0
@@ -311,6 +311,12 @@ struct drm_crtc_state {*/ bool vrr_enabled; +/** +* @page_flip_event_requested: indicates whether a page-flip event has +* been requested on this CRTC. +*/ +bool page_flip_event_requested; +/** * @self_refresh_active: *
include/drm/drm_mode_config.h +4 -0
@@ -670,6 +670,10 @@ struct drm_mode_config {* value of type s32, and then cast that pointer to u64. */ struct drm_property *prop_out_fence_ptr; +/** +* @page_flip_event_property: property to request page-flip events. +*/ +struct drm_property *prop_page_flip_event;/** * @prop_crtc_id: Default atomic plane property to specify the * &drm_crtc.
Signature · 1 line
2.54.0
+1, this is very useful. A KWin implementation for this is at
https://invent.kde.org/plasma/kwin/-/merge_requests/9308
- Xaver
IGT test available here:
https://lists.freedesktop.org/archives/igt-dev/2026-May/111026.html
Quoted 6 lines · On Sat, 30 May 2026 17:14:44 +0000 Simon Ser <[email protected]> wrote:
Currently user-space can only request page-flip events for all CRTCs included in an atomic commit. This is cumbersome with multi-CRTC commits: when moving a plane from a different CRTC, or when disabling a plane, user-space has no way to opt-out of the page-flip events.
Additionally, page-flip events are invalid for already-disable planes, so
Hi Simon,
do you mean CRTCs? I find "already disabled" to be not really clear that you mean off->off transition.
Quoted 3 lines
user-space needs to add special cases [1]. Libraries cannot add planes to the commit without risking causing unexpected page-flip events for the compositor [2].
If a library adds a plane that is currently associated with another CRTC, would it not be a logic error in userspace if it didn't expect that CRTC to be involved? Mostly likely if it succeeds, the plane would disappear from its old CRTC unintended.
If a CRTC is unexpectedly involved, userspace risks EBUSY when it wants to update that CRTC for real.
Quoted 2 lines
Figuring out what CRTCs get implicitly included in a commit is non-trivial [3].
Yes, but is this actually helpful rather than making the failures more rare and harder to debug?
Quoted 89 lines
Introduce a new
PAGE_FLIP_EVENTCRTC property so that user-space can select explicitly which CRTCs will get page-flip events. The property is very similar to IN_FENCE_FD/OUT_FENCE_PTR: it always reads as zero, and 1 can be written to request an event.A user-space implementation is available at [4].
[1]: https://github.com/ValveSoftware/gamescope/blob/67fcb3aebae0ae1eb2d1cff60f29e6d9fe1d128f/src/Backends/DRMBackend.cpp#L2897
[2]: https://gitlab.freedesktop.org/emersion/libliftoff/-/merge_requests/85
[3]: https://lore.kernel.org/dri-devel/[email protected]/
[4]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5387Signed-off-by Simon Ser <[email protected]>Cc Daniel Stone <[email protected]>Cc Michel Dänzer <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Christian König <[email protected]>Cc Simona Vetter <[email protected]>--- drivers/gpu/drm/drm_atomic_uapi.c | 17 +++++++++++++++-- drivers/gpu/drm/drm_crtc.c | 7 +++++++ drivers/gpu/drm/drm_mode_config.c | 6 ++++++ include/drm/drm_crtc.h | 6 ++++++ include/drm/drm_mode_config.h | 4 ++++ 5 files changed, 38 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic_uapi.c +15
-2@@ -466,6 +466,14 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,return -EFAULT ;set_out_fence_for_crtc (state->state, crtc, fence_ptr); + }else if (property == config->prop_page_flip_event) { +if (val !=1 ) { +drm_dbg_atomic (crtc->dev, +"[CRTC:%d:%s] PAGE_FLIP_EVENT can only be set to 1" , + crtc->base.id, crtc->name); +return -EINVAL ; + } + state->page_flip_event_requested = val; }else if (property == crtc->scaling_filter_property) { state->scaling_filter = val; }else if (property == crtc->sharpness_strength_property) {@@ -507,6 +515,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc, *val = state->background_color; else if (property == config->prop_out_fence_ptr) *val = 0; + else if (property == config->prop_page_flip_event) + *val = 0; else if (property == crtc->scaling_filter_property) *val = state->scaling_filter; else if (property == crtc->sharpness_strength_property)@@ -1385,6 +1395,7 @@ static int prepare_signaling(struct drm_device *dev,struct drm_connector *conn;struct drm_connector_state *conn_state;int i, c =0 , ret; +bool page_flip_event_requested;if (arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )return 0 ;@@ -1392,9 +1403,11 @@ static int prepare_signaling(struct drm_device *dev,for_each_new_crtc_in_state (state, crtc, crtc_state, i) {s32 __user *fence_ptr; + page_flip_event_requested = arg->flags &DRM_MODE_PAGE_FLIP_EVENT || + crtc_state->page_flip_event_requested; fence_ptr =get_out_fence_for_crtc (crtc_state->state, crtc); -if (arg->flags &DRM_MODE_PAGE_FLIP_EVENT || fence_ptr) { +if (page_flip_event_requested || fence_ptr) {struct drm_pending_vblank_event *e; e =create_vblank_event (crtc, arg->user_data);@@ -1404,7 +1417,7 @@ static int prepare_signaling(struct drm_device *dev, crtc_state->event = e; } -if (arg->flags &DRM_MODE_PAGE_FLIP_EVENT ) { +if (page_flip_event_requested) {struct drm_pending_vblank_event *e = crtc_state->event;if (!file_priv)drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) · line 255
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +5
-0@@ -248,6 +248,11 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)* The sharpness effect takes place post blending on the final composed output. * If the feature is disabled, the content remains same without any sharpening effect * and when this feature is applied, it enhances the clarity of the content. +* PAGE_FLIP_EVENT: +* Atomic property for requesting a page-flip event on this CRTC. +* +* The value of this property is an integer value which always reads as +* zero and can be written with 1 to request the event.
It took me a while to realise; should probably explain here that if one uses this, then they would not use DRM_MODE_PAGE_FLIP_EVENT at the same time.
Does this allow asking for an event for a CRTC off->off transition?
Thanks,
pq
Quoted 61 lines
drivers/gpu/drm/drm_crtc.c +2
-0*/ __printf (6 ,0 )@@ -322,6 +327,8 @@ static int __drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc * config->prop_out_fence_ptr, 0);drm_object_attach_property (&crtc->base, config->prop_vrr_enabled,0 ); +drm_object_attach_property (&crtc->base, + config->prop_page_flip_event,0 ); }return 0 ;drivers/gpu/drm/drm_mode_config.c +6
-0@@ -496,6 +496,12 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)return -ENOMEM ; dev->mode_config.prop_out_fence_ptr = prop; + prop =drm_property_create_range (dev,DRM_MODE_PROP_ATOMIC , +"PAGE_FLIP_EVENT" ,0 ,1 ); +if (!prop) +return -ENOMEM ; + dev->mode_config.prop_page_flip_event = prop; + prop =drm_property_create_object (dev,DRM_MODE_PROP_ATOMIC ,"CRTC_ID" ,DRM_MODE_OBJECT_CRTC );if (!prop)include/drm/drm_crtc.h +6
-0@@ -311,6 +311,12 @@ struct drm_crtc_state {*/ bool vrr_enabled; +/** +* @page_flip_event_requested: indicates whether a page-flip event has +* been requested on this CRTC. +*/ +bool page_flip_event_requested; +/** * @self_refresh_active: * include/drm/drm_mode_config.h +4
-0@@ -670,6 +670,10 @@ struct drm_mode_config {* value of type s32, and then cast that pointer to u64. */ struct drm_property *prop_out_fence_ptr; +/** +* @page_flip_event_property: property to request page-flip events. +*/ +struct drm_property *prop_page_flip_event;/** * @prop_crtc_id: Default atomic plane property to specify the * &drm_crtc.
Quoted 8 lines · Pekka Paalanen
Quoted 5 lines · On Sat, 30 May 2026 17:14:44 +0000 Simon Ser <[email protected]> wrote:
Currently user-space can only request page-flip events for all CRTCs included in an atomic commit. This is cumbersome with multi-CRTC commits: when moving a plane from a different CRTC, or when disabling a plane, user-space has no way to opt-out of the page-flip events.
Quoted 6 lines
Quoted 1 line
Additionally, page-flip events are invalid for already-disable planes, so
Hi Simon,
do you mean CRTCs? I find "already disabled" to be not really clear that you mean
off->offtransition.
Oh, yeah, indeed!
Quoted 11 lines
Quoted 3 lines
user-space needs to add special cases [1]. Libraries cannot add planes to the commit without risking causing unexpected page-flip events for the compositor [2].
If a library adds a plane that is currently associated with another CRTC, would it not be a logic error in userspace if it didn't expect that CRTC to be involved? Mostly likely if it succeeds, the plane would disappear from its old CRTC unintended.
If a CRTC is unexpectedly involved, userspace risks EBUSY when it wants to update that CRTC for real.
The plane is involved anyways, and the library can figure that out. The library is fully managing the plane, and has ensured it's turned off before migrating it to a new CRTC. What's unexpected and unavoidable is the page-flip event on the old CRTC.
Quoted 5 lines
Quoted 2 lines
Figuring out what CRTCs get implicitly included in a commit is non-trivial [3].
Yes, but is this actually helpful rather than making the failures more rare and harder to debug?
I don't believe spurious page-flip events help that much in that regard TBH. This only helps if the page-flip flag is on and user-space didn't mean to include these other CRTCs. The benefits of the new API outweigh the small cost of sometimes finding a bug a bit quicker. If some user-space believes otherwise, they can still keep using the old global flag.
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +1
-0@@ -248,6 +248,11 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)* The sharpness effect takes place post blending on the final composed output. * If the feature is disabled, the content remains same without any sharpening effect * and when this feature is applied, it enhances the clarity of the content. +* PAGE_FLIP_EVENT:
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) · line 255
Quoted 4 lines
drivers/gpu/drm/drm_crtc.c +4
-0+* Atomic property for requesting a page-flip event on this CRTC. +* +* The value of this property is an integer value which always reads as +* zero and can be written with 1 to request the event. It took me a while to realise; should probably explain here that if one uses this, then they would not use
DRM_MODE_PAGE_FLIP_EVENTat the same time.
Right.
Quoted 2 lines
Does this allow asking for an event for a CRTC
off->offtransition?
It does not.
Quoted 28 lines · On Thu, 23 Jul 2026 16:02:48 +0000 Simon Ser <[email protected]> wrote:
Quoted 8 lines · Pekka Paalanen
Quoted 5 lines · On Sat, 30 May 2026 17:14:44 +0000 Simon Ser <[email protected]> wrote:
Currently user-space can only request page-flip events for all CRTCs included in an atomic commit. This is cumbersome with multi-CRTC commits: when moving a plane from a different CRTC, or when disabling a plane, user-space has no way to opt-out of the page-flip events.
Quoted 6 lines
Quoted 1 line
Additionally, page-flip events are invalid for already-disable planes, so
Hi Simon,
do you mean CRTCs? I find "already disabled" to be not really clear that you mean
off->offtransition.Oh, yeah, indeed!
Quoted 9 lines
Quoted 3 lines
user-space needs to add special cases [1]. Libraries cannot add planes to the commit without risking causing unexpected page-flip events for the compositor [2].
If a library adds a plane that is currently associated with another CRTC, would it not be a logic error in userspace if it didn't expect that CRTC to be involved? Mostly likely if it succeeds, the plane would disappear from its old CRTC unintended.
Quoted 7 lines
Quoted 2 lines
If a CRTC is unexpectedly involved, userspace risks EBUSY when it wants to update that CRTC for real.
The plane is involved anyways, and the library can figure that out. The library is fully managing the plane, and has ensured it's turned off before migrating it to a new CRTC. What's unexpected and unavoidable is the page-flip event on the old CRTC.
Hi,
do you mean it currently works like this:
0. The plane is active on CRTC A.
1. Submit update 1 with CRTC A, turn the plane off on CRTC A.
2. Update 1 completes, and delivers its pageflip event.
3. Submit update 2 with CRTC B, turn the plane on on CRTC B.
4. Update 2 completes and delivers pageflip events on *both* CRTC B and A?
You want to prevent the pageflip event from CRTC A in step 4?
Or what is the scenario you have in mind?
Thanks,
pq
Quoted 37 lines
Quoted 5 lines
Quoted 2 lines
Figuring out what CRTCs get implicitly included in a commit is non-trivial [3].
Yes, but is this actually helpful rather than making the failures more rare and harder to debug?
I don't believe spurious page-flip events help that much in that regard TBH. This only helps if the page-flip flag is on and user-space didn't mean to include these other CRTCs. The benefits of the new API outweigh the small cost of sometimes finding a bug a bit quicker. If some user-space believes otherwise, they can still keep using the old global flag.
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +1
-0@@ -248,6 +248,11 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)* The sharpness effect takes place post blending on the final composed output. * If the feature is disabled, the content remains same without any sharpening effect * and when this feature is applied, it enhances the clarity of the content. +* PAGE_FLIP_EVENT: Quoted 8 lines
drivers/gpu/drm/drm_crtc.c struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) · line 255
Quoted 4 lines
drivers/gpu/drm/drm_crtc.c +4
-0+* Atomic property for requesting a page-flip event on this CRTC. +* +* The value of this property is an integer value which always reads as +* zero and can be written with 1 to request the event. It took me a while to realise; should probably explain here that if one uses this, then they would not use
DRM_MODE_PAGE_FLIP_EVENTat the same time.Right.
Quoted 2 lines
Does this allow asking for an event for a CRTC
off->offtransition?It does not.