AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Michel Dänzer" <michel@daenzer.net>
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/6] drm: Add page_flip_target CRTC hook
Date: Thu, 4 Aug 2016 12:47:38 +0200	[thread overview]
Message-ID: <20160804104738.GF6232@phenom.ffwll.local> (raw)
In-Reply-To: <1470281981-18172-2-git-send-email-michel@daenzer.net>

On Thu, Aug 04, 2016 at 12:39:36PM +0900, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
> 
> Mostly the same as the existing page_flip hook, but takes an additional
> parameter specifying the target vertical blank period when the flip
> should take effect.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++----
>  include/drm/drm_crtc.h     | 14 ++++++++++++++
>  2 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 9d3f80e..15ad7e2 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5421,6 +5421,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	struct drm_crtc *crtc;
>  	struct drm_framebuffer *fb = NULL;
>  	struct drm_pending_vblank_event *e = NULL;
> +	u32 target_vblank = 0;
>  	int ret = -EINVAL;
>  
>  	if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
> @@ -5434,6 +5435,18 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	if (!crtc)
>  		return -ENOENT;
>  
> +	if (crtc->funcs->page_flip_target) {
> +		int r;
> +
> +		r = drm_crtc_vblank_get(crtc);

This leaks when e.g framebuffer_lookup fails.
-Daniel

> +		if (r)
> +			return r;
> +
> +		target_vblank = drm_crtc_vblank_count(crtc) +
> +			!(page_flip->flags & DRM_MODE_PAGE_FLIP_ASYNC);
> +	} else if (crtc->funcs->page_flip == NULL)
> +		return -EINVAL;
> +
>  	drm_modeset_lock_crtc(crtc, crtc->primary);
>  	if (crtc->primary->fb == NULL) {
>  		/* The framebuffer is currently unbound, presumably
> @@ -5444,9 +5457,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  		goto out;
>  	}
>  
> -	if (crtc->funcs->page_flip == NULL)
> -		goto out;
> -
>  	fb = drm_framebuffer_lookup(dev, page_flip->fb_id);
>  	if (!fb) {
>  		ret = -ENOENT;
> @@ -5487,7 +5497,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	}
>  
>  	crtc->primary->old_fb = crtc->primary->fb;
> -	ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags);
> +	if (crtc->funcs->page_flip_target)
> +		ret = crtc->funcs->page_flip_target(crtc, fb, e,
> +						    page_flip->flags,
> +						    target_vblank);
> +	else
> +		ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags);
>  	if (ret) {
>  		if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
>  			drm_event_cancel_free(dev, &e->base);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 9e6ab4a..ae1d9b6 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -579,6 +579,20 @@ struct drm_crtc_funcs {
>  			 uint32_t flags);
>  
>  	/**
> +	 * @page_flip_target:
> +	 *
> +	 * Same as @page_flip but with an additional parameter specifying the
> +	 * target vertical blank period when the flip should take effect.
> +	 *
> +	 * Note that the core code calls drm_crtc_vblank_get before this entry
> +	 * point.

I think you should add "Drivers must drop that reference again by calling
drm_crtc_vblank_put()."

It's a bit icky that we have this difference (both compared to old page
flip, but also atomic doesn't grab a vblank reference either). But really
can't be avoided, at least if we implement the relative mode.
-Daniel

> +	 */
> +	int (*page_flip_target)(struct drm_crtc *crtc,
> +				struct drm_framebuffer *fb,
> +				struct drm_pending_vblank_event *event,
> +				uint32_t flags, uint32_t target);
> +
> +	/**
>  	 * @set_property:
>  	 *
>  	 * This is the legacy entry point to update a property attached to the
> -- 
> 2.8.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-08-04 10:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  3:39 [PATCH 0/6] drm: Explicit target vblank seqno for page flips Michel Dänzer
2016-08-04  3:39 ` [PATCH 3/6] drm/amdgpu: Set MASTER_UPDATE_MODE to 0 again Michel Dänzer
     [not found] ` <1470281981-18172-1-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-04  3:39   ` [PATCH 1/6] drm: Add page_flip_target CRTC hook Michel Dänzer
2016-08-04 10:47     ` Daniel Vetter [this message]
2016-08-04 11:01       ` Daniel Vetter
     [not found]         ` <20160804110116.GI6232-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2016-08-08  3:54           ` Michel Dänzer
2016-08-08  8:14             ` Daniel Vetter
     [not found]     ` <1470281981-18172-2-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-04 15:13       ` Alex Deucher
     [not found]         ` <CADnq5_OeoXDYnjAwnQCY9RXwqMo8eQ8LqWgUOeC0tgjH1b6M_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-08  3:33           ` Michel Dänzer
2016-08-08  7:23       ` [PATCH 1/6] drm: Add page_flip_target CRTC hook v2 Michel Dänzer
2016-08-04  3:39   ` [PATCH 2/6] drm/amdgpu: Provide page_flip_target hook Michel Dänzer
2016-08-04  3:39   ` [PATCH 4/6] drm/radeon: " Michel Dänzer
2016-08-16  0:35     ` Mario Kleiner
     [not found]       ` <dccd9347-afc4-83a6-8014-20692e71fd03-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-16  1:49         ` Michel Dänzer
2016-09-17 12:41           ` Mario Kleiner
     [not found]             ` <b00edbdc-c467-3f33-5a07-32def2961190-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-20  2:59               ` Michel Dänzer
2016-08-04  3:39   ` [PATCH 5/6] drm/radeon: Set MASTER_UPDATE_MODE to 0 again Michel Dänzer
2016-08-04  3:39   ` [PATCH 6/6] drm: Add DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags Michel Dänzer
2016-08-04  7:42     ` Ville Syrjälä
     [not found]       ` <20160804074205.GY4329-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-08-08  7:06         ` Michel Dänzer
2016-08-04 10:56     ` Daniel Vetter
     [not found]       ` <20160804105609.GG6232-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2016-08-08  6:53         ` Michel Dänzer
2016-08-08  7:23     ` [PATCH 6/6] drm: Add DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags v2 Michel Dänzer
2016-08-16  1:32       ` Mario Kleiner
     [not found]         ` <8974b919-6f9c-5912-0d26-f1a526829f83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-16  1:46           ` Michel Dänzer
2016-09-08  9:36             ` Pekka Paalanen
2016-08-04  7:38   ` [PATCH 0/6] drm: Explicit target vblank seqno for page flips Christian König
2016-08-04  9:51 ` Daniel Stone
2016-08-04 10:01   ` Michel Dänzer
2016-08-04 10:12     ` Daniel Stone
2016-08-04 11:15       ` Ville Syrjälä
     [not found]       ` <CAPj87rPO-QbyhmBy2p3XASqNdzrm3hmw0EsLLJYB2K4bBvTTrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-08  3:53         ` Michel Dänzer
2016-08-04 15:16 ` Alex Deucher

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=20160804104738.GF6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /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