Mali: midgard: Use new APIs for devfreq

Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Change-Id: Ib624fcb78606fc9a0c04680ae35dcc2eb75ffe8b
This commit is contained in:
Finley Xiao
2023-06-08 21:30:32 +08:00
committed by Tao Huang
parent 7724cd7e46
commit 5577e94f30
4 changed files with 15 additions and 4 deletions

View File

@@ -341,6 +341,7 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
struct devfreq_dev_profile *dp;
struct dev_pm_opp *opp;
unsigned long opp_rate;
unsigned int dyn_power_coeff = 0;
int err;
if (!kbdev->clock) {
@@ -372,6 +373,10 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
&ondemand_data.upthreshold);
of_property_read_u32(np, "downdifferential",
&ondemand_data.downdifferential);
of_property_read_u32(kbdev->dev->of_node, "dynamic-power-coefficient",
&dyn_power_coeff);
if (dyn_power_coeff)
dp->is_cooling_device = true;
kbdev->devfreq = devfreq_add_device(kbdev->dev, dp,
"simple_ondemand", &ondemand_data);
@@ -407,14 +412,16 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
kbdev->mdev_info = NULL;
}
#ifdef CONFIG_DEVFREQ_THERMAL
if (dp->is_cooling_device)
return 0;
err = kbase_ipa_init(kbdev);
if (err) {
dev_err(kbdev->dev, "IPA initialization failed\n");
goto cooling_failed;
}
kbdev->devfreq_cooling = of_devfreq_cooling_register_power(
kbdev->dev->of_node,
kbdev->devfreq_cooling = devfreq_cooling_em_register(
kbdev->devfreq,
&kbase_ipa_power_model_ops);
if (IS_ERR_OR_NULL(kbdev->devfreq_cooling)) {

View File

@@ -458,6 +458,7 @@ static u32 get_static_power_locked(struct kbase_device *kbdev,
return power;
}
__maybe_unused
#ifdef CONFIG_MALI_PWRSOFT_765
static unsigned long kbase_get_static_power(struct devfreq *df,
unsigned long voltage)
@@ -487,6 +488,7 @@ static unsigned long kbase_get_static_power(unsigned long voltage)
return power;
}
__maybe_unused
#ifdef CONFIG_MALI_PWRSOFT_765
static unsigned long kbase_get_dynamic_power(struct devfreq *df,
unsigned long freq,
@@ -579,7 +581,9 @@ struct devfreq_cooling_ops kbase_ipa_power_model_ops = {
#else
struct devfreq_cooling_power kbase_ipa_power_model_ops = {
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
.get_static_power = &kbase_get_static_power,
.get_dynamic_power = &kbase_get_dynamic_power,
#endif
};
KBASE_EXPORT_TEST_API(kbase_ipa_power_model_ops);

View File

@@ -4140,7 +4140,7 @@ static int kbase_device_debugfs_init(struct kbase_device *kbdev)
#ifdef CONFIG_MALI_DEVFREQ
#ifdef CONFIG_DEVFREQ_THERMAL
if (kbdev->inited_subsys & inited_devfreq)
if ((kbdev->inited_subsys & inited_devfreq) && kbdev->devfreq_cooling)
kbase_ipa_debugfs_init(kbdev);
#endif /* CONFIG_DEVFREQ_THERMAL */
#endif /* CONFIG_MALI_DEVFREQ */

View File

@@ -488,5 +488,5 @@ int kbase_platform_rk_init_opp_table(struct kbase_device *kbdev)
rockchip_get_opp_data(rockchip_mali_of_match, &kbdev->opp_info);
return rockchip_init_opp_table(kbdev->dev, &kbdev->opp_info,
"gpu_leakage", "mali");
NULL, "mali");
}