[PATCH] drm/amd/pm: drop redundant and unneeded BACO APIs V2

Deucher, Alexander Alexander.Deucher at amd.com
Mon Mar 22 15:34:19 UTC 2021


[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Evan Quan <evan.quan at amd.com>
Sent: Monday, March 22, 2021 2:11 AM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Quan, Evan <Evan.Quan at amd.com>
Subject: [PATCH] drm/amd/pm: drop redundant and unneeded BACO APIs V2

Use other APIs which are with the same functionality but much
more clean.

V2: drop mediate unneeded interface

Change-Id: I5e9e0ab5d39b49b02434f18e12392b13931396be
Signed-off-by: Evan Quan <evan.quan at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/nv.c           | 25 +-----
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  9 ---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 95 -----------------------
 3 files changed, 3 insertions(+), 126 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index e9cc3201054f..46d4bbabce75 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -515,21 +515,9 @@ static int nv_asic_mode2_reset(struct amdgpu_device *adev)
         return ret;
 }

-static bool nv_asic_supports_baco(struct amdgpu_device *adev)
-{
-       struct smu_context *smu = &adev->smu;
-
-       if (smu_baco_is_support(smu))
-               return true;
-       else
-               return false;
-}
-
 static enum amd_reset_method
 nv_asic_reset_method(struct amdgpu_device *adev)
 {
-       struct smu_context *smu = &adev->smu;
-
         if (amdgpu_reset_method == AMD_RESET_METHOD_MODE1 ||
             amdgpu_reset_method == AMD_RESET_METHOD_MODE2 ||
             amdgpu_reset_method == AMD_RESET_METHOD_BACO ||
@@ -548,7 +536,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
         case CHIP_DIMGREY_CAVEFISH:
                 return AMD_RESET_METHOD_MODE1;
         default:
-               if (smu_baco_is_support(smu))
+               if (amdgpu_dpm_is_baco_supported(adev))
                         return AMD_RESET_METHOD_BACO;
                 else
                         return AMD_RESET_METHOD_MODE1;
@@ -558,7 +546,6 @@ nv_asic_reset_method(struct amdgpu_device *adev)
 static int nv_asic_reset(struct amdgpu_device *adev)
 {
         int ret = 0;
-       struct smu_context *smu = &adev->smu;

         switch (nv_asic_reset_method(adev)) {
         case AMD_RESET_METHOD_PCI:
@@ -567,13 +554,7 @@ static int nv_asic_reset(struct amdgpu_device *adev)
                 break;
         case AMD_RESET_METHOD_BACO:
                 dev_info(adev->dev, "BACO reset\n");
-
-               ret = smu_baco_enter(smu);
-               if (ret)
-                       return ret;
-               ret = smu_baco_exit(smu);
-               if (ret)
-                       return ret;
+               ret = amdgpu_dpm_baco_reset(adev);
                 break;
         case AMD_RESET_METHOD_MODE2:
                 dev_info(adev->dev, "MODE2 reset\n");
@@ -981,7 +962,7 @@ static const struct amdgpu_asic_funcs nv_asic_funcs =
         .need_full_reset = &nv_need_full_reset,
         .need_reset_on_init = &nv_need_reset_on_init,
         .get_pcie_replay_count = &nv_get_pcie_replay_count,
-       .supports_baco = &nv_asic_supports_baco,
+       .supports_baco = &amdgpu_dpm_is_baco_supported,
         .pre_asic_init = &nv_pre_asic_init,
         .update_umd_stable_pstate = &nv_update_umd_stable_pstate,
         .query_video_codecs = &nv_query_video_codecs,
diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index 517f333fbc4b..02675155028d 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
@@ -1285,15 +1285,6 @@ int smu_get_power_limit(struct smu_context *smu,
                         uint32_t *limit,
                         enum smu_ppt_limit_level limit_level);

-int smu_set_azalia_d3_pme(struct smu_context *smu);
-
-bool smu_baco_is_support(struct smu_context *smu);
-
-int smu_baco_get_state(struct smu_context *smu, enum smu_baco_state *state);
-
-int smu_baco_enter(struct smu_context *smu);
-int smu_baco_exit(struct smu_context *smu);
-
 bool smu_mode1_reset_is_support(struct smu_context *smu);
 bool smu_mode2_reset_is_support(struct smu_context *smu);
 int smu_mode1_reset(struct smu_context *smu);
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 4120d28f782b..1bb0c0966e3d 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -2682,48 +2682,6 @@ static int smu_set_xgmi_pstate(void *handle,
         return ret;
 }

-int smu_set_azalia_d3_pme(struct smu_context *smu)
-{
-       int ret = 0;
-
-       if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
-               return -EOPNOTSUPP;
-
-       mutex_lock(&smu->mutex);
-
-       if (smu->ppt_funcs->set_azalia_d3_pme)
-               ret = smu->ppt_funcs->set_azalia_d3_pme(smu);
-
-       mutex_unlock(&smu->mutex);
-
-       return ret;
-}
-
-/*
- * On system suspending or resetting, the dpm_enabled
- * flag will be cleared. So that those SMU services which
- * are not supported will be gated.
- *
- * However, the baco/mode1 reset should still be granted
- * as they are still supported and necessary.
- */
-bool smu_baco_is_support(struct smu_context *smu)
-{
-       bool ret = false;
-
-       if (!smu->pm_enabled)
-               return false;
-
-       mutex_lock(&smu->mutex);
-
-       if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
-               ret = smu->ppt_funcs->baco_is_support(smu);
-
-       mutex_unlock(&smu->mutex);
-
-       return ret;
-}
-
 static int smu_get_baco_capability(void *handle, bool *cap)
 {
         struct smu_context *smu = handle;
@@ -2744,59 +2702,6 @@ static int smu_get_baco_capability(void *handle, bool *cap)
         return ret;
 }

-
-int smu_baco_get_state(struct smu_context *smu, enum smu_baco_state *state)
-{
-       if (smu->ppt_funcs->baco_get_state)
-               return -EINVAL;
-
-       mutex_lock(&smu->mutex);
-       *state = smu->ppt_funcs->baco_get_state(smu);
-       mutex_unlock(&smu->mutex);
-
-       return 0;
-}
-
-int smu_baco_enter(struct smu_context *smu)
-{
-       int ret = 0;
-
-       if (!smu->pm_enabled)
-               return -EOPNOTSUPP;
-
-       mutex_lock(&smu->mutex);
-
-       if (smu->ppt_funcs->baco_enter)
-               ret = smu->ppt_funcs->baco_enter(smu);
-
-       mutex_unlock(&smu->mutex);
-
-       if (ret)
-               dev_err(smu->adev->dev, "Failed to enter BACO state!\n");
-
-       return ret;
-}
-
-int smu_baco_exit(struct smu_context *smu)
-{
-       int ret = 0;
-
-       if (!smu->pm_enabled)
-               return -EOPNOTSUPP;
-
-       mutex_lock(&smu->mutex);
-
-       if (smu->ppt_funcs->baco_exit)
-               ret = smu->ppt_funcs->baco_exit(smu);
-
-       mutex_unlock(&smu->mutex);
-
-       if (ret)
-               dev_err(smu->adev->dev, "Failed to exit BACO state!\n");
-
-       return ret;
-}
-
 static int smu_baco_set_state(void *handle, int state)
 {
         struct smu_context *smu = handle;
--
2.29.0

_______________________________________________
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%7Calexander.deucher%40amd.com%7Cda2f33ff4e934846b74508d8ecf9584a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637519902972470482%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=A5gcNSzu1elCbA8Xc6UB3wbKI0a1cIOvedgAzpVlMQs%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20210322/5326cf6e/attachment-0001.htm>


More information about the amd-gfx mailing list