summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLijo Lazar <lijo.lazar@amd.com>2026-03-27 10:43:00 +0300
committerAlex Deucher <alexander.deucher@amd.com>2026-04-03 20:51:54 +0300
commitf2275ea90be581f599e7c88a9dbfc5dd4383087d (patch)
treec7a1b3aac6e1f86711e7dd462fee18be7541474f
parent1d0a26cf37c1b2e9928d2b61af6f282232b5daea (diff)
downloadlinux-f2275ea90be581f599e7c88a9dbfc5dd4383087d.tar.xz
drm/amd/pm: Add smu vram copy function
Add a wrapper function for copying data/to from vram. This additionally checks for any RAS fatal error. Copy cannot be trusted if any RAS fatal error happened as VRAM becomes inaccessible. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Asad Kamal <asad.kamal@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c12
-rw-r--r--drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
index 7bd8c435466a..006ef585a377 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
@@ -1104,6 +1104,18 @@ int smu_cmn_update_table(struct smu_context *smu,
return 0;
}
+int smu_cmn_vram_cpy(struct smu_context *smu, void *dst, const void *src,
+ size_t len)
+{
+ memcpy(dst, src, len);
+
+ /* Don't trust the copy operation if RAS fatal error happened. */
+ if (amdgpu_ras_get_fed_status(smu->adev))
+ return -EHWPOISON;
+
+ return 0;
+}
+
int smu_cmn_write_watermarks_table(struct smu_context *smu)
{
void *watermarks_table = smu->smu_table.watermarks_table;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
index b76e86df5da7..d129907535bd 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
@@ -174,6 +174,9 @@ int smu_cmn_update_table(struct smu_context *smu,
void *table_data,
bool drv2smu);
+int smu_cmn_vram_cpy(struct smu_context *smu, void *dst,
+ const void *src, size_t len);
+
int smu_cmn_write_watermarks_table(struct smu_context *smu);
int smu_cmn_write_pptable(struct smu_context *smu);