diff --git a/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c b/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c index e585e511e635..740363295932 100644 --- a/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c @@ -670,14 +670,11 @@ static unsigned long kbase_devfreq_get_static_power(struct devfreq *devfreq, return rockchip_ipa_get_static_power(kbdev->model_data, voltage); } -static struct devfreq_cooling_power kbase_cooling_power = { - .get_static_power = &kbase_devfreq_get_static_power, -}; - int kbase_devfreq_init(struct kbase_device *kbdev) { - struct devfreq_cooling_power *kbase_dcp = &kbase_cooling_power; + struct devfreq_cooling_power *kbase_dcp = &kbdev->dfc_power; struct device_node *np = kbdev->dev->of_node; + struct device_node *model_node; struct devfreq_dev_profile *dp; int err; struct dev_pm_opp *opp; @@ -776,26 +773,33 @@ int kbase_devfreq_init(struct kbase_device *kbdev) mali_mdevp.is_checked = true; } #if IS_ENABLED(CONFIG_DEVFREQ_THERMAL) - if (of_find_compatible_node(kbdev->dev->of_node, NULL, - "simple-power-model")) { - of_property_read_u32(kbdev->dev->of_node, - "dynamic-power-coefficient", - (u32 *)&kbase_dcp->dyn_power_coeff); - kbdev->model_data = rockchip_ipa_power_model_init(kbdev->dev, - "gpu_leakage"); + of_property_read_u32(kbdev->dev->of_node, "dynamic-power-coefficient", + (u32 *)&kbase_dcp->dyn_power_coeff); + model_node = of_get_compatible_child(kbdev->dev->of_node, + "simple-power-model"); + if (model_node) { + of_node_put(model_node); + kbdev->model_data = + rockchip_ipa_power_model_init(kbdev->dev, + "gpu_leakage"); if (IS_ERR_OR_NULL(kbdev->model_data)) { kbdev->model_data = NULL; - dev_err(kbdev->dev, "failed to initialize power model\n"); - } else if (kbdev->model_data->dynamic_coefficient) { - kbase_dcp->dyn_power_coeff = - kbdev->model_data->dynamic_coefficient; - } - if (!kbase_dcp->dyn_power_coeff) { - err = -EINVAL; - dev_err(kbdev->dev, "failed to get dynamic-coefficient\n"); - goto ipa_init_failed; + if (kbase_dcp->dyn_power_coeff) + dev_info(kbdev->dev, + "only calculate dynamic power\n"); + else + dev_err(kbdev->dev, + "failed to initialize power model\n"); + } else { + kbase_dcp->get_static_power = + kbase_devfreq_get_static_power; + if (kbdev->model_data->dynamic_coefficient) + kbase_dcp->dyn_power_coeff = + kbdev->model_data->dynamic_coefficient; } + } + if (kbase_dcp->dyn_power_coeff) { kbdev->devfreq_cooling = of_devfreq_cooling_register_power(kbdev->dev->of_node, kbdev->devfreq, @@ -803,7 +807,7 @@ int kbase_devfreq_init(struct kbase_device *kbdev) if (IS_ERR(kbdev->devfreq_cooling)) { err = PTR_ERR(kbdev->devfreq_cooling); dev_err(kbdev->dev, "failed to register cooling device\n"); - goto cooling_reg_failed; + goto ipa_init_failed; } } else { err = kbase_ipa_init(kbdev); diff --git a/drivers/gpu/arm/bifrost/mali_kbase_core_linux.c b/drivers/gpu/arm/bifrost/mali_kbase_core_linux.c index c62bb32222de..3b97463a244a 100644 --- a/drivers/gpu/arm/bifrost/mali_kbase_core_linux.c +++ b/drivers/gpu/arm/bifrost/mali_kbase_core_linux.c @@ -4821,7 +4821,8 @@ int kbase_device_debugfs_init(struct kbase_device *kbdev) #ifdef CONFIG_MALI_BIFROST_DEVFREQ #if IS_ENABLED(CONFIG_DEVFREQ_THERMAL) - if (kbdev->devfreq && !kbdev->model_data) + if (kbdev->devfreq && !kbdev->model_data && + !kbdev->dfc_power.dyn_power_coeff) kbase_ipa_debugfs_init(kbdev); #endif /* CONFIG_DEVFREQ_THERMAL */ #endif /* CONFIG_MALI_BIFROST_DEVFREQ */ diff --git a/drivers/gpu/arm/bifrost/mali_kbase_defs.h b/drivers/gpu/arm/bifrost/mali_kbase_defs.h index c88fdf30cab6..dc771f213091 100755 --- a/drivers/gpu/arm/bifrost/mali_kbase_defs.h +++ b/drivers/gpu/arm/bifrost/mali_kbase_defs.h @@ -63,6 +63,10 @@ #include #endif /* CONFIG_MALI_BIFROST_DEVFREQ */ +#if IS_ENABLED(CONFIG_DEVFREQ_THERMAL) +#include +#endif + #ifdef CONFIG_MALI_ARBITER_SUPPORT #include #endif /* CONFIG_MALI_ARBITER_SUPPORT */ @@ -1077,6 +1081,7 @@ struct kbase_device { struct kbase_devfreq_queue_info devfreq_queue; #if IS_ENABLED(CONFIG_DEVFREQ_THERMAL) + struct devfreq_cooling_power dfc_power; struct thermal_cooling_device *devfreq_cooling; bool ipa_protection_mode_switched; struct {