diff options
author | David Nieto <dmartineznie@nvidia.com> | 2017-02-13 14:22:59 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-20 19:39:55 -0400 |
commit | 74fe1caa2b56aab24c17ad4dd2524128fc237894 (patch) | |
tree | 0793bb92b67d64690658f3f7cd1a8e1ea93206ba /drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |
parent | 469308becaff326da02fcf791e803e812e1cf9f8 (diff) |
gpu: nvgpu: Add refcounting to driver fds
The main driver structure is not refcounted properly,
so when the driver unload, file desciptors associated to the
driver are kept open with dangling references to the main object.
This change adds referencing to the gk20a structure.
bug 200277762
JIRA: EVLR-1023
Change-Id: Id892e9e1677a344789e99bf649088c076f0bf8de
Signed-off-by: David Nieto <dmartineznie@nvidia.com>
Reviewed-on: http://git-master/r/1317420
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
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; |