From fe03b35c8eb9f9bd449fbdc24a5e3e18715f72a4 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Mon, 10 May 2021 11:56:06 -0400 Subject: [PATCH] libhsakmt: update create queue for exception handling Update hsaKmtCreateQueue to initialize the new save area header with the exception payload and event ID. Signed-by-off: Jonathan Kim Reviewed-by: Felix Kuehling Reviewed-by: Sean Keely Change-Id: Icd38062dc982cb29b30644699014eeb0b3e26d00 [ROCm/ROCR-Runtime commit: 96c7a5c9dcd80155edf2e9f908b082e74a1c6915] --- projects/rocr-runtime/include/hsakmttypes.h | 7 +++++++ projects/rocr-runtime/src/queues.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/projects/rocr-runtime/include/hsakmttypes.h b/projects/rocr-runtime/include/hsakmttypes.h index c96fd839f0..a8a396946a 100644 --- a/projects/rocr-runtime/include/hsakmttypes.h +++ b/projects/rocr-runtime/include/hsakmttypes.h @@ -689,6 +689,12 @@ typedef struct // debugger. Must be 64 byte aligned. HSAuint32 DebugSize; // Byte size of the memory reserved for the // debugger. Must be 64 byte aligned. + volatile HSAint64 *ErrorReason; // Address of the HSA signal payload for + // reporting the error reason bitmask. + // Must be 4 byte aligned. + HSAuint32 ErrorEventId; // Event ID used for exception signalling. + // Must be 4 byte aligned. + HSAuint32 Reserved1; } HsaUserContextSaveAreaHeader; @@ -738,6 +744,7 @@ typedef struct _HsaQueueResource HSAuint64 QueueRptrValue; }; + volatile HSAint64* ErrorReason; /** exception bits signal payload */ } HsaQueueResource; diff --git a/projects/rocr-runtime/src/queues.c b/projects/rocr-runtime/src/queues.c index de408903a5..e667f1a1ce 100644 --- a/projects/rocr-runtime/src/queues.c +++ b/projects/rocr-runtime/src/queues.c @@ -588,7 +588,9 @@ static void free_queue(struct queue *q) static int handle_concrete_asic(struct queue *q, struct kfd_ioctl_create_queue_args *args, - uint32_t NodeId) + uint32_t NodeId, + HsaEvent *Event, + volatile HSAint64 *ErrPayload) { const struct device_info *dev_info = q->dev_info; bool ret; @@ -626,6 +628,10 @@ static int handle_concrete_asic(struct queue *q, args->ctx_save_restore_address = (uintptr_t)q->ctx_save_restore; header = (HsaUserContextSaveAreaHeader *)q->ctx_save_restore; + header->ErrorEventId = 0; + if (Event) + header->ErrorEventId = Event->EventId; + header->ErrorReason = ErrPayload; header->DebugOffset = q->ctx_save_restore_size - q->debug_memory_size; header->DebugSize = q->debug_memory_size; } @@ -724,7 +730,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtCreateQueue(HSAuint32 NodeId, QueueResource->QueueWptrValue = (uintptr_t)&q->wptr; } - err = handle_concrete_asic(q, &args, NodeId); + err = handle_concrete_asic(q, &args, NodeId, Event, QueueResource->ErrorReason); if (err != HSAKMT_STATUS_SUCCESS) { free_queue(q); return err;