From: chenzhen Date: Thu, 23 Feb 2017 02:01:42 +0000 (+0800) Subject: Revert "Revert "MALI: midgard: avoid GPU voltage domain keeping the initial voltage"" X-Git-Tag: firefly_0821_release~333 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6b022755ac35d9c07295d93f118b448612abb511;p=firefly-linux-kernel-4.4.55.git Revert "Revert "MALI: midgard: avoid GPU voltage domain keeping the initial voltage"" This reverts commit e7db50b51268386fd0e9f88a95c45a4ef3454c4e. Change-Id: I47f9c1d114b06264d6dd4098bc0e00228fd8f187 Signed-off-by: chenzhen --- 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 2306c757735c..22f67916b549 100644 --- a/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c +++ b/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c @@ -54,6 +54,7 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) struct kbase_device *kbdev = dev_get_drvdata(dev); struct dev_pm_opp *opp; unsigned long freq = 0; + unsigned long old_freq = kbdev->current_freq; unsigned long voltage; int err; @@ -71,14 +72,24 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) /* * Only update if there is a change of frequency */ - if (kbdev->current_freq == freq) { + if (old_freq == freq) { *target_freq = freq; +#ifdef CONFIG_REGULATOR + if (kbdev->current_voltage == voltage) + return 0; + err = regulator_set_voltage(kbdev->regulator, voltage, voltage); + if (err) { + dev_err(dev, "Failed to set voltage (%d)\n", err); + return err; + } +#else return 0; +#endif } #ifdef CONFIG_REGULATOR - if (kbdev->regulator && kbdev->current_voltage != voltage - && kbdev->current_freq < freq) { + if (kbdev->regulator && kbdev->current_voltage != voltage && + old_freq < freq) { err = regulator_set_voltage(kbdev->regulator, voltage, voltage); if (err) { dev_err(dev, "Failed to increase voltage (%d)\n", err); @@ -93,10 +104,12 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) freq, *target_freq); return err; } + *target_freq = freq; + kbdev->current_freq = freq; #ifdef CONFIG_REGULATOR - if (kbdev->regulator && kbdev->current_voltage != voltage - && kbdev->current_freq > freq) { + if (kbdev->regulator && kbdev->current_voltage != voltage && + old_freq > freq) { err = regulator_set_voltage(kbdev->regulator, voltage, voltage); if (err) { dev_err(dev, "Failed to decrease voltage (%d)\n", err); @@ -105,9 +118,7 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) } #endif - *target_freq = freq; kbdev->current_voltage = voltage; - kbdev->current_freq = freq; kbase_tlstream_aux_devfreq_target((u64)freq); @@ -212,6 +223,11 @@ int kbase_devfreq_init(struct kbase_device *kbdev) return -ENODEV; kbdev->current_freq = clk_get_rate(kbdev->clock); +#ifdef CONFIG_REGULATOR + if (kbdev->regulator) + kbdev->current_voltage = + regulator_get_voltage(kbdev->regulator); +#endif dp = &kbdev->devfreq_profile;