drm/amd/powerplay: new interfaces for ActivityMonitor table with SMU
authorEvan Quan <evan.quan@amd.com>
Fri, 11 May 2018 02:56:25 +0000 (10:56 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 27 Aug 2018 16:10:27 +0000 (11:10 -0500)
Vega20 has a new activity monitor table that is stored in memory.  Add
API to get and set the new table.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c
drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.h

index 41a2a5df679b6a775ecb2e0a16b8e2038142d9b0..fe7f71079e0ecf830c647feedc36d5c5e72c2c68 100644 (file)
@@ -243,6 +243,63 @@ int vega20_copy_table_to_smc(struct pp_hwmgr *hwmgr,
        return 0;
 }
 
+int vega20_set_activity_monitor_coeff(struct pp_hwmgr *hwmgr,
+               uint8_t *table, uint16_t workload_type)
+{
+       struct vega20_smumgr *priv =
+                       (struct vega20_smumgr *)(hwmgr->smu_backend);
+       int ret = 0;
+
+       memcpy(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].table, table,
+                       priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].size);
+
+       PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
+                       PPSMC_MSG_SetDriverDramAddrHigh,
+                       upper_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
+                       "[SetActivityMonitor] Attempt to Set Dram Addr High Failed!",
+                       return ret);
+       PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
+                       PPSMC_MSG_SetDriverDramAddrLow,
+                       lower_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
+                       "[SetActivityMonitor] Attempt to Set Dram Addr Low Failed!",
+                       return ret);
+       PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
+                       PPSMC_MSG_TransferTableDram2Smu, TABLE_ACTIVITY_MONITOR_COEFF | (workload_type << 16))) == 0,
+                       "[SetActivityMonitor] Attempt to Transfer Table To SMU Failed!",
+                       return ret);
+
+       return 0;
+}
+
+int vega20_get_activity_monitor_coeff(struct pp_hwmgr *hwmgr,
+               uint8_t *table, uint16_t workload_type)
+{
+       struct vega20_smumgr *priv =
+                       (struct vega20_smumgr *)(hwmgr->smu_backend);
+       int ret = 0;
+
+       PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
+                       PPSMC_MSG_SetDriverDramAddrHigh,
+                       upper_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
+                       "[GetActivityMonitor] Attempt to Set Dram Addr High Failed!",
+                       return ret);
+       PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
+                       PPSMC_MSG_SetDriverDramAddrLow,
+                       lower_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
+                       "[GetActivityMonitor] Attempt to Set Dram Addr Low Failed!",
+                       return ret);
+       PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
+                       PPSMC_MSG_TransferTableSmu2Dram,
+                       TABLE_ACTIVITY_MONITOR_COEFF | (workload_type << 16))) == 0,
+                       "[GetActivityMonitor] Attempt to Transfer Table From SMU Failed!",
+                       return ret);
+
+       memcpy(table, priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].table,
+                       priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].size);
+
+       return 0;
+}
+
 int vega20_enable_smc_features(struct pp_hwmgr *hwmgr,
                bool enable, uint64_t feature_mask)
 {
index 71da82266e7f0660e81bd3705396178c8428218b..505eb0d82e3b3caee1eabe066dd3d2c470372a1e 100644 (file)
@@ -56,6 +56,10 @@ int vega20_enable_smc_features(struct pp_hwmgr *hwmgr,
                bool enable, uint64_t feature_mask);
 int vega20_get_enabled_smc_features(struct pp_hwmgr *hwmgr,
                uint64_t *features_enabled);
+int vega20_set_activity_monitor_coeff(struct pp_hwmgr *hwmgr,
+               uint8_t *table, uint16_t workload_type);
+int vega20_get_activity_monitor_coeff(struct pp_hwmgr *hwmgr,
+               uint8_t *table, uint16_t workload_type);
 
 #endif