Commit d516e75c authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Gerd Hoffmann

drm/virtio: Drop deprecated load/unload initialization

Move the code around so the driver is probed the bus
.probe and removed from the bus .remove callbacks.
This commit is just a cleanup and shouldn't affect
functionality.
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190108145930.15080-1-ezequiel@collabora.comSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 00eb5b0d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Makefile for the drm device driver. This driver provides support for the # Makefile for the drm device driver. This driver provides support for the
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_drm_bus.o virtgpu_gem.o \ virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o \
virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \
virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \
virtgpu_ioctl.o virtgpu_prime.o virtgpu_ioctl.o virtgpu_prime.o
......
...@@ -358,7 +358,7 @@ static const struct drm_mode_config_funcs virtio_gpu_mode_funcs = { ...@@ -358,7 +358,7 @@ static const struct drm_mode_config_funcs virtio_gpu_mode_funcs = {
.atomic_commit = drm_atomic_helper_commit, .atomic_commit = drm_atomic_helper_commit,
}; };
int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev) void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
{ {
int i; int i;
...@@ -377,7 +377,6 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev) ...@@ -377,7 +377,6 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
vgdev_output_init(vgdev, i); vgdev_output_init(vgdev, i);
drm_mode_config_reset(vgdev->ddev); drm_mode_config_reset(vgdev->ddev);
return 0;
} }
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev) void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev)
......
/*
* Copyright (C) 2015 Red Hat, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <linux/pci.h>
#include <drm/drm_fb_helper.h>
#include "virtgpu_drv.h"
int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
{
struct drm_device *dev;
int ret;
dev = drm_dev_alloc(driver, &vdev->dev);
if (IS_ERR(dev))
return PTR_ERR(dev);
vdev->priv = dev;
if (strcmp(vdev->dev.parent->bus->name, "pci") == 0) {
struct pci_dev *pdev = to_pci_dev(vdev->dev.parent);
const char *pname = dev_name(&pdev->dev);
bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
char unique[20];
DRM_INFO("pci: %s detected at %s\n",
vga ? "virtio-vga" : "virtio-gpu-pci",
pname);
dev->pdev = pdev;
if (vga)
drm_fb_helper_remove_conflicting_pci_framebuffers(pdev,
0,
"virtiodrmfb");
/*
* Normally the drm_dev_set_unique() call is done by core DRM.
* The following comment covers, why virtio cannot rely on it.
*
* Unlike the other virtual GPU drivers, virtio abstracts the
* underlying bus type by using struct virtio_device.
*
* Hence the dev_is_pci() check, used in core DRM, will fail
* and the unique returned will be the virtio_device "virtio0",
* while a "pci:..." one is required.
*
* A few other ideas were considered:
* - Extend the dev_is_pci() check [in drm_set_busid] to
* consider virtio.
* Seems like a bigger hack than what we have already.
*
* - Point drm_device::dev to the parent of the virtio_device
* Semantic changes:
* * Using the wrong device for i2c, framebuffer_alloc and
* prime import.
* Visual changes:
* * Helpers such as DRM_DEV_ERROR, dev_info, drm_printer,
* will print the wrong information.
*
* We could address the latter issues, by introducing
* drm_device::bus_dev, ... which would be used solely for this.
*
* So for the moment keep things as-is, with a bulky comment
* for the next person who feels like removing this
* drm_dev_set_unique() quirk.
*/
snprintf(unique, sizeof(unique), "pci:%s", pname);
ret = drm_dev_set_unique(dev, unique);
if (ret)
goto err_free;
}
ret = drm_dev_register(dev, 0);
if (ret)
goto err_free;
return 0;
err_free:
drm_dev_put(dev);
return ret;
}
...@@ -40,8 +40,60 @@ static int virtio_gpu_modeset = -1; ...@@ -40,8 +40,60 @@ static int virtio_gpu_modeset = -1;
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
module_param_named(modeset, virtio_gpu_modeset, int, 0400); module_param_named(modeset, virtio_gpu_modeset, int, 0400);
static int virtio_gpu_pci_quirk(struct drm_device *dev, struct virtio_device *vdev)
{
struct pci_dev *pdev = to_pci_dev(vdev->dev.parent);
const char *pname = dev_name(&pdev->dev);
bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
char unique[20];
DRM_INFO("pci: %s detected at %s\n",
vga ? "virtio-vga" : "virtio-gpu-pci",
pname);
dev->pdev = pdev;
if (vga)
drm_fb_helper_remove_conflicting_pci_framebuffers(pdev,
0,
"virtiodrmfb");
/*
* Normally the drm_dev_set_unique() call is done by core DRM.
* The following comment covers, why virtio cannot rely on it.
*
* Unlike the other virtual GPU drivers, virtio abstracts the
* underlying bus type by using struct virtio_device.
*
* Hence the dev_is_pci() check, used in core DRM, will fail
* and the unique returned will be the virtio_device "virtio0",
* while a "pci:..." one is required.
*
* A few other ideas were considered:
* - Extend the dev_is_pci() check [in drm_set_busid] to
* consider virtio.
* Seems like a bigger hack than what we have already.
*
* - Point drm_device::dev to the parent of the virtio_device
* Semantic changes:
* * Using the wrong device for i2c, framebuffer_alloc and
* prime import.
* Visual changes:
* * Helpers such as DRM_DEV_ERROR, dev_info, drm_printer,
* will print the wrong information.
*
* We could address the latter issues, by introducing
* drm_device::bus_dev, ... which would be used solely for this.
*
* So for the moment keep things as-is, with a bulky comment
* for the next person who feels like removing this
* drm_dev_set_unique() quirk.
*/
snprintf(unique, sizeof(unique), "pci:%s", pname);
return drm_dev_set_unique(dev, unique);
}
static int virtio_gpu_probe(struct virtio_device *vdev) static int virtio_gpu_probe(struct virtio_device *vdev)
{ {
struct drm_device *dev;
int ret; int ret;
if (vgacon_text_force() && virtio_gpu_modeset == -1) if (vgacon_text_force() && virtio_gpu_modeset == -1)
...@@ -50,18 +102,39 @@ static int virtio_gpu_probe(struct virtio_device *vdev) ...@@ -50,18 +102,39 @@ static int virtio_gpu_probe(struct virtio_device *vdev)
if (virtio_gpu_modeset == 0) if (virtio_gpu_modeset == 0)
return -EINVAL; return -EINVAL;
ret = drm_virtio_init(&driver, vdev); dev = drm_dev_alloc(&driver, &vdev->dev);
if (IS_ERR(dev))
return PTR_ERR(dev);
vdev->priv = dev;
if (!strcmp(vdev->dev.parent->bus->name, "pci")) {
ret = virtio_gpu_pci_quirk(dev, vdev);
if (ret) if (ret)
return ret; goto err_free;
}
ret = virtio_gpu_init(dev);
if (ret)
goto err_free;
ret = drm_dev_register(dev, 0);
if (ret)
goto err_free;
drm_fbdev_generic_setup(vdev->priv, 32); drm_fbdev_generic_setup(vdev->priv, 32);
return 0; return 0;
err_free:
drm_dev_put(dev);
return ret;
} }
static void virtio_gpu_remove(struct virtio_device *vdev) static void virtio_gpu_remove(struct virtio_device *vdev)
{ {
struct drm_device *dev = vdev->priv; struct drm_device *dev = vdev->priv;
drm_dev_unregister(dev);
virtio_gpu_deinit(dev);
drm_put_dev(dev); drm_put_dev(dev);
} }
...@@ -123,8 +196,6 @@ static const struct file_operations virtio_gpu_driver_fops = { ...@@ -123,8 +196,6 @@ static const struct file_operations virtio_gpu_driver_fops = {
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER | DRIVER_ATOMIC, .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER | DRIVER_ATOMIC,
.load = virtio_gpu_driver_load,
.unload = virtio_gpu_driver_unload,
.open = virtio_gpu_driver_open, .open = virtio_gpu_driver_open,
.postclose = virtio_gpu_driver_postclose, .postclose = virtio_gpu_driver_postclose,
......
...@@ -50,9 +50,6 @@ ...@@ -50,9 +50,6 @@
#define DRIVER_MINOR 1 #define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 0
/* virtgpu_drm_bus.c */
int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev);
struct virtio_gpu_object { struct virtio_gpu_object {
struct drm_gem_object gem_base; struct drm_gem_object gem_base;
uint32_t hw_res_handle; uint32_t hw_res_handle;
...@@ -209,8 +206,8 @@ struct virtio_gpu_fpriv { ...@@ -209,8 +206,8 @@ struct virtio_gpu_fpriv {
extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS]; extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS];
/* virtio_kms.c */ /* virtio_kms.c */
int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags); int virtio_gpu_init(struct drm_device *dev);
void virtio_gpu_driver_unload(struct drm_device *dev); void virtio_gpu_deinit(struct drm_device *dev);
int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file); int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file);
void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file); void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file);
...@@ -320,7 +317,7 @@ int virtio_gpu_framebuffer_init(struct drm_device *dev, ...@@ -320,7 +317,7 @@ int virtio_gpu_framebuffer_init(struct drm_device *dev,
struct virtio_gpu_framebuffer *vgfb, struct virtio_gpu_framebuffer *vgfb,
const struct drm_mode_fb_cmd2 *mode_cmd, const struct drm_mode_fb_cmd2 *mode_cmd,
struct drm_gem_object *obj); struct drm_gem_object *obj);
int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev); void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev); void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
/* virtio_gpu_plane.c */ /* virtio_gpu_plane.c */
......
...@@ -106,7 +106,7 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev, ...@@ -106,7 +106,7 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
vgdev->num_capsets = num_capsets; vgdev->num_capsets = num_capsets;
} }
int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) int virtio_gpu_init(struct drm_device *dev)
{ {
static vq_callback_t *callbacks[] = { static vq_callback_t *callbacks[] = {
virtio_gpu_ctrl_ack, virtio_gpu_cursor_ack virtio_gpu_ctrl_ack, virtio_gpu_cursor_ack
...@@ -193,9 +193,7 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -193,9 +193,7 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags)
num_capsets, &num_capsets); num_capsets, &num_capsets);
DRM_INFO("number of cap sets: %d\n", num_capsets); DRM_INFO("number of cap sets: %d\n", num_capsets);
ret = virtio_gpu_modeset_init(vgdev); virtio_gpu_modeset_init(vgdev);
if (ret)
goto err_modeset;
virtio_device_ready(vgdev->vdev); virtio_device_ready(vgdev->vdev);
vgdev->vqs_ready = true; vgdev->vqs_ready = true;
...@@ -209,7 +207,6 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -209,7 +207,6 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags)
5 * HZ); 5 * HZ);
return 0; return 0;
err_modeset:
err_scanouts: err_scanouts:
virtio_gpu_ttm_fini(vgdev); virtio_gpu_ttm_fini(vgdev);
err_ttm: err_ttm:
...@@ -231,7 +228,7 @@ static void virtio_gpu_cleanup_cap_cache(struct virtio_gpu_device *vgdev) ...@@ -231,7 +228,7 @@ static void virtio_gpu_cleanup_cap_cache(struct virtio_gpu_device *vgdev)
} }
} }
void virtio_gpu_driver_unload(struct drm_device *dev) void virtio_gpu_deinit(struct drm_device *dev)
{ {
struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_device *vgdev = dev->dev_private;
......
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