diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 753623fa..e6626c4a 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |||
@@ -55,10 +55,15 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) | |||
55 | 55 | ||
56 | g = container_of(inode->i_cdev, | 56 | g = container_of(inode->i_cdev, |
57 | struct gk20a, ctrl.cdev); | 57 | struct gk20a, ctrl.cdev); |
58 | g = gk20a_get(g); | ||
59 | if (!g) | ||
60 | return -ENODEV; | ||
58 | 61 | ||
59 | priv = kzalloc(sizeof(struct gk20a_ctrl_priv), GFP_KERNEL); | 62 | priv = kzalloc(sizeof(struct gk20a_ctrl_priv), GFP_KERNEL); |
60 | if (!priv) | 63 | if (!priv) { |
61 | return -ENOMEM; | 64 | err = -ENOMEM; |
65 | goto free_ref; | ||
66 | } | ||
62 | filp->private_data = priv; | 67 | filp->private_data = priv; |
63 | priv->dev = g->dev; | 68 | priv->dev = g->dev; |
64 | /* | 69 | /* |
@@ -71,16 +76,16 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) | |||
71 | if (!g->gr.sw_ready) { | 76 | if (!g->gr.sw_ready) { |
72 | err = gk20a_busy(g->dev); | 77 | err = gk20a_busy(g->dev); |
73 | if (err) | 78 | if (err) |
74 | return err; | 79 | goto free_ref; |
75 | gk20a_idle(g->dev); | 80 | gk20a_idle(g->dev); |
76 | } | 81 | } |
77 | 82 | ||
78 | #ifdef CONFIG_ARCH_TEGRA_18x_SOC | 83 | #ifdef CONFIG_ARCH_TEGRA_18x_SOC |
79 | err = nvgpu_clk_arb_init_session(g, &priv->clk_session); | 84 | err = nvgpu_clk_arb_init_session(g, &priv->clk_session); |
80 | if (err) | ||
81 | return err; | ||
82 | #endif | 85 | #endif |
83 | 86 | free_ref: | |
87 | if (err) | ||
88 | gk20a_put(g); | ||
84 | return err; | 89 | return err; |
85 | } | 90 | } |
86 | int gk20a_ctrl_dev_release(struct inode *inode, struct file *filp) | 91 | int gk20a_ctrl_dev_release(struct inode *inode, struct file *filp) |
@@ -95,6 +100,7 @@ int gk20a_ctrl_dev_release(struct inode *inode, struct file *filp) | |||
95 | nvgpu_clk_arb_release_session(g, priv->clk_session); | 100 | nvgpu_clk_arb_release_session(g, priv->clk_session); |
96 | #endif | 101 | #endif |
97 | 102 | ||
103 | gk20a_put(g); | ||
98 | kfree(priv); | 104 | kfree(priv); |
99 | 105 | ||
100 | return 0; | 106 | return 0; |