libhsakmt: fix KFDOpenCloseKFDTest.OpenAlreadyOpenedKFD Segmentation fault on gfx902

g_props is intialized in topology_take_snapshot which needs to call
hsaKmtAcquireSystemProperties. In hsaKmtOpenKFD, it doesn't call hsaKmtAcquireSystemProperties.
So it needs to change parameter of topology_is_svm_needed from node_id
to EngineId to avoid Segmentation fault on gfx902.

Signed-off-by: changzhu <Changfeng.Zhu@amd.com>
Change-Id: Iba8d20a9142510c70927454d26bdcaf579ad5574


[ROCm/ROCR-Runtime commit: 978028d3f6]
This commit is contained in:
changzhu
2021-08-18 16:38:21 +08:00
committed by Changfeng Zhu
parent 8f735fb9d5
commit 13c2ad6508
3 changed files with 12 additions and 7 deletions
+8 -3
View File
@@ -174,6 +174,7 @@ typedef struct {
uint32_t device_id;
uint32_t node_id;
uint64_t local_mem_size;
HSA_ENGINE_ID EngineId;
aperture_t lds_aperture;
aperture_t scratch_aperture;
aperture_t mmio_aperture;
@@ -1340,7 +1341,7 @@ void *fmm_allocate_device(uint32_t gpu_id, uint32_t node_id, void *address,
ioc_flags |= fmm_translate_hsa_to_ioc_flags(mflags);
if (topology_is_svm_needed(node_id)) {
if (topology_is_svm_needed(gpu_mem[gpu_mem_id].EngineId)) {
aperture = svm.dgpu_aperture;
if (mflags.ui32.AQLQueueMemory)
size = MemorySizeInBytes * 2;
@@ -2217,6 +2218,10 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes)
goto sysfs_parse_failed;
}
gpu_mem[gpu_mem_count].EngineId.ui32.Major = props.EngineId.ui32.Major;
gpu_mem[gpu_mem_count].EngineId.ui32.Minor = props.EngineId.ui32.Minor;
gpu_mem[gpu_mem_count].EngineId.ui32.Stepping = props.EngineId.ui32.Stepping;
gpu_mem[gpu_mem_count].drm_render_fd = fd;
gpu_mem[gpu_mem_count].gpu_id = gpu_id;
gpu_mem[gpu_mem_count].local_mem_size = props.LocalMemSize;
@@ -2387,7 +2392,7 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes)
fmm_init_rbtree();
for (gpu_mem_id = 0; (uint32_t)gpu_mem_id < gpu_mem_count; gpu_mem_id++) {
if (!topology_is_svm_needed(gpu_mem[gpu_mem_id].node_id))
if (!topology_is_svm_needed(gpu_mem[gpu_mem_id].EngineId))
continue;
gpu_mem[gpu_mem_id].mmio_aperture.base = map_mmio(
gpu_mem[gpu_mem_id].node_id,
@@ -3171,7 +3176,7 @@ HSAKMT_STATUS fmm_register_graphics_handle(HSAuint64 GraphicsResourceHandle,
gpu_mem_id = gpu_mem_find_by_gpu_id(infoArgs.gpu_id);
if (gpu_mem_id < 0)
goto error_free_metadata;
if (topology_is_svm_needed(gpu_mem[gpu_mem_id].node_id)) {
if (topology_is_svm_needed(gpu_mem[gpu_mem_id].EngineId)) {
aperture = svm.dgpu_aperture;
aperture_base = NULL;
} else {
+1 -1
View File
@@ -179,7 +179,7 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties
bool *p2p_links, uint32_t *num_p2pLinks);
HSAKMT_STATUS topology_sysfs_get_system_props(HsaSystemProperties *props);
void topology_setup_is_dgpu_param(HsaNodeProperties *props);
bool topology_is_svm_needed(uint32_t node_id);
bool topology_is_svm_needed(HSA_ENGINE_ID EngineId);
HSAuint32 PageSizeFromFlags(unsigned int pageSizeFlags);
+3 -3
View File
@@ -798,12 +798,12 @@ void topology_setup_is_dgpu_param(HsaNodeProperties *props)
is_dgpu = true;
}
bool topology_is_svm_needed(uint32_t node_id)
bool topology_is_svm_needed(HSA_ENGINE_ID EngineId)
{
if (is_dgpu)
return true;
if (get_gfxv_by_node_id(node_id) >= GFX_VERSION_VEGA10)
if (HSA_GET_GFX_VERSION_FULL(EngineId.ui32) >= GFX_VERSION_VEGA10)
return true;
return false;
@@ -2159,7 +2159,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtGetNodeMemoryProperties(HSAuint32 NodeId,
}
/* Add SVM aperture */
if (topology_is_svm_needed(get_device_id_by_gpu_id(gpu_id)) && i < NumBanks &&
if (topology_is_svm_needed(g_props[NodeId].node.EngineId) && i < NumBanks &&
fmm_get_aperture_base_and_limit(
FMM_SVM, gpu_id, &MemoryProperties[i].VirtualBaseAddress,
&aperture_limit) == HSAKMT_STATUS_SUCCESS) {