[Intel-gfx] [PATCH v3] drm/core: Add drm_accurate_vblank_count, v3.

2016-04-13 Thread kbuild test robot
Hi Maarten,

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.6-rc3 next-20160412]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Maarten-Lankhorst/drm-core-Add-drm_accurate_vblank_count-v3/20160412-223507
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/i915/i915_irq.c:2663: warning: No description found for 
parameter 'fmt'
   include/drm/drm_crtc.h:364: warning: No description found for parameter 
'mode_blob'
   include/drm/drm_crtc.h:779: warning: No description found for parameter 
'name'
   include/drm/drm_crtc.h:1238: warning: No description found for parameter 
'connector_id'
   include/drm/drm_crtc.h:1238: warning: No description found for parameter 
'tile_blob_ptr'
   include/drm/drm_crtc.h:1277: warning: No description found for parameter 
'rotation'
   include/drm/drm_crtc.h:1539: warning: No description found for parameter 
'name'
   include/drm/drm_crtc.h:1539: warning: No description found for parameter 
'mutex'
   include/drm/drm_crtc.h:1539: warning: No description found for parameter 
'helper_private'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tile_idr'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'connector_ida'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'delayed_event'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'edid_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'dpms_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'path_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tile_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'plane_type_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'rotation_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_src_x'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_src_y'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_src_w'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_src_h'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_crtc_x'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_crtc_y'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_crtc_w'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_crtc_h'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_fb_id'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_crtc_id'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_active'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'prop_mode_id'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'dvi_i_subconnector_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'dvi_i_select_subconnector_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_subconnector_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_select_subconnector_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_mode_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_left_margin_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_right_margin_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_top_margin_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_bottom_margin_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_brightness_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_contrast_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_flicker_reduction_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_overscan_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_saturation_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'tv_hue_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'scaling_mode_property'
   include/drm/drm_crtc.h:2175: warning: No description found for parameter 
'aspect_ratio_property'
   include/drm/drm_crtc.h:2175: warning: No 

[PATCH v3] drm/core: Add drm_accurate_vblank_count, v3.

2016-04-12 Thread Ville Syrjälä
On Tue, Apr 12, 2016 at 04:32:19PM +0200, Maarten Lankhorst wrote:
> This function is useful for gen2 intel devices which have no frame
> counter, but need a way to determine the current vblank count without
> racing with the vblank interrupt handler.
> 
> intel_pipe_update_start checks if no vblank interrupt will occur
> during vblank evasion, but cannot check whether the vblank handler has
> run to completion. This function uses the timestamps to determine
> when the last vblank has happened, and interpolates from there.
> 
> Changes since v1:
> - Take vblank_time_lock and don't use drm_vblank_count_and_time.
> Changes since v2:
> - Don't return time of last vblank.
> 
> Cc: Mario Kleiner 
> Cc: Ville Syrjälä 
> Signed-off-by: Maarten Lankhorst 
> ---
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 3c1a6f18e71c..32bfa4bb8f41 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -303,6 +303,32 @@ static void drm_update_vblank_count(struct drm_device 
> *dev, unsigned int pipe,
>   store_vblank(dev, pipe, diff, _vblank, cur_vblank);
>  }
>  
> +/**
> + * drm_accurate_vblank_count - retrieve the master vblank counter
> + * @crtc: which counter to retrieve
> + * @tv_ret: last time counter was updated
> + *
> + * This function is similar to @drm_crtc_vblank_count but this
> + * function interpolates to handle a race with vblank irq's.
> + */
> +
> +u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
> +{
> + struct drm_device *dev = crtc->dev;
> + u32 vblank, pipe = drm_crtc_index(crtc);

pipe should be 'unsigned int' for consistency.

> + unsigned long flags;
> +
> + spin_lock_irqsave(>vblank_time_lock, flags);
> +
> + drm_update_vblank_count(dev, pipe, 0);

One thing that came to mind is some callers might end up doing the
update twice if the irq wasn't yet enabled when drm_vblank_get() was
called. Eg. drm_wait_one_vblank() might do that. So it might be a bit
more efficient to add a drm_vblank_get_and_update() instead, or something
like that. But I don't really care too much.

Reviewed-by: Ville Syrjälä 

> + vblank = dev->vblank[pipe].count;
> +
> + spin_unlock_irqrestore(>vblank_time_lock, flags);
> +
> + return vblank;
> +}
> +EXPORT_SYMBOL(drm_accurate_vblank_count);
> +
>  /*
>   * Disable vblank irq's on crtc, make sure that last vblank count
>   * of hardware and corresponding consistent software vblank counter
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 31483c2fef51..747c80da70e5 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -995,6 +995,7 @@ extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
>  extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
>  extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
>  extern void drm_vblank_cleanup(struct drm_device *dev);
> +extern u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
>  extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int 
> pipe);
>  
>  extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,

-- 
Ville Syrjälä
Intel OTC


[PATCH v3] drm/core: Add drm_accurate_vblank_count, v3.

2016-04-12 Thread Maarten Lankhorst
This function is useful for gen2 intel devices which have no frame
counter, but need a way to determine the current vblank count without
racing with the vblank interrupt handler.

intel_pipe_update_start checks if no vblank interrupt will occur
during vblank evasion, but cannot check whether the vblank handler has
run to completion. This function uses the timestamps to determine
when the last vblank has happened, and interpolates from there.

Changes since v1:
- Take vblank_time_lock and don't use drm_vblank_count_and_time.
Changes since v2:
- Don't return time of last vblank.

Cc: Mario Kleiner 
Cc: Ville Syrjälä 
Signed-off-by: Maarten Lankhorst 
---
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 3c1a6f18e71c..32bfa4bb8f41 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -303,6 +303,32 @@ static void drm_update_vblank_count(struct drm_device 
*dev, unsigned int pipe,
store_vblank(dev, pipe, diff, _vblank, cur_vblank);
 }

+/**
+ * drm_accurate_vblank_count - retrieve the master vblank counter
+ * @crtc: which counter to retrieve
+ * @tv_ret: last time counter was updated
+ *
+ * This function is similar to @drm_crtc_vblank_count but this
+ * function interpolates to handle a race with vblank irq's.
+ */
+
+u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   u32 vblank, pipe = drm_crtc_index(crtc);
+   unsigned long flags;
+
+   spin_lock_irqsave(>vblank_time_lock, flags);
+
+   drm_update_vblank_count(dev, pipe, 0);
+   vblank = dev->vblank[pipe].count;
+
+   spin_unlock_irqrestore(>vblank_time_lock, flags);
+
+   return vblank;
+}
+EXPORT_SYMBOL(drm_accurate_vblank_count);
+
 /*
  * Disable vblank irq's on crtc, make sure that last vblank count
  * of hardware and corresponding consistent software vblank counter
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 31483c2fef51..747c80da70e5 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -995,6 +995,7 @@ extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
 extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
 extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
 extern void drm_vblank_cleanup(struct drm_device *dev);
+extern u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);

 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,