Skip to content

Commit 2a1fe39

Browse files
superm1alexdeucher
authored andcommitted
drm/amd: Fix logic error in sienna_cichlid_update_pcie_parameters()
While aligning SMU11 with SMU13 implementation an assumption was made that `dpm_context->dpm_tables.pcie_table` was populated in dpm table initialization like in SMU13 but it isn't. So restore some of the original logic and instead just check for amdgpu_device_pcie_dynamic_switching_supported() to decide whether to hardcode values; erring on the side of performance. Cc: stable@vger.kernel.org # 6.1+ Reported-and-tested-by: Umio Yasuno <coelacanth_dream@protonmail.com> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/1447#note_2101382 Fixes: e701156 ("drm/amd: Align SMU11 SMU_MSG_OverridePcieParameters implementation with SMU13") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 5d06167 commit 2a1fe39

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,36 +2082,41 @@ static int sienna_cichlid_display_disable_memory_clock_switch(struct smu_context
20822082
return ret;
20832083
}
20842084

2085+
#define MAX(a, b) ((a) > (b) ? (a) : (b))
2086+
20852087
static int sienna_cichlid_update_pcie_parameters(struct smu_context *smu,
20862088
uint32_t pcie_gen_cap,
20872089
uint32_t pcie_width_cap)
20882090
{
20892091
struct smu_11_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context;
20902092
struct smu_11_0_pcie_table *pcie_table = &dpm_context->dpm_tables.pcie_table;
2091-
u32 smu_pcie_arg;
2093+
uint8_t *table_member1, *table_member2;
2094+
uint32_t min_gen_speed, max_gen_speed;
2095+
uint32_t min_lane_width, max_lane_width;
2096+
uint32_t smu_pcie_arg;
20922097
int ret, i;
20932098

2094-
/* PCIE gen speed and lane width override */
2095-
if (!amdgpu_device_pcie_dynamic_switching_supported()) {
2096-
if (pcie_table->pcie_gen[NUM_LINK_LEVELS - 1] < pcie_gen_cap)
2097-
pcie_gen_cap = pcie_table->pcie_gen[NUM_LINK_LEVELS - 1];
2099+
GET_PPTABLE_MEMBER(PcieGenSpeed, &table_member1);
2100+
GET_PPTABLE_MEMBER(PcieLaneCount, &table_member2);
20982101

2099-
if (pcie_table->pcie_lane[NUM_LINK_LEVELS - 1] < pcie_width_cap)
2100-
pcie_width_cap = pcie_table->pcie_lane[NUM_LINK_LEVELS - 1];
2102+
min_gen_speed = MAX(0, table_member1[0]);
2103+
max_gen_speed = MIN(pcie_gen_cap, table_member1[1]);
2104+
min_gen_speed = min_gen_speed > max_gen_speed ?
2105+
max_gen_speed : min_gen_speed;
2106+
min_lane_width = MAX(1, table_member2[0]);
2107+
max_lane_width = MIN(pcie_width_cap, table_member2[1]);
2108+
min_lane_width = min_lane_width > max_lane_width ?
2109+
max_lane_width : min_lane_width;
21012110

2102-
/* Force all levels to use the same settings */
2103-
for (i = 0; i < NUM_LINK_LEVELS; i++) {
2104-
pcie_table->pcie_gen[i] = pcie_gen_cap;
2105-
pcie_table->pcie_lane[i] = pcie_width_cap;
2106-
}
2111+
if (!amdgpu_device_pcie_dynamic_switching_supported()) {
2112+
pcie_table->pcie_gen[0] = max_gen_speed;
2113+
pcie_table->pcie_lane[0] = max_lane_width;
21072114
} else {
2108-
for (i = 0; i < NUM_LINK_LEVELS; i++) {
2109-
if (pcie_table->pcie_gen[i] > pcie_gen_cap)
2110-
pcie_table->pcie_gen[i] = pcie_gen_cap;
2111-
if (pcie_table->pcie_lane[i] > pcie_width_cap)
2112-
pcie_table->pcie_lane[i] = pcie_width_cap;
2113-
}
2115+
pcie_table->pcie_gen[0] = min_gen_speed;
2116+
pcie_table->pcie_lane[0] = min_lane_width;
21142117
}
2118+
pcie_table->pcie_gen[1] = max_gen_speed;
2119+
pcie_table->pcie_lane[1] = max_lane_width;
21152120

21162121
for (i = 0; i < NUM_LINK_LEVELS; i++) {
21172122
smu_pcie_arg = (i << 16 |

0 commit comments

Comments
 (0)