RE: [PATCH] drm/amd/pm: Support for getting power1_cap_min value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - General]

Reviewed-by: Kenneth Feng <kenneth.feng@xxxxxxx>


-----Original Message-----
From: Ma, Jun <Jun.Ma2@xxxxxxx>
Sent: Tuesday, October 17, 2023 3:22 PM
To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx; Feng, Kenneth <Kenneth.Feng@xxxxxxx>; Deucher, Alexander <Alexander.Deucher@xxxxxxx>
Cc: Ma, Jun <Jun.Ma2@xxxxxxx>; Ma, Jun <Jun.Ma2@xxxxxxx>
Subject: [PATCH] drm/amd/pm: Support for getting power1_cap_min value

Support for getting power1_cap_min value on smu13 and smu11.
For other Asics, we still use 0 as the default value.

Signed-off-by: Ma Jun <Jun.Ma2@xxxxxxx>
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            | 14 ++++----
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 16 +++++----
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  8 +++--  .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 33 +++++++++++-------
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 33 +++++++++++-------
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   | 34 +++++++++++--------
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  |  5 ++-
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 13 ++++---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 34 ++++++++++++-------  .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  |  9 +++--  .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c  | 34 ++++++++++++-------
 drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  2 +-
 12 files changed, 147 insertions(+), 88 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index c7c29aa24c36..d76c3abf406f 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -2921,14 +2921,6 @@ static ssize_t amdgpu_hwmon_show_power_input(struct device *dev,
        return sysfs_emit(buf, "%zd\n", val);
 }

-static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev,
-                                        struct device_attribute *attr,
-                                        char *buf)
-{
-       return sysfs_emit(buf, "%i\n", 0);
-}
-
-
 static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,
                                        struct device_attribute *attr,
                                        char *buf,
@@ -2965,6 +2957,12 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,
        return size;
 }

+static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf)
+{
+       return amdgpu_hwmon_show_power_cap_generic(dev, attr, buf,
+PP_PWR_LIMIT_MIN); }

 static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
                                         struct device_attribute *attr,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 7c3356d6da5e..f4a68d107184 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -849,7 +849,8 @@ static int smu_late_init(void *handle)
        ret = smu_get_asic_power_limits(smu,
                                        &smu->current_power_limit,
                                        &smu->default_power_limit,
-                                       &smu->max_power_limit);
+                                       &smu->max_power_limit,
+                                       &smu->min_power_limit);
        if (ret) {
                dev_err(adev->dev, "Failed to get asic power limits!\n");
                return ret;
@@ -2447,6 +2448,8 @@ int smu_get_power_limit(void *handle,
                limit_level = SMU_PPT_LIMIT_MAX;
                break;
        case PP_PWR_LIMIT_MIN:
+               limit_level = SMU_PPT_LIMIT_MIN;
+               break;
        default:
                return -EOPNOTSUPP;
                break;
@@ -2466,8 +2469,7 @@ int smu_get_power_limit(void *handle,
                        case IP_VERSION(11, 0, 13):
                                ret = smu_get_asic_power_limits(smu,
                                                                &smu->current_power_limit,
-                                                               NULL,
-                                                               NULL);
+                                                               NULL, NULL, NULL);
                                break;
                        default:
                                break;
@@ -2480,6 +2482,8 @@ int smu_get_power_limit(void *handle,
                case SMU_PPT_LIMIT_MAX:
                        *limit = smu->max_power_limit;
                        break;
+               case SMU_PPT_LIMIT_MIN:
+                       *limit = smu->min_power_limit;
                default:
                        break;
                }
@@ -2502,10 +2506,10 @@ static int smu_set_power_limit(void *handle, uint32_t limit)
                if (smu->ppt_funcs->set_power_limit)
                        return smu->ppt_funcs->set_power_limit(smu, limit_type, limit);

-       if (limit > smu->max_power_limit) {
+       if ((limit > smu->max_power_limit) || (limit < smu->min_power_limit))
+{
                dev_err(smu->adev->dev,
-                       "New power limit (%d) is over the max allowed %d\n",
-                       limit, smu->max_power_limit);
+                       "New power limit (%d) is out of range [%d,%d]\n",
+                       limit, smu->min_power_limit, smu->max_power_limit);
                return -EINVAL;
        }

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index 1454eed76604..839553a86aa2 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
@@ -500,6 +500,7 @@ struct smu_context {
        uint32_t current_power_limit;
        uint32_t default_power_limit;
        uint32_t max_power_limit;
+       uint32_t min_power_limit;

        /* soft pptable */
        uint32_t ppt_offset_bytes;
@@ -821,9 +822,10 @@ struct pptable_funcs {
         * @get_power_limit: Get the device's power limits.
         */
        int (*get_power_limit)(struct smu_context *smu,
-                              uint32_t *current_power_limit,
-                              uint32_t *default_power_limit,
-                              uint32_t *max_power_limit);
+                                       uint32_t *current_power_limit,
+                                       uint32_t *default_power_limit,
+                                       uint32_t *max_power_limit,
+                                       uint32_t *min_power_limit);

        /**
         * @get_ppt_limit: Get the device's ppt limits.
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
index 44e4289b95cd..77c01bfb96fe 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
@@ -1285,14 +1285,15 @@ static int arcturus_get_fan_parameters(struct smu_context *smu)  }

 static int arcturus_get_power_limit(struct smu_context *smu,
-                                   uint32_t *current_power_limit,
-                                   uint32_t *default_power_limit,
-                                   uint32_t *max_power_limit)
+                                       uint32_t *current_power_limit,
+                                       uint32_t *default_power_limit,
+                                       uint32_t *max_power_limit,
+                                       uint32_t *min_power_limit)
 {
        struct smu_11_0_powerplay_table *powerplay_table =
                (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
        PPTable_t *pptable = smu->smu_table.driver_pptable;
-       uint32_t power_limit, od_percent;
+       uint32_t power_limit, od_percent_upper, od_percent_lower;

        if (smu_v11_0_get_current_power_limit(smu, &power_limit)) {
                /* the last hope to figure out the ppt limit */ @@ -1309,17 +1310,25 @@ static int arcturus_get_power_limit(struct smu_context *smu,
        if (default_power_limit)
                *default_power_limit = power_limit;

-       if (max_power_limit) {
-               if (smu->od_enabled) {
-                       od_percent = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+       if (smu->od_enabled) {
+               od_percent_upper = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+               od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+       } else {
+               od_percent_upper = 0;
+               od_percent_lower = 100;
+       }

-                       dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_percent, power_limit);
+       dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
+                                                       od_percent_upper, od_percent_lower, power_limit);

-                       power_limit *= (100 + od_percent);
-                       power_limit /= 100;
-               }
+       if (max_power_limit) {
+               *max_power_limit = power_limit * (100 + od_percent_upper);
+               *max_power_limit /= 100;
+       }

-               *max_power_limit = power_limit;
+       if (min_power_limit) {
+               *min_power_limit = power_limit * (100 - od_percent_lower);
+               *min_power_limit /= 100;
        }

        return 0;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index 5f3cbfff156a..a83bd3f347a9 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -2337,15 +2337,16 @@ static int navi10_display_disable_memory_clock_switch(struct smu_context *smu,  }

 static int navi10_get_power_limit(struct smu_context *smu,
-                                 uint32_t *current_power_limit,
-                                 uint32_t *default_power_limit,
-                                 uint32_t *max_power_limit)
+                                       uint32_t *current_power_limit,
+                                       uint32_t *default_power_limit,
+                                       uint32_t *max_power_limit,
+                                       uint32_t *min_power_limit)
 {
        struct smu_11_0_powerplay_table *powerplay_table =
                (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
        struct smu_11_0_overdrive_table *od_settings = smu->od_settings;
        PPTable_t *pptable = smu->smu_table.driver_pptable;
-       uint32_t power_limit, od_percent;
+       uint32_t power_limit, od_percent_upper, od_percent_lower;

        if (smu_v11_0_get_current_power_limit(smu, &power_limit)) {
                /* the last hope to figure out the ppt limit */ @@ -2362,18 +2363,26 @@ static int navi10_get_power_limit(struct smu_context *smu,
        if (default_power_limit)
                *default_power_limit = power_limit;

-       if (max_power_limit) {
-               if (smu->od_enabled &&
+       if (smu->od_enabled &&
                    navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_POWER_LIMIT)) {
-                       od_percent = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+               od_percent_upper = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+               od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+       } else {
+               od_percent_upper = 0;
+               od_percent_lower = 100;
+       }

-                       dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_percent, power_limit);
+       dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
+                                       od_percent_upper, od_percent_lower, power_limit);

-                       power_limit *= (100 + od_percent);
-                       power_limit /= 100;
-               }
+       if (max_power_limit) {
+               *max_power_limit = power_limit * (100 + od_percent_upper);
+               *max_power_limit /= 100;
+       }

-               *max_power_limit = power_limit;
+       if (min_power_limit) {
+               *min_power_limit = power_limit * (100 - od_percent_lower);
+               *min_power_limit /= 100;
        }

        return 0;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index 28868f64d134..8206a2744272 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -620,11 +620,12 @@ static uint32_t sienna_cichlid_get_throttler_status_locked(struct smu_context *s  static int sienna_cichlid_get_power_limit(struct smu_context *smu,
                                          uint32_t *current_power_limit,
                                          uint32_t *default_power_limit,
-                                         uint32_t *max_power_limit)
+                                         uint32_t *max_power_limit,
+                                         uint32_t *min_power_limit)
 {
        struct smu_11_0_7_powerplay_table *powerplay_table =
                (struct smu_11_0_7_powerplay_table *)smu->smu_table.power_play_table;
-       uint32_t power_limit, od_percent;
+       uint32_t power_limit, od_percent_upper, od_percent_lower;
        uint16_t *table_member;

        GET_PPTABLE_MEMBER(SocketPowerLimitAc, &table_member); @@ -639,21 +640,26 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu,
        if (default_power_limit)
                *default_power_limit = power_limit;

-       if (max_power_limit) {
-               if (smu->od_enabled) {
-                       od_percent =
-                               le32_to_cpu(powerplay_table->overdrive_table.max[
-                                                       SMU_11_0_7_ODSETTING_POWERPERCENTAGE]);
+       if (smu->od_enabled) {
+               od_percent_upper = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_7_ODSETTING_POWERPERCENTAGE]);
+               od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_11_0_7_ODSETTING_POWERPERCENTAGE]);
+       } else {
+               od_percent_upper = 0;
+               od_percent_lower = 100;
+       }

-                       dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n",
-                                       od_percent, power_limit);
+       dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
+                                       od_percent_upper, od_percent_lower, power_limit);

-                       power_limit *= (100 + od_percent);
-                       power_limit /= 100;
-               }
-               *max_power_limit = power_limit;
+       if (max_power_limit) {
+               *max_power_limit = power_limit * (100 + od_percent_upper);
+               *max_power_limit /= 100;
        }

+       if (min_power_limit) {
+               *min_power_limit = power_limit * (100 - od_percent_lower);
+               *min_power_limit /= 100;
+       }
        return 0;
 }

@@ -672,7 +678,7 @@ static void sienna_cichlid_get_smartshift_power_percentage(struct smu_context *s
        uint32_t cur_power_limit;

        if (metrics_v4->ApuSTAPMSmartShiftLimit != 0) {
-               sienna_cichlid_get_power_limit(smu, &cur_power_limit, NULL, NULL);
+               sienna_cichlid_get_power_limit(smu, &cur_power_limit, NULL, NULL,
+NULL);
                apu_power_limit = metrics_v4->ApuSTAPMLimit;
                dgpu_power_limit = cur_power_limit;
                powerRatio = (((apu_power_limit +
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 a5481274052e..d006ebe94aed 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
@@ -2344,7 +2344,8 @@ static u32 vangogh_get_gfxoff_status(struct smu_context *smu)  static int vangogh_get_power_limit(struct smu_context *smu,
                                   uint32_t *current_power_limit,
                                   uint32_t *default_power_limit,
-                                  uint32_t *max_power_limit)
+                                  uint32_t *max_power_limit,
+                                  uint32_t *min_power_limit)
 {
        struct smu_11_5_power_context *power_context =
                                                                smu->smu_power.power_context;
@@ -2366,6 +2367,8 @@ static int vangogh_get_power_limit(struct smu_context *smu,
                *default_power_limit = ppt_limit / 1000;
        if (max_power_limit)
                *max_power_limit = 29;
+       if (min_power_limit)
+               *min_power_limit = 0;

        ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPPTLimit, &ppt_limit);
        if (ret) {
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 2373a66c7efd..84df7df78032 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
@@ -1145,9 +1145,10 @@ static int aldebaran_read_sensor(struct smu_context *smu,  }

 static int aldebaran_get_power_limit(struct smu_context *smu,
-                                    uint32_t *current_power_limit,
-                                    uint32_t *default_power_limit,
-                                    uint32_t *max_power_limit)
+                                               uint32_t *current_power_limit,
+                                               uint32_t *default_power_limit,
+                                               uint32_t *max_power_limit,
+                                               uint32_t *min_power_limit)
 {
        PPTable_t *pptable = smu->smu_table.driver_pptable;
        uint32_t power_limit = 0;
@@ -1160,7 +1161,8 @@ static int aldebaran_get_power_limit(struct smu_context *smu,
                        *default_power_limit = 0;
                if (max_power_limit)
                        *max_power_limit = 0;
-
+               if (min_power_limit)
+                       *min_power_limit = 0;
                dev_warn(smu->adev->dev,
                        "PPT feature is not enabled, power values can't be fetched.");

@@ -1195,6 +1197,9 @@ static int aldebaran_get_power_limit(struct smu_context *smu,
                        *max_power_limit = pptable->PptLimit;
        }

+       if (min_power_limit)
+               *min_power_limit = 0;
+
        return 0;
 }

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
index 4ddaa372604a..851d7f1c6f19 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
@@ -2343,16 +2343,17 @@ static int smu_v13_0_0_enable_mgpu_fan_boost(struct smu_context *smu)  }

 static int smu_v13_0_0_get_power_limit(struct smu_context *smu,
-                                      uint32_t *current_power_limit,
-                                      uint32_t *default_power_limit,
-                                      uint32_t *max_power_limit)
+                                               uint32_t *current_power_limit,
+                                               uint32_t *default_power_limit,
+                                               uint32_t *max_power_limit,
+                                               uint32_t *min_power_limit)
 {
        struct smu_table_context *table_context = &smu->smu_table;
        struct smu_13_0_0_powerplay_table *powerplay_table =
                (struct smu_13_0_0_powerplay_table *)table_context->power_play_table;
        PPTable_t *pptable = table_context->driver_pptable;
        SkuTable_t *skutable = &pptable->SkuTable;
-       uint32_t power_limit, od_percent;
+       uint32_t power_limit, od_percent_upper, od_percent_lower;

        if (smu_v13_0_get_current_power_limit(smu, &power_limit))
                power_limit = smu->adev->pm.ac_power ?
@@ -2364,16 +2365,25 @@ static int smu_v13_0_0_get_power_limit(struct smu_context *smu,
        if (default_power_limit)
                *default_power_limit = power_limit;

-       if (max_power_limit) {
-               if (smu->od_enabled) {
-                       od_percent = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_13_0_0_ODSETTING_POWERPERCENTAGE]);
+       if (smu->od_enabled) {
+               od_percent_upper = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_13_0_0_ODSETTING_POWERPERCENTAGE]);
+               od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_13_0_0_ODSETTING_POWERPERCENTAGE]);
+       } else {
+               od_percent_upper = 0;
+               od_percent_lower = 100;
+       }

-                       dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_percent, power_limit);
+       dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
+                                       od_percent_upper, od_percent_lower, power_limit);

-                       power_limit *= (100 + od_percent);
-                       power_limit /= 100;
-               }
-               *max_power_limit = power_limit;
+       if (max_power_limit) {
+               *max_power_limit = power_limit * (100 + od_percent_upper);
+               *max_power_limit /= 100;
+       }
+
+       if (min_power_limit) {
+               *min_power_limit = power_limit * (100 - od_percent_lower);
+               *min_power_limit /= 100;
        }

        return 0;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 8220bdcbd927..3ea2031c7f7e 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -1242,9 +1242,10 @@ static int smu_v13_0_6_read_sensor(struct smu_context *smu,  }

 static int smu_v13_0_6_get_power_limit(struct smu_context *smu,
-                                      uint32_t *current_power_limit,
-                                      uint32_t *default_power_limit,
-                                      uint32_t *max_power_limit)
+                                               uint32_t *current_power_limit,
+                                               uint32_t *default_power_limit,
+                                               uint32_t *max_power_limit,
+                                               uint32_t *min_power_limit)
 {
        struct smu_table_context *smu_table = &smu->smu_table;
        struct PPTable_t *pptable =
@@ -1268,6 +1269,8 @@ static int smu_v13_0_6_get_power_limit(struct smu_context *smu,
                *max_power_limit = pptable->MaxSocketPowerLimit;
        }

+       if (min_power_limit)
+               *min_power_limit = 0;
        return 0;
 }

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
index 3c5526babb14..ac0e1cc812bd 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
@@ -2304,16 +2304,17 @@ static int smu_v13_0_7_enable_mgpu_fan_boost(struct smu_context *smu)  }

 static int smu_v13_0_7_get_power_limit(struct smu_context *smu,
-                                      uint32_t *current_power_limit,
-                                      uint32_t *default_power_limit,
-                                      uint32_t *max_power_limit)
+                                               uint32_t *current_power_limit,
+                                               uint32_t *default_power_limit,
+                                               uint32_t *max_power_limit,
+                                               uint32_t *min_power_limit)
 {
        struct smu_table_context *table_context = &smu->smu_table;
        struct smu_13_0_7_powerplay_table *powerplay_table =
                (struct smu_13_0_7_powerplay_table *)table_context->power_play_table;
        PPTable_t *pptable = table_context->driver_pptable;
        SkuTable_t *skutable = &pptable->SkuTable;
-       uint32_t power_limit, od_percent;
+       uint32_t power_limit, od_percent_upper, od_percent_lower;

        if (smu_v13_0_get_current_power_limit(smu, &power_limit))
                power_limit = smu->adev->pm.ac_power ?
@@ -2325,16 +2326,25 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu,
        if (default_power_limit)
                *default_power_limit = power_limit;

-       if (max_power_limit) {
-               if (smu->od_enabled) {
-                       od_percent = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_13_0_7_ODSETTING_POWERPERCENTAGE]);
+       if (smu->od_enabled) {
+               od_percent_upper = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_13_0_7_ODSETTING_POWERPERCENTAGE]);
+               od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_13_0_7_ODSETTING_POWERPERCENTAGE]);
+       } else {
+               od_percent_upper = 0;
+               od_percent_lower = 100;
+       }

-                       dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_percent, power_limit);
+       dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
+                                       od_percent_upper, od_percent_lower, power_limit);

-                       power_limit *= (100 + od_percent);
-                       power_limit /= 100;
-               }
-               *max_power_limit = power_limit;
+       if (max_power_limit) {
+               *max_power_limit = power_limit * (100 + od_percent_upper);
+               *max_power_limit /= 100;
+       }
+
+       if (min_power_limit) {
+               *min_power_limit = power_limit * (100 - od_percent_lower);
+               *min_power_limit /= 100;
        }

        return 0;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h
index bcc42abfc768..80b3c3efc006 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_internal.h
@@ -85,7 +85,7 @@
 #define smu_i2c_fini(smu)                                               smu_ppt_funcs(i2c_fini, 0, smu)
 #define smu_get_unique_id(smu)                                         smu_ppt_funcs(get_unique_id, 0, smu)
 #define smu_log_thermal_throttling(smu)                                        smu_ppt_funcs(log_thermal_throttling_event, 0, smu)
-#define smu_get_asic_power_limits(smu, current, default, max)          smu_ppt_funcs(get_power_limit, 0, smu, current, default, max)
+#define smu_get_asic_power_limits(smu, current, default, max, min)             smu_ppt_funcs(get_power_limit, 0, smu, current, default, max, min)
 #define smu_get_pp_feature_mask(smu, buf)                              smu_ppt_funcs(get_pp_feature_mask, 0, smu, buf)
 #define smu_set_pp_feature_mask(smu, new_mask)                         smu_ppt_funcs(set_pp_feature_mask, 0, smu, new_mask)
 #define smu_gfx_ulv_control(smu, enablement)                           smu_ppt_funcs(gfx_ulv_control, 0, smu, enablement)
--
2.34.1





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux