From d21e9d5bbd13ffc9fd89a54ef40ac1f4a0518c37 Mon Sep 17 00:00:00 2001 From: Philip Cox Date: Wed, 10 Apr 2019 14:45:18 -0400 Subject: [PATCH] libhsakmt: Update HsaQueueInfo for GetQueueInfo hsaKmtGetQueueInfo needs to return the control stack size, and the wave state size for the debugger. These changes are needed to support returning the new values. Change-Id: Ib4c60e0ea34446c06aef4a86996250989f348a69 Signed-off-by: Philip Cox --- include/hsakmttypes.h | 30 +++++++++++++++++++++++++++++- src/queues.c | 8 ++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/include/hsakmttypes.h b/include/hsakmttypes.h index f70f46e4e9..8b0d232597 100644 --- a/include/hsakmttypes.h +++ b/include/hsakmttypes.h @@ -641,6 +641,34 @@ typedef enum _HSA_QUEUE_TYPE HSA_QUEUE_TYPE_SIZE = 0xFFFFFFFF //aligns to 32bit enum } HSA_QUEUE_TYPE; +/** + The user context save area starts at offset 0 with the + HsaUserContextSaveAreaHeader header followed by the space for a + user space copy of the control stack and the user space wave save + state. The area must be dword aligned. The context save area is + valid for the duration that the associated queue exists. When a + context save occurs, the HsaUserContextSaveAreaHeader header will + be updated with information about the context save. The context save + area is not modified by any other operation, including a context + resume. + */ + +typedef struct +{ + HSAuint32 ControlStackOffset; // Byte offset from start of user context + // save area to the last saved top (lowest + // address) of control stack data. Must be + // 4 byte aligned. + HSAuint32 ControlStackSize; // Byte size of the last saved control stack + // data. Must be 4 byte aligned. + HSAuint32 WaveStateOffset; // Byte offset from start of user context save + // area to the last saved base (lowest address) + // of wave state data. Must be 4 byte aligned. + HSAuint32 WaveStateSize; // Byte size of the last saved wave state data. + // Must be 4 byte aligned. +} HsaUserContextSaveAreaHeader; + + typedef struct { HSAuint32 QueueDetailError; // HW specific queue error state @@ -656,7 +684,7 @@ typedef struct HSAuint64 SaveAreaSizeInBytes; // Must be 4-Byte aligned HSAuint32* ControlStackTop; // ptr to the TOS HSAuint64 ControlStackUsedInBytes; // Must be 4-Byte aligned - HSAuint64 Reserved1; // runtime/system CU assignment + HsaUserContextSaveAreaHeader *SaveAreaHeader; HSAuint64 Reserved2; // runtime/system CU assignment } HsaQueueInfo; diff --git a/src/queues.c b/src/queues.c index a1af2f39e7..4472e6f63a 100644 --- a/src/queues.c +++ b/src/queues.c @@ -373,9 +373,12 @@ static bool update_ctx_save_restore_size(uint32_t nodeid, struct queue *q) ctl_stack_size = cu_num * WAVES_PER_CU_VI * 8 + 8; wg_data_size = cu_num * WG_CONTEXT_DATA_SIZE_PER_CU_VI; - q->ctl_stack_size = PAGE_ALIGN_UP(ctl_stack_size); - q->ctx_save_restore_size = q->ctl_stack_size + PAGE_ALIGN_UP(wg_data_size); + q->ctl_stack_size = PAGE_ALIGN_UP(ctl_stack_size + + sizeof(HsaUserContextSaveAreaHeader)); + + q->ctx_save_restore_size = q->ctl_stack_size + + PAGE_ALIGN_UP(wg_data_size); return true; } return false; @@ -767,6 +770,7 @@ hsaKmtGetQueueInfo( QueueInfo->CUMaskInfo = q->cu_mask; QueueInfo->QueueDetailError = 0; QueueInfo->QueueTypeExtended = 0; + QueueInfo->SaveAreaHeader = q->ctx_save_restore; return HSAKMT_STATUS_SUCCESS; }