Skip to content

Commit f1d1abd

Browse files
Asad Kamalalexdeucher
authored andcommitted
drm/amd/pm: Update pci link speed for smu v13.0.6
Update pcie link speed registers for smu v13.0.6 & populate gpu metric table with pcie link speed rather than gen for smu v13_0_0, smu v13_0_6 & smu v13_0_7 v2: Update ESM register address Used macro to convert pcie gen to speed v3: Chaged macro to inline function for pcie gen to speed Signed-off-by: Asad Kamal <asad.kamal@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent e49311c commit f1d1abd

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#define LINK_SPEED_MAX 3
6565

6666
static const __maybe_unused uint16_t link_width[] = {0, 1, 2, 4, 8, 12, 16};
67-
static const __maybe_unused uint16_t link_speed[] = {25, 50, 80, 160};
6867

6968
static const
7069
struct smu_temperature_range __maybe_unused smu11_thermal_policy[] = {

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ MODULE_FIRMWARE("amdgpu/smu_13_0_10.bin");
8383
#define PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT 0xE
8484

8585
static const int link_width[] = {0, 1, 2, 4, 8, 12, 16};
86-
static const int link_speed[] = {25, 50, 80, 160};
8786

8887
const int pmfw_decoded_link_speed[5] = {1, 2, 3, 4, 5};
8988
const int pmfw_decoded_link_width[7] = {0, 1, 2, 4, 8, 12, 16};

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
#define PP_OD_FEATURE_UCLK_FMAX 3
103103
#define PP_OD_FEATURE_GFX_VF_CURVE 4
104104

105+
#define LINK_SPEED_MAX 3
106+
105107
static struct cmn2asic_msg_mapping smu_v13_0_0_message_map[SMU_MSG_MAX_COUNT] = {
106108
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1),
107109
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1),
@@ -1760,7 +1762,10 @@ static ssize_t smu_v13_0_0_get_gpu_metrics(struct smu_context *smu,
17601762
gpu_metrics->current_fan_speed = metrics->AvgFanRpm;
17611763

17621764
gpu_metrics->pcie_link_width = metrics->PcieWidth;
1763-
gpu_metrics->pcie_link_speed = metrics->PcieRate;
1765+
if ((metrics->PcieRate - 1) > LINK_SPEED_MAX)
1766+
gpu_metrics->pcie_link_speed = pcie_gen_to_speed(1);
1767+
else
1768+
gpu_metrics->pcie_link_speed = pcie_gen_to_speed(metrics->PcieRate);
17641769

17651770
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
17661771

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@
8080
/* possible frequency drift (1Mhz) */
8181
#define EPSILON 1
8282

83-
#define smnPCIE_ESM_CTRL 0x193D0
83+
#define smnPCIE_ESM_CTRL 0x93D0
8484
#define smnPCIE_LC_LINK_WIDTH_CNTL 0x1a340288
8585
#define PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD_MASK 0x00000070L
8686
#define PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD__SHIFT 0x4
8787
#define MAX_LINK_WIDTH 6
8888

89+
#define smnPCIE_LC_SPEED_CNTL 0x1a340290
90+
#define PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK 0xE0
91+
#define PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT 0x5
92+
#define LINK_SPEED_MAX 4
93+
8994
static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUNT] = {
9095
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 0),
9196
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1),
@@ -1930,14 +1935,21 @@ smu_v13_0_6_get_current_pcie_link_width_level(struct smu_context *smu)
19301935
static int smu_v13_0_6_get_current_pcie_link_speed(struct smu_context *smu)
19311936
{
19321937
struct amdgpu_device *adev = smu->adev;
1938+
uint32_t speed_level;
19331939
uint32_t esm_ctrl;
19341940

19351941
/* TODO: confirm this on real target */
19361942
esm_ctrl = RREG32_PCIE(smnPCIE_ESM_CTRL);
19371943
if ((esm_ctrl >> 15) & 0x1FFFF)
19381944
return (((esm_ctrl >> 8) & 0x3F) + 128);
19391945

1940-
return smu_v13_0_get_current_pcie_link_speed(smu);
1946+
speed_level = (RREG32_PCIE(smnPCIE_LC_SPEED_CNTL) &
1947+
PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK)
1948+
>> PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT;
1949+
if (speed_level > LINK_SPEED_MAX)
1950+
speed_level = 0;
1951+
1952+
return pcie_gen_to_speed(speed_level + 1);
19411953
}
19421954

19431955
static ssize_t smu_v13_0_6_get_gpu_metrics(struct smu_context *smu, void **table)

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
#define PP_OD_FEATURE_UCLK_FMAX 3
7979
#define PP_OD_FEATURE_GFX_VF_CURVE 4
8080

81+
#define LINK_SPEED_MAX 3
82+
8183
static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = {
8284
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1),
8385
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1),
@@ -1736,7 +1738,10 @@ static ssize_t smu_v13_0_7_get_gpu_metrics(struct smu_context *smu,
17361738
gpu_metrics->current_fan_speed = metrics->AvgFanRpm;
17371739

17381740
gpu_metrics->pcie_link_width = metrics->PcieWidth;
1739-
gpu_metrics->pcie_link_speed = metrics->PcieRate;
1741+
if ((metrics->PcieRate - 1) > LINK_SPEED_MAX)
1742+
gpu_metrics->pcie_link_speed = pcie_gen_to_speed(1);
1743+
else
1744+
gpu_metrics->pcie_link_speed = pcie_gen_to_speed(metrics->PcieRate);
17401745

17411746
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
17421747

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#define MP1_C2PMSG_90__CONTENT_MASK 0xFFFFFFFFL
4141

42+
const int link_speed[] = {25, 50, 80, 160, 320, 640};
43+
4244
#undef __SMU_DUMMY_MAP
4345
#define __SMU_DUMMY_MAP(type) #type
4446
static const char * const __smu_message_names[] = {

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
#define FDO_PWM_MODE_STATIC 1
3131
#define FDO_PWM_MODE_STATIC_RPM 5
3232

33+
extern const int link_speed[];
34+
35+
/* Helper to Convert from PCIE Gen 1/2/3/4/5/6 to 0.1 GT/s speed units */
36+
static inline int pcie_gen_to_speed(uint32_t gen)
37+
{
38+
return ((gen == 0) ? link_speed[0] : link_speed[gen - 1]);
39+
}
40+
3341
int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
3442
uint16_t msg_index,
3543
uint32_t param);

0 commit comments

Comments
 (0)