Commit d7144556 authored by Thomas Hellstrom's avatar Thomas Hellstrom Committed by Dave Airlie

drm: Make hashtab rcu-safe

TTM base objects will be the first consumer.
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent dedfdffd
...@@ -67,10 +67,8 @@ void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key) ...@@ -67,10 +67,8 @@ void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key)
hashed_key = hash_long(key, ht->order); hashed_key = hash_long(key, ht->order);
DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key); DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key);
h_list = &ht->table[hashed_key]; h_list = &ht->table[hashed_key];
hlist_for_each(list, h_list) { hlist_for_each_entry_rcu(entry, list, h_list, head)
entry = hlist_entry(list, struct drm_hash_item, head);
DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key); DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key);
}
} }
static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht, static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht,
...@@ -83,8 +81,7 @@ static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht, ...@@ -83,8 +81,7 @@ static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht,
hashed_key = hash_long(key, ht->order); hashed_key = hash_long(key, ht->order);
h_list = &ht->table[hashed_key]; h_list = &ht->table[hashed_key];
hlist_for_each(list, h_list) { hlist_for_each_entry_rcu(entry, list, h_list, head) {
entry = hlist_entry(list, struct drm_hash_item, head);
if (entry->key == key) if (entry->key == key)
return list; return list;
if (entry->key > key) if (entry->key > key)
...@@ -105,8 +102,7 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item) ...@@ -105,8 +102,7 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item)
hashed_key = hash_long(key, ht->order); hashed_key = hash_long(key, ht->order);
h_list = &ht->table[hashed_key]; h_list = &ht->table[hashed_key];
parent = NULL; parent = NULL;
hlist_for_each(list, h_list) { hlist_for_each_entry_rcu(entry, list, h_list, head) {
entry = hlist_entry(list, struct drm_hash_item, head);
if (entry->key == key) if (entry->key == key)
return -EINVAL; return -EINVAL;
if (entry->key > key) if (entry->key > key)
...@@ -114,9 +110,9 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item) ...@@ -114,9 +110,9 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item)
parent = list; parent = list;
} }
if (parent) { if (parent) {
hlist_add_after(parent, &item->head); hlist_add_after_rcu(parent, &item->head);
} else { } else {
hlist_add_head(&item->head, h_list); hlist_add_head_rcu(&item->head, h_list);
} }
return 0; return 0;
} }
...@@ -171,7 +167,7 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) ...@@ -171,7 +167,7 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key)
list = drm_ht_find_key(ht, key); list = drm_ht_find_key(ht, key);
if (list) { if (list) {
hlist_del_init(list); hlist_del_init_rcu(list);
return 0; return 0;
} }
return -EINVAL; return -EINVAL;
...@@ -179,7 +175,7 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) ...@@ -179,7 +175,7 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key)
int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item) int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item)
{ {
hlist_del_init(&item->head); hlist_del_init_rcu(&item->head);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_ht_remove_item); EXPORT_SYMBOL(drm_ht_remove_item);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment