diff options
author | Evan Quan <evan.quan@amd.com> | 2019-01-14 02:44:44 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-01-25 16:15:34 -0500 |
commit | 828e37efe802ba8c868922af23099638fde5b7b4 (patch) | |
tree | 6860d47f01d20d92cfe804fe970f0c8b61422177 /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |
parent | d7337ca2640cde21ff178bd78f01d94cd5ea2e08 (diff) |
drm/amd/powerplay: support retrieving and adjusting fclock power levels V2
User can use "pp_dpm_fclk" to retrieve and adjust fclock power
levels.
V2: expose this interface for Vega20 and later ASICs only
Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 4bdb1d082bea..23eb6f61da13 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -680,13 +680,14 @@ static ssize_t amdgpu_get_ppfeature_status(struct device *dev, | |||
680 | } | 680 | } |
681 | 681 | ||
682 | /** | 682 | /** |
683 | * DOC: pp_dpm_sclk pp_dpm_mclk pp_dpm_socclk pp_dpm_pcie | 683 | * DOC: pp_dpm_sclk pp_dpm_mclk pp_dpm_socclk pp_dpm_fclk pp_dpm_pcie |
684 | * | 684 | * |
685 | * The amdgpu driver provides a sysfs API for adjusting what power levels | 685 | * The amdgpu driver provides a sysfs API for adjusting what power levels |
686 | * are enabled for a given power state. The files pp_dpm_sclk, pp_dpm_mclk, | 686 | * are enabled for a given power state. The files pp_dpm_sclk, pp_dpm_mclk, |
687 | * pp_dpm_socclk and pp_dpm_pcie are used for this. | 687 | * pp_dpm_socclk, pp_dpm_fclk and pp_dpm_pcie are used for this. |
688 | * | 688 | * |
689 | * pp_dpm_socclk interface is only available for Vega10 and later ASICs. | 689 | * pp_dpm_socclk interface is only available for Vega10 and later ASICs. |
690 | * pp_dpm_fclk interface is only available for Vega20 and later ASICs. | ||
690 | * | 691 | * |
691 | * Reading back the files will show you the available power levels within | 692 | * Reading back the files will show you the available power levels within |
692 | * the power state and the clock information for those levels. | 693 | * the power state and the clock information for those levels. |
@@ -842,6 +843,42 @@ static ssize_t amdgpu_set_pp_dpm_socclk(struct device *dev, | |||
842 | return count; | 843 | return count; |
843 | } | 844 | } |
844 | 845 | ||
846 | static ssize_t amdgpu_get_pp_dpm_fclk(struct device *dev, | ||
847 | struct device_attribute *attr, | ||
848 | char *buf) | ||
849 | { | ||
850 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
851 | struct amdgpu_device *adev = ddev->dev_private; | ||
852 | |||
853 | if (adev->powerplay.pp_funcs->print_clock_levels) | ||
854 | return amdgpu_dpm_print_clock_levels(adev, PP_FCLK, buf); | ||
855 | else | ||
856 | return snprintf(buf, PAGE_SIZE, "\n"); | ||
857 | } | ||
858 | |||
859 | static ssize_t amdgpu_set_pp_dpm_fclk(struct device *dev, | ||
860 | struct device_attribute *attr, | ||
861 | const char *buf, | ||
862 | size_t count) | ||
863 | { | ||
864 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
865 | struct amdgpu_device *adev = ddev->dev_private; | ||
866 | int ret; | ||
867 | uint32_t mask = 0; | ||
868 | |||
869 | ret = amdgpu_read_mask(buf, count, &mask); | ||
870 | if (ret) | ||
871 | return ret; | ||
872 | |||
873 | if (adev->powerplay.pp_funcs->force_clock_level) | ||
874 | ret = amdgpu_dpm_force_clock_level(adev, PP_FCLK, mask); | ||
875 | |||
876 | if (ret) | ||
877 | return -EINVAL; | ||
878 | |||
879 | return count; | ||
880 | } | ||
881 | |||
845 | static ssize_t amdgpu_get_pp_dpm_pcie(struct device *dev, | 882 | static ssize_t amdgpu_get_pp_dpm_pcie(struct device *dev, |
846 | struct device_attribute *attr, | 883 | struct device_attribute *attr, |
847 | char *buf) | 884 | char *buf) |
@@ -1128,6 +1165,9 @@ static DEVICE_ATTR(pp_dpm_mclk, S_IRUGO | S_IWUSR, | |||
1128 | static DEVICE_ATTR(pp_dpm_socclk, S_IRUGO | S_IWUSR, | 1165 | static DEVICE_ATTR(pp_dpm_socclk, S_IRUGO | S_IWUSR, |
1129 | amdgpu_get_pp_dpm_socclk, | 1166 | amdgpu_get_pp_dpm_socclk, |
1130 | amdgpu_set_pp_dpm_socclk); | 1167 | amdgpu_set_pp_dpm_socclk); |
1168 | static DEVICE_ATTR(pp_dpm_fclk, S_IRUGO | S_IWUSR, | ||
1169 | amdgpu_get_pp_dpm_fclk, | ||
1170 | amdgpu_set_pp_dpm_fclk); | ||
1131 | static DEVICE_ATTR(pp_dpm_pcie, S_IRUGO | S_IWUSR, | 1171 | static DEVICE_ATTR(pp_dpm_pcie, S_IRUGO | S_IWUSR, |
1132 | amdgpu_get_pp_dpm_pcie, | 1172 | amdgpu_get_pp_dpm_pcie, |
1133 | amdgpu_set_pp_dpm_pcie); | 1173 | amdgpu_set_pp_dpm_pcie); |
@@ -2294,6 +2334,13 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) | |||
2294 | return ret; | 2334 | return ret; |
2295 | } | 2335 | } |
2296 | } | 2336 | } |
2337 | if (adev->asic_type >= CHIP_VEGA20) { | ||
2338 | ret = device_create_file(adev->dev, &dev_attr_pp_dpm_fclk); | ||
2339 | if (ret) { | ||
2340 | DRM_ERROR("failed to create device file pp_dpm_fclk\n"); | ||
2341 | return ret; | ||
2342 | } | ||
2343 | } | ||
2297 | ret = device_create_file(adev->dev, &dev_attr_pp_dpm_pcie); | 2344 | ret = device_create_file(adev->dev, &dev_attr_pp_dpm_pcie); |
2298 | if (ret) { | 2345 | if (ret) { |
2299 | DRM_ERROR("failed to create device file pp_dpm_pcie\n"); | 2346 | DRM_ERROR("failed to create device file pp_dpm_pcie\n"); |
@@ -2384,6 +2431,8 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) | |||
2384 | if (adev->asic_type >= CHIP_VEGA10) | 2431 | if (adev->asic_type >= CHIP_VEGA10) |
2385 | device_remove_file(adev->dev, &dev_attr_pp_dpm_socclk); | 2432 | device_remove_file(adev->dev, &dev_attr_pp_dpm_socclk); |
2386 | device_remove_file(adev->dev, &dev_attr_pp_dpm_pcie); | 2433 | device_remove_file(adev->dev, &dev_attr_pp_dpm_pcie); |
2434 | if (adev->asic_type >= CHIP_VEGA20) | ||
2435 | device_remove_file(adev->dev, &dev_attr_pp_dpm_fclk); | ||
2387 | device_remove_file(adev->dev, &dev_attr_pp_sclk_od); | 2436 | device_remove_file(adev->dev, &dev_attr_pp_sclk_od); |
2388 | device_remove_file(adev->dev, &dev_attr_pp_mclk_od); | 2437 | device_remove_file(adev->dev, &dev_attr_pp_mclk_od); |
2389 | device_remove_file(adev->dev, | 2438 | device_remove_file(adev->dev, |