Skip to content

Commit 6610713

Browse files
mcoffinalexdeucher
authored andcommitted
drm/amdgpu/navi10: implement GFXCLK_CURVE overdrive
[Why] Before this patch, there was no way to set the gfxclk voltage curve in the overdrive settings for navi10 through pp_od_clk_voltage [How] Add the required implementation to navi10's ppt dpm table editing implementation, similar to the vega20 implementation and interface. Reviewed-by: Evan Quan <[email protected]> Signed-off-by: Matt Coffin <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 21677d0 commit 6610713

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

drivers/gpu/drm/amd/powerplay/navi10_ppt.c

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,8 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
17281728
struct smu_table_context *table_context = &smu->smu_table;
17291729
OverDriveTable_t *od_table;
17301730
struct smu_11_0_overdrive_table *od_settings;
1731+
enum SMU_11_0_ODSETTING_ID freq_setting, voltage_setting;
1732+
uint16_t *freq_ptr, *voltage_ptr;
17311733
od_table = (OverDriveTable_t *)table_context->overdrive_table;
17321734

17331735
if (!smu->od_enabled) {
@@ -1824,8 +1826,62 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
18241826
}
18251827
break;
18261828
case PP_OD_EDIT_VDDC_CURVE:
1827-
// TODO: implement
1828-
return -ENOSYS;
1829+
if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_CURVE)) {
1830+
pr_warn("GFXCLK_CURVE not supported!\n");
1831+
return -ENOTSUPP;
1832+
}
1833+
if (size < 3) {
1834+
pr_info("invalid number of parameters: %d\n", size);
1835+
return -EINVAL;
1836+
}
1837+
if (!od_table) {
1838+
pr_info("Overdrive is not initialized\n");
1839+
return -EINVAL;
1840+
}
1841+
1842+
switch (input[0]) {
1843+
case 0:
1844+
freq_setting = SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P1;
1845+
voltage_setting = SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P1;
1846+
freq_ptr = &od_table->GfxclkFreq1;
1847+
voltage_ptr = &od_table->GfxclkVolt1;
1848+
break;
1849+
case 1:
1850+
freq_setting = SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P2;
1851+
voltage_setting = SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P2;
1852+
freq_ptr = &od_table->GfxclkFreq2;
1853+
voltage_ptr = &od_table->GfxclkVolt2;
1854+
break;
1855+
case 2:
1856+
freq_setting = SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P3;
1857+
voltage_setting = SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P3;
1858+
freq_ptr = &od_table->GfxclkFreq3;
1859+
voltage_ptr = &od_table->GfxclkVolt3;
1860+
break;
1861+
default:
1862+
pr_info("Invalid VDDC_CURVE index: %ld\n", input[0]);
1863+
pr_info("Supported indices: [0, 1, 2]\n");
1864+
return -EINVAL;
1865+
}
1866+
ret = navi10_od_setting_check_range(od_settings, freq_setting, input[1]);
1867+
if (ret)
1868+
return ret;
1869+
// Allow setting zero to disable the OverDrive VDDC curve
1870+
if (input[2] != 0) {
1871+
ret = navi10_od_setting_check_range(od_settings, voltage_setting, input[2]);
1872+
if (ret)
1873+
return ret;
1874+
*freq_ptr = input[1];
1875+
*voltage_ptr = ((uint16_t)input[2]) * NAVI10_VOLTAGE_SCALE;
1876+
pr_debug("OD: set curve %ld: (%d, %d)\n", input[0], *freq_ptr, *voltage_ptr);
1877+
} else {
1878+
// If setting 0, disable all voltage curve settings
1879+
od_table->GfxclkVolt1 = 0;
1880+
od_table->GfxclkVolt2 = 0;
1881+
od_table->GfxclkVolt3 = 0;
1882+
}
1883+
navi10_dump_od_table(od_table);
1884+
break;
18291885
default:
18301886
return -ENOSYS;
18311887
}

drivers/gpu/drm/amd/powerplay/navi10_ppt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#define NAVI14_UMD_PSTATE_PEAK_XTX_GFXCLK (1717)
3434
#define NAVI14_UMD_PSTATE_PEAK_XL_GFXCLK (1448)
3535

36+
#define NAVI10_VOLTAGE_SCALE (4)
37+
3638
extern void navi10_set_ppt_funcs(struct smu_context *smu);
3739

3840
#endif

0 commit comments

Comments
 (0)