aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Wang2015-05-21 04:21:21 -0500
committerAlex Deucher2015-08-05 12:47:50 -0500
commit322d02d025cad1a74138c86937c5d5f3ef6215c7 (patch)
treeccedcb0de4a6da4b4b1bd4b5a8fe897e647fe5f3 /amdgpu/amdgpu_vamgr.c
parentba1653eff8bd8ecc3d5fd5b2bbab604878cfa7e0 (diff)
downloadexternal-libgbm-322d02d025cad1a74138c86937c5d5f3ef6215c7.tar.gz
external-libgbm-322d02d025cad1a74138c86937c5d5f3ef6215c7.tar.xz
external-libgbm-322d02d025cad1a74138c86937c5d5f3ef6215c7.zip
amdgpu: make vamgr global
This is the first sub-patch of va interface task, the va task is about adding more va management interfaces for UMD, by design, the vamgr should be per-process rather than per-device. Signed-off-by: Ken Wang <Qingqing.Wang@amd.com> Reviewed-by: Christian K├Ânig <christian.koenig@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_vamgr.c')
-rw-r--r--amdgpu/amdgpu_vamgr.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 34c28878..b15729fa 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -28,20 +28,48 @@
28#include "amdgpu_internal.h" 28#include "amdgpu_internal.h"
29#include "util_math.h" 29#include "util_math.h"
30 30
31void amdgpu_vamgr_init(struct amdgpu_device *dev) 31static struct amdgpu_bo_va_mgr vamgr = {{0}};
32
33static void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, struct amdgpu_device *dev)
34{
35 mgr->va_offset = dev->dev_info.virtual_address_offset;
36 mgr->va_max = dev->dev_info.virtual_address_max;
37 mgr->va_alignment = dev->dev_info.virtual_address_alignment;
38
39 list_inithead(&mgr->va_holes);
40 pthread_mutex_init(&mgr->bo_va_mutex, NULL);
41}
42
43static void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr)
44{
45 struct amdgpu_bo_va_hole *hole;
46 LIST_FOR_EACH_ENTRY(hole, &mgr->va_holes, list) {
47 list_del(&hole->list);
48 free(hole);
49 }
50 pthread_mutex_destroy(&mgr->bo_va_mutex);
51}
52
53struct amdgpu_bo_va_mgr * amdgpu_vamgr_get_global(struct amdgpu_device *dev)
32{ 54{
33 struct amdgpu_bo_va_mgr *vamgr = &dev->vamgr; 55 int ref;
56 ref = atomic_inc_return(&vamgr.refcount);
34 57
35 vamgr->va_offset = dev->dev_info.virtual_address_offset; 58 if (ref == 1)
36 vamgr->va_max = dev->dev_info.virtual_address_max; 59 amdgpu_vamgr_init(&vamgr, dev);
37 vamgr->va_alignment = dev->dev_info.virtual_address_alignment; 60 return &vamgr;
61}
38 62
39 list_inithead(&vamgr->va_holes); 63void amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst,
40 pthread_mutex_init(&vamgr->bo_va_mutex, NULL); 64 struct amdgpu_bo_va_mgr *src)
65{
66 if (update_references(&(*dst)->refcount, NULL))
67 amdgpu_vamgr_deinit(*dst);
68 *dst = src;
41} 69}
42 70
43uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, 71uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr,
44 uint64_t size, uint64_t alignment) 72 uint64_t size, uint64_t alignment)
45{ 73{
46 struct amdgpu_bo_va_hole *hole, *n; 74 struct amdgpu_bo_va_hole *hole, *n;
47 uint64_t offset = 0, waste = 0; 75 uint64_t offset = 0, waste = 0;
@@ -108,8 +136,8 @@ uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr,
108 return offset; 136 return offset;
109} 137}
110 138
111void amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, 139void amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr,
112 uint64_t size) 140 uint64_t va, uint64_t size)
113{ 141{
114 struct amdgpu_bo_va_hole *hole; 142 struct amdgpu_bo_va_hole *hole;
115 143