aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJammy Zhou2015-05-12 12:14:11 -0500
committerAlex Deucher2015-08-05 12:47:49 -0500
commit241cf6d1051718a481c61b469171a34c0ca718a4 (patch)
treec48cadc94b9b0286e859ba38068a408abc689fe3 /amdgpu/amdgpu_vamgr.c
parentdb126d1d8a764b9d3ad322779b13904867b14e5c (diff)
downloadexternal-libgbm-241cf6d1051718a481c61b469171a34c0ca718a4.tar.gz
external-libgbm-241cf6d1051718a481c61b469171a34c0ca718a4.tar.xz
external-libgbm-241cf6d1051718a481c61b469171a34c0ca718a4.zip
amdgpu: validate the upper limit of virtual address v2
Only 8GB virtual address space is used by default now v2: use -ENOSPC for the error case Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_vamgr.c')
-rw-r--r--amdgpu/amdgpu_vamgr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 23359122..070ecc47 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -33,6 +33,7 @@ void amdgpu_vamgr_init(struct amdgpu_device *dev)
33 struct amdgpu_bo_va_mgr *vamgr = &dev->vamgr; 33 struct amdgpu_bo_va_mgr *vamgr = &dev->vamgr;
34 34
35 vamgr->va_offset = dev->dev_info.virtual_address_offset; 35 vamgr->va_offset = dev->dev_info.virtual_address_offset;
36 vamgr->va_max = dev->dev_info.virtual_address_max;
36 vamgr->va_alignment = dev->dev_info.virtual_address_alignment; 37 vamgr->va_alignment = dev->dev_info.virtual_address_alignment;
37 38
38 list_inithead(&vamgr->va_holes); 39 list_inithead(&vamgr->va_holes);
@@ -89,6 +90,12 @@ uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr,
89 offset = mgr->va_offset; 90 offset = mgr->va_offset;
90 waste = offset % alignment; 91 waste = offset % alignment;
91 waste = waste ? alignment - waste : 0; 92 waste = waste ? alignment - waste : 0;
93
94 if (offset + waste + size > mgr->va_max) {
95 pthread_mutex_unlock(&mgr->bo_va_mutex);
96 return AMDGPU_INVALID_VA_ADDRESS;
97 }
98
92 if (waste) { 99 if (waste) {
93 n = calloc(1, sizeof(struct amdgpu_bo_va_hole)); 100 n = calloc(1, sizeof(struct amdgpu_bo_va_hole));
94 n->size = waste; 101 n->size = waste;