Use the vblank pointer instead of a dev, pipe pair to simplify code. Rename to drm_vblank_crtc_count_and_time().
Drop the pipe check warning, as we can be sure vblank->pipe is within limits. v2: Rename (Thomas) Reviewed-by: Thomas Zimmermann <[email protected]> Signed-off-by: Jani Nikula <[email protected]> --- drivers/gpu/drm/drm_vblank.c | 38 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 233c60860c78..5182dfc7b930 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -395,8 +395,8 @@ u64 drm_vblank_crtc_count(struct drm_vblank_crtc *vblank) * This read barrier corresponds to the implicit write barrier of the * write seqlock in store_vblank(). Note that this is the only place * where we need an explicit barrier, since all other access goes - * through drm_vblank_count_and_time(), which already has the required - * read barrier curtesy of the read seqlock. + * through drm_vblank_crtc_count_and_time(), which already has the + * required read barrier curtesy of the read seqlock. */ smp_rmb(); @@ -939,7 +939,7 @@ u64 drm_crtc_vblank_count(struct drm_crtc *crtc) EXPORT_SYMBOL(drm_crtc_vblank_count); /** - * drm_vblank_count_and_time - retrieve "cooked" vblank counter value and the + * drm_vblank_crtc_count_and_time - retrieve "cooked" vblank counter value and the * system timestamp corresponding to that vblank counter value. * @dev: DRM device * @pipe: index of CRTC whose counter to retrieve @@ -952,18 +952,12 @@ EXPORT_SYMBOL(drm_crtc_vblank_count); * * This is the legacy version of drm_crtc_vblank_count_and_time(). */ -static u64 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, - ktime_t *vblanktime) +static u64 drm_vblank_crtc_count_and_time(struct drm_vblank_crtc *vblank, + ktime_t *vblanktime) { - struct drm_vblank_crtc *vblank = drm_vblank_crtc(dev, pipe); u64 vblank_count; unsigned int seq; - if (drm_WARN_ON(dev, pipe >= dev->num_crtcs)) { - *vblanktime = 0; - return 0; - } - do { seq = read_seqbegin(&vblank->seqlock); vblank_count = atomic64_read(&vblank->count); @@ -995,8 +989,8 @@ static u64 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, u64 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc, ktime_t *vblanktime) { - return drm_vblank_count_and_time(crtc->dev, drm_crtc_index(crtc), - vblanktime); + return drm_vblank_crtc_count_and_time(drm_crtc_vblank_crtc(crtc), + vblanktime); } EXPORT_SYMBOL(drm_crtc_vblank_count_and_time); @@ -1138,18 +1132,18 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc, struct drm_pending_vblank_event *e) { struct drm_device *dev = crtc->dev; + struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); u64 seq; - unsigned int pipe = drm_crtc_index(crtc); ktime_t now; if (drm_dev_has_vblank(dev)) { - seq = drm_vblank_count_and_time(dev, pipe, &now); + seq = drm_vblank_crtc_count_and_time(vblank, &now); } else { seq = 0; now = ktime_get(); } - e->pipe = pipe; + e->pipe = vblank->pipe; send_vblank_event(dev, e, seq, now); } EXPORT_SYMBOL(drm_crtc_send_vblank_event); @@ -1371,7 +1365,7 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc) spin_unlock(&dev->vbl_lock); /* Send any queued vblank events, lest the natives grow disquiet */ - seq = drm_vblank_count_and_time(dev, pipe, &now); + seq = drm_vblank_crtc_count_and_time(vblank, &now); list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) { if (e->pipe != pipe) @@ -1648,7 +1642,7 @@ static int drm_vblank_crtc_queue_event(struct drm_vblank_crtc *vblank, if (ret) goto err_unlock; - seq = drm_vblank_count_and_time(dev, pipe, &now); + seq = drm_vblank_crtc_count_and_time(vblank, &now); drm_dbg_core(dev, "event on vblank count %llu, current %llu, crtc %u\n", req_seq, seq, pipe); @@ -1716,7 +1710,7 @@ static void drm_vblank_crtc_wait_reply(struct drm_vblank_crtc *vblank, * to store the seconds. This is safe as we always use monotonic * timestamps since linux-4.15. */ - reply->sequence = drm_vblank_count_and_time(vblank->dev, vblank->pipe, &now); + reply->sequence = drm_vblank_crtc_count_and_time(vblank, &now); ts = ktime_to_timespec64(now); reply->tval_sec = (u32)ts.tv_sec; reply->tval_usec = ts.tv_nsec / 1000; @@ -1881,7 +1875,7 @@ static void drm_vblank_crtc_handle_events(struct drm_vblank_crtc *vblank) assert_spin_locked(&dev->event_lock); - seq = drm_vblank_count_and_time(dev, pipe, &now); + seq = drm_vblank_crtc_count_and_time(vblank, &now); list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) { if (e->pipe != pipe) @@ -2043,7 +2037,7 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data, else get_seq->active = crtc->enabled; drm_modeset_unlock(&crtc->mutex); - get_seq->sequence = drm_vblank_count_and_time(dev, pipe, &now); + get_seq->sequence = drm_vblank_crtc_count_and_time(vblank, &now); get_seq->sequence_ns = ktime_to_ns(now); if (!vblank_enabled) drm_crtc_vblank_put(crtc); @@ -2104,7 +2098,7 @@ int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data, goto err_free; } - seq = drm_vblank_count_and_time(dev, pipe, &now); + seq = drm_vblank_crtc_count_and_time(vblank, &now); req_seq = queue_seq->sequence; if (flags & DRM_CRTC_SEQUENCE_RELATIVE) -- 2.47.3
