aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--amdgpu/amdgpu_vamgr.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 2b1388ed..8516b594 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -34,18 +34,19 @@
34#include "util_math.h" 34#include "util_math.h"
35 35
36int amdgpu_va_range_query(amdgpu_device_handle dev, 36int amdgpu_va_range_query(amdgpu_device_handle dev,
37 enum amdgpu_gpu_va_range type, uint64_t *start, uint64_t *end) 37 enum amdgpu_gpu_va_range type,
38 uint64_t *start, uint64_t *end)
38{ 39{
39 if (type == amdgpu_gpu_va_range_general) { 40 if (type != amdgpu_gpu_va_range_general)
40 *start = dev->dev_info.virtual_address_offset; 41 return -EINVAL;
41 *end = dev->dev_info.virtual_address_max; 42
42 return 0; 43 *start = dev->dev_info.virtual_address_offset;
43 } 44 *end = dev->dev_info.virtual_address_max;
44 return -EINVAL; 45 return 0;
45} 46}
46 47
47drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start, 48drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
48 uint64_t max, uint64_t alignment) 49 uint64_t max, uint64_t alignment)
49{ 50{
50 mgr->va_offset = start; 51 mgr->va_offset = start;
51 mgr->va_max = max; 52 mgr->va_max = max;
@@ -83,8 +84,8 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
83 /* first look for a hole */ 84 /* first look for a hole */
84 LIST_FOR_EACH_ENTRY_SAFE(hole, n, &mgr->va_holes, list) { 85 LIST_FOR_EACH_ENTRY_SAFE(hole, n, &mgr->va_holes, list) {
85 if (base_required) { 86 if (base_required) {
86 if(hole->offset > base_required || 87 if (hole->offset > base_required ||
87 (hole->offset + hole->size) < (base_required + size)) 88 (hole->offset + hole->size) < (base_required + size))
88 continue; 89 continue;
89 waste = base_required - hole->offset; 90 waste = base_required - hole->offset;
90 offset = base_required; 91 offset = base_required;
@@ -192,9 +193,9 @@ amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size)
192 hole->offset = va; 193 hole->offset = va;
193 hole->size += size; 194 hole->size += size;
194 /* Merge lower hole if it's adjacent */ 195 /* Merge lower hole if it's adjacent */
195 if (next != hole 196 if (next != hole &&
196 && &next->list != &mgr->va_holes 197 &next->list != &mgr->va_holes &&
197 && (next->offset + next->size) == va) { 198 (next->offset + next->size) == va) {
198 next->size += hole->size; 199 next->size += hole->size;
199 list_del(&hole->list); 200 list_del(&hole->list);
200 free(hole); 201 free(hole);