aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
authorwelu <wei.lu2@amd.com>2018-04-24 09:13:20 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-05-15 14:43:50 -0400
commit48edde3959e2a538ff963e6dbdc9c9adca8b159b (patch)
tree37769defccf12284745683c798aff729f31cf5e7 /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
parent38610f15a7ad7a914e4fd0a9a5a6c386700b8ba0 (diff)
drm/amdgpu: change pp_dpm clk/mclk/pcie input format.
1. support more than 8 values when setting get_pp_dpm_mclk/ sclk/pcie, the former design just parse command format like "echo xxxx > pp_dpm_sclk" and current can parse "echo xx xxx xxxx > pp_dpm_sclk" whose operation is more user-friendly and convinent and can offer more values; 2. be compatible with former design like "xx". 3. add DOC: pp_dpm_sclk pp_dpm_mclk pp_dpm_pcie Bug:KFD-385 Signed-off-by: welu <wei.lu2@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.c103
1 files changed, 59 insertions, 44 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 27d8dd77860d..d9802d938e33 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -574,10 +574,10 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
574 * the power state and the clock information for those levels. 574 * the power state and the clock information for those levels.
575 * 575 *
576 * To manually adjust these states, first select manual using 576 * To manually adjust these states, first select manual using
577 * power_dpm_force_performance_level. Writing a string of the level 577 * power_dpm_force_performance_level.
578 * numbers to the file will select which levels you want to enable. 578 * Secondly,Enter a new value for each level by inputing a string that
579 * E.g., writing 456 to the file will enable levels 4, 5, and 6. 579 * contains " echo xx xx xx > pp_dpm_sclk/mclk/pcie"
580 * 580 * E.g., echo 4 5 6 to > pp_dpm_sclk will enable sclk levels 4, 5, and 6.
581 */ 581 */
582 582
583static ssize_t amdgpu_get_pp_dpm_sclk(struct device *dev, 583static ssize_t amdgpu_get_pp_dpm_sclk(struct device *dev,
@@ -602,23 +602,27 @@ static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
602 struct amdgpu_device *adev = ddev->dev_private; 602 struct amdgpu_device *adev = ddev->dev_private;
603 int ret; 603 int ret;
604 long level; 604 long level;
605 uint32_t i, mask = 0; 605 uint32_t mask = 0;
606 char sub_str[2]; 606 char *sub_str = NULL;
607 char *tmp;
608 char buf_cpy[count];
609 const char delimiter[3] = {' ', '\n', '\0'};
607 610
608 for (i = 0; i < strlen(buf); i++) { 611 memcpy(buf_cpy, buf, count+1);
609 if (*(buf + i) == '\n') 612 tmp = buf_cpy;
610 continue; 613 while (tmp[0]) {
611 sub_str[0] = *(buf + i); 614 sub_str = strsep(&tmp, delimiter);
612 sub_str[1] = '\0'; 615 if (strlen(sub_str)) {
613 ret = kstrtol(sub_str, 0, &level); 616 ret = kstrtol(sub_str, 0, &level);
614 617
615 if (ret) { 618 if (ret) {
616 count = -EINVAL; 619 count = -EINVAL;
617 goto fail; 620 goto fail;
618 } 621 }
619 mask |= 1 << level; 622 mask |= 1 << level;
623 } else
624 break;
620 } 625 }
621
622 if (adev->powerplay.pp_funcs->force_clock_level) 626 if (adev->powerplay.pp_funcs->force_clock_level)
623 amdgpu_dpm_force_clock_level(adev, PP_SCLK, mask); 627 amdgpu_dpm_force_clock_level(adev, PP_SCLK, mask);
624 628
@@ -648,21 +652,26 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
648 struct amdgpu_device *adev = ddev->dev_private; 652 struct amdgpu_device *adev = ddev->dev_private;
649 int ret; 653 int ret;
650 long level; 654 long level;
651 uint32_t i, mask = 0; 655 uint32_t mask = 0;
652 char sub_str[2]; 656 char *sub_str = NULL;
657 char *tmp;
658 char buf_cpy[count];
659 const char delimiter[3] = {' ', '\n', '\0'};
653 660
654 for (i = 0; i < strlen(buf); i++) { 661 memcpy(buf_cpy, buf, count+1);
655 if (*(buf + i) == '\n') 662 tmp = buf_cpy;
656 continue; 663 while (tmp[0]) {
657 sub_str[0] = *(buf + i); 664 sub_str = strsep(&tmp, delimiter);
658 sub_str[1] = '\0'; 665 if (strlen(sub_str)) {
659 ret = kstrtol(sub_str, 0, &level); 666 ret = kstrtol(sub_str, 0, &level);
660 667
661 if (ret) { 668 if (ret) {
662 count = -EINVAL; 669 count = -EINVAL;
663 goto fail; 670 goto fail;
664 } 671 }
665 mask |= 1 << level; 672 mask |= 1 << level;
673 } else
674 break;
666 } 675 }
667 if (adev->powerplay.pp_funcs->force_clock_level) 676 if (adev->powerplay.pp_funcs->force_clock_level)
668 amdgpu_dpm_force_clock_level(adev, PP_MCLK, mask); 677 amdgpu_dpm_force_clock_level(adev, PP_MCLK, mask);
@@ -693,21 +702,27 @@ static ssize_t amdgpu_set_pp_dpm_pcie(struct device *dev,
693 struct amdgpu_device *adev = ddev->dev_private; 702 struct amdgpu_device *adev = ddev->dev_private;
694 int ret; 703 int ret;
695 long level; 704 long level;
696 uint32_t i, mask = 0; 705 uint32_t mask = 0;
697 char sub_str[2]; 706 char *sub_str = NULL;
707 char *tmp;
708 char buf_cpy[count];
709 const char delimiter[3] = {' ', '\n', '\0'};
698 710
699 for (i = 0; i < strlen(buf); i++) { 711 memcpy(buf_cpy, buf, count+1);
700 if (*(buf + i) == '\n') 712 tmp = buf_cpy;
701 continue;
702 sub_str[0] = *(buf + i);
703 sub_str[1] = '\0';
704 ret = kstrtol(sub_str, 0, &level);
705 713
706 if (ret) { 714 while (tmp[0]) {
707 count = -EINVAL; 715 sub_str = strsep(&tmp, delimiter);
708 goto fail; 716 if (strlen(sub_str)) {
709 } 717 ret = kstrtol(sub_str, 0, &level);
710 mask |= 1 << level; 718
719 if (ret) {
720 count = -EINVAL;
721 goto fail;
722 }
723 mask |= 1 << level;
724 } else
725 break;
711 } 726 }
712 if (adev->powerplay.pp_funcs->force_clock_level) 727 if (adev->powerplay.pp_funcs->force_clock_level)
713 amdgpu_dpm_force_clock_level(adev, PP_PCIE, mask); 728 amdgpu_dpm_force_clock_level(adev, PP_PCIE, mask);