summaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_hashtab.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 12:24:07 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 12:24:07 -0700
commit5f757f91e70a97eda8f0cc13bddc853209b2d173 (patch)
treee2e97796f5145b5d6eb3fee6ec93050d90f2bd7d /drivers/char/drm/drm_hashtab.c
parent9fa0853a85a3a4067e4ad0aaa5d90984c2dd21b5 (diff)
parentce7dd06372058f9e3e57ee4c0aeba694a43a80ad (diff)
Merge branch 'drm-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6: drm/i915: Add 965GM pci id update drm: just use io_remap_pfn_range on all archs.. drm: fix DRM_CONSISTENT mapping drm: fix up mmap locking in preparation for ttm changes drm: fix driver deadlock with AIGLX and reclaim_buffers_locked drm: fix warning in drm_fops.c drm: allow for more generic drm ioctls drm: fix alpha domain handling via: fix CX700 pci id drm: make drm_io_prot static. drm: remove via_mm.h drm: add missing NULL assignment drm/radeon: Fix u32 overflows when determining AGP base address in card space. drm: port over use_vmalloc code from git hashtab drm: fix crash with fops lock and fixup sarea/page size locking drm: bring bufs code from git tree. drm: move protection stuff into separate function drm: Use ARRAY_SIZE macro when appropriate drm: update README.drm (bugzilla #7933) drm: remove unused exports
Diffstat (limited to 'drivers/char/drm/drm_hashtab.c')
-rw-r--r--drivers/char/drm/drm_hashtab.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/char/drm/drm_hashtab.c b/drivers/char/drm/drm_hashtab.c
index a0b2d6802ae..31acb621dcc 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)
ht->size = 1 << order;
ht->order = order;
ht->fill = 0;
- ht->table = vmalloc(ht->size*sizeof(*ht->table));
+ 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),
+ 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 +192,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;
}
}