]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: zero unused SMU argument registers
authorYang Wang <kevinyang.wang@amd.com>
Mon, 11 May 2026 08:33:37 +0000 (16:33 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 3 Jun 2026 18:51:59 +0000 (14:51 -0400)
SMU messages may use fewer arguments than the available argument registers,
the previous code only wrote used registers and left the rest unchanged,
so stale values from a prior message could persist.

Write all argument registers for each message and zero the unused tail
to keep command arguments deterministic and avoid unintended carry-over.

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit e03b635f61f77ebd5107ef82f48e3221cb695856)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c

index 90c7127beabffc46dbefc3c80ad4db01b44e15a4..fe97fda8bfe93e2fbe987ebecaba40e35c92ceab 100644 (file)
@@ -272,11 +272,15 @@ static void __smu_msg_v1_send(struct smu_msg_ctl *ctl, u16 index,
 {
        struct amdgpu_device *adev = ctl->smu->adev;
        struct smu_msg_config *cfg = &ctl->config;
+       u32 arg;
        int i;
 
        WREG32(cfg->resp_reg, 0);
-       for (i = 0; i < args->num_args; i++)
-               WREG32(cfg->arg_regs[i], args->args[i]);
+       for (i = 0; i < cfg->num_arg_regs; i++) {
+               /* NOTE: Clear unused argument registers to avoid stale values. */
+               arg = i < args->num_args ? args->args[i] : 0;
+               WREG32(cfg->arg_regs[i], arg);
+       }
        WREG32(cfg->msg_reg, index);
 }