aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJammy Zhou2015-08-16 22:09:08 -0500
committerAlex Deucher2015-08-17 15:26:26 -0500
commitffa305d0fc926418e4dff432381ead8907dc18d9 (patch)
tree1581c8b5ba358942fe6a376bf85e7750af6d3d3a /amdgpu/amdgpu_device.c
parent102ab6f0049c2c85857fd19f098bc5b51e2a8a60 (diff)
downloadexternal-libdrm-ffa305d0fc926418e4dff432381ead8907dc18d9.tar.gz
external-libdrm-ffa305d0fc926418e4dff432381ead8907dc18d9.tar.xz
external-libdrm-ffa305d0fc926418e4dff432381ead8907dc18d9.zip
amdgpu: add flag to support 32bit VA address v4
The AMDGPU_VA_RANGE_32_BIT flag is added to request VA range in the 32bit address space for amdgpu_va_range_alloc. The 32bit address space is reserved at initialization time, and managed with a separate VAMGR as part of the global VAMGR. And if no enough VA space available in range above 4GB, this reserved range can be used as fallback. v2: add comment for AMDGPU_VA_RANGE_32_BIT, and add vamgr to va_range v3: rebase to Emil's drm_private series v4: fix one warning 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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index c6bbae81..e16cd24b 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -43,6 +43,7 @@
43#include "amdgpu_drm.h" 43#include "amdgpu_drm.h"
44#include "amdgpu_internal.h" 44#include "amdgpu_internal.h"
45#include "util_hash_table.h" 45#include "util_hash_table.h"
46#include "util_math.h"
46 47
47#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) 48#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
48#define UINT_TO_PTR(x) ((void *)((intptr_t)(x))) 49#define UINT_TO_PTR(x) ((void *)((intptr_t)(x)))
@@ -173,6 +174,7 @@ int amdgpu_device_initialize(int fd,
173 int flag_auth = 0; 174 int flag_auth = 0;
174 int flag_authexist=0; 175 int flag_authexist=0;
175 uint32_t accel_working = 0; 176 uint32_t accel_working = 0;
177 uint64_t start, max;
176 178
177 *device_handle = NULL; 179 *device_handle = NULL;
178 180
@@ -251,6 +253,19 @@ int amdgpu_device_initialize(int fd,
251 253
252 dev->vamgr = amdgpu_vamgr_get_global(dev); 254 dev->vamgr = amdgpu_vamgr_get_global(dev);
253 255
256 max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff);
257 start = amdgpu_vamgr_find_va(dev->vamgr,
258 max - dev->dev_info.virtual_address_offset,
259 dev->dev_info.virtual_address_alignment, 0);
260 if (start > 0xffffffff)
261 goto free_va; /* shouldn't get here */
262
263 dev->vamgr_32 = calloc(1, sizeof(struct amdgpu_bo_va_mgr));
264 if (dev->vamgr_32 == NULL)
265 goto free_va;
266 amdgpu_vamgr_init(dev->vamgr_32, start, max,
267 dev->dev_info.virtual_address_alignment);
268
254 *major_version = dev->major_version; 269 *major_version = dev->major_version;
255 *minor_version = dev->minor_version; 270 *minor_version = dev->minor_version;
256 *device_handle = dev; 271 *device_handle = dev;
@@ -259,6 +274,11 @@ int amdgpu_device_initialize(int fd,
259 274
260 return 0; 275 return 0;
261 276
277free_va:
278 r = -ENOMEM;
279 amdgpu_vamgr_free_va(dev->vamgr, start,
280 max - dev->dev_info.virtual_address_offset);
281
262cleanup: 282cleanup:
263 if (dev->fd >= 0) 283 if (dev->fd >= 0)
264 close(dev->fd); 284 close(dev->fd);