All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Kim <jonathan.kim@amd.com>
To: <amd-gfx@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <Felix.Kuehling@amd.com>
Cc: Jinhuieric.Huang@amd.com
Subject: [PATCH 29/33] drm/amdkfd: add debug query event operation
Date: Thu, 25 May 2023 13:27:41 -0400	[thread overview]
Message-ID: <20230525172745.702700-29-jonathan.kim@amd.com> (raw)
In-Reply-To: <20230525172745.702700-1-jonathan.kim@amd.com>

Allow the debugger to query a single queue, device and process
exception.
The KFD should also return the GPU or Queue id of the exception.
The debugger also has the option of clearing exceptions after
being queried.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c |  6 +++
 drivers/gpu/drm/amd/amdkfd/kfd_debug.c   | 64 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdkfd/kfd_debug.h   |  5 ++
 3 files changed, 75 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index e5d95b144dcd..ebb2088d12fa 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -3038,6 +3038,12 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v
 		r = kfd_dbg_trap_set_flags(target, &args->set_flags.flags);
 		break;
 	case KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT:
+		r = kfd_dbg_ev_query_debug_event(target,
+				&args->query_debug_event.queue_id,
+				&args->query_debug_event.gpu_id,
+				args->query_debug_event.exception_mask,
+				&args->query_debug_event.exception_mask);
+		break;
 	case KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO:
 	case KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT:
 	case KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT:
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debug.c b/drivers/gpu/drm/amd/amdkfd/kfd_debug.c
index 43c3170998d3..e9530e682e85 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_debug.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_debug.c
@@ -27,6 +27,70 @@
 
 #define MAX_WATCH_ADDRESSES	4
 
+int kfd_dbg_ev_query_debug_event(struct kfd_process *process,
+		      unsigned int *queue_id,
+		      unsigned int *gpu_id,
+		      uint64_t exception_clear_mask,
+		      uint64_t *event_status)
+{
+	struct process_queue_manager *pqm;
+	struct process_queue_node *pqn;
+	int i;
+
+	if (!(process && process->debug_trap_enabled))
+		return -ENODATA;
+
+	mutex_lock(&process->event_mutex);
+	*event_status = 0;
+	*queue_id = 0;
+	*gpu_id = 0;
+
+	/* find and report queue events */
+	pqm = &process->pqm;
+	list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
+		uint64_t tmp = process->exception_enable_mask;
+
+		if (!pqn->q)
+			continue;
+
+		tmp &= pqn->q->properties.exception_status;
+
+		if (!tmp)
+			continue;
+
+		*event_status = pqn->q->properties.exception_status;
+		*queue_id = pqn->q->properties.queue_id;
+		*gpu_id = pqn->q->device->id;
+		pqn->q->properties.exception_status &= ~exception_clear_mask;
+		goto out;
+	}
+
+	/* find and report device events */
+	for (i = 0; i < process->n_pdds; i++) {
+		struct kfd_process_device *pdd = process->pdds[i];
+		uint64_t tmp = process->exception_enable_mask
+						& pdd->exception_status;
+
+		if (!tmp)
+			continue;
+
+		*event_status = pdd->exception_status;
+		*gpu_id = pdd->dev->id;
+		pdd->exception_status &= ~exception_clear_mask;
+		goto out;
+	}
+
+	/* report process events */
+	if (process->exception_enable_mask & process->exception_status) {
+		*event_status = process->exception_status;
+		process->exception_status &= ~exception_clear_mask;
+	}
+
+out:
+	mutex_unlock(&process->event_mutex);
+	return *event_status ? 0 : -EAGAIN;
+}
+
 void debug_event_write_work_handler(struct work_struct *work)
 {
 	struct kfd_process *process;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debug.h b/drivers/gpu/drm/amd/amdkfd/kfd_debug.h
index ef8e9f7f1716..e78f954c0684 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_debug.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_debug.h
@@ -27,6 +27,11 @@
 
 void kfd_dbg_trap_deactivate(struct kfd_process *target, bool unwind, int unwind_count);
 int kfd_dbg_trap_activate(struct kfd_process *target);
+int kfd_dbg_ev_query_debug_event(struct kfd_process *process,
+			unsigned int *queue_id,
+			unsigned int *gpu_id,
+			uint64_t exception_clear_mask,
+			uint64_t *event_status);
 bool kfd_set_dbg_ev_from_interrupt(struct kfd_node *dev,
 				   unsigned int pasid,
 				   uint32_t doorbell_id,
-- 
2.25.1


  parent reply	other threads:[~2023-05-25 17:28 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 17:27 [PATCH 01/33] drm/amdkfd: add debug and runtime enable interface Jonathan Kim
2023-05-25 17:27 ` [PATCH 02/33] drm/amdkfd: display debug capabilities Jonathan Kim
2023-05-30 19:20   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 03/33] drm/amdkfd: prepare per-process debug enable and disable Jonathan Kim
2023-05-25 17:27 ` [PATCH 04/33] drm/amdgpu: add kgd hw debug mode setting interface Jonathan Kim
2023-05-25 17:27 ` [PATCH 05/33] drm/amdgpu: setup hw debug registers on driver initialization Jonathan Kim
2023-05-30 19:23   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 06/33] drm/amdgpu: add gfx9 hw debug mode enable and disable calls Jonathan Kim
2023-05-25 17:27 ` [PATCH 07/33] drm/amdgpu: add gfx9.4.1 " Jonathan Kim
2023-05-25 17:27 ` [PATCH 08/33] drm/amdkfd: fix kfd_suspend_all_processes Jonathan Kim
2023-05-25 17:27 ` [PATCH 09/33] drm/amdgpu: add gfx10 hw debug mode enable and disable calls Jonathan Kim
2023-05-25 17:27 ` [PATCH 10/33] drm/amdgpu: add gfx9.4.2 " Jonathan Kim
2023-05-25 17:27 ` [PATCH 11/33] drm/amdgpu: add gfx11 " Jonathan Kim
2023-05-25 17:27 ` [PATCH 12/33] drm/amdgpu: add configurable grace period for unmap queues Jonathan Kim
2023-05-30 19:28   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 13/33] drm/amdkfd: prepare map process for single process debug devices Jonathan Kim
2023-05-30 19:36   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 14/33] drm/amdgpu: prepare map process for multi-process " Jonathan Kim
2023-05-30 19:55   ` Felix Kuehling
2023-05-30 19:58     ` Kim, Jonathan
2023-05-25 17:27 ` [PATCH 15/33] drm/amdgpu: expose debug api for mes Jonathan Kim
2023-05-25 17:27 ` [PATCH 16/33] drm/amdkfd: add per process hw trap enable and disable functions Jonathan Kim
2023-05-30 20:04   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 17/33] drm/amdkfd: apply trap workaround for gfx11 Jonathan Kim
2023-05-25 17:27 ` [PATCH 18/33] drm/amdkfd: add raise exception event function Jonathan Kim
2023-05-30 20:07   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 19/33] drm/amdkfd: add send exception operation Jonathan Kim
2023-05-25 17:27 ` [PATCH 20/33] drm/amdkfd: add runtime enable operation Jonathan Kim
2023-05-30 20:11   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 21/33] drm/amdkfd: add debug trap enabled flag to tma Jonathan Kim
2023-05-25 17:27 ` [PATCH 22/33] drm/amdkfd: update process interrupt handling for debug events Jonathan Kim
2023-05-30 20:16   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 23/33] drm/amdkfd: add debug set exceptions enabled operation Jonathan Kim
2023-05-25 17:27 ` [PATCH 24/33] drm/amdkfd: add debug wave launch override operation Jonathan Kim
2023-05-30 20:21   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 25/33] drm/amdkfd: add debug wave launch mode operation Jonathan Kim
2023-05-30 20:22   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 26/33] drm/amdkfd: add debug suspend and resume process queues operation Jonathan Kim
2023-05-30 20:24   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 27/33] drm/amdkfd: add debug set and clear address watch points operation Jonathan Kim
2023-05-30 20:26   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 28/33] drm/amdkfd: add debug set flags operation Jonathan Kim
2023-05-30 20:30   ` Felix Kuehling
2023-05-25 17:27 ` Jonathan Kim [this message]
2023-05-25 17:27 ` [PATCH 30/33] drm/amdkfd: add debug query exception info operation Jonathan Kim
2023-05-25 17:27 ` [PATCH 31/33] drm/amdkfd: add debug queue snapshot operation Jonathan Kim
2023-05-25 17:27 ` [PATCH 32/33] drm/amdkfd: add debug device " Jonathan Kim
2023-05-30 20:31   ` Felix Kuehling
2023-05-25 17:27 ` [PATCH 33/33] drm/amdkfd: bump kfd ioctl minor version for debug api availability Jonathan Kim
2023-05-30 19:17 ` [PATCH 01/33] drm/amdkfd: add debug and runtime enable interface Felix Kuehling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230525172745.702700-29-jonathan.kim@amd.com \
    --to=jonathan.kim@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Jinhuieric.Huang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.