Skip to contentSkip to conversation

drm: Stop using drm_vblank_count() as the hw frame counter

PATCH In review [email protected] 5 participants 21 messages Sep 30, 2015 – Oct 7, 2015

Subsystems (17)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm: Stop using drm_vblank_count() as the hw frame counter

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
 	.lastclose		= armada_drm_lastclose,
 	.unload			= armada_drm_unload,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= armada_drm_enable_vblank,
 	.disable_vblank		= armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
 	.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
 	.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
 	.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = atmel_hlcdc_dc_enable_vblank,
 	.disable_vblank = atmel_hlcdc_dc_disable_vblank,
 	.gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
 	return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+	return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
 	.lastclose		= exynos_drm_lastclose,
 	.postclose		= exynos_drm_postclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= exynos_drm_crtc_enable_vblank,
 	.disable_vblank		= exynos_drm_crtc_disable_vblank,
 	.gem_free_object	= exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
 	.unload			= fsl_dcu_unload,
 	.preclose		= fsl_dcu_drm_preclose,
 	.irq_handler		= fsl_dcu_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= fsl_dcu_drm_enable_vblank,
 	.disable_vblank		= fsl_dcu_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
 	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
 	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
 	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= imx_drm_enable_vblank,
 	.disable_vblank		= imx_drm_disable_vblank,
 	.ioctls			= imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
 	.irq_preinstall     = msm_irq_preinstall,
 	.irq_postinstall    = msm_irq_postinstall,
 	.irq_uninstall      = msm_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = msm_enable_vblank,
 	.disable_vblank     = msm_disable_vblank,
 	.gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
 	.debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
 	.preclose = dev_preclose,
 	.postclose = dev_postclose,
 	.set_busid = drm_platform_set_busid,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = omap_irq_enable_vblank,
 	.disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
 	.preclose		= rcar_du_preclose,
 	.lastclose		= rcar_du_lastclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rcar_du_enable_vblank,
 	.disable_vblank		= rcar_du_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
 	.load			= rockchip_drm_load,
 	.unload			= rockchip_drm_unload,
 	.lastclose		= rockchip_drm_lastclose,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rockchip_drm_crtc_enable_vblank,
 	.disable_vblank		= rockchip_drm_crtc_disable_vblank,
 	.gem_vm_ops		= &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
 	.preclose		= shmob_drm_preclose,
 	.set_busid		= drm_platform_set_busid,
 	.irq_handler		= shmob_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= shmob_drm_enable_vblank,
 	.disable_vblank		= shmob_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
 	.dumb_destroy = drm_gem_dumb_destroy,
 	.fops = &sti_driver_fops,
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = sti_crtc_enable_vblank,
 	.disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
 	.irq_preinstall     = tilcdc_irq_preinstall,
 	.irq_postinstall    = tilcdc_irq_postinstall,
 	.irq_uninstall      = tilcdc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = tilcdc_enable_vblank,
 	.disable_vblank     = tilcdc_disable_vblank,
 	.gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -0
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 						 unsigned int pipe, int *max_error,
Signature · 6 lines
2.4.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 drm: s/int pipe/unsigned int pipe/

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/drm_irq.c | 2 +-
 include/drm/drmP.h        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
  * Returns:
  * The software vblank counter.
  */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +1 -1
index f563333..8df4de7 100644
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
 extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
 extern int drm_wait_vblank(struct drm_device *dev, void *data,
 			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
 extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 				     struct timeval *vblanktime);
Signature · 6 lines
2.4.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 2/2] drm: s/int pipe/unsigned int pipe/

Hi,

Quoted 32 lines · On 09/30/2015 03:46 PM, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
  drivers/gpu/drm/drm_irq.c | 2 +-
  include/drm/drmP.h        | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
   * Returns:
   * The software vblank counter.
   */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
  {
  	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +0 -0
index f563333..8df4de7 100644

include/drm/drmP.h extern int drm_irq_uninstall(struct drm_device *dev); · line 934

Quoted 8 lines
include/drm/drmP.h +1 -1
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
  extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
  extern int drm_wait_vblank(struct drm_device *dev, void *data,
  			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
  extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
  extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
  				     struct timeval *vblanktime);

If you update drm_vblank_count you also need to update drm_vblank_no_hw_counter and need to change the u32 (*get_vblank_counter) prototype.

Thierry already done the job with "drm/irq: Use unsigned int pipe in public API" patch

BR
Vincent
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH 2/2] drm: s/int pipe/unsigned int pipe/

Quoted 40 lines · Vincent ABRIOU

Hi,

Quoted 37 lines · On 09/30/2015 03:46 PM, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
  drivers/gpu/drm/drm_irq.c | 2 +-
  include/drm/drmP.h        | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
   * Returns:
   * The software vblank counter.
   */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
  {
  	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +1 -1
index f563333..8df4de7 100644
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
  extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
  extern int drm_wait_vblank(struct drm_device *dev, void *data,
  			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
  extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
Quoted 8 lines

include/drm/drmP.h extern int drm_irq_uninstall(struct drm_device *dev); · line 934

Quoted 3 lines
include/drm/drmP.h +0 -0
  extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
  				     struct timeval *vblanktime);

If you update drm_vblank_count you also need to update drm_vblank_no_hw_counter and need to change the u32 (*get_vblank_counter) prototype.

No. drm_vblank_count() != .get_vblank_counter()

Quoted 3 lines

Thierry already done the job with "drm/irq: Use unsigned int pipe in public API" patch

Yes I know. Except all the driver hooks still have signed ints. I looked at changing that, and it looked like quite a bit of work, so probably a job for coccinelle. I wonder if it has a way to figure out which functions are plugged into these hooks and do the job entirely automatically...

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH 2/2] drm: s/int pipe/unsigned int pipe/

Quoted 50 lines · Ville Syrjälä
Quoted 40 lines · Vincent ABRIOU

Hi,

Quoted 37 lines · On 09/30/2015 03:46 PM, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
   drivers/gpu/drm/drm_irq.c | 2 +-
   include/drm/drmP.h        | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
    * Returns:
    * The software vblank counter.
    */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
   {
   	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +1 -1
index f563333..8df4de7 100644
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
   extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
   extern int drm_wait_vblank(struct drm_device *dev, void *data,
   			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
   extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
Quoted 8 lines

include/drm/drmP.h extern int drm_irq_uninstall(struct drm_device *dev); · line 934

Quoted 3 lines
include/drm/drmP.h +0 -0
   extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
   				     struct timeval *vblanktime);

If you update drm_vblank_count you also need to update drm_vblank_no_hw_counter and need to change the u32 (*get_vblank_counter) prototype.

Quoted 1 line

No. drm_vblank_count() != .get_vblank_counter()

I surely miss something but before your patch in drivers that did not support hw vblank counter we had:
.get_vblank_counter = drm_vblank_count;

Quoted 11 lines
Quoted 4 lines

Thierry already done the job with "drm/irq: Use unsigned int pipe in public API" patch

Yes I know. Except all the driver hooks still have signed ints. I looked at changing that, and it looked like quite a bit of work, so probably a job for coccinelle. I wonder if it has a way to figure out which functions are plugged into these hooks and do the job entirely automatically...

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Re: [PATCH 2/2] drm: s/int pipe/unsigned int pipe/

Quoted 53 lines · Vincent ABRIOU
Quoted 50 lines · Ville Syrjälä
Quoted 48 lines · Vincent ABRIOU

Hi,

Quoted 32 lines · On 09/30/2015 03:46 PM, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
   drivers/gpu/drm/drm_irq.c | 2 +-
   include/drm/drmP.h        | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
    * Returns:
    * The software vblank counter.
    */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
   {
   	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +0 -0
index f563333..8df4de7 100644

include/drm/drmP.h extern int drm_irq_uninstall(struct drm_device *dev); · line 934

Quoted 8 lines
include/drm/drmP.h +1 -1
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
   extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
   extern int drm_wait_vblank(struct drm_device *dev, void *data,
   			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
   extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
   extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
   				     struct timeval *vblanktime);

If you update drm_vblank_count you also need to update drm_vblank_no_hw_counter and need to change the u32 (*get_vblank_counter) prototype.

Quoted 5 lines
Quoted 1 line

No. drm_vblank_count() != .get_vblank_counter()

I surely miss something but before your patch in drivers that did not support hw vblank counter we had:
.get_vblank_counter = drm_vblank_count;

That was what patch 1/2 fixed.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by
#6 lore raw

Re: [PATCH 2/2] drm: s/int pipe/unsigned int pipe/

Quoted 54 lines · Ville Syrjälä
Quoted 53 lines · Vincent ABRIOU
Quoted 50 lines · Ville Syrjälä
Quoted 48 lines · Vincent ABRIOU

Hi,

Quoted 32 lines · On 09/30/2015 03:46 PM, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
    drivers/gpu/drm/drm_irq.c | 2 +-
    include/drm/drmP.h        | 2 +-
    2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
     * Returns:
     * The software vblank counter.
     */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
    {
    	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +0 -0
index f563333..8df4de7 100644

include/drm/drmP.h extern int drm_irq_uninstall(struct drm_device *dev); · line 934

Quoted 8 lines
include/drm/drmP.h +1 -1
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
    extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
    extern int drm_wait_vblank(struct drm_device *dev, void *data,
    			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
    extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
    extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
    				     struct timeval *vblanktime);

If you update drm_vblank_count you also need to update drm_vblank_no_hw_counter and need to change the u32 (*get_vblank_counter) prototype.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

No. drm_vblank_count() != .get_vblank_counter()

I surely miss something but before your patch in drivers that did not support hw vblank counter we had:
.get_vblank_counter = drm_vblank_count;

That was what patch 1/2 fixed.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH 2/2] drm: s/int pipe/unsigned int pipe/

In reply to Ville Syrjälä
Quoted 53 lines · Ville Syrjälä
Quoted 40 lines · Vincent ABRIOU

Hi,

Quoted 37 lines · On 09/30/2015 03:46 PM, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make the 'pipe' argument to drm_vblank_count() unsigned as it is everwhere else.

Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
  drivers/gpu/drm/drm_irq.c | 2 +-
  include/drm/drmP.h        | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -1
index 7d70b7c..f24c57c 100644
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
   * Returns:
   * The software vblank counter.
   */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
  {
  	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
include/drm/drmP.h +1 -1
index f563333..8df4de7 100644
@@ -928,7 +928,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
  extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
  extern int drm_wait_vblank(struct drm_device *dev, void *data,
  			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
  extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
Quoted 8 lines

include/drm/drmP.h extern int drm_irq_uninstall(struct drm_device *dev); · line 934

Quoted 3 lines
include/drm/drmP.h +0 -0
  extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
  				     struct timeval *vblanktime);

If you update drm_vblank_count you also need to update drm_vblank_no_hw_counter and need to change the u32 (*get_vblank_counter) prototype.

No. drm_vblank_count() != .get_vblank_counter()

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Thierry already done the job with "drm/irq: Use unsigned int pipe in public API" patch

Yes I know. Except all the driver hooks still have signed ints. I looked at changing that, and it looked like quite a bit of work, so probably a job for coccinelle. I wonder if it has a way to figure out which functions are plugged into these hooks and do the job entirely automatically...

Actually the above-mentioned patch updated drivers as well, otherwise there would've been tons of warnings from mismatched types.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional? -Daniel

Quoted 235 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
 	.lastclose		= armada_drm_lastclose,
 	.unload			= armada_drm_unload,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= armada_drm_enable_vblank,
 	.disable_vblank		= armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
 	.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
 	.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
 	.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = atmel_hlcdc_dc_enable_vblank,
 	.disable_vblank = atmel_hlcdc_dc_disable_vblank,
 	.gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
 	return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+	return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
 	.lastclose		= exynos_drm_lastclose,
 	.postclose		= exynos_drm_postclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= exynos_drm_crtc_enable_vblank,
 	.disable_vblank		= exynos_drm_crtc_disable_vblank,
 	.gem_free_object	= exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
 	.unload			= fsl_dcu_unload,
 	.preclose		= fsl_dcu_drm_preclose,
 	.irq_handler		= fsl_dcu_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= fsl_dcu_drm_enable_vblank,
 	.disable_vblank		= fsl_dcu_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
 	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
 	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
 	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= imx_drm_enable_vblank,
 	.disable_vblank		= imx_drm_disable_vblank,
 	.ioctls			= imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
 	.irq_preinstall     = msm_irq_preinstall,
 	.irq_postinstall    = msm_irq_postinstall,
 	.irq_uninstall      = msm_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = msm_enable_vblank,
 	.disable_vblank     = msm_disable_vblank,
 	.gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
 	.debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
 	.preclose = dev_preclose,
 	.postclose = dev_postclose,
 	.set_busid = drm_platform_set_busid,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = omap_irq_enable_vblank,
 	.disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
 	.preclose		= rcar_du_preclose,
 	.lastclose		= rcar_du_lastclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rcar_du_enable_vblank,
 	.disable_vblank		= rcar_du_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
 	.load			= rockchip_drm_load,
 	.unload			= rockchip_drm_unload,
 	.lastclose		= rockchip_drm_lastclose,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rockchip_drm_crtc_enable_vblank,
 	.disable_vblank		= rockchip_drm_crtc_disable_vblank,
 	.gem_vm_ops		= &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
 	.preclose		= shmob_drm_preclose,
 	.set_busid		= drm_platform_set_busid,
 	.irq_handler		= shmob_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= shmob_drm_enable_vblank,
 	.disable_vblank		= shmob_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
 	.dumb_destroy = drm_gem_dumb_destroy,
 	.fops = &sti_driver_fops,
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = sti_crtc_enable_vblank,
 	.disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
 	.irq_preinstall     = tilcdc_irq_preinstall,
 	.irq_postinstall    = tilcdc_irq_postinstall,
 	.irq_uninstall      = tilcdc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = tilcdc_enable_vblank,
 	.disable_vblank     = tilcdc_disable_vblank,
 	.gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -0
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 						 unsigned int pipe, int *max_error,
Signature · 6 lines
2.4.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 242 lines

-Daniel

Quoted 235 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
 	.lastclose		= armada_drm_lastclose,
 	.unload			= armada_drm_unload,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= armada_drm_enable_vblank,
 	.disable_vblank		= armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
 	.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
 	.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
 	.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = atmel_hlcdc_dc_enable_vblank,
 	.disable_vblank = atmel_hlcdc_dc_disable_vblank,
 	.gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
 	return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+	return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
 	.lastclose		= exynos_drm_lastclose,
 	.postclose		= exynos_drm_postclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= exynos_drm_crtc_enable_vblank,
 	.disable_vblank		= exynos_drm_crtc_disable_vblank,
 	.gem_free_object	= exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
 	.unload			= fsl_dcu_unload,
 	.preclose		= fsl_dcu_drm_preclose,
 	.irq_handler		= fsl_dcu_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= fsl_dcu_drm_enable_vblank,
 	.disable_vblank		= fsl_dcu_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
 	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
 	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
 	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= imx_drm_enable_vblank,
 	.disable_vblank		= imx_drm_disable_vblank,
 	.ioctls			= imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
 	.irq_preinstall     = msm_irq_preinstall,
 	.irq_postinstall    = msm_irq_postinstall,
 	.irq_uninstall      = msm_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = msm_enable_vblank,
 	.disable_vblank     = msm_disable_vblank,
 	.gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
 	.debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
 	.preclose = dev_preclose,
 	.postclose = dev_postclose,
 	.set_busid = drm_platform_set_busid,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = omap_irq_enable_vblank,
 	.disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
 	.preclose		= rcar_du_preclose,
 	.lastclose		= rcar_du_lastclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rcar_du_enable_vblank,
 	.disable_vblank		= rcar_du_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
 	.load			= rockchip_drm_load,
 	.unload			= rockchip_drm_unload,
 	.lastclose		= rockchip_drm_lastclose,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rockchip_drm_crtc_enable_vblank,
 	.disable_vblank		= rockchip_drm_crtc_disable_vblank,
 	.gem_vm_ops		= &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
 	.preclose		= shmob_drm_preclose,
 	.set_busid		= drm_platform_set_busid,
 	.irq_handler		= shmob_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= shmob_drm_enable_vblank,
 	.disable_vblank		= shmob_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
 	.dumb_destroy = drm_gem_dumb_destroy,
 	.fops = &sti_driver_fops,
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = sti_crtc_enable_vblank,
 	.disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
 	.irq_preinstall     = tilcdc_irq_preinstall,
 	.irq_postinstall    = tilcdc_irq_postinstall,
 	.irq_uninstall      = tilcdc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = tilcdc_enable_vblank,
 	.disable_vblank     = tilcdc_disable_vblank,
 	.gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -0
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 						 unsigned int pipe, int *max_error,
Signature · 6 lines
2.4.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw
Quoted 24 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: mercredi 30 septembre 2015 16:15
To: Daniel Vetter
Cc: Thierry Reding; [email protected]
Subject: Re: [PATCH 1/2] drm: Stop using drm_vblank_count() as the hw frame counter

Quoted 1 line · Daniel Vetter

On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected]

Quoted 10 lines · wrote:
Quoted 9 lines

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function
drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Quoted 4 lines
Quoted 1 line

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

I agree, I think it is better to have such explicit helpers.
Going into that warning make me check if the STI hardware has such vblank hw counter.

Vincent

Quoted 257 lines
Quoted 50 lines

-Daniel

Quoted 47 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
 	.lastclose		= armada_drm_lastclose,
 	.unload			= armada_drm_unload,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= armada_drm_enable_vblank,
 	.disable_vblank		= armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
 	.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
 	.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
 	.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
Quoted 8 lines

drivers/gpu/drm/drm_irq.c bool drm_crtc_handle_vblank(struct drm_crtc

Quoted 8 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +0 -0
 	.enable_vblank = atmel_hlcdc_dc_enable_vblank,
 	.disable_vblank = atmel_hlcdc_dc_disable_vblank,
 	.gem_free_object = drm_gem_cma_free_object, diff --git

a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index ed2394e..7d70b7c 100644

drivers/gpu/drm/drm_irq.c +0 -0
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc

*crtc)

Quoted 92 lines
Quoted 92 lines
drivers/gpu/drm/drm_irq.c +17 -0
 	return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));  }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of
+.get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe) {
+	return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
 	.lastclose		= exynos_drm_lastclose,
 	.postclose		= exynos_drm_postclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= exynos_drm_crtc_enable_vblank,
 	.disable_vblank		= exynos_drm_crtc_disable_vblank,
 	.gem_free_object	= exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
 	.unload			= fsl_dcu_unload,
 	.preclose		= fsl_dcu_drm_preclose,
 	.irq_handler		= fsl_dcu_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= fsl_dcu_drm_enable_vblank,
 	.disable_vblank		= fsl_dcu_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
 	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
 	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
 	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= imx_drm_enable_vblank,
 	.disable_vblank		= imx_drm_disable_vblank,
 	.ioctls			= imx_drm_ioctls,
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_drv.c index 0339c5d..3eba23f 100644

drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
 	.irq_preinstall     = msm_irq_preinstall,
 	.irq_postinstall    = msm_irq_postinstall,
 	.irq_uninstall      = msm_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = msm_enable_vblank,
 	.disable_vblank     = msm_disable_vblank,
 	.gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
 	.debugfs_cleanup = nouveau_debugfs_takedown,  #endif
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
 	.get_scanout_position = nouveau_display_scanoutpos, diff --git

a/drivers/gpu/drm/omapdrm/omap_drv.c
b/drivers/gpu/drm/omapdrm/omap_drv.c
index d685e23..4d58934 100644

drivers/gpu/drm/omapdrm/omap_drv.c +0 -0
Quoted 8 lines

drivers/gpu/drm/omapdrm/omap_drv.c static struct drm_driver omap_drm_driver = { · line 844

Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
 	.preclose = dev_preclose,
 	.postclose = dev_postclose,
 	.set_busid = drm_platform_set_busid,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = omap_irq_enable_vblank,
 	.disable_vblank = omap_irq_disable_vblank,  #ifdef

CONFIG_DEBUG_FS

Quoted 80 lines
Quoted 80 lines
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
 	.preclose		= rcar_du_preclose,
 	.lastclose		= rcar_du_lastclose,
 	.set_busid		= drm_platform_set_busid,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rcar_du_enable_vblank,
 	.disable_vblank		= rcar_du_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
 	.load			= rockchip_drm_load,
 	.unload			= rockchip_drm_unload,
 	.lastclose		= rockchip_drm_lastclose,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= rockchip_drm_crtc_enable_vblank,
 	.disable_vblank		= rockchip_drm_crtc_disable_vblank,
 	.gem_vm_ops		= &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
 	.preclose		= shmob_drm_preclose,
 	.set_busid		= drm_platform_set_busid,
 	.irq_handler		= shmob_drm_irq,
-	.get_vblank_counter	= drm_vblank_count,
+	.get_vblank_counter	= drm_vblank_no_hw_counter,
 	.enable_vblank		= shmob_drm_enable_vblank,
 	.disable_vblank		= shmob_drm_disable_vblank,
 	.gem_free_object	= drm_gem_cma_free_object,
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_drv.c index 9f85988..f846996 100644

drivers/gpu/drm/sti/sti_drv.c +1 -1
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
 	.dumb_destroy = drm_gem_dumb_destroy,
 	.fops = &sti_driver_fops,
 
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank = sti_crtc_enable_vblank,
 	.disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
 	.irq_preinstall     = tilcdc_irq_preinstall,
 	.irq_postinstall    = tilcdc_irq_postinstall,
 	.irq_uninstall      = tilcdc_irq_uninstall,
-	.get_vblank_counter = drm_vblank_count,
+	.get_vblank_counter = drm_vblank_no_hw_counter,
 	.enable_vblank      = tilcdc_enable_vblank,
 	.disable_vblank     = tilcdc_disable_vblank,
 	.gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h index renamed from include/drm/drmP.h +0 -0

d0251ac..f563333 100644

include/drm/drmP.h +0 -0
@@ -952,6 +952,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);

include/drm/drmP.h +2 -0
+extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, int
+pipe);
Quoted 1 line
Quoted 1 line

extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device

*dev,

Quoted 1 line
Quoted 1 line

unsigned int pipe, int

*max_error,

Quoted 8 lines
Quoted 7 lines

--
2.4.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 7 lines

--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Tested-by
#11 lore raw
In reply to Ville Syrjälä
Quoted 11 lines · Ville Syrjälä
Quoted 10 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Quoted 17 lines
Quoted 1 line

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 12 lines

-Daniel

Quoted 10 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
  drivers/gpu/drm/armada/armada_drv.c          |  2 +-
  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
  drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
  drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-

The 2 patches have been successfully tested on next-20151001. The warning message is gone and hw vblank counter stucks to 0.

Thanks for the patches

Vincent
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw
In reply to Ville Syrjälä
Quoted 11 lines · Ville Syrjälä
Quoted 10 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Quoted 4 lines
Quoted 1 line

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Well, I guess at this point we have more drm/kms drivers for hw without hw frame counters.. maybe a helper that guestimates based on time elapsed since last vbl irq would be useful..

BR,
-R

Quoted 243 lines
Quoted 233 lines

-Daniel

Quoted 231 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
    .lastclose              = armada_drm_lastclose,
    .unload                 = armada_drm_unload,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = armada_drm_enable_vblank,
    .disable_vblank         = armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
    .irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
    .irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
    .irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = atmel_hlcdc_dc_enable_vblank,
    .disable_vblank = atmel_hlcdc_dc_disable_vblank,
    .gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
    return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+   return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
    .lastclose              = exynos_drm_lastclose,
    .postclose              = exynos_drm_postclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = exynos_drm_crtc_enable_vblank,
    .disable_vblank         = exynos_drm_crtc_disable_vblank,
    .gem_free_object        = exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
    .unload                 = fsl_dcu_unload,
    .preclose               = fsl_dcu_drm_preclose,
    .irq_handler            = fsl_dcu_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = fsl_dcu_drm_enable_vblank,
    .disable_vblank         = fsl_dcu_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
    .gem_prime_vmap         = drm_gem_cma_prime_vmap,
    .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
    .gem_prime_mmap         = drm_gem_cma_prime_mmap,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = imx_drm_enable_vblank,
    .disable_vblank         = imx_drm_disable_vblank,
    .ioctls                 = imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
    .irq_preinstall     = msm_irq_preinstall,
    .irq_postinstall    = msm_irq_postinstall,
    .irq_uninstall      = msm_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = msm_enable_vblank,
    .disable_vblank     = msm_disable_vblank,
    .gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
    .debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = nouveau_display_vblank_enable,
    .disable_vblank = nouveau_display_vblank_disable,
    .get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
    .preclose = dev_preclose,
    .postclose = dev_postclose,
    .set_busid = drm_platform_set_busid,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = omap_irq_enable_vblank,
    .disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
    .preclose               = rcar_du_preclose,
    .lastclose              = rcar_du_lastclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rcar_du_enable_vblank,
    .disable_vblank         = rcar_du_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
    .load                   = rockchip_drm_load,
    .unload                 = rockchip_drm_unload,
    .lastclose              = rockchip_drm_lastclose,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rockchip_drm_crtc_enable_vblank,
    .disable_vblank         = rockchip_drm_crtc_disable_vblank,
    .gem_vm_ops             = &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
    .preclose               = shmob_drm_preclose,
    .set_busid              = drm_platform_set_busid,
    .irq_handler            = shmob_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = shmob_drm_enable_vblank,
    .disable_vblank         = shmob_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
    .dumb_destroy = drm_gem_dumb_destroy,
    .fops = &sti_driver_fops,
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = sti_crtc_enable_vblank,
    .disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
    .irq_preinstall     = tilcdc_irq_preinstall,
    .irq_postinstall    = tilcdc_irq_postinstall,
    .irq_uninstall      = tilcdc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = tilcdc_enable_vblank,
    .disable_vblank     = tilcdc_disable_vblank,
    .gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -1
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
                                             unsigned int pipe, int *max_error,
--

2.4.6

Quoted 9 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 7 lines

--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw
Quoted 13 lines · Rob Clark
Quoted 11 lines · Ville Syrjälä
Quoted 10 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Well, I guess at this point we have more drm/kms drivers for hw without hw frame counters.. maybe a helper that guestimates based on time elapsed since last vbl irq would be useful..

That's already being done for the sw counter.

Quoted 254 lines

BR,
-R

Quoted 250 lines
Quoted 233 lines

-Daniel

Quoted 231 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
    .lastclose              = armada_drm_lastclose,
    .unload                 = armada_drm_unload,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = armada_drm_enable_vblank,
    .disable_vblank         = armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
    .irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
    .irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
    .irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = atmel_hlcdc_dc_enable_vblank,
    .disable_vblank = atmel_hlcdc_dc_disable_vblank,
    .gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
    return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+   return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
    .lastclose              = exynos_drm_lastclose,
    .postclose              = exynos_drm_postclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = exynos_drm_crtc_enable_vblank,
    .disable_vblank         = exynos_drm_crtc_disable_vblank,
    .gem_free_object        = exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
    .unload                 = fsl_dcu_unload,
    .preclose               = fsl_dcu_drm_preclose,
    .irq_handler            = fsl_dcu_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = fsl_dcu_drm_enable_vblank,
    .disable_vblank         = fsl_dcu_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
    .gem_prime_vmap         = drm_gem_cma_prime_vmap,
    .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
    .gem_prime_mmap         = drm_gem_cma_prime_mmap,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = imx_drm_enable_vblank,
    .disable_vblank         = imx_drm_disable_vblank,
    .ioctls                 = imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
    .irq_preinstall     = msm_irq_preinstall,
    .irq_postinstall    = msm_irq_postinstall,
    .irq_uninstall      = msm_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = msm_enable_vblank,
    .disable_vblank     = msm_disable_vblank,
    .gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
    .debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = nouveau_display_vblank_enable,
    .disable_vblank = nouveau_display_vblank_disable,
    .get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
    .preclose = dev_preclose,
    .postclose = dev_postclose,
    .set_busid = drm_platform_set_busid,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = omap_irq_enable_vblank,
    .disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
    .preclose               = rcar_du_preclose,
    .lastclose              = rcar_du_lastclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rcar_du_enable_vblank,
    .disable_vblank         = rcar_du_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
    .load                   = rockchip_drm_load,
    .unload                 = rockchip_drm_unload,
    .lastclose              = rockchip_drm_lastclose,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rockchip_drm_crtc_enable_vblank,
    .disable_vblank         = rockchip_drm_crtc_disable_vblank,
    .gem_vm_ops             = &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
    .preclose               = shmob_drm_preclose,
    .set_busid              = drm_platform_set_busid,
    .irq_handler            = shmob_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = shmob_drm_enable_vblank,
    .disable_vblank         = shmob_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
    .dumb_destroy = drm_gem_dumb_destroy,
    .fops = &sti_driver_fops,
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = sti_crtc_enable_vblank,
    .disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
    .irq_preinstall     = tilcdc_irq_preinstall,
    .irq_postinstall    = tilcdc_irq_postinstall,
    .irq_uninstall      = tilcdc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = tilcdc_enable_vblank,
    .disable_vblank     = tilcdc_disable_vblank,
    .gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -1
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
                                             unsigned int pipe, int *max_error,
--

2.4.6

Quoted 9 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw
Quoted 16 lines · Ville Syrjälä
Quoted 15 lines · Rob Clark
Quoted 13 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Well, I guess at this point we have more drm/kms drivers for hw without hw frame counters.. maybe a helper that guestimates based on time elapsed since last vbl irq would be useful..

That's already being done for the sw counter.

... assuming you have accurate vbl timestamps that is.

Quoted 263 lines
Quoted 255 lines

BR,
-R

Quoted 250 lines
Quoted 233 lines

-Daniel

Quoted 231 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
    .lastclose              = armada_drm_lastclose,
    .unload                 = armada_drm_unload,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = armada_drm_enable_vblank,
    .disable_vblank         = armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
    .irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
    .irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
    .irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = atmel_hlcdc_dc_enable_vblank,
    .disable_vblank = atmel_hlcdc_dc_disable_vblank,
    .gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
    return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+   return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
    .lastclose              = exynos_drm_lastclose,
    .postclose              = exynos_drm_postclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = exynos_drm_crtc_enable_vblank,
    .disable_vblank         = exynos_drm_crtc_disable_vblank,
    .gem_free_object        = exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
    .unload                 = fsl_dcu_unload,
    .preclose               = fsl_dcu_drm_preclose,
    .irq_handler            = fsl_dcu_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = fsl_dcu_drm_enable_vblank,
    .disable_vblank         = fsl_dcu_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
    .gem_prime_vmap         = drm_gem_cma_prime_vmap,
    .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
    .gem_prime_mmap         = drm_gem_cma_prime_mmap,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = imx_drm_enable_vblank,
    .disable_vblank         = imx_drm_disable_vblank,
    .ioctls                 = imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
    .irq_preinstall     = msm_irq_preinstall,
    .irq_postinstall    = msm_irq_postinstall,
    .irq_uninstall      = msm_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = msm_enable_vblank,
    .disable_vblank     = msm_disable_vblank,
    .gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
    .debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = nouveau_display_vblank_enable,
    .disable_vblank = nouveau_display_vblank_disable,
    .get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
    .preclose = dev_preclose,
    .postclose = dev_postclose,
    .set_busid = drm_platform_set_busid,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = omap_irq_enable_vblank,
    .disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
    .preclose               = rcar_du_preclose,
    .lastclose              = rcar_du_lastclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rcar_du_enable_vblank,
    .disable_vblank         = rcar_du_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
    .load                   = rockchip_drm_load,
    .unload                 = rockchip_drm_unload,
    .lastclose              = rockchip_drm_lastclose,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rockchip_drm_crtc_enable_vblank,
    .disable_vblank         = rockchip_drm_crtc_disable_vblank,
    .gem_vm_ops             = &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
    .preclose               = shmob_drm_preclose,
    .set_busid              = drm_platform_set_busid,
    .irq_handler            = shmob_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = shmob_drm_enable_vblank,
    .disable_vblank         = shmob_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
    .dumb_destroy = drm_gem_dumb_destroy,
    .fops = &sti_driver_fops,
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = sti_crtc_enable_vblank,
    .disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
    .irq_preinstall     = tilcdc_irq_preinstall,
    .irq_postinstall    = tilcdc_irq_postinstall,
    .irq_uninstall      = tilcdc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = tilcdc_enable_vblank,
    .disable_vblank     = tilcdc_disable_vblank,
    .gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -1
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
                                             unsigned int pipe, int *max_error,
--

2.4.6

Quoted 9 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw
Quoted 20 lines · Ville Syrjälä
Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Rob Clark
Quoted 15 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Well, I guess at this point we have more drm/kms drivers for hw without hw frame counters.. maybe a helper that guestimates based on time elapsed since last vbl irq would be useful..

That's already being done for the sw counter.

... assuming you have accurate vbl timestamps that is.

yeah.. the set of drivers supporting drv->get_vblank_timestamp() is even smaller than the ones supporting drv->get_vblank_counter() ;-)

That all said, I think msm/mdp5 could actually support ->get_vblank_counter(), and I think even ->get_scanout_position() and
therefore ->get_vblank_timestamp().. but afaict mdp4 does not have
any line and frame count registers. And iirc, omap did not.. and I'd guess a lot of the other small embedded and mobile display controller blocks out there do not..

BR,
-R

Quoted 260 lines
Quoted 252 lines
Quoted 244 lines
Quoted 244 lines
Quoted 243 lines

-Daniel

Quoted 231 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c          |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
 drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-
 drivers/gpu/drm/msm/msm_drv.c                |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c        |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c           |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  2 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  2 +-
 drivers/gpu/drm/sti/sti_drv.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  2 +-
 include/drm/drmP.h                           |  1 +
 15 files changed, 31 insertions(+), 13 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +1 -1
index 225034b..464a13f 100644
@@ -300,7 +300,7 @@ static struct drm_driver armada_drm_driver = {
    .lastclose              = armada_drm_lastclose,
    .unload                 = armada_drm_unload,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = armada_drm_enable_vblank,
    .disable_vblank         = armada_drm_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +1 -1
index 8bc62ec..2eb1c66 100644
@@ -697,7 +697,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
    .irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
    .irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
    .irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = atmel_hlcdc_dc_enable_vblank,
    .disable_vblank = atmel_hlcdc_dc_disable_vblank,
    .gem_free_object = drm_gem_cma_free_object,
drivers/gpu/drm/drm_irq.c +17 -0
index ed2394e..7d70b7c 100644
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
    return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)
+{
+   return 0;
+}
+EXPORT_SYMBOL(drm_vblank_no_hw_counter);
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -1
index f0a5839..fb9cfc5 100644
@@ -447,7 +447,7 @@ static struct drm_driver exynos_drm_driver = {
    .lastclose              = exynos_drm_lastclose,
    .postclose              = exynos_drm_postclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = exynos_drm_crtc_enable_vblank,
    .disable_vblank         = exynos_drm_crtc_disable_vblank,
    .gem_free_object        = exynos_drm_gem_free_object,
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -1
index 9a8e2da..1f4e8b9 100644
@@ -192,7 +192,7 @@ static struct drm_driver fsl_dcu_drm_driver = {
    .unload                 = fsl_dcu_unload,
    .preclose               = fsl_dcu_drm_preclose,
    .irq_handler            = fsl_dcu_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = fsl_dcu_drm_enable_vblank,
    .disable_vblank         = fsl_dcu_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/imx/imx-drm-core.c +1 -1
index 74f505b..18a6642 100644
@@ -487,7 +487,7 @@ static struct drm_driver imx_drm_driver = {
    .gem_prime_vmap         = drm_gem_cma_prime_vmap,
    .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
    .gem_prime_mmap         = drm_gem_cma_prime_mmap,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = imx_drm_enable_vblank,
    .disable_vblank         = imx_drm_disable_vblank,
    .ioctls                 = imx_drm_ioctls,
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 0339c5d..3eba23f 100644
@@ -978,7 +978,7 @@ static struct drm_driver msm_driver = {
    .irq_preinstall     = msm_irq_preinstall,
    .irq_postinstall    = msm_irq_postinstall,
    .irq_uninstall      = msm_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = msm_enable_vblank,
    .disable_vblank     = msm_disable_vblank,
    .gem_free_object    = msm_gem_free_object,
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -1
index ccefb64..2416c7d 100644
@@ -934,7 +934,7 @@ driver_stub = {
    .debugfs_cleanup = nouveau_debugfs_takedown,
 #endif
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = nouveau_display_vblank_enable,
    .disable_vblank = nouveau_display_vblank_disable,
    .get_scanout_position = nouveau_display_scanoutpos,
drivers/gpu/drm/omapdrm/omap_drv.c +1 -1
index d685e23..4d58934 100644
@@ -839,7 +839,7 @@ static struct drm_driver omap_drm_driver = {
    .preclose = dev_preclose,
    .postclose = dev_postclose,
    .set_busid = drm_platform_set_busid,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = omap_irq_enable_vblank,
    .disable_vblank = omap_irq_disable_vblank,
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -1
index 780ca11..3608e88 100644
@@ -259,7 +259,7 @@ static struct drm_driver rcar_du_driver = {
    .preclose               = rcar_du_preclose,
    .lastclose              = rcar_du_lastclose,
    .set_busid              = drm_platform_set_busid,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rcar_du_enable_vblank,
    .disable_vblank         = rcar_du_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
index 9a0c291..b468add 100644
@@ -277,7 +277,7 @@ static struct drm_driver rockchip_drm_driver = {
    .load                   = rockchip_drm_load,
    .unload                 = rockchip_drm_unload,
    .lastclose              = rockchip_drm_lastclose,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = rockchip_drm_crtc_enable_vblank,
    .disable_vblank         = rockchip_drm_crtc_disable_vblank,
    .gem_vm_ops             = &rockchip_drm_vm_ops,
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
index 666321d..108a03b 100644
@@ -269,7 +269,7 @@ static struct drm_driver shmob_drm_driver = {
    .preclose               = shmob_drm_preclose,
    .set_busid              = drm_platform_set_busid,
    .irq_handler            = shmob_drm_irq,
-   .get_vblank_counter     = drm_vblank_count,
+   .get_vblank_counter     = drm_vblank_no_hw_counter,
    .enable_vblank          = shmob_drm_enable_vblank,
    .disable_vblank         = shmob_drm_disable_vblank,
    .gem_free_object        = drm_gem_cma_free_object,
drivers/gpu/drm/sti/sti_drv.c +1 -1
index 9f85988..f846996 100644
@@ -201,7 +201,7 @@ static struct drm_driver sti_driver = {
    .dumb_destroy = drm_gem_dumb_destroy,
    .fops = &sti_driver_fops,
 
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank = sti_crtc_enable_vblank,
    .disable_vblank = sti_crtc_disable_vblank,
 
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 0f283a3..7e0b0c5 100644
@@ -563,7 +563,7 @@ static struct drm_driver tilcdc_driver = {
    .irq_preinstall     = tilcdc_irq_preinstall,
    .irq_postinstall    = tilcdc_irq_postinstall,
    .irq_uninstall      = tilcdc_irq_uninstall,
-   .get_vblank_counter = drm_vblank_count,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
    .enable_vblank      = tilcdc_enable_vblank,
    .disable_vblank     = tilcdc_disable_vblank,
    .gem_free_object    = drm_gem_cma_free_object,
include/drm/drmP.h +1 -1
index d0251ac..f563333 100644
@@ -952,6 +952,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_vblank_no_hw_counter(struct drm_device *dev, int pipe);
 
 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
                                             unsigned int pipe, int *max_error,
--

2.4.6

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 7 lines
Quoted 7 lines

--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 7 lines

--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 3 lines

--
Ville Syrjälä
Intel OTC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#16 lore raw
In reply to Ville Syrjälä
Quoted 29 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 13 lines

-Daniel

Quoted 11 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
  drivers/gpu/drm/armada/armada_drv.c          |  2 +-
  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
  drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
  drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
  drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-

[..]

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/drm_irq.c +5 -0
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
     return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
  }
  EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_irq.c bool drm_crtc_handle_vblank(struct drm_crtc *crtc) · line 1812

Quoted 8 lines
drivers/gpu/drm/drm_irq.c +8 -0
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)

warning when building the kernel:
int pipe => unsigned int pipe

BR
Vincent
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw
Quoted 49 lines · Vincent ABRIOU
Quoted 29 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 13 lines

-Daniel

Quoted 11 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
  drivers/gpu/drm/armada/armada_drv.c          |  2 +-
  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
  drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
  drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
  drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-

[..]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/drm_irq.c +8 -0
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
     return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
  }
  EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_irq.c bool drm_crtc_handle_vblank(struct drm_crtc *crtc) · line 1812

Quoted 5 lines
drivers/gpu/drm/drm_irq.c +5 -0
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)

warning when building the kernel:
int pipe => unsigned int pipe

Where exactly? The function pointer signature still has a signed int here, and I was too lazy to go on a rampage to change all the remaining signed ints to unsigned for the vblank driver hooks.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw
Quoted 59 lines · Ville Syrjälä
Quoted 49 lines · Vincent ABRIOU
Quoted 29 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 13 lines

-Daniel

Quoted 11 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
   drivers/gpu/drm/armada/armada_drv.c          |  2 +-
   drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
   drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
   drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
   drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-

[..]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/drm_irq.c +8 -0
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
      return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
   }
   EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_irq.c bool drm_crtc_handle_vblank(struct drm_crtc *crtc) · line 1812

Quoted 5 lines
drivers/gpu/drm/drm_irq.c +5 -0
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)

warning when building the kernel:
int pipe => unsigned int pipe

Quoted 4 lines

Where exactly? The function pointer signature still has a signed int here, and I was too lazy to go on a rampage to change all the remaining signed ints to unsigned for the vblank driver hooks.

I made the comment on the wrong patch. Sorry for that. It concern "[PATCH 2/2] drm: s/int pipe/unsigned int pipe/"

Vincent
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by
#19 lore raw
In reply to Ville Syrjälä
Quoted 59 lines · Ville Syrjälä
Quoted 49 lines · Vincent ABRIOU
Quoted 29 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 13 lines

-Daniel

Quoted 11 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
   drivers/gpu/drm/armada/armada_drv.c          |  2 +-
   drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
   drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
   drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
   drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-

[..]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/drm_irq.c +8 -0
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
      return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
   }
   EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_irq.c bool drm_crtc_handle_vblank(struct drm_crtc *crtc) · line 1812

Quoted 5 lines
drivers/gpu/drm/drm_irq.c +5 -0
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)

warning when building the kernel:
int pipe => unsigned int pipe

Quoted 4 lines

Where exactly? The function pointer signature still has a signed int here, and I was too lazy to go on a rampage to change all the remaining signed ints to unsigned for the vblank driver hooks.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

Since I already applied Thierry's interface change I've added the unsigned here as a fixup and dropped patch 2 (since I have that already).

Thanks, Daniel

Quoted 66 lines · Vincent ABRIOU
Quoted 63 lines · Ville Syrjälä
Quoted 49 lines · Vincent ABRIOU
Quoted 29 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Wed, Sep 30, 2015 at 04:46:48PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

drm_vblank_count() returns the software counter. We should not pretend it's the hw counter since we use the hw counter to figuere out what the software counter value should be. So instead provide a new function drm_vblank_no_hw_counter() for drivers that don't have a real hw counter. The new function simply returns 0, which is about the only thing it can do.

Shouldn't we instead just make the get_vblank_counter hook optional?

Perhaps. But maybe this way would encourage people to go look for a hw frame counter in their hardware?

Quoted 13 lines

-Daniel

Quoted 11 lines
Cc Vincent Abriou <[email protected]>
Cc Thierry Reding <[email protected]>
---
   drivers/gpu/drm/armada/armada_drv.c          |  2 +-
   drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  2 +-
   drivers/gpu/drm/drm_irq.c                    | 17 +++++++++++++++++
   drivers/gpu/drm/exynos/exynos_drm_drv.c      |  2 +-
   drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  2 +-
   drivers/gpu/drm/imx/imx-drm-core.c           |  2 +-

[..]

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/drm_irq.c +8 -0
@@ -1797,3 +1797,20 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
      return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
   }
   EXPORT_SYMBOL(drm_crtc_handle_vblank);
+
+/**
+ * drm_vblank_no_hw_counter - "No hw counter" implementation of .get_vblank_counter()
+ * @dev: DRM device
+ * @pipe: CRTC for which to read the counter
+ *
+ * Drivers can plug this into the .get_vblank_counter() function if
+ * there is no useable hardware frame counter available.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_irq.c bool drm_crtc_handle_vblank(struct drm_crtc *crtc) · line 1812

Quoted 5 lines
drivers/gpu/drm/drm_irq.c +5 -0
+ *
+ * Returns:
+ * 0
+ */
+u32 drm_vblank_no_hw_counter(struct drm_device *dev, int pipe)

warning when building the kernel:
int pipe => unsigned int pipe

Where exactly? The function pointer signature still has a signed int here, and I was too lazy to go on a rampage to change all the remaining signed ints to unsigned for the vblank driver hooks.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel