From 298ec3d84004cb5a7caeddafd00d3715d483e0bc Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 27 Sep 2024 18:19:53 +0000 Subject: [PATCH] rocr/vmm: Only modify permisions for specified agents When hsa_amd_vmem_set_access is called, do not remove permissions for unspecified agents. Also updating documentation in header to clarify this. Change-Id: I3bb4cf08ba399f85cc67b17fd13a4a40d862415f [ROCm/ROCR-Runtime commit: 73f6bfa7470af9acc56e75ba909687ed0ec99880] --- .../hsa-runtime/core/runtime/runtime.cpp | 24 ------------------- .../runtime/hsa-runtime/inc/hsa_ext_amd.h | 5 ++-- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp index b0a3dc8abc..8592c63c38 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -3388,30 +3388,6 @@ Runtime::VMemorySetAccessPerHandle(void *va, MappedHandle &mappedHandle, } } } - - // Remove agents that were previously allowed but not included in current list - for (auto agentPermsIt = mappedHandle.allowed_agents.begin(); - agentPermsIt != mappedHandle.allowed_agents.end();) { - bool agent_removed = true; - - for (int i = 0; i < desc_cnt; i++) { - Agent *checkAgent = Agent::Convert(desc[i].agent_handle); - - if (agentPermsIt->first == checkAgent) { - agent_removed = false; - break; - } - } - if (agent_removed) { - if (agentPermsIt->second.RemoveAccess() != HSA_STATUS_SUCCESS) - throw AMD::hsa_exception(HSA_STATUS_ERROR, "Failed to remove access for memory handle."); - - agentPermsIt = mappedHandle.allowed_agents.erase(agentPermsIt); - } else { - ++agentPermsIt; - } - } - return HSA_STATUS_SUCCESS; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_amd.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_amd.h index 0f0f5fcf98..38b34b8b44 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_amd.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_amd.h @@ -3370,8 +3370,9 @@ typedef struct hsa_amd_memory_access_desc_s { * * Make previously mapped virtual address accessible to specific agents. @p size must be equal to * size of previously mapped virtual memory handle. - * Calling hsa_amd_vmem_set_access multiple times on the same @p va will overwrite previous - * permissions for all agents + * Calling hsa_amd_vmem_set_access multiple times on the same @p va: + * - Will overwrite permissions for agents specified in @p desc + * - Will leave permissions unchanged for agents not specified in @p desc * * @param[in] va previously mapped virtual address * @param[in] size of memory mapping