Commit facfb062 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

drm: Limit the number of .get_vblank_counter() retries

Pontential infinite loops in the vblank code are a bad idea. Add some
limits.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent a6e610dc
...@@ -127,6 +127,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe, ...@@ -127,6 +127,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
u32 cur_vblank, diff; u32 cur_vblank, diff;
bool rc; bool rc;
struct timeval t_vblank; struct timeval t_vblank;
int count = DRM_TIMESTAMP_MAXRETRIES;
/* /*
* Interrupts were disabled prior to this call, so deal with counter * Interrupts were disabled prior to this call, so deal with counter
...@@ -143,7 +144,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe, ...@@ -143,7 +144,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
do { do {
cur_vblank = dev->driver->get_vblank_counter(dev, pipe); cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags); rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
} while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe)); } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && --count > 0);
/* Deal with counter wrap */ /* Deal with counter wrap */
diff = cur_vblank - vblank->last; diff = cur_vblank - vblank->last;
...@@ -914,6 +915,7 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, ...@@ -914,6 +915,7 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
struct timeval *vblanktime) struct timeval *vblanktime)
{ {
struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
int count = DRM_TIMESTAMP_MAXRETRIES;
u32 cur_vblank; u32 cur_vblank;
if (WARN_ON(pipe >= dev->num_crtcs)) if (WARN_ON(pipe >= dev->num_crtcs))
...@@ -929,7 +931,7 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, ...@@ -929,7 +931,7 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
smp_rmb(); smp_rmb();
*vblanktime = vblanktimestamp(dev, pipe, cur_vblank); *vblanktime = vblanktimestamp(dev, pipe, cur_vblank);
smp_rmb(); smp_rmb();
} while (cur_vblank != vblank->count); } while (cur_vblank != vblank->count && --count > 0);
return cur_vblank; return cur_vblank;
} }
......
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