From: YiPeng Chai <YiPeng.Chai@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <Hawking.Zhang@amd.com>, <Tao.Zhou1@amd.com>,
<Candice.Li@amd.com>, <KevinYang.Wang@amd.com>,
<Stanley.Yang@amd.com>, YiPeng Chai <YiPeng.Chai@amd.com>
Subject: [PATCH 3/5] drm/amdgpu: clear all messages reset flags in fifo before gpu reset
Date: Thu, 13 Jun 2024 10:25:02 +0800 [thread overview]
Message-ID: <20240613022504.81787-3-YiPeng.Chai@amd.com> (raw)
In-Reply-To: <20240613022504.81787-1-YiPeng.Chai@amd.com>
To avoid resetting the gpu repeatedly, clear all
message reset flags in the fifo before the first
gpu reset.
Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 59 ++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 1e6e06009577..7dfb2e548d70 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -2768,6 +2768,49 @@ static int amdgpu_ras_get_poison_req(struct amdgpu_device *adev,
return kfifo_get(&con->poison_fifo, poison_msg);
}
+
+static void amdgpu_ras_clear_poison_fifo_msg_reset_flag(struct amdgpu_device *adev,
+ uint32_t *cached_reset)
+{
+ struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+ struct ras_poison_msg msg;
+ uint32_t cached_msg_count;
+ uint32_t reset = 0;
+ int i, ret;
+
+ cached_msg_count = kfifo_len(&con->poison_fifo);
+
+ for (i = 0; i < cached_msg_count; i++) {
+ ret = kfifo_get(&con->poison_fifo, &msg);
+ if (!ret)
+ continue;
+
+ if (msg.block != AMDGPU_RAS_BLOCK__UMC) {
+ reset |= msg.reset;
+
+ /* Clear reset flag */
+ msg.reset = 0;
+ }
+
+ /* add message back to fifo */
+ ret = kfifo_put(&con->poison_fifo, msg);
+ if (!ret)
+ dev_info(adev->dev, "Poison fifo drop message!\n");
+ }
+ *cached_reset = reset;
+}
+
+static void amdgpu_ras_clear_poison_fifo(struct amdgpu_device *adev)
+{
+ struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
+ struct ras_poison_msg msg;
+ int ret;
+
+ do {
+ ret = kfifo_get(&con->poison_fifo, &msg);
+ } while (ret);
+
+}
#endif
#ifdef HAVE_RADIX_TREE_ITER_DELETE
@@ -2886,9 +2929,23 @@ static int amdgpu_ras_poison_consumption_handler(struct amdgpu_device *adev,
poison_msg->pasid_fn(adev, pasid, poison_msg->data);
if (reset) {
+ uint32_t fifo_cached_reset = 0;
+
flush_delayed_work(&con->page_retirement_dwork);
- con->gpu_reset_flags |= reset;
+ amdgpu_ras_clear_poison_fifo_msg_reset_flag(adev, &fifo_cached_reset);
+
+ reset |= fifo_cached_reset;
+
+ if (reset & AMDGPU_RAS_GPU_RESET_MODE1_RESET) {
+ con->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
+ amdgpu_ras_clear_poison_fifo(adev);
+ } else if (reset & AMDGPU_RAS_GPU_RESET_MODE2_RESET) {
+ con->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE2_RESET;
+ } else {
+ con->gpu_reset_flags |= reset;
+ }
+
amdgpu_ras_reset_gpu(adev);
}
--
2.34.1
next prev parent reply other threads:[~2024-06-13 2:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 2:25 [PATCH 1/5] drm/amdgpu: add condition check for waking up thread YiPeng Chai
2024-06-13 2:25 ` [PATCH 2/5] drm/amdgpu: add threshold to interrupt waiting for DE data to be ready YiPeng Chai
2024-06-13 2:25 ` YiPeng Chai [this message]
2024-06-13 2:25 ` [PATCH 4/5] drm/amdgpu: wait for gpu to complete reset YiPeng Chai
2024-06-13 10:19 ` Christian König
2024-06-13 2:25 ` [PATCH 5/5] drm/amdgpu: add gpu reset check before page retirement thread runs YiPeng Chai
2024-06-13 10:21 ` Christian König
2024-06-13 8:11 ` [PATCH 1/5] drm/amdgpu: add condition check for waking up thread Lazar, Lijo
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=20240613022504.81787-3-YiPeng.Chai@amd.com \
--to=yipeng.chai@amd.com \
--cc=Candice.Li@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=KevinYang.Wang@amd.com \
--cc=Stanley.Yang@amd.com \
--cc=Tao.Zhou1@amd.com \
--cc=amd-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox