diff options
Diffstat (limited to 'drivers/char/drm/drm_hashtab.c')
-rw-r--r-- | drivers/char/drm/drm_hashtab.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/char/drm/drm_hashtab.c b/drivers/char/drm/drm_hashtab.c index a0b2d6802ae4..31acb621dcce 100644 --- a/drivers/char/drm/drm_hashtab.c +++ b/drivers/char/drm/drm_hashtab.c | |||
@@ -43,7 +43,16 @@ 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->table = NULL; |
47 | ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE); | ||
48 | if (!ht->use_vmalloc) { | ||
49 | ht->table = drm_calloc(ht->size, sizeof(*ht->table), | ||
50 | DRM_MEM_HASHTAB); | ||
51 | } | ||
52 | if (!ht->table) { | ||
53 | ht->use_vmalloc = 1; | ||
54 | ht->table = vmalloc(ht->size*sizeof(*ht->table)); | ||
55 | } | ||
47 | if (!ht->table) { | 56 | if (!ht->table) { |
48 | DRM_ERROR("Out of memory for hash table\n"); | 57 | DRM_ERROR("Out of memory for hash table\n"); |
49 | return -ENOMEM; | 58 | return -ENOMEM; |
@@ -183,7 +192,11 @@ int drm_ht_remove_item(drm_open_hash_t *ht, drm_hash_item_t *item) | |||
183 | void drm_ht_remove(drm_open_hash_t *ht) | 192 | void drm_ht_remove(drm_open_hash_t *ht) |
184 | { | 193 | { |
185 | if (ht->table) { | 194 | if (ht->table) { |
186 | vfree(ht->table); | 195 | if (ht->use_vmalloc) |
196 | vfree(ht->table); | ||
197 | else | ||
198 | drm_free(ht->table, ht->size * sizeof(*ht->table), | ||
199 | DRM_MEM_HASHTAB); | ||
187 | ht->table = NULL; | 200 | ht->table = NULL; |
188 | } | 201 | } |
189 | } | 202 | } |