drm/i915/gvt: Fix the vblank timer close issue after shutdown VMs in reverse
authorfred gao <fred.gao@intel.com>
Mon, 17 Jul 2017 06:52:05 +0000 (14:52 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Mon, 17 Jul 2017 09:09:04 +0000 (17:09 +0800)
Once the Windows guest is shutdown, the display pipe will be disabled
and intel_gvt_check_vblank_emulation will be called to check if the
vblank timer is turned off. Given the scenario of creating VM1 ,VM2,
destoying VM2 in current code, VM1 has pipe enabled and continues to
check VM2, the flag have_enabled_pipe is always false since all the VM2
pipes are disabled, so the vblank timer will be canceled and TDR happens
in Windows VM1 guest due to the vsync timeout.

In this patch the vblank timer will be never canceled once one pipe is
enabled.

v2:
- remove have_enabled_pipe flag and check pipe enabled directly. (Zhenyu)

Cc: Wang Hongbo <hongbo.wang@intel.com>
Signed-off-by: fred gao <fred.gao@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/display.c

index 2deb05f618fb11054064122a4b86f468d148c73b..7cb0818a13debecc1d3f08e4fb10042a3536b1e9 100644 (file)
@@ -323,27 +323,27 @@ void intel_gvt_check_vblank_emulation(struct intel_gvt *gvt)
 {
        struct intel_gvt_irq *irq = &gvt->irq;
        struct intel_vgpu *vgpu;
-       bool have_enabled_pipe = false;
        int pipe, id;
 
        if (WARN_ON(!mutex_is_locked(&gvt->lock)))
                return;
 
-       hrtimer_cancel(&irq->vblank_timer.timer);
-
        for_each_active_vgpu(gvt, vgpu, id) {
                for (pipe = 0; pipe < I915_MAX_PIPES; pipe++) {
-                       have_enabled_pipe =
-                               pipe_is_enabled(vgpu, pipe);
-                       if (have_enabled_pipe)
-                               break;
+                       if (pipe_is_enabled(vgpu, pipe))
+                               goto out;
                }
        }
 
-       if (have_enabled_pipe)
-               hrtimer_start(&irq->vblank_timer.timer,
-                       ktime_add_ns(ktime_get(), irq->vblank_timer.period),
-                       HRTIMER_MODE_ABS);
+       /* all the pipes are disabled */
+       hrtimer_cancel(&irq->vblank_timer.timer);
+       return;
+
+out:
+       hrtimer_start(&irq->vblank_timer.timer,
+               ktime_add_ns(ktime_get(), irq->vblank_timer.period),
+               HRTIMER_MODE_ABS);
+
 }
 
 static void emulate_vblank_on_pipe(struct intel_vgpu *vgpu, int pipe)