From b8dc875b3c8424aeed4c52ec524a8262f8b49511 Mon Sep 17 00:00:00 2001 From: Mukul Joshi Date: Tue, 1 Mar 2022 12:03:28 -0500 Subject: [PATCH] libhsakmt: Update context save area size calculations Currently, context save area size passed to KFD includes the size of the debug area. Change this to report the actual size of the context save area to KFD. Signed-off-by: Mukul Joshi Change-Id: I5d440ae802255a97ade046775f6a000bae79d5d5 --- src/queues.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/queues.c b/src/queues.c index 6a729b63ce..c83dd93038 100644 --- a/src/queues.c +++ b/src/queues.c @@ -291,7 +291,7 @@ static bool update_ctx_save_restore_size(uint32_t nodeid, struct queue *q) ALIGN_UP(wave_num * DEBUGGER_BYTES_PER_WAVE, DEBUGGER_BYTES_ALIGN); q->ctx_save_restore_size = q->ctl_stack_size - + PAGE_ALIGN_UP(wg_data_size + q->debug_memory_size); + + PAGE_ALIGN_UP(wg_data_size); return true; } return false; @@ -423,14 +423,21 @@ static int handle_concrete_asic(struct queue *q, ret = update_ctx_save_restore_size(NodeId, q); if (ret) { + uint32_t total_mem_alloc_size = 0; HsaUserContextSaveAreaHeader *header; args->ctx_save_restore_size = q->ctx_save_restore_size; args->ctl_stack_size = q->ctl_stack_size; + + /* Total memory to be allocated is = + * (Control Stack size + WG size) + Debug memory area size + */ + total_mem_alloc_size = q->ctx_save_restore_size + + q->debug_memory_size; q->ctx_save_restore = - allocate_exec_aligned_memory(q->ctx_save_restore_size, - q->use_ats, - NodeId, false, false); + allocate_exec_aligned_memory(total_mem_alloc_size, + q->use_ats, NodeId, false, false); + if (!q->ctx_save_restore) return HSAKMT_STATUS_NO_MEMORY; @@ -441,7 +448,7 @@ static int handle_concrete_asic(struct queue *q, if (Event) header->ErrorEventId = Event->EventId; header->ErrorReason = ErrPayload; - header->DebugOffset = q->ctx_save_restore_size - q->debug_memory_size; + header->DebugOffset = q->ctx_save_restore_size; header->DebugSize = q->debug_memory_size; }