From: Daniel Thompson <daniel.thompson@linaro.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
DRI Development <dri-devel@lists.freedesktop.org>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/atomic-helper: implement ->page_flip
Date: Wed, 05 Nov 2014 11:35:05 +0000 [thread overview]
Message-ID: <545A0B69.8080101@linaro.org> (raw)
In-Reply-To: <1415138972-13178-1-git-send-email-daniel.vetter@ffwll.ch>
On 04/11/14 22:09, Daniel Vetter wrote:
> Currently there is no way to implement async flips using atomic, that
> essentially requires us to be able to cancel pending requests
> mid-flight.
>
> To be able to do that (and I guess we want this since vblank synced
> updates whic opportunistically cancel still pending updates seem to be
> wanted) we'd need to add a mandatory cancellation mode. Depending upon
> the exact semantics we decide upon that could mean that userspace will
> not get completion events, or will get them all stacked up.
>
> So reject async updates for now. Also async updates usually means not
> vblank synced at all, and I guess for drivers which want to support
> this they should simply add a special pageflip handler (since usually
> you need a special flip cmd to achieve this). That kind of async flip
> is pretty much exclusively just used for games and benchmarks where
> dropping just one frame means you'll get a headshot or something bad
> like that ... And so slight amounts of tearing is acceptable.
>
> v2: Fixup kerneldoc, reported by Paulo.
>
> v3: Use the set_crtc_for_plane function to assign the crtc, since
> otherwise the book-keeping is off.
>
> v4: Update crtc->primary->fb since ->page_flip is the only driver
> callback where the core won't do this itself. We might want to fix
> this inconsistency eventually.
>
> v5: Use set_crtc_for_connector as suggested by Sean.
>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Paulo Zanoni <przanoni@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 92 +++++++++++++++++++++++++++++++++++++
> include/drm/drm_atomic_helper.h | 5 ++
> 2 files changed, 97 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 790edc18b2cb..36ccc42d43db 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1633,3 +1633,95 @@ backoff:
> goto retry;
> }
> EXPORT_SYMBOL(drm_atomic_helper_connector_set_property);
> +
> +/**
> + * 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 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(struct drm_crtc *crtc,
> + struct drm_framebuffer *fb,
> + struct drm_pending_vblank_event *event,
> + uint32_t 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;
> +
> + 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:
> + crtc_state = drm_atomic_get_crtc_state(state, crtc);
> + if (IS_ERR(crtc_state)) {
> + ret = PTR_ERR(crtc_state);
> + if (ret == -EDEADLK)
> + goto backoff;
> + else
> + 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);
> + if (ret == -EDEADLK)
> + goto backoff;
> + else
> + goto fail;
> + }
> +
> + ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
> + if (ret == -EDEADLK)
> + goto backoff;
The kerneldoc for this function states that it can return -ENOMEM too
and, even if it didn't, this approach to error handling is potentially
fragile as the kernel changes.
> + plane_state->fb = fb;
> +
> + ret = drm_atomic_async_commit(state);
> + if (ret == -EDEADLK)
> + goto backoff;
A fussy point but this would be easier to read if it followed the same
pattern as the above error checks with a "goto fail". The the success
path below can be outdented and made more obvious.
> +
> + /* Driver takes ownership of state on successful async commit. */
> + if (ret == 0) {
> + /* TODO: ->page_flip is the only driver callback where the core
> + * doesn't update plane->fb. For now patch it up here. */
> + plane->fb = plane->state->fb;
> +
> + return 0;
> + }
> +
> +fail:
> + drm_atomic_state_free(state);
> +
> + return ret;
> +backoff:
> + drm_atomic_legacy_backoff(state);
> + drm_atomic_state_clear(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);
> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> index 8cd6fe7a48e5..28a2f3a815fd 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -69,5 +69,10 @@ int drm_atomic_helper_plane_set_property(struct drm_plane *plane,
> int drm_atomic_helper_connector_set_property(struct drm_connector *connector,
> struct drm_property *property,
> uint64_t val);
> +int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
> + struct drm_framebuffer *fb,
> + struct drm_pending_vblank_event *event,
> + uint32_t flags);
> +
>
> #endif /* DRM_ATOMIC_HELPER_H_ */
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2014-11-05 11:35 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-02 13:19 [PATCH 00/17] atomic modeset core<->driver interfaces and helpers Daniel Vetter
2014-11-02 13:19 ` [PATCH 01/17] drm: Move drm_crtc_init from drm_crtc.h to drm_plane_helper.h Daniel Vetter
2014-11-04 20:31 ` Sean Paul
2014-11-02 13:19 ` [PATCH 02/17] drm: Pull drm_crtc.h into the kerneldoc template Daniel Vetter
2014-11-02 19:18 ` [PATCH] " Daniel Vetter
2014-11-03 3:04 ` Thierry Reding
2014-11-02 13:19 ` [PATCH 03/17] drm: fixup kerneldoc in drm_crtc.h Daniel Vetter
2014-11-02 19:19 ` Daniel Vetter
2014-11-02 13:19 ` [PATCH 04/17] drm/modeset_lock: document trylock_only in kerneldoc Daniel Vetter
2014-11-04 20:31 ` Sean Paul
2014-11-05 16:18 ` Thierry Reding
2014-11-02 13:19 ` [PATCH 05/17] drm: Add atomic driver interface definitions for objects Daniel Vetter
2014-11-04 20:31 ` Sean Paul
2014-11-05 16:26 ` Thierry Reding
2014-11-05 17:04 ` Daniel Vetter
2014-11-05 17:16 ` [Intel-gfx] " Damien Lespiau
2014-11-02 13:19 ` [PATCH 06/17] drm: Global atomic state handling Daniel Vetter
2014-11-03 23:41 ` Matt Roper
2014-11-04 8:40 ` Daniel Vetter
2014-11-04 20:31 ` Sean Paul
2014-11-04 21:30 ` Daniel Vetter
2014-11-04 21:41 ` Daniel Vetter
2014-11-04 21:37 ` [PATCH] " Daniel Vetter
2014-11-04 22:07 ` Daniel Vetter
2014-11-04 22:32 ` Sean Paul
2014-11-05 13:06 ` Ander Conselvan de Oliveira
2014-11-05 13:45 ` Daniel Vetter
2014-11-05 14:22 ` Daniel Vetter
2014-11-05 17:06 ` Daniel Vetter
2015-02-06 9:58 ` [Intel-gfx] " Jani Nikula
2015-02-06 21:14 ` Daniel Vetter
2014-11-02 13:19 ` [PATCH 07/17] drm: Add atomic/plane helpers Daniel Vetter
2014-11-04 22:30 ` Sean Paul
2014-11-04 23:16 ` Daniel Vetter
2014-11-02 13:19 ` [PATCH 08/17] drm/plane-helper: transitional atomic plane helpers Daniel Vetter
2014-11-05 16:45 ` Sean Paul
2014-11-05 16:51 ` Daniel Vetter
2014-11-05 16:59 ` [PATCH] " Daniel Vetter
2014-11-02 13:19 ` [PATCH 09/17] drm/crtc-helper: Transitional functions using " Daniel Vetter
2014-11-05 17:42 ` Sean Paul
2014-11-02 13:19 ` [PATCH 10/17] drm: Atomic crtc/connector updates using crtc/plane helper interfaces Daniel Vetter
2014-11-05 18:53 ` Sean Paul
2014-11-05 21:44 ` Daniel Vetter
2014-11-06 18:28 ` Sean Paul
2014-11-02 13:19 ` [PATCH 11/17] drm/atomic-helper: implementatations for legacy interfaces Daniel Vetter
2014-11-04 22:08 ` [PATCH] " Daniel Vetter
2014-11-05 13:46 ` Daniel Vetter
2014-11-05 19:48 ` Sean Paul
2014-11-05 22:01 ` Daniel Vetter
2014-11-06 18:31 ` Sean Paul
2014-11-02 13:19 ` [PATCH 12/17] drm/atomic: Integrate fence support Daniel Vetter
2014-11-06 17:43 ` [Intel-gfx] " Sean Paul
2014-11-02 13:19 ` [PATCH 13/17] drm/atomic-helpers: document how to implement async commit Daniel Vetter
2014-11-06 17:43 ` Sean Paul
2014-11-02 13:19 ` [PATCH 14/17] drm/atomic-helper: implement ->page_flip Daniel Vetter
2014-11-04 22:09 ` [PATCH] " Daniel Vetter
2014-11-05 11:35 ` Daniel Thompson [this message]
2014-11-05 13:46 ` Daniel Vetter
2014-11-06 17:43 ` [PATCH 14/17] " Sean Paul
2014-11-06 18:13 ` Daniel Vetter
2014-11-06 18:53 ` Sean Paul
2014-11-02 13:19 ` [PATCH 15/17] drm/atomic-helpers: functions for state duplicate/destroy/reset Daniel Vetter
2014-11-03 14:45 ` Daniel Thompson
2014-11-03 14:53 ` Daniel Vetter
2014-11-03 15:06 ` Daniel Thompson
2014-11-03 15:11 ` Daniel Vetter
2014-11-06 17:43 ` Sean Paul
2014-11-06 19:57 ` Daniel Vetter
2014-11-06 20:01 ` Sean Paul
2014-11-06 19:55 ` [PATCH] " Daniel Vetter
2014-11-02 13:19 ` [PATCH 16/17] drm: Docbook integration and over sections for all the new helpers Daniel Vetter
2014-11-06 17:43 ` Sean Paul
2014-11-06 20:00 ` [PATCH] " Daniel Vetter
2014-11-06 20:02 ` Sean Paul
2014-11-02 13:19 ` [PATCH 17/17] drm/atomic: Refcounting for plane_state->fb Daniel Vetter
2014-11-04 21:57 ` [PATCH] " Daniel Vetter
2014-11-06 17:44 ` [PATCH 17/17] " Sean Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=545A0B69.8080101@linaro.org \
--to=daniel.thompson@linaro.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox