Message ID | 20230320182441.11904-8-sumitg@nvidia.com |
---|---|
State | Superseded |
Headers | show |
Series | Tegra234 Memory interconnect support | expand |
Hi Sumit, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on robh/for-next] [also build test WARNING on krzk-mem-ctrl/for-next pci/next pci/for-linus] [cannot apply to tegra/for-next rafael-pm/linux-next linus/master v6.3-rc3 next-20230321] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20230320182441.11904-8-sumitg%40nvidia.com patch subject: [Patch v3 07/11] cpufreq: tegra194: add OPP support and set bandwidth config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230321/202303211551.eBLRqnv0-lkp@intel.com/config) compiler: aarch64-linux-gcc (GCC) 12.1.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 # https://github.com/intel-lab-lkp/linux/commit/fa31f117302fc7c15b5d9deeefb8c650554f503d git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 git checkout fa31f117302fc7c15b5d9deeefb8c650554f503d # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/cpufreq/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202303211551.eBLRqnv0-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/cpufreq/tegra194-cpufreq.c:397:5: warning: no previous prototype for 'tegra_cpufreq_init_cpufreq_table' [-Wmissing-prototypes] 397 | int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/tegra_cpufreq_init_cpufreq_table +397 drivers/cpufreq/tegra194-cpufreq.c 396 > 397 int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, 398 struct cpufreq_frequency_table *bpmp_lut, 399 struct cpufreq_frequency_table **opp_table) 400 { 401 struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); 402 struct cpufreq_frequency_table *freq_table = NULL; 403 struct cpufreq_frequency_table *pos; 404 struct device *cpu_dev; 405 struct dev_pm_opp *opp; 406 unsigned long rate; 407 int ret, max_opps; 408 int j = 0; 409 410 cpu_dev = get_cpu_device(policy->cpu); 411 if (!cpu_dev) { 412 pr_err("%s: failed to get cpu%d device\n", __func__, policy->cpu); 413 return -ENODEV; 414 } 415 416 /* Initialize OPP table mentioned in operating-points-v2 property in DT */ 417 ret = dev_pm_opp_of_add_table_indexed(cpu_dev, 0); 418 if (!ret) { 419 max_opps = dev_pm_opp_get_opp_count(cpu_dev); 420 if (max_opps <= 0) { 421 dev_err(cpu_dev, "Failed to add OPPs\n"); 422 return max_opps; 423 } 424 425 /* Disable all opps and cross-validate against LUT later */ 426 for (rate = 0; ; rate++) { 427 opp = dev_pm_opp_find_freq_ceil(cpu_dev, &rate); 428 if (IS_ERR(opp)) 429 break; 430 431 dev_pm_opp_put(opp); 432 dev_pm_opp_disable(cpu_dev, rate); 433 } 434 } else { 435 dev_err(cpu_dev, "Invalid or empty opp table in device tree\n"); 436 data->icc_dram_bw_scaling = false; 437 return ret; 438 } 439 440 freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_KERNEL); 441 if (!freq_table) 442 return -ENOMEM; 443 444 /* 445 * Cross check the frequencies from BPMP-FW LUT against the OPP's present in DT. 446 * Enable only those DT OPP's which are present in LUT also. 447 */ 448 cpufreq_for_each_valid_entry(pos, bpmp_lut) { 449 opp = dev_pm_opp_find_freq_exact(cpu_dev, pos->frequency * KHZ, false); 450 if (IS_ERR(opp)) 451 continue; 452 453 ret = dev_pm_opp_enable(cpu_dev, pos->frequency * KHZ); 454 if (ret < 0) 455 return ret; 456 457 freq_table[j].driver_data = pos->driver_data; 458 freq_table[j].frequency = pos->frequency; 459 j++; 460 } 461 462 freq_table[j].driver_data = pos->driver_data; 463 freq_table[j].frequency = CPUFREQ_TABLE_END; 464 465 *opp_table = &freq_table[0]; 466 467 dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus); 468 469 return ret; 470 } 471
On 21/03/23 13:06, kernel test robot wrote: > External email: Use caution opening links or attachments > > > Hi Sumit, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on robh/for-next] > [also build test WARNING on krzk-mem-ctrl/for-next pci/next pci/for-linus] > [cannot apply to tegra/for-next rafael-pm/linux-next linus/master v6.3-rc3 next-20230321] > [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#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 > base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next > patch link: https://lore.kernel.org/r/20230320182441.11904-8-sumitg%40nvidia.com > patch subject: [Patch v3 07/11] cpufreq: tegra194: add OPP support and set bandwidth > config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230321/202303211551.eBLRqnv0-lkp@intel.com/config) > compiler: aarch64-linux-gcc (GCC) 12.1.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 > # https://github.com/intel-lab-lkp/linux/commit/fa31f117302fc7c15b5d9deeefb8c650554f503d > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 > git checkout fa31f117302fc7c15b5d9deeefb8c650554f503d > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/cpufreq/ > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@intel.com> > | Link: https://lore.kernel.org/oe-kbuild-all/202303211551.eBLRqnv0-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > >>> drivers/cpufreq/tegra194-cpufreq.c:397:5: warning: no previous prototype for 'tegra_cpufreq_init_cpufreq_table' [-Wmissing-prototypes] > 397 | int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Thank you for the report. Adding static to the function prototype fixes the warning. Can we please squash the below change (or) please let me know if i need to re-send the patch. +++ b/drivers/cpufreq/tegra194-cpufreq.c @@ -394,7 +394,7 @@ static unsigned int tegra194_get_speed(u32 cpu) return rate; } -int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, +static int tegra_cpufreq_init_cpufreq_table( struct cpufreq_policy *policy, struct cpufreq_frequency_table *bpmp_lut, struct cpufreq_frequency_table **opp_table) Thank you, Sumit Gupta
On 21/03/2023 12:49, Sumit Gupta wrote: > > > On 21/03/23 13:06, kernel test robot wrote: >> External email: Use caution opening links or attachments >> >> >> Hi Sumit, >> >> Thank you for the patch! Perhaps something to improve: >> >> [auto build test WARNING on robh/for-next] >> [also build test WARNING on krzk-mem-ctrl/for-next pci/next pci/for-linus] >> [cannot apply to tegra/for-next rafael-pm/linux-next linus/master v6.3-rc3 next-20230321] >> [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#_base_tree_information] >> >> url: https://github.com/intel-lab-lkp/linux/commits/Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 >> base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next >> patch link: https://lore.kernel.org/r/20230320182441.11904-8-sumitg%40nvidia.com >> patch subject: [Patch v3 07/11] cpufreq: tegra194: add OPP support and set bandwidth >> config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230321/202303211551.eBLRqnv0-lkp@intel.com/config) >> compiler: aarch64-linux-gcc (GCC) 12.1.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 >> # https://github.com/intel-lab-lkp/linux/commit/fa31f117302fc7c15b5d9deeefb8c650554f503d >> git remote add linux-review https://github.com/intel-lab-lkp/linux >> git fetch --no-tags linux-review Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 >> git checkout fa31f117302fc7c15b5d9deeefb8c650554f503d >> # save the config file >> mkdir build_dir && cp config build_dir/.config >> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig >> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/cpufreq/ >> >> If you fix the issue, kindly add following tag where applicable >> | Reported-by: kernel test robot <lkp@intel.com> >> | Link: https://lore.kernel.org/oe-kbuild-all/202303211551.eBLRqnv0-lkp@intel.com/ >> >> All warnings (new ones prefixed by >>): >> >>>> drivers/cpufreq/tegra194-cpufreq.c:397:5: warning: no previous prototype for 'tegra_cpufreq_init_cpufreq_table' [-Wmissing-prototypes] >> 397 | int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> > > Thank you for the report. > > Adding static to the function prototype fixes the warning. > Can we please squash the below change (or) please let me know if i need > to re-send the patch. You must send new version which does not have warnings. The best if you also build test your code before sending (it's kind of obvious except that it is not). Best regards, Krzysztof
On 22/03/23 23:21, Krzysztof Kozlowski wrote: > External email: Use caution opening links or attachments > > > On 21/03/2023 12:49, Sumit Gupta wrote: >> >> >> On 21/03/23 13:06, kernel test robot wrote: >>> External email: Use caution opening links or attachments >>> >>> >>> Hi Sumit, >>> >>> Thank you for the patch! Perhaps something to improve: >>> >>> [auto build test WARNING on robh/for-next] >>> [also build test WARNING on krzk-mem-ctrl/for-next pci/next pci/for-linus] >>> [cannot apply to tegra/for-next rafael-pm/linux-next linus/master v6.3-rc3 next-20230321] >>> [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#_base_tree_information] >>> >>> url: https://github.com/intel-lab-lkp/linux/commits/Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 >>> base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next >>> patch link: https://lore.kernel.org/r/20230320182441.11904-8-sumitg%40nvidia.com >>> patch subject: [Patch v3 07/11] cpufreq: tegra194: add OPP support and set bandwidth >>> config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230321/202303211551.eBLRqnv0-lkp@intel.com/config) >>> compiler: aarch64-linux-gcc (GCC) 12.1.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 >>> # https://github.com/intel-lab-lkp/linux/commit/fa31f117302fc7c15b5d9deeefb8c650554f503d >>> git remote add linux-review https://github.com/intel-lab-lkp/linux >>> git fetch --no-tags linux-review Sumit-Gupta/firmware-tegra-add-function-to-get-BPMP-data/20230321-024112 >>> git checkout fa31f117302fc7c15b5d9deeefb8c650554f503d >>> # save the config file >>> mkdir build_dir && cp config build_dir/.config >>> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig >>> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/cpufreq/ >>> >>> If you fix the issue, kindly add following tag where applicable >>> | Reported-by: kernel test robot <lkp@intel.com> >>> | Link: https://lore.kernel.org/oe-kbuild-all/202303211551.eBLRqnv0-lkp@intel.com/ >>> >>> All warnings (new ones prefixed by >>): >>> >>>>> drivers/cpufreq/tegra194-cpufreq.c:397:5: warning: no previous prototype for 'tegra_cpufreq_init_cpufreq_table' [-Wmissing-prototypes] >>> 397 | int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, >>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >> >> Thank you for the report. >> >> Adding static to the function prototype fixes the warning. >> Can we please squash the below change (or) please let me know if i need >> to re-send the patch. > > You must send new version which does not have warnings. The best if you > also build test your code before sending (it's kind of obvious except > that it is not). > > Best regards, > Krzysztof > Sorry, missed checking with "W=1". Will take care in v4. Thanks, Sumit
diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c index 5890e25d7f77..038c67339b01 100644 --- a/drivers/cpufreq/tegra194-cpufreq.c +++ b/drivers/cpufreq/tegra194-cpufreq.c @@ -12,6 +12,7 @@ #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/slab.h> +#include <linux/units.h> #include <asm/smp_plat.h> @@ -65,12 +66,36 @@ struct tegra_cpufreq_soc { struct tegra194_cpufreq_data { void __iomem *regs; - struct cpufreq_frequency_table **tables; + struct cpufreq_frequency_table **bpmp_luts; const struct tegra_cpufreq_soc *soc; + bool icc_dram_bw_scaling; }; static struct workqueue_struct *read_counters_wq; +static int tegra_cpufreq_set_bw(struct cpufreq_policy *policy, unsigned long freq_khz) +{ + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); + struct dev_pm_opp *opp; + struct device *dev; + int ret; + + dev = get_cpu_device(policy->cpu); + if (!dev) + return -ENODEV; + + opp = dev_pm_opp_find_freq_exact(dev, freq_khz * KHZ, true); + if (IS_ERR(opp)) + return PTR_ERR(opp); + + ret = dev_pm_opp_set_opp(dev, opp); + if (ret) + data->icc_dram_bw_scaling = false; + + dev_pm_opp_put(opp); + return ret; +} + static void tegra_get_cpu_mpidr(void *mpidr) { *((u64 *)mpidr) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; @@ -354,7 +379,7 @@ static unsigned int tegra194_get_speed(u32 cpu) * to the last written ndiv value from freq_table. This is * done to return consistent value. */ - cpufreq_for_each_valid_entry(pos, data->tables[clusterid]) { + cpufreq_for_each_valid_entry(pos, data->bpmp_luts[clusterid]) { if (pos->driver_data != ndiv) continue; @@ -369,16 +394,93 @@ static unsigned int tegra194_get_speed(u32 cpu) return rate; } +int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *bpmp_lut, + struct cpufreq_frequency_table **opp_table) +{ + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); + struct cpufreq_frequency_table *freq_table = NULL; + struct cpufreq_frequency_table *pos; + struct device *cpu_dev; + struct dev_pm_opp *opp; + unsigned long rate; + int ret, max_opps; + int j = 0; + + cpu_dev = get_cpu_device(policy->cpu); + if (!cpu_dev) { + pr_err("%s: failed to get cpu%d device\n", __func__, policy->cpu); + return -ENODEV; + } + + /* Initialize OPP table mentioned in operating-points-v2 property in DT */ + ret = dev_pm_opp_of_add_table_indexed(cpu_dev, 0); + if (!ret) { + max_opps = dev_pm_opp_get_opp_count(cpu_dev); + if (max_opps <= 0) { + dev_err(cpu_dev, "Failed to add OPPs\n"); + return max_opps; + } + + /* Disable all opps and cross-validate against LUT later */ + for (rate = 0; ; rate++) { + opp = dev_pm_opp_find_freq_ceil(cpu_dev, &rate); + if (IS_ERR(opp)) + break; + + dev_pm_opp_put(opp); + dev_pm_opp_disable(cpu_dev, rate); + } + } else { + dev_err(cpu_dev, "Invalid or empty opp table in device tree\n"); + data->icc_dram_bw_scaling = false; + return ret; + } + + freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_KERNEL); + if (!freq_table) + return -ENOMEM; + + /* + * Cross check the frequencies from BPMP-FW LUT against the OPP's present in DT. + * Enable only those DT OPP's which are present in LUT also. + */ + cpufreq_for_each_valid_entry(pos, bpmp_lut) { + opp = dev_pm_opp_find_freq_exact(cpu_dev, pos->frequency * KHZ, false); + if (IS_ERR(opp)) + continue; + + ret = dev_pm_opp_enable(cpu_dev, pos->frequency * KHZ); + if (ret < 0) + return ret; + + freq_table[j].driver_data = pos->driver_data; + freq_table[j].frequency = pos->frequency; + j++; + } + + freq_table[j].driver_data = pos->driver_data; + freq_table[j].frequency = CPUFREQ_TABLE_END; + + *opp_table = &freq_table[0]; + + dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus); + + return ret; +} + static int tegra194_cpufreq_init(struct cpufreq_policy *policy) { struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); int maxcpus_per_cluster = data->soc->maxcpus_per_cluster; + struct cpufreq_frequency_table *freq_table; + struct cpufreq_frequency_table *bpmp_lut; u32 start_cpu, cpu; u32 clusterid; + int ret; data->soc->ops->get_cpu_cluster_id(policy->cpu, NULL, &clusterid); - - if (clusterid >= data->soc->num_clusters || !data->tables[clusterid]) + if (clusterid >= data->soc->num_clusters || !data->bpmp_luts[clusterid]) return -EINVAL; start_cpu = rounddown(policy->cpu, maxcpus_per_cluster); @@ -387,9 +489,22 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy) if (cpu_possible(cpu)) cpumask_set_cpu(cpu, policy->cpus); } - policy->freq_table = data->tables[clusterid]; policy->cpuinfo.transition_latency = TEGRA_CPUFREQ_TRANSITION_LATENCY; + bpmp_lut = data->bpmp_luts[clusterid]; + + if (data->icc_dram_bw_scaling) { + ret = tegra_cpufreq_init_cpufreq_table(policy, bpmp_lut, &freq_table); + if (!ret) { + policy->freq_table = freq_table; + return 0; + } + } + + data->icc_dram_bw_scaling = false; + policy->freq_table = bpmp_lut; + pr_info("OPP tables missing from DT, EMC frequency scaling disabled\n"); + return 0; } @@ -406,6 +521,9 @@ static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy, */ data->soc->ops->set_cpu_ndiv(policy, (u64)tbl->driver_data); + if (data->icc_dram_bw_scaling) + tegra_cpufreq_set_bw(policy, tbl->frequency); + return 0; } @@ -439,8 +557,8 @@ static void tegra194_cpufreq_free_resources(void) } static struct cpufreq_frequency_table * -init_freq_table(struct platform_device *pdev, struct tegra_bpmp *bpmp, - unsigned int cluster_id) +tegra_cpufreq_bpmp_read_lut(struct platform_device *pdev, struct tegra_bpmp *bpmp, + unsigned int cluster_id) { struct cpufreq_frequency_table *freq_table; struct mrq_cpu_ndiv_limits_response resp; @@ -515,6 +633,7 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) const struct tegra_cpufreq_soc *soc; struct tegra194_cpufreq_data *data; struct tegra_bpmp *bpmp; + struct device *cpu_dev; int err, i; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); @@ -530,9 +649,9 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) return -EINVAL; } - data->tables = devm_kcalloc(&pdev->dev, data->soc->num_clusters, - sizeof(*data->tables), GFP_KERNEL); - if (!data->tables) + data->bpmp_luts = devm_kcalloc(&pdev->dev, data->soc->num_clusters, + sizeof(*data->bpmp_luts), GFP_KERNEL); + if (!data->bpmp_luts) return -ENOMEM; if (soc->actmon_cntr_base) { @@ -556,15 +675,26 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) } for (i = 0; i < data->soc->num_clusters; i++) { - data->tables[i] = init_freq_table(pdev, bpmp, i); - if (IS_ERR(data->tables[i])) { - err = PTR_ERR(data->tables[i]); + data->bpmp_luts[i] = tegra_cpufreq_bpmp_read_lut(pdev, bpmp, i); + if (IS_ERR(data->bpmp_luts[i])) { + err = PTR_ERR(data->bpmp_luts[i]); goto err_free_res; } } tegra194_cpufreq_driver.driver_data = data; + /* Check for optional OPPv2 and interconnect paths on CPU0 to enable ICC scaling */ + cpu_dev = get_cpu_device(0); + if (!cpu_dev) + return -EPROBE_DEFER; + + if (dev_pm_opp_of_get_opp_desc_node(cpu_dev)) { + err = dev_pm_opp_of_find_icc_paths(cpu_dev, NULL); + if (!err) + data->icc_dram_bw_scaling = true; + } + err = cpufreq_register_driver(&tegra194_cpufreq_driver); if (!err) goto put_bpmp;
Add support to use OPP table from DT in Tegra194 cpufreq driver. Tegra SoC's receive the frequency lookup table (LUT) from BPMP-FW. Cross check the OPP's present in DT against the LUT from BPMP-FW and enable only those DT OPP's which are present in LUT also. The OPP table in DT has CPU Frequency to bandwidth mapping where the bandwidth value is per MC channel. DRAM bandwidth depends on the number of MC channels which can vary as per the boot configuration. This per channel bandwidth from OPP table will be later converted by MC driver to final bandwidth value by multiplying with number of channels before sending the request to BPMP-FW. If OPP table is not present in DT, then use the LUT from BPMP-FW directy as the CPU frequency table and not do the DRAM frequency scaling which is same as the current behavior. Now, as the CPU Frequency table is being controlling through OPP table in DT. Keeping fewer entries in the table will create less frequency steps and can help to scale fast to high frequencies when required. Signed-off-by: Sumit Gupta <sumitg@nvidia.com> --- drivers/cpufreq/tegra194-cpufreq.c | 156 ++++++++++++++++++++++++++--- 1 file changed, 143 insertions(+), 13 deletions(-)