Skip to contentSkip to conversation

drm/amd/powerplay: add baco smu reset function for smu11

PATCH In review Wang, Kevin(Yang) 2 participants 3 messages Jul 3, 2019 – Jul 4, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/powerplay: add baco smu reset function for smu11

add baco reset support for smu11.
it can help gpu do asic reset when gpu recovery.

Change-Id I7714ed03ad87c13e93ca1a7e6aef81eba14667c8
---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c        |  6 +-
 drivers/gpu/drm/amd/amdgpu/nv.c               |  9 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    | 14 +++
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    | 26 ++++++
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  8 ++
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  8 ++
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 91 +++++++++++++++++++
 7 files changed, 159 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -2
index b41169261f7d..45dd22a1ef77 100644
@@ -244,8 +244,10 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev,
 	mutex_lock(&adev->mman.gtt_window_lock);
 
 	gmc_v10_0_flush_vm_hub(adev, vmid, AMDGPU_MMHUB, 0);
-	if (!adev->mman.buffer_funcs_enabled || !adev->ib_pool_ready ||
-	    adev->asic_type != CHIP_NAVI10) {
+	if (!adev->mman.buffer_funcs_enabled ||
+	    !adev->ib_pool_ready ||
+	    adev->asic_type != CHIP_NAVI10 ||
+	    adev->in_gpu_reset) {
 		gmc_v10_0_flush_vm_hub(adev, vmid, AMDGPU_GFXHUB, 0);
 		mutex_unlock(&adev->mman.gtt_window_lock);
 		return;
drivers/gpu/drm/amd/amdgpu/nv.c +8 -1
index 8f605417b40a..cc5d06718e4c 100644
@@ -31,6 +31,7 @@
 #include "amdgpu_vce.h"
 #include "amdgpu_ucode.h"
 #include "amdgpu_psp.h"
+#include "amdgpu_smu.h"
 #include "atom.h"
 #include "amd_pcie.h"
 
@@ -266,8 +267,14 @@ static int nv_asic_reset(struct amdgpu_device *adev)
 
 	amdgpu_atombios_scratch_regs_engine_hung(adev, false);
 #endif
+	int ret = 0;
+	struct smu_context *smu = &adev->smu;
 
-	return 0;
+	if (smu_baco_is_support(smu)) {
+		ret = smu_baco_reset(smu);
+	}
+
+	return ret;
 }
 
 static int nv_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -0
index b28a923f998d..fc416c686151 100644
@@ -633,6 +633,11 @@ static int smu_sw_init(void *handle)
 	bitmap_zero(smu->smu_feature.supported, SMU_FEATURE_MAX);
 	bitmap_zero(smu->smu_feature.enabled, SMU_FEATURE_MAX);
 	bitmap_zero(smu->smu_feature.allowed, SMU_FEATURE_MAX);
+
+	mutex_init(&smu->smu_baco.mutex);
+	smu->smu_baco.state = SMU_BACO_STATE_EXIT;
+	smu->smu_baco.platform_support = false;
+
 	smu->watermarks_bitmap = 0;
 	smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
 	smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
@@ -1057,11 +1062,20 @@ static int smu_suspend(void *handle)
 	int ret;
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	struct smu_context *smu = &adev->smu;
+	bool baco_feature_is_enabled = smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT);
 
 	ret = smu_system_features_control(smu, false);
 	if (ret)
 		return ret;
 
+	if (adev->in_gpu_reset && baco_feature_is_enabled) {
+		ret = smu_feature_set_enabled(smu, SMU_FEATURE_BACO_BIT, true);
+		if (ret) {
+			pr_warn("set BACO feature enabled failed, return %d\n", ret);
+			return ret;
+		}
+	}
+
 	smu->watermarks_bitmap &= ~(WATERMARKS_LOADED);
 
 	if (adev->asic_type >= CHIP_NAVI10 &&
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +26 -0
index 2818df46481c..c97324ef7db2 100644
@@ -241,6 +241,7 @@ enum smu_message_type
 	SMU_MSG_PowerUpJpeg,
 	SMU_MSG_PowerDownJpeg,
 	SMU_MSG_BacoAudioD3PME,
+	SMU_MSG_ArmD3,
 	SMU_MSG_MAX_COUNT,
 };
 
@@ -489,6 +490,19 @@ struct mclock_latency_table {
 	struct mclk_latency_entries  entries[MAX_REGULAR_DPM_NUM];
 };
 
+enum smu_baco_state
+{
+	SMU_BACO_STATE_ENTER = 0,
+	SMU_BACO_STATE_EXIT,
+};
+
+struct smu_baco_context
+{
+	struct mutex mutex;
+	uint32_t state;
+	bool platform_support;
+};
+
 #define WORKLOAD_POLICY_MAX 7
 struct smu_context
 {
@@ -505,6 +519,7 @@ struct smu_context
 	struct smu_power_context	smu_power;
 	struct smu_feature		smu_feature;
 	struct amd_pp_display_configuration  *display_config;
+	struct smu_baco_context		smu_baco;
 	void *od_settings;
 
 	uint32_t pstate_sclk;
@@ -680,6 +695,11 @@ struct smu_funcs
 	int (*register_irq_handler)(struct smu_context *smu);
 	int (*set_azalia_d3_pme)(struct smu_context *smu);
 	int (*get_max_sustainable_clocks_by_dc)(struct smu_context *smu, struct pp_smu_nv_clock_table *max_clocks);
+	bool (*baco_is_support)(struct smu_context *smu);
+	enum smu_baco_state (*baco_get_state)(struct smu_context *smu);
+	int (*baco_set_state)(struct smu_context *smu, enum smu_baco_state state);
+	int (*baco_reset)(struct smu_context *smu);
+
 };
 
 #define smu_init_microcode(smu) \
@@ -892,6 +912,12 @@ struct smu_funcs
 	((smu)->funcs->get_max_sustainable_clocks_by_dc ? (smu)->funcs->get_max_sustainable_clocks_by_dc((smu), (max_clocks)) : 0)
 #define smu_get_uclk_dpm_states(smu, clocks_in_khz, num_states) \
 	((smu)->ppt_funcs->get_uclk_dpm_states ? (smu)->ppt_funcs->get_uclk_dpm_states((smu), (clocks_in_khz), (num_states)) : 0)
+#define smu_baco_is_support(smu) \
+	((smu)->funcs->baco_is_support? (smu)->funcs->baco_is_support((smu)) : false)
+#define smu_baco_get_state(smu, state) \
+	((smu)->funcs->baco_get_state? (smu)->funcs->baco_get_state((smu), (state)) : 0)
+#define smu_baco_reset(smu) \
+	((smu)->funcs->baco_reset? (smu)->funcs->baco_reset((smu)) : 0)
 
 extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
 				   uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +8 -0
index d93cd76269b4..2fff4b16cb4e 100644
@@ -105,6 +105,14 @@ struct smu_11_0_power_context {
 	enum smu_11_0_power_state power_state;
 };
 
+enum smu_v11_0_baco_seq {
+	BACO_SEQ_BACO = 0,
+	BACO_SEQ_MSR,
+	BACO_SEQ_BAMACO,
+	BACO_SEQ_ULPS,
+	BACO_SEQ_COUNT,
+};
+
 void smu_v11_0_set_smu_funcs(struct smu_context *smu);
 
 #endif
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +8 -0
index 373aeba44f16..7574a02350c6 100644
@@ -115,6 +115,7 @@ static int navi10_message_map[SMU_MSG_MAX_COUNT] = {
 	MSG_MAP(PowerUpJpeg,		PPSMC_MSG_PowerUpJpeg),
 	MSG_MAP(PowerDownJpeg,		PPSMC_MSG_PowerDownJpeg),
 	MSG_MAP(BacoAudioD3PME,		PPSMC_MSG_BacoAudioD3PME),
+	MSG_MAP(ArmD3,			PPSMC_MSG_ArmD3),
 };
 
 static int navi10_clk_map[SMU_CLK_COUNT] = {
@@ -478,6 +479,7 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 {
 	struct smu_11_0_powerplay_table *powerplay_table = NULL;
 	struct smu_table_context *table_context = &smu->smu_table;
+	struct smu_baco_context *smu_baco = &smu->smu_baco;
 
 	if (!table_context->power_play_table)
 		return -EINVAL;
@@ -489,6 +491,12 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 
 	table_context->thermal_controller_type = powerplay_table->thermal_controller_type;
 
+	mutex_lock(&smu_baco->mutex);
+	if (powerplay_table->platform_caps & SMU_11_0_PP_PLATFORM_CAP_BACO ||
+	    powerplay_table->platform_caps & SMU_11_0_PP_PLATFORM_CAP_MACO)
+		smu_baco->platform_support = true;
+	mutex_unlock(&smu_baco->mutex);
+
 	return 0;
 }
 
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +91 -0

109 lines not on this page · raw message

Signature · 6 lines
2.22.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

ping...,

which one can help me review this patch.

thanks.

Best Regards,

Kevin

________________________________
From: Wang, Kevin(Yang)
Sent: Wednesday, July 3, 2019 11:09:45 AM
To: [email protected]
Cc: Zhang, Hawking; Xiao, Jack; Huang, Ray; Wang, Kevin(Yang)
Subject: [PATCH] drm/amd/powerplay: add baco smu reset function for smu11

add baco reset support for smu11.
it can help gpu do asic reset when gpu recovery.

Change-Id I7714ed03ad87c13e93ca1a7e6aef81eba14667c8
---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c        |  6 +-
 drivers/gpu/drm/amd/amdgpu/nv.c               |  9 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    | 14 +++
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    | 26 ++++++
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  8 ++
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  8 ++
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 91 +++++++++++++++++++
 7 files changed, 159 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -2
index b41169261f7d..45dd22a1ef77 100644
@@ -244,8 +244,10 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev,
         mutex_lock(&adev->mman.gtt_window_lock);
 
         gmc_v10_0_flush_vm_hub(adev, vmid, AMDGPU_MMHUB, 0);
-       if (!adev->mman.buffer_funcs_enabled || !adev->ib_pool_ready ||
-           adev->asic_type != CHIP_NAVI10) {
+       if (!adev->mman.buffer_funcs_enabled ||
+           !adev->ib_pool_ready ||
+           adev->asic_type != CHIP_NAVI10 ||
+           adev->in_gpu_reset) {
                 gmc_v10_0_flush_vm_hub(adev, vmid, AMDGPU_GFXHUB, 0);
                 mutex_unlock(&adev->mman.gtt_window_lock);
                 return;
drivers/gpu/drm/amd/amdgpu/nv.c +8 -1
index 8f605417b40a..cc5d06718e4c 100644
@@ -31,6 +31,7 @@
 #include "amdgpu_vce.h"
 #include "amdgpu_ucode.h"
 #include "amdgpu_psp.h"
+#include "amdgpu_smu.h"
 #include "atom.h"
 #include "amd_pcie.h"
 
@@ -266,8 +267,14 @@ static int nv_asic_reset(struct amdgpu_device *adev)
 
         amdgpu_atombios_scratch_regs_engine_hung(adev, false);
 #endif
+       int ret = 0;
+       struct smu_context *smu = &adev->smu;
 
-       return 0;
+       if (smu_baco_is_support(smu)) {
+               ret = smu_baco_reset(smu);
+       }
+
+       return ret;
 }
 
 static int nv_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -0
index b28a923f998d..fc416c686151 100644
@@ -633,6 +633,11 @@ static int smu_sw_init(void *handle)
         bitmap_zero(smu->smu_feature.supported, SMU_FEATURE_MAX);
         bitmap_zero(smu->smu_feature.enabled, SMU_FEATURE_MAX);
         bitmap_zero(smu->smu_feature.allowed, SMU_FEATURE_MAX);
+
+       mutex_init(&smu->smu_baco.mutex);
+       smu->smu_baco.state = SMU_BACO_STATE_EXIT;
+       smu->smu_baco.platform_support = false;
+
         smu->watermarks_bitmap = 0;
         smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
         smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
@@ -1057,11 +1062,20 @@ static int smu_suspend(void *handle)
         int ret;
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
         struct smu_context *smu = &adev->smu;
+       bool baco_feature_is_enabled = smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT);
 
         ret = smu_system_features_control(smu, false);
         if (ret)
                 return ret;
 
+       if (adev->in_gpu_reset && baco_feature_is_enabled) {
+               ret = smu_feature_set_enabled(smu, SMU_FEATURE_BACO_BIT, true);
+               if (ret) {
+                       pr_warn("set BACO feature enabled failed, return %d\n", ret);
+                       return ret;
+               }
+       }
+
         smu->watermarks_bitmap &= ~(WATERMARKS_LOADED);
 
         if (adev->asic_type >= CHIP_NAVI10 &&
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +26 -0
index 2818df46481c..c97324ef7db2 100644
@@ -241,6 +241,7 @@ enum smu_message_type
         SMU_MSG_PowerUpJpeg,
         SMU_MSG_PowerDownJpeg,
         SMU_MSG_BacoAudioD3PME,
+       SMU_MSG_ArmD3,
         SMU_MSG_MAX_COUNT,
 };
 
@@ -489,6 +490,19 @@ struct mclock_latency_table {
         struct mclk_latency_entries  entries[MAX_REGULAR_DPM_NUM];
 };
 
+enum smu_baco_state
+{
+       SMU_BACO_STATE_ENTER = 0,
+       SMU_BACO_STATE_EXIT,
+};
+
+struct smu_baco_context
+{
+       struct mutex mutex;
+       uint32_t state;
+       bool platform_support;
+};
+
 #define WORKLOAD_POLICY_MAX 7
 struct smu_context
 {
@@ -505,6 +519,7 @@ struct smu_context
         struct smu_power_context        smu_power;
         struct smu_feature              smu_feature;
         struct amd_pp_display_configuration  *display_config;
+       struct smu_baco_context         smu_baco;
         void *od_settings;
 
         uint32_t pstate_sclk;
@@ -680,6 +695,11 @@ struct smu_funcs
         int (*register_irq_handler)(struct smu_context *smu);
         int (*set_azalia_d3_pme)(struct smu_context *smu);
         int (*get_max_sustainable_clocks_by_dc)(struct smu_context *smu, struct pp_smu_nv_clock_table *max_clocks);
+       bool (*baco_is_support)(struct smu_context *smu);
+       enum smu_baco_state (*baco_get_state)(struct smu_context *smu);
+       int (*baco_set_state)(struct smu_context *smu, enum smu_baco_state state);
+       int (*baco_reset)(struct smu_context *smu);
+
 };
 
 #define smu_init_microcode(smu) \
@@ -892,6 +912,12 @@ struct smu_funcs
         ((smu)->funcs->get_max_sustainable_clocks_by_dc ? (smu)->funcs->get_max_sustainable_clocks_by_dc((smu), (max_clocks)) : 0)
 #define smu_get_uclk_dpm_states(smu, clocks_in_khz, num_states) \
         ((smu)->ppt_funcs->get_uclk_dpm_states ? (smu)->ppt_funcs->get_uclk_dpm_states((smu), (clocks_in_khz), (num_states)) : 0)
+#define smu_baco_is_support(smu) \
+       ((smu)->funcs->baco_is_support? (smu)->funcs->baco_is_support((smu)) : false)
+#define smu_baco_get_state(smu, state) \
+       ((smu)->funcs->baco_get_state? (smu)->funcs->baco_get_state((smu), (state)) : 0)
+#define smu_baco_reset(smu) \
+       ((smu)->funcs->baco_reset? (smu)->funcs->baco_reset((smu)) : 0)
 
 extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
                                    uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +8 -0
index d93cd76269b4..2fff4b16cb4e 100644
@@ -105,6 +105,14 @@ struct smu_11_0_power_context {
         enum smu_11_0_power_state power_state;
 };
 
+enum smu_v11_0_baco_seq {
+       BACO_SEQ_BACO = 0,
+       BACO_SEQ_MSR,
+       BACO_SEQ_BAMACO,
+       BACO_SEQ_ULPS,
+       BACO_SEQ_COUNT,
+};
+
 void smu_v11_0_set_smu_funcs(struct smu_context *smu);
 
 #endif
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +8 -0
index 373aeba44f16..7574a02350c6 100644
@@ -115,6 +115,7 @@ static int navi10_message_map[SMU_MSG_MAX_COUNT] = {
         MSG_MAP(PowerUpJpeg,            PPSMC_MSG_PowerUpJpeg),
         MSG_MAP(PowerDownJpeg,          PPSMC_MSG_PowerDownJpeg),
         MSG_MAP(BacoAudioD3PME,         PPSMC_MSG_BacoAudioD3PME),
+       MSG_MAP(ArmD3,                  PPSMC_MSG_ArmD3),
 };
 
 static int navi10_clk_map[SMU_CLK_COUNT] = {
@@ -478,6 +479,7 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 {
         struct smu_11_0_powerplay_table *powerplay_table = NULL;
         struct smu_table_context *table_context = &smu->smu_table;
+       struct smu_baco_context *smu_baco = &smu->smu_baco;
 
         if (!table_context->power_play_table)
                 return -EINVAL;
@@ -489,6 +491,12 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 
         table_context->thermal_controller_type = powerplay_table->thermal_controller_type;
 
+       mutex_lock(&smu_baco->mutex);
+       if (powerplay_table->platform_caps & SMU_11_0_PP_PLATFORM_CAP_BACO ||
+           powerplay_table->platform_caps & SMU_11_0_PP_PLATFORM_CAP_MACO)
+               smu_baco->platform_support = true;
+       mutex_unlock(&smu_baco->mutex);
+
         return 0;
 }
 
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +91 -0

109 lines not on this page · raw message

--
2.22.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3296575FE79BC02F2E406C64A2FA0-rweVpJHSKTqAm9ToKNQgFgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

Reviewed-by Hawking Zhang
#4 lore raw

From: Wang, Kevin(Yang) <[email protected]>
Sent: 2019年7月4日 11:13
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Xiao, Jack <[email protected]>; Huang, Ray <[email protected]>; Feng, Kenneth <[email protected]>; Quan, Evan <[email protected]>
Subject: Re: [PATCH] drm/amd/powerplay: add baco smu reset function for smu11

ping...,

which one can help me review this patch.

thanks.

Best Regards,

Kevin

________________________________
From: Wang, Kevin(Yang)
Sent: Wednesday, July 3, 2019 11:09:45 AM
To: [email protected]<mailto:[email protected]>
Cc: Zhang, Hawking; Xiao, Jack; Huang, Ray; Wang, Kevin(Yang)
Subject: [PATCH] drm/amd/powerplay: add baco smu reset function for smu11

add baco reset support for smu11.
it can help gpu do asic reset when gpu recovery.

Change-Id I7714ed03ad87c13e93ca1a7e6aef81eba14667c8
---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c        |  6 +-
 drivers/gpu/drm/amd/amdgpu/nv.c               |  9 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    | 14 +++
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    | 26 ++++++
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  8 ++
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  8 ++
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 91 +++++++++++++++++++
 7 files changed, 159 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -2
index b41169261f7d..45dd22a1ef77 100644
@@ -244,8 +244,10 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev,
         mutex_lock(&adev->mman.gtt_window_lock);
 
         gmc_v10_0_flush_vm_hub(adev, vmid, AMDGPU_MMHUB, 0);
-       if (!adev->mman.buffer_funcs_enabled || !adev->ib_pool_ready ||
-           adev->asic_type != CHIP_NAVI10) {
+       if (!adev->mman.buffer_funcs_enabled ||
+           !adev->ib_pool_ready ||
+           adev->asic_type != CHIP_NAVI10 ||
+           adev->in_gpu_reset) {
                 gmc_v10_0_flush_vm_hub(adev, vmid, AMDGPU_GFXHUB, 0);
                 mutex_unlock(&adev->mman.gtt_window_lock);
                 return;
drivers/gpu/drm/amd/amdgpu/nv.c +8 -1
index 8f605417b40a..cc5d06718e4c 100644
@@ -31,6 +31,7 @@
 #include "amdgpu_vce.h"
 #include "amdgpu_ucode.h"
 #include "amdgpu_psp.h"
+#include "amdgpu_smu.h"
 #include "atom.h"
 #include "amd_pcie.h"
 
@@ -266,8 +267,14 @@ static int nv_asic_reset(struct amdgpu_device *adev)
 
         amdgpu_atombios_scratch_regs_engine_hung(adev, false);
 #endif
+       int ret = 0;
+       struct smu_context *smu = &adev->smu;
 
-       return 0;
+       if (smu_baco_is_support(smu)) {
+               ret = smu_baco_reset(smu);
+       }
+
+       return ret;
 }
 
 static int nv_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -0
index b28a923f998d..fc416c686151 100644
@@ -633,6 +633,11 @@ static int smu_sw_init(void *handle)
         bitmap_zero(smu->smu_feature.supported, SMU_FEATURE_MAX);
         bitmap_zero(smu->smu_feature.enabled, SMU_FEATURE_MAX);
         bitmap_zero(smu->smu_feature.allowed, SMU_FEATURE_MAX);
+
+       mutex_init(&smu->smu_baco.mutex);
+       smu->smu_baco.state = SMU_BACO_STATE_EXIT;
+       smu->smu_baco.platform_support = false;
+
         smu->watermarks_bitmap = 0;
         smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
         smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
@@ -1057,11 +1062,20 @@ static int smu_suspend(void *handle)
         int ret;
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
         struct smu_context *smu = &adev->smu;
+       bool baco_feature_is_enabled = smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT);
 
         ret = smu_system_features_control(smu, false);
         if (ret)
                 return ret;
 
+       if (adev->in_gpu_reset && baco_feature_is_enabled) {
+               ret = smu_feature_set_enabled(smu, SMU_FEATURE_BACO_BIT, true);
+               if (ret) {
+                       pr_warn("set BACO feature enabled failed, return %d\n", ret);
+                       return ret;
+               }
+       }
+
         smu->watermarks_bitmap &= ~(WATERMARKS_LOADED);
 
         if (adev->asic_type >= CHIP_NAVI10 &&
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +26 -0
index 2818df46481c..c97324ef7db2 100644
@@ -241,6 +241,7 @@ enum smu_message_type
         SMU_MSG_PowerUpJpeg,
         SMU_MSG_PowerDownJpeg,
         SMU_MSG_BacoAudioD3PME,
+       SMU_MSG_ArmD3,
         SMU_MSG_MAX_COUNT,
 };
 
@@ -489,6 +490,19 @@ struct mclock_latency_table {
         struct mclk_latency_entries  entries[MAX_REGULAR_DPM_NUM];
 };
 
+enum smu_baco_state
+{
+       SMU_BACO_STATE_ENTER = 0,
+       SMU_BACO_STATE_EXIT,
+};
+
+struct smu_baco_context
+{
+       struct mutex mutex;
+       uint32_t state;
+       bool platform_support;
+};
+
 #define WORKLOAD_POLICY_MAX 7
 struct smu_context
 {
@@ -505,6 +519,7 @@ struct smu_context
         struct smu_power_context        smu_power;
         struct smu_feature              smu_feature;
         struct amd_pp_display_configuration  *display_config;
+       struct smu_baco_context         smu_baco;
         void *od_settings;
 
         uint32_t pstate_sclk;
@@ -680,6 +695,11 @@ struct smu_funcs
         int (*register_irq_handler)(struct smu_context *smu);
         int (*set_azalia_d3_pme)(struct smu_context *smu);
         int (*get_max_sustainable_clocks_by_dc)(struct smu_context *smu, struct pp_smu_nv_clock_table *max_clocks);
+       bool (*baco_is_support)(struct smu_context *smu);
+       enum smu_baco_state (*baco_get_state)(struct smu_context *smu);
+       int (*baco_set_state)(struct smu_context *smu, enum smu_baco_state state);
+       int (*baco_reset)(struct smu_context *smu);
+
 };
 
 #define smu_init_microcode(smu) \
@@ -892,6 +912,12 @@ struct smu_funcs
         ((smu)->funcs->get_max_sustainable_clocks_by_dc ? (smu)->funcs->get_max_sustainable_clocks_by_dc((smu), (max_clocks)) : 0)
 #define smu_get_uclk_dpm_states(smu, clocks_in_khz, num_states) \
         ((smu)->ppt_funcs->get_uclk_dpm_states ? (smu)->ppt_funcs->get_uclk_dpm_states((smu), (clocks_in_khz), (num_states)) : 0)
+#define smu_baco_is_support(smu) \
+       ((smu)->funcs->baco_is_support? (smu)->funcs->baco_is_support((smu)) : false)
+#define smu_baco_get_state(smu, state) \
+       ((smu)->funcs->baco_get_state? (smu)->funcs->baco_get_state((smu), (state)) : 0)
+#define smu_baco_reset(smu) \
+       ((smu)->funcs->baco_reset? (smu)->funcs->baco_reset((smu)) : 0)
 
 extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
                                    uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +8 -0
index d93cd76269b4..2fff4b16cb4e 100644
@@ -105,6 +105,14 @@ struct smu_11_0_power_context {
         enum smu_11_0_power_state power_state;
 };
 
+enum smu_v11_0_baco_seq {
+       BACO_SEQ_BACO = 0,
+       BACO_SEQ_MSR,
+       BACO_SEQ_BAMACO,
+       BACO_SEQ_ULPS,
+       BACO_SEQ_COUNT,
+};
+
 void smu_v11_0_set_smu_funcs(struct smu_context *smu);
 
 #endif
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +8 -0
index 373aeba44f16..7574a02350c6 100644
@@ -115,6 +115,7 @@ static int navi10_message_map[SMU_MSG_MAX_COUNT] = {
         MSG_MAP(PowerUpJpeg,            PPSMC_MSG_PowerUpJpeg),
         MSG_MAP(PowerDownJpeg,          PPSMC_MSG_PowerDownJpeg),
         MSG_MAP(BacoAudioD3PME,         PPSMC_MSG_BacoAudioD3PME),
+       MSG_MAP(ArmD3,                  PPSMC_MSG_ArmD3),
 };
 
 static int navi10_clk_map[SMU_CLK_COUNT] = {
@@ -478,6 +479,7 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 {
         struct smu_11_0_powerplay_table *powerplay_table = NULL;
         struct smu_table_context *table_context = &smu->smu_table;
+       struct smu_baco_context *smu_baco = &smu->smu_baco;
 
         if (!table_context->power_play_table)
                 return -EINVAL;
@@ -489,6 +491,12 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 
         table_context->thermal_controller_type = powerplay_table->thermal_controller_type;
 
+       mutex_lock(&smu_baco->mutex);
+       if (powerplay_table->platform_caps & SMU_11_0_PP_PLATFORM_CAP_BACO ||
+           powerplay_table->platform_caps & SMU_11_0_PP_PLATFORM_CAP_MACO)
+               smu_baco->platform_support = true;
+       mutex_unlock(&smu_baco->mutex);
+
         return 0;
 }
 
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +91 -0

109 lines not on this page · raw message

--
2.22.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx