Skip to contentSkip to conversation

drm: Add target_vblank field to drm_crtc_state

PATCH In review Andrey Grodzovsky 4 participants 18 messages Jan 1, 2017 – Jan 12, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover drm: Add target_vblank field to drm_crtc_state

Following the introduction of target vblank flip in c229bfbbd drm: Add page_flip_target CRTC hook v2 the target vblank An extra step is required to support this feature in atomic drivers. The value has to be passed down to atomic commit to do the page flip.

Patch 1 uses drm_crtc_state as the place to hold this field. Patch 2 is the intended usage in AMDGPU/DAL driver.

Andrey Grodzovsky (2):
drm/core: Add target_vblank member to drm_crtc_state drm/amd/dal: Switch to page_flip_target hook in DAL.

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 8 +++++---
 include/drm/drm_crtc.h                                  | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/2 drm: Add target_vblank member to drm_crtc_state

This change allows usage of the new page_flip_target hook for drivers implementing the atomic path.

---
 include/drm/drm_crtc.h | 3 +++
 1 file changed, 3 insertions(+)
include/drm/drm_crtc.h +3 -0
index 946672f..3a7685f 100644
@@ -156,6 +156,9 @@ struct drm_crtc_state {
 	struct drm_property_blob *ctm;
 	struct drm_property_blob *gamma_lut;
 
+	/* target vblank count to do a flip */
+	u32 target_vblank;
+
 	/**
 	 * @event:
 	 *
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 1/2] drm: Add target_vblank member to drm_crtc_state

Quoted 6 lines · Andrey Grodzovsky

This change allows usage of the new page_flip_target hook for drivers implementing the atomic path.

Instead of patching your amdgpu version of the page_flip helper you should patch at least the one in drm_atomic_helper..c, and then use that one. We probably need a page_flip_target version of that, which then opens some questions about how you would expose this for atomic drivers and the atomic ioctl. Just adding this here in the shared struct is somewhat pointless, you could do that in the amdgpu_crtc_state struct too.

include/drm/drm_crtc.h struct drm_crtc_state { · line 159

Quoted 13 lines
---
 include/drm/drm_crtc.h | 3 +++
 1 file changed, 3 insertions(+)
include/drm/drm_crtc.h +1 -0
index 946672f..3a7685f 100644
@@ -156,6 +156,9 @@ struct drm_crtc_state {
        struct drm_property_blob *ctm;
        struct drm_property_blob *gamma_lut;
 
+       /* target vblank count to do a flip */

Please type real kerneldoc for this.

Thanks, Daniel

Quoted 12 lines
include/drm/drm_crtc.h +2 -1
+       u32 target_vblank;
+
        /**
         * @event:
         *
--

1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 1/1 drm/atomic: Add target_vblank support in atomic helpers.

Allows usage of the new page_flip_target hook for
drivers implementing the atomic path.
Provides default atomic helper for the new hook.

---
 drivers/gpu/drm/drm_atomic_helper.c | 146 ++++++++++++++++++++++++++++--------
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   3 +
 3 files changed, 125 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +116 -30
index 583f47f..5e76f90 100644
@@ -2733,6 +2733,59 @@ int drm_atomic_helper_resume(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int drm_atomic_helper_page_flip_create_state(
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
+static void drm_atomic_helper_page_flip_prepare_retry(
+				struct drm_atomic_state *state,
+				struct drm_plane *plane)
+{
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we dropped locks
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
@@ -2756,8 +2809,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
@@ -2768,35 +2819,79 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb, event);
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_helper_page_flip_prepare_retry(state, plane);
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip - execute a legacy page flip
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ *
+ * Provides a default page flip on specific vblank implementation using
+ * the atomic driver interface.
+ *
+ * Note that for now so called async page flips (i.e. updates which are not
+ * synchronized to vblank) are not supported, since the atomic interfaces have
+ * no provisions for this yet.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.
+ */
+int drm_atomic_helper_page_flip_on_target_vblank(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
+retry:
+	ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb, event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2805,19 +2900,10 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 	return ret;
 
 backoff:
-	drm_atomic_state_clear(state);
-	drm_atomic_legacy_backoff(state);
-
-	/*
-	 * Someone might have exchanged the framebuffer while we dropped locks
-	 * in the backoff code. We need to fix up the fb refcount tracking the
-	 * core does for us.
-	 */
-	plane->old_fb = plane->fb;
-
+	drm_atomic_helper_page_flip_prepare_retry(state, plane);
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_on_target_vblank);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper implementation
include/drm/drm_atomic_helper.h +6 -0
index 7ff92b0..e8cb6b7 100644
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_on_target_vblank(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector *connector,
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h +3 -0
index 946672f..cc926dc 100644
@@ -103,6 +103,7 @@ static inline uint64_t I642U64(int64_t val)
  * @ctm: Transformation matrix
  * @gamma_lut: Lookup table for converting pixel data after the
  *	conversion matrix
+ * @target_vblank: Target vblank count to flip
  * @state: backpointer to global drm_atomic_state
  *
  * Note that the distinction between @enable and @active is rather subtile:
@@ -156,6 +157,8 @@ struct drm_crtc_state {
 	struct drm_property_blob *ctm;
 	struct drm_property_blob *gamma_lut;
 
+	u32 target_vblank;
+
 	/**
 	 * @event:
 	 *
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers.

Quoted 5 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for
drivers implementing the atomic path.
Provides default atomic helper for the new hook.

Please keep a per-patch changelog so that it's easier for everyone to follow the evolution of this patch.

Quoted 11 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 146 ++++++++++++++++++++++++++++--------
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   3 +
 3 files changed, 125 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 583f47f..5e76f90 100644

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev, · line 2736

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -0
@@ -2733,6 +2733,59 @@ int drm_atomic_helper_resume(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int drm_atomic_helper_page_flip_create_state(

I'd just call this page_flip_common without the long namespace prefix since it's static. And without the create_state name since this function also does some basic checks.

Quoted 40 lines
drivers/gpu/drm/drm_atomic_helper.c +40 -0
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
+static void drm_atomic_helper_page_flip_prepare_retry(
+				struct drm_atomic_state *state,
+				struct drm_plane *plane)

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev, · line 2786

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+{
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we dropped locks
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;

There's a lot more places where we do this trick, please either refactor them all, or none. Personally I'd go with none since the function call is more verbose than the assignement, and you're hiding this rather important comment behind a function name that doesn't say what games are being played here.

Quoted 56 lines
drivers/gpu/drm/drm_atomic_helper.c +25 -13
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
@@ -2756,8 +2809,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
@@ -2768,35 +2819,79 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb, event);
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_helper_page_flip_prepare_retry(state, plane);
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip - execute a legacy page flip
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc, · line 2858

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+ *
+ * Provides a default page flip on specific vblank implementation using
+ * the atomic driver interface.
+ *
+ * Note that for now so called async page flips (i.e. updates which are not
+ * synchronized to vblank) are not supported, since the atomic interfaces have
+ * no provisions for this yet.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.

Kerneldoc isn't updated, just verbatim copypaste. Please also linke these 2 functions. And if you have time, would be good to sprinkle links to the vfunc hooks for each of these default helpers (they're unfortunately missing ...), e.g. here &drm_crtc_funcs.page_flip_target.

And please build the docs per http://blog.ffwll.ch/2016/12/howto-docs.html
and make sure it all looks pretty.

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc, · line 2860

Quoted 2 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -0
+ */
+int drm_atomic_helper_page_flip_on_target_vblank(

Please name this helper to match the vhook it's supposed to slot into, i.e. drm_atomic_helper_page_flip_target.

Quoted 95 lines
drivers/gpu/drm/drm_atomic_helper.c +28 -17
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
+retry:
+	ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb, event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2805,19 +2900,10 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 	return ret;
 
 backoff:
-	drm_atomic_state_clear(state);
-	drm_atomic_legacy_backoff(state);
-
-	/*
-	 * Someone might have exchanged the framebuffer while we dropped locks
-	 * in the backoff code. We need to fix up the fb refcount tracking the
-	 * core does for us.
-	 */
-	plane->old_fb = plane->fb;
-
+	drm_atomic_helper_page_flip_prepare_retry(state, plane);
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_on_target_vblank);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper implementation
include/drm/drm_atomic_helper.h +6 -0
index 7ff92b0..e8cb6b7 100644
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_on_target_vblank(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector *connector,
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h +1 -0
index 946672f..cc926dc 100644
@@ -103,6 +103,7 @@ static inline uint64_t I642U64(int64_t val)
  * @ctm: Transformation matrix
  * @gamma_lut: Lookup table for converting pixel data after the
  *	conversion matrix
+ * @target_vblank: Target vblank count to flip
  * @state: backpointer to global drm_atomic_state
  *
  * Note that the distinction between @enable and @active is rather subtile:

include/drm/drm_crtc.h struct drm_crtc_state { · line 160

Quoted 4 lines
include/drm/drm_crtc.h +1 -0
@@ -156,6 +157,8 @@ struct drm_crtc_state {
 	struct drm_property_blob *ctm;
 	struct drm_property_blob *gamma_lut;
 
+	u32 target_vblank;

The in-line style is preferred for structures, since it allows to group comments with each member. There's also still the question of how drivers opt-in into target_vblank (only amdgpu, and then only in your private branch supports it). I think that should be documented in the kernel-doc.

Thanks, Daniel

Quoted 7 lines
include/drm/drm_crtc.h +1 -0
+
 	/**
 	 * @event:
 	 *
Signature · 1 line
1.9.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

RE: [PATCH] drm/atomic: Add target_vblank support in atomic helpers.

Quoted 168 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, January 04, 2017 3:44 AM
To: Grodzovsky, Andrey
Cc: [email protected]; [email protected]; Deucher, Alexander; Daenzer, Michel; Wentland, Harry
Subject: Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers.

Quoted 5 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

Please keep a per-patch changelog so that it's easier for everyone to follow the evolution of this patch.

Quoted 2 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 146

++++++++++++++++++++++++++++--------

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 10 lines
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   3 +
 3 files changed, 125 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 583f47f..5e76f90 100644
@@ -2733,6 +2733,59 @@ int drm_atomic_helper_resume(struct

drm_device

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev, · line 2736

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -0
 *dev,  }  EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int drm_atomic_helper_page_flip_create_state(

I'd just call this page_flip_common without the long namespace prefix since it's static. And without the create_state name since this function also does some basic checks.

Quoted 19 lines
drivers/gpu/drm/drm_atomic_helper.c +19 -0
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event) {
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy

flip\n",

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +6 -0
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+static void drm_atomic_helper_page_flip_prepare_retry(
+				struct drm_atomic_state *state,
+				struct drm_plane *plane)
+{
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we

dropped locks

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev, · line 2786

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +4 -0
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;

There's a lot more places where we do this trick, please either refactor them all, or none. Personally I'd go with none since the function call is more verbose than the assignement, and you're hiding this rather important comment behind a function name that doesn't say what games are being played here.

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -0
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc · line 2814

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -2
@@ -2756,8 +2809,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc
 *crtc,  {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC) @@ -2768,35 +2819,79

@@ int

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines

drm_atomic_helper_page_flip(struct drm_crtc *crtc,

drivers/gpu/drm/drm_atomic_helper.c +2 -3
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb,

event);

Quoted 40 lines
drivers/gpu/drm/drm_atomic_helper.c +29 -8
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_helper_page_flip_prepare_retry(state, plane);
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip - execute a legacy page flip
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ *
+ * Provides a default page flip on specific vblank implementation
+using
+ * the atomic driver interface.
+ *
+ * Note that for now so called async page flips (i.e. updates which
+are not
+ * synchronized to vblank) are not supported, since the atomic
Quoted 8 lines
Quoted 5 lines

+interfaces have
+ * no provisions for this yet.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.

Kerneldoc isn't updated, just verbatim copypaste. Please also linke these 2 functions. And if you have time, would be good to sprinkle links to the

Not sure here, do you mean kerneldoc is not generated for the new helper function ? If so , Is it because @tags are missing ?

Quoted 2 lines

vfunc hooks for each of these default helpers (they're unfortunately missing ...), e.g. here &drm_crtc_funcs.page_flip_target.

Do you mean adding kernedoc for the vfunc hook ?

Thanks, Andrey

Quoted 131 lines

And please build the docs per http://blog.ffwll.ch/2016/12/howto-docs.html
and make sure it all looks pretty.

Quoted 2 lines

+ */
+int drm_atomic_helper_page_flip_on_target_vblank(

Please name this helper to match the vhook it's supposed to slot into, i.e. drm_atomic_helper_page_flip_target.

Quoted 21 lines
drivers/gpu/drm/drm_atomic_helper.c +21 -0
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
+retry:

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -5
+	ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb,
+event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy

flip\n",

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct

Quoted 14 lines
drivers/gpu/drm/drm_atomic_helper.c +4 -1
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2805,19 +2900,10 @@ int drm_atomic_helper_page_flip(struct

drm_crtc *crtc,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -5
 	return ret;
 
 backoff:
-	drm_atomic_state_clear(state);
-	drm_atomic_legacy_backoff(state);
-
-	/*
-	 * Someone might have exchanged the framebuffer while we

dropped locks

include/drm/drm_atomic_helper.h int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 18 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -6
-	 * in the backoff code. We need to fix up the fb refcount tracking the
-	 * core does for us.
-	 */
-	plane->old_fb = plane->fb;
-
+	drm_atomic_helper_page_flip_prepare_retry(state, plane);
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_on_target_vblank);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper

implementation diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 7ff92b0..e8cb6b7 100644

include/drm/drm_atomic_helper.h +0 -0
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

include/drm/drm_atomic_helper.h int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
include/drm/drm_atomic_helper.h +6 -0
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_on_target_vblank(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector

*connector,

Quoted 7 lines
include/drm/drm_atomic_helper.h +0 -0
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h index renamed from include/drm/drm_crtc.h +0 -0

946672f..cc926dc 100644

include/drm/drm_crtc.h static inline uint64_t I642U64(int64_t val) · line 109

Quoted 7 lines
include/drm/drm_crtc.h +1 -0
@@ -103,6 +103,7 @@ static inline uint64_t I642U64(int64_t val)
  * @ctm: Transformation matrix
  * @gamma_lut: Lookup table for converting pixel data after the
  *	conversion matrix
+ * @target_vblank: Target vblank count to flip
  * @state: backpointer to global drm_atomic_state
  *
  * Note that the distinction between @enable and @active is rather

subtile:

include/drm/drm_crtc.h struct drm_crtc_state { · line 160

Quoted 5 lines
include/drm/drm_crtc.h +1 -0
@@ -156,6 +157,8 @@ struct drm_crtc_state {
 	struct drm_property_blob *ctm;
 	struct drm_property_blob *gamma_lut;
 
+	u32 target_vblank;

The in-line style is preferred for structures, since it allows to group comments with each member. There's also still the question of how drivers opt-in into target_vblank (only amdgpu, and then only in your private branch supports it). I think that should be documented in the kernel-doc.

Thanks, Daniel

Quoted 7 lines
include/drm/drm_crtc.h +1 -1
+
 	/**
 	 * @event:
 	 *
--

1.9.1

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers.

Quoted 23 lines · Andrey
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/drm_atomic_helper.c +14 -0
+/**
+ * drm_atomic_helper_page_flip - execute a legacy page flip
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ *
+ * Provides a default page flip on specific vblank implementation
+using
+ * the atomic driver interface.
+ *
+ * Note that for now so called async page flips (i.e. updates which
+are not
+ * synchronized to vblank) are not supported, since the atomic
Quoted 8 lines
Quoted 5 lines

+interfaces have
+ * no provisions for this yet.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.

Kerneldoc isn't updated, just verbatim copypaste. Please also linke these 2 functions. And if you have time, would be good to sprinkle links to the

Quoted 2 lines

Not sure here, do you mean kerneldoc is not generated for the new helper function ? If so , Is it because @tags are missing ?

You should get a warning about the missing @tag, yes. But having the exact same text for both is pointless, so for similar functions it's good to highlight the differences (and mabye link between the two using the functions() syntax).

Quoted 5 lines
Quoted 3 lines

vfunc hooks for each of these default helpers (they're unfortunately missing ...), e.g. here &drm_crtc_funcs.page_flip_target.

Do you mean adding kernedoc for the vfunc hook ?

No, just linking to them.

http://blog.ffwll.ch/2016/12/howto-docs.html

and you can see the output, makes all this a bit easier to understand probably.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

---
 drivers/gpu/drm/drm_atomic_helper.c | 133 ++++++++++++++++++++++++++++++------
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   9 +++
 3 files changed, 127 insertions(+), 21 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +112 -21
index 583f47f..a4e5477 100644
@@ -2733,6 +2733,44 @@ int drm_atomic_helper_resume(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int page_flip_common(
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
@@ -2740,7 +2778,8 @@ int drm_atomic_helper_resume(struct drm_device *dev,
  * @event: optional DRM event to signal upon completion
  * @flags: flip flags for non-vblank sync'ed updates
  *
- * Provides a default page flip implementation using the atomic driver interface.
+ * Provides a default &drm_crtc_funcs.page_flip implementation
+ * using the atomic driver interface.
  *
  * Note that for now so called async page flips (i.e. updates which are not
  * synchronized to vblank) are not supported, since the atomic interfaces have
@@ -2748,6 +2787,9 @@ int drm_atomic_helper_resume(struct drm_device *dev,
  *
  * Returns:
  * Returns 0 on success, negative errno numbers on failure.
+ *
+ * See also:
+ * drm_atomic_helper_page_flip_target()
  */
 int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
@@ -2756,8 +2798,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
@@ -2768,35 +2808,86 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = page_flip_common(state, crtc, fb, event);
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we dropped locks
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;
+
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip_target - do page flip on target vblank period.
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ * @target: specifying the target vblank period when the flip to take effect
+ *
+ * Provides a default &drm_crtc_funcs.page_flip_target implementation.
+ * Similar to drm_atomic_helper_page_flip() with extra parameter to specify
+ * target vblank period to flip.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.
+ */
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
+retry:
+	ret = page_flip_common(state, crtc, fb, event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2817,7 +2908,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper implementation
include/drm/drm_atomic_helper.h +6 -0
index 7ff92b0..b3b3abe 100644
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector *connector,
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h +9 -0
index 946672f..5c77c3f 100644
@@ -157,6 +157,15 @@ struct drm_crtc_state {
 	struct drm_property_blob *gamma_lut;
 
 	/**
+	 * @target_vblank:
+	 *
+	 * Target vertical blank period when a page flip
+	 * should take effect.
+	 */
+
+	u32 target_vblank;
+
+	/**
 	 * @event:
 	 *
 	 * Optional pointer to a DRM event to signal upon completion of the
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 9 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Thanks, Daniel

Quoted 237 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 133 ++++++++++++++++++++++++++++++------
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   9 +++
 3 files changed, 127 insertions(+), 21 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +112 -21
index 583f47f..a4e5477 100644
@@ -2733,6 +2733,44 @@ int drm_atomic_helper_resume(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int page_flip_common(
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
@@ -2740,7 +2778,8 @@ int drm_atomic_helper_resume(struct drm_device *dev,
  * @event: optional DRM event to signal upon completion
  * @flags: flip flags for non-vblank sync'ed updates
  *
- * Provides a default page flip implementation using the atomic driver interface.
+ * Provides a default &drm_crtc_funcs.page_flip implementation
+ * using the atomic driver interface.
  *
  * Note that for now so called async page flips (i.e. updates which are not
  * synchronized to vblank) are not supported, since the atomic interfaces have
@@ -2748,6 +2787,9 @@ int drm_atomic_helper_resume(struct drm_device *dev,
  *
  * Returns:
  * Returns 0 on success, negative errno numbers on failure.
+ *
+ * See also:
+ * drm_atomic_helper_page_flip_target()
  */
 int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
@@ -2756,8 +2798,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
@@ -2768,35 +2808,86 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = page_flip_common(state, crtc, fb, event);
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we dropped locks
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;
+
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip_target - do page flip on target vblank period.
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ * @target: specifying the target vblank period when the flip to take effect
+ *
+ * Provides a default &drm_crtc_funcs.page_flip_target implementation.
+ * Similar to drm_atomic_helper_page_flip() with extra parameter to specify
+ * target vblank period to flip.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.
+ */
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
+retry:
+	ret = page_flip_common(state, crtc, fb, event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n",
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2817,7 +2908,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper implementation
include/drm/drm_atomic_helper.h +6 -0
index 7ff92b0..b3b3abe 100644
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector *connector,
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h +9 -0
index 946672f..5c77c3f 100644
@@ -157,6 +157,15 @@ struct drm_crtc_state {
 	struct drm_property_blob *gamma_lut;
 
 	/**
+	 * @target_vblank:
+	 *
+	 * Target vertical blank period when a page flip
+	 * should take effect.
+	 */
+
+	u32 target_vblank;
+
+	/**
 	 * @event:
 	 *
 	 * Optional pointer to a DRM event to signal upon completion of the
Signature · 1 line
1.9.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

Quoted 8 lines
Quoted 5 lines

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Andrey, is there an updated patch 2 adapted to current patch 1? Other than that and some questionable indentation of parameters in function signatures, looks good to me FWIW.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

RE: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 18 lines

-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Wednesday, January 11, 2017 3:33 AM
To: Daniel Vetter; Grodzovsky, Andrey
Cc: Deucher, Alexander; [email protected]
Subject: Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Andrey, is there an updated patch 2 adapted to current patch 1? Other than that and some questionable indentation of parameters in function signatures, looks good to me FWIW.

We are unable to use the atomic helpers both for page_flip and page_flip_target
At their current form mostly due to DRM_MODE_PAGE_FLIP_ASYNC flag rejection they do. I discussed this with Daniel Vetter on IRC and suggested
to remove the rejection but he said the precise semantics of
atomic async flip is not clear yet and it's better to leave that out for now
until there is a userspace asking for it.
So I tested it by just hacking the helper to remove the rejection.
Until that settled the original change [PATCH 2/2] drm/amd/dal: Switch to page_flip_target hook in DAL Is what we plan to use in DAL

Andrey

Quoted 5 lines

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 20 lines · Andrey
Quoted 11 lines

From: Michel Dänzer [mailto:[email protected]]

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Andrey, is there an updated patch 2 adapted to current patch 1? Other than that and some questionable indentation of parameters in function signatures, looks good to me FWIW.

Quoted 9 lines

We are unable to use the atomic helpers both for page_flip and page_flip_target
At their current form mostly due to DRM_MODE_PAGE_FLIP_ASYNC flag rejection they do. I discussed this with Daniel Vetter on IRC and suggested
to remove the rejection but he said the precise semantics of
atomic async flip is not clear yet and it's better to leave that out for now
until there is a userspace asking for it.
So I tested it by just hacking the helper to remove the rejection.
Until that settled the original change [PATCH 2/2] drm/amd/dal: Switch to page_flip_target hook in DAL Is what we plan to use in DAL

IIRC Daniel suggested (on IRC?) to use the helper for non-async flips and the current DC code for async flips. Is that feasible?

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 31 lines · Michel Dänzer
Quoted 20 lines · Andrey
Quoted 11 lines

From: Michel Dänzer [mailto:[email protected]]

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Andrey, is there an updated patch 2 adapted to current patch 1? Other than that and some questionable indentation of parameters in function signatures, looks good to me FWIW.

Quoted 9 lines

We are unable to use the atomic helpers both for page_flip and page_flip_target
At their current form mostly due to DRM_MODE_PAGE_FLIP_ASYNC flag rejection they do. I discussed this with Daniel Vetter on IRC and suggested
to remove the rejection but he said the precise semantics of
atomic async flip is not clear yet and it's better to leave that out for now
until there is a userspace asking for it.
So I tested it by just hacking the helper to remove the rejection.
Until that settled the original change [PATCH 2/2] drm/amd/dal: Switch to page_flip_target hook in DAL Is what we plan to use in DAL

Quoted 2 lines

IIRC Daniel suggested (on IRC?) to use the helper for non-async flips and the current DC code for async flips. Is that feasible?

We do have some async flip flag reserved for atomic, so we could route it through. But since atm there's no one asking for async flips on the atomic ioctl I'm a bit wary for fear of ending up with ill-defined semantics. But I guess if we do this for legacy pageflips only, and make sure we do still reject async flips submitted through the atomic ioctl that should be all fine. And it should allow amdgpu to entirely get rid of the legacy flip path, which would be nice.

Once we have that we could even use it for cursor plane updates (through the legacy ioctl, for drivers with universal planes), for those drivers that support it.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

RE: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 54 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, January 12, 2017 3:51 AM
To: Michel Dänzer
Cc: Grodzovsky, Andrey; Deucher, Alexander; dri- [email protected]
Subject: Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Andrey
Quoted 16 lines

From: Michel Dänzer [mailto:[email protected]] On 09/01/17 06:59

Quoted 13 lines · Daniel Vetter
Quoted 9 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Andrey, is there an updated patch 2 adapted to current patch 1? Other than that and some questionable indentation of parameters in function signatures, looks good to me FWIW.

We are unable to use the atomic helpers both for page_flip and page_flip_target At their current form mostly due to

DRM_MODE_PAGE_FLIP_ASYNC flag rejection they do.

Quoted 10 lines
Quoted 7 lines

I discussed this with Daniel Vetter on IRC and suggested to remove the rejection but he said the precise semantics of atomic async flip is not clear yet and it's better to leave that out for now until there is a userspace asking for it.
So I tested it by just hacking the helper to remove the rejection. Until that settled the original change [PATCH 2/2] drm/amd/dal:
Switch to page_flip_target hook in DAL Is what we plan to use in DAL

IIRC Daniel suggested (on IRC?) to use the helper for non-async flips and the current DC code for async flips. Is that feasible?

We do have some async flip flag reserved for atomic, so we could route it through. But since atm there's no one asking for async flips on the atomic ioctl I'm a bit wary for fear of ending up with ill-defined semantics. But I guess if we do this for legacy pageflips only, and make sure we do still reject async flips submitted through the atomic ioctl that should be all fine. And it should allow amdgpu to entirely get rid of the legacy flip path, which would be nice.

Quoted 4 lines

Once we have that we could even use it for cursor plane updates (through the legacy ioctl, for drivers with universal planes), for those drivers that support it.
-Daniel

So are we ok with a follow-up patch removing the ASYNC_FLIP restriction in the legacy IOCTL
+ adding the drm_mode_crtc_page_flip_target.flags to drm_crtc_state ? In that case as I said before, at least for DAL we could drop our own page_flip hook and use the avaialbe helpers.

Andrey

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 54 lines · Andrey
Quoted 54 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, January 12, 2017 3:51 AM
To: Michel Dänzer
Cc: Grodzovsky, Andrey; Deucher, Alexander; dri- [email protected]
Subject: Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Andrey
Quoted 16 lines

From: Michel Dänzer [mailto:[email protected]] On 09/01/17 06:59

Quoted 13 lines · Daniel Vetter
Quoted 9 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Andrey, is there an updated patch 2 adapted to current patch 1? Other than that and some questionable indentation of parameters in function signatures, looks good to me FWIW.

We are unable to use the atomic helpers both for page_flip and page_flip_target At their current form mostly due to

DRM_MODE_PAGE_FLIP_ASYNC flag rejection they do.

Quoted 10 lines
Quoted 7 lines

I discussed this with Daniel Vetter on IRC and suggested to remove the rejection but he said the precise semantics of atomic async flip is not clear yet and it's better to leave that out for now until there is a userspace asking for it.
So I tested it by just hacking the helper to remove the rejection. Until that settled the original change [PATCH 2/2] drm/amd/dal:
Switch to page_flip_target hook in DAL Is what we plan to use in DAL

IIRC Daniel suggested (on IRC?) to use the helper for non-async flips and the current DC code for async flips. Is that feasible?

We do have some async flip flag reserved for atomic, so we could route it through. But since atm there's no one asking for async flips on the atomic ioctl I'm a bit wary for fear of ending up with ill-defined semantics. But I guess if we do this for legacy pageflips only, and make sure we do still reject async flips submitted through the atomic ioctl that should be all fine. And it should allow amdgpu to entirely get rid of the legacy flip path, which would be nice.

Quoted 8 lines
Quoted 4 lines

Once we have that we could even use it for cursor plane updates (through the legacy ioctl, for drivers with universal planes), for those drivers that support it.
-Daniel

So are we ok with a follow-up patch removing the ASYNC_FLIP restriction in the legacy IOCTL
+ adding the drm_mode_crtc_page_flip_target.flags to drm_crtc_state ? In that case as I said before, at least for DAL we could drop our own page_flip hook and use the avaialbe helpers.

Yeah, reconsidering all I think that'd be rather reasonable approach. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by
#15 lore raw

RE: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

In reply to Daniel Vetter
Quoted 15 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, January 09, 2017 4:59 AM
To: Grodzovsky, Andrey
Cc: [email protected]; [email protected]; Deucher, Alexander; Daenzer, Michel; Wentland, Harry
Subject: Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 4 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

Quoted 8 lines
Quoted 5 lines

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

I had a discussion about this with Andrey and I think we are in good shape.

Quoted 257 lines

Thanks, Daniel

Quoted 2 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 133

++++++++++++++++++++++++++++++------

Review

Quoted 5 lines
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   9 +++
 3 files changed, 127 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 4 lines

index 583f47f..a4e5477 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -2733,6 +2733,44 @@ int drm_atomic_helper_resume(struct

drm_device *dev,

Quoted 24 lines
drivers/gpu/drm/drm_atomic_helper.c +21 -0
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int page_flip_common(
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy

flip\n",

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 11 lines
drivers/gpu/drm/drm_atomic_helper.c +7 -0
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
@@ -2740,7 +2778,8 @@ int drm_atomic_helper_resume(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -1
  * @event: optional DRM event to signal upon completion
  * @flags: flip flags for non-vblank sync'ed updates
  *
- * Provides a default page flip implementation using the atomic driver

interface.

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -0
+ * Provides a default &drm_crtc_funcs.page_flip implementation
+ * using the atomic driver interface.
  *
  * Note that for now so called async page flips (i.e. updates which are not
  * synchronized to vblank) are not supported, since the atomic interfaces

have

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 1 line
drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -2748,6 +2787,9 @@ int drm_atomic_helper_resume(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
  *
  * Returns:
  * Returns 0 on success, negative errno numbers on failure.
+ *
+ * See also:
+ * drm_atomic_helper_page_flip_target()
  */
 int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
@@ -2756,8 +2798,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct

Quoted 9 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -2
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
@@ -2768,35 +2808,86 @@ int drm_atomic_helper_page_flip(struct

drm_crtc *crtc,

Quoted 25 lines
drivers/gpu/drm/drm_atomic_helper.c +7 -11
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = page_flip_common(state, crtc, fb, event);
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we

dropped locks

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 11 lines
drivers/gpu/drm/drm_atomic_helper.c +11 -0
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;
+
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip_target - do page flip on target vblank

period.

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -0
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ * @target: specifying the target vblank period when the flip to take

effect

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
+ *
+ * Provides a default &drm_crtc_funcs.page_flip_target implementation.
+ * Similar to drm_atomic_helper_page_flip() with extra parameter to

specify

Quoted 26 lines
drivers/gpu/drm/drm_atomic_helper.c +26 -0
+ * target vblank period to flip.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.
+ */
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -5
+retry:
+	ret = page_flip_common(state, crtc, fb, event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy

flip\n",

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 14 lines
drivers/gpu/drm/drm_atomic_helper.c +4 -1
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2817,7 +2908,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper

implementation

Review

Quoted 1 line
(quoted diff) +0 -0

b/include/drm/drm_atomic_helper.h

include/drm/drm_atomic_helper.h int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 4 lines

index 7ff92b0..b3b3abe 100644

include/drm/drm_atomic_helper.h +0 -0
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

include/drm/drm_atomic_helper.h int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
include/drm/drm_atomic_helper.h +6 -0
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector

*connector,

Quoted 22 lines
include/drm/drm_atomic_helper.h +0 -0
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h +9 -0
index 946672f..5c77c3f 100644
@@ -157,6 +157,15 @@ struct drm_crtc_state {
 	struct drm_property_blob *gamma_lut;
 
 	/**
+	 * @target_vblank:
+	 *
+	 * Target vertical blank period when a page flip
+	 * should take effect.
+	 */
+
+	u32 target_vblank;
+
+	/**
 	 * @event:
 	 *
 	 * Optional pointer to a DRM event to signal upon completion of the
Quoted 8 lines
Quoted 3 lines

--
1.9.1

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#16 lore raw

Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 19 lines · Alexander
Quoted 19 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, January 09, 2017 4:59 AM
To: Grodzovsky, Andrey
Cc: [email protected]; [email protected]; Deucher, Alexander; Daenzer, Michel; Wentland, Harry
Subject: Re: [PATCH] drm/atomic: Add target_vblank support in atomic helpers (v2)

Quoted 8 lines · Andrey Grodzovsky

Allows usage of the new page_flip_target hook for drivers implementing the atomic path.
Provides default atomic helper for the new hook.

v2:
Update code sharing logic between exsiting and the new flip hooks. Improve kerneldoc.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Looks all reasonable, I think an ack from Alex that the amd side is in shape too, and I'll pull this into drm-misc.

I had a discussion about this with Andrey and I think we are in good shape.

Applied to drm-misc, thanks.
-Daniel

Quoted 266 lines
Quoted 266 lines

Thanks, Daniel

Quoted 2 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 133

++++++++++++++++++++++++++++++------

Review

Quoted 5 lines
 include/drm/drm_atomic_helper.h     |   6 ++
 include/drm/drm_crtc.h              |   9 +++
 3 files changed, 127 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 4 lines

index 583f47f..a4e5477 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -2733,6 +2733,44 @@ int drm_atomic_helper_resume(struct

drm_device *dev,

Quoted 24 lines
drivers/gpu/drm/drm_atomic_helper.c +21 -0
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
 
+static int page_flip_common(
+				struct drm_atomic_state *state,
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_plane_state *plane_state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
+	crtc_state->event = event;
+
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state))
+		return PTR_ERR(plane_state);
+

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+	if (ret != 0)
+		return ret;
+	drm_atomic_set_fb_for_plane(plane_state, fb);
+
+	/* Make sure we don't accidentally do a full modeset. */
+	state->allow_modeset = false;
+	if (!crtc_state->active) {
+		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy

flip\n",

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 11 lines
drivers/gpu/drm/drm_atomic_helper.c +7 -0
+				 crtc->base.id);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
 /**
  * drm_atomic_helper_page_flip - execute a legacy page flip
  * @crtc: DRM crtc
@@ -2740,7 +2778,8 @@ int drm_atomic_helper_resume(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -1
  * @event: optional DRM event to signal upon completion
  * @flags: flip flags for non-vblank sync'ed updates
  *
- * Provides a default page flip implementation using the atomic driver

interface.

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct drm_device *dev,

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -0
+ * Provides a default &drm_crtc_funcs.page_flip implementation
+ * using the atomic driver interface.
  *
  * Note that for now so called async page flips (i.e. updates which are not
  * synchronized to vblank) are not supported, since the atomic interfaces

have

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_resume(struct

Quoted 1 line
drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -2748,6 +2787,9 @@ int drm_atomic_helper_resume(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
  *
  * Returns:
  * Returns 0 on success, negative errno numbers on failure.
+ *
+ * See also:
+ * drm_atomic_helper_page_flip_target()
  */
 int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
@@ -2756,8 +2798,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct

Quoted 9 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -2
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_atomic_state *state;
-	struct drm_plane_state *plane_state;
-	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 
 	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
@@ -2768,35 +2808,86 @@ int drm_atomic_helper_page_flip(struct

drm_crtc *crtc,

Quoted 25 lines
drivers/gpu/drm/drm_atomic_helper.c +7 -11
 		return -ENOMEM;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+
 retry:
-	crtc_state = drm_atomic_get_crtc_state(state, crtc);
-	if (IS_ERR(crtc_state)) {
-		ret = PTR_ERR(crtc_state);
+	ret = page_flip_common(state, crtc, fb, event);
+	if (ret != 0)
 		goto fail;
-	}
-	crtc_state->event = event;
 
-	plane_state = drm_atomic_get_plane_state(state, plane);
-	if (IS_ERR(plane_state)) {
-		ret = PTR_ERR(plane_state);
-		goto fail;
-	}
+	ret = drm_atomic_nonblocking_commit(state);
 
-	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+	drm_atomic_state_put(state);
+	return ret;
+
+backoff:
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	/*
+	 * Someone might have exchanged the framebuffer while we

dropped locks

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 11 lines
drivers/gpu/drm/drm_atomic_helper.c +11 -0
+	 * in the backoff code. We need to fix up the fb refcount tracking the
+	 * core does for us.
+	 */
+	plane->old_fb = plane->fb;
+
+	goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+
+/**
+ * drm_atomic_helper_page_flip_target - do page flip on target vblank

period.

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -0
+ * @crtc: DRM crtc
+ * @fb: DRM framebuffer
+ * @event: optional DRM event to signal upon completion
+ * @flags: flip flags for non-vblank sync'ed updates
+ * @target: specifying the target vblank period when the flip to take

effect

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
+ *
+ * Provides a default &drm_crtc_funcs.page_flip_target implementation.
+ * Similar to drm_atomic_helper_page_flip() with extra parameter to

specify

Quoted 26 lines
drivers/gpu/drm/drm_atomic_helper.c +26 -0
+ * target vblank period to flip.
+ *
+ * Returns:
+ * Returns 0 on success, negative errno numbers on failure.
+ */
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target)
+{
+	struct drm_plane *plane = crtc->primary;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
+		return -EINVAL;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -5
+retry:
+	ret = page_flip_common(state, crtc, fb, event);
 	if (ret != 0)
 		goto fail;
-	drm_atomic_set_fb_for_plane(plane_state, fb);
 
-	/* Make sure we don't accidentally do a full modeset. */
-	state->allow_modeset = false;
-	if (!crtc_state->active) {
-		DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy

flip\n",

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 14 lines
drivers/gpu/drm/drm_atomic_helper.c +4 -1
-				 crtc->base.id);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+	if (WARN_ON(!crtc_state)) {
 		ret = -EINVAL;
 		goto fail;
 	}
+	crtc_state->target_vblank = target;
 
 	ret = drm_atomic_nonblocking_commit(state);
+
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -2817,7 +2908,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
 	goto retry;
 }
-EXPORT_SYMBOL(drm_atomic_helper_page_flip);
+EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
 
 /**
  * drm_atomic_helper_connector_dpms() - connector dpms helper

implementation

Review

Quoted 1 line
(quoted diff) +0 -0

b/include/drm/drm_atomic_helper.h

include/drm/drm_atomic_helper.h int drm_atomic_helper_page_flip(struct drm_crtc

Quoted 4 lines

index 7ff92b0..b3b3abe 100644

include/drm/drm_atomic_helper.h +0 -0
@@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc

*crtc,

include/drm/drm_atomic_helper.h int drm_atomic_helper_page_flip(struct drm_crtc *crtc,

Quoted 10 lines
include/drm/drm_atomic_helper.h +6 -0
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
 				uint32_t flags);
+int drm_atomic_helper_page_flip_target(
+				struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags,
+				uint32_t target);
 int drm_atomic_helper_connector_dpms(struct drm_connector

*connector,

Quoted 23 lines
include/drm/drm_atomic_helper.h +0 -0
 				     int mode);
 struct drm_encoder *
include/drm/drm_crtc.h +9 -1
index 946672f..5c77c3f 100644
@@ -157,6 +157,15 @@ struct drm_crtc_state {
 	struct drm_property_blob *gamma_lut;
 
 	/**
+	 * @target_vblank:
+	 *
+	 * Target vertical blank period when a page flip
+	 * should take effect.
+	 */
+
+	u32 target_vblank;
+
+	/**
 	 * @event:
 	 *
 	 * Optional pointer to a DRM event to signal upon completion of the
--
Quoted 2 lines

1.9.1

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#17 lore raw

PATCH 2/2 drm/amd/dal: Switch to page_flip_target hook in DAL.

In reply to Andrey Grodzovsky

This change shows the usage of proposed target_vblank field in drivers using the atomic code path.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +5 -3
index b44cd1a..eba3caa 100644
@@ -1057,7 +1057,8 @@ static int dm_crtc_funcs_atomic_set_property(
 static int amdgpu_atomic_helper_page_flip(struct drm_crtc *crtc,
 				struct drm_framebuffer *fb,
 				struct drm_pending_vblank_event *event,
-				uint32_t flags)
+				uint32_t flags,
+				uint32_t target_vblank)
 {
 	struct drm_plane *plane = crtc->primary;
 	struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
@@ -1078,6 +1079,7 @@ static int amdgpu_atomic_helper_page_flip(struct drm_crtc *crtc,
 		goto fail;
 	}
 	crtc_state->event = event;
+	crtc_state->target_vblank = target_vblank;
 
 	plane_state = drm_atomic_get_plane_state(state, plane);
 	if (IS_ERR(plane_state)) {
@@ -1130,7 +1132,7 @@ static int amdgpu_atomic_helper_page_flip(struct drm_crtc *crtc,
 	.destroy = amdgpu_dm_crtc_destroy,
 	.gamma_set = amdgpu_dm_atomic_crtc_gamma_set,
 	.set_config = drm_atomic_helper_set_config,
-	.page_flip = amdgpu_atomic_helper_page_flip,
+	.page_flip_target = amdgpu_atomic_helper_page_flip,
 	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 	.atomic_set_property = dm_crtc_funcs_atomic_set_property
@@ -2757,7 +2759,7 @@ int amdgpu_dm_atomic_commit(
 							   fb,
 							   crtc->state->event,
 							   acrtc->flip_flags,
-							   drm_crtc_vblank_count(crtc));
+							   crtc->state->target_vblank);
 			/*clean up the flags for next usage*/
 			acrtc->flip_flags = 0;
 			if (ret)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel