aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_hashtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/drm_hashtab.c')
-rw-r--r--drivers/char/drm/drm_hashtab.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/char/drm/drm_hashtab.c b/drivers/char/drm/drm_hashtab.c
index a0b2d6802ae4..df0c48539ca4 100644
--- a/drivers/char/drm/drm_hashtab.c
+++ b/drivers/char/drm/drm_hashtab.c
@@ -43,7 +43,15 @@ int drm_ht_create(drm_open_hash_t *ht, unsigned int order)
43 ht->size = 1 << order; 43 ht->size = 1 << order;
44 ht->order = order; 44 ht->order = order;
45 ht->fill = 0; 45 ht->fill = 0;
46 ht->table = vmalloc(ht->size*sizeof(*ht->table)); 46 ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE);
47 if (!ht->use_vmalloc) {
48 ht->table = drm_calloc(ht->size, sizeof(*ht->table),
49 DRM_MEM_HASHTAB);
50 }
51 if (!ht->table) {
52 ht->use_vmalloc = 1;
53 ht->table = vmalloc(ht->size*sizeof(*ht->table));
54 }
47 if (!ht->table) { 55 if (!ht->table) {
48 DRM_ERROR("Out of memory for hash table\n"); 56 DRM_ERROR("Out of memory for hash table\n");
49 return -ENOMEM; 57 return -ENOMEM;
@@ -183,7 +191,11 @@ int drm_ht_remove_item(drm_open_hash_t *ht, drm_hash_item_t *item)
183void drm_ht_remove(drm_open_hash_t *ht) 191void drm_ht_remove(drm_open_hash_t *ht)
184{ 192{
185 if (ht->table) { 193 if (ht->table) {
186 vfree(ht->table); 194 if (ht->use_vmalloc)
195 vfree(ht->table);
196 else
197 drm_free(ht->table, ht->size * sizeof(*ht->table),
198 DRM_MEM_HASHTAB);
187 ht->table = NULL; 199 ht->table = NULL;
188 } 200 }
189} 201}