aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJammy Zhou2015-08-16 22:09:09 -0500
committerAlex Deucher2015-08-17 15:29:26 -0500
commit56d8dd6a9c03680700e0b0043cb56e0af7e3e3de (patch)
treed9f049c3c8d8ce7010436add5ad76c6f36e32943 /amdgpu/amdgpu_device.c
parentffa305d0fc926418e4dff432381ead8907dc18d9 (diff)
downloadexternal-libdrm-56d8dd6a9c03680700e0b0043cb56e0af7e3e3de.tar.gz
external-libdrm-56d8dd6a9c03680700e0b0043cb56e0af7e3e3de.tar.xz
external-libdrm-56d8dd6a9c03680700e0b0043cb56e0af7e3e3de.zip
amdgpu: make vamgr per device v2
Each device can have its own vamgr, so make it per device now. This can fix the failure with multiple GPUs used in one single process. v2: rebase Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Christian K├Ânig <christian.koenig@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_device.c')
-rw-r--r--amdgpu/amdgpu_device.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index e16cd24b..75b12e25 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -130,7 +130,8 @@ static int amdgpu_get_auth(int fd, int *auth)
130 130
131static void amdgpu_device_free_internal(amdgpu_device_handle dev) 131static void amdgpu_device_free_internal(amdgpu_device_handle dev)
132{ 132{
133 amdgpu_vamgr_reference(&dev->vamgr, NULL); 133 amdgpu_vamgr_deinit(dev->vamgr);
134 free(dev->vamgr);
134 util_hash_table_destroy(dev->bo_flink_names); 135 util_hash_table_destroy(dev->bo_flink_names);
135 util_hash_table_destroy(dev->bo_handles); 136 util_hash_table_destroy(dev->bo_handles);
136 pthread_mutex_destroy(&dev->bo_table_mutex); 137 pthread_mutex_destroy(&dev->bo_table_mutex);
@@ -251,7 +252,13 @@ int amdgpu_device_initialize(int fd,
251 if (r) 252 if (r)
252 goto cleanup; 253 goto cleanup;
253 254
254 dev->vamgr = amdgpu_vamgr_get_global(dev); 255 dev->vamgr = calloc(1, sizeof(struct amdgpu_bo_va_mgr));
256 if (dev->vamgr == NULL)
257 goto cleanup;
258
259 amdgpu_vamgr_init(dev->vamgr, dev->dev_info.virtual_address_offset,
260 dev->dev_info.virtual_address_max,
261 dev->dev_info.virtual_address_alignment);
255 262
256 max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff); 263 max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff);
257 start = amdgpu_vamgr_find_va(dev->vamgr, 264 start = amdgpu_vamgr_find_va(dev->vamgr,
@@ -278,6 +285,8 @@ free_va:
278 r = -ENOMEM; 285 r = -ENOMEM;
279 amdgpu_vamgr_free_va(dev->vamgr, start, 286 amdgpu_vamgr_free_va(dev->vamgr, start,
280 max - dev->dev_info.virtual_address_offset); 287 max - dev->dev_info.virtual_address_offset);
288 amdgpu_vamgr_deinit(dev->vamgr);
289 free(dev->vamgr);
281 290
282cleanup: 291cleanup:
283 if (dev->fd >= 0) 292 if (dev->fd >= 0)