[bug report] drm/amd/pm: add the parameters of power profiles for vangogh
Du, Xiaojian
Xiaojian.Du at amd.com
Tue Jan 12 09:31:17 UTC 2021
[AMD Official Use Only - Internal Distribution Only]
Thanks for detailed feedback.
For Vangogh APU, only 5 kinds of power profile mode are used, they are exported from swSMU firmware header.
We driver will not add other power profile mode which is created by extra hard code.
But smu common header contains 6 kinds of power profile mode.
So it means one kind of power profile mode will not be used for Vangogh.
I will double confirm this "warning" and fix it soon.
Thanks,
Xiaojian
-----Original Message-----
From: Dan Carpenter <dan.carpenter at oracle.com>
Sent: 2021年1月12日 17:10
To: Du, Xiaojian <Xiaojian.Du at amd.com>
Cc: amd-gfx at lists.freedesktop.org
Subject: [bug report] drm/amd/pm: add the parameters of power profiles for vangogh
Hello Xiaojian Du,
The patch 307f049bfcad: "drm/amd/pm: add the parameters of power profiles for vangogh" from Jan 7, 2021, leads to the following static checker warning:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/vangogh_ppt.c:801 vangogh_get_power_profile_mode()
error: buffer overflow 'profile_name' 5 <= 6
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/vangogh_ppt.c
773 static int vangogh_get_power_profile_mode(struct smu_context *smu,
774 char *buf)
775 {
776 static const char *profile_name[] = {
777 "FULL_SCREEN_3D",
778 "VIDEO",
779 "VR",
780 "COMPUTE",
781 "CUSTOM"};
This list leaves out DEFAULT and POWERSAVING profiles, so I don't think it's correct.
782 uint32_t i, size = 0;
783 int16_t workload_type = 0;
784
785 if (!buf)
786 return -EINVAL;
787
788 for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
789 /*
790 * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT
791 * Not all profile modes are supported on vangogh.
792 */
793 workload_type = smu_cmn_to_asic_specific_index(smu,
794 CMN2ASIC_MAPPING_WORKLOAD,
795 i);
796
797 if (workload_type < 0)
798 continue;
799
800 size += sprintf(buf + size, "%2d %14s%s\n",
801 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " ");
^^^^^^^^^^^^^^^ Also it leads to an array overflow.
802 }
803
804 return size;
805 }
regards,
dan carpenter
More information about the amd-gfx
mailing list