amdgpu: add amdgpu_va_range_alloc2
This is the same functionnality that amdgpu_va_range_alloc offers, except it's now usable without a device handle. Reviewed-by: Marek Olšák <marek.olsak@amd.com>main
parent
96fe43a029
commit
6978f999ea
|
@ -75,6 +75,7 @@ amdgpu_va_manager_alloc
|
||||||
amdgpu_va_manager_init
|
amdgpu_va_manager_init
|
||||||
amdgpu_va_manager_deinit
|
amdgpu_va_manager_deinit
|
||||||
amdgpu_va_range_alloc
|
amdgpu_va_range_alloc
|
||||||
|
amdgpu_va_range_alloc2
|
||||||
amdgpu_va_range_free
|
amdgpu_va_range_free
|
||||||
amdgpu_va_get_start_addr
|
amdgpu_va_get_start_addr
|
||||||
amdgpu_va_range_query
|
amdgpu_va_range_query
|
||||||
|
|
|
@ -1432,6 +1432,20 @@ void amdgpu_va_manager_init(amdgpu_va_manager_handle va_mgr,
|
||||||
|
|
||||||
void amdgpu_va_manager_deinit(amdgpu_va_manager_handle va_mgr);
|
void amdgpu_va_manager_deinit(amdgpu_va_manager_handle va_mgr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to #amdgpu_va_range_alloc() but allocates VA
|
||||||
|
* directly from an amdgpu_va_manager_handle instead of using
|
||||||
|
* the manager from an amdgpu_device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int amdgpu_va_range_alloc2(amdgpu_va_manager_handle va_mgr,
|
||||||
|
enum amdgpu_gpu_va_range va_range_type,
|
||||||
|
uint64_t size,
|
||||||
|
uint64_t va_base_alignment,
|
||||||
|
uint64_t va_base_required,
|
||||||
|
uint64_t *va_base_allocated,
|
||||||
|
amdgpu_va_handle *va_range_handle,
|
||||||
|
uint64_t flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VA mapping/unmapping for the buffer object
|
* VA mapping/unmapping for the buffer object
|
||||||
|
|
|
@ -228,25 +228,40 @@ drm_public int amdgpu_va_range_alloc(amdgpu_device_handle dev,
|
||||||
uint64_t *va_base_allocated,
|
uint64_t *va_base_allocated,
|
||||||
amdgpu_va_handle *va_range_handle,
|
amdgpu_va_handle *va_range_handle,
|
||||||
uint64_t flags)
|
uint64_t flags)
|
||||||
|
{
|
||||||
|
return amdgpu_va_range_alloc2(&dev->va_mgr, va_range_type, size,
|
||||||
|
va_base_alignment, va_base_required,
|
||||||
|
va_base_allocated, va_range_handle,
|
||||||
|
flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
drm_public int amdgpu_va_range_alloc2(amdgpu_va_manager_handle va_mgr,
|
||||||
|
enum amdgpu_gpu_va_range va_range_type,
|
||||||
|
uint64_t size,
|
||||||
|
uint64_t va_base_alignment,
|
||||||
|
uint64_t va_base_required,
|
||||||
|
uint64_t *va_base_allocated,
|
||||||
|
amdgpu_va_handle *va_range_handle,
|
||||||
|
uint64_t flags)
|
||||||
{
|
{
|
||||||
struct amdgpu_bo_va_mgr *vamgr;
|
struct amdgpu_bo_va_mgr *vamgr;
|
||||||
bool search_from_top = !!(flags & AMDGPU_VA_RANGE_REPLAYABLE);
|
bool search_from_top = !!(flags & AMDGPU_VA_RANGE_REPLAYABLE);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Clear the flag when the high VA manager is not initialized */
|
/* Clear the flag when the high VA manager is not initialized */
|
||||||
if (flags & AMDGPU_VA_RANGE_HIGH && !dev->va_mgr.vamgr_high_32.va_max)
|
if (flags & AMDGPU_VA_RANGE_HIGH && !va_mgr->vamgr_high_32.va_max)
|
||||||
flags &= ~AMDGPU_VA_RANGE_HIGH;
|
flags &= ~AMDGPU_VA_RANGE_HIGH;
|
||||||
|
|
||||||
if (flags & AMDGPU_VA_RANGE_HIGH) {
|
if (flags & AMDGPU_VA_RANGE_HIGH) {
|
||||||
if (flags & AMDGPU_VA_RANGE_32_BIT)
|
if (flags & AMDGPU_VA_RANGE_32_BIT)
|
||||||
vamgr = &dev->va_mgr.vamgr_high_32;
|
vamgr = &va_mgr->vamgr_high_32;
|
||||||
else
|
else
|
||||||
vamgr = &dev->va_mgr.vamgr_high;
|
vamgr = &va_mgr->vamgr_high;
|
||||||
} else {
|
} else {
|
||||||
if (flags & AMDGPU_VA_RANGE_32_BIT)
|
if (flags & AMDGPU_VA_RANGE_32_BIT)
|
||||||
vamgr = &dev->va_mgr.vamgr_32;
|
vamgr = &va_mgr->vamgr_32;
|
||||||
else
|
else
|
||||||
vamgr = &dev->va_mgr.vamgr_low;
|
vamgr = &va_mgr->vamgr_low;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment);
|
va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment);
|
||||||
|
@ -259,9 +274,9 @@ drm_public int amdgpu_va_range_alloc(amdgpu_device_handle dev,
|
||||||
if (!(flags & AMDGPU_VA_RANGE_32_BIT) && ret) {
|
if (!(flags & AMDGPU_VA_RANGE_32_BIT) && ret) {
|
||||||
/* fallback to 32bit address */
|
/* fallback to 32bit address */
|
||||||
if (flags & AMDGPU_VA_RANGE_HIGH)
|
if (flags & AMDGPU_VA_RANGE_HIGH)
|
||||||
vamgr = &dev->va_mgr.vamgr_high_32;
|
vamgr = &va_mgr->vamgr_high_32;
|
||||||
else
|
else
|
||||||
vamgr = &dev->va_mgr.vamgr_32;
|
vamgr = &va_mgr->vamgr_32;
|
||||||
ret = amdgpu_vamgr_find_va(vamgr, size,
|
ret = amdgpu_vamgr_find_va(vamgr, size,
|
||||||
va_base_alignment, va_base_required,
|
va_base_alignment, va_base_required,
|
||||||
search_from_top, va_base_allocated);
|
search_from_top, va_base_allocated);
|
||||||
|
|
Loading…
Reference in New Issue