round_jiffies() aligns the wakeup time to the nearest second in order to
batch wakeups and reduce system load, which is useful for unimportant
coarse timers like our hangcheck.
v2: round_jiffies_relative() returns the relative jiffie value, whereas
we need the absolute value for the timer.
Suggested-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
 
        /* For hangcheck timer */
 #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */
+#define DRM_I915_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD)
        struct timer_list hangcheck_timer;
        int hangcheck_count;
        uint32_t last_acthd[I915_NUM_RINGS];
 
        if (!dev_priv->mm.suspended) {
                if (i915_enable_hangcheck) {
                        mod_timer(&dev_priv->hangcheck_timer,
-                                 jiffies +
-                                 msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
+                                 round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES));
                }
                if (was_empty) {
                        queue_delayed_work(dev_priv->wq,
 
        if (i915_enable_hangcheck) {
                dev_priv->hangcheck_count = 0;
                mod_timer(&dev_priv->hangcheck_timer,
-                         jiffies +
-                         msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
+                         round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES));
        }
 }
 
 repeat:
        /* Reset timer case chip hangs without another request being added */
        mod_timer(&dev_priv->hangcheck_timer,
-                 jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
+                 round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES));
 }
 
 /* drm_dma.h hooks