Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cd839d0048c3cb332cb0cd7d3de3431f8e1d3c7a
Commit:     cd839d0048c3cb332cb0cd7d3de3431f8e1d3c7a
Parent:     11d9c2fd0ae74647ea2b52f9bdfa7a920b48d1f1
Author:     Dave Airlie <[EMAIL PROTECTED]>
AuthorDate: Sun Feb 18 17:14:09 2007 +1100
Committer:  Dave Airlie <[EMAIL PROTECTED]>
CommitDate: Sun Mar 11 12:07:17 2007 +1100

    drm: port over use_vmalloc code from git hashtab
    
    Signed-off-by: Dave Airlie <[EMAIL PROTECTED]>
---
 drivers/char/drm/drm_hashtab.c |   16 ++++++++++++++--
 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 a0b2d68..df0c485 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;
        }
 }
diff --git a/drivers/char/drm/drm_hashtab.h b/drivers/char/drm/drm_hashtab.h
index 40afec0..613091c 100644
--- a/drivers/char/drm/drm_hashtab.h
+++ b/drivers/char/drm/drm_hashtab.h
@@ -47,6 +47,7 @@ typedef struct drm_open_hash{
        unsigned int order;
        unsigned int fill;
        struct hlist_head *table;
+       int use_vmalloc;
 } drm_open_hash_t;
 
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to