From a844925c8af45161145ab512efb8d5584c9d97f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 2 Nov 2017 18:54:59 +0100 Subject: [PATCH] amdgpu: sanitize 64bit VA manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding the extra reservation of the 32bit space to the 64bit manager is complete nonsense and just a waste of memory and CPU cycles. Signed-off-by: Christian König --- amdgpu/amdgpu_device.c | 24 ++++++------------------ amdgpu/amdgpu_internal.h | 7 ------- amdgpu/amdgpu_vamgr.c | 4 ++-- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index 2b31c45b..344e87ed 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -270,20 +270,14 @@ int amdgpu_device_initialize(int fd, goto cleanup; } - amdgpu_vamgr_init(&dev->vamgr, dev->dev_info.virtual_address_offset, - dev->dev_info.virtual_address_max, + start = dev->dev_info.virtual_address_offset; + max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff); + amdgpu_vamgr_init(&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); - max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff); - start = amdgpu_vamgr_find_va(&dev->vamgr, - max - dev->dev_info.virtual_address_offset, - dev->dev_info.virtual_address_alignment, 0); - if (start > 0xffffffff) { - fprintf(stderr, "%s: amdgpu_vamgr_find_va failed\n", __func__); - goto free_va; /* shouldn't get here */ - } - - amdgpu_vamgr_init(&dev->vamgr_32, start, max, + start = MAX2(dev->dev_info.virtual_address_offset, 0x100000000ULL); + max = MAX2(dev->dev_info.virtual_address_max, 0x100000000ULL); + amdgpu_vamgr_init(&dev->vamgr, start, max, dev->dev_info.virtual_address_alignment); r = amdgpu_parse_asic_ids(&dev->asic_ids); @@ -300,12 +294,6 @@ int amdgpu_device_initialize(int fd, return 0; -free_va: - r = -ENOMEM; - amdgpu_vamgr_free_va(&dev->vamgr, start, - max - dev->dev_info.virtual_address_offset); - amdgpu_vamgr_deinit(&dev->vamgr); - cleanup: if (dev->fd >= 0) close(dev->fd); diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 56d15112..e26e5190 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -148,13 +148,6 @@ drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start, drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr); -drm_private uint64_t -amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, - uint64_t alignment, uint64_t base_required); - -drm_private void -amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size); - drm_private int amdgpu_parse_asic_ids(struct amdgpu_asic_id **asic_ids); drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev); diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index 8516b594..ab425ef7 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -66,7 +66,7 @@ drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr) pthread_mutex_destroy(&mgr->bo_va_mutex); } -drm_private uint64_t +static drm_private uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, uint64_t alignment, uint64_t base_required) { @@ -155,7 +155,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, return offset; } -drm_private void +static drm_private void amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size) { struct amdgpu_bo_va_hole *hole;