Re: [Freedreno] [PATCH 8/8] drm/msm/gpu: Add devfreq support for the GPU

2017-11-23 Thread kbuild test robot
Hi Jordan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on robclark/msm-next]
[also build test ERROR on next-20171122]
[cannot apply to v4.14]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jordan-Crouse/msm-gpu-devfreq-support/20171124-022911
base:   git://people.freedesktop.org/~robclark/linux msm-next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

>> ERROR: "__aeabi_uldivmod" [drivers/gpu/drm/msm/msm.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


Re: [Freedreno] [PATCH 8/8] drm/msm/gpu: Add devfreq support for the GPU

2017-11-23 Thread kbuild test robot
Hi Jordan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on robclark/msm-next]
[also build test ERROR on next-20171122]
[cannot apply to v4.14]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jordan-Crouse/msm-gpu-devfreq-support/20171124-022911
base:   git://people.freedesktop.org/~robclark/linux msm-next
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/msm/msm_gpu.o: In function `msm_devfreq_get_dev_status':
>> msm_gpu.c:(.text+0x558): undefined reference to `__aeabi_uldivmod'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno


[Freedreno] [PATCH 8/8] drm/msm/gpu: Add devfreq support for the GPU

2017-11-21 Thread Jordan Crouse
Add support for devfreq to dynamically control the GPU frequency.
By default try to use the 'simple_ondemand' governor which can
adjust the frequency based on GPU load.

Signed-off-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   | 12 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.c |  1 -
 drivers/gpu/drm/msm/msm_gpu.c   | 90 +
 drivers/gpu/drm/msm/msm_gpu.h   |  7 +++
 4 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index 56c2c44..7e09d44 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -600,6 +600,9 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
/* Select CP0 to always count cycles */
gpu_write(gpu, REG_A5XX_CP_PERFCTR_CP_SEL_0, PERF_CP_ALWAYS_COUNT);
 
+   /* Select RBBM0 to countable 6 to get the busy status for devfreq */
+   gpu_write(gpu, REG_A5XX_RBBM_PERFCTR_RBBM_SEL_0, 6);
+
/* Increase VFD cache access so LRZ and other data gets evicted less */
gpu_write(gpu, REG_A5XX_UCHE_CACHE_WAYS, 0x02);
 
@@ -1170,6 +1173,14 @@ static struct msm_ringbuffer *a5xx_active_ring(struct 
msm_gpu *gpu)
return a5xx_gpu->cur_ring;
 }
 
+static int a5xx_gpu_busy(struct msm_gpu *gpu, uint64_t *value)
+{
+   *value = gpu_read64(gpu, REG_A5XX_RBBM_PERFCTR_RBBM_0_LO,
+   REG_A5XX_RBBM_PERFCTR_RBBM_0_HI);
+
+   return 0;
+}
+
 static const struct adreno_gpu_funcs funcs = {
.base = {
.get_param = adreno_get_param,
@@ -1185,6 +1196,7 @@ static struct msm_ringbuffer *a5xx_active_ring(struct 
msm_gpu *gpu)
 #ifdef CONFIG_DEBUG_FS
.show = a5xx_show,
 #endif
+   .gpu_busy = a5xx_gpu_busy,
},
.get_timestamp = a5xx_get_timestamp,
 };
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index b4bac84..de63ff2 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -22,7 +22,6 @@
 #include "msm_gem.h"
 #include "msm_mmu.h"
 
-
 int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
 {
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 3d00e7a..243e06e 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -21,12 +21,90 @@
 #include "msm_fence.h"
 
 #include 
+#include 
+#include 
 
 
 /*
  * Power Management:
  */
 
+static int msm_devfreq_target(struct device *dev, unsigned long *freq,
+   u32 flags)
+{
+   struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev));
+   struct dev_pm_opp *opp;
+
+   opp = dev_pm_opp_find_freq_ceil(dev, freq);
+
+   if (!IS_ERR(opp)) {
+   clk_set_rate(gpu->core_clk, *freq);
+   dev_pm_opp_put(opp);
+   }
+
+   return 0;
+}
+
+static int msm_devfreq_get_dev_status(struct device *dev,
+   struct devfreq_dev_status *status)
+{
+   struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev));
+   u64 cycles;
+   ktime_t time;
+
+   status->current_frequency = (unsigned long) clk_get_rate(gpu->core_clk);
+   gpu->funcs->gpu_busy(gpu, );
+
+   status->busy_time = (cycles - gpu->devfreq.busy_cycles) /
+   (status->current_frequency / 100);
+
+   gpu->devfreq.busy_cycles = cycles;
+
+   time = ktime_get();
+   status->total_time = ktime_us_delta(time, gpu->devfreq.time);
+   gpu->devfreq.time = time;
+
+   return 0;
+}
+
+static int msm_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
+{
+   struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev));
+
+   *freq = (unsigned long) clk_get_rate(gpu->core_clk);
+
+   return 0;
+}
+
+static struct devfreq_dev_profile msm_devfreq_profile = {
+   .polling_ms = 10,
+   .target = msm_devfreq_target,
+   .get_dev_status = msm_devfreq_get_dev_status,
+   .get_cur_freq = msm_devfreq_get_cur_freq,
+};
+
+static void msm_devfreq_init(struct msm_gpu *gpu)
+{
+   /* We need target support to do devfreq */
+   if (!gpu->funcs->gpu_busy)
+   return;
+
+   msm_devfreq_profile.initial_freq = gpu->fast_rate;
+
+   /*
+* Don't set the freq_table or max_state and let devfreq build the table
+* from OPP
+*/
+
+   gpu->devfreq.devfreq = devm_devfreq_add_device(>pdev->dev,
+   _devfreq_profile, "simple_ondemand", NULL);
+
+   if (IS_ERR(gpu->devfreq.devfreq)) {
+   dev_err(>pdev->dev, "Couldn't initialize GPU devfreq\n");
+   gpu->devfreq.devfreq = NULL;
+   }
+}
+
 static int enable_pwrrail(struct msm_gpu *gpu)
 {
struct drm_device *dev = gpu->dev;
@@ -140,6 +218,13 @@ int