AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lang Yu <Lang.Yu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Christian Koenig <christian.koenig@amd.com>,
	Lang Yu <Lang.Yu@amd.com>
Subject: [PATCH] drm/amdgpu: add post reset IP callback
Date: Thu, 28 Mar 2024 12:40:14 +0800	[thread overview]
Message-ID: <20240328044014.3278891-1-Lang.Yu@amd.com> (raw)

There are use cases which need full GPU functionality
(e.g., VM update, TLB inavildate) when doing a GPU reset.

Especially, the mes/umsch self tests which help validate
the hw state after hw init like ring/ib tests.

Add a post reset IP callback to handle such use cases
which will be executed after GPU reset succeeds.

Signed-off-by: Lang Yu <Lang.Yu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++++++++++++++++++++++
 drivers/gpu/drm/amd/include/amd_shared.h   |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 12dc71a6b5db..feeab9397aab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5556,6 +5556,27 @@ static int amdgpu_device_health_check(struct list_head *device_list_handle)
 	return ret;
 }
 
+static int amdgpu_device_ip_post_reset(struct amdgpu_device *adev)
+{
+	uint32_t i;
+	int r;
+
+	for (i = 0; i < adev->num_ip_blocks; i++) {
+		if (!adev->ip_blocks[i].status.valid ||
+		    !adev->ip_blocks[i].version->funcs->post_reset)
+			continue;
+
+		r = adev->ip_blocks[i].version->funcs->post_reset(adev);
+		if (r) {
+			DRM_ERROR("post reset of IP block <%s> failed %d\n",
+				  adev->ip_blocks[i].version->funcs->name, r);
+			return r;
+		}
+	}
+
+	return r;
+}
+
 /**
  * amdgpu_device_gpu_recover - reset the asic and recover scheduler
  *
@@ -5805,6 +5826,9 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 		amdgpu_put_xgmi_hive(hive);
 	}
 
+	if (!r && !job_signaled)
+		r = amdgpu_device_ip_post_reset(adev);
+
 	if (r)
 		dev_info(adev->dev, "GPU reset end with ret = %d\n", r);
 
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index b0a6256e89f4..33ce30a8e3ab 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -287,6 +287,7 @@ enum amd_dpm_forced_level;
  * @pre_soft_reset: pre soft reset the IP block
  * @soft_reset: soft reset the IP block
  * @post_soft_reset: post soft reset the IP block
+ * @post_reset: handles IP specific post reset stuff(e.g., self test)
  * @set_clockgating_state: enable/disable cg for the IP block
  * @set_powergating_state: enable/disable pg for the IP block
  * @get_clockgating_state: get current clockgating status
@@ -316,11 +317,13 @@ struct amd_ip_funcs {
 	int (*pre_soft_reset)(void *handle);
 	int (*soft_reset)(void *handle);
 	int (*post_soft_reset)(void *handle);
+	int (*post_reset)(void *handle);
 	int (*set_clockgating_state)(void *handle,
 				     enum amd_clockgating_state state);
 	int (*set_powergating_state)(void *handle,
 				     enum amd_powergating_state state);
 	void (*get_clockgating_state)(void *handle, u64 *flags);
+
 };
 
 
-- 
2.25.1


             reply	other threads:[~2024-03-28  4:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  4:40 Lang Yu [this message]
2024-04-02 13:38 ` [PATCH] drm/amdgpu: add post reset IP callback Christian König
2024-04-03  6:51   ` Yu, Lang
2024-04-03  7:18     ` Sharma, Shashank
2024-04-03  7:31       ` Yu, Lang
2024-04-03  8:44         ` Sharma, Shashank
2024-04-03  9:40     ` Christian König

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=20240328044014.3278891-1-Lang.Yu@amd.com \
    --to=lang.yu@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@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