Skip to content

Commit

Permalink
drm/qxl: rework to new fence interface
Browse files Browse the repository at this point in the history
Final driver! \o/

This is not a proper dma_fence because the hardware may never signal
anything, so don't use dma-buf with qxl, ever.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
  • Loading branch information
Maarten Lankhorst committed Sep 2, 2014
1 parent 29ba89b commit 2f453ed
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 175 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/qxl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

ccflags-y := -Iinclude/drm

qxl-y := qxl_drv.o qxl_kms.o qxl_display.o qxl_ttm.o qxl_fb.o qxl_object.o qxl_gem.o qxl_cmd.o qxl_image.o qxl_draw.o qxl_debugfs.o qxl_irq.o qxl_dumb.o qxl_ioctl.o qxl_fence.o qxl_release.o
qxl-y := qxl_drv.o qxl_kms.o qxl_display.o qxl_ttm.o qxl_fb.o qxl_object.o qxl_gem.o qxl_cmd.o qxl_image.o qxl_draw.o qxl_debugfs.o qxl_irq.o qxl_dumb.o qxl_ioctl.o qxl_release.o

obj-$(CONFIG_DRM_QXL)+= qxl.o
5 changes: 0 additions & 5 deletions drivers/gpu/drm/qxl/qxl_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,6 @@ static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stal
if (ret == -EBUSY)
return -EBUSY;

if (surf->fence.num_active_releases > 0 && stall == false) {
qxl_bo_unreserve(surf);
return -EBUSY;
}

if (stall)
mutex_unlock(&qdev->surf_evict_mutex);

Expand Down
12 changes: 11 additions & 1 deletion drivers/gpu/drm/qxl/qxl_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ qxl_debugfs_buffers_info(struct seq_file *m, void *data)
struct qxl_device *qdev = node->minor->dev->dev_private;
struct qxl_bo *bo;

spin_lock(&qdev->release_lock);
list_for_each_entry(bo, &qdev->gem.objects, list) {
struct reservation_object_list *fobj;
int rel;

rcu_read_lock();
fobj = rcu_dereference(bo->tbo.resv->fence);
rel = fobj ? fobj->shared_count : 0;
rcu_read_unlock();

seq_printf(m, "size %ld, pc %d, sync obj %p, num releases %d\n",
(unsigned long)bo->gem_base.size, bo->pin_count,
bo->tbo.sync_obj, bo->fence.num_active_releases);
bo->tbo.sync_obj, rel);
}
spin_unlock(&qdev->release_lock);
return 0;
}

Expand Down
22 changes: 8 additions & 14 deletions drivers/gpu/drm/qxl/qxl_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Definitions taken from spice-protocol, plus kernel driver specific bits.
*/

#include <linux/fence.h>
#include <linux/workqueue.h>
#include <linux/firmware.h>
#include <linux/platform_device.h>
Expand Down Expand Up @@ -95,13 +96,6 @@ enum {
QXL_INTERRUPT_IO_CMD |\
QXL_INTERRUPT_CLIENT_MONITORS_CONFIG)

struct qxl_fence {
struct qxl_device *qdev;
uint32_t num_active_releases;
uint32_t *release_ids;
struct radix_tree_root tree;
};

struct qxl_bo {
/* Protected by gem.mutex */
struct list_head list;
Expand All @@ -113,13 +107,13 @@ struct qxl_bo {
unsigned pin_count;
void *kptr;
int type;

/* Constant after initialization */
struct drm_gem_object gem_base;
bool is_primary; /* is this now a primary surface */
bool hw_surf_alloc;
struct qxl_surface surf;
uint32_t surface_id;
struct qxl_fence fence; /* per bo fence - list of releases */
struct qxl_release *surf_create;
};
#define gem_to_qxl_bo(gobj) container_of((gobj), struct qxl_bo, gem_base)
Expand Down Expand Up @@ -191,6 +185,8 @@ enum {
* spice-protocol/qxl_dev.h */
#define QXL_MAX_RES 96
struct qxl_release {
struct fence base;

int id;
int type;
uint32_t release_offset;
Expand Down Expand Up @@ -284,7 +280,11 @@ struct qxl_device {
uint8_t slot_gen_bits;
uint64_t va_slot_mask;

/* XXX: when rcu becomes available, release_lock can be killed */
spinlock_t release_lock;
spinlock_t fence_lock;
struct idr release_idr;
uint32_t release_seqno;
spinlock_t release_idr_lock;
struct mutex async_io_mutex;
unsigned int last_sent_io_cmd;
Expand Down Expand Up @@ -561,10 +561,4 @@ qxl_surface_lookup(struct drm_device *dev, int surface_id);
void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool freeing);
int qxl_update_surface(struct qxl_device *qdev, struct qxl_bo *surf);

/* qxl_fence.c */
void qxl_fence_add_release_locked(struct qxl_fence *qfence, uint32_t rel_id);
int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id);
int qxl_fence_init(struct qxl_device *qdev, struct qxl_fence *qfence);
void qxl_fence_fini(struct qxl_fence *qfence);

#endif
87 changes: 0 additions & 87 deletions drivers/gpu/drm/qxl/qxl_fence.c

This file was deleted.

2 changes: 2 additions & 0 deletions drivers/gpu/drm/qxl/qxl_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ static int qxl_device_init(struct qxl_device *qdev,

idr_init(&qdev->release_idr);
spin_lock_init(&qdev->release_idr_lock);
spin_lock_init(&qdev->release_lock);
spin_lock_init(&qdev->fence_lock);

idr_init(&qdev->surf_id_idr);
spin_lock_init(&qdev->surf_id_idr_lock);
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/qxl/qxl_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
qdev = (struct qxl_device *)bo->gem_base.dev->dev_private;

qxl_surface_evict(qdev, bo, false);
qxl_fence_fini(&bo->fence);
mutex_lock(&qdev->gem.mutex);
list_del_init(&bo->list);
mutex_unlock(&qdev->gem.mutex);
Expand Down Expand Up @@ -102,7 +101,6 @@ int qxl_bo_create(struct qxl_device *qdev,
bo->type = domain;
bo->pin_count = pinned ? 1 : 0;
bo->surface_id = 0;
qxl_fence_init(qdev, &bo->fence);
INIT_LIST_HEAD(&bo->list);

if (surf)
Expand Down
Loading

0 comments on commit 2f453ed

Please sign in to comment.