Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vboxvideo: Switch to generic fbdev emulation

There's nothing special about vboxvideo's fbdev emulation that is
not provided by the generic implementation. Switch over and remove
the driver's code.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191011134808.3955-2-tzimmermann@suse.de

+6 -169
+1 -1
drivers/gpu/drm/vboxvideo/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 vboxvideo-y := hgsmi_base.o modesetting.o vbva_base.o \ 3 - vbox_drv.o vbox_fb.o vbox_hgsmi.o vbox_irq.o vbox_main.o \ 3 + vbox_drv.o vbox_hgsmi.o vbox_irq.o vbox_main.o \ 4 4 vbox_mode.o vbox_ttm.o 5 5 6 6 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo.o
+3 -11
drivers/gpu/drm/vboxvideo/vbox_drv.c
··· 14 14 15 15 #include <drm/drm_crtc_helper.h> 16 16 #include <drm/drm_drv.h> 17 + #include <drm/drm_fb_helper.h> 17 18 #include <drm/drm_file.h> 18 19 #include <drm/drm_ioctl.h> 19 20 ··· 32 31 { } 33 32 }; 34 33 MODULE_DEVICE_TABLE(pci, pciidlist); 35 - 36 - static const struct drm_fb_helper_funcs vbox_fb_helper_funcs = { 37 - .fb_probe = vboxfb_create, 38 - }; 39 34 40 35 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 41 36 { ··· 76 79 if (ret) 77 80 goto err_mode_fini; 78 81 79 - ret = drm_fb_helper_fbdev_setup(&vbox->ddev, &vbox->fb_helper, 80 - &vbox_fb_helper_funcs, 32, 81 - vbox->num_crtcs); 82 + ret = drm_fbdev_generic_setup(&vbox->ddev, 32); 82 83 if (ret) 83 84 goto err_irq_fini; 84 85 85 86 ret = drm_dev_register(&vbox->ddev, 0); 86 87 if (ret) 87 - goto err_fbdev_fini; 88 + goto err_irq_fini; 88 89 89 90 return 0; 90 91 91 - err_fbdev_fini: 92 - vbox_fbdev_fini(vbox); 93 92 err_irq_fini: 94 93 vbox_irq_fini(vbox); 95 94 err_mode_fini: ··· 106 113 struct vbox_private *vbox = pci_get_drvdata(pdev); 107 114 108 115 drm_dev_unregister(&vbox->ddev); 109 - vbox_fbdev_fini(vbox); 110 116 vbox_irq_fini(vbox); 111 117 vbox_mode_fini(vbox); 112 118 vbox_mm_fini(vbox);
-7
drivers/gpu/drm/vboxvideo/vbox_drv.h
··· 16 16 #include <linux/string.h> 17 17 18 18 #include <drm/drm_encoder.h> 19 - #include <drm/drm_fb_helper.h> 20 19 #include <drm/drm_gem.h> 21 20 #include <drm/drm_gem_vram_helper.h> 22 21 ··· 53 54 struct vbox_private { 54 55 /* Must be first; or we must define our own release callback */ 55 56 struct drm_device ddev; 56 - struct drm_fb_helper fb_helper; 57 - struct vbox_framebuffer afb; 58 57 59 58 u8 __iomem *guest_heap; 60 59 u8 __iomem *vbva_buffers; ··· 151 154 struct vbox_framebuffer *vbox_fb, 152 155 const struct drm_mode_fb_cmd2 *mode_cmd, 153 156 struct drm_gem_object *obj); 154 - 155 - int vboxfb_create(struct drm_fb_helper *helper, 156 - struct drm_fb_helper_surface_size *sizes); 157 - void vbox_fbdev_fini(struct vbox_private *vbox); 158 157 159 158 int vbox_mm_init(struct vbox_private *vbox); 160 159 void vbox_mm_fini(struct vbox_private *vbox);
-149
drivers/gpu/drm/vboxvideo/vbox_fb.c
··· 1 - // SPDX-License-Identifier: MIT 2 - /* 3 - * Copyright (C) 2013-2017 Oracle Corporation 4 - * This file is based on ast_fb.c 5 - * Copyright 2012 Red Hat Inc. 6 - * Authors: Dave Airlie <airlied@redhat.com> 7 - * Michael Thayer <michael.thayer@oracle.com, 8 - */ 9 - #include <linux/delay.h> 10 - #include <linux/errno.h> 11 - #include <linux/fb.h> 12 - #include <linux/init.h> 13 - #include <linux/kernel.h> 14 - #include <linux/mm.h> 15 - #include <linux/module.h> 16 - #include <linux/pci.h> 17 - #include <linux/string.h> 18 - #include <linux/sysrq.h> 19 - #include <linux/tty.h> 20 - 21 - #include <drm/drm_crtc.h> 22 - #include <drm/drm_crtc_helper.h> 23 - #include <drm/drm_fb_helper.h> 24 - #include <drm/drm_fourcc.h> 25 - 26 - #include "vbox_drv.h" 27 - #include "vboxvideo.h" 28 - 29 - #ifdef CONFIG_DRM_KMS_FB_HELPER 30 - static struct fb_deferred_io vbox_defio = { 31 - .delay = HZ / 30, 32 - .deferred_io = drm_fb_helper_deferred_io, 33 - }; 34 - #endif 35 - 36 - static struct fb_ops vboxfb_ops = { 37 - .owner = THIS_MODULE, 38 - DRM_FB_HELPER_DEFAULT_OPS, 39 - .fb_fillrect = drm_fb_helper_sys_fillrect, 40 - .fb_copyarea = drm_fb_helper_sys_copyarea, 41 - .fb_imageblit = drm_fb_helper_sys_imageblit, 42 - }; 43 - 44 - int vboxfb_create(struct drm_fb_helper *helper, 45 - struct drm_fb_helper_surface_size *sizes) 46 - { 47 - struct vbox_private *vbox = 48 - container_of(helper, struct vbox_private, fb_helper); 49 - struct pci_dev *pdev = vbox->ddev.pdev; 50 - struct drm_mode_fb_cmd2 mode_cmd; 51 - struct drm_framebuffer *fb; 52 - struct fb_info *info; 53 - struct drm_gem_object *gobj; 54 - struct drm_gem_vram_object *gbo; 55 - int size, ret; 56 - s64 gpu_addr; 57 - u32 pitch; 58 - 59 - mode_cmd.width = sizes->surface_width; 60 - mode_cmd.height = sizes->surface_height; 61 - pitch = mode_cmd.width * ((sizes->surface_bpp + 7) / 8); 62 - mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, 63 - sizes->surface_depth); 64 - mode_cmd.pitches[0] = pitch; 65 - 66 - size = pitch * mode_cmd.height; 67 - 68 - ret = vbox_gem_create(vbox, size, true, &gobj); 69 - if (ret) { 70 - DRM_ERROR("failed to create fbcon backing object %d\n", ret); 71 - return ret; 72 - } 73 - 74 - ret = vbox_framebuffer_init(vbox, &vbox->afb, &mode_cmd, gobj); 75 - if (ret) 76 - return ret; 77 - 78 - gbo = drm_gem_vram_of_gem(gobj); 79 - 80 - ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM); 81 - if (ret) 82 - return ret; 83 - 84 - info = drm_fb_helper_alloc_fbi(helper); 85 - if (IS_ERR(info)) 86 - return PTR_ERR(info); 87 - 88 - info->screen_size = size; 89 - info->screen_base = (char __iomem *)drm_gem_vram_kmap(gbo, true, NULL); 90 - if (IS_ERR(info->screen_base)) 91 - return PTR_ERR(info->screen_base); 92 - 93 - fb = &vbox->afb.base; 94 - helper->fb = fb; 95 - 96 - info->fbops = &vboxfb_ops; 97 - 98 - /* 99 - * This seems to be done for safety checking that the framebuffer 100 - * is not registered twice by different drivers. 101 - */ 102 - info->apertures->ranges[0].base = pci_resource_start(pdev, 0); 103 - info->apertures->ranges[0].size = pci_resource_len(pdev, 0); 104 - 105 - drm_fb_helper_fill_info(info, helper, sizes); 106 - 107 - gpu_addr = drm_gem_vram_offset(gbo); 108 - if (gpu_addr < 0) 109 - return (int)gpu_addr; 110 - info->fix.smem_start = info->apertures->ranges[0].base + gpu_addr; 111 - info->fix.smem_len = vbox->available_vram_size - gpu_addr; 112 - 113 - #ifdef CONFIG_DRM_KMS_FB_HELPER 114 - info->fbdefio = &vbox_defio; 115 - fb_deferred_io_init(info); 116 - #endif 117 - 118 - info->pixmap.flags = FB_PIXMAP_SYSTEM; 119 - 120 - DRM_DEBUG_KMS("allocated %dx%d\n", fb->width, fb->height); 121 - 122 - return 0; 123 - } 124 - 125 - void vbox_fbdev_fini(struct vbox_private *vbox) 126 - { 127 - struct vbox_framebuffer *afb = &vbox->afb; 128 - 129 - #ifdef CONFIG_DRM_KMS_FB_HELPER 130 - if (vbox->fb_helper.fbdev && vbox->fb_helper.fbdev->fbdefio) 131 - fb_deferred_io_cleanup(vbox->fb_helper.fbdev); 132 - #endif 133 - 134 - drm_fb_helper_unregister_fbi(&vbox->fb_helper); 135 - 136 - if (afb->obj) { 137 - struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(afb->obj); 138 - 139 - drm_gem_vram_kunmap(gbo); 140 - drm_gem_vram_unpin(gbo); 141 - 142 - drm_gem_object_put_unlocked(afb->obj); 143 - afb->obj = NULL; 144 - } 145 - drm_fb_helper_fini(&vbox->fb_helper); 146 - 147 - drm_framebuffer_unregister_private(&afb->base); 148 - drm_framebuffer_cleanup(&afb->base); 149 - }
+2 -1
drivers/gpu/drm/vboxvideo/vbox_mode.c
··· 13 13 14 14 #include <drm/drm_atomic.h> 15 15 #include <drm/drm_atomic_helper.h> 16 + #include <drm/drm_fb_helper.h> 16 17 #include <drm/drm_fourcc.h> 17 18 #include <drm/drm_plane_helper.h> 18 19 #include <drm/drm_probe_helper.h> ··· 134 133 135 134 if (!fb1) { 136 135 fb1 = fb; 137 - if (to_vbox_framebuffer(fb1) == &vbox->afb) 136 + if (fb1 == vbox->ddev.fb_helper->fb) 138 137 break; 139 138 } else if (fb != fb1) { 140 139 single_framebuffer = false;