From 7223b4e264a64df2df70715d8777f2ccaa883d5e Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 14 Sep 2006 16:42:00 +0200 Subject: Simplify ttm alloc and free. --- linux-core/drm_ttm.c | 32 +++++++++++++++----------------- linux-core/drm_ttm.h | 3 --- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index cd95e311..f72e7d30 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -47,31 +47,29 @@ typedef struct drm_val_action { */ -static void *ttm_alloc(unsigned long size, int type, int *do_vmalloc) +static void *ttm_alloc(unsigned long size, int type) { void *ret = NULL; - *do_vmalloc = 0; if (size <= 4*PAGE_SIZE) { ret = drm_alloc(size, type); } if (!ret) { - *do_vmalloc = 1; ret = vmalloc(size); } return ret; } - -static void ttm_free(void *pointer, unsigned long size, int type, - int do_vfree) + +static void ttm_free(void *pointer, unsigned long size, int type) { - if (!do_vfree) { - drm_free(pointer, size, type); - }else { + + if ((unsigned long) pointer >= VMALLOC_START && + (unsigned long) pointer <= VMALLOC_END) { vfree(pointer); + } else { + drm_free(pointer, size, type); } -} - +} /* @@ -287,12 +285,12 @@ int drm_destroy_ttm(drm_ttm_t * ttm) if (do_tlbflush) global_flush_tlb(); ttm_free(ttm->pages, ttm->num_pages*sizeof(*ttm->pages), - DRM_MEM_TTM, ttm->pages_vmalloc); + DRM_MEM_TTM); ttm->pages = NULL; } if (ttm->page_flags) { - ttm_free(ttm->page_flags, ttm->num_pages*sizeof(*ttm->page_flags), DRM_MEM_TTM, ttm->pf_vmalloc); + ttm_free(ttm->page_flags, ttm->num_pages*sizeof(*ttm->page_flags), DRM_MEM_TTM); ttm->page_flags = NULL; } @@ -338,7 +336,7 @@ static drm_ttm_t *drm_init_ttm(struct drm_device *dev, unsigned long size) ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; ttm->page_flags = ttm_alloc(ttm->num_pages * sizeof(*ttm->page_flags), - DRM_MEM_TTM, &ttm->pf_vmalloc); + DRM_MEM_TTM); if (!ttm->page_flags) { drm_destroy_ttm(ttm); DRM_ERROR("Failed allocating page_flags table\n"); @@ -347,7 +345,7 @@ static drm_ttm_t *drm_init_ttm(struct drm_device *dev, unsigned long size) memset(ttm->page_flags, 0, ttm->num_pages * sizeof(*ttm->page_flags)); ttm->pages = ttm_alloc(ttm->num_pages * sizeof(*ttm->pages), - DRM_MEM_TTM, &ttm->pages_vmalloc); + DRM_MEM_TTM); if (!ttm->pages) { drm_destroy_ttm(ttm); DRM_ERROR("Failed allocating page table\n"); @@ -735,7 +733,7 @@ void drm_user_destroy_region(drm_ttm_backend_list_t * entry) } ttm_free(entry->anon_pages, sizeof(*entry->anon_pages)*entry->anon_locked, - DRM_MEM_TTM, entry->pages_vmalloc); + DRM_MEM_TTM); } be->destroy(be); @@ -781,7 +779,7 @@ int drm_user_create_region(drm_device_t * dev, unsigned long start, int len, } tmp->anon_pages = ttm_alloc(sizeof(*(tmp->anon_pages)) * len, - DRM_MEM_TTM, &tmp->pages_vmalloc); + DRM_MEM_TTM); if (!tmp->anon_pages) { drm_user_destroy_region(tmp); diff --git a/linux-core/drm_ttm.h b/linux-core/drm_ttm.h index 5c65e747..d647578c 100644 --- a/linux-core/drm_ttm.h +++ b/linux-core/drm_ttm.h @@ -70,7 +70,6 @@ typedef struct drm_ttm_backend_list { drm_file_t *anon_owner; struct page **anon_pages; int anon_locked; - int pages_vmalloc; enum { ttm_bound, ttm_evicted, @@ -100,8 +99,6 @@ typedef struct drm_ttm { atomic_t vma_count; int mmap_sem_locked; int destroy; - int pages_vmalloc; - int pf_vmalloc; } drm_ttm_t; typedef struct drm_ttm_object { -- cgit v1.2.3