OSDN Git Service

drm/amd/pm: Add function to wait for smu events
authorLijo Lazar <lijo.lazar@amd.com>
Tue, 16 Mar 2021 11:34:38 +0000 (19:34 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Apr 2021 20:46:01 +0000 (16:46 -0400)
v1: Add function to wait for specific event/states from PMFW

v2: Add mutex lock, simplify sequence

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

index c823570..65672bb 100644 (file)
@@ -195,6 +195,11 @@ struct smu_user_dpm_profile {
        uint32_t clk_dependency;
 };
 
+enum smu_event_type {
+
+       SMU_EVENT_RESET_COMPLETE = 0,
+};
+
 #define SMU_TABLE_INIT(tables, table_id, s, a, d)      \
        do {                                            \
                tables[table_id].size = s;              \
@@ -338,7 +343,6 @@ struct smu_power_context {
        struct smu_power_gate power_gate;
 };
 
-
 #define SMU_FEATURE_MAX        (64)
 struct smu_feature
 {
@@ -1167,6 +1171,12 @@ struct pptable_funcs {
         * @set_light_sbr:  Set light sbr mode for the SMU.
         */
        int (*set_light_sbr)(struct smu_context *smu, bool enable);
+
+       /**
+        * @wait_for_event:  Wait for events from SMU.
+        */
+       int (*wait_for_event)(struct smu_context *smu,
+                             enum smu_event_type event, uint64_t event_arg);
 };
 
 typedef enum {
@@ -1283,5 +1293,8 @@ int smu_gfx_state_change_set(struct smu_context *smu, uint32_t state);
 
 int smu_set_light_sbr(struct smu_context *smu, bool enable);
 
+int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
+                      uint64_t event_arg);
+
 #endif
 #endif
index d4b804c..4a3037e 100644 (file)
@@ -2982,3 +2982,18 @@ static const struct amd_pm_funcs swsmu_pm_funcs = {
        .display_disable_memory_clock_switch = smu_display_disable_memory_clock_switch,
        .get_max_sustainable_clocks_by_dc    = smu_get_max_sustainable_clocks_by_dc,
 };
+
+int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
+                      uint64_t event_arg)
+{
+       int ret = -EINVAL;
+       struct smu_context *smu = &adev->smu;
+
+       if (smu->ppt_funcs->wait_for_event) {
+               mutex_lock(&smu->mutex);
+               ret = smu->ppt_funcs->wait_for_event(smu, event, event_arg);
+               mutex_unlock(&smu->mutex);
+       }
+
+       return ret;
+}