Skip to content

Commit df42523

Browse files
committed
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: Zack Rusin <zackr@vmware.com> Reviewed-by: Maaz Mombasawala <mombasawalam@vmware.com> Reviewed-by: Martin Krastev <krastevm@vmware.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patchwork.freedesktop.org/patch/msgid/20221022040236.616490-14-zack@kde.org
1 parent 1c8d537 commit df42523

File tree

7 files changed

+28
-991
lines changed

7 files changed

+28
-991
lines changed

drivers/gpu/drm/vmwgfx/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ config DRM_VMWGFX
1616
virtual hardware.
1717
The compiled module will be called "vmwgfx.ko".
1818

19-
config DRM_VMWGFX_FBCON
20-
depends on DRM_VMWGFX && DRM_FBDEV_EMULATION
21-
bool "Enable framebuffer console under vmwgfx by default"
22-
help
23-
Choose this option if you are shipping a new vmwgfx
24-
userspace driver that supports using the kernel driver.
25-
2619
config DRM_VMWGFX_MKSSTATS
2720
bool "Enable mksGuestStats instrumentation of vmwgfx by default"
2821
depends on DRM_VMWGFX

drivers/gpu/drm/vmwgfx/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \
1212
vmwgfx_devcaps.o ttm_object.o vmwgfx_system_manager.o \
1313
vmwgfx_gem.o
1414

15-
vmwgfx-$(CONFIG_DRM_FBDEV_EMULATION) += vmwgfx_fb.o
16-
1715
obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <drm/drm_aperture.h>
3737
#include <drm/drm_drv.h>
38+
#include <drm/drm_fb_helper.h>
3839
#include <drm/drm_gem_ttm_helper.h>
3940
#include <drm/drm_ioctl.h>
4041
#include <drm/drm_module.h>
@@ -52,9 +53,6 @@
5253

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

55-
#define VMW_MIN_INITIAL_WIDTH 800
56-
#define VMW_MIN_INITIAL_HEIGHT 600
57-
5856
/*
5957
* Fully encoded drm commands. Might move to vmw_drm.h
6058
*/
@@ -265,7 +263,6 @@ static const struct pci_device_id vmw_pci_id_list[] = {
265263
};
266264
MODULE_DEVICE_TABLE(pci, vmw_pci_id_list);
267265

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

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

629-
width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH);
630-
height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT);
624+
width = max_t(uint32_t, width, VMWGFX_MIN_INITIAL_WIDTH);
625+
height = max_t(uint32_t, height, VMWGFX_MIN_INITIAL_HEIGHT);
631626

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

639-
width = VMW_MIN_INITIAL_WIDTH;
640-
height = VMW_MIN_INITIAL_HEIGHT;
634+
width = VMWGFX_MIN_INITIAL_WIDTH;
635+
height = VMWGFX_MIN_INITIAL_HEIGHT;
641636
}
642637

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

887882
dev_priv->assume_16bpp = !!vmw_assume_16bpp;
888883

889-
dev_priv->enable_fb = enable_fbdev;
890-
891-
892884
dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
893885
vmw_print_bitmap(&dev_priv->drm, "Capabilities",
894886
dev_priv->capabilities,
@@ -1135,12 +1127,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
11351127
VMWGFX_DRIVER_PATCHLEVEL, UTS_RELEASE);
11361128
vmw_write_driver_id(dev_priv);
11371129

1138-
if (dev_priv->enable_fb) {
1139-
vmw_fifo_resource_inc(dev_priv);
1140-
vmw_svga_enable(dev_priv);
1141-
vmw_fb_init(dev_priv);
1142-
}
1143-
11441130
dev_priv->pm_nb.notifier_call = vmwgfx_pm_notifier;
11451131
register_pm_notifier(&dev_priv->pm_nb);
11461132

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

11891175
vmw_sw_context_fini(dev_priv);
1190-
if (dev_priv->enable_fb) {
1191-
vmw_fb_off(dev_priv);
1192-
vmw_fb_close(dev_priv);
1193-
vmw_fifo_resource_dec(dev_priv);
1194-
vmw_svga_disable(dev_priv);
1195-
}
1176+
vmw_fifo_resource_dec(dev_priv);
1177+
1178+
vmw_svga_disable(dev_priv);
11961179

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

13321315
vmw_kms_legacy_hotspot_clear(dev_priv);
1333-
if (!dev_priv->enable_fb)
1334-
vmw_svga_disable(dev_priv);
13351316
}
13361317

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

15301509
vmw_execbuf_release_pinned_bo(dev_priv);
15311510
vmw_resource_evict_all(dev_priv);
15321511
vmw_release_device_early(dev_priv);
15331512
while (ttm_device_swapout(&dev_priv->bdev, &ctx, GFP_KERNEL) > 0);
1534-
if (dev_priv->enable_fb)
1535-
vmw_fifo_resource_dec(dev_priv);
1513+
vmw_fifo_resource_dec(dev_priv);
15361514
if (atomic_read(&dev_priv->num_fifo_resources) != 0) {
15371515
DRM_ERROR("Can't hibernate while 3D resources are active.\n");
1538-
if (dev_priv->enable_fb)
1539-
vmw_fifo_resource_inc(dev_priv);
1516+
vmw_fifo_resource_inc(dev_priv);
15401517
WARN_ON(vmw_request_device_late(dev_priv));
15411518
dev_priv->suspend_locked = false;
15421519
if (dev_priv->suspend_state)
15431520
vmw_kms_resume(dev);
1544-
if (dev_priv->enable_fb)
1545-
vmw_fb_on(dev_priv);
15461521
return -EBUSY;
15471522
}
15481523

@@ -1562,24 +1537,19 @@ static int vmw_pm_restore(struct device *kdev)
15621537

15631538
vmw_detect_version(dev_priv);
15641539

1565-
if (dev_priv->enable_fb)
1566-
vmw_fifo_resource_inc(dev_priv);
1540+
vmw_fifo_resource_inc(dev_priv);
15671541

15681542
ret = vmw_request_device(dev_priv);
15691543
if (ret)
15701544
return ret;
15711545

1572-
if (dev_priv->enable_fb)
1573-
__vmw_svga_enable(dev_priv);
1546+
__vmw_svga_enable(dev_priv);
15741547

15751548
vmw_fence_fifo_up(dev_priv->fman);
15761549
dev_priv->suspend_locked = false;
15771550
if (dev_priv->suspend_state)
15781551
vmw_kms_resume(&dev_priv->drm);
15791552

1580-
if (dev_priv->enable_fb)
1581-
vmw_fb_on(dev_priv);
1582-
15831553
return 0;
15841554
}
15851555

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

1643+
vmw_fifo_resource_inc(vmw);
1644+
vmw_svga_enable(vmw);
1645+
drm_fbdev_generic_setup(&vmw->drm, 0);
1646+
16731647
vmw_debugfs_gem_init(vmw);
16741648
vmw_debugfs_resource_managers_init(vmw);
16751649

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
#define VMWGFX_MAX_DISPLAYS 16
6363
#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768
6464

65+
#define VMWGFX_MIN_INITIAL_WIDTH 1280
66+
#define VMWGFX_MIN_INITIAL_HEIGHT 800
67+
6568
#define VMWGFX_PCI_ID_SVGA2 0x0405
6669
#define VMWGFX_PCI_ID_SVGA3 0x0406
6770

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

554-
void *fb_info;
555557
enum vmw_display_unit_type active_display_unit;
556558
struct vmw_legacy_display *ldu_priv;
557559
struct vmw_overlay *overlay_priv;
@@ -610,8 +612,6 @@ struct vmw_private {
610612
struct mutex cmdbuf_mutex;
611613
struct mutex binding_mutex;
612614

613-
bool enable_fb;
614-
615615
/**
616616
* PM management.
617617
*/
@@ -1189,35 +1189,6 @@ extern void vmw_generic_waiter_add(struct vmw_private *dev_priv, u32 flag,
11891189
extern void vmw_generic_waiter_remove(struct vmw_private *dev_priv,
11901190
u32 flag, int *waiter_count);
11911191

1192-
1193-
/**
1194-
* Kernel framebuffer - vmwgfx_fb.c
1195-
*/
1196-
1197-
#ifdef CONFIG_DRM_FBDEV_EMULATION
1198-
int vmw_fb_init(struct vmw_private *vmw_priv);
1199-
int vmw_fb_close(struct vmw_private *dev_priv);
1200-
int vmw_fb_off(struct vmw_private *vmw_priv);
1201-
int vmw_fb_on(struct vmw_private *vmw_priv);
1202-
#else
1203-
static inline int vmw_fb_init(struct vmw_private *vmw_priv)
1204-
{
1205-
return 0;
1206-
}
1207-
static inline int vmw_fb_close(struct vmw_private *dev_priv)
1208-
{
1209-
return 0;
1210-
}
1211-
static inline int vmw_fb_off(struct vmw_private *vmw_priv)
1212-
{
1213-
return 0;
1214-
}
1215-
static inline int vmw_fb_on(struct vmw_private *vmw_priv)
1216-
{
1217-
return 0;
1218-
}
1219-
#endif
1220-
12211192
/**
12221193
* Kernel modesetting - vmwgfx_kms.c
12231194
*/

0 commit comments

Comments
 (0)