Commit 9a4d9bab authored by Chris Wilson's avatar Chris Wilson Committed by Ville Syrjälä

drm: Refactor vblank sequence number comparison

Move the repeated (a - b) <= (1 << 23) to its own function.

v2: Catch the '1<<23' inside drm_handle_vblank() as well
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Michel Dänzer <michel@daenzer.net>
Link: http://patchwork.freedesktop.org/patch/msgid/20170322100650.26082-1-chris@chris-wilson.co.ukReviewed-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent 6c06a597
...@@ -1484,6 +1484,11 @@ int drm_legacy_modeset_ctl(struct drm_device *dev, void *data, ...@@ -1484,6 +1484,11 @@ int drm_legacy_modeset_ctl(struct drm_device *dev, void *data,
return 0; return 0;
} }
static inline bool vblank_passed(u32 seq, u32 ref)
{
return (seq - ref) <= (1 << 23);
}
static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe, static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
union drm_wait_vblank *vblwait, union drm_wait_vblank *vblwait,
struct drm_file *file_priv) struct drm_file *file_priv)
...@@ -1534,7 +1539,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe, ...@@ -1534,7 +1539,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
vblwait->request.sequence); vblwait->request.sequence);
e->event.sequence = vblwait->request.sequence; e->event.sequence = vblwait->request.sequence;
if ((seq - vblwait->request.sequence) <= (1 << 23)) { if (vblank_passed(seq, vblwait->request.sequence)) {
drm_vblank_put(dev, pipe); drm_vblank_put(dev, pipe);
send_vblank_event(dev, e, seq, &now); send_vblank_event(dev, e, seq, &now);
vblwait->reply.sequence = seq; vblwait->reply.sequence = seq;
...@@ -1624,9 +1629,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data, ...@@ -1624,9 +1629,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
} }
if ((flags & _DRM_VBLANK_NEXTONMISS) && if ((flags & _DRM_VBLANK_NEXTONMISS) &&
(seq - vblwait->request.sequence) <= (1 << 23)) { vblank_passed(seq, vblwait->request.sequence))
vblwait->request.sequence = seq + 1; vblwait->request.sequence = seq + 1;
}
if (flags & _DRM_VBLANK_EVENT) { if (flags & _DRM_VBLANK_EVENT) {
/* must hold on to the vblank ref until the event fires /* must hold on to the vblank ref until the event fires
...@@ -1639,8 +1643,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data, ...@@ -1639,8 +1643,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
DRM_DEBUG("waiting on vblank count %u, crtc %u\n", DRM_DEBUG("waiting on vblank count %u, crtc %u\n",
vblwait->request.sequence, pipe); vblwait->request.sequence, pipe);
DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
(drm_vblank_count(dev, pipe) - vblank_passed(drm_vblank_count(dev, pipe),
vblwait->request.sequence) <= (1 << 23) || vblwait->request.sequence) ||
!READ_ONCE(vblank->enabled)); !READ_ONCE(vblank->enabled));
} }
...@@ -1675,7 +1679,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe) ...@@ -1675,7 +1679,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) { list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) {
if (e->pipe != pipe) if (e->pipe != pipe)
continue; continue;
if ((seq - e->event.sequence) > (1<<23)) if (!vblank_passed(seq, e->event.sequence))
continue; continue;
DRM_DEBUG("vblank event on %u, current %u\n", DRM_DEBUG("vblank event on %u, current %u\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment