drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
/* vim: set ts=8 sw=8 tw=78 ai noexpandtab */
|
|
|
|
/* qxl_drv.c -- QXL driver -*- linux-c -*-
|
|
|
|
*
|
|
|
|
* Copyright 2011 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
|
|
|
|
* VA LINUX SYSTEMS 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.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Dave Airlie <airlie@redhat.com>
|
|
|
|
* Alon Levy <alevy@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2019-06-30 14:18:58 +08:00
|
|
|
#include "qxl_drv.h"
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
#include <linux/console.h>
|
2019-06-30 14:18:58 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
|
2017-04-24 12:50:30 +08:00
|
|
|
#include <drm/drm.h>
|
2019-06-30 14:18:58 +08:00
|
|
|
#include <drm/drm_drv.h>
|
|
|
|
#include <drm/drm_file.h>
|
2019-01-18 05:03:34 +08:00
|
|
|
#include <drm/drm_modeset_helper.h>
|
2019-06-30 14:18:58 +08:00
|
|
|
#include <drm/drm_prime.h>
|
2019-01-18 05:03:34 +08:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2019-06-30 14:18:58 +08:00
|
|
|
|
2013-07-04 13:02:33 +08:00
|
|
|
#include "qxl_object.h"
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
|
2014-08-08 21:56:03 +08:00
|
|
|
static const struct pci_device_id pciidlist[] = {
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
{ 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8,
|
|
|
|
0xffff00, 0 },
|
|
|
|
{ 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_OTHER << 8,
|
|
|
|
0xffff00, 0 },
|
|
|
|
{ 0, 0, 0 },
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, pciidlist);
|
|
|
|
|
2013-04-16 11:24:25 +08:00
|
|
|
static int qxl_modeset = -1;
|
2013-07-02 13:37:13 +08:00
|
|
|
int qxl_num_crtc = 4;
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
|
|
|
|
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
|
|
|
|
module_param_named(modeset, qxl_modeset, int, 0400);
|
|
|
|
|
2013-07-02 13:37:13 +08:00
|
|
|
MODULE_PARM_DESC(num_heads, "Number of virtual crtcs to expose (default 4)");
|
|
|
|
module_param_named(num_heads, qxl_num_crtc, int, 0400);
|
|
|
|
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
static struct drm_driver qxl_driver;
|
|
|
|
static struct pci_driver qxl_pci_driver;
|
|
|
|
|
|
|
|
static int
|
|
|
|
qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|
|
|
{
|
2017-01-19 21:48:05 +08:00
|
|
|
struct qxl_device *qdev;
|
|
|
|
int ret;
|
|
|
|
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
if (pdev->revision < 4) {
|
|
|
|
DRM_ERROR("qxl too old, doesn't support client_monitors_config,"
|
|
|
|
" use xf86-video-qxl in user mode");
|
|
|
|
return -EINVAL; /* TODO: ENODEV ? */
|
|
|
|
}
|
2017-01-19 21:48:05 +08:00
|
|
|
|
|
|
|
qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
|
2017-01-27 09:05:48 +08:00
|
|
|
if (!qdev)
|
|
|
|
return -ENOMEM;
|
2017-01-19 21:48:05 +08:00
|
|
|
|
|
|
|
ret = pci_enable_device(pdev);
|
|
|
|
if (ret)
|
2017-01-27 09:05:48 +08:00
|
|
|
goto free_dev;
|
2017-01-19 21:48:05 +08:00
|
|
|
|
2019-03-01 17:25:01 +08:00
|
|
|
ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "qxl");
|
|
|
|
if (ret)
|
|
|
|
goto disable_pci;
|
|
|
|
|
2017-02-28 04:43:15 +08:00
|
|
|
ret = qxl_device_init(qdev, &qxl_driver, pdev);
|
2017-01-19 21:48:05 +08:00
|
|
|
if (ret)
|
|
|
|
goto disable_pci;
|
|
|
|
|
|
|
|
ret = qxl_modeset_init(qdev);
|
|
|
|
if (ret)
|
2017-02-28 04:43:17 +08:00
|
|
|
goto unload;
|
2017-01-19 21:48:05 +08:00
|
|
|
|
2017-01-27 09:05:48 +08:00
|
|
|
drm_kms_helper_poll_init(&qdev->ddev);
|
2017-01-19 21:48:05 +08:00
|
|
|
|
|
|
|
/* Complete initialization. */
|
2017-01-27 09:05:48 +08:00
|
|
|
ret = drm_dev_register(&qdev->ddev, ent->driver_data);
|
2017-01-19 21:48:05 +08:00
|
|
|
if (ret)
|
|
|
|
goto modeset_cleanup;
|
|
|
|
|
2019-01-18 20:20:14 +08:00
|
|
|
drm_fbdev_generic_setup(&qdev->ddev, 32);
|
2017-01-19 21:48:05 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
modeset_cleanup:
|
|
|
|
qxl_modeset_fini(qdev);
|
|
|
|
unload:
|
|
|
|
qxl_device_fini(qdev);
|
|
|
|
disable_pci:
|
|
|
|
pci_disable_device(pdev);
|
2017-01-27 09:05:48 +08:00
|
|
|
free_dev:
|
2017-01-19 21:48:05 +08:00
|
|
|
kfree(qdev);
|
|
|
|
return ret;
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
qxl_pci_remove(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
2017-01-19 21:48:06 +08:00
|
|
|
struct qxl_device *qdev = dev->dev_private;
|
|
|
|
|
|
|
|
drm_dev_unregister(dev);
|
|
|
|
|
|
|
|
qxl_modeset_fini(qdev);
|
|
|
|
qxl_device_fini(qdev);
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
|
2017-01-19 21:48:06 +08:00
|
|
|
dev->dev_private = NULL;
|
|
|
|
kfree(qdev);
|
2018-07-13 20:03:18 +08:00
|
|
|
drm_dev_put(dev);
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations qxl_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = drm_open,
|
|
|
|
.release = drm_release,
|
|
|
|
.unlocked_ioctl = drm_ioctl,
|
|
|
|
.poll = drm_poll,
|
2014-08-08 16:40:55 +08:00
|
|
|
.read = drm_read,
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
.mmap = qxl_mmap,
|
|
|
|
};
|
|
|
|
|
2013-07-04 13:02:33 +08:00
|
|
|
static int qxl_drm_freeze(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = dev->pdev;
|
|
|
|
struct qxl_device *qdev = dev->dev_private;
|
2018-09-05 04:27:47 +08:00
|
|
|
int ret;
|
2013-07-04 13:02:33 +08:00
|
|
|
|
2018-09-05 04:27:47 +08:00
|
|
|
ret = drm_mode_config_helper_suspend(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2013-07-04 13:02:33 +08:00
|
|
|
|
|
|
|
qxl_destroy_monitors_object(qdev);
|
|
|
|
qxl_surf_evict(qdev);
|
|
|
|
qxl_vram_evict(qdev);
|
|
|
|
|
|
|
|
while (!qxl_check_idle(qdev->command_ring));
|
|
|
|
while (!qxl_check_idle(qdev->release_ring))
|
|
|
|
qxl_queue_garbage_collect(qdev, 1);
|
|
|
|
|
|
|
|
pci_save_state(pdev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_drm_resume(struct drm_device *dev, bool thaw)
|
|
|
|
{
|
|
|
|
struct qxl_device *qdev = dev->dev_private;
|
|
|
|
|
|
|
|
qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
|
|
|
|
if (!thaw) {
|
|
|
|
qxl_reinit_memslots(qdev);
|
|
|
|
qxl_ring_init_hdr(qdev->release_ring);
|
|
|
|
}
|
|
|
|
|
|
|
|
qxl_create_monitors_object(qdev);
|
2018-09-05 04:27:47 +08:00
|
|
|
return drm_mode_config_helper_resume(dev);
|
2013-07-04 13:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
|
|
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = qxl_drm_freeze(drm_dev);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
pci_set_power_state(pdev, PCI_D3hot);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
|
|
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
pci_set_power_state(pdev, PCI_D0);
|
|
|
|
pci_restore_state(pdev);
|
|
|
|
if (pci_enable_device(pdev)) {
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return qxl_drm_resume(drm_dev, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_thaw(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
|
|
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
return qxl_drm_resume(drm_dev, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_freeze(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
|
|
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
return qxl_drm_freeze(drm_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_restore(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
|
|
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
|
|
|
struct qxl_device *qdev = drm_dev->dev_private;
|
|
|
|
|
|
|
|
qxl_io_reset(qdev);
|
|
|
|
return qxl_drm_resume(drm_dev, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dev_pm_ops qxl_pm_ops = {
|
|
|
|
.suspend = qxl_pm_suspend,
|
|
|
|
.resume = qxl_pm_resume,
|
|
|
|
.freeze = qxl_pm_freeze,
|
|
|
|
.thaw = qxl_pm_thaw,
|
|
|
|
.poweroff = qxl_pm_freeze,
|
|
|
|
.restore = qxl_pm_restore,
|
|
|
|
};
|
|
|
|
static struct pci_driver qxl_pci_driver = {
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.id_table = pciidlist,
|
|
|
|
.probe = qxl_pci_probe,
|
|
|
|
.remove = qxl_pci_remove,
|
|
|
|
.driver.pm = &qxl_pm_ops,
|
|
|
|
};
|
|
|
|
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
static struct drm_driver qxl_driver = {
|
2019-06-17 23:39:24 +08:00
|
|
|
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
|
|
|
|
.dumb_create = qxl_mode_dumb_create,
|
|
|
|
.dumb_map_offset = qxl_mode_dumb_mmap,
|
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
|
|
|
.debugfs_init = qxl_debugfs_init,
|
|
|
|
#endif
|
2019-04-26 13:33:24 +08:00
|
|
|
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
|
|
|
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
2014-08-08 16:40:56 +08:00
|
|
|
.gem_prime_pin = qxl_gem_prime_pin,
|
|
|
|
.gem_prime_unpin = qxl_gem_prime_unpin,
|
2019-04-26 13:33:24 +08:00
|
|
|
.gem_prime_get_sg_table = qxl_gem_prime_get_sg_table,
|
|
|
|
.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
|
2014-08-08 16:40:56 +08:00
|
|
|
.gem_prime_vmap = qxl_gem_prime_vmap,
|
|
|
|
.gem_prime_vunmap = qxl_gem_prime_vunmap,
|
|
|
|
.gem_prime_mmap = qxl_gem_prime_mmap,
|
2016-05-31 01:53:01 +08:00
|
|
|
.gem_free_object_unlocked = qxl_gem_object_free,
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
.gem_open_object = qxl_gem_object_open,
|
|
|
|
.gem_close_object = qxl_gem_object_close,
|
|
|
|
.fops = &qxl_fops,
|
|
|
|
.ioctls = qxl_ioctls,
|
|
|
|
.irq_handler = qxl_irq_handler,
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.desc = DRIVER_DESC,
|
|
|
|
.date = DRIVER_DATE,
|
|
|
|
.major = 0,
|
|
|
|
.minor = 1,
|
|
|
|
.patchlevel = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init qxl_init(void)
|
|
|
|
{
|
|
|
|
if (vgacon_text_force() && qxl_modeset == -1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (qxl_modeset == 0)
|
|
|
|
return -EINVAL;
|
|
|
|
qxl_driver.num_ioctls = qxl_max_ioctls;
|
2017-05-24 22:51:40 +08:00
|
|
|
return pci_register_driver(&qxl_pci_driver);
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit qxl_exit(void)
|
|
|
|
{
|
2017-05-24 22:51:40 +08:00
|
|
|
pci_unregister_driver(&qxl_pci_driver);
|
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop
interface.
The drivers uses GEM and TTM to manage memory, the qxl hw fencing however
is quite different than normal TTM expects, we have to keep track of a number
of non-linear fence ids per bo that we need to have released by the hardware.
The releases are freed from a workqueue that wakes up and processes the
release ring.
releases are suballocated from a BO, there are 3 release categories, drawables,
surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling.
The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface
ids.
This requires a newer version of the QXL userspace driver, so shouldn't be
enabled until that has been placed into your distro of choice.
Authors: Dave Airlie, Alon Levy
v1.1: fixup some issues in the ioctl interface with padding
v1.2: add module device table
v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq,
don't try flush release ring (broken hw), fix -modesetting.
v1.4: fbcon cpu usage reduction + suitable accel flags.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-02-25 12:47:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(qxl_init);
|
|
|
|
module_exit(qxl_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL and additional rights");
|