diff options
author | Finley Xiao <finley.xiao@rock-chips.com> | 2018-06-29 16:20:24 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2018-07-06 19:42:07 +0800 |
commit | c891cb339e21defcbff90b19b39544ba47f086d8 (patch) | |
tree | 9aeed48f80a86ecd1106aa0e5e9e25e6aa48016a /drivers/gpu/arm | |
parent | 21d81d9c9c799b1ce3402fedc7a516d58455d9b7 (diff) |
MALI: bifrost: Add wide-temperature control
Change-Id: I74ec8bed3065740148814114a72b2740e58688e6
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Diffstat (limited to 'drivers/gpu/arm')
4 files changed, 33 insertions, 0 deletions
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 0ea045c23f3e..ce6f8d7fb4e0 100644 --- a/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c @@ -47,6 +47,13 @@ #define dev_pm_opp_find_freq_ceil opp_find_freq_ceil #define dev_pm_opp_find_freq_floor opp_find_freq_floor #endif /* Linux >= 3.13 */ +#include <soc/rockchip/rockchip_opp_select.h> + +static struct thermal_opp_device_data gpu_devdata = { + .type = THERMAL_OPP_TPYE_DEV, + .low_temp_adjust = rockchip_dev_low_temp_adjust, + .high_temp_adjust = rockchip_dev_high_temp_adjust, +}; /** * opp_translate - Translate nominal OPP frequency from devicetree into real @@ -396,6 +403,13 @@ int kbase_devfreq_init(struct kbase_device *kbdev) devfreq_recommended_opp(kbdev->dev, &opp_rate, 0); rcu_read_unlock(); kbdev->devfreq->last_status.current_frequency = opp_rate; + gpu_devdata.data = kbdev->devfreq; + kbdev->opp_info = rockchip_register_thermal_notifier(kbdev->dev, + &gpu_devdata); + if (IS_ERR(kbdev->opp_info)) { + dev_dbg(kbdev->dev, "without thermal notifier\n"); + kbdev->opp_info = NULL; + } #ifdef CONFIG_DEVFREQ_THERMAL err = kbase_ipa_init(kbdev); if (err) { @@ -437,6 +451,7 @@ void kbase_devfreq_term(struct kbase_device *kbdev) dev_dbg(kbdev->dev, "Term Mali devfreq\n"); + rockchip_unregister_thermal_notifier(kbdev->opp_info); #ifdef CONFIG_DEVFREQ_THERMAL if (kbdev->devfreq_cooling) devfreq_cooling_unregister(kbdev->devfreq_cooling); diff --git a/drivers/gpu/arm/bifrost/mali_kbase_defs.h b/drivers/gpu/arm/bifrost/mali_kbase_defs.h index 908293236ec4..a79d01dca13b 100644 --- a/drivers/gpu/arm/bifrost/mali_kbase_defs.h +++ b/drivers/gpu/arm/bifrost/mali_kbase_defs.h @@ -1536,6 +1536,7 @@ struct kbase_device { struct kbase_devfreq_opp *opp_table; int num_opps; struct kbasep_pm_metrics last_devfreq_metrics; + struct thermal_opp_info *opp_info; #ifdef CONFIG_DEVFREQ_THERMAL #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) struct devfreq_cooling_device *devfreq_cooling; diff --git a/drivers/gpu/arm/bifrost_for_linux/backend/gpu/mali_kbase_devfreq.c b/drivers/gpu/arm/bifrost_for_linux/backend/gpu/mali_kbase_devfreq.c index 9e7f1276048a..a69008437fa1 100644 --- a/drivers/gpu/arm/bifrost_for_linux/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/bifrost_for_linux/backend/gpu/mali_kbase_devfreq.c @@ -43,6 +43,14 @@ #define dev_pm_opp_find_freq_floor opp_find_freq_floor #endif /* Linux >= 3.13 */ +#include <soc/rockchip/rockchip_opp_select.h> + +static struct thermal_opp_device_data gpu_devdata = { + .type = THERMAL_OPP_TPYE_DEV, + .low_temp_adjust = rockchip_dev_low_temp_adjust, + .high_temp_adjust = rockchip_dev_high_temp_adjust, +}; + /** * opp_translate - Translate nominal OPP frequency from devicetree into real * frequency and core mask @@ -369,6 +377,13 @@ int kbase_devfreq_init(struct kbase_device *kbdev) devfreq_recommended_opp(kbdev->dev, &opp_rate, 0); rcu_read_unlock(); kbdev->devfreq->last_status.current_frequency = opp_rate; + gpu_devdata.data = kbdev->devfreq; + kbdev->opp_info = rockchip_register_thermal_notifier(kbdev->dev, + &gpu_devdata); + if (IS_ERR(kbdev->opp_info)) { + dev_dbg(kbdev->dev, "without thermal notifier\n"); + kbdev->opp_info = NULL; + } #ifdef CONFIG_DEVFREQ_THERMAL err = kbase_ipa_init(kbdev); if (err) { @@ -410,6 +425,7 @@ void kbase_devfreq_term(struct kbase_device *kbdev) dev_dbg(kbdev->dev, "Term Mali devfreq\n"); + rockchip_unregister_thermal_notifier(kbdev->opp_info); #ifdef CONFIG_DEVFREQ_THERMAL if (kbdev->devfreq_cooling) devfreq_cooling_unregister(kbdev->devfreq_cooling); diff --git a/drivers/gpu/arm/bifrost_for_linux/mali_kbase_defs.h b/drivers/gpu/arm/bifrost_for_linux/mali_kbase_defs.h index d957c1461440..14b596c07fe7 100644 --- a/drivers/gpu/arm/bifrost_for_linux/mali_kbase_defs.h +++ b/drivers/gpu/arm/bifrost_for_linux/mali_kbase_defs.h @@ -1126,6 +1126,7 @@ struct kbase_device { u64 current_core_mask; struct kbase_devfreq_opp *opp_table; int num_opps; + struct thermal_opp_info *opp_info; #ifdef CONFIG_DEVFREQ_THERMAL #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) struct devfreq_cooling_device *devfreq_cooling; |