Commit df42523c authored by Zack Rusin's avatar Zack Rusin

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
...@@ -16,13 +16,6 @@ config DRM_VMWGFX ...@@ -16,13 +16,6 @@ config DRM_VMWGFX
virtual hardware. virtual hardware.
The compiled module will be called "vmwgfx.ko". 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 config DRM_VMWGFX_MKSSTATS
bool "Enable mksGuestStats instrumentation of vmwgfx by default" bool "Enable mksGuestStats instrumentation of vmwgfx by default"
depends on DRM_VMWGFX depends on DRM_VMWGFX
......
...@@ -12,6 +12,4 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ ...@@ -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_devcaps.o ttm_object.o vmwgfx_system_manager.o \
vmwgfx_gem.o vmwgfx_gem.o
vmwgfx-$(CONFIG_DRM_FBDEV_EMULATION) += vmwgfx_fb.o
obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <drm/drm_aperture.h> #include <drm/drm_aperture.h>
#include <drm/drm_drv.h> #include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_gem_ttm_helper.h> #include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h> #include <drm/drm_ioctl.h>
#include <drm/drm_module.h> #include <drm/drm_module.h>
...@@ -52,9 +53,6 @@ ...@@ -52,9 +53,6 @@
#define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices" #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 * Fully encoded drm commands. Might move to vmw_drm.h
*/ */
...@@ -265,7 +263,6 @@ static const struct pci_device_id vmw_pci_id_list[] = { ...@@ -265,7 +263,6 @@ static const struct pci_device_id vmw_pci_id_list[] = {
}; };
MODULE_DEVICE_TABLE(pci, 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_restrict_iommu;
static int vmw_force_coherent; static int vmw_force_coherent;
static int vmw_restrict_dma_mask; static int vmw_restrict_dma_mask;
...@@ -275,8 +272,6 @@ static int vmw_probe(struct pci_dev *, const struct pci_device_id *); ...@@ -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, static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
void *ptr); 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_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600); module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages"); MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
...@@ -626,8 +621,8 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv) ...@@ -626,8 +621,8 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv)
width = vmw_read(dev_priv, SVGA_REG_WIDTH); width = vmw_read(dev_priv, SVGA_REG_WIDTH);
height = vmw_read(dev_priv, SVGA_REG_HEIGHT); height = vmw_read(dev_priv, SVGA_REG_HEIGHT);
width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH); width = max_t(uint32_t, width, VMWGFX_MIN_INITIAL_WIDTH);
height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT); height = max_t(uint32_t, height, VMWGFX_MIN_INITIAL_HEIGHT);
if (width > dev_priv->fb_max_width || if (width > dev_priv->fb_max_width ||
height > dev_priv->fb_max_height) { height > dev_priv->fb_max_height) {
...@@ -636,8 +631,8 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv) ...@@ -636,8 +631,8 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv)
* This is a host error and shouldn't occur. * This is a host error and shouldn't occur.
*/ */
width = VMW_MIN_INITIAL_WIDTH; width = VMWGFX_MIN_INITIAL_WIDTH;
height = VMW_MIN_INITIAL_HEIGHT; height = VMWGFX_MIN_INITIAL_HEIGHT;
} }
dev_priv->initial_width = width; dev_priv->initial_width = width;
...@@ -886,9 +881,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) ...@@ -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->assume_16bpp = !!vmw_assume_16bpp;
dev_priv->enable_fb = enable_fbdev;
dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES); dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
vmw_print_bitmap(&dev_priv->drm, "Capabilities", vmw_print_bitmap(&dev_priv->drm, "Capabilities",
dev_priv->capabilities, dev_priv->capabilities,
...@@ -1135,12 +1127,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) ...@@ -1135,12 +1127,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
VMWGFX_DRIVER_PATCHLEVEL, UTS_RELEASE); VMWGFX_DRIVER_PATCHLEVEL, UTS_RELEASE);
vmw_write_driver_id(dev_priv); 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; dev_priv->pm_nb.notifier_call = vmwgfx_pm_notifier;
register_pm_notifier(&dev_priv->pm_nb); register_pm_notifier(&dev_priv->pm_nb);
...@@ -1187,12 +1173,9 @@ static void vmw_driver_unload(struct drm_device *dev) ...@@ -1187,12 +1173,9 @@ static void vmw_driver_unload(struct drm_device *dev)
unregister_pm_notifier(&dev_priv->pm_nb); unregister_pm_notifier(&dev_priv->pm_nb);
vmw_sw_context_fini(dev_priv); 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_fifo_resource_dec(dev_priv);
vmw_svga_disable(dev_priv); vmw_svga_disable(dev_priv);
}
vmw_kms_close(dev_priv); vmw_kms_close(dev_priv);
vmw_overlay_close(dev_priv); vmw_overlay_close(dev_priv);
...@@ -1330,8 +1313,6 @@ static void vmw_master_drop(struct drm_device *dev, ...@@ -1330,8 +1313,6 @@ static void vmw_master_drop(struct drm_device *dev,
struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_private *dev_priv = vmw_priv(dev);
vmw_kms_legacy_hotspot_clear(dev_priv); 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) ...@@ -1524,25 +1505,19 @@ static int vmw_pm_freeze(struct device *kdev)
DRM_ERROR("Failed to freeze modesetting.\n"); DRM_ERROR("Failed to freeze modesetting.\n");
return ret; return ret;
} }
if (dev_priv->enable_fb)
vmw_fb_off(dev_priv);
vmw_execbuf_release_pinned_bo(dev_priv); vmw_execbuf_release_pinned_bo(dev_priv);
vmw_resource_evict_all(dev_priv); vmw_resource_evict_all(dev_priv);
vmw_release_device_early(dev_priv); vmw_release_device_early(dev_priv);
while (ttm_device_swapout(&dev_priv->bdev, &ctx, GFP_KERNEL) > 0); while (ttm_device_swapout(&dev_priv->bdev, &ctx, GFP_KERNEL) > 0);
if (dev_priv->enable_fb)
vmw_fifo_resource_dec(dev_priv); vmw_fifo_resource_dec(dev_priv);
if (atomic_read(&dev_priv->num_fifo_resources) != 0) { if (atomic_read(&dev_priv->num_fifo_resources) != 0) {
DRM_ERROR("Can't hibernate while 3D resources are active.\n"); DRM_ERROR("Can't hibernate while 3D resources are active.\n");
if (dev_priv->enable_fb)
vmw_fifo_resource_inc(dev_priv); vmw_fifo_resource_inc(dev_priv);
WARN_ON(vmw_request_device_late(dev_priv)); WARN_ON(vmw_request_device_late(dev_priv));
dev_priv->suspend_locked = false; dev_priv->suspend_locked = false;
if (dev_priv->suspend_state) if (dev_priv->suspend_state)
vmw_kms_resume(dev); vmw_kms_resume(dev);
if (dev_priv->enable_fb)
vmw_fb_on(dev_priv);
return -EBUSY; return -EBUSY;
} }
...@@ -1562,14 +1537,12 @@ static int vmw_pm_restore(struct device *kdev) ...@@ -1562,14 +1537,12 @@ static int vmw_pm_restore(struct device *kdev)
vmw_detect_version(dev_priv); vmw_detect_version(dev_priv);
if (dev_priv->enable_fb)
vmw_fifo_resource_inc(dev_priv); vmw_fifo_resource_inc(dev_priv);
ret = vmw_request_device(dev_priv); ret = vmw_request_device(dev_priv);
if (ret) if (ret)
return ret; return ret;
if (dev_priv->enable_fb)
__vmw_svga_enable(dev_priv); __vmw_svga_enable(dev_priv);
vmw_fence_fifo_up(dev_priv->fman); vmw_fence_fifo_up(dev_priv->fman);
...@@ -1577,9 +1550,6 @@ static int vmw_pm_restore(struct device *kdev) ...@@ -1577,9 +1550,6 @@ static int vmw_pm_restore(struct device *kdev)
if (dev_priv->suspend_state) if (dev_priv->suspend_state)
vmw_kms_resume(&dev_priv->drm); vmw_kms_resume(&dev_priv->drm);
if (dev_priv->enable_fb)
vmw_fb_on(dev_priv);
return 0; return 0;
} }
...@@ -1670,6 +1640,10 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1670,6 +1640,10 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto out_unload; 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_gem_init(vmw);
vmw_debugfs_resource_managers_init(vmw); vmw_debugfs_resource_managers_init(vmw);
......
...@@ -62,6 +62,9 @@ ...@@ -62,6 +62,9 @@
#define VMWGFX_MAX_DISPLAYS 16 #define VMWGFX_MAX_DISPLAYS 16
#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 #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_SVGA2 0x0405
#define VMWGFX_PCI_ID_SVGA3 0x0406 #define VMWGFX_PCI_ID_SVGA3 0x0406
...@@ -551,7 +554,6 @@ struct vmw_private { ...@@ -551,7 +554,6 @@ struct vmw_private {
* Framebuffer info. * Framebuffer info.
*/ */
void *fb_info;
enum vmw_display_unit_type active_display_unit; enum vmw_display_unit_type active_display_unit;
struct vmw_legacy_display *ldu_priv; struct vmw_legacy_display *ldu_priv;
struct vmw_overlay *overlay_priv; struct vmw_overlay *overlay_priv;
...@@ -610,8 +612,6 @@ struct vmw_private { ...@@ -610,8 +612,6 @@ struct vmw_private {
struct mutex cmdbuf_mutex; struct mutex cmdbuf_mutex;
struct mutex binding_mutex; struct mutex binding_mutex;
bool enable_fb;
/** /**
* PM management. * PM management.
*/ */
...@@ -1189,35 +1189,6 @@ extern void vmw_generic_waiter_add(struct vmw_private *dev_priv, u32 flag, ...@@ -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, extern void vmw_generic_waiter_remove(struct vmw_private *dev_priv,
u32 flag, int *waiter_count); 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 * Kernel modesetting - vmwgfx_kms.c
*/ */
......
This diff is collapsed.
...@@ -2203,6 +2203,8 @@ int vmw_kms_init(struct vmw_private *dev_priv) ...@@ -2203,6 +2203,8 @@ int vmw_kms_init(struct vmw_private *dev_priv)
dev->mode_config.min_height = 1; dev->mode_config.min_height = 1;
dev->mode_config.max_width = dev_priv->texture_max_width; dev->mode_config.max_width = dev_priv->texture_max_width;
dev->mode_config.max_height = dev_priv->texture_max_height; dev->mode_config.max_height = dev_priv->texture_max_height;
dev->mode_config.preferred_depth = dev_priv->assume_16bpp ? 16 : 32;
dev->mode_config.prefer_shadow_fbdev = !dev_priv->has_mob;
drm_mode_create_suggested_offset_properties(dev); drm_mode_create_suggested_offset_properties(dev);
vmw_kms_create_hotplug_mode_update_property(dev_priv); vmw_kms_create_hotplug_mode_update_property(dev_priv);
...@@ -2372,8 +2374,8 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, ...@@ -2372,8 +2374,8 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv,
du->gui_x = rects[du->unit].x1; du->gui_x = rects[du->unit].x1;
du->gui_y = rects[du->unit].y1; du->gui_y = rects[du->unit].y1;
} else { } else {
du->pref_width = 800; du->pref_width = VMWGFX_MIN_INITIAL_WIDTH;
du->pref_height = 600; du->pref_height = VMWGFX_MIN_INITIAL_HEIGHT;
du->pref_active = false; du->pref_active = false;
du->gui_x = 0; du->gui_x = 0;
du->gui_y = 0; du->gui_y = 0;
...@@ -2400,13 +2402,13 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, ...@@ -2400,13 +2402,13 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv,
} }
con->status = vmw_du_connector_detect(con, true); con->status = vmw_du_connector_detect(con, true);
} }
drm_sysfs_hotplug_event(dev);
out_fini: out_fini:
drm_modeset_drop_locks(&ctx); drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx); drm_modeset_acquire_fini(&ctx);
mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&dev->mode_config.mutex);
drm_sysfs_hotplug_event(dev);
return 0; return 0;
} }
...@@ -2686,10 +2688,9 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, ...@@ -2686,10 +2688,9 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
int ret, i; int ret, i;
if (!arg->num_outputs) { if (!arg->num_outputs) {
struct drm_rect def_rect = {0, 0, 800, 600}; struct drm_rect def_rect = {0, 0,
VMW_DEBUG_KMS("Default layout x1 = %d y1 = %d x2 = %d y2 = %d\n", VMWGFX_MIN_INITIAL_WIDTH,
def_rect.x1, def_rect.y1, VMWGFX_MIN_INITIAL_HEIGHT};
def_rect.x2, def_rect.y2);
vmw_du_update_layout(dev_priv, 1, &def_rect); vmw_du_update_layout(dev_priv, 1, &def_rect);
return 0; return 0;
} }
...@@ -2984,68 +2985,6 @@ int vmw_kms_update_proxy(struct vmw_resource *res, ...@@ -2984,68 +2985,6 @@ int vmw_kms_update_proxy(struct vmw_resource *res,
return 0; return 0;
} }
int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
unsigned unit,
u32 max_width,
u32 max_height,
struct drm_connector **p_con,
struct drm_crtc **p_crtc,
struct drm_display_mode **p_mode)
{
struct drm_connector *con;
struct vmw_display_unit *du;
struct drm_display_mode *mode;
int i = 0;
int ret = 0;
mutex_lock(&dev_priv->drm.mode_config.mutex);
list_for_each_entry(con, &dev_priv->drm.mode_config.connector_list,
head) {
if (i == unit)
break;
++i;
}
if (&con->head == &dev_priv->drm.mode_config.connector_list) {
DRM_ERROR("Could not find initial display unit.\n");
ret = -EINVAL;
goto out_unlock;
}
if (list_empty(&con->modes))
(void) vmw_du_connector_fill_modes(con, max_width, max_height);
if (list_empty(&con->modes)) {
DRM_ERROR("Could not find initial display mode.\n");
ret = -EINVAL;
goto out_unlock;
}
du = vmw_connector_to_du(con);
*p_con = con;
*p_crtc = &du->crtc;
list_for_each_entry(mode, &con->modes, head) {
if (mode->type & DRM_MODE_TYPE_PREFERRED)
break;
}
if (&mode->head == &con->modes) {
WARN_ONCE(true, "Could not find initial preferred mode.\n");
*p_mode = list_first_entry(&con->modes,
struct drm_display_mode,
head);
} else {
*p_mode = mode;
}
out_unlock:
mutex_unlock(&dev_priv->drm.mode_config.mutex);
return ret;
}
/** /**
* vmw_kms_create_implicit_placement_property - Set up the implicit placement * vmw_kms_create_implicit_placement_property - Set up the implicit placement
* property. * property.
......
...@@ -462,13 +462,6 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv, ...@@ -462,13 +462,6 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
struct vmw_surface *surface, struct vmw_surface *surface,
bool only_2d, bool only_2d,
const struct drm_mode_fb_cmd2 *mode_cmd); const struct drm_mode_fb_cmd2 *mode_cmd);
int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
unsigned unit,
u32 max_width,
u32 max_height,
struct drm_connector **p_con,
struct drm_crtc **p_crtc,
struct drm_display_mode **p_mode);
void vmw_guess_mode_timing(struct drm_display_mode *mode); void vmw_guess_mode_timing(struct drm_display_mode *mode);
void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv); void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv);
void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv); void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment