aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu
diff options
context:
space:
mode:
authorAlex Xie2017-01-28 13:50:36 -0600
committerAlex Deucher2017-02-02 14:22:45 -0600
commit067e9a1d47a8373b3145481a70fec84ce8e76441 (patch)
treec24672d4f6f1cdada5b54be01e249a004f962ea3 /amdgpu
parent7a03cdf6a703911d2a8e8ab0781f1e6b88412329 (diff)
downloadexternal-libdrm-067e9a1d47a8373b3145481a70fec84ce8e76441.tar.gz
external-libdrm-067e9a1d47a8373b3145481a70fec84ce8e76441.tar.xz
external-libdrm-067e9a1d47a8373b3145481a70fec84ce8e76441.zip
amdgpu: vamgr_32 can be a struct instead of a pointer
vamgr_32 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')
-rw-r--r--amdgpu/amdgpu_device.c8
-rw-r--r--amdgpu/amdgpu_internal.h2
-rw-r--r--amdgpu/amdgpu_vamgr.c4
3 files changed, 5 insertions, 9 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index cad7133d..11714e47 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -131,8 +131,7 @@ static int amdgpu_get_auth(int fd, int *auth)
131 131
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 free(dev->vamgr_32);
136 amdgpu_vamgr_deinit(dev->vamgr); 135 amdgpu_vamgr_deinit(dev->vamgr);
137 free(dev->vamgr); 136 free(dev->vamgr);
138 util_hash_table_destroy(dev->bo_flink_names); 137 util_hash_table_destroy(dev->bo_flink_names);
@@ -270,10 +269,7 @@ int amdgpu_device_initialize(int fd,
270 if (start > 0xffffffff) 269 if (start > 0xffffffff)
271 goto free_va; /* shouldn't get here */ 270 goto free_va; /* shouldn't get here */
272 271
273 dev->vamgr_32 = calloc(1, sizeof(struct amdgpu_bo_va_mgr)); 272 amdgpu_vamgr_init(&dev->vamgr_32, start, max,
274 if (dev->vamgr_32 == NULL)
275 goto free_va;
276 amdgpu_vamgr_init(dev->vamgr_32, start, max,
277 dev->dev_info.virtual_address_alignment); 273 dev->dev_info.virtual_address_alignment);
278 274
279 *major_version = dev->major_version; 275 *major_version = dev->major_version;
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 4f039b68..7e237ac1 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -87,7 +87,7 @@ struct amdgpu_device {
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};
92 92
93struct amdgpu_bo { 93struct amdgpu_bo {
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 8a707cbc..4dc4253c 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -236,7 +236,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
236 struct amdgpu_bo_va_mgr *vamgr; 236 struct amdgpu_bo_va_mgr *vamgr;
237 237
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
@@ -249,7 +249,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
249 if (!(flags & AMDGPU_VA_RANGE_32_BIT) && 249 if (!(flags & AMDGPU_VA_RANGE_32_BIT) &&
250 (*va_base_allocated == AMDGPU_INVALID_VA_ADDRESS)) { 250 (*va_base_allocated == AMDGPU_INVALID_VA_ADDRESS)) {
251 /* fallback to 32bit address */ 251 /* fallback to 32bit address */
252 vamgr = dev->vamgr_32; 252 vamgr = &dev->vamgr_32;
253 *va_base_allocated = amdgpu_vamgr_find_va(vamgr, size, 253 *va_base_allocated = amdgpu_vamgr_find_va(vamgr, size,
254 va_base_alignment, va_base_required); 254 va_base_alignment, va_base_required);
255 } 255 }