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
|
|
|
/*
|
|
|
|
* Copyright 2013 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* 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 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 HOLDER(S) OR AUTHOR(S) 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
|
|
|
|
* Alon Levy
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qxl_drv.h"
|
|
|
|
|
2013-12-11 18:34:42 +08:00
|
|
|
irqreturn_t qxl_irq_handler(int irq, void *arg)
|
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
|
|
|
{
|
|
|
|
struct drm_device *dev = (struct drm_device *) arg;
|
|
|
|
struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
|
|
|
|
uint32_t pending;
|
|
|
|
|
|
|
|
pending = xchg(&qdev->ram_header->int_pending, 0);
|
|
|
|
|
2014-05-12 16:35:39 +08:00
|
|
|
if (!pending)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
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
|
|
|
atomic_inc(&qdev->irq_received);
|
|
|
|
|
|
|
|
if (pending & QXL_INTERRUPT_DISPLAY) {
|
|
|
|
atomic_inc(&qdev->irq_received_display);
|
|
|
|
wake_up_all(&qdev->display_event);
|
|
|
|
qxl_queue_garbage_collect(qdev, false);
|
|
|
|
}
|
|
|
|
if (pending & QXL_INTERRUPT_CURSOR) {
|
|
|
|
atomic_inc(&qdev->irq_received_cursor);
|
|
|
|
wake_up_all(&qdev->cursor_event);
|
|
|
|
}
|
|
|
|
if (pending & QXL_INTERRUPT_IO_CMD) {
|
|
|
|
atomic_inc(&qdev->irq_received_io_cmd);
|
|
|
|
wake_up_all(&qdev->io_cmd_event);
|
|
|
|
}
|
|
|
|
if (pending & QXL_INTERRUPT_ERROR) {
|
|
|
|
/* TODO: log it, reset device (only way to exit this condition)
|
|
|
|
* (do it a certain number of times, afterwards admit defeat,
|
|
|
|
* to avoid endless loops).
|
|
|
|
*/
|
|
|
|
qdev->irq_received_error++;
|
2018-04-20 15:19:01 +08:00
|
|
|
DRM_WARN("driver is in bug mode\n");
|
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 (pending & QXL_INTERRUPT_CLIENT_MONITORS_CONFIG) {
|
|
|
|
schedule_work(&qdev->client_monitors_config_work);
|
|
|
|
}
|
|
|
|
qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
|
|
|
|
outb(0, qdev->io_base + QXL_IO_UPDATE_IRQ);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qxl_client_monitors_config_work_func(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct qxl_device *qdev = container_of(work, struct qxl_device,
|
|
|
|
client_monitors_config_work);
|
|
|
|
|
|
|
|
qxl_display_read_client_monitors_config(qdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
int qxl_irq_init(struct qxl_device *qdev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
init_waitqueue_head(&qdev->display_event);
|
|
|
|
init_waitqueue_head(&qdev->cursor_event);
|
|
|
|
init_waitqueue_head(&qdev->io_cmd_event);
|
|
|
|
INIT_WORK(&qdev->client_monitors_config_work,
|
|
|
|
qxl_client_monitors_config_work_func);
|
|
|
|
atomic_set(&qdev->irq_received, 0);
|
|
|
|
atomic_set(&qdev->irq_received_display, 0);
|
|
|
|
atomic_set(&qdev->irq_received_cursor, 0);
|
|
|
|
atomic_set(&qdev->irq_received_io_cmd, 0);
|
|
|
|
qdev->irq_received_error = 0;
|
2017-01-27 09:05:48 +08:00
|
|
|
ret = drm_irq_install(&qdev->ddev, qdev->ddev.pdev->irq);
|
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
|
|
|
qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
|
|
|
|
if (unlikely(ret != 0)) {
|
|
|
|
DRM_ERROR("Failed installing irq: %d\n", ret);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|