diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-02-09 10:57:27 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-02-09 10:57:27 +0000 |
commit | 247eb21896c54c2feef7cf901f51e02ce0c2ff82 (patch) | |
tree | 1e1982ac6134d6a36f6a8903b6e65c7919127fa1 /sys/dev/pci | |
parent | fd1a5bfb6a22ccc1be8c8b0d4944f31b96b8f490 (diff) |
use linux style memory allocations in ttm
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_agp_backend.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_bo.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_bo_manager.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_bo_util.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_memory.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_object.c | 20 | ||||
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_page_alloc.c | 16 |
7 files changed, 42 insertions, 42 deletions
diff --git a/sys/dev/pci/drm/ttm/ttm_agp_backend.c b/sys/dev/pci/drm/ttm/ttm_agp_backend.c index 5f6f4a8c485..0b4f8ca09b6 100644 --- a/sys/dev/pci/drm/ttm/ttm_agp_backend.c +++ b/sys/dev/pci/drm/ttm/ttm_agp_backend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_agp_backend.c,v 1.2 2013/12/08 07:54:06 jsg Exp $ */ +/* $OpenBSD: ttm_agp_backend.c,v 1.3 2014/02/09 10:57:26 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA @@ -99,7 +99,7 @@ static void ttm_agp_destroy(struct ttm_tt *ttm) if (agp_be->bound) ttm_agp_unbind(ttm); ttm_tt_fini(ttm); - free(agp_be, M_DRM); + kfree(agp_be); } static struct ttm_backend_func ttm_agp_func = { @@ -115,7 +115,7 @@ struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev, { struct ttm_agp_backend *agp_be; - agp_be = malloc(sizeof(*agp_be), M_DRM, M_WAITOK); + agp_be = kmalloc(sizeof(*agp_be), GFP_KERNEL); if (!agp_be) return NULL; diff --git a/sys/dev/pci/drm/ttm/ttm_bo.c b/sys/dev/pci/drm/ttm/ttm_bo.c index 97b1b6351f2..f6d7e391ecc 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo.c +++ b/sys/dev/pci/drm/ttm/ttm_bo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_bo.c,v 1.5 2013/12/08 07:54:06 jsg Exp $ */ +/* $OpenBSD: ttm_bo.c,v 1.6 2014/02/09 10:57:26 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA @@ -154,7 +154,7 @@ static void ttm_bo_release_list(struct ttm_buffer_object *bo) if (bo->destroy) bo->destroy(bo); else { - free(bo, M_DRM); + kfree(bo); } ttm_mem_global_free(bdev->glob->mem_glob, acc_size); } @@ -1204,7 +1204,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev, if (destroy) (*destroy)(bo); else - free(bo, M_DRM); + kfree(bo); return -ENOMEM; } @@ -1214,7 +1214,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev, if (destroy) (*destroy)(bo); else - free(bo, M_DRM); + kfree(bo); ttm_mem_global_free(mem_glob, acc_size); return -EINVAL; } @@ -1323,7 +1323,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev, size_t acc_size; int ret; - bo = malloc(sizeof(*bo), M_DRM, M_WAITOK | M_ZERO); + bo = kzalloc(sizeof(*bo), GFP_KERNEL); if (unlikely(bo == NULL)) return -ENOMEM; @@ -1455,7 +1455,7 @@ static void ttm_bo_global_kobj_release(struct ttm_bo_global *glob) ttm_mem_unregister_shrink(glob->mem_glob, &glob->shrink); km_free(glob->dummy_read_page, PAGE_SIZE, &kv_any, &kp_dma_zero); - drm_free(glob); + kfree(glob); } void ttm_bo_global_release(struct drm_global_reference *ref) @@ -1503,7 +1503,7 @@ int ttm_bo_global_init(struct drm_global_reference *ref) out_no_shrink: km_free(glob->dummy_read_page, PAGE_SIZE, &kv_any, &kp_dma_zero); out_no_drp: - free(glob, M_DRM); + kfree(glob); return ret; } EXPORT_SYMBOL(ttm_bo_global_init); diff --git a/sys/dev/pci/drm/ttm/ttm_bo_manager.c b/sys/dev/pci/drm/ttm/ttm_bo_manager.c index 3bcca960a58..441feb32ec0 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo_manager.c +++ b/sys/dev/pci/drm/ttm/ttm_bo_manager.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_bo_manager.c,v 1.1 2013/08/12 04:11:53 jsg Exp $ */ +/* $OpenBSD: ttm_bo_manager.c,v 1.2 2014/02/09 10:57:26 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2007-2010 VMware, Inc., Palo Alto, CA., USA @@ -103,13 +103,13 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man, struct ttm_range_manager *rman; int ret; - rman = malloc(sizeof(*rman), M_DRM, M_WAITOK | M_ZERO); + rman = kzalloc(sizeof(*rman), GFP_KERNEL); if (!rman) return -ENOMEM; ret = drm_mm_init(&rman->mm, 0, p_size); if (ret) { - free(rman, M_DRM); + kfree(rman); return ret; } @@ -127,7 +127,7 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) if (drm_mm_clean(mm)) { drm_mm_takedown(mm); mtx_leave(&rman->lock); - free(rman, M_DRM); + kfree(rman); man->priv = NULL; return 0; } diff --git a/sys/dev/pci/drm/ttm/ttm_bo_util.c b/sys/dev/pci/drm/ttm/ttm_bo_util.c index 43b81910989..60426189811 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo_util.c +++ b/sys/dev/pci/drm/ttm/ttm_bo_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_bo_util.c,v 1.2 2013/12/08 07:54:06 jsg Exp $ */ +/* $OpenBSD: ttm_bo_util.c,v 1.3 2014/02/09 10:57:26 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2007-2009 VMware, Inc., Palo Alto, CA., USA @@ -409,7 +409,7 @@ EXPORT_SYMBOL(ttm_bo_move_memcpy); static void ttm_transfered_destroy(struct ttm_buffer_object *bo) { - free(bo, M_DRM); + kfree(bo); } /** @@ -434,7 +434,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, struct ttm_bo_device *bdev = bo->bdev; struct ttm_bo_driver *driver = bdev->driver; - fbo = malloc(sizeof(*fbo), M_DRM, M_WAITOK); + fbo = kmalloc(sizeof(*fbo), GFP_KERNEL); if (!fbo) return -ENOMEM; diff --git a/sys/dev/pci/drm/ttm/ttm_memory.c b/sys/dev/pci/drm/ttm/ttm_memory.c index 0aaf9a21ea1..6c0a6e09f20 100644 --- a/sys/dev/pci/drm/ttm/ttm_memory.c +++ b/sys/dev/pci/drm/ttm/ttm_memory.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_memory.c,v 1.3 2013/12/08 07:54:06 jsg Exp $ */ +/* $OpenBSD: ttm_memory.c,v 1.4 2014/02/09 10:57:26 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA @@ -75,7 +75,7 @@ static void ttm_mem_zone_kobj_release(struct ttm_mem_zone *zone) DRM_INFO("Zone %7s: Used memory at exit: %llu kiB\n", zone->name, (unsigned long long)zone->used_mem >> 10); - free(zone, M_DRM); + kfree(zone); } #ifdef notyet @@ -170,7 +170,7 @@ static struct kobj_type ttm_mem_zone_kobj_type = { static void ttm_mem_global_kobj_release(struct ttm_mem_global *glob) { - free(glob, M_DRM); + kfree(glob); } #ifdef notyet @@ -244,7 +244,7 @@ static void ttm_shrink_work(void *arg1, void *arg2) static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob, uint64_t mem) { - struct ttm_mem_zone *zone = malloc(sizeof(*zone), M_DRM, M_WAITOK | M_ZERO); + struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); if (unlikely(!zone)) return -ENOMEM; @@ -271,7 +271,7 @@ static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, if (si->totalhigh == 0) return 0; - zone = malloc(sizeof(*zone), M_DRM, M_WAITOK | M_ZERO); + zone = kzalloc(sizeof(*zone), GFP_KERNEL); if (unlikely(!zone)) return -ENOMEM; @@ -291,7 +291,7 @@ static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob, uint64_t mem) { - struct ttm_mem_zone *zone = malloc(sizeof(*zone), M_DRM, M_WAITOK | M_ZERO); + struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); if (unlikely(!zone)) return -ENOMEM; @@ -301,7 +301,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob, */ if (mem <= ((uint64_t) 1ULL << 32)) { - free(zone, M_DRM); + kfree(zone); return 0; } diff --git a/sys/dev/pci/drm/ttm/ttm_object.c b/sys/dev/pci/drm/ttm/ttm_object.c index edf9aa8464d..f3490cf7a74 100644 --- a/sys/dev/pci/drm/ttm/ttm_object.c +++ b/sys/dev/pci/drm/ttm/ttm_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_object.c,v 1.1 2013/08/12 04:11:53 jsg Exp $ */ +/* $OpenBSD: ttm_object.c,v 1.2 2014/02/09 10:57:26 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA @@ -124,7 +124,7 @@ ttm_object_file_ref(struct ttm_object_file *tfile) static void ttm_object_file_destroy(struct ttm_object_file *tfile) { - free(tfile, M_DRM); + kfree(tfile); } static inline void ttm_object_file_unref(struct ttm_object_file **p_tfile) @@ -268,7 +268,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, false, false); if (unlikely(ret != 0)) return ret; - ref = malloc(sizeof(*ref), M_DRM, M_WAITOK); + ref = kmalloc(sizeof(*ref), GFP_KERNEL); if (unlikely(ref == NULL)) { ttm_mem_global_free(mem_glob, sizeof(*ref)); return -ENOMEM; @@ -296,7 +296,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, BUG_ON(ret != -EINVAL); ttm_mem_global_free(mem_glob, sizeof(*ref)); - free(ref, M_DRM); + kfree(ref); } return ret; @@ -320,7 +320,7 @@ static void ttm_ref_object_release(struct ttm_ref_object *ref) ttm_base_object_unref(&ref->obj); ttm_mem_global_free(mem_glob, sizeof(*ref)); - free(ref, M_DRM); + kfree(ref); rw_enter_write(&tfile->lock); } @@ -378,7 +378,7 @@ EXPORT_SYMBOL(ttm_object_file_release); struct ttm_object_file *ttm_object_file_init(struct ttm_object_device *tdev, unsigned int hash_order) { - struct ttm_object_file *tfile = malloc(sizeof(*tfile), M_DRM, M_WAITOK); + struct ttm_object_file *tfile = kmalloc(sizeof(*tfile), GFP_KERNEL); unsigned int i; unsigned int j = 0; int ret; @@ -404,7 +404,7 @@ out_err: for (i = 0; i < j; ++i) drm_ht_remove(&tfile->ref_hash[i]); - free(tfile, M_DRM); + kfree(tfile); return NULL; } @@ -414,7 +414,7 @@ struct ttm_object_device *ttm_object_device_init(struct ttm_mem_global *mem_glob, unsigned int hash_order) { - struct ttm_object_device *tdev = malloc(sizeof(*tdev), M_DRM, M_WAITOK); + struct ttm_object_device *tdev = kmalloc(sizeof(*tdev), GFP_KERNEL); int ret; if (unlikely(tdev == NULL)) @@ -428,7 +428,7 @@ struct ttm_object_device *ttm_object_device_init(struct ttm_mem_global if (likely(ret == 0)) return tdev; - free(tdev, M_DRM); + kfree(tdev); return NULL; } EXPORT_SYMBOL(ttm_object_device_init); @@ -443,6 +443,6 @@ void ttm_object_device_release(struct ttm_object_device **p_tdev) drm_ht_remove(&tdev->object_hash); mtx_leave(&tdev->object_lock); - free(tdev, M_DRM); + kfree(tdev); } EXPORT_SYMBOL(ttm_object_device_release); diff --git a/sys/dev/pci/drm/ttm/ttm_page_alloc.c b/sys/dev/pci/drm/ttm/ttm_page_alloc.c index ef28a9f130c..9b00a203209 100644 --- a/sys/dev/pci/drm/ttm/ttm_page_alloc.c +++ b/sys/dev/pci/drm/ttm/ttm_page_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_page_alloc.c,v 1.2 2013/12/08 07:54:06 jsg Exp $ */ +/* $OpenBSD: ttm_page_alloc.c,v 1.3 2014/02/09 10:57:26 jsg Exp $ */ /* * Copyright (c) Red Hat Inc. @@ -172,7 +172,7 @@ ttm_uvm_free_page(struct vm_page *m) static void ttm_pool_kobj_release(struct ttm_pool_manager *m) { - free(m, M_DRM); + kfree(m); } #ifdef notyet @@ -348,8 +348,8 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free) if (NUM_PAGES_TO_ALLOC < nr_free) npages_to_free = NUM_PAGES_TO_ALLOC; - pages_to_free = malloc(npages_to_free * sizeof(struct vm_page *), - M_DRM, M_WAITOK); + pages_to_free = kmalloc(npages_to_free * sizeof(struct vm_page *), + GFP_KERNEL); if (!pages_to_free) { printf("Failed to allocate memory for pool free operation\n"); return 0; @@ -414,7 +414,7 @@ restart: if (freed_pages) ttm_pages_put(pages_to_free, freed_pages); out: - free(pages_to_free, M_DRM); + kfree(pages_to_free); return nr_free; } @@ -532,7 +532,7 @@ static int ttm_alloc_new_pages(struct pglist *pages, int gfp_flags, (unsigned)(PAGE_SIZE/sizeof(struct vm_page *))); /* allocate array for page caching change */ - caching_array = malloc(max_cpages*sizeof(struct vm_page *), M_DRM, M_WAITOK); + caching_array = kmalloc(max_cpages*sizeof(struct vm_page *), GFP_KERNEL); if (!caching_array) { printf("Unable to allocate table for new pages\n"); @@ -592,7 +592,7 @@ static int ttm_alloc_new_pages(struct pglist *pages, int gfp_flags, caching_array, cpages); } out: - free(caching_array, M_DRM); + kfree(caching_array); return r; } @@ -829,7 +829,7 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) DRM_DEBUG("Initializing pool allocator\n"); - _manager = malloc(sizeof(*_manager), M_DRM, M_WAITOK | M_ZERO); + _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); ttm_page_pool_init_locked(&_manager->wc_pool, 0, "wc"); |