diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-03-08 20:08:50 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-30 15:36:09 -0400 |
commit | 24e1c7e0a729158be36d63b821550d206a8a0436 (patch) | |
tree | cf26c850cc63957f63f3e8f97914268839d8e0de /drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |
parent | 7010bf88399ea81b2b35844f738baac19dc5a441 (diff) |
gpu: nvgpu: Use new kmem API functions (misc)
Use the new kmem API functions in misc gk20a code. Some additional
modifications were also made:
o Add a struct gk20a pointer to gk20a_fence to enable proper
kmem free usage.
o Add gk20a pointer to alloc_session() in dbg_gpu_gk20a.c to
use kmem API for allocating a session.
o Plumb a gk20a pointer through the fence creation and deletion.
o Use statically allocated buffers for names in file creation.
Bug 1799159
Bug 1823380
Change-Id: I3678080e3ffa1f9bcf6934e3f4819a1bc531689b
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1318323
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 | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 5661b402..fba39a50 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <uapi/linux/nvgpu.h> | 23 | #include <uapi/linux/nvgpu.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | 25 | ||
26 | #include <nvgpu/kmem.h> | ||
27 | |||
26 | #include "gk20a.h" | 28 | #include "gk20a.h" |
27 | #include "fence_gk20a.h" | 29 | #include "fence_gk20a.h" |
28 | 30 | ||
@@ -52,7 +54,7 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp) | |||
52 | if (!g) | 54 | if (!g) |
53 | return -ENODEV; | 55 | return -ENODEV; |
54 | 56 | ||
55 | priv = kzalloc(sizeof(struct gk20a_ctrl_priv), GFP_KERNEL); | 57 | priv = nvgpu_kzalloc(g, sizeof(struct gk20a_ctrl_priv)); |
56 | if (!priv) { | 58 | if (!priv) { |
57 | err = -ENOMEM; | 59 | err = -ENOMEM; |
58 | goto free_ref; | 60 | goto free_ref; |
@@ -94,7 +96,7 @@ int gk20a_ctrl_dev_release(struct inode *inode, struct file *filp) | |||
94 | #endif | 96 | #endif |
95 | 97 | ||
96 | gk20a_put(g); | 98 | gk20a_put(g); |
97 | kfree(priv); | 99 | nvgpu_kfree(g, priv); |
98 | 100 | ||
99 | return 0; | 101 | return 0; |
100 | } | 102 | } |
@@ -195,18 +197,16 @@ static int gk20a_ctrl_alloc_as( | |||
195 | int err; | 197 | int err; |
196 | int fd; | 198 | int fd; |
197 | struct file *file; | 199 | struct file *file; |
198 | char *name; | 200 | char name[64]; |
199 | 201 | ||
200 | err = get_unused_fd_flags(O_RDWR); | 202 | err = get_unused_fd_flags(O_RDWR); |
201 | if (err < 0) | 203 | if (err < 0) |
202 | return err; | 204 | return err; |
203 | fd = err; | 205 | fd = err; |
204 | 206 | ||
205 | name = kasprintf(GFP_KERNEL, "nvhost-%s-fd%d", | 207 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); |
206 | g->name, fd); | ||
207 | 208 | ||
208 | file = anon_inode_getfile(name, g->as.cdev.ops, NULL, O_RDWR); | 209 | file = anon_inode_getfile(name, g->as.cdev.ops, NULL, O_RDWR); |
209 | kfree(name); | ||
210 | if (IS_ERR(file)) { | 210 | if (IS_ERR(file)) { |
211 | err = PTR_ERR(file); | 211 | err = PTR_ERR(file); |
212 | goto clean_up; | 212 | goto clean_up; |
@@ -236,18 +236,16 @@ static int gk20a_ctrl_open_tsg(struct gk20a *g, | |||
236 | int err; | 236 | int err; |
237 | int fd; | 237 | int fd; |
238 | struct file *file; | 238 | struct file *file; |
239 | char *name; | 239 | char name[64]; |
240 | 240 | ||
241 | err = get_unused_fd_flags(O_RDWR); | 241 | err = get_unused_fd_flags(O_RDWR); |
242 | if (err < 0) | 242 | if (err < 0) |
243 | return err; | 243 | return err; |
244 | fd = err; | 244 | fd = err; |
245 | 245 | ||
246 | name = kasprintf(GFP_KERNEL, "nvgpu-%s-tsg%d", | 246 | snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd); |
247 | g->name, fd); | ||
248 | 247 | ||
249 | file = anon_inode_getfile(name, g->tsg.cdev.ops, NULL, O_RDWR); | 248 | file = anon_inode_getfile(name, g->tsg.cdev.ops, NULL, O_RDWR); |
250 | kfree(name); | ||
251 | if (IS_ERR(file)) { | 249 | if (IS_ERR(file)) { |
252 | err = PTR_ERR(file); | 250 | err = PTR_ERR(file); |
253 | goto clean_up; | 251 | goto clean_up; |
@@ -407,7 +405,7 @@ static int nvgpu_gpu_ioctl_wait_for_pause(struct gk20a *g, | |||
407 | 405 | ||
408 | sm_count = g->gr.gpc_count * g->gr.tpc_count; | 406 | sm_count = g->gr.gpc_count * g->gr.tpc_count; |
409 | size = sm_count * sizeof(struct warpstate); | 407 | size = sm_count * sizeof(struct warpstate); |
410 | w_state = kzalloc(size, GFP_KERNEL); | 408 | w_state = nvgpu_kzalloc(g, size); |
411 | if (!w_state) | 409 | if (!w_state) |
412 | return -ENOMEM; | 410 | return -ENOMEM; |
413 | 411 | ||
@@ -421,7 +419,7 @@ static int nvgpu_gpu_ioctl_wait_for_pause(struct gk20a *g, | |||
421 | } | 419 | } |
422 | 420 | ||
423 | nvgpu_mutex_release(&g->dbg_sessions_lock); | 421 | nvgpu_mutex_release(&g->dbg_sessions_lock); |
424 | kfree(w_state); | 422 | nvgpu_kfree(g, w_state); |
425 | return err; | 423 | return err; |
426 | } | 424 | } |
427 | 425 | ||
@@ -473,7 +471,7 @@ static int gk20a_ctrl_vsm_mapping(struct gk20a *g, | |||
473 | struct nvgpu_gpu_vsms_mapping_entry *vsms_buf; | 471 | struct nvgpu_gpu_vsms_mapping_entry *vsms_buf; |
474 | u32 i; | 472 | u32 i; |
475 | 473 | ||
476 | vsms_buf = kzalloc(write_size, GFP_KERNEL); | 474 | vsms_buf = nvgpu_kzalloc(g, write_size); |
477 | if (vsms_buf == NULL) | 475 | if (vsms_buf == NULL) |
478 | return -ENOMEM; | 476 | return -ENOMEM; |
479 | 477 | ||
@@ -485,7 +483,7 @@ static int gk20a_ctrl_vsm_mapping(struct gk20a *g, | |||
485 | err = copy_to_user((void __user *)(uintptr_t) | 483 | err = copy_to_user((void __user *)(uintptr_t) |
486 | args->vsms_map_buf_addr, | 484 | args->vsms_map_buf_addr, |
487 | vsms_buf, write_size); | 485 | vsms_buf, write_size); |
488 | kfree(vsms_buf); | 486 | nvgpu_kfree(g, vsms_buf); |
489 | 487 | ||
490 | return err; | 488 | return err; |
491 | } | 489 | } |
@@ -760,7 +758,7 @@ static int nvgpu_gpu_clk_get_vf_points(struct gk20a *g, | |||
760 | if (err) | 758 | if (err) |
761 | return err; | 759 | return err; |
762 | 760 | ||
763 | fpoints = kcalloc(max_points, sizeof(u16), GFP_KERNEL); | 761 | fpoints = nvgpu_kcalloc(g, max_points, sizeof(u16)); |
764 | if (!fpoints) | 762 | if (!fpoints) |
765 | return -ENOMEM; | 763 | return -ENOMEM; |
766 | 764 | ||
@@ -797,7 +795,7 @@ static int nvgpu_gpu_clk_get_vf_points(struct gk20a *g, | |||
797 | args->num_entries = num_points; | 795 | args->num_entries = num_points; |
798 | 796 | ||
799 | fail: | 797 | fail: |
800 | kfree(fpoints); | 798 | nvgpu_kfree(g, fpoints); |
801 | return err; | 799 | return err; |
802 | } | 800 | } |
803 | 801 | ||
@@ -1245,13 +1243,13 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
1245 | 1243 | ||
1246 | memset(get_info_args, 0, sizeof(struct nvgpu_gpu_zcull_get_info_args)); | 1244 | memset(get_info_args, 0, sizeof(struct nvgpu_gpu_zcull_get_info_args)); |
1247 | 1245 | ||
1248 | zcull_info = kzalloc(sizeof(struct gr_zcull_info), GFP_KERNEL); | 1246 | zcull_info = nvgpu_kzalloc(g, sizeof(struct gr_zcull_info)); |
1249 | if (zcull_info == NULL) | 1247 | if (zcull_info == NULL) |
1250 | return -ENOMEM; | 1248 | return -ENOMEM; |
1251 | 1249 | ||
1252 | err = g->ops.gr.get_zcull_info(g, &g->gr, zcull_info); | 1250 | err = g->ops.gr.get_zcull_info(g, &g->gr, zcull_info); |
1253 | if (err) { | 1251 | if (err) { |
1254 | kfree(zcull_info); | 1252 | nvgpu_kfree(g, zcull_info); |
1255 | break; | 1253 | break; |
1256 | } | 1254 | } |
1257 | 1255 | ||
@@ -1266,12 +1264,12 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
1266 | get_info_args->subregion_height_align_pixels = zcull_info->subregion_height_align_pixels; | 1264 | get_info_args->subregion_height_align_pixels = zcull_info->subregion_height_align_pixels; |
1267 | get_info_args->subregion_count = zcull_info->subregion_count; | 1265 | get_info_args->subregion_count = zcull_info->subregion_count; |
1268 | 1266 | ||
1269 | kfree(zcull_info); | 1267 | nvgpu_kfree(g, zcull_info); |
1270 | break; | 1268 | break; |
1271 | case NVGPU_GPU_IOCTL_ZBC_SET_TABLE: | 1269 | case NVGPU_GPU_IOCTL_ZBC_SET_TABLE: |
1272 | set_table_args = (struct nvgpu_gpu_zbc_set_table_args *)buf; | 1270 | set_table_args = (struct nvgpu_gpu_zbc_set_table_args *)buf; |
1273 | 1271 | ||
1274 | zbc_val = kzalloc(sizeof(struct zbc_entry), GFP_KERNEL); | 1272 | zbc_val = nvgpu_kzalloc(g, sizeof(struct zbc_entry)); |
1275 | if (zbc_val == NULL) | 1273 | if (zbc_val == NULL) |
1276 | return -ENOMEM; | 1274 | return -ENOMEM; |
1277 | 1275 | ||
@@ -1303,12 +1301,12 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
1303 | } | 1301 | } |
1304 | 1302 | ||
1305 | if (zbc_val) | 1303 | if (zbc_val) |
1306 | kfree(zbc_val); | 1304 | nvgpu_kfree(g, zbc_val); |
1307 | break; | 1305 | break; |
1308 | case NVGPU_GPU_IOCTL_ZBC_QUERY_TABLE: | 1306 | case NVGPU_GPU_IOCTL_ZBC_QUERY_TABLE: |
1309 | query_table_args = (struct nvgpu_gpu_zbc_query_table_args *)buf; | 1307 | query_table_args = (struct nvgpu_gpu_zbc_query_table_args *)buf; |
1310 | 1308 | ||
1311 | zbc_tbl = kzalloc(sizeof(struct zbc_query_params), GFP_KERNEL); | 1309 | zbc_tbl = nvgpu_kzalloc(g, sizeof(struct zbc_query_params)); |
1312 | if (zbc_tbl == NULL) | 1310 | if (zbc_tbl == NULL) |
1313 | return -ENOMEM; | 1311 | return -ENOMEM; |
1314 | 1312 | ||
@@ -1342,7 +1340,7 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg | |||
1342 | } | 1340 | } |
1343 | 1341 | ||
1344 | if (zbc_tbl) | 1342 | if (zbc_tbl) |
1345 | kfree(zbc_tbl); | 1343 | nvgpu_kfree(g, zbc_tbl); |
1346 | break; | 1344 | break; |
1347 | 1345 | ||
1348 | case NVGPU_GPU_IOCTL_GET_CHARACTERISTICS: | 1346 | case NVGPU_GPU_IOCTL_GET_CHARACTERISTICS: |