]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00241739-2 gpu: Enable thermal hot notification in gpu driver
authorRong Dian <b38775@freescale.com>
Mon, 28 Jan 2013 05:40:20 +0000 (13:40 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:52 +0000 (08:35 +0200)
Using notify mechanism instead of global variable to
trigger gpu3d clock change through thermal driver

Signed-off-by: Rong Dian <b38775@freescale.com>
Signed-off-by: Loren Huang <b02279@freescale.com>
Acked-by: Lily Zhang
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command.c
drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c

index 06bebeef001afb65205e12bcaced7c1ff99ce6c0..952ee88dd9b37abcd314af4528293eba34f20fee 100644 (file)
@@ -30,9 +30,6 @@
 
 #define _GC_OBJ_ZONE            gcvZONE_COMMAND
 
-#if gcdENABLE_FSCALE_VAL_ADJUST
-extern int thermal_hot;
-#endif
 /******************************************************************************\
 ********************************* Support Code *********************************
 \******************************************************************************/
@@ -1163,24 +1160,6 @@ gckCOMMAND_Commit(
     /* Extract the gckHARDWARE and gckEVENT objects. */
     hardware = Command->kernel->hardware;
 
-#if gcdENABLE_FSCALE_VAL_ADJUST
-    if(hardware->core == gcvCORE_MAJOR){
-        static gctUINT orgFscale,minFscale,maxFscale;
-        static gctBOOL bAlreadyTooHot = gcvFALSE;
-        if((thermal_hot > 0) && (!bAlreadyTooHot)) {
-            gckHARDWARE_GetFscaleValue(hardware,&orgFscale,&minFscale, &maxFscale);
-            gckHARDWARE_SetFscaleValue(hardware, minFscale);
-            bAlreadyTooHot = gcvTRUE;
-            gckOS_Print("System is too hot. GPU3D will work at %d/64 clock.\n", minFscale);
-        } else if((!(thermal_hot > 0)) && bAlreadyTooHot) {
-            gckHARDWARE_SetFscaleValue(hardware, orgFscale);
-            gckOS_Print("Hot alarm is canceled. GPU3D clock will return to %d/64\n", orgFscale);
-            bAlreadyTooHot = gcvFALSE;
-        }
-
-    }
-#endif
-
     /* Check wehther we need to copy the structures or not. */
     gcmkONERROR(gckOS_QueryNeedCopy(Command->os, ProcessID, &needCopy));
 
index e7e148d5558c1b0a252099f12bb37639c78bd0a9..537e58c714b2f00ebee983fa2c20d91a7aecf29b 100644 (file)
 #   define gcdVIRTUAL_COMMAND_BUFFER            0
 #endif
 
-/*
-    gcdENABLE_FSCALE_VAL_ADJUST
-        When non-zero, FSCALE_VAL when gcvPOWER_ON can be adjusted externally.
- */
-#ifndef gcdENABLE_FSCALE_VAL_ADJUST
-#   define gcdENABLE_FSCALE_VAL_ADJUST          0
-#endif
-
 /*
     gcdENABLE_FSCALE_VAL_ADJUST
         When non-zero, FSCALE_VAL when gcvPOWER_ON can be adjusted externally.
index 7586bca52095915334a7eea4dc2c4b4a0818c477..0fc189198b788529dadcc2be7d82051fecff98a7 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/device.h>
 #include <linux/slab.h>
+#include <linux/notifier.h>
 #include "gc_hal_kernel_linux.h"
 #include "gc_hal_driver.h"
 
 /* Zone used for header/footer. */
 #define _GC_OBJ_ZONE    gcvZONE_DRIVER
 
+#if gcdENABLE_FSCALE_VAL_ADJUST
+extern int register_thermal_notifier(struct notifier_block *nb);
+extern int unregister_thermal_notifier(struct notifier_block *nb);
+#endif
+
 MODULE_DESCRIPTION("Vivante Graphics Driver");
 MODULE_LICENSE("GPL");
 
@@ -953,6 +959,34 @@ static void drv_exit(void)
 #   define DEVICE_NAME "galcore"
 #endif
 
+#if gcdENABLE_FSCALE_VAL_ADJUST
+static int thermal_hot_pm_notify(struct notifier_block *nb, unsigned long event,
+       void *dummy)
+{
+    static gctUINT orgFscale, minFscale, maxFscale;
+    static gctBOOL bAlreadyTooHot = gcvFALSE;
+    gckHARDWARE hardware = galDevice->kernels[gcvCORE_MAJOR]->hardware;
+
+    if (event && !bAlreadyTooHot) {
+        gckHARDWARE_GetFscaleValue(hardware,&orgFscale,&minFscale, &maxFscale);
+        gckHARDWARE_SetFscaleValue(hardware, minFscale);
+        bAlreadyTooHot = gcvTRUE;
+        gckOS_Print("System is too hot. GPU3D will work at %d/64 clock.\n", minFscale);
+    } else if (!event && bAlreadyTooHot) {
+        gckHARDWARE_SetFscaleValue(hardware, orgFscale);
+        gckOS_Print("Hot alarm is canceled. GPU3D clock will return to %d/64\n", orgFscale);
+        bAlreadyTooHot = gcvFALSE;
+    }
+    return NOTIFY_OK;
+}
+
+static struct notifier_block thermal_hot_pm_notifier = {
+    .notifier_call = thermal_hot_pm_notify,
+    };
+#endif
+
+
+
 static int __devinit gpu_probe(struct platform_device *pdev)
 {
     int ret = -ENODEV;
@@ -1022,10 +1056,16 @@ static int __devinit gpu_probe(struct platform_device *pdev)
     {
         platform_set_drvdata(pdev, galDevice);
 
+#if gcdENABLE_FSCALE_VAL_ADJUST
+        if(galDevice->kernels[gcvCORE_MAJOR])
+            register_thermal_notifier(&thermal_hot_pm_notifier);
+#endif
         gcmkFOOTER_NO();
         return ret;
     }
-
+#if gcdENABLE_FSCALE_VAL_ADJUST
+    unregister_thermal_notifier(&thermal_hot_pm_notifier);
+#endif
     gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
     return ret;
 }
@@ -1033,6 +1073,10 @@ static int __devinit gpu_probe(struct platform_device *pdev)
 static int __devinit gpu_remove(struct platform_device *pdev)
 {
     gcmkHEADER();
+#if gcdENABLE_FSCALE_VAL_ADJUST
+    if(galDevice->kernels[gcvCORE_MAJOR])
+        unregister_thermal_notifier(&thermal_hot_pm_notifier);
+#endif
     drv_exit();
     gcmkFOOTER_NO();
     return 0;