]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/msm: Add support for GPU cooling
authorAkhil P Oommen <akhilpo@codeaurora.org>
Fri, 30 Oct 2020 10:47:10 +0000 (16:17 +0530)
committerRob Clark <robdclark@chromium.org>
Thu, 5 Nov 2020 16:39:57 +0000 (08:39 -0800)
Register GPU as a devfreq cooling device so that it can be passively
cooled by the thermal framework.

Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/msm_gpu.c
drivers/gpu/drm/msm/msm_gpu.h

index dbb8400f187281b0bde7c4880c4368dbf2f9b969..dfa3b5ad2099c59d25a128c65720e4661d2a4034 100644 (file)
@@ -14,6 +14,7 @@
 #include <generated/utsrelease.h>
 #include <linux/string_helpers.h>
 #include <linux/devfreq.h>
+#include <linux/devfreq_cooling.h>
 #include <linux/devcoredump.h>
 #include <linux/sched/task.h>
 
@@ -107,9 +108,18 @@ static void msm_devfreq_init(struct msm_gpu *gpu)
        if (IS_ERR(gpu->devfreq.devfreq)) {
                DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
                gpu->devfreq.devfreq = NULL;
+               return;
        }
 
        devfreq_suspend_device(gpu->devfreq.devfreq);
+
+       gpu->cooling = of_devfreq_cooling_register(gpu->pdev->dev.of_node,
+                       gpu->devfreq.devfreq);
+       if (IS_ERR(gpu->cooling)) {
+               DRM_DEV_ERROR(&gpu->pdev->dev,
+                               "Couldn't register GPU cooling device\n");
+               gpu->cooling = NULL;
+       }
 }
 
 static int enable_pwrrail(struct msm_gpu *gpu)
@@ -1044,4 +1054,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
        if (gpu->worker) {
                kthread_destroy_worker(gpu->worker);
        }
+
+       devfreq_cooling_unregister(gpu->cooling);
 }
index 09938ae114ec366a86bdad11746cc008f23d7dbb..786cfc285be0283f294134dc91ccb506ff78a908 100644 (file)
@@ -155,6 +155,8 @@ struct msm_gpu {
        struct msm_gpu_state *crashstate;
        /* True if the hardware supports expanded apriv (a650 and newer) */
        bool hw_apriv;
+
+       struct thermal_cooling_device *cooling;
 };
 
 static inline struct msm_gpu *dev_to_gpu(struct device *dev)