From cd839d0048c3cb332cb0cd7d3de3431f8e1d3c7a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 18 Feb 2007 17:14:09 +1100 Subject: drm: port over use_vmalloc code from git hashtab Signed-off-by: Dave Airlie --- drivers/char/drm/drm_hashtab.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'drivers/char/drm/drm_hashtab.c') diff --git a/drivers/char/drm/drm_hashtab.c b/drivers/char/drm/drm_hashtab.c index a0b2d6802ae..df0c48539ca 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) ht->size = 1 << order; ht->order = order; ht->fill = 0; - ht->table = vmalloc(ht->size*sizeof(*ht->table)); + ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE); + if (!ht->use_vmalloc) { + ht->table = drm_calloc(ht->size, sizeof(*ht->table), + DRM_MEM_HASHTAB); + } + if (!ht->table) { + ht->use_vmalloc = 1; + ht->table = vmalloc(ht->size*sizeof(*ht->table)); + } if (!ht->table) { DRM_ERROR("Out of memory for hash table\n"); return -ENOMEM; @@ -183,7 +191,11 @@ int drm_ht_remove_item(drm_open_hash_t *ht, drm_hash_item_t *item) void drm_ht_remove(drm_open_hash_t *ht) { if (ht->table) { - vfree(ht->table); + if (ht->use_vmalloc) + vfree(ht->table); + else + drm_free(ht->table, ht->size * sizeof(*ht->table), + DRM_MEM_HASHTAB); ht->table = NULL; } } -- cgit v1.2.3-70-g09d2 From c1185ccdfb797df82fa84b581eea128041bd63b0 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 18 Feb 2007 18:23:11 +1100 Subject: drm: add missing NULL assignment Signed-off-by: Dave Airlie --- drivers/char/drm/drm_hashtab.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/char/drm/drm_hashtab.c') diff --git a/drivers/char/drm/drm_hashtab.c b/drivers/char/drm/drm_hashtab.c index df0c48539ca..31acb621dcc 100644 --- a/drivers/char/drm/drm_hashtab.c +++ b/drivers/char/drm/drm_hashtab.c @@ -43,6 +43,7 @@ int drm_ht_create(drm_open_hash_t *ht, unsigned int order) ht->size = 1 << order; ht->order = order; ht->fill = 0; + ht->table = NULL; ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE); if (!ht->use_vmalloc) { ht->table = drm_calloc(ht->size, sizeof(*ht->table), -- cgit v1.2.3-70-g09d2