The timeslice usage will determine vGPU whether has chance to
schedule or not at every vGPU switch checkpoint.
Signed-off-by: Ping Gao <ping.a.gao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
                if (!vgpu_has_pending_workload(vgpu_data->vgpu))
                        continue;
 
-               vgpu = vgpu_data->vgpu;
-               break;
+               /* Return the vGPU only if it has time slice left */
+               if (vgpu_data->left_ts > 0) {
+                       vgpu = vgpu_data->vgpu;
+                       break;
+               }
        }
 
        return vgpu;
                                &sched_data->lru_runq_head);
 
                gvt_dbg_sched("pick next vgpu %d\n", vgpu->id);
+       } else {
+               scheduler->next_vgpu = gvt->idle_vgpu;
        }
 out:
        if (scheduler->next_vgpu) {