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

drm/vmwgfx: Port the framebuffer code to drm fb helpers



Instead of using vmwgfx specific framebuffer implementation use the drm
fb helpers. There's no change in functionality, the only difference
is a reduction in the amount of code inside the vmwgfx module.

drm fb helpers do not deal correctly with changes in crtc preferred mode
at runtime, but the old fb code wasn't dealing with it either.
Same situation applies to high-res fb consoles - the old code was
limited to 1176x885 because it was checking for legacy/deprecated
memory limites, the drm fb helpers are limited to the initial resolution
set on fb due to first problem (drm fb helpers being unable to handle
hotplug crtc preferred mode changes).

This also removes the kernel config for disabling fb support which hasn't
been used or supported in a very long time.

Signed-off-by: default avatarZack Rusin <zackr@vmware.com>
Reviewed-by: default avatarMaaz Mombasawala <mombasawalam@vmware.com>
Reviewed-by: default avatarMartin Krastev <krastevm@vmware.com>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20221022040236.616490-14-zack@kde.org
parent 1c8d537b
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -16,13 +16,6 @@ config DRM_VMWGFX
	  virtual hardware.
	  The compiled module will be called "vmwgfx.ko".

config DRM_VMWGFX_FBCON
	depends on DRM_VMWGFX && DRM_FBDEV_EMULATION
	bool "Enable framebuffer console under vmwgfx by default"
	help
	   Choose this option if you are shipping a new vmwgfx
	   userspace driver that supports using the kernel driver.

config DRM_VMWGFX_MKSSTATS
	bool "Enable mksGuestStats instrumentation of vmwgfx by default"
	depends on DRM_VMWGFX
+0 −2
Original line number Diff line number Diff line
@@ -12,6 +12,4 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \
	    vmwgfx_devcaps.o ttm_object.o vmwgfx_system_manager.o \
	    vmwgfx_gem.o

vmwgfx-$(CONFIG_DRM_FBDEV_EMULATION) += vmwgfx_fb.o

obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
+16 −42
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@

#include <drm/drm_aperture.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_module.h>
@@ -52,9 +53,6 @@

#define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"

#define VMW_MIN_INITIAL_WIDTH 800
#define VMW_MIN_INITIAL_HEIGHT 600

/*
 * Fully encoded drm commands. Might move to vmw_drm.h
 */
@@ -265,7 +263,6 @@ static const struct pci_device_id vmw_pci_id_list[] = {
};
MODULE_DEVICE_TABLE(pci, vmw_pci_id_list);

static int enable_fbdev = IS_ENABLED(CONFIG_DRM_VMWGFX_FBCON);
static int vmw_restrict_iommu;
static int vmw_force_coherent;
static int vmw_restrict_dma_mask;
@@ -275,8 +272,6 @@ static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
			      void *ptr);

MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
module_param_named(enable_fbdev, enable_fbdev, int, 0600);
MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
@@ -626,8 +621,8 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv)
	width = vmw_read(dev_priv, SVGA_REG_WIDTH);
	height = vmw_read(dev_priv, SVGA_REG_HEIGHT);

	width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH);
	height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT);
	width = max_t(uint32_t, width, VMWGFX_MIN_INITIAL_WIDTH);
	height = max_t(uint32_t, height, VMWGFX_MIN_INITIAL_HEIGHT);

	if (width > dev_priv->fb_max_width ||
	    height > dev_priv->fb_max_height) {
@@ -636,8 +631,8 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv)
		 * This is a host error and shouldn't occur.
		 */

		width = VMW_MIN_INITIAL_WIDTH;
		height = VMW_MIN_INITIAL_HEIGHT;
		width  = VMWGFX_MIN_INITIAL_WIDTH;
		height = VMWGFX_MIN_INITIAL_HEIGHT;
	}

	dev_priv->initial_width = width;
@@ -886,9 +881,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)

	dev_priv->assume_16bpp = !!vmw_assume_16bpp;

	dev_priv->enable_fb = enable_fbdev;


	dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
	vmw_print_bitmap(&dev_priv->drm, "Capabilities",
			 dev_priv->capabilities,
@@ -1135,12 +1127,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
			VMWGFX_DRIVER_PATCHLEVEL, UTS_RELEASE);
	vmw_write_driver_id(dev_priv);

	if (dev_priv->enable_fb) {
		vmw_fifo_resource_inc(dev_priv);
		vmw_svga_enable(dev_priv);
		vmw_fb_init(dev_priv);
	}

	dev_priv->pm_nb.notifier_call = vmwgfx_pm_notifier;
	register_pm_notifier(&dev_priv->pm_nb);

@@ -1187,12 +1173,9 @@ static void vmw_driver_unload(struct drm_device *dev)
	unregister_pm_notifier(&dev_priv->pm_nb);

	vmw_sw_context_fini(dev_priv);
	if (dev_priv->enable_fb) {
		vmw_fb_off(dev_priv);
		vmw_fb_close(dev_priv);
	vmw_fifo_resource_dec(dev_priv);

	vmw_svga_disable(dev_priv);
	}

	vmw_kms_close(dev_priv);
	vmw_overlay_close(dev_priv);
@@ -1330,8 +1313,6 @@ static void vmw_master_drop(struct drm_device *dev,
	struct vmw_private *dev_priv = vmw_priv(dev);

	vmw_kms_legacy_hotspot_clear(dev_priv);
	if (!dev_priv->enable_fb)
		vmw_svga_disable(dev_priv);
}

/**
@@ -1524,25 +1505,19 @@ static int vmw_pm_freeze(struct device *kdev)
		DRM_ERROR("Failed to freeze modesetting.\n");
		return ret;
	}
	if (dev_priv->enable_fb)
		vmw_fb_off(dev_priv);

	vmw_execbuf_release_pinned_bo(dev_priv);
	vmw_resource_evict_all(dev_priv);
	vmw_release_device_early(dev_priv);
	while (ttm_device_swapout(&dev_priv->bdev, &ctx, GFP_KERNEL) > 0);
	if (dev_priv->enable_fb)
	vmw_fifo_resource_dec(dev_priv);
	if (atomic_read(&dev_priv->num_fifo_resources) != 0) {
		DRM_ERROR("Can't hibernate while 3D resources are active.\n");
		if (dev_priv->enable_fb)
		vmw_fifo_resource_inc(dev_priv);
		WARN_ON(vmw_request_device_late(dev_priv));
		dev_priv->suspend_locked = false;
		if (dev_priv->suspend_state)
			vmw_kms_resume(dev);
		if (dev_priv->enable_fb)
			vmw_fb_on(dev_priv);
		return -EBUSY;
	}

@@ -1562,14 +1537,12 @@ static int vmw_pm_restore(struct device *kdev)

	vmw_detect_version(dev_priv);

	if (dev_priv->enable_fb)
	vmw_fifo_resource_inc(dev_priv);

	ret = vmw_request_device(dev_priv);
	if (ret)
		return ret;

	if (dev_priv->enable_fb)
	__vmw_svga_enable(dev_priv);

	vmw_fence_fifo_up(dev_priv->fman);
@@ -1577,9 +1550,6 @@ static int vmw_pm_restore(struct device *kdev)
	if (dev_priv->suspend_state)
		vmw_kms_resume(&dev_priv->drm);

	if (dev_priv->enable_fb)
		vmw_fb_on(dev_priv);

	return 0;
}

@@ -1670,6 +1640,10 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
	if (ret)
		goto out_unload;

	vmw_fifo_resource_inc(vmw);
	vmw_svga_enable(vmw);
	drm_fbdev_generic_setup(&vmw->drm,  0);

	vmw_debugfs_gem_init(vmw);
	vmw_debugfs_resource_managers_init(vmw);

+3 −32
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@
#define VMWGFX_MAX_DISPLAYS 16
#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768

#define VMWGFX_MIN_INITIAL_WIDTH 1280
#define VMWGFX_MIN_INITIAL_HEIGHT 800

#define VMWGFX_PCI_ID_SVGA2              0x0405
#define VMWGFX_PCI_ID_SVGA3              0x0406

@@ -551,7 +554,6 @@ struct vmw_private {
	 * Framebuffer info.
	 */

	void *fb_info;
	enum vmw_display_unit_type active_display_unit;
	struct vmw_legacy_display *ldu_priv;
	struct vmw_overlay *overlay_priv;
@@ -610,8 +612,6 @@ struct vmw_private {
	struct mutex cmdbuf_mutex;
	struct mutex binding_mutex;

	bool enable_fb;

	/**
	 * PM management.
	 */
@@ -1189,35 +1189,6 @@ extern void vmw_generic_waiter_add(struct vmw_private *dev_priv, u32 flag,
extern void vmw_generic_waiter_remove(struct vmw_private *dev_priv,
				      u32 flag, int *waiter_count);


/**
 * Kernel framebuffer - vmwgfx_fb.c
 */

#ifdef CONFIG_DRM_FBDEV_EMULATION
int vmw_fb_init(struct vmw_private *vmw_priv);
int vmw_fb_close(struct vmw_private *dev_priv);
int vmw_fb_off(struct vmw_private *vmw_priv);
int vmw_fb_on(struct vmw_private *vmw_priv);
#else
static inline int vmw_fb_init(struct vmw_private *vmw_priv)
{
	return 0;
}
static inline int vmw_fb_close(struct vmw_private *dev_priv)
{
	return 0;
}
static inline int vmw_fb_off(struct vmw_private *vmw_priv)
{
	return 0;
}
static inline int vmw_fb_on(struct vmw_private *vmw_priv)
{
	return 0;
}
#endif

/**
 * Kernel modesetting - vmwgfx_kms.c
 */
+0 −831

File deleted.

Preview size limit exceeded, changes collapsed.

Loading