]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amd/pm: Add smu interface for temp metrics
authorAsad Kamal <asad.kamal@amd.com>
Fri, 1 Aug 2025 18:10:12 +0000 (02:10 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Aug 2025 18:20:44 +0000 (14:20 -0400)
Add smu interface to get baseboard/gpuboard temperature metrics

v2: Rename is_support to is_supported(Lijo)

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h

index b47cb4a5f4887d6d9bcf00abe3a08eb9ff792532..8b015107f761964a19836549b32008c673351e04 100644 (file)
@@ -3831,6 +3831,33 @@ int smu_set_pm_policy(struct smu_context *smu, enum pp_pm_policy p_type,
        return ret;
 }
 
+static ssize_t smu_sys_get_temp_metrics(void *handle, enum smu_temp_metric_type type, void *table)
+{
+       struct smu_context *smu = handle;
+
+       if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+               return -EOPNOTSUPP;
+
+       if (!smu->smu_temp.temp_funcs || !smu->smu_temp.temp_funcs->get_temp_metrics)
+               return -EOPNOTSUPP;
+
+       return smu->smu_temp.temp_funcs->get_temp_metrics(smu, type, table);
+}
+
+static bool smu_temp_metrics_is_supported(void *handle, enum smu_temp_metric_type type)
+{
+       struct smu_context *smu = handle;
+       bool ret = false;
+
+       if (!smu->pm_enabled)
+               return false;
+
+       if (smu->smu_temp.temp_funcs && smu->smu_temp.temp_funcs->temp_metrics_is_supported)
+               ret = smu->smu_temp.temp_funcs->temp_metrics_is_supported(smu, type);
+
+       return ret;
+}
+
 static ssize_t smu_sys_get_xcp_metrics(void *handle, int xcp_id, void *table)
 {
        struct smu_context *smu = handle;
@@ -3903,6 +3930,8 @@ static const struct amd_pm_funcs swsmu_pm_funcs = {
        .get_dpm_clock_table              = smu_get_dpm_clock_table,
        .get_smu_prv_buf_details = smu_get_prv_buffer_details,
        .get_xcp_metrics                  = smu_sys_get_xcp_metrics,
+       .get_temp_metrics             = smu_sys_get_temp_metrics,
+       .temp_metrics_is_supported      = smu_temp_metrics_is_supported,
 };
 
 int smu_wait_for_event(struct smu_context *smu, enum smu_event_type event,
index b52e194397e2e34506e25498658e369991237244..b490c39e313e9d678002aefb9afef46b38f22ed2 100644 (file)
@@ -396,6 +396,10 @@ struct smu_dpm_context {
        struct smu_dpm_policy_ctxt *dpm_policies;
 };
 
+struct smu_temp_context {
+       const struct smu_temp_funcs      *temp_funcs;
+};
+
 struct smu_power_gate {
        bool uvd_gated;
        bool vce_gated;
@@ -529,6 +533,7 @@ struct smu_context {
        struct smu_table_context        smu_table;
        struct smu_dpm_context          smu_dpm;
        struct smu_power_context        smu_power;
+       struct smu_temp_context         smu_temp;
        struct smu_feature              smu_feature;
        struct amd_pp_display_configuration  *display_config;
        struct smu_baco_context         smu_baco;
@@ -623,6 +628,28 @@ struct smu_context {
 
 struct i2c_adapter;
 
+/**
+ * struct smu_temp_funcs - Callbacks used to get temperature data.
+ */
+struct smu_temp_funcs {
+       /**
+        * @get_temp_metrics: Calibrate voltage/frequency curve to fit the system's
+        *           power delivery and voltage margins. Required for adaptive
+        * @type Temperature metrics type(baseboard/gpuboard)
+        * Return: Size of &table
+        */
+       ssize_t (*get_temp_metrics)(struct smu_context *smu,
+                                   enum smu_temp_metric_type type, void *table);
+
+       /**
+        * @temp_metrics_is_support: Get if specific temperature metrics is supported
+        * @type Temperature metrics type(baseboard/gpuboard)
+        * Return: true if supported else false
+        */
+       bool (*temp_metrics_is_supported)(struct smu_context *smu, enum smu_temp_metric_type type);
+
+};
+
 /**
  * struct pptable_funcs - Callbacks used to interact with the SMU.
  */