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 14:47:55 +10:00
|
|
|
/* 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 08:18:58 +02:00
|
|
|
#include "qxl_drv.h"
|
2021-04-12 15:10:42 +02:00
|
|
|
|
2024-09-30 15:03:12 +02:00
|
|
|
#include <linux/aperture.h>
|
2019-06-30 08:18:58 +02:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
2021-04-12 15:10:42 +02:00
|
|
|
#include <linux/vgaarb.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 14:47:55 +10:00
|
|
|
|
2024-11-08 16:42:38 +01:00
|
|
|
#include <drm/clients/drm_client_setup.h>
|
2017-04-24 13:50:30 +09:00
|
|
|
#include <drm/drm.h>
|
2020-02-10 12:37:52 +01:00
|
|
|
#include <drm/drm_atomic_helper.h>
|
2019-06-30 08:18:58 +02:00
|
|
|
#include <drm/drm_drv.h>
|
2024-04-19 10:29:35 +02:00
|
|
|
#include <drm/drm_fbdev_ttm.h>
|
2019-06-30 08:18:58 +02:00
|
|
|
#include <drm/drm_file.h>
|
2021-04-08 16:01:39 +02:00
|
|
|
#include <drm/drm_gem_ttm_helper.h>
|
2021-12-17 15:46:13 +01:00
|
|
|
#include <drm/drm_module.h>
|
2019-01-17 22:03:34 +01:00
|
|
|
#include <drm/drm_modeset_helper.h>
|
2019-06-30 08:18:58 +02:00
|
|
|
#include <drm/drm_prime.h>
|
2019-01-17 22:03:34 +01:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2019-06-30 08:18:58 +02:00
|
|
|
|
2013-07-04 15:02:33 +10: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 14:47:55 +10:00
|
|
|
|
2014-08-08 15:56:03 +02: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 14:47:55 +10: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 13:24:25 +10:00
|
|
|
static int qxl_modeset = -1;
|
2013-07-02 06:37:13 +01: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 14:47:55 +10:00
|
|
|
|
|
|
|
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
|
|
|
|
module_param_named(modeset, qxl_modeset, int, 0400);
|
|
|
|
|
2013-07-02 06:37:13 +01: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 14:47:55 +10: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 11:48:05 -02: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 14:47:55 +10: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 11:48:05 -02:00
|
|
|
|
2020-04-15 09:40:01 +02:00
|
|
|
qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
|
|
|
|
struct qxl_device, ddev);
|
|
|
|
if (IS_ERR(qdev)) {
|
|
|
|
pr_err("Unable to init drm dev");
|
2017-01-26 23:05:48 -02:00
|
|
|
return -ENOMEM;
|
2020-04-15 09:40:01 +02:00
|
|
|
}
|
2017-01-19 11:48:05 -02:00
|
|
|
|
|
|
|
ret = pci_enable_device(pdev);
|
|
|
|
if (ret)
|
2020-04-15 09:40:01 +02:00
|
|
|
return ret;
|
2017-01-19 11:48:05 -02:00
|
|
|
|
2024-09-30 15:03:12 +02:00
|
|
|
ret = aperture_remove_conflicting_pci_devices(pdev, qxl_driver.name);
|
2019-03-01 10:25:01 +01:00
|
|
|
if (ret)
|
|
|
|
goto disable_pci;
|
|
|
|
|
2023-08-30 19:15:32 +08:00
|
|
|
if (pci_is_vga(pdev) && pdev->revision < 5) {
|
2019-08-05 12:54:01 +02:00
|
|
|
ret = vga_get_interruptible(pdev, VGA_RSRC_LEGACY_IO);
|
|
|
|
if (ret) {
|
|
|
|
DRM_ERROR("can't get legacy vga ioports\n");
|
|
|
|
goto disable_pci;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-15 09:40:01 +02:00
|
|
|
ret = qxl_device_init(qdev, pdev);
|
2017-01-19 11:48:05 -02:00
|
|
|
if (ret)
|
2019-08-05 12:54:01 +02:00
|
|
|
goto put_vga;
|
2017-01-19 11:48:05 -02:00
|
|
|
|
|
|
|
ret = qxl_modeset_init(qdev);
|
|
|
|
if (ret)
|
2017-02-27 17:43:17 -03:00
|
|
|
goto unload;
|
2017-01-19 11:48:05 -02:00
|
|
|
|
2017-01-26 23:05:48 -02:00
|
|
|
drm_kms_helper_poll_init(&qdev->ddev);
|
2017-01-19 11:48:05 -02:00
|
|
|
|
|
|
|
/* Complete initialization. */
|
2017-01-26 23:05:48 -02:00
|
|
|
ret = drm_dev_register(&qdev->ddev, ent->driver_data);
|
2017-01-19 11:48:05 -02:00
|
|
|
if (ret)
|
|
|
|
goto modeset_cleanup;
|
|
|
|
|
2024-09-24 09:13:07 +02:00
|
|
|
drm_client_setup(&qdev->ddev, NULL);
|
2017-01-19 11:48:05 -02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
modeset_cleanup:
|
|
|
|
qxl_modeset_fini(qdev);
|
|
|
|
unload:
|
|
|
|
qxl_device_fini(qdev);
|
2019-08-05 12:54:01 +02:00
|
|
|
put_vga:
|
2023-08-30 19:15:32 +08:00
|
|
|
if (pci_is_vga(pdev) && pdev->revision < 5)
|
2019-08-05 12:54:01 +02:00
|
|
|
vga_put(pdev, VGA_RSRC_LEGACY_IO);
|
2017-01-19 11:48:05 -02:00
|
|
|
disable_pci:
|
|
|
|
pci_disable_device(pdev);
|
2020-04-15 09:40:01 +02:00
|
|
|
|
2017-01-19 11:48:05 -02:00
|
|
|
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 14:47:55 +10:00
|
|
|
}
|
|
|
|
|
2020-02-10 12:37:52 +01:00
|
|
|
static void qxl_drm_release(struct drm_device *dev)
|
|
|
|
{
|
2020-04-15 09:40:02 +02:00
|
|
|
struct qxl_device *qdev = to_qxl(dev);
|
2020-02-10 12:37:52 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: qxl_device_fini() call should be in qxl_pci_remove(),
|
2020-08-25 16:44:48 -05:00
|
|
|
* reordering qxl_modeset_fini() + qxl_device_fini() calls is
|
2020-02-10 12:37:52 +01:00
|
|
|
* non-trivial though.
|
|
|
|
*/
|
|
|
|
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 14:47:55 +10:00
|
|
|
static void
|
|
|
|
qxl_pci_remove(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
2017-01-19 11:48:06 -02:00
|
|
|
|
|
|
|
drm_dev_unregister(dev);
|
2020-02-10 12:37:52 +01:00
|
|
|
drm_atomic_helper_shutdown(dev);
|
2023-08-30 19:15:32 +08:00
|
|
|
if (pci_is_vga(pdev) && pdev->revision < 5)
|
2019-08-05 12:54:01 +02:00
|
|
|
vga_put(pdev, VGA_RSRC_LEGACY_IO);
|
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 14:47:55 +10:00
|
|
|
}
|
|
|
|
|
2023-09-01 16:39:53 -07:00
|
|
|
static void
|
|
|
|
qxl_pci_shutdown(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
drm_atomic_helper_shutdown(pci_get_drvdata(pdev));
|
|
|
|
}
|
|
|
|
|
2019-10-17 15:26:37 +02:00
|
|
|
DEFINE_DRM_GEM_FOPS(qxl_fops);
|
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 14:47:55 +10:00
|
|
|
|
2013-07-04 15:02:33 +10:00
|
|
|
static int qxl_drm_freeze(struct drm_device *dev)
|
|
|
|
{
|
2020-12-01 11:35:36 +01:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
2020-04-15 09:40:02 +02:00
|
|
|
struct qxl_device *qdev = to_qxl(dev);
|
2018-09-04 22:27:47 +02:00
|
|
|
int ret;
|
2013-07-04 15:02:33 +10:00
|
|
|
|
2018-09-04 22:27:47 +02:00
|
|
|
ret = drm_mode_config_helper_suspend(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2013-07-04 15:02:33 +10: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)
|
|
|
|
{
|
2020-04-15 09:40:02 +02:00
|
|
|
struct qxl_device *qdev = to_qxl(dev);
|
2013-07-04 15:02:33 +10:00
|
|
|
|
|
|
|
qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
|
|
|
|
if (!thaw) {
|
|
|
|
qxl_reinit_memslots(qdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
qxl_create_monitors_object(qdev);
|
2018-09-04 22:27:47 +02:00
|
|
|
return drm_mode_config_helper_resume(dev);
|
2013-07-04 15:02:33 +10: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);
|
drm/qxl: fix the suspend/resume issue on qxl device
Details:
Currently, when trying to suspend and resume with qxl device,
there are some error messages after resuming,
eventually caused to black screen and can't be recovered.
The first error message:
[ 64.668577][ C3] [drm] driver is in bug mode
This error is due to guest qxl driver
will call qxl_reinit_memslots(qdev) during system resume,
but didn't call qxl_io_reset(qdev) before this,
Then will cause the QXL_IO_MEMSLOT_ADD operation to fail on QEMU,
qxl->guest_bug flag will be set,As a result,
the QXL device can't communicate with guest qxl driver through the IO port.
after fix the first error,can success to resume and login to desktop,
but shortly after that will observe the second error message :
[ 353.095343][ T863] qxl 0000:00:02.0: object_init failed for (262144, 0x00000001)
[ 353.096660][ T863] [drm:qxl_gem_object_create [qxl]] *ERROR* Failed to allocate GEM object (260852, 1, 4096, -12)
[ 353.097277][ T863] [drm:qxl_alloc_ioctl [qxl]] *ERROR* qxl_alloc_ioctl: failed to create gem ret=-12
[ 368.197538][ T863] qxl 0000:00:02.0: object_init failed for (3149824, 0x00000001)
[ 368.197541][ T863] [drm:qxl_alloc_bo_reserved [qxl]] *ERROR* failed to allocate VRAM BO
The problem is caused by calling qxl_ring_init_hdr(qdev->release_ring)
in qxl_drm_resume() function.
When do QXL_IO_RESET,QEMU will call init_qxl_ram(),
so params like prod,cons,notify_on_cons and notify_on_prod
will be set to default value.
Ring push/pop actions for release_ring can be performed normally.
But call qxl_ring_init_hdr(qdev->release_ring)
will eventually set notify_on_prod to number of QXL_RELEASE_RING_SIZE,
affect the value of notify in qxl_push_free_res() function always be false,
QEMU will no longer send events of QXL_INTERRUPT_DISPLAY to the
guest qxl driver,so qxl_ring_pop() will never been called anymore,
and can't do dma_fence_signal(),result to ttm_bo_wait_ctx(bo, ctx)
always return EBUSY,fail to call qxl_bo_create().
Test scenario:
1) start virtual machine with qemu command "-device qxl-vga"
2) click suspend botton to enter suspend mode
3) resume and observe the error message in kernel logs,screen will be black
Let's fix this by reset io and remove the qxl_ring_init_hdr calling.
Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
Suggested-by: Ming Xie<xieming@kylinos.cn>
Link: http://patchwork.freedesktop.org/patch/msgid/20220907094423.93581-1-min_halo@163.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2022-09-07 17:44:23 +08:00
|
|
|
struct qxl_device *qdev = to_qxl(drm_dev);
|
2013-07-04 15:02:33 +10:00
|
|
|
|
|
|
|
pci_set_power_state(pdev, PCI_D0);
|
|
|
|
pci_restore_state(pdev);
|
|
|
|
if (pci_enable_device(pdev)) {
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
drm/qxl: fix the suspend/resume issue on qxl device
Details:
Currently, when trying to suspend and resume with qxl device,
there are some error messages after resuming,
eventually caused to black screen and can't be recovered.
The first error message:
[ 64.668577][ C3] [drm] driver is in bug mode
This error is due to guest qxl driver
will call qxl_reinit_memslots(qdev) during system resume,
but didn't call qxl_io_reset(qdev) before this,
Then will cause the QXL_IO_MEMSLOT_ADD operation to fail on QEMU,
qxl->guest_bug flag will be set,As a result,
the QXL device can't communicate with guest qxl driver through the IO port.
after fix the first error,can success to resume and login to desktop,
but shortly after that will observe the second error message :
[ 353.095343][ T863] qxl 0000:00:02.0: object_init failed for (262144, 0x00000001)
[ 353.096660][ T863] [drm:qxl_gem_object_create [qxl]] *ERROR* Failed to allocate GEM object (260852, 1, 4096, -12)
[ 353.097277][ T863] [drm:qxl_alloc_ioctl [qxl]] *ERROR* qxl_alloc_ioctl: failed to create gem ret=-12
[ 368.197538][ T863] qxl 0000:00:02.0: object_init failed for (3149824, 0x00000001)
[ 368.197541][ T863] [drm:qxl_alloc_bo_reserved [qxl]] *ERROR* failed to allocate VRAM BO
The problem is caused by calling qxl_ring_init_hdr(qdev->release_ring)
in qxl_drm_resume() function.
When do QXL_IO_RESET,QEMU will call init_qxl_ram(),
so params like prod,cons,notify_on_cons and notify_on_prod
will be set to default value.
Ring push/pop actions for release_ring can be performed normally.
But call qxl_ring_init_hdr(qdev->release_ring)
will eventually set notify_on_prod to number of QXL_RELEASE_RING_SIZE,
affect the value of notify in qxl_push_free_res() function always be false,
QEMU will no longer send events of QXL_INTERRUPT_DISPLAY to the
guest qxl driver,so qxl_ring_pop() will never been called anymore,
and can't do dma_fence_signal(),result to ttm_bo_wait_ctx(bo, ctx)
always return EBUSY,fail to call qxl_bo_create().
Test scenario:
1) start virtual machine with qemu command "-device qxl-vga"
2) click suspend botton to enter suspend mode
3) resume and observe the error message in kernel logs,screen will be black
Let's fix this by reset io and remove the qxl_ring_init_hdr calling.
Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
Suggested-by: Ming Xie<xieming@kylinos.cn>
Link: http://patchwork.freedesktop.org/patch/msgid/20220907094423.93581-1-min_halo@163.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2022-09-07 17:44:23 +08:00
|
|
|
qxl_io_reset(qdev);
|
2013-07-04 15:02:33 +10:00
|
|
|
return qxl_drm_resume(drm_dev, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_thaw(struct device *dev)
|
|
|
|
{
|
2019-07-23 18:40:00 +08:00
|
|
|
struct drm_device *drm_dev = dev_get_drvdata(dev);
|
2013-07-04 15:02:33 +10:00
|
|
|
|
|
|
|
return qxl_drm_resume(drm_dev, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_pm_freeze(struct device *dev)
|
|
|
|
{
|
2019-07-23 18:40:00 +08:00
|
|
|
struct drm_device *drm_dev = dev_get_drvdata(dev);
|
2013-07-04 15:02:33 +10:00
|
|
|
|
|
|
|
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);
|
2020-04-15 09:40:02 +02:00
|
|
|
struct qxl_device *qdev = to_qxl(drm_dev);
|
2013-07-04 15:02:33 +10:00
|
|
|
|
|
|
|
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,
|
2023-09-01 16:39:53 -07:00
|
|
|
.shutdown = qxl_pci_shutdown,
|
2013-07-04 15:02:33 +10:00
|
|
|
.driver.pm = &qxl_pm_ops,
|
|
|
|
};
|
|
|
|
|
2021-12-17 15:46:12 +01:00
|
|
|
static const struct drm_ioctl_desc qxl_ioctls[] = {
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_ALLOC, qxl_alloc_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_MAP, qxl_map_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_EXECBUFFER, qxl_execbuffer_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_UPDATE_AREA, qxl_update_area_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_GETPARAM, qxl_getparam_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_CLIENTCAP, qxl_clientcap_ioctl, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(QXL_ALLOC_SURF, qxl_alloc_surf_ioctl, DRM_AUTH),
|
|
|
|
};
|
|
|
|
|
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 14:47:55 +10:00
|
|
|
static struct drm_driver qxl_driver = {
|
2023-10-23 09:46:05 +02:00
|
|
|
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_CURSOR_HOTSPOT,
|
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 14:47:55 +10:00
|
|
|
|
|
|
|
.dumb_create = qxl_mode_dumb_create,
|
2021-04-08 16:01:39 +02:00
|
|
|
.dumb_map_offset = drm_gem_ttm_dumb_map_offset,
|
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 14:47:55 +10:00
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
|
|
|
.debugfs_init = qxl_debugfs_init,
|
|
|
|
#endif
|
2019-04-26 07:33:24 +02:00
|
|
|
.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
|
2024-09-24 09:13:07 +02:00
|
|
|
DRM_FBDEV_TTM_DRIVER_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 14:47:55 +10:00
|
|
|
.fops = &qxl_fops,
|
|
|
|
.ioctls = qxl_ioctls,
|
2021-12-17 15:46:12 +01:00
|
|
|
.num_ioctls = ARRAY_SIZE(qxl_ioctls),
|
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 14:47:55 +10:00
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.desc = DRIVER_DESC,
|
|
|
|
.major = 0,
|
|
|
|
.minor = 1,
|
|
|
|
.patchlevel = 0,
|
2020-02-10 12:37:52 +01:00
|
|
|
|
|
|
|
.release = qxl_drm_release,
|
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 14:47:55 +10:00
|
|
|
};
|
|
|
|
|
2021-12-17 15:46:13 +01:00
|
|
|
drm_module_pci_driver_if_modeset(qxl_pci_driver, qxl_modeset);
|
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 14:47:55 +10:00
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL and additional rights");
|