aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu
diff options
context:
space:
mode:
Diffstat (limited to 'amdgpu')
-rw-r--r--amdgpu/amdgpu_device.c16
-rw-r--r--amdgpu/amdgpu_internal.h2
-rw-r--r--amdgpu/amdgpu_vamgr.c2
3 files changed, 7 insertions, 13 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index 11714e47..f473d2da 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -132,8 +132,7 @@ static int amdgpu_get_auth(int fd, int *auth)
132static void amdgpu_device_free_internal(amdgpu_device_handle dev) 132static void amdgpu_device_free_internal(amdgpu_device_handle dev)
133{ 133{
134 amdgpu_vamgr_deinit(&dev->vamgr_32); 134 amdgpu_vamgr_deinit(&dev->vamgr_32);
135 amdgpu_vamgr_deinit(dev->vamgr); 135 amdgpu_vamgr_deinit(&dev->vamgr);
136 free(dev->vamgr);
137 util_hash_table_destroy(dev->bo_flink_names); 136 util_hash_table_destroy(dev->bo_flink_names);
138 util_hash_table_destroy(dev->bo_handles); 137 util_hash_table_destroy(dev->bo_handles);
139 pthread_mutex_destroy(&dev->bo_table_mutex); 138 pthread_mutex_destroy(&dev->bo_table_mutex);
@@ -254,16 +253,12 @@ int amdgpu_device_initialize(int fd,
254 if (r) 253 if (r)
255 goto cleanup; 254 goto cleanup;
256 255
257 dev->vamgr = calloc(1, sizeof(struct amdgpu_bo_va_mgr)); 256 amdgpu_vamgr_init(&dev->vamgr, dev->dev_info.virtual_address_offset,
258 if (dev->vamgr == NULL)
259 goto cleanup;
260
261 amdgpu_vamgr_init(dev->vamgr, dev->dev_info.virtual_address_offset,
262 dev->dev_info.virtual_address_max, 257 dev->dev_info.virtual_address_max,
263 dev->dev_info.virtual_address_alignment); 258 dev->dev_info.virtual_address_alignment);
264 259
265 max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff); 260 max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff);
266 start = amdgpu_vamgr_find_va(dev->vamgr, 261 start = amdgpu_vamgr_find_va(&dev->vamgr,
267 max - dev->dev_info.virtual_address_offset, 262 max - dev->dev_info.virtual_address_offset,
268 dev->dev_info.virtual_address_alignment, 0); 263 dev->dev_info.virtual_address_alignment, 0);
269 if (start > 0xffffffff) 264 if (start > 0xffffffff)
@@ -282,10 +277,9 @@ int amdgpu_device_initialize(int fd,
282 277
283free_va: 278free_va:
284 r = -ENOMEM; 279 r = -ENOMEM;
285 amdgpu_vamgr_free_va(dev->vamgr, start, 280 amdgpu_vamgr_free_va(&dev->vamgr, start,
286 max - dev->dev_info.virtual_address_offset); 281 max - dev->dev_info.virtual_address_offset);
287 amdgpu_vamgr_deinit(dev->vamgr); 282 amdgpu_vamgr_deinit(&dev->vamgr);
288 free(dev->vamgr);
289 283
290cleanup: 284cleanup:
291 if (dev->fd >= 0) 285 if (dev->fd >= 0)
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 7e237ac1..cf119a53 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -85,7 +85,7 @@ struct amdgpu_device {
85 struct drm_amdgpu_info_device dev_info; 85 struct drm_amdgpu_info_device dev_info;
86 struct amdgpu_gpu_info info; 86 struct amdgpu_gpu_info info;
87 /** The global VA manager for the whole virtual address space */ 87 /** The global VA manager for the whole virtual address space */
88 struct amdgpu_bo_va_mgr *vamgr; 88 struct amdgpu_bo_va_mgr vamgr;
89 /** The VA manager for the 32bit address space */ 89 /** The VA manager for the 32bit address space */
90 struct amdgpu_bo_va_mgr vamgr_32; 90 struct amdgpu_bo_va_mgr vamgr_32;
91}; 91};
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 4dc4253c..2b1388ed 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -238,7 +238,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
238 if (flags & AMDGPU_VA_RANGE_32_BIT) 238 if (flags & AMDGPU_VA_RANGE_32_BIT)
239 vamgr = &dev->vamgr_32; 239 vamgr = &dev->vamgr_32;
240 else 240 else
241 vamgr = dev->vamgr; 241 vamgr = &dev->vamgr;
242 242
243 va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment); 243 va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment);
244 size = ALIGN(size, vamgr->va_alignment); 244 size = ALIGN(size, vamgr->va_alignment);