Skip to contentSkip to conversation

Revert "drm/amdgpu: add sysfs interface to set arbitrary sclk value for navi14"

PATCH In review Chengming Gui 3 participants 7 messages Feb 28, 2020

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

PATCH 1/2 Revert "drm/amdgpu: add sysfs interface to set arbitrary sclk value for navi14"

Revert this commit and than add debugfs interface to replace this to meet the specitic requirement.

This reverts commit 3107269204f8e18f389080673f7848b420970aa5.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c    | 42 -------------------------------
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c |  9 ++-----
 2 files changed, 2 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0 -42
index 9deff8c..bc3cf04 100644
@@ -1034,40 +1034,6 @@ static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask)
 	return 0;
 }
 
-static ssize_t amdgpu_set_pp_sclk(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t count)
-{
-	struct drm_device *ddev = dev_get_drvdata(dev);
-	struct amdgpu_device *adev = ddev->dev_private;
-	int ret;
-	uint32_t value;
-
-	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
-		return -EINVAL;
-
-	ret = pm_runtime_get_sync(ddev->dev);
-	if (ret < 0)
-		return ret;
-
-	ret = kstrtou32(buf, 0, &value);
-	if (ret < 0)
-		return ret;
-	if (is_support_sw_smu(adev))
-		ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, value, value);
-	else
-		return 0;
-
-	pm_runtime_mark_last_busy(ddev->dev);
-	pm_runtime_put_autosuspend(ddev->dev);
-
-	if (ret)
-		return -EINVAL;
-
-	return count;
-}
-
 static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
 		struct device_attribute *attr,
 		const char *buf,
@@ -1829,8 +1795,6 @@ static DEVICE_ATTR(pp_force_state, S_IRUGO | S_IWUSR,
 static DEVICE_ATTR(pp_table, S_IRUGO | S_IWUSR,
 		amdgpu_get_pp_table,
 		amdgpu_set_pp_table);
-static DEVICE_ATTR(pp_sclk, S_IWUSR,
-		NULL, amdgpu_set_pp_sclk);
 static DEVICE_ATTR(pp_dpm_sclk, S_IRUGO | S_IWUSR,
 		amdgpu_get_pp_dpm_sclk,
 		amdgpu_set_pp_dpm_sclk);
@@ -3322,12 +3286,6 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
 		return ret;
 	}
 
-	ret = device_create_file(adev->dev, &dev_attr_pp_sclk);
-	if (ret) {
-		DRM_ERROR("failed to create device file pp_sclk\n");
-		return ret;
-	}
-
 	ret = device_create_file(adev->dev, &dev_attr_pp_dpm_sclk);
 	if (ret) {
 		DRM_ERROR("failed to create device file pp_dpm_sclk\n");
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +2 -7
index 1507bb7..c9e5ce1 100644
@@ -1803,17 +1803,12 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_
 {
 	int ret = 0, clk_id = 0;
 	uint32_t param;
-	uint32_t min_freq, max_freq;
 
 	clk_id = smu_clk_get_index(smu, clk_type);
 	if (clk_id < 0)
 		return clk_id;
 
-	ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq, true);
-	if (ret)
-		return ret;
-
-	if (max > 0 && max <=  max_freq) {
+	if (max > 0) {
 		param = (uint32_t)((clk_id << 16) | (max & 0xffff));
 		ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxByFreq,
 						  param);
@@ -1821,7 +1816,7 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_
 			return ret;
 	}
 
-	if (min > 0 && min >= min_freq) {
+	if (min > 0) {
 		param = (uint32_t)((clk_id << 16) | (min & 0xffff));
 		ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMinByFreq,
 						  param);
Signature · 6 lines
2.7.4

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

PATCH 2/2 drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

add debugfs interface amdgpu_force_sclk
to set arbitrary sclk for navi14

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c    | 44 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  3 ++
 2 files changed, 47 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +44 -0
index 3bb7405..5ee7e92 100644
@@ -1269,9 +1269,43 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
 	return 0;
 }
 
+static int amdgpu_debugfs_sclk_set(void *data, u64 val)
+{
+	int ret = 0;
+	uint32_t max_freq, min_freq;
+	struct amdgpu_device *adev = (struct amdgpu_device *)data;
+
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return -EINVAL;
+
+	ret = pm_runtime_get_sync(adev->ddev->dev);
+	if (ret < 0)
+		return ret;
+
+	if (is_support_sw_smu(adev)) {
+		ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK, &min_freq, &max_freq, true);
+		if (ret || val > max_freq || val < min_freq)
+			return -EINVAL;
+		ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, (uint32_t)val, (uint32_t)val);
+	} else {
+		return 0;
+	}
+
+	pm_runtime_mark_last_busy(adev->ddev->dev);
+	pm_runtime_put_autosuspend(adev->ddev->dev);
+
+	if (ret)
+		return -EINVAL;
+
+	return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
 			amdgpu_debugfs_ib_preempt, "%llu\n");
 
+DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
+			amdgpu_debugfs_sclk_set, "%llu\n");
+
 int amdgpu_debugfs_init(struct amdgpu_device *adev)
 {
 	int r, i;
@@ -1285,6 +1319,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 		return -EIO;
 	}
 
+	adev->smu.debugfs_sclk =
+		debugfs_create_file("amdgpu_force_sclk", 0200,
+				    adev->ddev->primary->debugfs_root, adev,
+				    &fops_sclk_set);
+	if (!(adev->smu.debugfs_sclk)) {
+		DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
+		return -EIO;
+	}
+
 	/* Register debugfs entries for amdgpu_ttm */
 	r = amdgpu_ttm_debugfs_init(adev);
 	if (r) {
@@ -1353,6 +1396,7 @@ void amdgpu_debugfs_fini(struct amdgpu_device *adev)
 	}
 	amdgpu_ttm_debugfs_fini(adev);
 	debugfs_remove(adev->debugfs_preempt);
+	debugfs_remove(adev->smu.debugfs_sclk);
 }
 
 #else
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
index 97b6714..36fe19c 100644
@@ -371,6 +371,9 @@ struct smu_context
 	struct amd_pp_display_configuration  *display_config;
 	struct smu_baco_context		smu_baco;
 	void *od_settings;
+#if defined(CONFIG_DEBUG_FS)
+	struct dentry                   *debugfs_sclk;
+#endif
 
 	uint32_t pstate_sclk;
 	uint32_t pstate_mclk;
Signature · 6 lines
2.7.4

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

RE: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

Please confirm whether smu_set_soft_freq_range() is properly lock protected.

-----Original Message-----
From: Chengming Gui <[email protected]>
Sent: Friday, February 28, 2020 10:37 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

add debugfs interface amdgpu_force_sclk
to set arbitrary sclk for navi14

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c    | 44 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  3 ++
 2 files changed, 47 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +44 -0
index 3bb7405..5ee7e92 100644
@@ -1269,9 +1269,43 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
 	return 0;
 }
 
+static int amdgpu_debugfs_sclk_set(void *data, u64 val)
+{
+	int ret = 0;
+	uint32_t max_freq, min_freq;
+	struct amdgpu_device *adev = (struct amdgpu_device *)data;
+
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return -EINVAL;
+
+	ret = pm_runtime_get_sync(adev->ddev->dev);
+	if (ret < 0)
+		return ret;
+
+	if (is_support_sw_smu(adev)) {
+		ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK, &min_freq, &max_freq, true);
+		if (ret || val > max_freq || val < min_freq)
+			return -EINVAL;
+		ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, (uint32_t)val, (uint32_t)val);
+	} else {
+		return 0;
+	}
+
+	pm_runtime_mark_last_busy(adev->ddev->dev);
+	pm_runtime_put_autosuspend(adev->ddev->dev);
+
+	if (ret)
+		return -EINVAL;
+
+	return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
 			amdgpu_debugfs_ib_preempt, "%llu\n");
 
+DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
+			amdgpu_debugfs_sclk_set, "%llu\n");
+
 int amdgpu_debugfs_init(struct amdgpu_device *adev)
 {
 	int r, i;
@@ -1285,6 +1319,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 		return -EIO;
 	}
 
+	adev->smu.debugfs_sclk =
+		debugfs_create_file("amdgpu_force_sclk", 0200,
+				    adev->ddev->primary->debugfs_root, adev,
+				    &fops_sclk_set);
+	if (!(adev->smu.debugfs_sclk)) {
+		DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
+		return -EIO;
+	}
+
 	/* Register debugfs entries for amdgpu_ttm */
 	r = amdgpu_ttm_debugfs_init(adev);
 	if (r) {
@@ -1353,6 +1396,7 @@ void amdgpu_debugfs_fini(struct amdgpu_device *adev)
 	}
 	amdgpu_ttm_debugfs_fini(adev);
 	debugfs_remove(adev->debugfs_preempt);
+	debugfs_remove(adev->smu.debugfs_sclk);
 }
 
 #else
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
index 97b6714..36fe19c 100644
@@ -371,6 +371,9 @@ struct smu_context
 	struct amd_pp_display_configuration  *display_config;
 	struct smu_baco_context		smu_baco;
 	void *od_settings;
+#if defined(CONFIG_DEBUG_FS)
+	struct dentry                   *debugfs_sclk;
+#endif
 
 	uint32_t pstate_sclk;
 	uint32_t pstate_mclk;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

RE: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

[AMD Official Use Only - Internal Distribution Only]

Hi Evan,

No lock is created for smu_set_soft_freq_range() in this code path.
But some other sysfs interfaces calling smu_set_soft_freq_range() indirectly
have created lock in middle function to protect smu_set_soft_freq_range() as critical resource. So, if we want to lock the "issue message action" in smu_set_soft_freq_range(), another patch is needed.

BR,
Jack

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Friday, February 28, 2020 11:37 AM
To: Gui, Jack <[email protected]>; [email protected]
Cc: Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

Please confirm whether smu_set_soft_freq_range() is properly lock protected.

-----Original Message-----
From: Chengming Gui <[email protected]>
Sent: Friday, February 28, 2020 10:37 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

add debugfs interface amdgpu_force_sclk
to set arbitrary sclk for navi14

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c    | 44 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  3 ++
 2 files changed, 47 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +43 -0
index 3bb7405..5ee7e92 100644
@@ -1269,9 +1269,43 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
 	return 0;
 }
 
+static int amdgpu_debugfs_sclk_set(void *data, u64 val) {
+	int ret = 0;
+	uint32_t max_freq, min_freq;
+	struct amdgpu_device *adev = (struct amdgpu_device *)data;
+
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return -EINVAL;
+
+	ret = pm_runtime_get_sync(adev->ddev->dev);
+	if (ret < 0)
+		return ret;
+
+	if (is_support_sw_smu(adev)) {
+		ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK, &min_freq, &max_freq, true);
+		if (ret || val > max_freq || val < min_freq)
+			return -EINVAL;
+		ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, (uint32_t)val, (uint32_t)val);
+	} else {
+		return 0;
+	}
+
+	pm_runtime_mark_last_busy(adev->ddev->dev);
+	pm_runtime_put_autosuspend(adev->ddev->dev);
+
+	if (ret)
+		return -EINVAL;
+
+	return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
 			amdgpu_debugfs_ib_preempt, "%llu\n");
 
+DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
+			amdgpu_debugfs_sclk_set, "%llu\n");
+
 int amdgpu_debugfs_init(struct amdgpu_device *adev)  {
 	int r, i;
@@ -1285,6 +1319,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 		return -EIO;
 	}
 
+	adev->smu.debugfs_sclk =
+		debugfs_create_file("amdgpu_force_sclk", 0200,
+				    adev->ddev->primary->debugfs_root, adev,
+				    &fops_sclk_set);
+	if (!(adev->smu.debugfs_sclk)) {
+		DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
+		return -EIO;
+	}
+
 	/* Register debugfs entries for amdgpu_ttm */
 	r = amdgpu_ttm_debugfs_init(adev);
 	if (r) {
@@ -1353,6 +1396,7 @@ void amdgpu_debugfs_fini(struct amdgpu_device *adev)
 	}
 	amdgpu_ttm_debugfs_fini(adev);
 	debugfs_remove(adev->debugfs_preempt);
+	debugfs_remove(adev->smu.debugfs_sclk);
 }
 
 #else
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
index 97b6714..36fe19c 100644
@@ -371,6 +371,9 @@ struct smu_context
 	struct amd_pp_display_configuration  *display_config;
 	struct smu_baco_context		smu_baco;
 	void *od_settings;
+#if defined(CONFIG_DEBUG_FS)
+	struct dentry                   *debugfs_sclk;
+#endif
 
 	uint32_t pstate_sclk;
 	uint32_t pstate_mclk;

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

#4 lore raw

RE: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

Please add proper lock in smu_set_soft_freq_range() then.
You can do necessary modification to existing code paths.
Otherwise without lock protection, you may run into race condition on the new debugfs intrace(amdgpu_debugfs_sclk_set) called by multiple instances.

-----Original Message-----
From: Gui, Jack <[email protected]>
Sent: Friday, February 28, 2020 12:35 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

[AMD Official Use Only - Internal Distribution Only]

Hi Evan,

No lock is created for smu_set_soft_freq_range() in this code path.
But some other sysfs interfaces calling smu_set_soft_freq_range() indirectly have created lock in middle function to protect smu_set_soft_freq_range() as critical resource. So, if we want to lock the "issue message action" in smu_set_soft_freq_range(), another patch is needed.

BR,
Jack

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Friday, February 28, 2020 11:37 AM
To: Gui, Jack <[email protected]>; [email protected]
Cc: Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

Please confirm whether smu_set_soft_freq_range() is properly lock protected.

-----Original Message-----
From: Chengming Gui <[email protected]>
Sent: Friday, February 28, 2020 10:37 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Add debugfs interface to set arbitrary sclk for navi14

add debugfs interface amdgpu_force_sclk
to set arbitrary sclk for navi14

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c    | 44 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  3 ++
 2 files changed, 47 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +43 -0
index 3bb7405..5ee7e92 100644
@@ -1269,9 +1269,43 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
 	return 0;
 }
 
+static int amdgpu_debugfs_sclk_set(void *data, u64 val) {
+	int ret = 0;
+	uint32_t max_freq, min_freq;
+	struct amdgpu_device *adev = (struct amdgpu_device *)data;
+
+	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		return -EINVAL;
+
+	ret = pm_runtime_get_sync(adev->ddev->dev);
+	if (ret < 0)
+		return ret;
+
+	if (is_support_sw_smu(adev)) {
+		ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK, &min_freq, &max_freq, true);
+		if (ret || val > max_freq || val < min_freq)
+			return -EINVAL;
+		ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, (uint32_t)val, (uint32_t)val);
+	} else {
+		return 0;
+	}
+
+	pm_runtime_mark_last_busy(adev->ddev->dev);
+	pm_runtime_put_autosuspend(adev->ddev->dev);
+
+	if (ret)
+		return -EINVAL;
+
+	return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
 			amdgpu_debugfs_ib_preempt, "%llu\n");
 
+DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
+			amdgpu_debugfs_sclk_set, "%llu\n");
+
 int amdgpu_debugfs_init(struct amdgpu_device *adev)  {
 	int r, i;
@@ -1285,6 +1319,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 		return -EIO;
 	}
 
+	adev->smu.debugfs_sclk =
+		debugfs_create_file("amdgpu_force_sclk", 0200,
+				    adev->ddev->primary->debugfs_root, adev,
+				    &fops_sclk_set);
+	if (!(adev->smu.debugfs_sclk)) {
+		DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
+		return -EIO;
+	}
+
 	/* Register debugfs entries for amdgpu_ttm */
 	r = amdgpu_ttm_debugfs_init(adev);
 	if (r) {
@@ -1353,6 +1396,7 @@ void amdgpu_debugfs_fini(struct amdgpu_device *adev)
 	}
 	amdgpu_ttm_debugfs_fini(adev);
 	debugfs_remove(adev->debugfs_preempt);
+	debugfs_remove(adev->smu.debugfs_sclk);
 }
 
 #else
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
index 97b6714..36fe19c 100644
@@ -371,6 +371,9 @@ struct smu_context
 	struct amd_pp_display_configuration  *display_config;
 	struct smu_baco_context		smu_baco;
 	void *od_settings;
+#if defined(CONFIG_DEBUG_FS)
+	struct dentry                   *debugfs_sclk;
+#endif
 
 	uint32_t pstate_sclk;
 	uint32_t pstate_mclk;

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

Reviewed-by on v1 1/2
#5 lore raw
In reply to Chengming Gui

-----Original Message-----
From: Chengming Gui <[email protected]>
Sent: Friday, February 28, 2020 10:37 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: [PATCH 1/2] Revert "drm/amdgpu: add sysfs interface to set arbitrary sclk value for navi14"

Revert this commit and than add debugfs interface to replace this to meet the specitic requirement.

This reverts commit 3107269204f8e18f389080673f7848b420970aa5.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c    | 42 -------------------------------
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c |  9 ++-----
 2 files changed, 2 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0 -42
index 9deff8c..bc3cf04 100644
@@ -1034,40 +1034,6 @@ static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask)
 	return 0;
 }
 
-static ssize_t amdgpu_set_pp_sclk(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t count)
-{
-	struct drm_device *ddev = dev_get_drvdata(dev);
-	struct amdgpu_device *adev = ddev->dev_private;
-	int ret;
-	uint32_t value;
-
-	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
-		return -EINVAL;
-
-	ret = pm_runtime_get_sync(ddev->dev);
-	if (ret < 0)
-		return ret;
-
-	ret = kstrtou32(buf, 0, &value);
-	if (ret < 0)
-		return ret;
-	if (is_support_sw_smu(adev))
-		ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, value, value);
-	else
-		return 0;
-
-	pm_runtime_mark_last_busy(ddev->dev);
-	pm_runtime_put_autosuspend(ddev->dev);
-
-	if (ret)
-		return -EINVAL;
-
-	return count;
-}
-
 static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
 		struct device_attribute *attr,
 		const char *buf,
@@ -1829,8 +1795,6 @@ static DEVICE_ATTR(pp_force_state, S_IRUGO | S_IWUSR,  static DEVICE_ATTR(pp_table, S_IRUGO | S_IWUSR,
 		amdgpu_get_pp_table,
 		amdgpu_set_pp_table);
-static DEVICE_ATTR(pp_sclk, S_IWUSR,
-		NULL, amdgpu_set_pp_sclk);
 static DEVICE_ATTR(pp_dpm_sclk, S_IRUGO | S_IWUSR,
 		amdgpu_get_pp_dpm_sclk,
 		amdgpu_set_pp_dpm_sclk);
@@ -3322,12 +3286,6 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
 		return ret;
 	}
 
-	ret = device_create_file(adev->dev, &dev_attr_pp_sclk);
-	if (ret) {
-		DRM_ERROR("failed to create device file pp_sclk\n");
-		return ret;
-	}
-
 	ret = device_create_file(adev->dev, &dev_attr_pp_dpm_sclk);
 	if (ret) {
 		DRM_ERROR("failed to create device file pp_dpm_sclk\n"); diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c

index 1507bb7..c9e5ce1 100644

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +2 -7
@@ -1803,17 +1803,12 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_  {
 	int ret = 0, clk_id = 0;
 	uint32_t param;
-	uint32_t min_freq, max_freq;
 
 	clk_id = smu_clk_get_index(smu, clk_type);
 	if (clk_id < 0)
 		return clk_id;
 
-	ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq, true);
-	if (ret)
-		return ret;
-
-	if (max > 0 && max <=  max_freq) {
+	if (max > 0) {
 		param = (uint32_t)((clk_id << 16) | (max & 0xffff));
 		ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxByFreq,
 						  param);
@@ -1821,7 +1816,7 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_
 			return ret;
 	}
 
-	if (min > 0 && min >= min_freq) {
+	if (min > 0) {
 		param = (uint32_t)((clk_id << 16) | (min & 0xffff));
 		ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMinByFreq,
 						  param);

--
2.7.4

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

maintainer Reviewed-by Evan Quan
#6 lore raw

[AMD Public Use]

Please also revert this fix:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-next&id=4e261b86437af7481364a5239c62cc3c5ef0ee38

Alex
________________________________
From: amd-gfx <[email protected]> on behalf of Quan, Evan <[email protected]>
Sent: Thursday, February 27, 2020 10:37 PM
To: Gui, Jack <[email protected]>; [email protected] <[email protected]>
Cc: Xu, Feifei <[email protected]>; Feng, Kenneth <[email protected]>; Gui, Jack <[email protected]>
Subject: RE: [PATCH 1/2] Revert "drm/amdgpu: add sysfs interface to set arbitrary sclk value for navi14"

-----Original Message-----
From: Chengming Gui <[email protected]>
Sent: Friday, February 28, 2020 10:37 AM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Xu, Feifei <[email protected]>; Gui, Jack <[email protected]>
Subject: [PATCH 1/2] Revert "drm/amdgpu: add sysfs interface to set arbitrary sclk value for navi14"

Revert this commit and than add debugfs interface to replace this to meet the specitic requirement.

This reverts commit 3107269204f8e18f389080673f7848b420970aa5.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c    | 42 -------------------------------
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c |  9 ++-----
 2 files changed, 2 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0 -42
index 9deff8c..bc3cf04 100644
@@ -1034,40 +1034,6 @@ static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask)
         return 0;
 }
 
-static ssize_t amdgpu_set_pp_sclk(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t count)
-{
-       struct drm_device *ddev = dev_get_drvdata(dev);
-       struct amdgpu_device *adev = ddev->dev_private;
-       int ret;
-       uint32_t value;
-
-       if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
-               return -EINVAL;
-
-       ret = pm_runtime_get_sync(ddev->dev);
-       if (ret < 0)
-               return ret;
-
-       ret = kstrtou32(buf, 0, &value);
-       if (ret < 0)
-               return ret;
-       if (is_support_sw_smu(adev))
-               ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, value, value);
-       else
-               return 0;
-
-       pm_runtime_mark_last_busy(ddev->dev);
-       pm_runtime_put_autosuspend(ddev->dev);
-
-       if (ret)
-               return -EINVAL;
-
-       return count;
-}
-
 static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
                 struct device_attribute *attr,
                 const char *buf,
@@ -1829,8 +1795,6 @@ static DEVICE_ATTR(pp_force_state, S_IRUGO | S_IWUSR,  static DEVICE_ATTR(pp_table, S_IRUGO | S_IWUSR,
                 amdgpu_get_pp_table,
                 amdgpu_set_pp_table);
-static DEVICE_ATTR(pp_sclk, S_IWUSR,
-               NULL, amdgpu_set_pp_sclk);
 static DEVICE_ATTR(pp_dpm_sclk, S_IRUGO | S_IWUSR,
                 amdgpu_get_pp_dpm_sclk,
                 amdgpu_set_pp_dpm_sclk);
@@ -3322,12 +3286,6 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
                 return ret;
         }
 
-       ret = device_create_file(adev->dev, &dev_attr_pp_sclk);
-       if (ret) {
-               DRM_ERROR("failed to create device file pp_sclk\n");
-               return ret;
-       }
-
         ret = device_create_file(adev->dev, &dev_attr_pp_dpm_sclk);
         if (ret) {
                 DRM_ERROR("failed to create device file pp_dpm_sclk\n"); diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c

index 1507bb7..c9e5ce1 100644

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +2 -7
@@ -1803,17 +1803,12 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_  {
         int ret = 0, clk_id = 0;
         uint32_t param;
-       uint32_t min_freq, max_freq;
 
         clk_id = smu_clk_get_index(smu, clk_type);
         if (clk_id < 0)
                 return clk_id;
 
-       ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq, true);
-       if (ret)
-               return ret;
-
-       if (max > 0 && max <=  max_freq) {
+       if (max > 0) {
                 param = (uint32_t)((clk_id << 16) | (max & 0xffff));
                 ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxByFreq,
                                                   param);
@@ -1821,7 +1816,7 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_
                         return ret;
         }
 
-       if (min > 0 && min >= min_freq) {
+       if (min > 0) {
                 param = (uint32_t)((clk_id << 16) | (min & 0xffff));
                 ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMinByFreq,
                                                   param);

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Calexander.deucher%40amd.com%7C86a8aed9b2854f38626908d7bbff8780%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637184578512568577&amp;sdata=O1zVjtLbL6JRjrWzN23MARS6NlM8kUjLd3%2BKuxQOVbI%3D&amp;reserved=0

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