dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: hamohammed.sa@gmail.com, airlied@linux.ie,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org, alexandre.torgue@st.com,
	thellstrom@vmware.com, sean@poorly.run,
	linux-graphics-maintainer@vmware.com, bskeggs@redhat.com,
	mcoquelin.stm32@gmail.com, sunpeng.li@amd.com,
	linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	rodrigo.vivi@intel.com, vincent.abriou@st.com,
	rodrigosiqueiramelo@gmail.com, philippe.cornu@st.com,
	yannick.fertre@st.com, alexander.deucher@amd.com,
	freedreno@lists.freedesktop.org, christian.koenig@amd.com
Subject: Re: [Intel-gfx] [PATCH v2 02/21] drm: Evaluate struct drm_device.vblank_disable_immediate on each use
Date: Wed, 15 Jan 2020 16:37:57 +0200	[thread overview]
Message-ID: <20200115143757.GZ13686@intel.com> (raw)
In-Reply-To: <20200115121652.7050-3-tzimmermann@suse.de>

On Wed, Jan 15, 2020 at 01:16:33PM +0100, Thomas Zimmermann wrote:
> VBLANK interrupts can be disabled immediately or with a delay, where the
> latter is the default. The former option can be selected by setting
> get_vblank_timestamp, and enabling vblank_disable_immediate in struct
> drm_device.
> 
> The setup is only evaluated once when DRM initializes VBLANKs. Evaluating
> the settings on each use of vblank_disable_immediate will allow for easy
> integration of CRTC VBLANK functions.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  drivers/gpu/drm/drm_vblank.c | 31 ++++++++++++++-----------------
>  1 file changed, 14 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 3f1dd54cc8bb..abb085c67d82 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -481,19 +481,6 @@ int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs)
>  
>  	DRM_INFO("Supports vblank timestamp caching Rev 2 (21.10.2013).\n");
>  
> -	/* Driver specific high-precision vblank timestamping supported? */
> -	if (dev->driver->get_vblank_timestamp)
> -		DRM_INFO("Driver supports precise vblank timestamp query.\n");
> -	else
> -		DRM_INFO("No driver support for vblank timestamp query.\n");
> -
> -	/* Must have precise timestamping for reliable vblank instant disable */
> -	if (dev->vblank_disable_immediate && !dev->driver->get_vblank_timestamp) {
> -		dev->vblank_disable_immediate = false;
> -		DRM_INFO("Setting vblank_disable_immediate to false because "
> -			 "get_vblank_timestamp == NULL\n");
> -	}

Which drivers are so broken they set vblank_disable_immediate to true
without having the vfunc specified? IMO this code should just go away
(or converted to a WARN).

> -
>  	return 0;
>  
>  err:
> @@ -1070,6 +1057,15 @@ int drm_crtc_vblank_get(struct drm_crtc *crtc)
>  }
>  EXPORT_SYMBOL(drm_crtc_vblank_get);
>  
> +static bool __vblank_disable_immediate(struct drm_device *dev, unsigned int pipe)
> +{
> +	if (!dev->vblank_disable_immediate)
> +		return false;
> +	if (!dev->driver->get_vblank_timestamp)
> +		return false;
> +	return true;
> +}
> +
>  static void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
> @@ -1086,7 +1082,7 @@ static void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
>  			return;
>  		else if (drm_vblank_offdelay < 0)
>  			vblank_disable_fn(&vblank->disable_timer);
> -		else if (!dev->vblank_disable_immediate)
> +		else if (__vblank_disable_immediate(dev, pipe))
>  			mod_timer(&vblank->disable_timer,
>  				  jiffies + ((drm_vblank_offdelay * HZ)/1000));
>  	}
> @@ -1663,7 +1659,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
>  	/* If the counter is currently enabled and accurate, short-circuit
>  	 * queries to return the cached timestamp of the last vblank.
>  	 */
> -	if (dev->vblank_disable_immediate &&
> +	if (__vblank_disable_immediate(dev, pipe) &&
>  	    drm_wait_vblank_is_query(vblwait) &&
>  	    READ_ONCE(vblank->enabled)) {
>  		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
> @@ -1820,7 +1816,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe)
>  	 * been signaled. The disable has to be last (after
>  	 * drm_handle_vblank_events) so that the timestamp is always accurate.
>  	 */
> -	disable_irq = (dev->vblank_disable_immediate &&
> +	disable_irq = (__vblank_disable_immediate(dev, pipe) &&
>  		       drm_vblank_offdelay > 0 &&
>  		       !atomic_read(&vblank->refcount));
>  
> @@ -1893,7 +1889,8 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
>  	pipe = drm_crtc_index(crtc);
>  
>  	vblank = &dev->vblank[pipe];
> -	vblank_enabled = dev->vblank_disable_immediate && READ_ONCE(vblank->enabled);
> +	vblank_enabled = __vblank_disable_immediate(dev, pipe) &&
> +			 READ_ONCE(vblank->enabled);
>  
>  	if (!vblank_enabled) {
>  		ret = drm_crtc_vblank_get(crtc);
> -- 
> 2.24.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-01-15 14:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 12:16 [PATCH v2 00/21] drm: Clean up VBLANK callbacks in struct drm_driver Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 01/21] drm: Add get_scanout_position() to struct drm_crtc_helper_funcs Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 02/21] drm: Evaluate struct drm_device.vblank_disable_immediate on each use Thomas Zimmermann
2020-01-15 14:37   ` Ville Syrjälä [this message]
2020-01-16  8:03     ` [Intel-gfx] " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 03/21] drm: Add get_vblank_timestamp() to struct drm_crtc_funcs Thomas Zimmermann
2020-01-15 14:49   ` [Intel-gfx] " Ville Syrjälä
2020-01-16  8:44     ` Thomas Zimmermann
2020-01-16 11:21       ` Ville Syrjälä
2020-01-15 12:16 ` [PATCH v2 04/21] drm/amdgpu: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 05/21] drm/amdgpu: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 06/21] drm/gma500: " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 07/21] drm/i915: " Thomas Zimmermann
2020-01-15 12:38   ` Jani Nikula
2020-01-15 15:11   ` Ville Syrjälä
2020-01-15 12:16 ` [PATCH v2 08/21] drm/nouveau: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 09/21] drm/nouveau: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 10/21] drm/radeon: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 11/21] drm/radeon: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 12/21] drm/msm: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 13/21] drm/msm: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 14/21] drm/stm: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 15/21] drm/stm: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 16/21] drm/sti: " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 17/21] drm/vc4: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 18/21] drm/vc4: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 19/21] drm/vkms: " Thomas Zimmermann
2020-01-15 23:18   ` Rodrigo Siqueira
2020-01-17 13:22     ` Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 20/21] drm/vmwgfx: " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 21/21] drm: Clean-up VBLANK-related callbacks in struct drm_driver Thomas Zimmermann

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=20200115143757.GZ13686@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=alexandre.torgue@st.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=philippe.cornu@st.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=rodrigosiqueiramelo@gmail.com \
    --cc=sean@poorly.run \
    --cc=sunpeng.li@amd.com \
    --cc=thellstrom@vmware.com \
    --cc=tzimmermann@suse.de \
    --cc=vincent.abriou@st.com \
    --cc=yannick.fertre@st.com \
    /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;
as well as URLs for NNTP newsgroup(s).