From: Stanley.Yang <Stanley.Yang@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <Hawking.Zhang@amd.com>, <Tao.Zhou1@amd.com>,
<YiPeng.Chai@amd.com>, <Candice.Li@amd.com>, <Xiang.Liu@amd.com>,
<Ce.Sun@amd.com>, <Gangliang.Xie@amd.com>,
Stanley.Yang <Stanley.Yang@amd.com>
Subject: [PATCH Review 1/1] drm/amd/ras: Support invoke ras command
Date: Tue, 29 Sep 2026 11:55:24 +0800 [thread overview]
Message-ID: <20260929035524.229925-1-Stanley.Yang@amd.com> (raw)
Use uniras core to invoke ras command.
Signed-off-by: Stanley.Yang <Stanley.Yang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 17 ++++++
drivers/gpu/drm/amd/ras/core/ras_psp.c | 62 ++++++++++++++++++++++
drivers/gpu/drm/amd/ras/core/ras_psp.h | 3 ++
3 files changed, 82 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
index 8ae72c862d11..2d494ac57eb4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
@@ -23,6 +23,7 @@
#include "amdgpu.h"
#include "amdgpu_psp_ta.h"
+#include "amdgpu_ras_mgr.h"
#if defined(CONFIG_DEBUG_FS)
@@ -330,6 +331,22 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
if (IS_ERR(shared_buf))
return PTR_ERR(shared_buf);
+ if (ta_type == TA_TYPE_RAS && amdgpu_uniras_enabled(adev)) {
+ struct amdgpu_ras_mgr *ras_mgr = amdgpu_ras_mgr_get_context(adev);
+
+ if (!ras_mgr || !ras_mgr->ras_core) {
+ ret = -EINVAL;
+ goto free_shared_buf;
+ }
+
+ ret = ras_psp_invoke_ras_ta(ras_mgr->ras_core, ta_id, cmd_id,
+ shared_buf, shared_buf_len);
+ if (!ret && copy_to_user((char *)&buf[copy_pos], shared_buf, shared_buf_len))
+ ret = -EFAULT;
+
+ goto free_shared_buf;
+ }
+
set_ta_context_funcs(psp, ta_type, &context);
if (!context || !context->initialized) {
diff --git a/drivers/gpu/drm/amd/ras/core/ras_psp.c b/drivers/gpu/drm/amd/ras/core/ras_psp.c
index ed53cd25d6bd..a1f1b671300c 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_psp.c
+++ b/drivers/gpu/drm/amd/ras/core/ras_psp.c
@@ -785,6 +785,68 @@ int ras_psp_unsideload_ras_ta(struct ras_core_context *ras_core,
return unload_ras_ta_fw(ras_core, ras_ta_unload);
}
+int ras_psp_invoke_ras_ta(struct ras_core_context *ras_core,
+ uint32_t session_id, uint32_t cmd_id,
+ void *shared_buf, uint32_t shared_buf_len)
+{
+ struct ras_ta_ctx *ta_ctx = &ras_core->ras_psp.ta_ctx;
+ struct psp_gfx_cmd_invoke_cmd invoke_cmd = {0};
+ struct psp_cmd_resp resp = {0};
+ struct gpu_mem_block *cmd_mem;
+ int ret;
+
+ if (!shared_buf || !shared_buf_len)
+ return -EINVAL;
+
+ if (!ras_core_down_trylock_gpu_reset_lock(ras_core))
+ return -EACCES;
+
+ mutex_lock(&ta_ctx->ta_mutex);
+
+ if (!ta_ctx->ras_ta_initialized) {
+ RAS_DEV_ERR(ras_core->dev, "RAS TA is not initialized, cmd_id: %u\n", cmd_id);
+ ret = -EINVAL;
+ goto unlock;
+ }
+
+ cmd_mem = ta_ctx->cmd_gpu_mem;
+ if (!cmd_mem || !cmd_mem->mem_cpu_addr) {
+ ret = -ENOMEM;
+ goto unlock;
+ }
+
+ if (shared_buf_len > cmd_mem->mem_size) {
+ ret = -EINVAL;
+ goto unlock;
+ }
+
+ memset(cmd_mem->mem_cpu_addr, 0, cmd_mem->mem_size);
+ memcpy(cmd_mem->mem_cpu_addr, shared_buf, shared_buf_len);
+
+ invoke_cmd.ta_cmd_id = cmd_id;
+ invoke_cmd.session_id = session_id;
+ ret = send_psp_cmd(ras_core, GFX_CMD_ID_INVOKE_CMD,
+ &invoke_cmd, sizeof(invoke_cmd), &resp);
+ ta_ctx->resp_status = resp.status;
+ if (ret || resp.status) {
+ RAS_DEV_ERR(ras_core->dev,
+ "Failed to invoke RAS TA (%d) and status (0x%X)\n",
+ ret, resp.status);
+ if (!ret)
+ ret = -EINVAL;
+ goto unlock;
+ }
+
+ /* Return the complete TA response, including its status, to the caller. */
+ memcpy(shared_buf, cmd_mem->mem_cpu_addr, shared_buf_len);
+
+unlock:
+ mutex_unlock(&ta_ctx->ta_mutex);
+ ras_core_up_gpu_reset_lock(ras_core);
+
+ return ret;
+}
+
int ras_psp_reload_firmwares(struct ras_core_context *ras_core,
uint32_t flags)
{
diff --git a/drivers/gpu/drm/amd/ras/core/ras_psp.h b/drivers/gpu/drm/amd/ras/core/ras_psp.h
index 4cc133c6a6d3..91d17fdd6bda 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_psp.h
+++ b/drivers/gpu/drm/amd/ras/core/ras_psp.h
@@ -196,6 +196,9 @@ int ras_psp_sideload_ras_ta(struct ras_core_context *ras_core,
struct ras_psp_ta_load *ta_load);
int ras_psp_unsideload_ras_ta(struct ras_core_context *ras_core,
struct ras_psp_ta_unload *ras_ta_unload);
+int ras_psp_invoke_ras_ta(struct ras_core_context *ras_core,
+ uint32_t session_id, uint32_t cmd_id,
+ void *shared_buf, uint32_t shared_buf_len);
int ras_psp_enable_features(struct ras_core_context *ras_core,
struct ras_ta_enable_features_input *info, bool enable);
int ras_psp_trigger_error(struct ras_core_context *ras_core,
--
2.43.0
reply other threads:[~2026-09-29 3:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260929035524.229925-1-Stanley.Yang@amd.com \
--to=stanley.yang@amd.com \
--cc=Candice.Li@amd.com \
--cc=Ce.Sun@amd.com \
--cc=Gangliang.Xie@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Tao.Zhou1@amd.com \
--cc=Xiang.Liu@amd.com \
--cc=YiPeng.Chai@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