Skip to contentSkip to conversation

drm/amd/powerplay: remove mutex lock for smu_handle_task when smu late init

PATCH In review Chengming Gui 2 participants 6 messages Jul 18, 2019 – Jul 19, 2019 3 messages not in the archive

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

PATCH 1/3 drm/amd/powerplay: remove mutex lock for smu_handle_task when smu late init

remove mutex lock when smu late init to call smu_handle_task

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +0 -2
index 7d1bd09..122985c 100644
@@ -569,11 +569,9 @@ static int smu_late_init(void *handle)
 
 	if (!smu->pm_enabled)
 		return 0;
-	mutex_lock(&smu->mutex);
 	smu_handle_task(&adev->smu,
 			smu->smu_dpm.dpm_level,
 			AMD_PP_TASK_COMPLETE_INIT);
-	mutex_unlock(&smu->mutex);
 
 	return 0;
 }
Signature · 6 lines
2.7.4

_______________________________________________
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): 1563444138-23948-1-git-send-email-Jack.Gui-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/3 drm/amd/powerplay: force sclk limit for peak profile

force different GFX clocks with different SKUs for navi10:

XL  (other rev_id):  1625MHz
XT         (F1/C1):  1755MHz
XTX        (F0/C0):  1830MHz
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     |  2 +
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  2 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c     | 66 +++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
index 122985c..693414f 100644
@@ -664,6 +664,8 @@ static int smu_sw_init(void *handle)
 	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;
+	smu->smu_dpm.default_sclk_limit = 0;
+	smu->smu_dpm.peak_sclk_limit = 0;
 
 	smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
 	smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
index 135a323..acb522b 100644
@@ -441,6 +441,8 @@ struct smu_dpm_context {
 	void *dpm_context;
 	void *golden_dpm_context;
 	bool enable_umd_pstate;
+	uint32_t default_sclk_limit;
+	uint32_t peak_sclk_limit;
 	enum amd_dpm_forced_level dpm_level;
 	enum amd_dpm_forced_level saved_dpm_level;
 	enum amd_dpm_forced_level requested_dpm_level;
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +64 -2

121 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
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): 1563444138-23948-2-git-send-email-Jack.Gui-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile

1. In navi10_force_clk_levels, i think you need to compare the max level user requested with the peak limit and set the smaller one.
2. can you help me to understand why the change in apply_clock_rules is needed?

________________________________
发件人: amd-gfx <[email protected]> 代表 Chengming Gui <[email protected]> 发送时间: Thursday, July 18, 2019 6:02:17 PM
收件人: [email protected] <[email protected]>
抄送: Gui, Jack <[email protected]>
主题: [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile

force different GFX clocks with different SKUs for navi10:

XL  (other rev_id):  1625MHz
XT         (F1/C1):  1755MHz
XTX        (F0/C0):  1830MHz
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     |  2 +
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  2 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c     | 66 +++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
index 122985c..693414f 100644
@@ -664,6 +664,8 @@ static int smu_sw_init(void *handle)
         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;
+       smu->smu_dpm.default_sclk_limit = 0;
+       smu->smu_dpm.peak_sclk_limit = 0;
 
         smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
         smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
index 135a323..acb522b 100644
@@ -441,6 +441,8 @@ struct smu_dpm_context {
         void *dpm_context;
         void *golden_dpm_context;
         bool enable_umd_pstate;
+       uint32_t default_sclk_limit;
+       uint32_t peak_sclk_limit;
         enum amd_dpm_forced_level dpm_level;
         enum amd_dpm_forced_level saved_dpm_level;
         enum amd_dpm_forced_level requested_dpm_level;
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +64 -2

121 lines not on this page · raw message

--
2.7.4

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

_______________________________________________
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): MN2PR12MB3344FFA5D4975E0D66F98301E4C80-rweVpJHSKToDMgCC8P//[email protected]

author
#6 lore raw

RE: [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile

Hi Evan,
1, The hack hard code was just served for profile_peak mode and (max_count - 1) level always used for GFX clock, we just force the limit value with data from tool team. 2, The requirement from tool team is to force GFX clock limit value with different SKU’s clocks when enter profile peak mode, so the hack code was added when clock adjust rules was applied.

From: Quan, Evan <[email protected]>
Sent: Thursday, July 18, 2019 6:32 PM
To: Gui, Jack <[email protected]>; [email protected]
Cc: Gui, Jack <[email protected]>
Subject: Re: [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile

1. In navi10_force_clk_levels, i think you need to compare the max level user requested with the peak limit and set the smaller one.
2. can you help me to understand why the change in apply_clock_rules is needed?

________________________________
发件人: amd-gfx <[email protected]<mailto:[email protected]>> 代表 Chengming Gui <[email protected]<mailto:[email protected]>> 发送时间: Thursday, July 18, 2019 6:02:17 PM
收件人: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> 抄送: Gui, Jack <[email protected]<mailto:[email protected]>>
主题: [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile

force different GFX clocks with different SKUs for navi10:

XL  (other rev_id):  1625MHz
XT         (F1/C1):  1755MHz
XTX        (F0/C0):  1830MHz
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     |  2 +
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  2 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c     | 66 +++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
index 122985c..693414f 100644
@@ -664,6 +664,8 @@ static int smu_sw_init(void *handle)
         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;
+       smu->smu_dpm.default_sclk_limit = 0;
+       smu->smu_dpm.peak_sclk_limit = 0;
 
         smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
         smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
index 135a323..acb522b 100644
@@ -441,6 +441,8 @@ struct smu_dpm_context {
         void *dpm_context;
         void *golden_dpm_context;
         bool enable_umd_pstate;
+       uint32_t default_sclk_limit;
+       uint32_t peak_sclk_limit;
         enum amd_dpm_forced_level dpm_level;
         enum amd_dpm_forced_level saved_dpm_level;
         enum amd_dpm_forced_level requested_dpm_level;
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +64 -2

121 lines not on this page · raw message

--
2.7.4

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

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

#7 lore raw

PATCH 3/3 drm/amd/powerplay: add mutex lock to protect dpm context resource

In reply to a message not in the archive

add mutex lock to protect dpm context resource

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     | 5 +++--
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c     | 8 ++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +3 -2
index 693414f..ac01960 100644
@@ -664,6 +664,7 @@ static int smu_sw_init(void *handle)
 	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;
+	mutex_init(&smu->smu_dpm.mutex);
 	smu->smu_dpm.default_sclk_limit = 0;
 	smu->smu_dpm.peak_sclk_limit = 0;
 
@@ -1471,9 +1472,9 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu)
 	if (!smu_dpm_ctx->dpm_context)
 		return -EINVAL;
 
-	mutex_lock(&(smu->mutex));
+	mutex_lock(&(smu_dpm_ctx->mutex));
 	level = smu_dpm_ctx->dpm_level;
-	mutex_unlock(&(smu->mutex));
+	mutex_unlock(&(smu_dpm_ctx->mutex));
 
 	return level;
 }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
index acb522b..b6fcad2 100644
@@ -449,6 +449,7 @@ struct smu_dpm_context {
 	struct smu_power_state *dpm_request_power_state;
 	struct smu_power_state *dpm_current_power_state;
 	struct mclock_latency_table *mclk_latency_table;
+	struct mutex mutex;
 };
 
 struct smu_power_gate {
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +8 -0
index b4deb9e..2079097 100644
@@ -693,7 +693,9 @@ static int navi10_force_clk_levels(struct smu_context *smu,
 	case SMU_GFXCLK:
 	case SMU_SCLK:
 		if (smu_dpm_ctx->peak_sclk_limit) {
+			mutex_lock(&smu_dpm_ctx->mutex);
 			max_freq = smu_dpm_ctx->peak_sclk_limit;
+			mutex_unlock(&smu_dpm_ctx->mutex);
 			ret = smu_get_dpm_freq_by_index(smu, clk_type, soft_min_level, &min_freq);
 			if (ret)
 				return size;
@@ -878,7 +880,9 @@ static int navi10_unforce_dpm_levels(struct smu_context *smu)
 			return ret;
 
 		if (clk_type == SMU_GFXCLK && smu_dpm_ctx->default_sclk_limit != 0) {
+			mutex_lock(&smu_dpm_ctx->mutex);
 			max_freq = smu_dpm_ctx->default_sclk_limit;
+			mutex_unlock(&smu_dpm_ctx->mutex);
 			ret = smu_get_dpm_freq_range(smu, SMU_GFXCLK,
 						     &min_freq, NULL);
 			if (ret)
@@ -888,7 +892,9 @@ static int navi10_unforce_dpm_levels(struct smu_context *smu)
 		if (ret)
 			return ret;
 	}
+	mutex_lock(&smu_dpm_ctx->mutex);
 	smu_dpm_ctx->peak_sclk_limit = 0;
+	mutex_unlock(&smu_dpm_ctx->mutex);
 
 	return ret;
 }
@@ -1571,6 +1577,7 @@ static int navi10_apply_clocks_adjust_rules(struct smu_context *smu)
 	struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
 	struct amdgpu_device *adev = smu->adev;
 
+	mutex_lock(&smu_dpm_ctx->mutex);
 	if (smu_dpm_ctx->default_sclk_limit == 0) {
 		ret = smu_get_dpm_freq_range(smu, SMU_SCLK, NULL,
 					     &smu_dpm_ctx->default_sclk_limit);
@@ -1588,6 +1595,7 @@ static int navi10_apply_clocks_adjust_rules(struct smu_context *smu)
 	} else if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && smu_dpm_ctx->peak_sclk_limit != 0) {
 		smu_dpm_ctx->peak_sclk_limit = 0;
 	}
+	mutex_unlock(&smu_dpm_ctx->mutex);
 
 	return 0;
 }
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#8 lore raw
In reply to a message not in the archive

please hold on the mutex changes of patch1 and patch3. We need an overall thought over the smu mutex machinsim. Let us have some internal discussions first.

________________________________
发件人: amd-gfx <[email protected]> 代表 Chengming Gui <[email protected]> 发送时间: Thursday, July 18, 2019 6:02:16 PM
收件人: [email protected] <[email protected]>
抄送: Gui, Jack <[email protected]>
主题: [PATCH 1/3] drm/amd/powerplay: remove mutex lock for smu_handle_task when smu late init

remove mutex lock when smu late init to call smu_handle_task

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +0 -2
index 7d1bd09..122985c 100644
@@ -569,11 +569,9 @@ static int smu_late_init(void *handle)
 
         if (!smu->pm_enabled)
                 return 0;
-       mutex_lock(&smu->mutex);
         smu_handle_task(&adev->smu,
                         smu->smu_dpm.dpm_level,
                         AMD_PP_TASK_COMPLETE_INIT);
-       mutex_unlock(&smu->mutex);
 
         return 0;
 }

--
2.7.4

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

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