]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: Add smu vram copy function
authorLijo Lazar <lijo.lazar@amd.com>
Fri, 27 Mar 2026 07:43:00 +0000 (13:13 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 3 Apr 2026 17:51:54 +0000 (13:51 -0400)
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>
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h

index 7bd8c435466a12cca5fe5527e4f74b18a0d3a966..006ef585a377fe626ba13cf99d298cd33e69abfc 100644 (file)
@@ -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;
index b76e86df5da78db7bccb0fce965e57efc0fa97ea..d129907535bd06ca5bd0efc57a885164cfffe425 100644 (file)
@@ -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);