diff --git a/drivers/gpu/nvgpu/gk20a/clk_gk20a.c b/drivers/gpu/nvgpu/gk20a/clk_gk20a.c index abb9e98aa..30f2b4ed6 100644 --- a/drivers/gpu/nvgpu/gk20a/clk_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/clk_gk20a.c @@ -42,6 +42,10 @@ struct pll_parms gpc_pll_params = { 1, 32, /* PL */ }; +#ifdef CONFIG_DEBUG_FS +static int clk_gk20a_debugfs_init(struct gk20a *g); +#endif + static u8 pl_to_div[] = { /* PL: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ /* p: */ 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 12, 16, 20, 24, 32 }; @@ -661,6 +665,12 @@ int gk20a_init_clk_support(struct gk20a *g) if (err) return err; +#ifdef CONFIG_DEBUG_FS + if (!clk->debugfs_set) { + if (!clk_gk20a_debugfs_init(g)) + clk->debugfs_set = true; + } +#endif return err; } @@ -800,11 +810,10 @@ static int monitor_get(void *data, u64 *val) } DEFINE_SIMPLE_ATTRIBUTE(monitor_fops, monitor_get, NULL, "%llu\n"); -int clk_gk20a_debugfs_init(struct platform_device *dev) +static int clk_gk20a_debugfs_init(struct gk20a *g) { struct dentry *d; - struct gk20a_platform *platform = platform_get_drvdata(dev); - struct gk20a *g = get_gk20a(dev); + struct gk20a_platform *platform = platform_get_drvdata(g->dev); d = debugfs_create_file( "rate", S_IRUGO|S_IWUSR, platform->debugfs, g, &rate_fops); diff --git a/drivers/gpu/nvgpu/gk20a/clk_gk20a.h b/drivers/gpu/nvgpu/gk20a/clk_gk20a.h index f6cdd2727..950034a46 100644 --- a/drivers/gpu/nvgpu/gk20a/clk_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/clk_gk20a.h @@ -56,6 +56,7 @@ struct clk_gk20a { struct mutex clk_mutex; bool sw_ready; bool clk_hw_on; + bool debugfs_set; }; int gk20a_init_clk_support(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index b0aef022e..fb4e0886e 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -1502,8 +1502,6 @@ static int gk20a_probe(struct platform_device *dev) gk20a_create_sysfs(dev); #ifdef CONFIG_DEBUG_FS - clk_gk20a_debugfs_init(dev); - spin_lock_init(&gk20a->debugfs_lock); gk20a->mm.ltc_enabled = true; gk20a->mm.ltc_enabled_debug = true; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 0b91420bf..57cc338cd 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -591,10 +591,6 @@ static inline int support_gk20a_pmu(void){return 0;} void gk20a_create_sysfs(struct platform_device *dev); -#ifdef CONFIG_DEBUG_FS -int clk_gk20a_debugfs_init(struct platform_device *dev); -#endif - #define GK20A_BAR0_IORESOURCE_MEM 0 #define GK20A_BAR1_IORESOURCE_MEM 1 #define GK20A_SIM_IORESOURCE_MEM 2