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 11:47:55 +07:00
|
|
|
/*
|
|
|
|
* Copyright 2011 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
|
|
|
|
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
|
|
|
* license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS 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 "qxl_drv.h"
|
|
|
|
#include "qxl_object.h"
|
2016-10-25 19:00:45 +07:00
|
|
|
#include <trace/events/dma_fence.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 11:47:55 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* drawable cmd cache - allocate a bunch of VRAM pages, suballocate
|
|
|
|
* into 256 byte chunks for now - gives 16 cmds per page.
|
|
|
|
*
|
|
|
|
* use an ida to index into the chunks?
|
|
|
|
*/
|
|
|
|
/* manage releaseables */
|
|
|
|
/* stack them 16 high for now -drawable object is 191 */
|
|
|
|
#define RELEASE_SIZE 256
|
|
|
|
#define RELEASES_PER_BO (4096 / RELEASE_SIZE)
|
|
|
|
/* put an alloc/dealloc surface cmd into one bo and round up to 128 */
|
|
|
|
#define SURFACE_RELEASE_SIZE 128
|
|
|
|
#define SURFACE_RELEASES_PER_BO (4096 / SURFACE_RELEASE_SIZE)
|
|
|
|
|
|
|
|
static const int release_size_per_bo[] = { RELEASE_SIZE, SURFACE_RELEASE_SIZE, RELEASE_SIZE };
|
|
|
|
static const int releases_per_bo[] = { RELEASES_PER_BO, SURFACE_RELEASES_PER_BO, RELEASES_PER_BO };
|
2013-07-23 11:16:42 +07:00
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
static const char *qxl_get_driver_name(struct dma_fence *fence)
|
2014-04-02 17:40:05 +07:00
|
|
|
{
|
|
|
|
return "qxl";
|
|
|
|
}
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
static const char *qxl_get_timeline_name(struct dma_fence *fence)
|
2014-04-02 17:40:05 +07:00
|
|
|
{
|
|
|
|
return "release";
|
|
|
|
}
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
static bool qxl_nop_signaling(struct dma_fence *fence)
|
2014-04-02 17:40:05 +07:00
|
|
|
{
|
|
|
|
/* fences are always automatically signaled, so just pretend we did this.. */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
static long qxl_fence_wait(struct dma_fence *fence, bool intr,
|
|
|
|
signed long timeout)
|
2014-04-02 17:40:05 +07:00
|
|
|
{
|
|
|
|
struct qxl_device *qdev;
|
|
|
|
struct qxl_release *release;
|
|
|
|
int count = 0, sc = 0;
|
|
|
|
bool have_drawable_releases;
|
|
|
|
unsigned long cur, end = jiffies + timeout;
|
|
|
|
|
|
|
|
qdev = container_of(fence->lock, struct qxl_device, release_lock);
|
|
|
|
release = container_of(fence, struct qxl_release, base);
|
|
|
|
have_drawable_releases = release->type == QXL_RELEASE_DRAWABLE;
|
|
|
|
|
|
|
|
retry:
|
|
|
|
sc++;
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
if (dma_fence_is_signaled(fence))
|
2014-04-02 17:40:05 +07:00
|
|
|
goto signaled;
|
|
|
|
|
|
|
|
qxl_io_notify_oom(qdev);
|
|
|
|
|
|
|
|
for (count = 0; count < 11; count++) {
|
|
|
|
if (!qxl_queue_garbage_collect(qdev, true))
|
|
|
|
break;
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
if (dma_fence_is_signaled(fence))
|
2014-04-02 17:40:05 +07:00
|
|
|
goto signaled;
|
|
|
|
}
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
if (dma_fence_is_signaled(fence))
|
2014-04-02 17:40:05 +07:00
|
|
|
goto signaled;
|
|
|
|
|
|
|
|
if (have_drawable_releases || sc < 4) {
|
|
|
|
if (sc > 2)
|
|
|
|
/* back off */
|
|
|
|
usleep_range(500, 1000);
|
|
|
|
|
|
|
|
if (time_after(jiffies, end))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (have_drawable_releases && sc > 300) {
|
2016-10-25 19:00:45 +07:00
|
|
|
DMA_FENCE_WARN(fence, "failed to wait on release %llu "
|
|
|
|
"after spincount %d\n",
|
|
|
|
fence->context & ~0xf0000000, sc);
|
2014-04-02 17:40:05 +07:00
|
|
|
goto signaled;
|
|
|
|
}
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* yeah, original sync_obj_wait gave up after 3 spins when
|
|
|
|
* have_drawable_releases is not set.
|
|
|
|
*/
|
|
|
|
|
|
|
|
signaled:
|
|
|
|
cur = jiffies;
|
|
|
|
if (time_after(cur, end))
|
|
|
|
return 0;
|
|
|
|
return end - cur;
|
|
|
|
}
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
static const struct dma_fence_ops qxl_fence_ops = {
|
2014-04-02 17:40:05 +07:00
|
|
|
.get_driver_name = qxl_get_driver_name,
|
|
|
|
.get_timeline_name = qxl_get_timeline_name,
|
|
|
|
.enable_signaling = qxl_nop_signaling,
|
|
|
|
.wait = qxl_fence_wait,
|
|
|
|
};
|
|
|
|
|
2015-06-03 18:09:14 +07:00
|
|
|
static int
|
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 11:47:55 +07:00
|
|
|
qxl_release_alloc(struct qxl_device *qdev, int type,
|
|
|
|
struct qxl_release **ret)
|
|
|
|
{
|
|
|
|
struct qxl_release *release;
|
2013-05-03 07:37:20 +07:00
|
|
|
int handle;
|
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 11:47:55 +07:00
|
|
|
size_t size = sizeof(*release);
|
|
|
|
|
|
|
|
release = kmalloc(size, GFP_KERNEL);
|
|
|
|
if (!release) {
|
|
|
|
DRM_ERROR("Out of memory\n");
|
2016-12-03 22:11:42 +07:00
|
|
|
return -ENOMEM;
|
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 11:47:55 +07:00
|
|
|
}
|
2014-04-02 17:40:05 +07:00
|
|
|
release->base.ops = NULL;
|
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 11:47:55 +07:00
|
|
|
release->type = type;
|
|
|
|
release->release_offset = 0;
|
|
|
|
release->surface_release_id = 0;
|
2013-07-23 11:16:42 +07:00
|
|
|
INIT_LIST_HEAD(&release->bos);
|
2013-05-03 07:37:20 +07:00
|
|
|
|
|
|
|
idr_preload(GFP_KERNEL);
|
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 11:47:55 +07:00
|
|
|
spin_lock(&qdev->release_idr_lock);
|
2014-04-02 17:40:05 +07:00
|
|
|
handle = idr_alloc(&qdev->release_idr, release, 1, 0, GFP_NOWAIT);
|
|
|
|
release->base.seqno = ++qdev->release_seqno;
|
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 11:47:55 +07:00
|
|
|
spin_unlock(&qdev->release_idr_lock);
|
2013-05-03 07:37:20 +07:00
|
|
|
idr_preload_end();
|
2014-04-02 17:40:05 +07:00
|
|
|
if (handle < 0) {
|
|
|
|
kfree(release);
|
|
|
|
*ret = NULL;
|
|
|
|
return handle;
|
|
|
|
}
|
2013-05-03 07:37:20 +07:00
|
|
|
*ret = release;
|
2017-10-19 13:21:49 +07:00
|
|
|
DRM_DEBUG_DRIVER("allocated release %d\n", handle);
|
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 11:47:55 +07:00
|
|
|
release->id = handle;
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2014-04-02 17:40:05 +07:00
|
|
|
static void
|
|
|
|
qxl_release_free_list(struct qxl_release *release)
|
|
|
|
{
|
|
|
|
while (!list_empty(&release->bos)) {
|
2014-09-03 22:01:28 +07:00
|
|
|
struct qxl_bo_list *entry;
|
|
|
|
struct qxl_bo *bo;
|
2014-04-02 17:40:05 +07:00
|
|
|
|
|
|
|
entry = container_of(release->bos.next,
|
2014-09-03 22:01:28 +07:00
|
|
|
struct qxl_bo_list, tv.head);
|
|
|
|
bo = to_qxl_bo(entry->tv.bo);
|
|
|
|
qxl_bo_unref(&bo);
|
|
|
|
list_del(&entry->tv.head);
|
2014-04-02 17:40:05 +07:00
|
|
|
kfree(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 11:47:55 +07:00
|
|
|
void
|
|
|
|
qxl_release_free(struct qxl_device *qdev,
|
|
|
|
struct qxl_release *release)
|
|
|
|
{
|
2017-10-19 13:21:49 +07:00
|
|
|
DRM_DEBUG_DRIVER("release %d, type %d\n", release->id, release->type);
|
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 11:47:55 +07:00
|
|
|
|
|
|
|
if (release->surface_release_id)
|
|
|
|
qxl_surface_id_dealloc(qdev, release->surface_release_id);
|
|
|
|
|
|
|
|
spin_lock(&qdev->release_idr_lock);
|
|
|
|
idr_remove(&qdev->release_idr, release->id);
|
|
|
|
spin_unlock(&qdev->release_idr_lock);
|
2014-04-02 17:40:05 +07:00
|
|
|
|
|
|
|
if (release->base.ops) {
|
|
|
|
WARN_ON(list_empty(&release->bos));
|
|
|
|
qxl_release_free_list(release);
|
|
|
|
|
2016-10-25 19:00:45 +07:00
|
|
|
dma_fence_signal(&release->base);
|
|
|
|
dma_fence_put(&release->base);
|
2014-04-02 17:40:05 +07:00
|
|
|
} else {
|
|
|
|
qxl_release_free_list(release);
|
|
|
|
kfree(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 11:47:55 +07:00
|
|
|
}
|
|
|
|
|
2013-04-16 10:24:25 +07:00
|
|
|
static int qxl_release_bo_alloc(struct qxl_device *qdev,
|
|
|
|
struct qxl_bo **bo)
|
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 11:47:55 +07:00
|
|
|
{
|
2013-07-23 11:06:07 +07:00
|
|
|
/* pin releases bo's they are too messy to evict */
|
2016-09-14 21:39:11 +07:00
|
|
|
return qxl_bo_create(qdev, PAGE_SIZE, false, true,
|
|
|
|
QXL_GEM_DOMAIN_VRAM, NULL, bo);
|
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 11:47:55 +07:00
|
|
|
}
|
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)
|
|
|
|
{
|
|
|
|
struct qxl_bo_list *entry;
|
|
|
|
|
|
|
|
list_for_each_entry(entry, &release->bos, tv.head) {
|
|
|
|
if (entry->tv.bo == &bo->tbo)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = kmalloc(sizeof(struct qxl_bo_list), GFP_KERNEL);
|
|
|
|
if (!entry)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
qxl_bo_ref(bo);
|
|
|
|
entry->tv.bo = &bo->tbo;
|
2014-09-05 01:01:52 +07:00
|
|
|
entry->tv.shared = false;
|
2013-07-23 11:16:42 +07:00
|
|
|
list_add_tail(&entry->tv.head, &release->bos);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qxl_release_validate_bo(struct qxl_bo *bo)
|
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 11:47:55 +07:00
|
|
|
{
|
|
|
|
int ret;
|
2013-07-23 11:16:42 +07:00
|
|
|
|
|
|
|
if (!bo->pin_count) {
|
|
|
|
qxl_ttm_placement_from_domain(bo, bo->type, false);
|
|
|
|
ret = ttm_bo_validate(&bo->tbo, &bo->placement,
|
|
|
|
true, false);
|
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 11:47:55 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
2013-07-23 11:16:42 +07:00
|
|
|
|
2014-04-02 17:40:05 +07:00
|
|
|
ret = reservation_object_reserve_shared(bo->tbo.resv);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
/* allocate a surface for reserved + validated buffers */
|
|
|
|
ret = qxl_bo_check_id(bo->gem_base.dev->dev_private, bo);
|
|
|
|
if (ret)
|
|
|
|
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 11:47:55 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
int qxl_release_reserve_list(struct qxl_release *release, bool no_intr)
|
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 11:47:55 +07:00
|
|
|
{
|
2013-07-23 11:16:42 +07:00
|
|
|
int ret;
|
|
|
|
struct qxl_bo_list *entry;
|
|
|
|
|
|
|
|
/* if only one object on the release its the release itself
|
|
|
|
since these objects are pinned no need to reserve */
|
|
|
|
if (list_is_singular(&release->bos))
|
|
|
|
return 0;
|
|
|
|
|
2014-12-03 21:46:48 +07:00
|
|
|
ret = ttm_eu_reserve_buffers(&release->ticket, &release->bos,
|
|
|
|
!no_intr, NULL);
|
2013-07-23 11:16:42 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
list_for_each_entry(entry, &release->bos, tv.head) {
|
|
|
|
struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
|
|
|
|
|
|
|
|
ret = qxl_release_validate_bo(bo);
|
|
|
|
if (ret) {
|
|
|
|
ttm_eu_backoff_reservation(&release->ticket, &release->bos);
|
|
|
|
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 11:47:55 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
void qxl_release_backoff_reserve_list(struct qxl_release *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 11:47:55 +07:00
|
|
|
{
|
2013-07-23 11:16:42 +07:00
|
|
|
/* if only one object on the release its the release itself
|
|
|
|
since these objects are pinned no need to reserve */
|
|
|
|
if (list_is_singular(&release->bos))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ttm_eu_backoff_reservation(&release->ticket, &release->bos);
|
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 11:47:55 +07:00
|
|
|
}
|
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
|
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 11:47:55 +07:00
|
|
|
int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
|
|
|
|
enum qxl_surface_cmd_type surface_cmd_type,
|
|
|
|
struct qxl_release *create_rel,
|
|
|
|
struct qxl_release **release)
|
|
|
|
{
|
|
|
|
if (surface_cmd_type == QXL_SURFACE_CMD_DESTROY && create_rel) {
|
|
|
|
int idr_ret;
|
2013-07-23 11:16:42 +07:00
|
|
|
struct qxl_bo_list *entry = list_first_entry(&create_rel->bos, struct qxl_bo_list, tv.head);
|
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 11:47:55 +07:00
|
|
|
struct qxl_bo *bo;
|
|
|
|
union qxl_release_info *info;
|
|
|
|
|
|
|
|
/* stash the release after the create command */
|
|
|
|
idr_ret = qxl_release_alloc(qdev, QXL_RELEASE_SURFACE_CMD, release);
|
2014-04-02 17:40:05 +07:00
|
|
|
if (idr_ret < 0)
|
|
|
|
return idr_ret;
|
2015-09-24 20:18:22 +07:00
|
|
|
bo = to_qxl_bo(entry->tv.bo);
|
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 11:47:55 +07:00
|
|
|
|
|
|
|
(*release)->release_offset = create_rel->release_offset + 64;
|
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
qxl_release_list_add(*release, bo);
|
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 11:47:55 +07:00
|
|
|
|
|
|
|
info = qxl_release_map(qdev, *release);
|
|
|
|
info->id = idr_ret;
|
|
|
|
qxl_release_unmap(qdev, *release, info);
|
2013-07-23 11:16:42 +07:00
|
|
|
return 0;
|
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 11:47:55 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return qxl_alloc_release_reserved(qdev, sizeof(struct qxl_surface_cmd),
|
|
|
|
QXL_RELEASE_SURFACE_CMD, release, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
|
|
|
|
int type, struct qxl_release **release,
|
|
|
|
struct qxl_bo **rbo)
|
|
|
|
{
|
|
|
|
struct qxl_bo *bo;
|
|
|
|
int idr_ret;
|
2013-07-23 11:16:42 +07:00
|
|
|
int ret = 0;
|
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 11:47:55 +07:00
|
|
|
union qxl_release_info *info;
|
|
|
|
int cur_idx;
|
|
|
|
|
|
|
|
if (type == QXL_RELEASE_DRAWABLE)
|
|
|
|
cur_idx = 0;
|
|
|
|
else if (type == QXL_RELEASE_SURFACE_CMD)
|
|
|
|
cur_idx = 1;
|
|
|
|
else if (type == QXL_RELEASE_CURSOR_CMD)
|
|
|
|
cur_idx = 2;
|
|
|
|
else {
|
|
|
|
DRM_ERROR("got illegal type: %d\n", type);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
idr_ret = qxl_release_alloc(qdev, type, release);
|
2014-04-02 17:40:05 +07:00
|
|
|
if (idr_ret < 0) {
|
|
|
|
if (rbo)
|
|
|
|
*rbo = NULL;
|
|
|
|
return idr_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 11:47:55 +07:00
|
|
|
|
|
|
|
mutex_lock(&qdev->release_mutex);
|
|
|
|
if (qdev->current_release_bo_offset[cur_idx] + 1 >= releases_per_bo[cur_idx]) {
|
|
|
|
qxl_bo_unref(&qdev->current_release_bo[cur_idx]);
|
|
|
|
qdev->current_release_bo_offset[cur_idx] = 0;
|
|
|
|
qdev->current_release_bo[cur_idx] = NULL;
|
|
|
|
}
|
|
|
|
if (!qdev->current_release_bo[cur_idx]) {
|
|
|
|
ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx]);
|
|
|
|
if (ret) {
|
|
|
|
mutex_unlock(&qdev->release_mutex);
|
2015-06-03 18:09:15 +07:00
|
|
|
qxl_release_free(qdev, *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 11:47:55 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bo = qxl_bo_ref(qdev->current_release_bo[cur_idx]);
|
|
|
|
|
|
|
|
(*release)->release_offset = qdev->current_release_bo_offset[cur_idx] * release_size_per_bo[cur_idx];
|
|
|
|
qdev->current_release_bo_offset[cur_idx]++;
|
|
|
|
|
|
|
|
if (rbo)
|
|
|
|
*rbo = bo;
|
|
|
|
|
|
|
|
mutex_unlock(&qdev->release_mutex);
|
2013-07-23 11:16:42 +07:00
|
|
|
|
2015-06-03 18:09:15 +07:00
|
|
|
ret = qxl_release_list_add(*release, bo);
|
|
|
|
qxl_bo_unref(&bo);
|
|
|
|
if (ret) {
|
|
|
|
qxl_release_free(qdev, *release);
|
|
|
|
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 11:47:55 +07:00
|
|
|
|
|
|
|
info = qxl_release_map(qdev, *release);
|
|
|
|
info->id = idr_ret;
|
|
|
|
qxl_release_unmap(qdev, *release, info);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
|
|
|
|
uint64_t id)
|
|
|
|
{
|
|
|
|
struct qxl_release *release;
|
|
|
|
|
|
|
|
spin_lock(&qdev->release_idr_lock);
|
|
|
|
release = idr_find(&qdev->release_idr, id);
|
|
|
|
spin_unlock(&qdev->release_idr_lock);
|
|
|
|
if (!release) {
|
|
|
|
DRM_ERROR("failed to find id in release_idr\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-23 11:16:42 +07:00
|
|
|
|
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 11:47:55 +07:00
|
|
|
return release;
|
|
|
|
}
|
|
|
|
|
|
|
|
union qxl_release_info *qxl_release_map(struct qxl_device *qdev,
|
|
|
|
struct qxl_release *release)
|
|
|
|
{
|
|
|
|
void *ptr;
|
|
|
|
union qxl_release_info *info;
|
2013-07-23 11:16:42 +07:00
|
|
|
struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
|
|
|
|
struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
|
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 11:47:55 +07:00
|
|
|
|
|
|
|
ptr = qxl_bo_kmap_atomic_page(qdev, bo, release->release_offset & PAGE_SIZE);
|
2013-07-23 11:16:42 +07:00
|
|
|
if (!ptr)
|
|
|
|
return NULL;
|
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 11:47:55 +07:00
|
|
|
info = ptr + (release->release_offset & ~PAGE_SIZE);
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qxl_release_unmap(struct qxl_device *qdev,
|
|
|
|
struct qxl_release *release,
|
|
|
|
union qxl_release_info *info)
|
|
|
|
{
|
2013-07-23 11:16:42 +07:00
|
|
|
struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
|
|
|
|
struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
|
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 11:47:55 +07:00
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
ptr = ((void *)info) - (release->release_offset & ~PAGE_SIZE);
|
|
|
|
qxl_bo_kunmap_atomic_page(qdev, bo, ptr);
|
|
|
|
}
|
2013-07-23 11:16:42 +07:00
|
|
|
|
|
|
|
void qxl_release_fence_buffer_objects(struct qxl_release *release)
|
|
|
|
{
|
|
|
|
struct ttm_buffer_object *bo;
|
|
|
|
struct ttm_bo_global *glob;
|
|
|
|
struct ttm_bo_device *bdev;
|
|
|
|
struct ttm_bo_driver *driver;
|
|
|
|
struct qxl_bo *qbo;
|
2014-04-02 17:40:05 +07:00
|
|
|
struct ttm_validate_buffer *entry;
|
|
|
|
struct qxl_device *qdev;
|
2013-07-23 11:16:42 +07:00
|
|
|
|
|
|
|
/* if only one object on the release its the release itself
|
|
|
|
since these objects are pinned no need to reserve */
|
2014-09-03 22:02:44 +07:00
|
|
|
if (list_is_singular(&release->bos) || list_empty(&release->bos))
|
2013-07-23 11:16:42 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
bo = list_first_entry(&release->bos, struct ttm_validate_buffer, head)->bo;
|
|
|
|
bdev = bo->bdev;
|
2014-04-02 17:40:05 +07:00
|
|
|
qdev = container_of(bdev, struct qxl_device, mman.bdev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we never really allocated a context and we don't want to conflict,
|
|
|
|
* set the highest bits. This will break if we really allow exporting of dma-bufs.
|
|
|
|
*/
|
2016-10-25 19:00:45 +07:00
|
|
|
dma_fence_init(&release->base, &qxl_fence_ops, &qdev->release_lock,
|
|
|
|
release->id | 0xf0000000, release->base.seqno);
|
|
|
|
trace_dma_fence_emit(&release->base);
|
2014-04-02 17:40:05 +07:00
|
|
|
|
2013-07-23 11:16:42 +07:00
|
|
|
driver = bdev->driver;
|
|
|
|
glob = bo->glob;
|
|
|
|
|
|
|
|
spin_lock(&glob->lru_lock);
|
|
|
|
|
|
|
|
list_for_each_entry(entry, &release->bos, head) {
|
|
|
|
bo = entry->bo;
|
|
|
|
qbo = to_qxl_bo(bo);
|
|
|
|
|
2014-04-02 17:40:05 +07:00
|
|
|
reservation_object_add_shared_fence(bo->resv, &release->base);
|
2013-07-23 11:16:42 +07:00
|
|
|
ttm_bo_add_to_lru(bo);
|
2014-02-20 17:36:25 +07:00
|
|
|
__ttm_bo_unreserve(bo);
|
2013-07-23 11:16:42 +07:00
|
|
|
}
|
|
|
|
spin_unlock(&glob->lru_lock);
|
|
|
|
ww_acquire_fini(&release->ticket);
|
|
|
|
}
|
|
|
|
|