From 6e8e4e17ae3bab07c7daf90d13b3550f15ecff6f Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 15 Jul 2024 19:05:37 +0000 Subject: [PATCH] Add new system event for memory errors Currently, the only error type is HSA_AMD_MEMORY_ERROR_MEMORY_IN_USE, which happens when a user application incorrectly tries to free memory that is currently being used by underlying device hardware. Change-Id: I8ce352eb9719694135fba1fa56d62368036b2e5e Signed-off-by: Chris Freehill [ROCm/ROCR-Runtime commit: 2853bf03f017b4d668e3f6663df8ce18c40cb2ff] --- .../runtime/hsa-runtime/inc/hsa_ext_amd.h | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) 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 ae3bcfdb24..e8e7a75cbe 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 @@ -2298,6 +2298,10 @@ typedef enum hsa_amd_event_type_s { AMD GPU HW Exception. */ HSA_AMD_GPU_HW_EXCEPTION_EVENT, + /* + AMD GPU memory error. + */ + HSA_AMD_GPU_MEMORY_ERROR_EVENT, } hsa_amd_event_type_t; /** @@ -2341,6 +2345,33 @@ typedef struct hsa_amd_gpu_memory_fault_info_s { uint32_t fault_reason_mask; } hsa_amd_gpu_memory_fault_info_t; +/** + * @brief Flags denoting the cause of a memory error. + */ +typedef enum { + // Memory was in use by low-level HW component and cannot be released + HSA_AMD_MEMORY_ERROR_MEMORY_IN_USE = (1 << 0), +} hsa_amd_memory_error_reason_t; + +/** + * @brief AMD GPU memory error event data. + */ +typedef struct hsa_amd_gpu_memory_error_info_s { + /* + The agent where the memory error occurred. + */ + hsa_agent_t agent; + /* + Virtual address involved. + */ + uint64_t virtual_address; + /* + Bit field encoding the memory error failure reasons. There could be multiple bits set + for one error. Bits are defined in hsa_amd_memory_error_reason_t. + */ + uint32_t error_reason_mask; +} hsa_amd_gpu_memory_error_info_t; + /** * @brief Flags denoting the type of a HW exception */ @@ -2388,6 +2419,10 @@ typedef struct hsa_amd_event_s { The memory fault info, only valid when @p event_type is HSA_AMD_GPU_HW_EXCEPTION_EVENT. */ hsa_amd_gpu_hw_exception_info_t hw_exception; + /* + The memory error info, only valid when @p event_type is HSA_AMD_GPU_MEMORY_ERROR_EVENT. + */ + hsa_amd_gpu_memory_error_info_t memory_error; }; } hsa_amd_event_t;