From 12802da74f0e480bbde5a11df689329910893e87 Mon Sep 17 00:00:00 2001 From: Sabre Shao Date: Thu, 9 Jul 2015 13:53:24 +0800 Subject: [PATCH] amdgpu: add va range query interface amdgpu_va_range_query interface is added so that client can query va range supported by specific device. Signed-off-by: Sabre Shao Reviewed-by: Jammy Zhou --- amdgpu/amdgpu.h | 21 +++++++++++++++++++++ amdgpu/amdgpu_vamgr.c | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index fcd12b3e..a38e488e 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1155,4 +1155,25 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev, */ int amdgpu_va_range_free(amdgpu_va_handle va_range_handle); +/** +* Query virtual address range +* +* UMD can query GPU VM range supported by each device +* to initialize its own VAM accordingly. +* +* \param dev - [in] Device handle. See #amdgpu_device_initialize() +* \param type - \c [in] Type of virtual address range +* \param offset - \c [out] Start offset of virtual address range +* \param size - \c [out] Size of virtual address range +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ + +int amdgpu_va_range_query(amdgpu_device_handle dev, + enum amdgpu_gpu_va_range type, + uint64_t *start, + uint64_t *end); + #endif /* #ifdef _AMDGPU_H_ */ diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index faffba20..d6ec9b4f 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -31,6 +31,17 @@ static struct amdgpu_bo_va_mgr vamgr = {{0}}; +int amdgpu_va_range_query(amdgpu_device_handle dev, + enum amdgpu_gpu_va_range type, uint64_t *start, uint64_t *end) +{ + if (type == amdgpu_gpu_va_range_general) { + *start = dev->dev_info.virtual_address_offset; + *end = dev->dev_info.virtual_address_max; + return 0; + } + return -EINVAL; +} + static void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, struct amdgpu_device *dev) { mgr->va_offset = dev->dev_info.virtual_address_offset;