From 525489f26eba34804de93a07d6035fc3458deeab Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Tue, 1 Aug 2017 17:17:34 -0700 Subject: gpu: nvgpu: fix debugfs to disable big pages After setting 'Y' in disable_bigpage, in native SMMU case, we could still see 64K GMMU pages beeing used. Fixed the following: - enforce disable_bigpage in nvgpu_vm_map - update GPU characteristics so that new clients know whether or not big pages are enabled. For instance this may affect how CUDA requests memory mapping. JIRA EVLR-1694 Change-Id: I62841096add3bd798c5c11090054f82c8a2be832 Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/1532429 Reviewed-by: Richard Zhao GVS: Gerrit_Virtual_Submit Reviewed-by: svccoveritychecker Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/debug.c | 45 ++++++++++++++++++++++++++++++++-- drivers/gpu/nvgpu/common/linux/vm.c | 5 +++- 2 files changed, 47 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c index 36f142d7..7dce74d6 100644 --- a/drivers/gpu/nvgpu/common/linux/debug.c +++ b/drivers/gpu/nvgpu/common/linux/debug.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -173,6 +174,45 @@ void gk20a_debug_show_dump(struct gk20a *g, struct gk20a_debug_output *o) gk20a_debug_dump_all_channel_status_ramfc(g, o); } +static ssize_t disable_bigpage_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) +{ + char buf[3]; + struct gk20a *g = file->private_data; + + if (g->mm.disable_bigpage) + buf[0] = 'Y'; + else + buf[0] = 'N'; + buf[1] = '\n'; + buf[2] = 0x00; + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); +} + +static ssize_t disable_bigpage_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) +{ + char buf[32]; + int buf_size; + bool bv; + struct gk20a *g = file->private_data; + + buf_size = min(count, (sizeof(buf)-1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (strtobool(buf, &bv) == 0) { + g->mm.disable_bigpage = bv; + gk20a_init_gpu_characteristics(g); + } + + return count; +} + +static struct file_operations disable_bigpage_fops = { + .open = simple_open, + .read = disable_bigpage_read, + .write = disable_bigpage_write, +}; + static int railgate_residency_show(struct seq_file *s, void *data) { struct gk20a *g = s->private; @@ -296,10 +336,11 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink) l->debugfs, &g->mm.bypass_smmu); l->debugfs_disable_bigpage = - debugfs_create_bool("disable_bigpage", + debugfs_create_file("disable_bigpage", S_IRUGO|S_IWUSR, l->debugfs, - &g->mm.disable_bigpage); + g, + &disable_bigpage_fops); l->debugfs_timeslice_low_priority_us = debugfs_create_u32("timeslice_low_priority_us", diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index d47d6bb1..dec05209 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.c @@ -260,7 +260,10 @@ u64 nvgpu_vm_map(struct vm_gk20a *vm, map_offset = offset_align; bfr.align = nvgpu_get_buffer_alignment(g, sgl, aperture); - bfr.pgsz_idx = __get_pte_size(vm, map_offset, + if (g->mm.disable_bigpage) + bfr.pgsz_idx = gmmu_page_size_small; + else + bfr.pgsz_idx = __get_pte_size(vm, map_offset, min_t(u64, bfr.size, bfr.align)); mapping_size = mapping_size ? mapping_size : bfr.size; -- cgit v1.2.2