mbox series

[v9,0/4] drm: Add support for atomic async page-flip

Message ID 20231122161941.320564-1-andrealmeid@igalia.com (mailing list archive)
Headers show
Series drm: Add support for atomic async page-flip | expand

Message

André Almeida Nov. 22, 2023, 4:19 p.m. UTC
Hi,

This work from me and Simon adds support for DRM_MODE_PAGE_FLIP_ASYNC through
the atomic API. This feature is already available via the legacy API. The use
case is to be able to present a new frame immediately (or as soon as
possible), even if after missing a vblank. This might result in tearing, but
it's useful when a high framerate is desired, such as for gaming.

Differently from earlier versions, this one refuses to flip if any prop changes
for async flips. The idea is that the fast path of immediate page flips doesn't
play well with modeset changes, so only the fb_id can be changed.

Tested with:
 - Intel TigerLake-LP GT2
 - AMD VanGogh

Thanks,
	André

- User-space patch: https://github.com/Plagman/gamescope/pull/595
- IGT tests: https://lore.kernel.org/all/20231110163811.24158-1-andrealmeid@igalia.com/

Changes from v8:
- Dropped atomic_async_page_flip_not_supported, giving that current design works
with any driver that support atomic and async at the same time.
- Dropped the patch that disabled atomic_async_page_flip_not_supported for AMD.
- Reordered commits
v8: https://lore.kernel.org/all/20231025005318.293690-1-andrealmeid@igalia.com/

Changes from v7:
- Only accept flips to primary planes. If a driver support flips in different
planes, support will be added  later.
v7: https://lore.kernel.org/dri-devel/20231017092837.32428-1-andrealmeid@igalia.com/

Changes from v6:
- Dropped the exception to allow MODE_ID changes (Simon)
- Clarify what happens when flipping with the same FB_ID (Pekka)

v6: https://lore.kernel.org/dri-devel/20230815185710.159779-1-andrealmeid@igalia.com/

Changes from v5:
- Add note in the docs that not every redundant attribute will result in no-op,
  some might cause oversynchronization issues.

v5: https://lore.kernel.org/dri-devel/20230707224059.305474-1-andrealmeid@igalia.com/

Changes from v4:
 - Documentation rewrote by Pekka Paalanen

v4: https://lore.kernel.org/dri-devel/20230701020917.143394-1-andrealmeid@igalia.com/

Changes from v3:
 - Add new patch to reject prop changes
 - Add a documentation clarifying the KMS atomic state set

v3: https://lore.kernel.org/dri-devel/20220929184307.258331-1-contact@emersion.fr/

André Almeida (1):
  drm: Refuse to async flip with atomic prop changes

Pekka Paalanen (1):
  drm/doc: Define KMS atomic state set

Simon Ser (2):
  drm: allow DRM_MODE_PAGE_FLIP_ASYNC for atomic commits
  drm: introduce DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP

 Documentation/gpu/drm-uapi.rst      | 47 ++++++++++++++++++
 drivers/gpu/drm/drm_atomic_uapi.c   | 77 ++++++++++++++++++++++++++---
 drivers/gpu/drm/drm_crtc_internal.h |  2 +-
 drivers/gpu/drm/drm_ioctl.c         |  4 ++
 drivers/gpu/drm/drm_mode_object.c   |  2 +-
 include/uapi/drm/drm.h              | 10 +++-
 include/uapi/drm/drm_mode.h         |  9 ++++
 7 files changed, 142 insertions(+), 9 deletions(-)

Comments

Hamza Mahfooz Nov. 22, 2023, 8:23 p.m. UTC | #1
Hi André,
On 11/22/23 11:19, André Almeida wrote:
> Hi,
> 
> This work from me and Simon adds support for DRM_MODE_PAGE_FLIP_ASYNC through
> the atomic API. This feature is already available via the legacy API. The use
> case is to be able to present a new frame immediately (or as soon as
> possible), even if after missing a vblank. This might result in tearing, but
> it's useful when a high framerate is desired, such as for gaming.
> 
> Differently from earlier versions, this one refuses to flip if any prop changes
> for async flips. The idea is that the fast path of immediate page flips doesn't
> play well with modeset changes, so only the fb_id can be changed.
> 
> Tested with:
>   - Intel TigerLake-LP GT2
>   - AMD VanGogh

Have you had a chance to test this with VRR enabled? Since, I suspect
this series might break that feature.

> 
> Thanks,
> 	André
> 
> - User-space patch: https://github.com/Plagman/gamescope/pull/595
> - IGT tests: https://lore.kernel.org/all/20231110163811.24158-1-andrealmeid@igalia.com/
> 
> Changes from v8:
> - Dropped atomic_async_page_flip_not_supported, giving that current design works
> with any driver that support atomic and async at the same time.
> - Dropped the patch that disabled atomic_async_page_flip_not_supported for AMD.
> - Reordered commits
> v8: https://lore.kernel.org/all/20231025005318.293690-1-andrealmeid@igalia.com/
> 
> Changes from v7:
> - Only accept flips to primary planes. If a driver support flips in different
> planes, support will be added  later.
> v7: https://lore.kernel.org/dri-devel/20231017092837.32428-1-andrealmeid@igalia.com/
> 
> Changes from v6:
> - Dropped the exception to allow MODE_ID changes (Simon)
> - Clarify what happens when flipping with the same FB_ID (Pekka)
> 
> v6: https://lore.kernel.org/dri-devel/20230815185710.159779-1-andrealmeid@igalia.com/
> 
> Changes from v5:
> - Add note in the docs that not every redundant attribute will result in no-op,
>    some might cause oversynchronization issues.
> 
> v5: https://lore.kernel.org/dri-devel/20230707224059.305474-1-andrealmeid@igalia.com/
> 
> Changes from v4:
>   - Documentation rewrote by Pekka Paalanen
> 
> v4: https://lore.kernel.org/dri-devel/20230701020917.143394-1-andrealmeid@igalia.com/
> 
> Changes from v3:
>   - Add new patch to reject prop changes
>   - Add a documentation clarifying the KMS atomic state set
> 
> v3: https://lore.kernel.org/dri-devel/20220929184307.258331-1-contact@emersion.fr/
> 
> André Almeida (1):
>    drm: Refuse to async flip with atomic prop changes
> 
> Pekka Paalanen (1):
>    drm/doc: Define KMS atomic state set
> 
> Simon Ser (2):
>    drm: allow DRM_MODE_PAGE_FLIP_ASYNC for atomic commits
>    drm: introduce DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP
> 
>   Documentation/gpu/drm-uapi.rst      | 47 ++++++++++++++++++
>   drivers/gpu/drm/drm_atomic_uapi.c   | 77 ++++++++++++++++++++++++++---
>   drivers/gpu/drm/drm_crtc_internal.h |  2 +-
>   drivers/gpu/drm/drm_ioctl.c         |  4 ++
>   drivers/gpu/drm/drm_mode_object.c   |  2 +-
>   include/uapi/drm/drm.h              | 10 +++-
>   include/uapi/drm/drm_mode.h         |  9 ++++
>   7 files changed, 142 insertions(+), 9 deletions(-)
>
André Almeida Nov. 22, 2023, 8:28 p.m. UTC | #2
Hi Hamza,

Em 22/11/2023 17:23, Hamza Mahfooz escreveu:
> Hi André,
> On 11/22/23 11:19, André Almeida wrote:
>> Hi,
>>
>> This work from me and Simon adds support for DRM_MODE_PAGE_FLIP_ASYNC 
>> through
>> the atomic API. This feature is already available via the legacy API. 
>> The use
>> case is to be able to present a new frame immediately (or as soon as
>> possible), even if after missing a vblank. This might result in 
>> tearing, but
>> it's useful when a high framerate is desired, such as for gaming.
>>
>> Differently from earlier versions, this one refuses to flip if any 
>> prop changes
>> for async flips. The idea is that the fast path of immediate page 
>> flips doesn't
>> play well with modeset changes, so only the fb_id can be changed.
>>
>> Tested with:
>>   - Intel TigerLake-LP GT2
>>   - AMD VanGogh
> 
> Have you had a chance to test this with VRR enabled? Since, I suspect
> this series might break that feature.
> 

Someone asked this question in an earlier version of this patch, and the 
result is that VRR still works as expected. You can follow the thread at 
this link:

https://lore.kernel.org/lkml/b48bd1fc-fcb0-481b-8413-9210d44d709b@igalia.com/

I should have included this note at my cover letter, my bad.

Thanks,
	André
Simon Ser Nov. 23, 2023, 4:24 p.m. UTC | #3
Thanks! This iteration of the first 3 patches LGTM, I've pushed them to
drm-misc-next. I've made two adjustments to make checkpatch.pl happy:

- s/uint64_t/u64/
- Fix indentation for a drm_dbg_atomic()
André Almeida Nov. 23, 2023, 4:26 p.m. UTC | #4
Em 23/11/2023 13:24, Simon Ser escreveu:
> Thanks! This iteration of the first 3 patches LGTM, I've pushed them to
> drm-misc-next. I've made two adjustments to make checkpatch.pl happy:
> 

Thank you!

> - s/uint64_t/u64/
> - Fix indentation for a drm_dbg_atomic()

ops :)