summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas@tungstengraphics.com>2006-06-08 13:56:35 +0000
committerThomas Hellstrom <thomas@tungstengraphics.com>2006-06-08 13:56:35 +0000
commitdde85024f2d2dc7505ae9b033b11bc3233e18e1f (patch)
tree661466d4cee656375ff90860df84de2abf39bd96
parent3092e7ec12ca07a45385a015dc6ab997770f42bb (diff)
Backport the trunk hlist hash table implementation. Enable libdrmdrm-ttm_20060608drm-ttm-20060621drm-ttm-branch
sched_yeild() Bump i915 driver date an patchlevel.
-rw-r--r--libdrm/xf86mm.c2
-rw-r--r--linux-core/drm_hashtab.c95
-rw-r--r--linux-core/drm_hashtab.h8
-rw-r--r--shared-core/i915_drv.h4
4 files changed, 57 insertions, 52 deletions
diff --git a/libdrm/xf86mm.c b/libdrm/xf86mm.c
index b8b0f861..c94c4fb7 100644
--- a/libdrm/xf86mm.c
+++ b/libdrm/xf86mm.c
@@ -265,7 +265,7 @@ drmWaitFence(int drmFD, drmFence fence)
* arbitration scheme. We need a scheduler!!.
*/
-#if 0
+#if 1
sched_yield();
if ((drmMMKI.sarea->retired[fence.fenceType & DRM_FENCE_MASK] -
diff --git a/linux-core/drm_hashtab.c b/linux-core/drm_hashtab.c
index 8fd6a348..3be781df 100644
--- a/linux-core/drm_hashtab.c
+++ b/linux-core/drm_hashtab.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2006 Tungsten Graphics, Inc., Steamboat Springs, CO. USA.
+ * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -50,7 +50,7 @@ drm_ht_create(drm_open_hash_t *ht, unsigned int order)
return -ENOMEM;
}
for (i=0; i< ht->size; ++i) {
- INIT_LIST_HEAD(&ht->table[i]);
+ INIT_HLIST_HEAD(&ht->table[i]);
}
return 0;
}
@@ -59,59 +59,65 @@ void
drm_ht_verbose_list(drm_open_hash_t *ht, unsigned long key)
{
drm_hash_item_t *entry;
- struct list_head *list, *h_list;
+ struct hlist_head *h_list;
+ struct hlist_node *list;
unsigned int hashed_key;
int count = 0;
hashed_key = hash_long(key, ht->order);
DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key);
h_list = &ht->table[hashed_key];
- list_for_each(list, h_list) {
- entry = list_entry(list, drm_hash_item_t, head);
+ hlist_for_each(list, h_list) {
+ entry = hlist_entry(list, drm_hash_item_t, head);
DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key);
}
}
-
-static struct list_head
-*drm_ht_find_key(drm_open_hash_t *ht, unsigned long key, int *found)
+static struct hlist_node
+*drm_ht_find_key(drm_open_hash_t *ht, unsigned long key)
{
drm_hash_item_t *entry;
- struct list_head *list, *h_list, *ret;
+ struct hlist_head *h_list;
+ struct hlist_node *list;
unsigned int hashed_key;
hashed_key = hash_long(key, ht->order);
-
- *found = FALSE;
h_list = &ht->table[hashed_key];
- ret = h_list;
- list_for_each(list, h_list) {
- entry = list_entry(list, drm_hash_item_t, head);
- if (entry->key == key) {
- ret = list;
- *found = TRUE;
- break;
- }
- if (entry->key > key) {
- ret = list;
+ hlist_for_each(list, h_list) {
+ entry = hlist_entry(list, drm_hash_item_t, head);
+ if (entry->key == key)
+ return list;
+ if (entry->key > key)
break;
- }
}
- return ret;
+ return NULL;
}
+
int
drm_ht_insert_item(drm_open_hash_t *ht, drm_hash_item_t *item)
{
- int found;
- struct list_head *list;
-
- list = drm_ht_find_key(ht, item->key, &found);
- if (found) {
- return -EINVAL;
+ drm_hash_item_t *entry;
+ struct hlist_head *h_list;
+ struct hlist_node *list, *parent;
+ unsigned int hashed_key;
+ unsigned long key = item->key;
+
+ hashed_key = hash_long(key, ht->order);
+ h_list = &ht->table[hashed_key];
+ parent = NULL;
+ hlist_for_each(list, h_list) {
+ entry = hlist_entry(list, drm_hash_item_t, head);
+ if (entry->key == key)
+ return -1;
+ if (entry->key > key)
+ break;
+ parent = list;
+ }
+ if (parent) {
+ hlist_add_after(parent, &item->head);
} else {
- list_add_tail(&item->head, list);
- ht->fill++;
+ hlist_add_head(&item->head, h_list);
}
return 0;
}
@@ -133,7 +139,7 @@ drm_ht_just_insert_please(drm_open_hash_t *ht, drm_hash_item_t *item,
do{
ret = drm_ht_insert_item(ht, item);
if (ret)
- item->key = (item->key + 1) & mask;
+ item->key = (item->key + 1) & mask;
} while(ret && (item->key != first));
if (ret) {
@@ -146,27 +152,24 @@ drm_ht_just_insert_please(drm_open_hash_t *ht, drm_hash_item_t *item,
int
drm_ht_find_item(drm_open_hash_t *ht, unsigned long key, drm_hash_item_t **item)
{
- int found;
- struct list_head *list;
+ struct hlist_node *list;
- list = drm_ht_find_key(ht, key, &found);
- if (!found) {
+ list = drm_ht_find_key(ht, key);
+ if (!list)
return -1;
- } else {
- *item = list_entry(list, drm_hash_item_t, head);
- return 0;
- }
+
+ *item = hlist_entry(list, drm_hash_item_t, head);
+ return 0;
}
int
drm_ht_remove_key(drm_open_hash_t *ht, unsigned long key)
{
- int found;
- struct list_head *list;
+ struct hlist_node *list;
- list = drm_ht_find_key(ht, key, &found);
- if (found) {
- list_del_init(list);
+ list = drm_ht_find_key(ht, key);
+ if (list) {
+ hlist_del_init(list);
ht->fill--;
return 0;
}
@@ -176,7 +179,7 @@ drm_ht_remove_key(drm_open_hash_t *ht, unsigned long key)
int
drm_ht_remove_item(drm_open_hash_t *ht, drm_hash_item_t *item)
{
- list_del_init(&item->head);
+ hlist_del_init(&item->head);
ht->fill--;
return 0;
}
diff --git a/linux-core/drm_hashtab.h b/linux-core/drm_hashtab.h
index 90716132..580a02ed 100644
--- a/linux-core/drm_hashtab.h
+++ b/linux-core/drm_hashtab.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2006 Tungsten Graphics, Inc., Steamboat Springs, CO. USA.
+ * Copyright 2006 Tungsten Graphics, Inc., Bismack, ND. USA.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,8 +35,10 @@
#ifndef DRM_HASHTAB_H
#define DRM_HASHTAB_H
+#define drm_hash_entry(_a1, _a2, _a3) list_entry(_a1, _a2, _a3)
+
typedef struct drm_hash_item{
- struct list_head head;
+ struct hlist_node head;
unsigned long key;
} drm_hash_item_t;
@@ -44,7 +46,7 @@ typedef struct drm_open_hash{
unsigned int size;
unsigned int order;
unsigned int fill;
- struct list_head *table;
+ struct hlist_head *table;
} drm_open_hash_t;
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index 81f3b2ae..29b5a7fb 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -37,7 +37,7 @@
#define DRIVER_NAME "i915"
#define DRIVER_DESC "Intel Graphics"
-#define DRIVER_DATE "20060329"
+#define DRIVER_DATE "20060608"
/* Interface history:
*
@@ -49,7 +49,7 @@
*/
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 5
-#define DRIVER_PATCHLEVEL 0
+#define DRIVER_PATCHLEVEL 1
typedef struct _drm_i915_ring_buffer {
int tail_mask;