AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Zhu <James.Zhu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Felix.kuehling@amd.com, jamesz@amd.com
Subject: [PATCH v3 2/5] drm/amdkfd: add event_age tracking when receiving interrupt
Date: Thu, 8 Jun 2023 13:07:02 -0400	[thread overview]
Message-ID: <20230608170705.2271276-3-James.Zhu@amd.com> (raw)
In-Reply-To: <20230608170705.2271276-1-James.Zhu@amd.com>

Add event_age tracking when receiving interrupt.

Signed-off-by: James Zhu <James.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 6 ++++++
 drivers/gpu/drm/amd/amdkfd/kfd_events.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
index 7ff5c4e1b7e2..c7689181cc22 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
@@ -431,6 +431,7 @@ int kfd_event_create(struct file *devkfd, struct kfd_process *p,
 	if (!ret) {
 		*event_id = ev->event_id;
 		*event_trigger_data = ev->event_id;
+		ev->event_age = 1;
 	} else {
 		kfree(ev);
 	}
@@ -629,6 +630,11 @@ static void set_event(struct kfd_event *ev)
 	 * updating the wait queues in kfd_wait_on_events.
 	 */
 	ev->signaled = !ev->auto_reset || !waitqueue_active(&ev->wq);
+	if (!(++ev->event_age)) {
+		/* Never wrap back to reserved/default event age 0/1 */
+		ev->event_age = 2;
+		WARN_ONCE(1, "event_age wrap back!");
+	}
 
 	list_for_each_entry(waiter, &ev->wq.head, wait.entry)
 		WRITE_ONCE(waiter->activated, true);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.h b/drivers/gpu/drm/amd/amdkfd/kfd_events.h
index 1c62c8dd6460..52ccfd397c2b 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.h
@@ -53,6 +53,7 @@ struct signal_page;
 
 struct kfd_event {
 	u32 event_id;
+	u64 event_age;
 
 	bool signaled;
 	bool auto_reset;
-- 
2.34.1


  parent reply	other threads:[~2023-06-08 17:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 17:07 [PATCH v3 0/5] new event wait support James Zhu
2023-06-08 17:07 ` [PATCH v3 1/5] drm/amdkfd: add event age tracking James Zhu
2023-06-08 17:07 ` James Zhu [this message]
2023-06-08 17:07 ` [PATCH v3 3/5] drm/amdkfd: set activated flag true when event age unmatchs James Zhu
2023-06-09 19:43   ` Felix Kuehling
2023-06-09 19:47     ` James Zhu
2023-06-09 20:13   ` [PATCH v4 " James Zhu
2023-06-09 20:22     ` Felix Kuehling
2023-06-09 20:27       ` James Zhu
2023-06-09 20:43   ` [PATCH v5 " James Zhu
2023-06-09 22:44     ` Felix Kuehling
2023-06-12 16:19       ` Yat Sin, David
2023-06-12 16:31         ` Felix Kuehling
2023-06-08 17:07 ` [PATCH v3 4/5] drm/amdkfd: update user space last_event_age James Zhu
2023-06-08 17:07 ` [PATCH v3 5/5] drm/amdkfd: bump kfd ioctl minor version for event age availability James Zhu

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=20230608170705.2271276-3-James.Zhu@amd.com \
    --to=james.zhu@amd.com \
    --cc=Felix.kuehling@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=jamesz@amd.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox