Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

drm/ttm: Use the Linux wait queues API

Reducing differences with Linux 3.9 (ttm) and Linux 3.8 (rest of the code)
  • Loading branch information...
commit a832fc0dc3a7e59b10f5fe57bed43809a2d77791 1 parent a6796b4
François Tigeot authored
View
1  sys/dev/drm/drm_fops.c
@@ -171,6 +171,7 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
INIT_LIST_HEAD(&priv->fbs);
INIT_LIST_HEAD(&priv->event_list);
+ init_waitqueue_head(&priv->event_wait);
priv->event_space = 4096; /* set aside 4k for event buffer */
if (dev->driver->driver_features & DRIVER_GEM)
View
28 sys/dev/drm/include/drm/drmP.h
@@ -99,6 +99,7 @@
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/types.h>
+#include <linux/wait.h>
#include <asm/uaccess.h>
@@ -202,7 +203,6 @@ SYSCTL_DECL(_hw_drm);
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
-#define wait_queue_head_t atomic_t
#define DRM_WAKEUP(w) wakeup((void *)w)
#define DRM_WAKEUP_INT(w) wakeup(w)
#define DRM_INIT_WAITQUEUE(queue) do {(void)(queue);} while (0)
@@ -456,14 +456,15 @@ typedef struct drm_buf {
void *dev_private; /**< Per-buffer private storage */
} drm_buf_t;
-typedef struct drm_freelist {
+struct drm_freelist {
int initialized; /* Freelist in use */
atomic_t count; /* Number of free buffers */
drm_buf_t *next; /* End pointer */
+ wait_queue_head_t waiting; /**< Processes waiting on free bufs */
int low_mark; /* Low water mark */
int high_mark; /* High water mark */
-} drm_freelist_t;
+};
typedef struct drm_dma_handle {
void *vaddr;
@@ -480,7 +481,7 @@ typedef struct drm_buf_entry {
drm_dma_handle_t **seglist;
int page_order;
- drm_freelist_t freelist;
+ struct drm_freelist freelist;
} drm_buf_entry_t;
/* Event queued up for userspace to read */
@@ -524,18 +525,23 @@ struct drm_file {
struct list_head fbs;
+ wait_queue_head_t event_wait;
struct list_head event_list;
int event_space;
struct drm_prime_file_private prime;
};
-typedef struct drm_lock_data {
- struct drm_hw_lock *hw_lock; /* Hardware lock */
- struct drm_file *file_priv; /* Unique identifier of holding process (NULL is kernel)*/
- int lock_queue; /* Queue of blocked processes */
- unsigned long lock_time; /* Time of last lock in jiffies */
-} drm_lock_data_t;
+/**
+ * Lock data.
+ */
+struct drm_lock_data {
+ struct drm_hw_lock *hw_lock; /**< Hardware lock */
+ /** Private of lock holder's file (NULL=kernel) */
+ struct drm_file *file_priv;
+ wait_queue_head_t lock_queue; /**< Queue of blocked processes */
+ unsigned long lock_time; /**< Time of last lock in jiffies */
+};
/* This structure, in the struct drm_device, is always initialized while the
* device
@@ -954,7 +960,7 @@ struct drm_device {
drm_local_map_t **context_sareas;
int max_context;
- drm_lock_data_t lock; /* Information on hardware lock */
+ struct drm_lock_data lock; /* Information on hardware lock */
/* DMA queues (contexts) */
drm_device_dma_t *dma; /* Optional pointer for DMA support */
View
2  sys/dev/drm/include/drm/ttm/ttm_bo_api.h
@@ -208,7 +208,7 @@ struct ttm_buffer_object {
struct kref kref;
struct kref list_kref;
- /* wait_queue_head_t event_queue; */
+ wait_queue_head_t event_queue;
/**
* Members protected by the bo::reserved lock.
View
1  sys/dev/drm/include/drm/ttm/ttm_lock.h
@@ -68,6 +68,7 @@
struct ttm_lock {
struct ttm_base_object base;
+ wait_queue_head_t queue;
struct lock lock;
int32_t rw;
uint32_t flags;
View
18 sys/dev/drm/ttm/ttm_bo.c
@@ -38,6 +38,7 @@
#include <linux/atomic.h>
#include <linux/export.h>
#include <linux/rbtree.h>
+#include <linux/wait.h>
#define TTM_ASSERT_LOCKED(param)
#define TTM_DEBUG(fmt, arg...)
@@ -257,7 +258,7 @@ int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo,
bo->val_seq = sequence;
bo->seq_valid = true;
if (wake_up)
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
} else {
bo->seq_valid = false;
}
@@ -323,7 +324,7 @@ int ttm_bo_reserve_slowpath_nolru(struct ttm_buffer_object *bo,
bo->val_seq = sequence;
bo->seq_valid = true;
if (wake_up)
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
return 0;
}
@@ -349,7 +350,7 @@ void ttm_bo_unreserve_locked(struct ttm_buffer_object *bo)
{
ttm_bo_add_to_lru(bo);
atomic_set(&bo->reserved, 0);
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
}
void ttm_bo_unreserve(struct ttm_buffer_object *bo)
@@ -533,7 +534,7 @@ static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo)
ttm_bo_mem_put(bo, &bo->mem);
atomic_set(&bo->reserved, 0);
- wakeup(&bo);
+ wake_up_all(&bo->event_queue);
/*
* Since the final reference to this bo may not be dropped by
@@ -576,7 +577,7 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
if (!ret) {
atomic_set(&bo->reserved, 0);
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
}
kref_get(&bo->list_kref);
@@ -628,7 +629,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
lockmgr(&bdev->fence_lock, LK_RELEASE);
atomic_set(&bo->reserved, 0);
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
lockmgr(&glob->lru_lock, LK_RELEASE);
ret = driver->sync_obj_wait(sync_obj, false, interruptible);
@@ -667,7 +668,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
if (ret || unlikely(list_empty(&bo->ddestroy))) {
atomic_set(&bo->reserved, 0);
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
lockmgr(&glob->lru_lock, LK_RELEASE);
return ret;
}
@@ -1260,6 +1261,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
kref_init(&bo->list_kref);
atomic_set(&bo->cpu_writers, 0);
atomic_set(&bo->reserved, 1);
+ init_waitqueue_head(&bo->event_queue);
INIT_LIST_HEAD(&bo->lru);
INIT_LIST_HEAD(&bo->ddestroy);
INIT_LIST_HEAD(&bo->swap);
@@ -1914,7 +1916,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
*/
atomic_set(&bo->reserved, 0);
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
kref_put(&bo->list_kref, ttm_bo_release_list);
return ret;
}
View
2  sys/dev/drm/ttm/ttm_bo_util.c
@@ -32,6 +32,7 @@
#include <drm/ttm/ttm_placement.h>
#include <sys/sfbuf.h>
#include <linux/export.h>
+#include <linux/wait.h>
void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
{
@@ -416,6 +417,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
* TODO: Explicit member copy would probably be better here.
*/
+ init_waitqueue_head(&fbo->event_queue);
INIT_LIST_HEAD(&fbo->ddestroy);
INIT_LIST_HEAD(&fbo->lru);
INIT_LIST_HEAD(&fbo->swap);
View
3  sys/dev/drm/ttm/ttm_execbuf_util.c
@@ -29,6 +29,7 @@
#include <drm/ttm/ttm_bo_driver.h>
#include <drm/ttm/ttm_placement.h>
#include <linux/export.h>
+#include <linux/wait.h>
static void ttm_eu_backoff_reservation_locked(struct list_head *list)
{
@@ -46,7 +47,7 @@ static void ttm_eu_backoff_reservation_locked(struct list_head *list)
}
entry->reserved = false;
atomic_set(&bo->reserved, 0);
- wakeup(bo);
+ wake_up_all(&bo->event_queue);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.