All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Likun Gao <Likun.Gao-5C7GfCeVMHo@public.gmane.org>,
	Kevin Wang <Kevin1.Wang-5C7GfCeVMHo@public.gmane.org>,
	Chengming Gui <Jack.Gui-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 21/26] drm/amd/powerplay: support sysfs to set/get pcie
Date: Mon, 25 Feb 2019 20:12:27 +0800	[thread overview]
Message-ID: <1551096752-18205-22-git-send-email-ray.huang@amd.com> (raw)
In-Reply-To: <1551096752-18205-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>

From: Likun Gao <Likun.Gao@amd.com>

Add sys interface to set and get pcie info for smu.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Gui Chengming <Jack.Gui@amd.com>
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 38 ++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index e564948..8ea44b7 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -35,6 +35,10 @@
 #include "vega20_ppt.h"
 #include "vega20_pptable.h"
 #include "vega20_ppsmc.h"
+#include "nbio/nbio_7_4_sh_mask.h"
+
+#define smnPCIE_LC_SPEED_CNTL			0x11140290
+#define smnPCIE_LC_LINK_WIDTH_CNTL		0x11140288
 
 #define MSG_MAP(msg, index) \
 	[SMU_MSG_##msg] = index
@@ -719,6 +723,8 @@ static int vega20_print_clk_levels(struct smu_context *smu,
 {
 	int i, now, size = 0;
 	int ret = 0;
+	uint32_t gen_speed, lane_width;
+	struct amdgpu_device *adev = smu->adev;
 	struct pp_clock_levels_with_latency clocks;
 	struct vega20_single_dpm_table *single_dpm_table;
 	struct smu_table_context *table_context = &smu->smu_table;
@@ -728,6 +734,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
 		(struct vega20_od8_settings *)table_context->od8_settings;
 	OverDriveTable_t *od_table =
 		(OverDriveTable_t *)(table_context->overdrive_table);
+	PPTable_t *pptable = (PPTable_t *)table_context->driver_pptable;
 
 	dpm_table = smu_dpm->dpm_context;
 
@@ -831,6 +838,28 @@ static int vega20_print_clk_levels(struct smu_context *smu,
 		break;
 
 	case PP_PCIE:
+		gen_speed = (RREG32_PCIE(smnPCIE_LC_SPEED_CNTL) &
+			     PSWUSP0_PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK)
+			>> PSWUSP0_PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT;
+		lane_width = (RREG32_PCIE(smnPCIE_LC_LINK_WIDTH_CNTL) &
+			      PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD_MASK)
+			>> PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD__SHIFT;
+		for (i = 0; i < NUM_LINK_LEVELS; i++)
+			size += sprintf(buf + size, "%d: %s %s %dMhz %s\n", i,
+					(pptable->PcieGenSpeed[i] == 0) ? "2.5GT/s," :
+					(pptable->PcieGenSpeed[i] == 1) ? "5.0GT/s," :
+					(pptable->PcieGenSpeed[i] == 2) ? "8.0GT/s," :
+					(pptable->PcieGenSpeed[i] == 3) ? "16.0GT/s," : "",
+					(pptable->PcieLaneCount[i] == 1) ? "x1" :
+					(pptable->PcieLaneCount[i] == 2) ? "x2" :
+					(pptable->PcieLaneCount[i] == 3) ? "x4" :
+					(pptable->PcieLaneCount[i] == 4) ? "x8" :
+					(pptable->PcieLaneCount[i] == 5) ? "x12" :
+					(pptable->PcieLaneCount[i] == 6) ? "x16" : "",
+					pptable->LclkFreq[i],
+					(gen_speed == pptable->PcieGenSpeed[i]) &&
+					(lane_width == pptable->PcieLaneCount[i]) ?
+					"*" : "");
 		break;
 
 	case OD_SCLK:
@@ -1171,6 +1200,15 @@ static int vega20_force_clk_levels(struct smu_context *smu,
 		break;
 
 	case PP_PCIE:
+		if (soft_min_level >= NUM_LINK_LEVELS ||
+		    soft_max_level >= NUM_LINK_LEVELS)
+			return -EINVAL;
+
+		ret = smu_send_smc_msg_with_param(smu,
+				SMU_MSG_SetMinLinkDpmByIndex, soft_min_level);
+		if (ret)
+			pr_err("Failed to set min link dpm level!\n");
+
 		break;
 
 	default:
-- 
2.7.4

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

  parent reply	other threads:[~2019-02-25 12:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 12:12 [PATCH 00/26] Updates for SW SMU driver Huang Rui
     [not found] ` <1551096752-18205-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2019-02-25 12:12   ` [PATCH 01/26] drm/amd/powerplay: debugfs don't check powerplay when SW SMU is enabled Huang Rui
2019-02-25 12:12   ` [PATCH 02/26] drm/amd/powerplay: add fan rpm limit interface for hwmon Huang Rui
2019-02-25 12:12   ` [PATCH 03/26] drm/amd/powerplay: add fan input " Huang Rui
2019-02-25 12:12   ` [PATCH 04/26] drm/amd/powerplay: implement power1_cap and power1_cap_max interface for SMU11 Huang Rui
     [not found]     ` <1551096752-18205-5-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2019-02-26  3:55       ` Alex Deucher
2019-02-25 12:12   ` [PATCH 05/26] drm/amd/powerplay: add STABLE_PSTATE_SCLK and STABLE_PSTATE_MCLK when read sensor " Huang Rui
2019-02-25 12:12   ` [PATCH 06/26] drm/amd/powerplay: implement pwm1 hwmon interface " Huang Rui
2019-02-25 12:12   ` [PATCH 07/26] drm/amd/powerplay: implement pwm1_enable " Huang Rui
     [not found]     ` <1551096752-18205-8-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2019-02-26  3:58       ` Alex Deucher
     [not found]         ` <CADnq5_Oaq7mh6V-SyrS72Zgm9wsWosP86-ZPJ-10X2hnq7xgPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-02-26  5:40           ` Huang, Ray
2019-02-25 12:12   ` [PATCH 08/26] drm/amd/powerplay: implement fan1_enable hwmon interface for SMU11 (v2) Huang Rui
     [not found]     ` <1551096752-18205-9-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2019-02-26  3:59       ` Alex Deucher
2019-02-25 12:12   ` [PATCH 09/26] drm/amd/powerplay: set fan target interface for hwmon Huang Rui
2019-02-25 12:12   ` [PATCH 10/26] drm/amd/powerplay: get eclk/vclk/dclk for smu11 Huang Rui
2019-02-25 12:12   ` [PATCH 11/26] drm/amd/powerplay: set dpm table of vclk/dclk/eclk for smu11 (v2) Huang Rui
2019-02-25 12:12   ` [PATCH 12/26] drm/amd/powerplay: add smu_late_init for SMU11 Huang Rui
2019-02-25 12:12   ` [PATCH 13/26] drm/amd/powerplay: add limit of pp_feature for smu Huang Rui
     [not found]     ` <1551096752-18205-14-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2019-02-26  4:08       ` Alex Deucher
     [not found]         ` <CADnq5_PtdOYSk_FYAb9cQTn7mCkEZuvi8xocPWuW0Eb8OvepzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-02-26  6:01           ` Huang, Ray
     [not found]             ` <MN2PR12MB33093B43C19D5C0D2DBD2E2CEC7B0-rweVpJHSKTpWdvXm18W95QdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-02-26  6:44               ` Gao, Likun
2019-02-25 12:12   ` [PATCH 14/26] drm/amd/powerplay: add od condition for power limit Huang Rui
2019-02-25 12:12   ` [PATCH 15/26] drm/amd/powerplay: add is_dpm_running for SMU11 Huang Rui
2019-02-25 12:12   ` [PATCH 16/26] drm/amd/powerplay: add suspend and resume function for smu Huang Rui
2019-02-25 12:12   ` [PATCH 17/26] drm/amd/powerplay: add condition for smc table hw init Huang Rui
2019-02-25 12:12   ` [PATCH 18/26] drm/amd/powerplay: support sysfs to get socclk, fclk, dcefclk Huang Rui
2019-02-25 12:12   ` [PATCH 19/26] drm/amd/powerplay: support sysfs to set " Huang Rui
2019-02-25 12:12   ` [PATCH 20/26] drm/amd/powerplay: add override pcie parameters Huang Rui
2019-02-25 12:12   ` Huang Rui [this message]
2019-02-25 12:12   ` [PATCH 22/26] drm/amd/powerplay: fix smc messsage index report Huang Rui
2019-02-25 12:12   ` [PATCH 23/26] drm/amd/powerplay: fix byte alignment issue of smu11 pptable Huang Rui
2019-02-25 12:12   ` [PATCH 24/26] drm/amd/powerplay: move setting allowed mask and feature enabling together Huang Rui
2019-02-25 12:12   ` [PATCH 25/26] drm/amd/powerplay: fix the issue of checking on message mapping Huang Rui
2019-02-25 12:12   ` [PATCH 26/26] drm/amd/powerplay: use REG32_PCIE wrapper instead for sw smu Huang Rui
     [not found]     ` <1551096752-18205-27-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2019-02-26  4:13       ` Alex Deucher

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=1551096752-18205-22-git-send-email-ray.huang@amd.com \
    --to=ray.huang-5c7gfcevmho@public.gmane.org \
    --cc=Jack.Gui-5C7GfCeVMHo@public.gmane.org \
    --cc=Kevin1.Wang-5C7GfCeVMHo@public.gmane.org \
    --cc=Likun.Gao-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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.