[PATCH] drm/amd/pm: Support board calibration on aldebaran

Wang, Kevin(Yang) Kevin1.Wang at amd.com
Thu Jul 15 08:08:15 UTC 2021


[AMD Official Use Only]

<comments inline>
________________________________
From: Lazar, Lijo <Lijo.Lazar at amd.com>
Sent: Thursday, July 15, 2021 3:47 PM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Zhang, Hawking <Hawking.Zhang at amd.com>; Wang, Kevin(Yang) <Kevin1.Wang at amd.com>; Feng, Kenneth <Kenneth.Feng at amd.com>; Quan, Evan <Evan.Quan at amd.com>
Subject: [PATCH] drm/amd/pm: Support board calibration on aldebaran

Add support for board power calibration on Aldebaran.
Board calibration is done after DC offset calibration.

Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
---
 drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h  |  3 +-
 drivers/gpu/drm/amd/pm/inc/smu_types.h        |  3 +-
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 42 ++++++++++++++-----
 3 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h b/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h
index 610266088ff1..35fa0d8e92dd 100644
--- a/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h
+++ b/drivers/gpu/drm/amd/pm/inc/aldebaran_ppsmc.h
@@ -101,7 +101,8 @@
 #define PPSMC_MSG_SetSystemVirtualSTBtoDramAddrLow  0x41

 #define PPSMC_MSG_GfxDriverResetRecovery        0x42
-#define PPSMC_Message_Count                    0x43
+#define PPSMC_MSG_BoardPowerCalibration         0x43
+#define PPSMC_Message_Count                    0x44

 //PPSMC Reset Types
 #define PPSMC_RESET_TYPE_WARM_RESET              0x00
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_types.h b/drivers/gpu/drm/amd/pm/inc/smu_types.h
index 89a16dcd0fff..1d3765b873df 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_types.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_types.h
@@ -225,7 +225,8 @@
         __SMU_DUMMY_MAP(DisableDeterminism),            \
         __SMU_DUMMY_MAP(SetUclkDpmMode),                \
         __SMU_DUMMY_MAP(LightSBR),                      \
-       __SMU_DUMMY_MAP(GfxDriverResetRecovery),
+       __SMU_DUMMY_MAP(GfxDriverResetRecovery),        \
+       __SMU_DUMMY_MAP(BoardPowerCalibration),

 #undef __SMU_DUMMY_MAP
 #define __SMU_DUMMY_MAP(type)   SMU_MSG_##type
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
index c16ca0c78e93..1400ccb3bf52 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
@@ -134,6 +134,7 @@ static const struct cmn2asic_msg_mapping aldebaran_message_map[SMU_MSG_MAX_COUNT
         MSG_MAP(DisableDeterminism,                  PPSMC_MSG_DisableDeterminism,               0),
         MSG_MAP(SetUclkDpmMode,                      PPSMC_MSG_SetUclkDpmMode,                   0),
         MSG_MAP(GfxDriverResetRecovery,              PPSMC_MSG_GfxDriverResetRecovery,           0),
+       MSG_MAP(BoardPowerCalibration,               PPSMC_MSG_BoardPowerCalibration,            0),
 };

 static const struct cmn2asic_mapping aldebaran_clk_map[SMU_CLK_COUNT] = {
@@ -440,6 +441,35 @@ static int aldebaran_setup_pptable(struct smu_context *smu)
         return ret;
 }

+static bool aldebaran_is_primary(struct smu_context *smu)
+{
+       struct amdgpu_device *adev = smu->adev;
+
+       if (adev->smuio.funcs && adev->smuio.funcs->get_die_id)
+               return adev->smuio.funcs->get_die_id(adev) == 0;
+
+       return true;
+}
+
+static int aldebaran_run_board_btc(struct smu_context *smu)
+{
+       u32 smu_version;
[kevin]:
change type to uint32_t is better match with smu driver coding style.
+       int ret;
+
+       if (!aldebaran_is_primary(smu))
+               return 0;
+
+       smu_cmn_get_smc_version(smu, NULL, &smu_version);
[kevin]:
you'd better to check return value first before using smu_version.

others is fine for me.

Reviewed-by: Kevin Wang <kevin1.wang at amd.com>

+       if (smu_version <= 0x00441d00)
+               return 0;
+
+       ret = smu_cmn_send_smc_msg(smu, SMU_MSG_BoardPowerCalibration, NULL);
+       if (ret)
+               dev_err(smu->adev->dev, "Board power calibration failed!\n");
+
+       return ret;
+}
+
 static int aldebaran_run_btc(struct smu_context *smu)
 {
         int ret;
@@ -447,6 +477,8 @@ static int aldebaran_run_btc(struct smu_context *smu)
         ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
         if (ret)
                 dev_err(smu->adev->dev, "RunDcBtc failed!\n");
+       else
+               ret = aldebaran_run_board_btc(smu);

         return ret;
 }
@@ -524,16 +556,6 @@ static int aldebaran_freqs_in_same_level(int32_t frequency1,
         return (abs(frequency1 - frequency2) <= EPSILON);
 }

-static bool aldebaran_is_primary(struct smu_context *smu)
-{
-       struct amdgpu_device *adev = smu->adev;
-
-       if (adev->smuio.funcs && adev->smuio.funcs->get_die_id)
-               return adev->smuio.funcs->get_die_id(adev) == 0;
-
-       return true;
-}
-
 static int aldebaran_get_smu_metrics_data(struct smu_context *smu,
                                           MetricsMember_t member,
                                           uint32_t *value)
--
2.17.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20210715/a69215ea/attachment.htm>


More information about the amd-gfx mailing list