Unify fmm_get_aperture_xxx functions
Unify fmm_get_aperture_base and fmm_get_aperture_limit into one function. Make the return value to HSAKMT_STATUS. Change-Id: I0b3f563ffb268947ab891f4935f61788d0af0e01
This commit is contained in:
@@ -1035,8 +1035,10 @@ HSAKMT_STATUS fmm_init_process_apertures(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
HSAuint64 fmm_get_aperture_limit(aperture_type_e aperture_type, HSAuint32 gpu_id)
|
||||
HSAKMT_STATUS fmm_get_aperture_base_and_limit(aperture_type_e aperture_type, HSAuint32 gpu_id,
|
||||
HSAuint64 *aperture_base, HSAuint64 *aperture_limit)
|
||||
{
|
||||
HSAKMT_STATUS err = HSAKMT_STATUS_SUCCESS;
|
||||
int32_t slot = gpu_mem_find_by_gpu_id(gpu_id);
|
||||
|
||||
if (slot < 0)
|
||||
@@ -1044,56 +1046,34 @@ HSAuint64 fmm_get_aperture_limit(aperture_type_e aperture_type, HSAuint32 gpu_id
|
||||
|
||||
switch (aperture_type) {
|
||||
case FMM_GPUVM:
|
||||
return aperture_is_valid(gpu_mem[slot].gpuvm_aperture.base,
|
||||
gpu_mem[slot].gpuvm_aperture.limit) ?
|
||||
PORT_VPTR_TO_UINT64(gpu_mem[slot].gpuvm_aperture.limit) : 0;
|
||||
if (aperture_is_valid(gpu_mem[slot].gpuvm_aperture.base,
|
||||
gpu_mem[slot].gpuvm_aperture.limit)) {
|
||||
*aperture_base = PORT_VPTR_TO_UINT64(gpu_mem[slot].gpuvm_aperture.base);
|
||||
*aperture_limit = PORT_VPTR_TO_UINT64(gpu_mem[slot].gpuvm_aperture.limit);
|
||||
}
|
||||
break;
|
||||
|
||||
case FMM_SCRATCH:
|
||||
return aperture_is_valid(gpu_mem[slot].scratch_aperture.base,
|
||||
gpu_mem[slot].scratch_aperture.limit) ?
|
||||
PORT_VPTR_TO_UINT64(gpu_mem[slot].scratch_aperture.limit) : 0;
|
||||
if (aperture_is_valid(gpu_mem[slot].scratch_aperture.base,
|
||||
gpu_mem[slot].scratch_aperture.limit)) {
|
||||
*aperture_base = PORT_VPTR_TO_UINT64(gpu_mem[slot].scratch_aperture.base);
|
||||
*aperture_limit = PORT_VPTR_TO_UINT64(gpu_mem[slot].scratch_aperture.limit);
|
||||
}
|
||||
break;
|
||||
|
||||
case FMM_LDS:
|
||||
return aperture_is_valid(gpu_mem[slot].lds_aperture.base,
|
||||
gpu_mem[slot].lds_aperture.limit) ?
|
||||
PORT_VPTR_TO_UINT64(gpu_mem[slot].lds_aperture.limit) : 0;
|
||||
if (aperture_is_valid(gpu_mem[slot].lds_aperture.base,
|
||||
gpu_mem[slot].lds_aperture.limit)) {
|
||||
*aperture_base = PORT_VPTR_TO_UINT64(gpu_mem[slot].lds_aperture.base);
|
||||
*aperture_limit = PORT_VPTR_TO_UINT64(gpu_mem[slot].lds_aperture.limit);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
err = HSAKMT_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
HSAuint64 fmm_get_aperture_base(aperture_type_e aperture_type, HSAuint32 gpu_id)
|
||||
{
|
||||
int32_t slot = gpu_mem_find_by_gpu_id(gpu_id);
|
||||
|
||||
if (slot < 0)
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
|
||||
switch (aperture_type) {
|
||||
case FMM_GPUVM:
|
||||
return aperture_is_valid(gpu_mem[slot].gpuvm_aperture.base,
|
||||
gpu_mem[slot].gpuvm_aperture.limit) ?
|
||||
PORT_VPTR_TO_UINT64(gpu_mem[slot].gpuvm_aperture.base) : 0;
|
||||
break;
|
||||
|
||||
case FMM_SCRATCH:
|
||||
return aperture_is_valid(gpu_mem[slot].scratch_aperture.base,
|
||||
gpu_mem[slot].scratch_aperture.limit) ?
|
||||
PORT_VPTR_TO_UINT64(gpu_mem[slot].scratch_aperture.base) : 0;
|
||||
break;
|
||||
|
||||
case FMM_LDS:
|
||||
return aperture_is_valid(gpu_mem[slot].lds_aperture.base,
|
||||
gpu_mem[slot].lds_aperture.limit) ?
|
||||
PORT_VPTR_TO_UINT64(gpu_mem[slot].lds_aperture.base) : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static int _fmm_map_to_gpu_gtt(uint32_t gpu_id, manageble_aperture_t *aperture,
|
||||
|
||||
@@ -65,6 +65,6 @@ bool fmm_get_handle(void *address, uint64_t *handle);
|
||||
/* Topology interface*/
|
||||
HSAKMT_STATUS fmm_node_added(HSAuint32 gpu_id);
|
||||
HSAKMT_STATUS fmm_node_removed(HSAuint32 gpu_id);
|
||||
HSAuint64 fmm_get_aperture_base(aperture_type_e aperture_type, HSAuint32 gpu_id);
|
||||
HSAuint64 fmm_get_aperture_limit(aperture_type_e aperture_type, HSAuint32 gpu_id);
|
||||
HSAKMT_STATUS fmm_get_aperture_base_and_limit(aperture_type_e aperture_type, HSAuint32 gpu_id,
|
||||
HSAuint64 *aperture_base, HSAuint64 *aperture_limit);
|
||||
#endif /* FMM_H_ */
|
||||
|
||||
+15
-12
@@ -894,8 +894,9 @@ hsaKmtGetNodeMemoryProperties(
|
||||
HsaMemoryProperties* MemoryProperties //OUT
|
||||
)
|
||||
{
|
||||
HSAKMT_STATUS err;
|
||||
HSAKMT_STATUS err = HSAKMT_STATUS_SUCCESS;
|
||||
uint32_t i, gpu_id;
|
||||
HSAuint64 aperture_limit;
|
||||
|
||||
if (!MemoryProperties)
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
@@ -918,7 +919,7 @@ hsaKmtGetNodeMemoryProperties(
|
||||
|
||||
err = validate_nodeid(NodeId, &gpu_id);
|
||||
if (err != HSAKMT_STATUS_SUCCESS)
|
||||
return err;
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < MIN(node[NodeId].node.NumMemoryBanks, NumBanks); i++) {
|
||||
assert(node[NodeId].mem);
|
||||
@@ -926,31 +927,33 @@ hsaKmtGetNodeMemoryProperties(
|
||||
}
|
||||
|
||||
/*Add LDS*/
|
||||
if (i < NumBanks){
|
||||
if (i < NumBanks &&
|
||||
fmm_get_aperture_base_and_limit(FMM_LDS, gpu_id,
|
||||
&MemoryProperties[i].VirtualBaseAddress, &aperture_limit) == HSAKMT_STATUS_SUCCESS) {
|
||||
MemoryProperties[i].HeapType = HSA_HEAPTYPE_GPU_LDS;
|
||||
MemoryProperties[i].SizeInBytes = node[NodeId].node.LDSSizeInKB * 1024;
|
||||
MemoryProperties[i].VirtualBaseAddress = fmm_get_aperture_base(FMM_LDS, gpu_id);
|
||||
i++;
|
||||
}
|
||||
|
||||
/*Add Local memory - HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE*/
|
||||
if ((i < NumBanks) && (node[NodeId].node.LocalMemSize > 0)) {
|
||||
/* Add Local memory - HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE*/
|
||||
if (i < NumBanks &&
|
||||
node[NodeId].node.LocalMemSize > 0 &&
|
||||
fmm_get_aperture_base_and_limit(FMM_GPUVM, gpu_id,
|
||||
&MemoryProperties[i].VirtualBaseAddress, &aperture_limit) == HSAKMT_STATUS_SUCCESS) {
|
||||
MemoryProperties[i].HeapType = HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE;
|
||||
MemoryProperties[i].SizeInBytes = node[NodeId].node.LocalMemSize;
|
||||
MemoryProperties[i].VirtualBaseAddress = fmm_get_aperture_base(FMM_GPUVM, gpu_id);
|
||||
i++;
|
||||
}
|
||||
|
||||
/*Add SCRATCH*/
|
||||
if (i < NumBanks){
|
||||
if (i < NumBanks &&
|
||||
fmm_get_aperture_base_and_limit(FMM_SCRATCH, gpu_id,
|
||||
&MemoryProperties[i].VirtualBaseAddress, &aperture_limit) == HSAKMT_STATUS_SUCCESS) {
|
||||
MemoryProperties[i].HeapType = HSA_HEAPTYPE_GPU_SCRATCH;
|
||||
MemoryProperties[i].VirtualBaseAddress = fmm_get_aperture_base(FMM_SCRATCH, gpu_id);
|
||||
MemoryProperties[i].SizeInBytes = fmm_get_aperture_limit(FMM_SCRATCH, gpu_id) - MemoryProperties[i].VirtualBaseAddress;
|
||||
MemoryProperties[i].SizeInBytes = (aperture_limit - MemoryProperties[i].VirtualBaseAddress) + 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
err = HSAKMT_STATUS_SUCCESS;
|
||||
|
||||
out:
|
||||
pthread_mutex_unlock(&hsakmt_mutex);
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user