public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: ville.syrjala@linux.intel.com
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 7/9] drm: Disable vblank interrupt immediately when drm_vblank_offdelay==0
Date: Mon, 26 May 2014 15:02:28 +0200	[thread overview]
Message-ID: <20140526130228.GH14357@phenom.ffwll.local> (raw)
In-Reply-To: <1401104792-26560-8-git-send-email-ville.syrjala@linux.intel.com>

On Mon, May 26, 2014 at 02:46:30PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Make drm_vblank_put() disable the vblank interrupt immediately when the
> refcount drops to zero and drm_vblank_offdelay==0.
> 
> Currently drm_vblank_put() would just leave vblank interrupts enabled all
> the time if drm_vblank_offdelay==0. In case someone might still want that
> behaviour drm_vblank_offdelay is now signed and a negative value will
> allow the user to keep vblank interrupts on all the time. Well, since
> the first drm_vblank_get() anyway.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I think what we actually want is a new dev->vblank_is_race_free or
something which is a boolean. Then we can keep the drm_vblank_offdelay
as-is and seletively kill the entire logic for drivers where this works
correctly.
-Daniel

> ---
>  Documentation/DocBook/drm.tmpl          |  1 +
>  drivers/gpu/drm/drm_irq.c               | 11 +++++++----
>  drivers/gpu/drm/drm_stub.c              |  4 ++--
>  drivers/gpu/drm/exynos/exynos_drm_drv.h |  2 +-
>  include/drm/drmP.h                      |  2 +-
>  5 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 9574bf2..25632b0 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2508,6 +2508,7 @@ void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis>
>        by scheduling a timer. The delay is accessible through the vblankoffdelay
>        module parameter or the <varname>drm_vblank_offdelay</varname> global
>        variable and expressed in milliseconds. Its default value is 5000 ms.
> +      Zero means disable immediately, and a negative value means never disable.
>      </para>
>      <para>
>        When a vertical blanking interrupt occurs drivers only need to call the
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 54cb85d..54a56b2 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -978,10 +978,13 @@ void drm_vblank_put(struct drm_device *dev, int crtc)
>  	BUG_ON(atomic_read(&dev->vblank[crtc].refcount) == 0);
>  
>  	/* Last user schedules interrupt disable */
> -	if (atomic_dec_and_test(&dev->vblank[crtc].refcount) &&
> -	    (drm_vblank_offdelay > 0))
> -		mod_timer(&dev->vblank[crtc].disable_timer,
> -			  jiffies + ((drm_vblank_offdelay * HZ)/1000));
> +	if (atomic_dec_and_test(&dev->vblank[crtc].refcount)) {
> +		if (drm_vblank_offdelay > 0)
> +			mod_timer(&dev->vblank[crtc].disable_timer,
> +				  jiffies + ((drm_vblank_offdelay * HZ)/1000));
> +		else if (drm_vblank_offdelay == 0)
> +			vblank_disable_fn((unsigned long)&dev->vblank[crtc]);
> +	}
>  }
>  EXPORT_SYMBOL(drm_vblank_put);
>  
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index 3727ac8..8758f81 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -49,7 +49,7 @@ EXPORT_SYMBOL(drm_rnodes);
>  unsigned int drm_universal_planes = 0;
>  EXPORT_SYMBOL(drm_universal_planes);
>  
> -unsigned int drm_vblank_offdelay = 5000;    /* Default to 5000 msecs. */
> +int drm_vblank_offdelay = 5000;    /* Default to 5000 msecs. */
>  EXPORT_SYMBOL(drm_vblank_offdelay);
>  
>  unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
> @@ -66,7 +66,7 @@ MODULE_DESCRIPTION(CORE_DESC);
>  MODULE_LICENSE("GPL and additional rights");
>  MODULE_PARM_DESC(debug, "Enable debug output");
>  MODULE_PARM_DESC(rnodes, "Enable experimental render nodes API");
> -MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs]");
> +MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] (< 0 means never disable)");
>  MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]");
>  MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");
>  
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index ce3e6a3..9734bec 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -40,7 +40,7 @@ struct drm_device;
>  struct exynos_drm_overlay;
>  struct drm_connector;
>  
> -extern unsigned int drm_vblank_offdelay;
> +extern int drm_vblank_offdelay;
>  
>  /* this enumerates display type. */
>  enum exynos_drm_output_type {
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 76ccaab..979a498 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1404,7 +1404,7 @@ extern unsigned int drm_debug;
>  extern unsigned int drm_rnodes;
>  extern unsigned int drm_universal_planes;
>  
> -extern unsigned int drm_vblank_offdelay;
> +extern int drm_vblank_offdelay;
>  extern unsigned int drm_timestamp_precision;
>  extern unsigned int drm_timestamp_monotonic;
>  
> -- 
> 1.8.5.5
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

  reply	other threads:[~2014-05-26 13:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 11:46 [PATCH 0/9] drm: More vblank on/off work ville.syrjala
2014-05-26 11:46 ` [PATCH 1/9] drm: Always reject drm_vblank_get() after drm_vblank_off() ville.syrjala
2014-05-26 13:21   ` Daniel Vetter
2014-05-26 13:32     ` Ville Syrjälä
2014-05-26 13:47       ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 2/9] drm/i915: Warn if drm_vblank_get() still works " ville.syrjala
2014-05-26 13:22   ` Daniel Vetter
2014-05-26 13:36     ` Ville Syrjälä
2014-05-26 13:48       ` Daniel Vetter
2014-05-26 13:49     ` [PATCH v2 " ville.syrjala
2014-05-26 13:54       ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 3/9] drm: Don't clear vblank timestamps when vblank interrupt is disabled ville.syrjala
2014-05-26 13:24   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 4/9] drm: Move drm_update_vblank_count() ville.syrjala
2014-05-26 11:46 ` [PATCH 5/9] drm: Have the vblank counter account for the time between vblank irq disable and drm_vblank_off() ville.syrjala
2014-05-26 13:27   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 6/9] drm: Avoid random vblank counter jumps if the hardware counter has been reset ville.syrjala
2014-05-26 13:28   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH 7/9] drm: Disable vblank interrupt immediately when drm_vblank_offdelay==0 ville.syrjala
2014-05-26 13:02   ` Daniel Vetter [this message]
2014-05-26 14:26     ` [PATCH 10/9] drm: Add dev->vblank_disable_immediate flag ville.syrjala
2014-05-26 14:26       ` [PATCH 11/9] drm/i915: Opt out of vblank disable timer on >gen2 ville.syrjala
2014-05-26 15:31         ` Daniel Vetter
2014-05-26 19:27         ` Daniel Vetter
2015-11-19 19:44         ` [Intel-gfx] " Paulo Zanoni
2015-11-19 20:06           ` Ville Syrjälä
2015-11-19 20:35             ` Paulo Zanoni
2015-11-19 20:53               ` Ville Syrjälä
2015-11-19 21:15                 ` Ville Syrjälä
2015-11-19 21:27             ` [Intel-gfx] " Chris Wilson
2014-06-20  0:41       ` [PATCH 10/9] drm: Add dev->vblank_disable_immediate flag Matt Roper
2014-07-29 17:31         ` [Intel-gfx] " Ville Syrjälä
2014-07-29 17:57           ` Daniel Vetter
2014-05-26 16:06     ` [PATCH v2 1/9] drm: Always reject drm_vblank_get() after drm_vblank_off() ville.syrjala
2014-05-26 11:46 ` [PATCH 8/9] drm: Reduce the amount of dev->vblank[crtc] in the code ville.syrjala
2014-05-26 13:31   ` Daniel Vetter
2014-05-26 11:46 ` [PATCH v2 9/9] drm/i915: Leave interrupts enabled while disabling crtcs during suspend ville.syrjala
2014-05-26 15:49   ` Daniel Vetter
2014-06-20 18:10   ` Matt Roper
2014-06-02  8:15 ` [PATCH 12/9] drm: Fix deadlock between event_lock and vbl_lock/vblank_time_lock ville.syrjala
2014-06-02  8:15   ` [PATCH 13/9] drm: Fix race between drm_vblank_off() and drm_queue_vblank_event() ville.syrjala
2014-06-02  8:15   ` [PATCH 14/9] drm: Kick start vblank interrupts at drm_vblank_on() ville.syrjala
2014-06-20 18:29     ` Matt Roper
2014-06-26 16:32 ` [PATCH 0/9] drm: More vblank on/off work Jesse Barnes

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=20140526130228.GH14357@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.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