diff options
author | Alex Waterman <alexw@nvidia.com> | 2016-10-18 18:23:44 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-12-19 18:39:58 -0500 |
commit | 28fce3e72bd5231da0e648fb940e04b0ef49ca22 (patch) | |
tree | 7e53a771b6d5d25123c27bd9ba7942d917d10398 /drivers/gpu/nvgpu/gk20a/gk20a.c | |
parent | ca2c4995278f42835d4667cc486172e38e0186d6 (diff) |
gpu: nvgpu: Use struct to hold gk20a pointer
The private_data field in the file pointer passed to release() for
channels originally pointed directly to the referenced channel. The
problem with this is that when the driver is killed and the channel
mmeory is freed that pointer becomes invalid.
The necessity of that channel is to get access to the gk20a struct that
owns the channel. This can instead be accomplished by making a new
private data struct that has a pointer to the gk20a struct directly
instead of requiring the channel to be valid. This lets the release()
function work even if the channels are gone (though in such cases the
release function doesn't do very much).
Change-Id: I5e50bb5b6dd08d38974f8e7b46ba125e9a3f1922
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1246586
(cherry picked from commit 14b7c380c74d2caeb04c47ad3e33332a423a84bb)
Reviewed-on: http://git-master/r/1261913
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 086f756b..156d33ed 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c | |||
@@ -168,7 +168,7 @@ static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a) | |||
168 | gk20a_get_platform(&pdev->dev)->g = gk20a; | 168 | gk20a_get_platform(&pdev->dev)->g = gk20a; |
169 | } | 169 | } |
170 | 170 | ||
171 | static const struct file_operations gk20a_channel_ops = { | 171 | const struct file_operations gk20a_channel_ops = { |
172 | .owner = THIS_MODULE, | 172 | .owner = THIS_MODULE, |
173 | .release = gk20a_channel_release, | 173 | .release = gk20a_channel_release, |
174 | .open = gk20a_channel_open, | 174 | .open = gk20a_channel_open, |
@@ -1280,23 +1280,6 @@ fail: | |||
1280 | return err; | 1280 | return err; |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | struct channel_gk20a *gk20a_get_channel_from_file(int fd) | ||
1284 | { | ||
1285 | struct channel_gk20a *ch; | ||
1286 | struct file *f = fget(fd); | ||
1287 | if (!f) | ||
1288 | return NULL; | ||
1289 | |||
1290 | if (f->f_op != &gk20a_channel_ops) { | ||
1291 | fput(f); | ||
1292 | return NULL; | ||
1293 | } | ||
1294 | |||
1295 | ch = (struct channel_gk20a *)f->private_data; | ||
1296 | fput(f); | ||
1297 | return ch; | ||
1298 | } | ||
1299 | |||
1300 | static int gk20a_pm_railgate(struct device *dev) | 1283 | static int gk20a_pm_railgate(struct device *dev) |
1301 | { | 1284 | { |
1302 | struct gk20a_platform *platform = dev_get_drvdata(dev); | 1285 | struct gk20a_platform *platform = dev_get_drvdata(dev); |