diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2012-11-06 06:31:48 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-11-20 01:14:58 -0500 |
commit | d7144556195ab04a148e722a93103da5438bdf78 (patch) | |
tree | ee152765fe715eedd06d79c647ac3d4ffba34469 | |
parent | dedfdffd448aea2543b59fd504b92b8212ab3b7d (diff) |
drm: Make hashtab rcu-safe
TTM base objects will be the first consumer.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_hashtab.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c index c3745c4d46d8..5729e390aa4e 100644 --- a/drivers/gpu/drm/drm_hashtab.c +++ b/drivers/gpu/drm/drm_hashtab.c | |||
@@ -67,10 +67,8 @@ void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key) | |||
67 | hashed_key = hash_long(key, ht->order); | 67 | hashed_key = hash_long(key, ht->order); |
68 | DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key); | 68 | DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key); |
69 | h_list = &ht->table[hashed_key]; | 69 | h_list = &ht->table[hashed_key]; |
70 | hlist_for_each(list, h_list) { | 70 | hlist_for_each_entry_rcu(entry, list, h_list, head) |
71 | entry = hlist_entry(list, struct drm_hash_item, head); | ||
72 | DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key); | 71 | DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key); |
73 | } | ||
74 | } | 72 | } |
75 | 73 | ||
76 | static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht, | 74 | 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 | 81 | ||
84 | hashed_key = hash_long(key, ht->order); | 82 | hashed_key = hash_long(key, ht->order); |
85 | h_list = &ht->table[hashed_key]; | 83 | h_list = &ht->table[hashed_key]; |
86 | hlist_for_each(list, h_list) { | 84 | hlist_for_each_entry_rcu(entry, list, h_list, head) { |
87 | entry = hlist_entry(list, struct drm_hash_item, head); | ||
88 | if (entry->key == key) | 85 | if (entry->key == key) |
89 | return list; | 86 | return list; |
90 | if (entry->key > key) | 87 | if (entry->key > key) |
@@ -105,8 +102,7 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item) | |||
105 | hashed_key = hash_long(key, ht->order); | 102 | hashed_key = hash_long(key, ht->order); |
106 | h_list = &ht->table[hashed_key]; | 103 | h_list = &ht->table[hashed_key]; |
107 | parent = NULL; | 104 | parent = NULL; |
108 | hlist_for_each(list, h_list) { | 105 | hlist_for_each_entry_rcu(entry, list, h_list, head) { |
109 | entry = hlist_entry(list, struct drm_hash_item, head); | ||
110 | if (entry->key == key) | 106 | if (entry->key == key) |
111 | return -EINVAL; | 107 | return -EINVAL; |
112 | if (entry->key > key) | 108 | if (entry->key > key) |
@@ -114,9 +110,9 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item) | |||
114 | parent = list; | 110 | parent = list; |
115 | } | 111 | } |
116 | if (parent) { | 112 | if (parent) { |
117 | hlist_add_after(parent, &item->head); | 113 | hlist_add_after_rcu(parent, &item->head); |
118 | } else { | 114 | } else { |
119 | hlist_add_head(&item->head, h_list); | 115 | hlist_add_head_rcu(&item->head, h_list); |
120 | } | 116 | } |
121 | return 0; | 117 | return 0; |
122 | } | 118 | } |
@@ -171,7 +167,7 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) | |||
171 | 167 | ||
172 | list = drm_ht_find_key(ht, key); | 168 | list = drm_ht_find_key(ht, key); |
173 | if (list) { | 169 | if (list) { |
174 | hlist_del_init(list); | 170 | hlist_del_init_rcu(list); |
175 | return 0; | 171 | return 0; |
176 | } | 172 | } |
177 | return -EINVAL; | 173 | return -EINVAL; |
@@ -179,7 +175,7 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) | |||
179 | 175 | ||
180 | int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item) | 176 | int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item) |
181 | { | 177 | { |
182 | hlist_del_init(&item->head); | 178 | hlist_del_init_rcu(&item->head); |
183 | return 0; | 179 | return 0; |
184 | } | 180 | } |
185 | EXPORT_SYMBOL(drm_ht_remove_item); | 181 | EXPORT_SYMBOL(drm_ht_remove_item); |