Skip to contentSkip to conversation

Allow ASYNC flip with atomic helpers.

PATCH Superseded Andrey Grodzovsky 3 participants 5 messages Jan 17, 2017 1 message not in the archive

Subsystems (5)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Allow ASYNC flip with atomic helpers.

This series is a folow-up on
https://patchwork.kernel.org/patch/9501787/

The first patch makes changes to atomic helpers to allow for drives with ASYNC flip support to use them.
Patch 2 is to use this in AMDGPU/DC.
Patch 3 is possible cleanup in nouveau/kms who seems to have to duplicate the helper as we did to support ASYNC flips.

v2:
Resend drm/atomic: Save flip flags in drm_plane_state since the original patch was incomplete.
Squash 2 AMD changes into one to not break compilation.

Andrey Grodzovsky (3):
drm/atomic: Save flip flags in drm_plane_state drm/amd/display: Switch to using atomic_helper for flip. drm/nouveau/kms/nv50: Switch to using atomic helper for flip.

 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |  1 -
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    | 92 ++--------------------
 drivers/gpu/drm/drm_atomic_helper.c                | 18 ++---
 drivers/gpu/drm/nouveau/nv50_display.c             | 77 ++----------------
 include/drm/drm_plane.h                            |  8 ++
 5 files changed, 24 insertions(+), 172 deletions(-)
Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1484630207-27366-1-git-send-email-Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH v2 1/3 drm/atomic: Save flip flags in drm_plane_state

Allows using atomic flip helpers for drivers using ASYNC flip.
Remove ASYNC_FLIP restriction in helpers and caches the page flip flags in drm_plane_state to be used in the low level drivers.

v2:
Resending the patch since the original was broken. Remove comment about not supporting ASYNC flips.

Change-Id I0219c3ec3ecceb82143ee176d30cb50d9aa76bf0
---
 drivers/gpu/drm/drm_atomic_helper.c | 18 +++++-------------
 include/drm/drm_plane.h             |  8 ++++++++
 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +5 -13
index a4e5477..12f70f2 100644
@@ -2737,7 +2737,8 @@ 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_pending_vblank_event *event,
+				uint32_t flags)
 {
 	struct drm_plane *plane = crtc->primary;
 	struct drm_plane_state *plane_state;
@@ -2754,6 +2755,7 @@ static int page_flip_common(
 	if (IS_ERR(plane_state))
 		return PTR_ERR(plane_state);
 
+	plane_state->pflip_flags = flags;
 
 	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
 	if (ret != 0)
@@ -2781,10 +2783,6 @@ static int page_flip_common(
  * 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
- * no provisions for this yet.
- *
  * Returns:
  * Returns 0 on success, negative errno numbers on failure.
  *
@@ -2800,9 +2798,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 	struct drm_atomic_state *state;
 	int ret = 0;
 
-	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
-		return -EINVAL;
-
 	state = drm_atomic_state_alloc(plane->dev);
 	if (!state)
 		return -ENOMEM;
@@ -2810,7 +2805,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
 
 retry:
-	ret = page_flip_common(state, crtc, fb, event);
+	ret = page_flip_common(state, crtc, fb, event, flags);
 	if (ret != 0)
 		goto fail;
 
@@ -2865,9 +2860,6 @@ int drm_atomic_helper_page_flip_target(
 	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;
@@ -2875,7 +2867,7 @@ int drm_atomic_helper_page_flip_target(
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
 
 retry:
-	ret = page_flip_common(state, crtc, fb, event);
+	ret = page_flip_common(state, crtc, fb, event, flags);
 	if (ret != 0)
 		goto fail;
 
include/drm/drm_plane.h +8 -0
index db3bbde..86d8ffc 100644
@@ -122,6 +122,14 @@ struct drm_plane_state {
 	 */
 	bool visible;
 
+
+	/**
+	 * @pflip_flags:
+	 *
+	 * Flip related config options
+	 */
+	u32 pflip_flags;
+
 	struct drm_atomic_state *state;
 };
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#3 lore raw
In reply to a message not in the archive

This series is,

Quoted 19 lines · Andrey Grodzovsky

This series is a folow-up on
https://patchwork.kernel.org/patch/9501787/

The first patch makes changes to atomic helpers to allow for drives with ASYNC flip support to use them.
Patch 2 is to use this in AMDGPU/DC.
Patch 3 is possible cleanup in nouveau/kms who seems to have to duplicate the helper as we did to support ASYNC flips.

v2:
Resend drm/atomic: Save flip flags in drm_plane_state since the original patch was incomplete.
Squash 2 AMD changes into one to not break compilation.

Andrey Grodzovsky (3):
drm/atomic: Save flip flags in drm_plane_state drm/amd/display: Switch to using atomic_helper for flip. drm/nouveau/kms/nv50: Switch to using atomic helper for flip.

Quoted 7 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |  1 -
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    | 92 ++--------------------
 drivers/gpu/drm/drm_atomic_helper.c                | 18 ++---
 drivers/gpu/drm/nouveau/nv50_display.c             | 77 ++----------------
 include/drm/drm_plane.h                            |  8 ++
 5 files changed, 24 insertions(+), 172 deletions(-)

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

#4 lore raw

PATCH v2 2/3 drm/amd/display: Switch to using atomic_helper for flip.

In reply to Andrey Grodzovsky
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |  1 -
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    | 92 ++--------------------
 2 files changed, 6 insertions(+), 87 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -1
index 4c0a86e..3ff3c14 100644
@@ -443,7 +443,6 @@ struct amdgpu_crtc {
 	enum amdgpu_interrupt_state vsync_timer_enabled;
 
 	int otg_inst;
-	uint32_t flip_flags;
 	/* After Set Mode target will be non-NULL */
 	struct dc_target *target;
 };
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +6 -86

128 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

PATCH v2 3/3 drm/nouveau/kms/nv50: Switch to using atomic helper for flip.

In reply to Andrey Grodzovsky
Change-Id I5a3189c03e389af2ff6c13d870a7d28282b7b0ee
---
 drivers/gpu/drm/nouveau/nv50_display.c | 77 +++-------------------------------
 1 file changed, 5 insertions(+), 72 deletions(-)
drivers/gpu/drm/nouveau/nv50_display.c +5 -72
index 2c2c645..419e00c 100644
@@ -846,6 +846,10 @@ struct nv50_wndw_func {
 	asyw->image.w = fb->base.width;
 	asyw->image.h = fb->base.height;
 	asyw->image.kind = (fb->nvbo->tile_flags & 0x0000ff00) >> 8;
+
+	asyw->interval =
+			asyw->state.pflip_flags & DRM_MODE_PAGE_FLIP_ASYNC ? 0 : 1;
+
 	if (asyw->image.kind) {
 		asyw->image.layout = 0;
 		if (drm->device.info.chipset >= 0xc0)
@@ -2221,77 +2225,6 @@ struct nv50_base {
 	.atomic_check = nv50_head_atomic_check,
 };
 
-/* This is identical to the version in the atomic helpers, except that
- * it supports non-vblanked ("async") page flips.
- */
-static int
-nv50_head_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
-		    struct drm_pending_vblank_event *event, u32 flags)
-{
-	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;
-
-	state = drm_atomic_state_alloc(plane->dev);
-	if (!state)
-		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);
-		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_set_crtc_for_plane(plane_state, crtc);
-	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);
-		ret = -EINVAL;
-		goto fail;
-	}
-
-	if (flags & DRM_MODE_PAGE_FLIP_ASYNC)
-		nv50_wndw_atom(plane_state)->interval = 0;
-
-	ret = drm_atomic_nonblocking_commit(state);
-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;
-}
-
 static int
 nv50_head_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
 		    uint32_t size)
@@ -2386,7 +2319,7 @@ struct nv50_base {
 	.gamma_set = nv50_head_gamma_set,
 	.destroy = nv50_head_destroy,
 	.set_config = drm_atomic_helper_set_config,
-	.page_flip = nv50_head_page_flip,
+	.page_flip = drm_atomic_helper_page_flip,
 	.set_property = drm_atomic_helper_crtc_set_property,
 	.atomic_duplicate_state = nv50_head_atomic_duplicate_state,
 	.atomic_destroy_state = nv50_head_atomic_destroy_state,
Signature · 6 lines
1.9.1

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