drm/msm/gpu: Add devfreq tuning debugfs
authorRob Clark <robdclark@chromium.org>
Tue, 10 Jan 2023 23:14:42 +0000 (15:14 -0800)
committerRob Clark <robdclark@chromium.org>
Mon, 16 Jan 2023 18:40:18 +0000 (10:40 -0800)
Make the handful of tuning knobs available visible via debugfs.

v2: select DEVFREQ_GOV_SIMPLE_ONDEMAND because for some reason
    struct devfreq_simple_ondemand_data depends on this

Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/517784/
Link: https://lore.kernel.org/r/20230110231447.1939101-2-robdclark@gmail.com
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
drivers/gpu/drm/msm/Kconfig
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/msm_debugfs.c
drivers/gpu/drm/msm/msm_drv.h
drivers/gpu/drm/msm/msm_gpu.h
drivers/gpu/drm/msm/msm_gpu_devfreq.c

index 3c9dfdb0b328317833e083ca06bc5e3da746d490..f7abacb4b221be03982be32f762bb10397797b01 100644 (file)
@@ -23,6 +23,7 @@ config DRM_MSM
        select SHMEM
        select TMPFS
        select QCOM_SCM
+       select DEVFREQ_GOV_SIMPLE_ONDEMAND
        select WANT_DEV_COREDUMP
        select SND_SOC_HDMI_CODEC if SND_SOC
        select SYNC_FILE
index 36c8fb699b56be46193c3a04c41868b858df7e70..6f7401f2acdae6b59626daefa1c168e380dcf143 100644 (file)
@@ -2021,7 +2021,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
         * to cause power supply issues:
         */
        if (adreno_is_a618(adreno_gpu) || adreno_is_7c3(adreno_gpu))
-               gpu->clamp_to_idle = true;
+               priv->gpu_clamp_to_idle = true;
 
        /* Check if there is a GMU phandle and set it up */
        node = of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0);
index 95f4374ae21c2212c3dfa7c19e53627a71d6da37..d6ecff0ab6187cb7832e5c0ca59774d3614be5ac 100644 (file)
@@ -305,6 +305,7 @@ void msm_debugfs_init(struct drm_minor *minor)
 {
        struct drm_device *dev = minor->dev;
        struct msm_drm_private *priv = dev->dev_private;
+       struct dentry *gpu_devfreq;
 
        drm_debugfs_create_files(msm_debugfs_list,
                                 ARRAY_SIZE(msm_debugfs_list),
@@ -325,6 +326,17 @@ void msm_debugfs_init(struct drm_minor *minor)
        debugfs_create_file("shrink", S_IRWXU, minor->debugfs_root,
                dev, &shrink_fops);
 
+       gpu_devfreq = debugfs_create_dir("devfreq", minor->debugfs_root);
+
+       debugfs_create_bool("idle_clamp",0600, gpu_devfreq,
+                           &priv->gpu_clamp_to_idle);
+
+       debugfs_create_u32("upthreshold",0600, gpu_devfreq,
+                          &priv->gpu_devfreq_config.upthreshold);
+
+       debugfs_create_u32("downdifferential",0600, gpu_devfreq,
+                          &priv->gpu_devfreq_config.downdifferential);
+
        if (priv->kms && priv->kms->funcs->debugfs_init)
                priv->kms->funcs->debugfs_init(priv->kms, minor);
 
index d4e0ef608950eadebff22df39221d09965cb101f..81deb112ea4466e6f06843c927bbdb4673b7d179 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
+#include <linux/devfreq.h>
 #include <linux/module.h>
 #include <linux/component.h>
 #include <linux/platform_device.h>
@@ -233,6 +234,14 @@ struct msm_drm_private {
         */
        unsigned int hangcheck_period;
 
+       /** gpu_devfreq_config: Devfreq tuning config for the GPU. */
+       struct devfreq_simple_ondemand_data gpu_devfreq_config;
+
+       /**
+        * gpu_clamp_to_idle: Enable clamping to idle freq when inactive
+        */
+       bool gpu_clamp_to_idle;
+
        /**
         * disable_err_irq:
         *
index 651786bc55e5a8a989a882840ac62857f1f41017..9e36f6c9bc29686bd50ecae72a60ae3c58bcbbf3 100644 (file)
@@ -275,9 +275,6 @@ struct msm_gpu {
 
        struct msm_gpu_state *crashstate;
 
-       /* Enable clamping to idle freq when inactive: */
-       bool clamp_to_idle;
-
        /* True if the hardware supports expanded apriv (a650 and newer) */
        bool hw_apriv;
 
index 85c443a37e4e82ee53bff95a4c1795ef5c9bfa06..1f4e2dd8e76dd03e4c42ba1dda0156a8f497a877 100644 (file)
@@ -183,6 +183,7 @@ static bool has_devfreq(struct msm_gpu *gpu)
 void msm_devfreq_init(struct msm_gpu *gpu)
 {
        struct msm_gpu_devfreq *df = &gpu->devfreq;
+       struct msm_drm_private *priv = gpu->dev->dev_private;
 
        /* We need target support to do devfreq */
        if (!gpu->funcs->gpu_busy)
@@ -209,7 +210,7 @@ void msm_devfreq_init(struct msm_gpu *gpu)
 
        df->devfreq = devm_devfreq_add_device(&gpu->pdev->dev,
                        &msm_devfreq_profile, DEVFREQ_GOV_SIMPLE_ONDEMAND,
-                       NULL);
+                       &priv->gpu_devfreq_config);
 
        if (IS_ERR(df->devfreq)) {
                DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
@@ -358,10 +359,11 @@ static void msm_devfreq_idle_work(struct kthread_work *work)
        struct msm_gpu_devfreq *df = container_of(work,
                        struct msm_gpu_devfreq, idle_work.work);
        struct msm_gpu *gpu = container_of(df, struct msm_gpu, devfreq);
+       struct msm_drm_private *priv = gpu->dev->dev_private;
 
        df->idle_time = ktime_get();
 
-       if (gpu->clamp_to_idle)
+       if (priv->gpu_clamp_to_idle)
                dev_pm_qos_update_request(&df->idle_freq, 0);
 }