From 5d88f40f5adcd9599e841cc79c29b158d6342491 Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Mon, 7 May 2018 16:17:29 +0800 Subject: [PATCH] MALI: rockchip: Ensure that set voltage when update devfreq for the first time Sometimes the regulator is shared between several devices, if target rate and target voltage are equal to initial rate and iniital voltage , the min_uV and max_uV of regulator will be always equal to zero, other devices may set a low voltage. Change-Id: Ibf82f335ce0739776286e3733be5415f84bf035b Signed-off-by: Finley Xiao --- .../gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c | 5 ----- .../bifrost_for_linux/backend/gpu/mali_kbase_devfreq.c | 5 ----- drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c | 2 -- .../gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c | 10 ++++++++++ .../midgard_for_linux/backend/gpu/mali_kbase_devfreq.c | 10 ++++++++++ 5 files changed, 20 insertions(+), 12 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 027eeeb6575b..f9605fc1ae53 100644 --- a/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_devfreq.c @@ -349,11 +349,6 @@ int kbase_devfreq_init(struct kbase_device *kbdev) kbdev->current_freq = clk_get_rate(kbdev->clock); kbdev->current_nominal_freq = kbdev->current_freq; -#ifdef CONFIG_REGULATOR - if (kbdev->regulator) - kbdev->current_voltage = - regulator_get_voltage(kbdev->regulator); -#endif dp = &kbdev->devfreq_profile; 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 99b39cafb62a..9e7f1276048a 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 @@ -329,11 +329,6 @@ int kbase_devfreq_init(struct kbase_device *kbdev) kbdev->current_freq = clk_get_rate(kbdev->clock); kbdev->current_nominal_freq = kbdev->current_freq; -#ifdef CONFIG_REGULATOR - if (kbdev->regulator) - kbdev->current_voltage = - regulator_get_voltage(kbdev->regulator); -#endif dp = &kbdev->devfreq_profile; diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c b/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c index 6e2d29a1e29e..06c83f017165 100644 --- a/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c +++ b/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c @@ -237,8 +237,6 @@ int mali_devfreq_init(struct mali_device *mdev) return -ENODEV; mdev->current_freq = clk_get_rate(mdev->clock); - if (mdev->regulator) - mdev->current_voltage = regulator_get_voltage(mdev->regulator); dp = &mdev->devfreq_profile; diff --git a/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c b/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c index 86e23ca0225a..0127d2a1d66f 100644 --- a/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c @@ -108,6 +108,16 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) */ if (kbdev->current_nominal_freq == nominal_freq) { *target_freq = nominal_freq; +#ifdef CONFIG_REGULATOR + if (kbdev->current_voltage == voltage) + return 0; + err = regulator_set_voltage(kbdev->regulator, voltage, INT_MAX); + if (err) { + dev_err(dev, "Failed to set voltage (%d)\n", err); + return err; + } + kbdev->current_voltage = voltage; +#endif return 0; } diff --git a/drivers/gpu/arm/midgard_for_linux/backend/gpu/mali_kbase_devfreq.c b/drivers/gpu/arm/midgard_for_linux/backend/gpu/mali_kbase_devfreq.c index 1fb28302d7c2..3c7fdeaa9542 100644 --- a/drivers/gpu/arm/midgard_for_linux/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/midgard_for_linux/backend/gpu/mali_kbase_devfreq.c @@ -73,6 +73,16 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) */ if (kbdev->current_freq == freq) { *target_freq = freq; +#ifdef CONFIG_REGULATOR + if (kbdev->current_voltage == voltage) + return 0; + err = regulator_set_voltage(kbdev->regulator, voltage, INT_MAX); + if (err) { + dev_err(dev, "Failed to set voltage (%d)\n", err); + return err; + } + kbdev->current_voltage = voltage; +#endif return 0; }