All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexander.deucher@amd.com>
To: amd-gfx@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Xiaomeng Hou <Xiaomeng.Hou@amd.com>,
	Huang Rui <ray.huang@amd.com>
Subject: [PATCH 65/89] drm/amd/pm: add set_performance_level function for yellow carp
Date: Wed,  2 Jun 2021 12:48:44 -0400	[thread overview]
Message-ID: <20210602164908.2848791-65-alexander.deucher@amd.com> (raw)
In-Reply-To: <20210602164908.2848791-1-alexander.deucher@amd.com>

From: Xiaomeng Hou <Xiaomeng.Hou@amd.com>

This patch enables editing sysfs file power_dpm_force_performance_level
for yellow carp. User could thus adjust the dpm forced level.

v2: enable fine grain control of GFXCLK only when in manual performance
level mode. In other mode, the min/max range of GFXCLK will be reset to
corresponding values.

Ex: To enable min 300MHz / max 600MHz gfx clocks

1) echo manual > /sys/bus/pci/devices/.../power_dpm_force_performance_level
2) echo s 0 300 > /sys/bus/pci/devices/.../pp_od_clk_voltage
3) echo s 1 600 > /sys/bus/pci/devices/.../pp_od_clk_voltage
4) echo c > /sys/bus/pci/devices/.../pp_od_clk_voltage

Signed-off-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
index 24dbd4ce4938..ddf56b31a403 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
@@ -602,8 +602,13 @@ static ssize_t yellow_carp_get_gpu_metrics(struct smu_context *smu,
 static int yellow_carp_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABLE_COMMAND type,
 					long input[], uint32_t size)
 {
+	struct smu_dpm_context *smu_dpm = &(smu->smu_dpm);
 	int ret = 0;
 
+	/* Only allowed in manual mode */
+	if (smu_dpm->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL)
+		return -EINVAL;
+
 	switch (type) {
 	case PP_OD_EDIT_SCLK_VDDC_TABLE:
 		if (size != 2) {
@@ -1049,6 +1054,84 @@ static int yellow_carp_force_clk_levels(struct smu_context *smu,
 	return ret;
 }
 
+static int yellow_carp_set_performance_level(struct smu_context *smu,
+						enum amd_dpm_forced_level level)
+{
+	struct amdgpu_device *adev = smu->adev;
+	uint32_t sclk_min = 0, sclk_max = 0;
+	uint32_t mclk_min = 0, mclk_max = 0;
+	uint32_t socclk_min = 0, socclk_max = 0;
+	int ret = 0;
+
+	switch (level) {
+	case AMD_DPM_FORCED_LEVEL_HIGH:
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, NULL, &sclk_max);
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_MCLK, NULL, &mclk_max);
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, NULL, &socclk_max);
+		sclk_min = sclk_max;
+		mclk_min = mclk_max;
+		socclk_min = socclk_max;
+		break;
+	case AMD_DPM_FORCED_LEVEL_LOW:
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, &sclk_min, NULL);
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_MCLK, &mclk_min, NULL);
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, &socclk_min, NULL);
+		sclk_max = sclk_min;
+		mclk_max = mclk_min;
+		socclk_max = socclk_min;
+		break;
+	case AMD_DPM_FORCED_LEVEL_AUTO:
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, &sclk_min, &sclk_max);
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_MCLK, &mclk_min, &mclk_max);
+		yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, &socclk_min, &socclk_max);
+		break;
+	case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD:
+	case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK:
+	case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK:
+	case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK:
+		/* Temporarily do nothing since the optimal clocks haven't been provided yet */
+		break;
+	case AMD_DPM_FORCED_LEVEL_MANUAL:
+	case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT:
+		return 0;
+	default:
+		dev_err(adev->dev, "Invalid performance level %d\n", level);
+		return -EINVAL;
+	}
+
+	if (sclk_min && sclk_max) {
+		ret = yellow_carp_set_soft_freq_limited_range(smu,
+							    SMU_SCLK,
+							    sclk_min,
+							    sclk_max);
+		if (ret)
+			return ret;
+
+		smu->gfx_actual_hard_min_freq = sclk_min;
+		smu->gfx_actual_soft_max_freq = sclk_max;
+	}
+
+	if (mclk_min && mclk_max) {
+		ret = yellow_carp_set_soft_freq_limited_range(smu,
+							    SMU_MCLK,
+							    mclk_min,
+							    mclk_max);
+		if (ret)
+			return ret;
+	}
+
+	if (socclk_min && socclk_max) {
+		ret = yellow_carp_set_soft_freq_limited_range(smu,
+							    SMU_SOCCLK,
+							    socclk_min,
+							    socclk_max);
+		if (ret)
+			return ret;
+	}
+
+	return ret;
+}
+
 static int yellow_carp_set_fine_grain_gfx_freq_parameters(struct smu_context *smu)
 {
 	DpmClocks_t *clk_table = smu->smu_table.clocks_table;
@@ -1088,6 +1171,7 @@ static const struct pptable_funcs yellow_carp_ppt_funcs = {
 	.od_edit_dpm_table = yellow_carp_od_edit_dpm_table,
 	.print_clk_levels = yellow_carp_print_clk_levels,
 	.force_clk_levels = yellow_carp_force_clk_levels,
+	.set_performance_level = yellow_carp_set_performance_level,
 	.set_fine_grain_gfx_freq_parameters = yellow_carp_set_fine_grain_gfx_freq_parameters,
 };
 
-- 
2.31.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2021-06-02 16:51 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 16:47 [PATCH 00/89] Add initial support for Yellow Carp Alex Deucher
2021-06-02 16:47 ` [PATCH 02/89] drm/amdgpu: add yellow carp asic_type enum Alex Deucher
2021-06-02 16:47 ` [PATCH 03/89] drm/amdgpu: add uapi to define yellow carp series Alex Deucher
2021-06-02 16:47 ` [PATCH 04/89] drm/amdgpu: add yellow carp support for gpu_info and ip block setting Alex Deucher
2021-06-02 16:47 ` [PATCH 05/89] drm/amdgpu: add yellow_carp_reg_base_init function for yellow carp (v2) Alex Deucher
2021-06-02 16:47 ` [PATCH 06/89] drm/amdgpu: add nv common ip block support for yellow carp Alex Deucher
2021-06-02 16:47 ` [PATCH 07/89] drm/amdgpu: add yellow carp support for ih block Alex Deucher
2021-06-02 16:47 ` [PATCH 08/89] drm/amdgpu: add gmc v10 supports for yellow carp Alex Deucher
2021-06-02 16:47 ` [PATCH 09/89] drm/amdgpu: support fw load type " Alex Deucher
2021-06-02 16:47 ` [PATCH 10/89] drm/amdgpu: add gfx support " Alex Deucher
2021-06-02 16:47 ` [PATCH 11/89] drm/amdgpu: add sdma " Alex Deucher
2021-06-02 16:47 ` [PATCH 12/89] drm/amdgpu: set ip blocks " Alex Deucher
2021-06-02 16:47 ` [PATCH 13/89] drm/amdkfd: add yellow carp KFD support Alex Deucher
2021-06-02 16:47 ` [PATCH 14/89] drm/amdgpu: support nbio_7_2_1 for yellow carp Alex Deucher
2021-06-02 16:47 ` [PATCH 15/89] drm/admgpu/pm: add smu v13 driver interface header for yellow carp (v3) Alex Deucher
2021-06-02 16:47 ` [PATCH 16/89] drm/amdgpu/pm: add smu v13.0.1 firmware header for yellow carp (V4) Alex Deucher
2021-06-02 16:47 ` [PATCH 17/89] drm/amdgpu/pm: add smu v13.0.1 smc header for yellow carp (v2) Alex Deucher
2021-06-02 16:47 ` [PATCH 18/89] drm/amd/pm: add smu13 ip support for moment(V3) Alex Deucher
2021-06-02 16:47 ` [PATCH 19/89] drm/amd/pm: add yellow_carp_ppt implementation(V3) Alex Deucher
2021-06-02 16:47 ` [PATCH 20/89] drm/amd/pm: partially enable swsmu for yellow carp(V2) Alex Deucher
2021-06-02 16:48 ` [PATCH 21/89] drm/amdgpu: add smu ip block for yellow carp(V3) Alex Deucher
2021-06-02 16:48 ` [PATCH 22/89] drm/amdgpu: add gfx golden settings for yellow carp (v3) Alex Deucher
2021-06-02 16:48 ` [PATCH 23/89] drm/amdgpu: introduce a stolen reserved buffer to protect specific buffer region (v2) Alex Deucher
2021-06-02 16:48 ` [PATCH 24/89] drm/amdgpu: reserved buffer is not needed with ip discovery enabled Alex Deucher
2021-06-02 16:48 ` [PATCH 25/89] drm/amdgpu: add mmhub client support for yellow carp Alex Deucher
2021-06-02 16:48 ` [PATCH 26/89] drm/amdgpu: add psp_v13 " Alex Deucher
2021-06-02 16:48 ` [PATCH 27/89] drm/amdgpu: enable psp_v13 " Alex Deucher
2021-06-02 16:48 ` [PATCH 28/89] drm/amdgpu/pm: set_pp_feature is unsupport " Alex Deucher
2021-06-02 16:48 ` [PATCH 29/89] drm/amdgpu/pm: add set_driver_table_location implementation " Alex Deucher
2021-06-02 16:48 ` [PATCH 30/89] drm/amdgpu: add GFX Clock Gating support " Alex Deucher
2021-06-02 16:48 ` [PATCH 31/89] drm/amdgpu: add MMHUB " Alex Deucher
2021-06-02 16:48 ` [PATCH 32/89] drm/amdgpu: add GFX Power " Alex Deucher
2021-06-02 16:48 ` [PATCH 33/89] drm/amdgpu/pm: enable smu_hw_init " Alex Deucher
2021-06-02 16:48 ` [PATCH 34/89] drm/amdgpu/pm: add gfx_off_control " Alex Deucher
2021-06-02 16:48 ` [PATCH 35/89] drm/amdgpu/pm: enable gfx_off in yellow carp smu post init Alex Deucher
2021-06-02 16:48 ` [PATCH 36/89] drm/amdgpu: add SDMA Clock Gating support for yellow carp Alex Deucher
2021-06-02 16:48 ` [PATCH 37/89] drm/amdgpu: add HDP " Alex Deucher
2021-06-02 16:48 ` [PATCH 38/89] drm/amdgpu: add ATHUB " Alex Deucher
2021-06-02 16:48 ` [PATCH 39/89] drm/amdgpu: add IH " Alex Deucher
2021-06-02 16:48 ` [PATCH 40/89] drm/amd/pm: add vcn/jepg enable functions " Alex Deucher
2021-06-02 16:48 ` [PATCH 41/89] drm/amdgpu/jpeg: Remove harvest checking on CHIP_YELLOW_CARP Alex Deucher
2021-06-02 16:48 ` [PATCH 42/89] drm/amdgpu/vcn: add vcn support for yellow carp Alex Deucher
2021-06-02 16:48 ` [PATCH 43/89] drm/amdgpu: enable vcn/jpeg on " Alex Deucher
2021-06-02 16:48 ` [PATCH 44/89] drm/amdgpu: enable vcn dpg mode " Alex Deucher
2021-06-02 16:48 ` [PATCH 45/89] drm/amdgpu: enable VCN PG and CG for " Alex Deucher
2021-06-02 16:48 ` [PATCH 46/89] drm/amdgpu/pm: support smu_post_init " Alex Deucher
2021-06-02 16:48 ` [PATCH 47/89] drm/amdgpu: add RLC_PG_DELAY_3 " Alex Deucher
2021-06-02 16:48 ` [PATCH 48/89] drm/amdgpu: add timestamp counter query support " Alex Deucher
2021-06-02 16:48 ` [PATCH 49/89] drm/amd/pm: add read_sensor function " Alex Deucher
2021-06-02 16:48 ` [PATCH 50/89] drm/amd/pm: add set_watermarks_table " Alex Deucher
2021-06-02 16:48 ` [PATCH 51/89] drm/amd/pm: add the fine grain tuning " Alex Deucher
2021-06-02 16:48 ` [PATCH 52/89] drm/amd/pm: add support to get dpm clock value " Alex Deucher
2021-06-02 16:48 ` [PATCH 53/89] drm/amd/pm: add feature map " Alex Deucher
2021-06-02 16:48 ` [PATCH 54/89] drm/amd/pm: implement is_dpm_running() callback " Alex Deucher
2021-06-02 16:48 ` [PATCH 55/89] drm/amd/pm: initialize feature_enabled/feature_support bitmap " Alex Deucher
2021-06-02 16:48 ` [PATCH 56/89] drm/amd/pm: add callback force_clk_levels " Alex Deucher
2021-06-02 16:48 ` [PATCH 57/89] drm/amd/pm: add PrepareMp1ForUnload support " Alex Deucher
2021-06-02 16:48 ` [PATCH 58/89] drm/amdgpu: Load TA firmware " Alex Deucher
2021-06-02 16:48 ` [PATCH 59/89] drm/amd/pm: add callback to get bootup values " Alex Deucher
2021-06-02 16:48 ` [PATCH 60/89] drm/amd/pm: add callback get_dpm_ultimate_freq " Alex Deucher
2021-06-02 16:48 ` [PATCH 61/89] drm/amd/pm: add callbacks to read/write sysfs file pp_power_profile_mode Alex Deucher
2021-06-02 16:48 ` [PATCH 62/89] drm/amd/pm: add the interface to dump smu metrics table for yellow carp Alex Deucher
2021-06-02 16:48 ` [PATCH 63/89] drm/amdgpu: add gpu harvest support for yellow carp (v2) Alex Deucher
2021-06-02 16:48 ` [PATCH 64/89] drm/amdgpu: correct the cu and rb info for yellow carp Alex Deucher
2021-06-02 16:48 ` Alex Deucher [this message]
2021-06-02 16:48 ` [PATCH 66/89] drm/amdgpu: add mode2 reset support " Alex Deucher
2021-06-02 16:48 ` [PATCH 67/89] drm/amd/pm: disable manually setting MCLK power level on " Alex Deucher
2021-06-02 16:48 ` [PATCH 68/89] drm/amdgpu: add video_codecs query support for " Alex Deucher
2021-06-02 16:48 ` [PATCH 69/89] drm/amdgpu: Update atomfirmware for DCN3.1 phy tuning and eDP caps Alex Deucher
2021-06-02 16:48 ` [PATCH 70/89] drm/amd/display: Add DCN3.1 yellow carp asic family IDs Alex Deucher
2021-06-02 16:48 ` [PATCH 71/89] drm/amd/display: Add DCN3.1 clock manager support Alex Deucher
2021-06-02 16:48 ` [PATCH 72/89] drm/amd/display: Add DCN3.1 DCCG Alex Deucher
2021-06-02 16:48 ` [PATCH 73/89] drm/amd/display: Add DCN3.1 DIO Alex Deucher
2021-06-02 16:48 ` [PATCH 74/89] drm/amd/display: Add DCN3.1 OPTC Alex Deucher
2021-06-02 16:48 ` [PATCH 75/89] drm/amd/display: Add DCN3.1 DCHHUB Alex Deucher
2021-06-02 16:48 ` [PATCH 76/89] drm/amd/display: Add DCN3.1 DML calculation support Alex Deucher
2021-06-02 16:48 ` [PATCH 77/89] drm/amd/display: Add DCN3.1 IRQ manager Alex Deucher
2021-06-02 16:48 ` [PATCH 78/89] drm/amd/display: Add DCN3.1 GPIO support Alex Deucher
2021-06-02 16:48 ` [PATCH 79/89] drm/amd/display: Add DCN3.1 DMCUB Alex Deucher
2021-06-02 16:48 ` [PATCH 80/89] drm/amd/display: Add DCN3.1 PANEL Alex Deucher
2021-06-02 16:49 ` [PATCH 81/89] drm/amd/display: Add DCN3.1 HDCP support Alex Deucher
2021-06-02 16:49 ` [PATCH 82/89] drm/amd/display: Add DCN3.1 BIOS parser support Alex Deucher
2021-06-02 16:49 ` [PATCH 83/89] drm/amd/display: Add DCN3.1 HWSEQ Alex Deucher
2021-06-02 16:49 ` [PATCH 84/89] drm/amd/display: Add z10 restore checks for DC interfaces Alex Deucher
2021-06-02 16:49 ` [PATCH 85/89] drm/amd/display: Add DCN3.1 Resource Alex Deucher
2021-06-02 16:49 ` [PATCH 86/89] drm/amd/display: Add DCN3.1 blocks to the DC Makefile Alex Deucher
2021-06-02 16:49 ` [PATCH 87/89] drm/amd/display: Add DCN3.1 Yellow Carp support to DM Alex Deucher
2021-06-02 16:49 ` [PATCH 88/89] drm/amd/display: Add DC DCN3.1 support to Kconfig Alex Deucher
2021-06-02 16:49 ` [PATCH 89/89] drm/amdgpu: Add DC support and display block for Yellow Carp Alex Deucher
2021-06-03  6:56 ` [PATCH 00/89] Add initial support " Huang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210602164908.2848791-65-alexander.deucher@amd.com \
    --to=alexander.deucher@amd.com \
    --cc=Xiaomeng.Hou@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.