summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>2023-12-18 14:53:10 +0100
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>2024-03-21 10:56:29 +0100
commit43768487204f5d53d5ffcd76a717e2293e1684cb (patch)
treee648799e0fee0822ef46d9f2149dffa112364ee4
parentc8f327ce9cb504a6c2185487d576be3d5254556a (diff)
amdgpu: add amdgpu_va_manager
Until now VA management was tied to a device handle, but there's no reason for this. As a first step to export VA management outside of amdgpu_device, this commit adds a new structure type holding the 4 va_mgr. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--amdgpu/amdgpu_device.c22
-rw-r--r--amdgpu/amdgpu_internal.h21
-rw-r--r--amdgpu/amdgpu_vamgr.c14
3 files changed, 31 insertions, 26 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index 7d9c5dd9..79abd97c 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -105,10 +105,10 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev)
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
close(dev->flink_fd);
- amdgpu_vamgr_deinit(&dev->vamgr_32);
- amdgpu_vamgr_deinit(&dev->vamgr);
- amdgpu_vamgr_deinit(&dev->vamgr_high_32);
- amdgpu_vamgr_deinit(&dev->vamgr_high);
+ amdgpu_vamgr_deinit(&dev->va_mgr.vamgr_32);
+ amdgpu_vamgr_deinit(&dev->va_mgr.vamgr_low);
+ amdgpu_vamgr_deinit(&dev->va_mgr.vamgr_high_32);
+ amdgpu_vamgr_deinit(&dev->va_mgr.vamgr_high);
handle_table_fini(&dev->bo_handles);
handle_table_fini(&dev->bo_flink_names);
pthread_mutex_destroy(&dev->bo_table_mutex);
@@ -238,24 +238,24 @@ drm_public int amdgpu_device_initialize(int fd,
start = dev->dev_info.virtual_address_offset;
max = MIN2(dev->dev_info.virtual_address_max, 0x100000000ULL);
- amdgpu_vamgr_init(&dev->vamgr_32, start, max,
+ amdgpu_vamgr_init(&dev->va_mgr.vamgr_32, start, max,
dev->dev_info.virtual_address_alignment);
start = max;
max = MAX2(dev->dev_info.virtual_address_max, 0x100000000ULL);
- amdgpu_vamgr_init(&dev->vamgr, start, max,
+ amdgpu_vamgr_init(&dev->va_mgr.vamgr_low, start, max,
dev->dev_info.virtual_address_alignment);
start = dev->dev_info.high_va_offset;
max = MIN2(dev->dev_info.high_va_max, (start & ~0xffffffffULL) +
0x100000000ULL);
- amdgpu_vamgr_init(&dev->vamgr_high_32, start, max,
+ amdgpu_vamgr_init(&dev->va_mgr.vamgr_high_32, start, max,
dev->dev_info.virtual_address_alignment);
start = max;
max = MAX2(dev->dev_info.high_va_max, (start & ~0xffffffffULL) +
0x100000000ULL);
- amdgpu_vamgr_init(&dev->vamgr_high, start, max,
+ amdgpu_vamgr_init(&dev->va_mgr.vamgr_high, start, max,
dev->dev_info.virtual_address_alignment);
amdgpu_parse_asic_ids(dev);
@@ -306,10 +306,10 @@ drm_public int amdgpu_query_sw_info(amdgpu_device_handle dev,
switch (info) {
case amdgpu_sw_info_address32_hi:
- if (dev->vamgr_high_32.va_max)
- *val32 = (dev->vamgr_high_32.va_max - 1) >> 32;
+ if (dev->va_mgr.vamgr_high_32.va_max)
+ *val32 = (dev->va_mgr.vamgr_high_32.va_max - 1) >> 32;
else
- *val32 = (dev->vamgr_32.va_max - 1) >> 32;
+ *val32 = (dev->va_mgr.vamgr_32.va_max - 1) >> 32;
return 0;
}
return -EINVAL;
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 2834c9c6..af85b849 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -63,6 +63,17 @@ struct amdgpu_va {
struct amdgpu_bo_va_mgr *vamgr;
};
+struct amdgpu_va_manager {
+ /** The VA manager for the lower virtual address space */
+ struct amdgpu_bo_va_mgr vamgr_low;
+ /** The VA manager for the 32bit address space */
+ struct amdgpu_bo_va_mgr vamgr_32;
+ /** The VA manager for the high virtual address space */
+ struct amdgpu_bo_va_mgr vamgr_high;
+ /** The VA manager for the 32bit high address space */
+ struct amdgpu_bo_va_mgr vamgr_high_32;
+};
+
struct amdgpu_device {
atomic_t refcount;
struct amdgpu_device *next;
@@ -80,14 +91,8 @@ struct amdgpu_device {
pthread_mutex_t bo_table_mutex;
struct drm_amdgpu_info_device dev_info;
struct amdgpu_gpu_info info;
- /** The VA manager for the lower virtual address space */
- struct amdgpu_bo_va_mgr vamgr;
- /** The VA manager for the 32bit address space */
- struct amdgpu_bo_va_mgr vamgr_32;
- /** The VA manager for the high virtual address space */
- struct amdgpu_bo_va_mgr vamgr_high;
- /** The VA manager for the 32bit high address space */
- struct amdgpu_bo_va_mgr vamgr_high_32;
+
+ struct amdgpu_va_manager va_mgr;
};
struct amdgpu_bo {
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 2c4c9dba..aa657db7 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -234,19 +234,19 @@ drm_public int amdgpu_va_range_alloc(amdgpu_device_handle dev,
int ret;
/* Clear the flag when the high VA manager is not initialized */
- if (flags & AMDGPU_VA_RANGE_HIGH && !dev->vamgr_high_32.va_max)
+ if (flags & AMDGPU_VA_RANGE_HIGH && !dev->va_mgr.vamgr_high_32.va_max)
flags &= ~AMDGPU_VA_RANGE_HIGH;
if (flags & AMDGPU_VA_RANGE_HIGH) {
if (flags & AMDGPU_VA_RANGE_32_BIT)
- vamgr = &dev->vamgr_high_32;
+ vamgr = &dev->va_mgr.vamgr_high_32;
else
- vamgr = &dev->vamgr_high;
+ vamgr = &dev->va_mgr.vamgr_high;
} else {
if (flags & AMDGPU_VA_RANGE_32_BIT)
- vamgr = &dev->vamgr_32;
+ vamgr = &dev->va_mgr.vamgr_32;
else
- vamgr = &dev->vamgr;
+ vamgr = &dev->va_mgr.vamgr_low;
}
va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment);
@@ -259,9 +259,9 @@ drm_public int amdgpu_va_range_alloc(amdgpu_device_handle dev,
if (!(flags & AMDGPU_VA_RANGE_32_BIT) && ret) {
/* fallback to 32bit address */
if (flags & AMDGPU_VA_RANGE_HIGH)
- vamgr = &dev->vamgr_high_32;
+ vamgr = &dev->va_mgr.vamgr_high_32;
else
- vamgr = &dev->vamgr_32;
+ vamgr = &dev->va_mgr.vamgr_32;
ret = amdgpu_vamgr_find_va(vamgr, size,
va_base_alignment, va_base_required,
search_from_top, va_base_allocated);