Re: [PATCH 2/4] scmi: perf: Extend protocol to support performance statistics

From: kernel test robot
Date: Thu Jul 30 2020 - 21:52:15 EST


Hi Lukasz,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200729]
[cannot apply to pm/linux-next tip/auto-latest linux/master linus/master v5.8-rc7 v5.8-rc6 v5.8-rc5 v5.8-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Lukasz-Luba/CPUFreq-statistics-retrieved-by-drivers/20200729-231539
base: 04b4571786305a76ad81757bbec78eb16a5de582
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All error/warnings (new ones prefixed by >>):

drivers/firmware/arm_scmi/perf.c: In function 'scmi_dvfs_stats_get':
>> drivers/firmware/arm_scmi/perf.c:905:17: error: implicit declaration of function 'vmalloc' [-Werror=implicit-function-declaration]
905 | raw_stats[0] = vmalloc(domain_stats->size);
| ^~~~~~~
>> drivers/firmware/arm_scmi/perf.c:905:15: warning: assignment to 'struct scmi_perf_domain_raw_stats *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
905 | raw_stats[0] = vmalloc(domain_stats->size);
| ^
drivers/firmware/arm_scmi/perf.c:909:15: warning: assignment to 'struct scmi_perf_domain_raw_stats *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
909 | raw_stats[1] = vmalloc(domain_stats->size);
| ^
>> drivers/firmware/arm_scmi/perf.c:911:3: error: implicit declaration of function 'vfree' [-Werror=implicit-function-declaration]
911 | vfree(raw_stats[0]);
| ^~~~~
cc1: some warnings being treated as errors

vim +/vmalloc +905 drivers/firmware/arm_scmi/perf.c

868
869 static int
870 scmi_dvfs_stats_get(const struct scmi_handle *handle, u32 domain_id,
871 struct scmi_perf_domain_stats *stats)
872 {
873 struct scmi_perf_domain_stats_desc *domain_stats;
874 struct scmi_perf_domain_raw_stats *raw_stats[2];
875 struct scmi_perf_info *pi = handle->perf_priv;
876 struct scmi_perf_level_raw_stats *perf;
877 int i, index, ret = -EINVAL;
878 struct perf_dom_info *dom;
879 u64 transition_count = 0;
880 struct scmi_opp *opp;
881
882 if (!stats)
883 return -EINVAL;
884
885 if (!pi->stats_virt_addr || !pi->stats_desc ||
886 !pi->stats_desc->domain_stats)
887 return -ENOENT;
888
889 if (pi->stats_desc->domain_count <= domain_id ||
890 !pi->stats_desc->domain_stats[domain_id].addr)
891 return -ENOENT;
892
893 dom = pi->dom_info + domain_id;
894 if (!dom)
895 return -EIO;
896
897 domain_stats = &pi->stats_desc->domain_stats[domain_id];
898
899 if (!domain_stats->opp_map) {
900 ret = scmi_dvfs_setup_opps_mapping(handle, domain_id);
901 if (ret)
902 return ret;
903 }
904
> 905 raw_stats[0] = vmalloc(domain_stats->size);
906 if (!raw_stats[0])
907 return -ENOMEM;
908
909 raw_stats[1] = vmalloc(domain_stats->size);
910 if (!raw_stats[1]) {
> 911 vfree(raw_stats[0]);
912 return -ENOMEM;
913 }
914
915 /*
916 * Let's try 10 times. If two consecutive reads are the same - done.
917 * This approach is aligned with SCMI v2 specification.
918 */
919 for (i = 0; i < 10; i++) {
920 memcpy_fromio(raw_stats[0], domain_stats->addr,
921 domain_stats->size);
922 memcpy_fromio(raw_stats[1], domain_stats->addr,
923 domain_stats->size);
924 if (!memcmp(raw_stats[0], raw_stats[1], domain_stats->size)) {
925 ret = 0;
926 break;
927 }
928 }
929
930 if (ret)
931 goto free_buf;
932
933 for (i = 0; i < dom->opp_count; i++) {
934 perf = &raw_stats[0]->perf_level[i];
935
936 transition_count += __le64_to_cpu(perf->usage_count);
937 stats->time_in_state[i] =
938 __le64_to_cpu(perf->total_residency_us);
939
940 /* Speed-up and initialize the frequencies only once. */
941 if (stats->freq_table[i] == 0) {
942 index = domain_stats->opp_map[i];
943 opp = &dom->opp[index];
944 stats->freq_table[i] = opp->perf * dom->mult_factor;
945 }
946 }
947
948 stats->total_trans = transition_count;
949
950 stats->last_index = __le16_to_cpu(raw_stats[0]->curr_perf_level_id);
951 stats->last_time = __le64_to_cpu(raw_stats[0]->ts_last_change_us);
952
953 free_buf:
954 vfree(raw_stats[1]);
955 vfree(raw_stats[0]);
956
957 return ret;
958 }
959

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip