aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Xie2017-01-28 13:50:44 -0600
committerAlex Deucher2017-02-02 14:22:53 -0600
commitfe7cb34eda1855ac9770bc9f3e582897000e41b0 (patch)
tree1f9b794b15dc3a73ad9e1092ed1c4992ea8572cd /amdgpu/amdgpu_device.c
parent067e9a1d47a8373b3145481a70fec84ce8e76441 (diff)
downloadexternal-libdrm-fe7cb34eda1855ac9770bc9f3e582897000e41b0.tar.gz
external-libdrm-fe7cb34eda1855ac9770bc9f3e582897000e41b0.tar.xz
external-libdrm-fe7cb34eda1855ac9770bc9f3e582897000e41b0.zip
amdgpu: vamgr can be a struct instead of a pointer
vamgr is an integral part of amdgpu_device. We don't need to calloc and free it. This can save CPU time, reduce heap fragmentation. Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com> Reviewed-by: Christian K├Ânig <christian.koenig@amd.com> [Grazvydas Ignotas: rebase, correct a typo in commit message] Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_device.c')
-rw-r--r--amdgpu/amdgpu_device.c16
1 files changed, 5 insertions, 11 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)