ARM: tegra: use general clock framework for GPU throttling
Hyungwoo Yang [Thu, 5 Sep 2013 23:51:41 +0000 (16:51 -0700)]
Bug 1363262

Change-Id: Ic455507d191a5b980d8d54580048c2dbb7b828df
Signed-off-by: Hyungwoo Yang <hyungwooy@nvidia.com>
Reviewed-on: http://git-master/r/271123
Reviewed-by: Philip Rakity <prakity@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

arch/arm/mach-tegra/include/mach/thermal.h
arch/arm/mach-tegra/tegra3_throttle.c
drivers/video/tegra/host/gk20a/clk_gk20a.c

index b031859..2f4fe5d 100644 (file)
@@ -53,13 +53,6 @@ struct balanced_throttle {
        struct throttle_table *throt_tab;
 };
 
-/* TODO : remove when GPU clock is available in Linux Clock Framework */
-struct gk20a_clk_cap_info {
-       struct gk20a *g;
-       int (*set_cap_thermal)(struct gk20a *g, unsigned long rate);
-       unsigned long (*get_max)(void);
-};
-
 #ifdef CONFIG_TEGRA_THERMAL_THROTTLE
 int tegra_throttle_init(struct mutex *cpu_lock);
 struct thermal_cooling_device *balanced_throttle_register(
@@ -68,8 +61,6 @@ struct thermal_cooling_device *balanced_throttle_register(
 void tegra_throttle_exit(void);
 bool tegra_is_throttling(int *count);
 unsigned long tegra_throttle_governor_speed(unsigned long requested_speed);
-/* TODO : remove when GPU clock is available in Linux Clock Framework */
-int tegra_throttle_gk20a_clk_cap_register(struct gk20a_clk_cap_info *gk20a_clk);
 #else
 static inline int tegra_throttle_init(struct mutex *cpu_lock)
 { return 0; }
@@ -84,10 +75,6 @@ static inline bool tegra_is_throttling(int *count)
 static inline unsigned long tegra_throttle_governor_speed(
        unsigned long requested_speed)
 { return requested_speed; }
-/* TODO : remove when GPU clock is available in Linux Clock Framework */
-static int tegra_throttle_gk20a_clk_cap_register(
-                               struct gk20a_clk_cap_info *gk20a_clk)
-{ return 0; }
 #endif /* CONFIG_TEGRA_THERMAL_THROTTLE */
 
 #endif /* __MACH_THERMAL_H */
index b8ba9e2..2021cd7 100644 (file)
@@ -33,9 +33,6 @@
 #include "clock.h"
 #include "cpu-tegra.h"
 
-/* TODO : remove when GPU clock is in Linux Clock Framework */
-struct gk20a_clk_cap_info *gk20a_clk_cap;
-
 /* cpu_throttle_lock is tegra_cpu_lock from cpu-tegra.c */
 static struct mutex *cpu_throttle_lock;
 static DEFINE_MUTEX(bthrot_list_lock);
@@ -52,11 +49,9 @@ static struct {
 } cap_freqs_table[] = {
 #ifdef CONFIG_TEGRA_DUAL_CBUS
 #ifdef CONFIG_TEGRA_GPU_DVFS
-       { .cap_name = "cap.throttle.gpu" },
+       { .cap_name = "cap.throttle.gbus" },
 #else
-       /* TODO : use c2bus and remove gpu when CONFIG_TEGRA_GPU_DVFS==y */
-       /* { .cap_name = "cap.throttle.c2bus" }, */
-       { .cap_name = "cap.throttle.gpu" },
+       { .cap_name = "cap.throttle.c2bus" },
 #endif
        { .cap_name = "cap.throttle.c3bus" },
 #else
@@ -147,40 +142,19 @@ static void tegra_throttle_set_cap_clk(struct throttle_table *throt_tab,
                                        int cap_clk_index)
 {
        unsigned long cap_rate, clk_rate;
-       struct nvhost_device_data *pdata;
 
        if (tegra_throttle_init_failed)
                return;
 
        cap_rate = throt_tab->cap_freqs[cap_clk_index];
 
-       if (cap_rate == NO_CAP) {
-               /* TODO : remove when GPU clock is in Linux Clock Framework */
-               if (strcmp(CAP_TBL_CAP_NAME(cap_clk_index-1),
-                                       "cap.throttle.gpu") != 0)
-                       clk_rate = clk_get_max_rate(
-                                       CAP_TBL_CAP_CLK(cap_clk_index-1));
-               else if (gk20a_clk_cap != NULL)
-                       clk_rate = gk20a_clk_cap->get_max();
-
-               /* TODO : use when GPU clock is in Linux Clock Framework */
-               /* clk_rate = */
-               /* clk_get_max_rate(CAP_TBL_CAP_CLK(cap_clk_index-1)); */
-       } else
+       if (cap_rate == NO_CAP)
+               clk_rate = clk_get_max_rate(CAP_TBL_CAP_CLK(cap_clk_index-1));
+       else
                clk_rate = cap_rate * 1000UL;
 
        if (CAP_TBL_CAP_FREQ(cap_clk_index-1) != clk_rate) {
-               /* TODO : remove when GPU clock is in Linux Clock Framework */
-               if (strcmp(CAP_TBL_CAP_NAME(cap_clk_index-1),
-                                       "cap.throttle.gpu") != 0)
-                       clk_set_rate(CAP_TBL_CAP_CLK(cap_clk_index-1),
-                                                               clk_rate);
-               else if (gk20a_clk_cap != NULL)
-                       gk20a_clk_cap->set_cap_thermal(gk20a_clk_cap->g,
-                                                               clk_rate);
-
-               /* TODO : use when GPU clock is in Linux Clock Framework */
-               /* clk_set_rate(CAP_TBL_CAP_CLK(cap_clk_index-1), clk_rate); */
+               clk_set_rate(CAP_TBL_CAP_CLK(cap_clk_index-1), clk_rate);
                CAP_TBL_CAP_FREQ(cap_clk_index-1) = clk_rate;
        }
 }
@@ -372,12 +346,6 @@ struct thermal_cooling_device *balanced_throttle_register(
        return bthrot->cdev;
 }
 
-/* TODO : remove when GPU clock is available in Linux clock framework */
-int tegra_throttle_gk20a_clk_cap_register(struct gk20a_clk_cap_info *gk20a_clk)
-{
-       gk20a_clk_cap = gk20a_clk;
-}
-
 int __init tegra_throttle_init(struct mutex *cpu_lock)
 {
        int i;
@@ -398,22 +366,16 @@ int __init tegra_throttle_init(struct mutex *cpu_lock)
 #endif
 
        for (i = 0; i < ARRAY_SIZE(cap_freqs_table); i++) {
-               /* TODO : need to be modified when GPU clock is available in */
-               /* Linux Clock Framework */
-               if (strcmp(CAP_TBL_CAP_NAME(i),
-                                       "cap.throttle.gpu") != 0) {
-                       c = tegra_get_clock_by_name(CAP_TBL_CAP_NAME(i));
-                       if (!c) {
-                               pr_err("tegra_throttle: cannot get clock %s\n",
-                                       CAP_TBL_CAP_NAME(i));
-                               tegra_throttle_init_failed = true;
-                               continue;
-                       }
+               c = tegra_get_clock_by_name(CAP_TBL_CAP_NAME(i));
+               if (!c) {
+                       pr_err("tegra_throttle: cannot get clock %s\n",
+                               CAP_TBL_CAP_NAME(i));
+                       tegra_throttle_init_failed = true;
+                       continue;
+               }
 
-                       CAP_TBL_CAP_CLK(i) = c;
-                       CAP_TBL_CAP_FREQ(i) = clk_get_max_rate(c);
-               } else if (gk20a_clk_cap != NULL)
-                       CAP_TBL_CAP_FREQ(i) = gk20a_clk_cap->get_max();
+               CAP_TBL_CAP_CLK(i) = c;
+               CAP_TBL_CAP_FREQ(i) = clk_get_max_rate(c);
        }
        pr_info("tegra_throttle : init %s\n",
                tegra_throttle_init_failed ? "FAILED" : "passed");
index c1d0b29..a6ab9ac 100644 (file)
@@ -615,16 +615,6 @@ static int gk20a_clk_set_cap_thermal(struct gk20a *g, unsigned long rate)
        return gk20a_clk_set_rate(g, rate);
 }
 
-static unsigned long gk20a_clk_get_max(void)
-{
-       return rate_gpc2clk_to_gpu(gpc_pll_params.max_freq);
-}
-
-static struct gk20a_clk_cap_info gk20a_clk_cap = {
-       .set_cap_thermal = gk20a_clk_set_cap_thermal,
-       .get_max = gk20a_clk_get_max,
-};
-
 int gk20a_clk_init_cap_freqs(struct gk20a *g)
 {
        struct clk_gk20a *clk = &g->clk;
@@ -633,10 +623,6 @@ int gk20a_clk_init_cap_freqs(struct gk20a *g)
        clk->cap_freq = gpc_pll_params.max_freq;
        clk->cap_freq_thermal = gpc_pll_params.max_freq;
 
-       gk20a_clk_cap.g = g;
-
-       tegra_throttle_gk20a_clk_cap_register(&gk20a_clk_cap);
-
        return 0;
 }