Commit cd2eb57d authored by Zack Rusin's avatar Zack Rusin
Browse files

drm/vmwgfx: Implement virtual kms



By default vmwgfx doesn't support vblanking or crc generation which
makes it impossible to use various IGT tests to validate vmwgfx.
Implement virtual kernel mode setting, which is mainly related to
simulated vblank support.

Code is very similar to amd's vkms and the vkms module itself, except
that it's integrated with vmwgfx three different output technologies -
legacy, screen object and screen targets.

Make IGT's kms_vblank pass on vmwgfx and allows a lot of other IGT
tests to run with vmwgfx.

Support for vkms needs to be manually enabled by adding:
guestinfo.vmwgfx.vkms_enable = "TRUE"
somewhere in the vmx file, otherwise it's off by default.

Signed-off-by: default avatarZack Rusin <zack.rusin@broadcom.com>
Acked-by: default avatarMartin Krastev <martin.krastev@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240412025511.78553-2-zack.rusin@broadcom.com
parent bfc7bc53
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,6 +10,6 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \
	    vmwgfx_simple_resource.o vmwgfx_va.o vmwgfx_blit.o \
	    vmwgfx_validation.o vmwgfx_page_dirty.o vmwgfx_streamoutput.o \
	    vmwgfx_devcaps.o ttm_object.o vmwgfx_system_manager.o \
	    vmwgfx_gem.o
	    vmwgfx_gem.o vmwgfx_vkms.o

obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "vmwgfx_binding.h"
#include "vmwgfx_devcaps.h"
#include "vmwgfx_mksstat.h"
#include "vmwgfx_vkms.h"
#include "ttm_object.h"

#include <drm/drm_aperture.h>
@@ -910,6 +911,8 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
			     "Please switch to a supported graphics device to avoid problems.");
	}

	vmw_vkms_init(dev_priv);

	ret = vmw_dma_select_mode(dev_priv);
	if (unlikely(ret != 0)) {
		drm_info(&dev_priv->drm,
+2 −0
Original line number Diff line number Diff line
@@ -615,6 +615,8 @@ struct vmw_private {

	uint32 *devcaps;

	bool vkms_enabled;

	/*
	 * mksGuestStat instance-descriptor and pid arrays
	 */
+8 −7
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "vmwgfx_kms.h"

#include "vmwgfx_bo.h"
#include "vmwgfx_vkms.h"
#include "vmw_surface_cache.h"

#include <drm/drm_atomic.h>
@@ -37,9 +38,16 @@
#include <drm/drm_sysfs.h>
#include <drm/drm_edid.h>

void vmw_du_init(struct vmw_display_unit *du)
{
	hrtimer_init(&du->vkms.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	du->vkms.timer.function = &vmw_vkms_vblank_simulate;
}

void vmw_du_cleanup(struct vmw_display_unit *du)
{
	struct vmw_private *dev_priv = vmw_priv(du->primary.dev);
	hrtimer_cancel(&du->vkms.timer);
	drm_plane_cleanup(&du->primary);
	if (vmw_cmd_supported(dev_priv))
		drm_plane_cleanup(&du->cursor.base);
@@ -957,13 +965,6 @@ void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
{
}


void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
			      struct drm_atomic_state *state)
{
}


/**
 * vmw_du_crtc_duplicate_state - duplicate crtc state
 * @crtc: DRM crtc
+7 −2
Original line number Diff line number Diff line
@@ -376,6 +376,12 @@ struct vmw_display_unit {
	bool is_implicit;
	int set_gui_x;
	int set_gui_y;

	struct {
		struct hrtimer timer;
		ktime_t period_ns;
		struct drm_pending_vblank_event *event;
	} vkms;
};

#define vmw_crtc_to_du(x) \
@@ -387,6 +393,7 @@ struct vmw_display_unit {
/*
 * Shared display unit functions - vmwgfx_kms.c
 */
void vmw_du_init(struct vmw_display_unit *du);
void vmw_du_cleanup(struct vmw_display_unit *du);
void vmw_du_crtc_save(struct drm_crtc *crtc);
void vmw_du_crtc_restore(struct drm_crtc *crtc);
@@ -473,8 +480,6 @@ int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
			     struct drm_atomic_state *state);
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
			      struct drm_atomic_state *state);
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
			      struct drm_atomic_state *state);
void vmw_du_crtc_reset(struct drm_crtc *crtc);
struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
void vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
Loading