[PATCH] drm/amdgpu: revise the mode2 reset for vangogh
Quan, Evan
Evan.Quan at amd.com
Wed Dec 23 07:28:18 UTC 2020
[AMD Official Use Only - Internal Distribution Only]
Acked-by: Evan Quan <evan.quan at amd.com>
-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Huang Rui
Sent: Wednesday, December 23, 2020 10:08 AM
To: amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Su, Jinzhou (Joe) <Jinzhou.Su at amd.com>; Huang, Ray <Ray.Huang at amd.com>
Subject: [PATCH] drm/amdgpu: revise the mode2 reset for vangogh
PCIE MMIO bar needs to be restored firstly after the reset event
triggers. So it's unable to access the registers to wait for response
from SMU. Becasue the value of mmMP1_SMN_C2PMSG_90 is invalid at that
moment.
Signed-off-by: Huang Rui <ray.huang at amd.com>
---
.../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 22 +++++++++-
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 42 ++++++++++---------
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 2 +
3 files changed, 46 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
index 49864efdeffe..93328eaec0da 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
@@ -888,9 +888,29 @@ static int vangogh_set_fine_grain_gfx_freq_parameters(struct smu_context *smu)
return 0;
}
+static int vangogh_mode_reset(struct smu_context *smu, int type)
+{
+int ret = 0, index = 0;
+
+index = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_MSG,
+ SMU_MSG_GfxDeviceDriverReset);
+if (index < 0)
+return index == -EACCES ? 0 : index;
+
+mutex_lock(&smu->message_lock);
+
+ret = smu_cmn_send_msg_without_waiting(smu, (uint16_t)index, type);
+
+mutex_unlock(&smu->message_lock);
+
+mdelay(10);
+
+return ret;
+}
+
static int vangogh_mode2_reset(struct smu_context *smu)
{
-return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset, SMU_RESET_MODE_2, NULL);
+return vangogh_mode_reset(smu, SMU_RESET_MODE_2);
}
static const struct pptable_funcs vangogh_ppt_funcs = {
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
index 76ca41653354..39d5edb8c16b 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
@@ -68,14 +68,6 @@ static const char *smu_get_message_name(struct smu_context *smu,
return __smu_message_names[type];
}
-static void smu_cmn_send_msg_without_waiting(struct smu_context *smu,
- uint16_t msg)
-{
-struct amdgpu_device *adev = smu->adev;
-
-WREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_66, msg);
-}
-
static void smu_cmn_read_arg(struct smu_context *smu,
uint32_t *arg)
{
@@ -104,6 +96,26 @@ static int smu_cmn_wait_for_response(struct smu_context *smu)
return RREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90) == 0x1 ? 0 : -EIO;
}
+int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
+ uint16_t msg, uint32_t param)
+{
+struct amdgpu_device *adev = smu->adev;
+int ret;
+
+ret = smu_cmn_wait_for_response(smu);
+if (ret) {
+dev_err(adev->dev, "Msg issuing pre-check failed and "
+ "SMU may be not in the right state!\n");
+return ret;
+}
+
+WREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
+WREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_82, param);
+WREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_66, msg);
+
+return 0;
+}
+
int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
enum smu_message_type msg,
uint32_t param,
@@ -122,18 +134,10 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
return index == -EACCES ? 0 : index;
mutex_lock(&smu->message_lock);
-ret = smu_cmn_wait_for_response(smu);
-if (ret) {
-dev_err(adev->dev, "Msg issuing pre-check failed and "
- "SMU may be not in the right state!\n");
-goto out;
-}
-
-WREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
-WREG32_SOC15_NO_KIQ(MP1, 0, mmMP1_SMN_C2PMSG_82, param);
-
-smu_cmn_send_msg_without_waiting(smu, (uint16_t)index);
+ret = smu_cmn_send_msg_without_waiting(smu, (uint16_t)index, param);
+if (ret)
+goto out;
ret = smu_cmn_wait_for_response(smu);
if (ret) {
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
index 01e825d83d8d..08ccf2d3257c 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
@@ -26,6 +26,8 @@
#include "amdgpu_smu.h"
#if defined(SWSMU_CODE_LAYER_L2) || defined(SWSMU_CODE_LAYER_L3) || defined(SWSMU_CODE_LAYER_L4)
+int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
+ uint16_t msg, uint32_t param);
int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
enum smu_message_type msg,
uint32_t param,
--
2.25.1
_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cevan.quan%40amd.com%7C7f292c1025234e6c2d2b08d8a6e7a3d5%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637442861103766873%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6qYjw519hhNI77EiaBSgDskyt%2BOoHyoD9KOQW6on0aw%3D&reserved=0
More information about the amd-gfx
mailing list