diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 9e73cbcfce44..632b18670098 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -734,161 +734,6 @@ fail: | |||
734 | return -EINVAL; | 734 | return -EINVAL; |
735 | } | 735 | } |
736 | 736 | ||
737 | static ssize_t amdgpu_get_pp_power_profile(struct device *dev, | ||
738 | char *buf, struct amd_pp_profile *query) | ||
739 | { | ||
740 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
741 | struct amdgpu_device *adev = ddev->dev_private; | ||
742 | int ret = 0xff; | ||
743 | |||
744 | if (adev->powerplay.pp_funcs->get_power_profile_state) | ||
745 | ret = amdgpu_dpm_get_power_profile_state( | ||
746 | adev, query); | ||
747 | |||
748 | if (ret) | ||
749 | return ret; | ||
750 | |||
751 | return snprintf(buf, PAGE_SIZE, | ||
752 | "%d %d %d %d %d\n", | ||
753 | query->min_sclk / 100, | ||
754 | query->min_mclk / 100, | ||
755 | query->activity_threshold, | ||
756 | query->up_hyst, | ||
757 | query->down_hyst); | ||
758 | } | ||
759 | |||
760 | static ssize_t amdgpu_get_pp_gfx_power_profile(struct device *dev, | ||
761 | struct device_attribute *attr, | ||
762 | char *buf) | ||
763 | { | ||
764 | struct amd_pp_profile query = {0}; | ||
765 | |||
766 | query.type = AMD_PP_GFX_PROFILE; | ||
767 | |||
768 | return amdgpu_get_pp_power_profile(dev, buf, &query); | ||
769 | } | ||
770 | |||
771 | static ssize_t amdgpu_get_pp_compute_power_profile(struct device *dev, | ||
772 | struct device_attribute *attr, | ||
773 | char *buf) | ||
774 | { | ||
775 | struct amd_pp_profile query = {0}; | ||
776 | |||
777 | query.type = AMD_PP_COMPUTE_PROFILE; | ||
778 | |||
779 | return amdgpu_get_pp_power_profile(dev, buf, &query); | ||
780 | } | ||
781 | |||
782 | static ssize_t amdgpu_set_pp_power_profile(struct device *dev, | ||
783 | const char *buf, | ||
784 | size_t count, | ||
785 | struct amd_pp_profile *request) | ||
786 | { | ||
787 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
788 | struct amdgpu_device *adev = ddev->dev_private; | ||
789 | uint32_t loop = 0; | ||
790 | char *sub_str, buf_cpy[128], *tmp_str; | ||
791 | const char delimiter[3] = {' ', '\n', '\0'}; | ||
792 | long int value; | ||
793 | int ret = 0xff; | ||
794 | |||
795 | if (strncmp("reset", buf, strlen("reset")) == 0) { | ||
796 | if (adev->powerplay.pp_funcs->reset_power_profile_state) | ||
797 | ret = amdgpu_dpm_reset_power_profile_state( | ||
798 | adev, request); | ||
799 | if (ret) { | ||
800 | count = -EINVAL; | ||
801 | goto fail; | ||
802 | } | ||
803 | return count; | ||
804 | } | ||
805 | |||
806 | if (strncmp("set", buf, strlen("set")) == 0) { | ||
807 | if (adev->powerplay.pp_funcs->set_power_profile_state) | ||
808 | ret = amdgpu_dpm_set_power_profile_state( | ||
809 | adev, request); | ||
810 | |||
811 | if (ret) { | ||
812 | count = -EINVAL; | ||
813 | goto fail; | ||
814 | } | ||
815 | return count; | ||
816 | } | ||
817 | |||
818 | if (count + 1 >= 128) { | ||
819 | count = -EINVAL; | ||
820 | goto fail; | ||
821 | } | ||
822 | |||
823 | memcpy(buf_cpy, buf, count + 1); | ||
824 | tmp_str = buf_cpy; | ||
825 | |||
826 | while (tmp_str[0]) { | ||
827 | sub_str = strsep(&tmp_str, delimiter); | ||
828 | ret = kstrtol(sub_str, 0, &value); | ||
829 | if (ret) { | ||
830 | count = -EINVAL; | ||
831 | goto fail; | ||
832 | } | ||
833 | |||
834 | switch (loop) { | ||
835 | case 0: | ||
836 | /* input unit MHz convert to dpm table unit 10KHz*/ | ||
837 | request->min_sclk = (uint32_t)value * 100; | ||
838 | break; | ||
839 | case 1: | ||
840 | /* input unit MHz convert to dpm table unit 10KHz*/ | ||
841 | request->min_mclk = (uint32_t)value * 100; | ||
842 | break; | ||
843 | case 2: | ||
844 | request->activity_threshold = (uint16_t)value; | ||
845 | break; | ||
846 | case 3: | ||
847 | request->up_hyst = (uint8_t)value; | ||
848 | break; | ||
849 | case 4: | ||
850 | request->down_hyst = (uint8_t)value; | ||
851 | break; | ||
852 | default: | ||
853 | break; | ||
854 | } | ||
855 | |||
856 | loop++; | ||
857 | } | ||
858 | if (adev->powerplay.pp_funcs->set_power_profile_state) | ||
859 | ret = amdgpu_dpm_set_power_profile_state(adev, request); | ||
860 | |||
861 | if (ret) | ||
862 | count = -EINVAL; | ||
863 | |||
864 | fail: | ||
865 | return count; | ||
866 | } | ||
867 | |||
868 | static ssize_t amdgpu_set_pp_gfx_power_profile(struct device *dev, | ||
869 | struct device_attribute *attr, | ||
870 | const char *buf, | ||
871 | size_t count) | ||
872 | { | ||
873 | struct amd_pp_profile request = {0}; | ||
874 | |||
875 | request.type = AMD_PP_GFX_PROFILE; | ||
876 | |||
877 | return amdgpu_set_pp_power_profile(dev, buf, count, &request); | ||
878 | } | ||
879 | |||
880 | static ssize_t amdgpu_set_pp_compute_power_profile(struct device *dev, | ||
881 | struct device_attribute *attr, | ||
882 | const char *buf, | ||
883 | size_t count) | ||
884 | { | ||
885 | struct amd_pp_profile request = {0}; | ||
886 | |||
887 | request.type = AMD_PP_COMPUTE_PROFILE; | ||
888 | |||
889 | return amdgpu_set_pp_power_profile(dev, buf, count, &request); | ||
890 | } | ||
891 | |||
892 | static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); | 737 | static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); |
893 | static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, | 738 | static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, |
894 | amdgpu_get_dpm_forced_performance_level, | 739 | amdgpu_get_dpm_forced_performance_level, |
@@ -916,12 +761,6 @@ static DEVICE_ATTR(pp_sclk_od, S_IRUGO | S_IWUSR, | |||
916 | static DEVICE_ATTR(pp_mclk_od, S_IRUGO | S_IWUSR, | 761 | static DEVICE_ATTR(pp_mclk_od, S_IRUGO | S_IWUSR, |
917 | amdgpu_get_pp_mclk_od, | 762 | amdgpu_get_pp_mclk_od, |
918 | amdgpu_set_pp_mclk_od); | 763 | amdgpu_set_pp_mclk_od); |
919 | static DEVICE_ATTR(pp_gfx_power_profile, S_IRUGO | S_IWUSR, | ||
920 | amdgpu_get_pp_gfx_power_profile, | ||
921 | amdgpu_set_pp_gfx_power_profile); | ||
922 | static DEVICE_ATTR(pp_compute_power_profile, S_IRUGO | S_IWUSR, | ||
923 | amdgpu_get_pp_compute_power_profile, | ||
924 | amdgpu_set_pp_compute_power_profile); | ||
925 | static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR, | 764 | static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR, |
926 | amdgpu_get_pp_power_profile_mode, | 765 | amdgpu_get_pp_power_profile_mode, |
927 | amdgpu_set_pp_power_profile_mode); | 766 | amdgpu_set_pp_power_profile_mode); |
@@ -1767,21 +1606,6 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) | |||
1767 | return ret; | 1606 | return ret; |
1768 | } | 1607 | } |
1769 | ret = device_create_file(adev->dev, | 1608 | ret = device_create_file(adev->dev, |
1770 | &dev_attr_pp_gfx_power_profile); | ||
1771 | if (ret) { | ||
1772 | DRM_ERROR("failed to create device file " | ||
1773 | "pp_gfx_power_profile\n"); | ||
1774 | return ret; | ||
1775 | } | ||
1776 | ret = device_create_file(adev->dev, | ||
1777 | &dev_attr_pp_compute_power_profile); | ||
1778 | if (ret) { | ||
1779 | DRM_ERROR("failed to create device file " | ||
1780 | "pp_compute_power_profile\n"); | ||
1781 | return ret; | ||
1782 | } | ||
1783 | |||
1784 | ret = device_create_file(adev->dev, | ||
1785 | &dev_attr_pp_power_profile_mode); | 1609 | &dev_attr_pp_power_profile_mode); |
1786 | if (ret) { | 1610 | if (ret) { |
1787 | DRM_ERROR("failed to create device file " | 1611 | DRM_ERROR("failed to create device file " |
@@ -1827,10 +1651,6 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) | |||
1827 | device_remove_file(adev->dev, &dev_attr_pp_sclk_od); | 1651 | device_remove_file(adev->dev, &dev_attr_pp_sclk_od); |
1828 | device_remove_file(adev->dev, &dev_attr_pp_mclk_od); | 1652 | device_remove_file(adev->dev, &dev_attr_pp_mclk_od); |
1829 | device_remove_file(adev->dev, | 1653 | device_remove_file(adev->dev, |
1830 | &dev_attr_pp_gfx_power_profile); | ||
1831 | device_remove_file(adev->dev, | ||
1832 | &dev_attr_pp_compute_power_profile); | ||
1833 | device_remove_file(adev->dev, | ||
1834 | &dev_attr_pp_power_profile_mode); | 1654 | &dev_attr_pp_power_profile_mode); |
1835 | device_remove_file(adev->dev, | 1655 | device_remove_file(adev->dev, |
1836 | &dev_attr_pp_od_clk_voltage); | 1656 | &dev_attr_pp_od_clk_voltage); |