gpu: nvgpu: Check reference clock before use

We use GPU reference clock as a divider. Check before division that
reference clock is not zero.

Change-Id: Ie453a78b422b2e740daeb7c12ce5b06faa52ba76
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1275743
GVS: Gerrit_Virtual_Submit
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
This commit is contained in:
Terje Bergstrom
2016-12-20 15:14:16 -08:00
committed by mobile promotions
parent fef7083e51
commit 2a95a288b2
2 changed files with 10 additions and 0 deletions

View File

@@ -439,6 +439,11 @@ static int gk20a_init_clk_setup_sw(struct gk20a *g)
clk->gpc_pll.id = GK20A_GPC_PLL;
clk->gpc_pll.clk_in = ref_rate / KHZ;
if (clk->gpc_pll.clk_in == 0) {
gk20a_err(dev_from_gk20a(g),
"GPCPLL reference clock is zero");
return -EINVAL;
}
/* Decide initial frequency */
if (!initialized) {

View File

@@ -1158,6 +1158,11 @@ static int gm20b_init_gpc_pll(struct gk20a *g)
clk->gpc_pll.id = GK20A_GPC_PLL;
clk->gpc_pll.clk_in = clk_get_rate(ref) / KHZ;
if (clk->gpc_pll.clk_in == 0) {
gk20a_err(dev_from_gk20a(g),
"GPCPLL reference clock is zero");
return -EINVAL;
}
gm20b_calc_dvfs_safe_max_freq(c);
clk->gpc_pll.PL = (dvfs_safe_max_freq == 0) ? 0 :