diff options
author | Dave Airlie <airlied@linux.ie> | 2007-02-18 01:14:09 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2007-03-10 20:07:17 -0500 |
commit | cd839d0048c3cb332cb0cd7d3de3431f8e1d3c7a (patch) | |
tree | 67fc15fe046198f9c8e19bf031e4424f85446a30 /drivers/char/drm | |
parent | 11d9c2fd0ae74647ea2b52f9bdfa7a920b48d1f1 (diff) |
drm: port over use_vmalloc code from git hashtab
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm')
-rw-r--r-- | drivers/char/drm/drm_hashtab.c | 16 | ||||
-rw-r--r-- | drivers/char/drm/drm_hashtab.h | 1 |
2 files changed, 15 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) | |||
183 | void drm_ht_remove(drm_open_hash_t *ht) | 191 | void 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 | } |
diff --git a/drivers/char/drm/drm_hashtab.h b/drivers/char/drm/drm_hashtab.h index 40afec05bff8..613091c970af 100644 --- a/drivers/char/drm/drm_hashtab.h +++ b/drivers/char/drm/drm_hashtab.h | |||
@@ -47,6 +47,7 @@ typedef struct drm_open_hash{ | |||
47 | unsigned int order; | 47 | unsigned int order; |
48 | unsigned int fill; | 48 | unsigned int fill; |
49 | struct hlist_head *table; | 49 | struct hlist_head *table; |
50 | int use_vmalloc; | ||
50 | } drm_open_hash_t; | 51 | } drm_open_hash_t; |
51 | 52 | ||
52 | 53 | ||