summaryrefslogtreecommitdiff
path: root/bsd/drm
diff options
context:
space:
mode:
authorDavid Dawes <dawes@xfree86.org>2001-04-09 16:27:54 +0000
committerDavid Dawes <dawes@xfree86.org>2001-04-09 16:27:54 +0000
commit1759c16ab9b64598968a0058039e8a66bf5f9773 (patch)
treea82d44dc47302041daf1f5f408c6f47017baac47 /bsd/drm
parent0e7f6c0726e5ff08eeab8e17a5aa63fbe44b3410 (diff)
Import -f XFree86 4.0.99.2
Diffstat (limited to 'bsd/drm')
-rw-r--r--bsd/drm/auth.c4
-rw-r--r--bsd/drm/lists.c20
-rw-r--r--bsd/drm/lock.c9
-rw-r--r--bsd/drm/memory.c4
4 files changed, 30 insertions, 7 deletions
diff --git a/bsd/drm/auth.c b/bsd/drm/auth.c
index a2699011..37d17be5 100644
--- a/bsd/drm/auth.c
+++ b/bsd/drm/auth.c
@@ -135,12 +135,12 @@ int drm_getmagic(dev_t kdev, u_long cmd, caddr_t data,
if (priv->magic) {
auth.magic = priv->magic;
} else {
- simple_lock(&lock);
do {
+ simple_lock(&lock);
if (!sequence) ++sequence; /* reserve 0 */
auth.magic = sequence++;
- } while (drm_find_file(dev, auth.magic));
simple_unlock(&lock);
+ } while (drm_find_file(dev, auth.magic));
priv->magic = auth.magic;
drm_add_magic(dev, priv, auth.magic);
}
diff --git a/bsd/drm/lists.c b/bsd/drm/lists.c
index 61becaa1..b9722973 100644
--- a/bsd/drm/lists.c
+++ b/bsd/drm/lists.c
@@ -121,6 +121,7 @@ int drm_freelist_create(drm_freelist_t *bl, int count)
bl->low_mark = 0;
bl->high_mark = 0;
atomic_set(&bl->wfh, 0);
+/* bl->lock = SPIN_LOCK_UNLOCKED; */
++bl->initialized;
return 0;
}
@@ -159,6 +160,7 @@ int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf)
drm_histogram_compute(dev, buf);
#endif
buf->list = DRM_LIST_FREE;
+/*
do {
old = (unsigned long)bl->next;
buf->next = (void *)old;
@@ -169,6 +171,13 @@ int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf)
return 1;
}
} while (failed);
+*/
+
+ simple_lock(&bl->lock);
+ buf->next = bl->next;
+ bl->next = buf;
+ simple_unlock(&bl->lock);
+
atomic_inc(&bl->count);
if (atomic_read(&bl->count) > dma->buf_count) {
DRM_ERROR("%d of %d buffers free after addition of %d\n",
@@ -195,6 +204,7 @@ static drm_buf_t *drm_freelist_try(drm_freelist_t *bl)
if (!bl) return NULL;
/* Get buffer */
+/*
do {
old = (unsigned int)bl->next;
if (!old) {
@@ -210,6 +220,16 @@ static drm_buf_t *drm_freelist_try(drm_freelist_t *bl)
atomic_dec(&bl->count);
buf = (drm_buf_t *)old;
+*/
+ simple_lock(&bl->lock);
+ if(!bl->next){
+ simple_unlock(&bl->lock);
+ return NULL;
+ }
+ buf = bl->next;
+ bl->next = bl->next->next;
+ simple_unlock(&bl->lock);
+ atomic_dec(&bl->count);
buf->next = NULL;
buf->list = DRM_LIST_NONE;
DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n",
diff --git a/bsd/drm/lock.c b/bsd/drm/lock.c
index 1affcd1d..ec295b2b 100644
--- a/bsd/drm/lock.c
+++ b/bsd/drm/lock.c
@@ -135,9 +135,12 @@ static int drm_flush_queue(drm_device_t *dev, int context)
if (atomic_read(&q->use_count) > 1) {
atomic_inc(&q->block_write);
atomic_inc(&q->block_count);
- error = tsleep(&q->flush_queue, PCATCH|PZERO, "drmfq", 0);
- if (error)
- return error;
+ for (;;) {
+ if (!DRM_BUFCOUNT(&q->waitlist)) break;
+ error = tsleep(&q->flush_queue, PCATCH|PZERO, "drmfq", 0);
+ if (error)
+ return error;
+ }
atomic_dec(&q->block_count);
}
atomic_dec(&q->use_count);
diff --git a/bsd/drm/memory.c b/bsd/drm/memory.c
index 81c1b1a0..f60e2128 100644
--- a/bsd/drm/memory.c
+++ b/bsd/drm/memory.c
@@ -95,7 +95,7 @@ void drm_mem_init(void)
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
-static int _drm_mem_info SYSCTL_HANDLER_ARGS
+static int _drm_mem_info DRM_SYSCTL_HANDLER_ARGS
{
drm_mem_stats_t *pt;
char buf[128];
@@ -127,7 +127,7 @@ static int _drm_mem_info SYSCTL_HANDLER_ARGS
return 0;
}
-int drm_mem_info SYSCTL_HANDLER_ARGS
+int drm_mem_info DRM_SYSCTL_HANDLER_ARGS
{
int ret;