]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: Update message IDs to PMFW to correctly gather GFXOFF residency logs
authorFares Soliman <Fares.Soliman@amd.com>
Mon, 13 Jul 2026 13:18:41 +0000 (09:18 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Jul 2026 23:59:22 +0000 (19:59 -0400)
Updates PPSMC_MSGs and set/get functions for gathering GFXOFF logs
on Van Gogh. Logs are now gathered live rather than starting then
stopping logging and reading an average value afterwards. This is
in accordance to changes made in PMFW.

In regards to messageID 0x52, the old interface uses a start/stop
parameter, and the new one doesn't. The firmware is checked to
determine which method to use.

v2: added firmware guard to new interface, old interface kept as
fallback

Signed-off-by: Fares Soliman <Fares.Soliman@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 482e2cadea8c34ae4e733f269a640d6b04fc9262)

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c

index 389bad7242731188ea05b2df4685636914299b3f..662ec01961f47fe3cc445cca22071df5bf23f65f 100644 (file)
@@ -1319,8 +1319,8 @@ err:
  * @size: Number of bytes to read
  * @pos:  Offset to seek to
  *
- * Read the last residency value logged. It doesn't auto update, one needs to
- * stop logging before getting the current value.
+ * Read a live GFXOFF residency sample from firmware. One needs to start logging
+ * before getting the current value.
  */
 static ssize_t amdgpu_debugfs_gfxoff_residency_read(struct file *f, char __user *buf,
                                                    size_t size, loff_t *pos)
index e3a89e9a9df4168f1c6609e411ba9ecc260fd956..64a64973fb86e73d66a02640a8e4c721e179bc95 100644 (file)
@@ -1348,7 +1348,7 @@ struct pptable_funcs {
        u32 (*set_gfx_off_residency)(struct smu_context *smu, bool start);
 
        /**
-        * @get_gfx_off_residency: Average GFXOFF residency % during the logging interval
+        * @get_gfx_off_residency: Live GFXOFF residency percentage
         */
        u32 (*get_gfx_off_residency)(struct smu_context *smu, uint32_t *residency);
 
index 7471e2df2828538faa2dccde8152bb4333f04713..4206514765cdac4e4fd4c6adfb676cc49421b6a0 100644 (file)
 #define PPSMC_MSG_GetSlowPPTLimit                      0x4C
 #define PPSMC_MSG_GetGfxOffStatus                     0x50
 #define PPSMC_MSG_GetGfxOffEntryCount                 0x51
-#define PPSMC_MSG_LogGfxOffResidency                  0x52
-#define PPSMC_Message_Count                            0x53
+#define PPSMC_MSG_GfxOffResidencyLogReadSample        0x52
+#define PPSMC_MSG_StopGfxOffResidencyLogging            0x53
+#define PPSMC_MSG_StartGfxOffResidencyLogging           0x56
+#define PPSMC_Message_Count                            0x57
 
 //Argument for PPSMC_MSG_GfxDeviceDriverReset
 enum {
index 636ff90923d98d0e8649d280340323621aae1a64..acf03838d49d56326a3740f78c3a32902a537a92 100644 (file)
        __SMU_DUMMY_MAP(DriverMode2Reset), \
        __SMU_DUMMY_MAP(GetGfxOffStatus),                \
        __SMU_DUMMY_MAP(GetGfxOffEntryCount),            \
-       __SMU_DUMMY_MAP(LogGfxOffResidency),                    \
+       __SMU_DUMMY_MAP(StartGfxOffResidencyLogging),           \
+       __SMU_DUMMY_MAP(GfxOffResidencyLogReadSample),          \
+       __SMU_DUMMY_MAP(StopGfxOffResidencyLogging),            \
        __SMU_DUMMY_MAP(SetNumBadMemoryPagesRetired),           \
        __SMU_DUMMY_MAP(SetBadMemoryPagesRetiredFlagsPerChannel), \
        __SMU_DUMMY_MAP(AllowGpo),      \
index 016a5c893fee56c64c106167c463251d10fa629d..c54675b00a96869be667306dfd00c67d5207fe40 100644 (file)
@@ -72,6 +72,12 @@ static const struct smu_feature_bits vangogh_dpm_features = {
        }
 };
 
+/*
+ * SMU support new GFXOFF residency log interface since version 4.63.62.00,
+ * use this to get live readings of GFXOFF residency
+ */
+#define SUPPORT_LIVE_RESIDENCY_MSG_VERSION 0x043f3e00
+
 static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {
        MSG_MAP(TestMessage,                    PPSMC_MSG_TestMessage,                  0),
        MSG_MAP(GetSmuVersion,                  PPSMC_MSG_GetSmuVersion,                0),
@@ -142,7 +148,9 @@ static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {
        MSG_MAP(GetSlowPPTLimit,                    PPSMC_MSG_GetSlowPPTLimit,                                          0),
        MSG_MAP(GetGfxOffStatus,                    PPSMC_MSG_GetGfxOffStatus,                                          0),
        MSG_MAP(GetGfxOffEntryCount,                PPSMC_MSG_GetGfxOffEntryCount,                                      0),
-       MSG_MAP(LogGfxOffResidency,                 PPSMC_MSG_LogGfxOffResidency,                                       0),
+       MSG_MAP(StartGfxOffResidencyLogging,  PPSMC_MSG_StartGfxOffResidencyLogging,    0),
+       MSG_MAP(GfxOffResidencyLogReadSample, PPSMC_MSG_GfxOffResidencyLogReadSample,   0),
+       MSG_MAP(StopGfxOffResidencyLogging,   PPSMC_MSG_StopGfxOffResidencyLogging,             0),
 };
 
 static struct cmn2asic_mapping vangogh_feature_mask_map[SMU_FEATURE_COUNT] = {
@@ -2449,19 +2457,32 @@ static int vangogh_set_power_limit(struct smu_context *smu,
 static u32 vangogh_set_gfxoff_residency(struct smu_context *smu, bool start)
 {
        int ret = 0;
-       u32 residency;
        struct amdgpu_device *adev = smu->adev;
 
        if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
                return 0;
 
-       ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_LogGfxOffResidency,
-                                             start, &residency);
-       if (ret)
-               return ret;
+       if (smu->smc_fw_version < SUPPORT_LIVE_RESIDENCY_MSG_VERSION) {
+               u32 residency;
+
+               ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxOffResidencyLogReadSample,
+                                                       start, &residency);
+               if (ret)
+                       return ret;
 
-       if (!start)
-               adev->gfx.gfx_off_residency = residency;
+               if (!start)
+                       adev->gfx.gfx_off_residency = residency;
+       } else {
+               if (start) {
+                       ret = smu_cmn_send_smc_msg(smu, SMU_MSG_StartGfxOffResidencyLogging, NULL);
+                       if (ret)
+                               return ret;
+               } else {
+                       ret = smu_cmn_send_smc_msg(smu, SMU_MSG_StopGfxOffResidencyLogging, NULL);
+                       if (ret)
+                               return ret;
+               }
+       }
 
        return ret;
 }
@@ -2478,11 +2499,20 @@ static u32 vangogh_set_gfxoff_residency(struct smu_context *smu, bool start)
  */
 static u32 vangogh_get_gfxoff_residency(struct smu_context *smu, uint32_t *residency)
 {
+       int ret = 0;
        struct amdgpu_device *adev = smu->adev;
 
-       *residency = adev->gfx.gfx_off_residency;
+       if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
+               return 0;
+
+       if (smu->smc_fw_version < SUPPORT_LIVE_RESIDENCY_MSG_VERSION) {
+               *residency = adev->gfx.gfx_off_residency;
+       } else {
+               ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GfxOffResidencyLogReadSample,
+                                                               residency);
+       }
 
-       return 0;
+       return ret;
 }
 
 /**