If a driver supports this capability, it means that it will take ownership of signalling the OUT_FENCE from drm core. Therefore, the OUT_FENCE will no longer be signalled at pageflip completion time but instead at a later time as chosen by the driver. This capability may only be relevant for VKMS drivers. And, it can provide a potential solution for: https://gitlab.freedesktop.org/wayland/weston/-/issues/514 Signed-off-by: Vivek Kasireddy <vivek.kasireddy@xxxxxxxxx> --- drivers/gpu/drm/drm_file.c | 11 +++++++---- drivers/gpu/drm/drm_ioctl.c | 3 +++ include/drm/drm_mode_config.h | 9 +++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index ceb1a9723855..9337938cfa12 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -787,10 +787,13 @@ static void drm_send_event_helper(struct drm_device *dev, } if (e->fence) { - if (timestamp) - dma_fence_signal_timestamp(e->fence, timestamp); - else - dma_fence_signal(e->fence); + if (!dev->mode_config.deferred_out_fence) { + if (timestamp) + dma_fence_signal_timestamp(e->fence, timestamp); + else + dma_fence_signal(e->fence); + } + dma_fence_put(e->fence); } diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index f454e0424086..d6ff36fe0b72 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -302,6 +302,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ case DRM_CAP_CRTC_IN_VBLANK_EVENT: req->value = 1; break; + case DRM_CAP_DEFERRED_OUT_FENCE: + req->value = dev->mode_config.deferred_out_fence; + break; default: return -EINVAL; } diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 1ddf7783fdf7..a9ac9f5ce6ad 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -929,6 +929,15 @@ struct drm_mode_config { */ bool normalize_zpos; + /** + * @deferred_out_fence: + * + * If this option is set, the drm core would no longer signal the + * out_fence at pageflip completion time. Instead, the driver would + * signal the out_fence at a time when it deems appropriate. + */ + bool deferred_out_fence; + /** * @modifiers_property: Plane property to list support modifier/format * combination. diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 3b810b53ba8b..6a85a6892972 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -767,6 +767,7 @@ struct drm_gem_open { * Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". */ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14 +#define DRM_CAP_DEFERRED_OUT_FENCE 0x15 /* DRM_IOCTL_GET_CAP ioctl argument type */ struct drm_get_cap { -- 2.30.2