Skip to content

Commit e21fd55

Browse files
Yu Zhangdanvet
authored andcommitted
drm/i915: Add the display switch logic for vGPU in i915 driver
Display switch logic is added to notify the host side that current vGPU have a valid surface to show. It does so by writing the display_ready field in PV INFO page, and then will be handled in the host side. This is useful to avoid trickiness when the VM's framebuffer is being accessed in the middle of VM modesetting, e.g. compositing the framebuffer in the host side. v2: - move the notification code outside the 'else' in load sequence - remove the notification code in intel_crtc_set_config() v4: - code rebase, no need to define another dev_priv - use #define instead of enum for display readiness Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com> Signed-off-by: Jike Song <jike.song@intel.com> Signed-off-by: Zhiyuan Lv <zhiyuan.lv@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent bd49234 commit e21fd55

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎drivers/gpu/drm/i915/i915_dma.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "intel_drv.h"
3737
#include <drm/i915_drm.h>
3838
#include "i915_drv.h"
39+
#include "i915_vgpu.h"
3940
#include "i915_trace.h"
4041
#include <linux/pci.h>
4142
#include <linux/console.h>
@@ -842,6 +843,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
842843
}
843844
}
844845

846+
/*
847+
* Notify a valid surface after modesetting,
848+
* when running inside a VM.
849+
*/
850+
if (intel_vgpu_active(dev))
851+
I915_WRITE(vgtif_reg(display_ready), VGT_DRV_DISPLAY_READY);
852+
845853
i915_setup_sysfs(dev);
846854

847855
if (INTEL_INFO(dev)->num_pipes) {

‎drivers/gpu/drm/i915/i915_vgpu.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ struct vgt_if {
8080
#define vgtif_reg(x) \
8181
(VGT_PVINFO_PAGE + (long)&((struct vgt_if *)NULL)->x)
8282

83+
/* vGPU display status to be used by the host side */
84+
#define VGT_DRV_DISPLAY_NOT_READY 0
85+
#define VGT_DRV_DISPLAY_READY 1 /* ready for display switch */
86+
8387
extern void i915_check_vgpu(struct drm_device *dev);
8488
extern int intel_vgt_balloon(struct drm_device *dev);
8589
extern void intel_vgt_deballoon(void);

0 commit comments

Comments
 (0)