Hi

Am 10.11.25 um 17:17 schrieb Jani Nikula:
Use the vblank pointer instead of a dev, pipe pair to simplify code.

I always thought the code could benefit from this change. Great to see it happen.


Signed-off-by: Jani Nikula <[email protected]>

Reviewed-by: Thomas Zimmermann <[email protected]>

For this patch and the others, I assume that some interfaces might change there names as we discussed.

---
  drivers/gpu/drm/drm_vblank.c | 21 +++++++++++----------
  1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 0ae34f848660..d2748ed01c34 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -292,10 +292,11 @@ static void drm_reset_vblank_timestamp(struct drm_device 
*dev, unsigned int pipe
   * Note: caller must hold &drm_device.vbl_lock since this reads & writes
   * device vblank fields.
   */
-static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
+static void drm_update_vblank_count(struct drm_vblank_crtc *vblank,
                                    bool in_vblank_irq)
  {
-       struct drm_vblank_crtc *vblank = drm_vblank_crtc(dev, pipe);
+       struct drm_device *dev = vblank->dev;
+       unsigned int pipe = vblank->pipe;
        u32 cur_vblank, diff;
        bool rc;
        ktime_t t_vblank;
@@ -424,8 +425,8 @@ static u64 _drm_vblank_count(struct drm_device *dev, 
unsigned int pipe)
  u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
  {
        struct drm_device *dev = crtc->dev;
-       unsigned int pipe = drm_crtc_index(crtc);
-       u64 vblank;
+       struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
+       u64 vblank_count;
        unsigned long flags;
drm_WARN_ONCE(dev, drm_debug_enabled(DRM_UT_VBL) &&
@@ -434,12 +435,12 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
spin_lock_irqsave(&dev->vblank_time_lock, flags); - drm_update_vblank_count(dev, pipe, false);
-       vblank = _drm_vblank_count(dev, pipe);
+       drm_update_vblank_count(vblank, false);
+       vblank_count = drm_vblank_count(vblank);
spin_unlock_irqrestore(&dev->vblank_time_lock, flags); - return vblank;
+       return vblank_count;
  }
  EXPORT_SYMBOL(drm_crtc_accurate_vblank_count);
@@ -490,7 +491,7 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
         * this time. This makes the count account for the entire time
         * between drm_crtc_vblank_on() and drm_crtc_vblank_off().
         */
-       drm_update_vblank_count(dev, pipe, false);
+       drm_update_vblank_count(vblank, false);
        __disable_vblank(dev, pipe);
        vblank->enabled = false;
@@ -1197,7 +1198,7 @@ static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
                if (ret) {
                        atomic_dec(&vblank->refcount);
                } else {
-                       drm_update_vblank_count(dev, pipe, 0);
+                       drm_update_vblank_count(vblank, 0);
                        /* drm_update_vblank_count() includes a wmb so we just
                         * need to ensure that the compiler emits the write
                         * to mark the vblank as enabled after the call
@@ -1957,7 +1958,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned 
int pipe)
                return false;
        }
- drm_update_vblank_count(dev, pipe, true);
+       drm_update_vblank_count(vblank, true);
spin_unlock(&dev->vblank_time_lock);

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)


Reply via email to