PD #92881: add clock on/off in runtime pm.
authorKasin Lee <kasin.li@amlogic.com>
Mon, 9 Jun 2014 06:56:10 +0000 (14:56 +0800)
committerKasin Lee <kasin.li@amlogic.com>
Mon, 9 Jun 2014 06:56:10 +0000 (14:56 +0800)
mali/platform/mali_clock.c
mali/platform/meson_m450/platform_m8b.c
mali/platform/meson_m450/scaling_m8b.c
mali/platform/meson_main.c
mali/platform/meson_main.h

index d40e92b2761ffea419d647b919f33ed72d2f30bb..8d2c43e95e9d5f7d83905e282d70d2625c883edb 100755 (executable)
@@ -75,7 +75,6 @@ void disable_clock(void)
        spin_lock_irqsave(&lock, flags);
        clrbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
        spin_unlock_irqrestore(&lock, flags);
-       printk("## mali clock off----\n");
 }
 
 void enable_clock(void)
@@ -86,7 +85,6 @@ void enable_clock(void)
        setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
        ret = readl((u32 *)P_HHI_MALI_CLK_CNTL) & (1 << 8);
        spin_unlock_irqrestore(&lock, flags);
-       printk("## mali clock on :%x++++\n", ret);
 }
 
 u32 get_mali_freq(u32 idx)
index 22291bb37b6fc0771e81e948ae0895d7395915e1..d78dcc0c3d3000adcefca668a7d9b4c239db2d86 100755 (executable)
@@ -158,18 +158,17 @@ int mali_meson_uninit(struct platform_device* ptr_plt_dev)
        return 0;
 }
 
-int mali_light_suspend(struct device *device)
+static int mali_cri_light_suspend(size_t param)
 {
-       int ret = 0;
+       int ret;
+       struct device *device;
        struct mali_pmu_core *pmu;
 
+       ret = 0;
+       mali_pm_statue = 0;
+       device = (struct device *)param;
        pmu = mali_pmu_get_global_pmu_core();
-#ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       0, 0,   0,      0,      0);
-#endif
+
        if (NULL != device->driver &&
            NULL != device->driver->pm &&
            NULL != device->driver->pm->runtime_suspend)
@@ -177,27 +176,21 @@ int mali_light_suspend(struct device *device)
                /* Need to notify Mali driver about this event */
                ret = device->driver->pm->runtime_suspend(device);
        }
-
-       /* clock scaling. Kasin..*/
        mali_pmu_power_down_all(pmu);
-       //disable_clock();
        return ret;
 }
 
-int mali_light_resume(struct device *device)
+static int mali_cri_light_resume(size_t param)
 {
-       int ret = 0;
+       int ret;
+       struct device *device;
        struct mali_pmu_core *pmu;
 
+       ret = 0;
+       device = (struct device *)param;
        pmu = mali_pmu_get_global_pmu_core();
-       mali_pmu_power_up_all(pmu);
-#ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       get_current_frequency(), 0,     0,      0,      0);
-#endif
 
+       mali_pmu_power_up_all(pmu);
        if (NULL != device->driver &&
            NULL != device->driver->pm &&
            NULL != device->driver->pm->runtime_resume)
@@ -205,17 +198,20 @@ int mali_light_resume(struct device *device)
                /* Need to notify Mali driver about this event */
                ret = device->driver->pm->runtime_resume(device);
        }
+       mali_pm_statue = 1;
        return ret;
 }
 
-int mali_deep_suspend(struct device *device)
+static int mali_cri_deep_suspend(size_t param)
 {
-       int ret = 0;
+       int ret;
+       struct device *device;
        struct mali_pmu_core *pmu;
 
+       ret = 0;
+       device = (struct device *)param;
        pmu = mali_pmu_get_global_pmu_core();
-       enable_clock();
-       flush_scaling_job();
+
        if (NULL != device->driver &&
            NULL != device->driver->pm &&
            NULL != device->driver->pm->suspend)
@@ -223,20 +219,20 @@ int mali_deep_suspend(struct device *device)
                /* Need to notify Mali driver about this event */
                ret = device->driver->pm->suspend(device);
        }
-
-       /* clock scaling off. Kasin... */
        mali_pmu_power_down_all(pmu);
-       disable_clock();
        return ret;
 }
 
-int mali_deep_resume(struct device *device)
+static int mali_cri_deep_resume(size_t param)
 {
-       int ret = 0;
+       int ret;
+       struct device *device;
        struct mali_pmu_core *pmu;
 
+       ret = 0;
+       device = (struct device *)param;
        pmu = mali_pmu_get_global_pmu_core();
-       enable_clock();
+
        mali_pmu_power_up_all(pmu);
        if (NULL != device->driver &&
            NULL != device->driver->pm &&
@@ -246,5 +242,59 @@ int mali_deep_resume(struct device *device)
                ret = device->driver->pm->resume(device);
        }
        return ret;
+
+}
+
+int mali_light_suspend(struct device *device)
+{
+       int ret = 0;
+#ifdef CONFIG_MALI400_PROFILING
+       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
+                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+                                       0, 0,   0,      0,      0);
+#endif
+
+       /* clock scaling. Kasin..*/
+       ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
+       disable_clock();
+       return ret;
+}
+
+int mali_light_resume(struct device *device)
+{
+       int ret = 0;
+       enable_clock();
+       ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
+#ifdef CONFIG_MALI400_PROFILING
+       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
+                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+                                       get_current_frequency(), 0,     0,      0,      0);
+#endif
+       return ret;
+}
+
+int mali_deep_suspend(struct device *device)
+{
+       int ret = 0;
+       enable_clock();
+       flush_scaling_job();
+
+       /* clock scaling off. Kasin... */
+       ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
+       disable_clock();
+       return ret;
+}
+
+int mali_deep_resume(struct device *device)
+{
+       int ret = 0;
+
+       /* clock scaling up. Kasin.. */
+       enable_clock();
+       ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
+       return ret;
+
 }
 
index 662ca7d27c4a4a2e1b397b894f4ab03ca80690ef..b05cad7d115289714e6d7f1f6fa6f577beeba0c5 100755 (executable)
@@ -103,6 +103,11 @@ uint32_t* get_mali_dvfs_tbl_addr(void)
 static void do_scaling(struct work_struct *work)
 {
        int err = mali_perf_set_num_pp_cores(num_cores_enabled);
+
+       if (mali_pm_statue == 0) {
+               printk("skip none clock test.\n");
+               return;
+       }
        MALI_DEBUG_ASSERT(0 == err);
        MALI_IGNORE(err);
        if (mali_dvfs_threshold[currentStep].freq_index != mali_dvfs_threshold[lastStep].freq_index) {
@@ -426,6 +431,11 @@ void mali_plat_preheat(void)
 
 void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data)
 {
+
+       if (mali_pm_statue == 0) {
+               printk("skip none clock scaling.\n");
+               return;
+       }
        switch (scaling_mode) {
        case MALI_PP_FS_SCALING:
                mali_pp_fs_scaling_update(data);
index 10b2106338c87a95a8a5e5471c5c99630eba8b80..e09599584196f962c32a018f49ba93846d5226be 100755 (executable)
@@ -28,7 +28,7 @@
 #include "common/mali_osk_profiling.h"
 
 static void mali_platform_device_release(struct device *device);
-
+int mali_pm_statue = 1;
 static struct mali_gpu_device_data mali_gpu_data =
 {
        .shared_mem_size = 1024 * 1024 * 1024,
index f9fb3c512709cb56647be104c5cc9638fc5bef82..b47a67f74b9d8b7100aa89e245c9d8125d593a73 100755 (executable)
@@ -26,6 +26,7 @@ extern u32 mali_up_clock_idx;
 extern u32 set_max_mali_freq(u32 idx);
 extern u32 get_max_mali_freq(void);
 extern u32 get_mali_tbl_size(void);
+extern int mali_pm_statue;
 
 int mali_meson_init_start(struct platform_device* ptr_plt_dev);
 int mali_meson_init_finish(struct platform_device* ptr_plt_dev);