For multiple async flips in a single atomic_commit initialize a
flip_done completion in plane_state and the respective drivers should
signal the plane_state ->flip_done upon getting the flip_done on that
particular plane.
This logic of waiting for the plane_state->flip_done is done after
getting the flip_done interrupt and before sending the event to user.
Ideally the plane_state->flip_done should be signaled by then and as a
fallback mechanism the drm will do a fake complete for the timeouts.

Signed-off-by: Arun R Murthy <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c | 2 ++
 drivers/gpu/drm/drm_atomic_uapi.c   | 4 +++-
 include/drm/drm_plane.h             | 7 +++++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 
cc1f0c102414f1e387a187b7f9d5beb162db2eb2..0e7d98df8eccf91b3b01e7a93526ccc4eb7f0dcc
 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2433,6 +2433,8 @@ static void release_crtc_commit(struct completion 
*completion)
 
 static void init_commit(struct drm_crtc_commit *commit, struct drm_crtc *crtc)
 {
+       struct drm_plane *plane;
+
        init_completion(&commit->flip_done);
        init_completion(&commit->hw_done);
        init_completion(&commit->cleanup_done);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
b/drivers/gpu/drm/drm_atomic_uapi.c
index 
7b8e3b6ca3a5a93d3afbb923f20dacbd21cfc08b..c672b95d359abda622064b6d748c9cb2cea36c3f
 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1201,8 +1201,10 @@ int drm_atomic_set_property(struct drm_atomic_state 
*state,
                                prop, prop_value);
 
                /* Hack to make the legacy DRM_MODE_PAGE_FLIP_ASYNC work with 
atomic_ioctl() */
-               if (async_flip && prop == config->prop_fb_id)
+               if (async_flip && prop == config->prop_fb_id) {
                        plane_state->async_flip = true;
+                       init_completion(&plane_state->flip_done);
+               }
 
                break;
        }
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 
ed8342c9a6258ee97ad930092a48ac3a34e62fc9..6671b4f738703c8720c204b3dbaa726eaeca387d
 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -274,6 +274,12 @@ struct drm_plane_state {
         * mode.
         */
        bool async_flip;
+
+       /**
+        * @flip_done: Used to track the flip completion for each plane in
+        * case of asynchronous flips only.
+        */
+       struct completion flip_done;
 };
 
 static inline struct drm_rect
@@ -830,6 +836,7 @@ struct drm_plane {
         * @kmsg_panic: Used to register a panic notifier for this plane
         */
        struct kmsg_dumper kmsg_panic;
+
 };
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)

-- 
2.25.1

Reply via email to