summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-01-29 19:21:30 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-02-02 15:11:53 -0500
commit98da3f8eed914225e9ffe0f768d7647506e95cdc (patch)
treea16c4e29f6983d648f08d2ba1d34440883231cef
parentac5b3d9640790b99798070fbb011c4b0c100d33e (diff)
gpu: nvgpu: Cleanup usage of bypass_smmu
The GPU has multiple different operating modes in respect to IOMMU'ability. As such there needs to be a clean way to tell the driver whether it is IOMMU'able or not. This state also does not always reflect what is possible: all becasue the GPU can generate IOMMU'ed memory requests doesn't mean it wants to. The nvgpu_iommuable() API has now existed for a little while which is a useful way to convey whether nvgpu should consider the GPU as IOMMU'able. However, there is also the g->mm.bypass_smmu flag which used to be able to override what the GPU decided it should do. Typically it was assigned the same value as nvgpu_iommuable() but that was not necessarily a requirment. This patch removes all the usages of g->mm.bypass_smmu and instead uses the nvgpu_iommuable() function. All places where the check against g->mm.bypass_smmu have been replaced with nvgpu_iommuable(). The code should now be much cleaner. Subsequently other checks can also be placed in the nvgpu_iommuable() function. For example, when NVLINK comes online and the GPU should no longer consider DMA addresses and instead use scatter-gather lists directly the ngpu_iommuable() function will be able to check the state of NVLINK and then act accordingly. Change-Id: I0da6262386de15709decac89d63d3eecfec20cd7 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1648332 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/linux/cde_gp10b.c7
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug.c5
-rw-r--r--drivers/gpu/nvgpu/common/linux/dma.c11
-rw-r--r--drivers/gpu/nvgpu/common/linux/driver_common.c1
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_linux.h1
-rw-r--r--drivers/gpu/nvgpu/common/linux/platform_gk20a.h3
-rw-r--r--drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c3
-rw-r--r--drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c3
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c4
-rw-r--r--drivers/gpu/nvgpu/common/mm/gmmu.c2
-rw-r--r--drivers/gpu/nvgpu/common/mm/nvgpu_mem.c2
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/mm.h1
12 files changed, 18 insertions, 25 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/cde_gp10b.c b/drivers/gpu/nvgpu/common/linux/cde_gp10b.c
index ffae6e34..483a3ee7 100644
--- a/drivers/gpu/nvgpu/common/linux/cde_gp10b.c
+++ b/drivers/gpu/nvgpu/common/linux/cde_gp10b.c
@@ -26,6 +26,7 @@
26#include "cde_gp10b.h" 26#include "cde_gp10b.h"
27 27
28#include <nvgpu/log.h> 28#include <nvgpu/log.h>
29#include <nvgpu/dma.h>
29 30
30enum gp10b_programs { 31enum gp10b_programs {
31 GP10B_PROG_HPASS = 0, 32 GP10B_PROG_HPASS = 0,
@@ -56,10 +57,10 @@ void gp10b_cde_get_program_numbers(struct gk20a *g,
56 hprog = GP10B_PROG_HPASS_DEBUG; 57 hprog = GP10B_PROG_HPASS_DEBUG;
57 vprog = GP10B_PROG_VPASS_DEBUG; 58 vprog = GP10B_PROG_VPASS_DEBUG;
58 } 59 }
59 if (g->mm.bypass_smmu) { 60 if (!nvgpu_iommuable(g)) {
60 if (!g->mm.disable_bigpage) { 61 if (!g->mm.disable_bigpage) {
61 nvgpu_warn(g, 62 nvgpu_warn(g,
62 "when bypass_smmu is 1, disable_bigpage must be 1 too"); 63 "When no IOMMU big pages cannot be used");
63 } 64 }
64 hprog |= 1; 65 hprog |= 1;
65 vprog |= 1; 66 vprog |= 1;
@@ -72,7 +73,7 @@ void gp10b_cde_get_program_numbers(struct gk20a *g,
72 73
73bool gp10b_need_scatter_buffer(struct gk20a *g) 74bool gp10b_need_scatter_buffer(struct gk20a *g)
74{ 75{
75 return g->mm.bypass_smmu; 76 return !nvgpu_iommuable(g);
76} 77}
77 78
78static u8 parity(u32 a) 79static u8 parity(u32 a)
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c
index 76018f8d..af3b9964 100644
--- a/drivers/gpu/nvgpu/common/linux/debug.c
+++ b/drivers/gpu/nvgpu/common/linux/debug.c
@@ -332,11 +332,6 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
332 l->debugfs, 332 l->debugfs,
333 &g->timeouts_enabled); 333 &g->timeouts_enabled);
334 334
335 l->debugfs_bypass_smmu =
336 debugfs_create_bool("bypass_smmu",
337 S_IRUGO,
338 l->debugfs,
339 &g->mm.bypass_smmu);
340 l->debugfs_disable_bigpage = 335 l->debugfs_disable_bigpage =
341 debugfs_create_file("disable_bigpage", 336 debugfs_create_file("disable_bigpage",
342 S_IRUGO|S_IWUSR, 337 S_IRUGO|S_IWUSR,
diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c
index 786065dd..ec9c3b5a 100644
--- a/drivers/gpu/nvgpu/common/linux/dma.c
+++ b/drivers/gpu/nvgpu/common/linux/dma.c
@@ -637,8 +637,13 @@ bool nvgpu_iommuable(struct gk20a *g)
637#ifdef CONFIG_TEGRA_GK20A 637#ifdef CONFIG_TEGRA_GK20A
638 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); 638 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
639 639
640 return device_is_iommuable(l->dev); 640 /*
641#else 641 * Check against the nvgpu device to see if it's been marked as
642 return true; 642 * IOMMU'able.
643 */
644 if (!device_is_iommuable(l->dev))
645 return false;
643#endif 646#endif
647
648 return true;
644} 649}
diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c
index ed7f7fe9..9df7ea3f 100644
--- a/drivers/gpu/nvgpu/common/linux/driver_common.c
+++ b/drivers/gpu/nvgpu/common/linux/driver_common.c
@@ -184,7 +184,6 @@ static void nvgpu_init_mm_vars(struct gk20a *g)
184{ 184{
185 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); 185 struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g));
186 186
187 g->mm.bypass_smmu = platform->bypass_smmu;
188 g->mm.disable_bigpage = platform->disable_bigpage; 187 g->mm.disable_bigpage = platform->disable_bigpage;
189 __nvgpu_set_enabled(g, NVGPU_MM_HONORS_APERTURE, 188 __nvgpu_set_enabled(g, NVGPU_MM_HONORS_APERTURE,
190 platform->honors_aperture); 189 platform->honors_aperture);
diff --git a/drivers/gpu/nvgpu/common/linux/os_linux.h b/drivers/gpu/nvgpu/common/linux/os_linux.h
index a2181c05..ebe131de 100644
--- a/drivers/gpu/nvgpu/common/linux/os_linux.h
+++ b/drivers/gpu/nvgpu/common/linux/os_linux.h
@@ -123,7 +123,6 @@ struct nvgpu_os_linux {
123 struct dentry *debugfs_ltc_enabled; 123 struct dentry *debugfs_ltc_enabled;
124 struct dentry *debugfs_timeouts_enabled; 124 struct dentry *debugfs_timeouts_enabled;
125 struct dentry *debugfs_gr_idle_timeout_default; 125 struct dentry *debugfs_gr_idle_timeout_default;
126 struct dentry *debugfs_bypass_smmu;
127 struct dentry *debugfs_disable_bigpage; 126 struct dentry *debugfs_disable_bigpage;
128 struct dentry *debugfs_gr_default_attrib_cb_size; 127 struct dentry *debugfs_gr_default_attrib_cb_size;
129 128
diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a.h b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h
index 60e71a74..6994677e 100644
--- a/drivers/gpu/nvgpu/common/linux/platform_gk20a.h
+++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h
@@ -106,9 +106,6 @@ struct gk20a_platform {
106 /* Timeout for per-channel watchdog (in mS) */ 106 /* Timeout for per-channel watchdog (in mS) */
107 u32 ch_wdt_timeout_ms; 107 u32 ch_wdt_timeout_ms;
108 108
109 /* Enable SMMU bypass by default */
110 bool bypass_smmu;
111
112 /* Disable big page support */ 109 /* Disable big page support */
113 bool disable_bigpage; 110 bool disable_bigpage;
114 111
diff --git a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c
index 4dd5d46e..0b0ebeeb 100644
--- a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c
+++ b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c
@@ -137,8 +137,7 @@ static int gp10b_tegra_probe(struct device *dev)
137 return ret; 137 return ret;
138#endif 138#endif
139 139
140 platform->bypass_smmu = !device_is_iommuable(dev); 140 platform->disable_bigpage = !device_is_iommuable(dev);
141 platform->disable_bigpage = platform->bypass_smmu;
142 141
143 platform->g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close 142 platform->g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close
144 = false; 143 = false;
diff --git a/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c
index c56bc0f3..7d7fc603 100644
--- a/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c
+++ b/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c
@@ -81,8 +81,7 @@ static int gv11b_tegra_probe(struct device *dev)
81 g->has_syncpoints = false; 81 g->has_syncpoints = false;
82#endif 82#endif
83 83
84 platform->bypass_smmu = !device_is_iommuable(dev); 84 platform->disable_bigpage = !device_is_iommuable(dev);
85 platform->disable_bigpage = platform->bypass_smmu;
86 85
87 platform->g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close 86 platform->g->gr.ctx_vars.dump_ctxsw_stats_on_channel_close
88 = false; 87 = false;
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c
index 72214d3c..161a69e9 100644
--- a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c
+++ b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c
@@ -23,10 +23,10 @@
23#include "gk20a/mm_gk20a.h" 23#include "gk20a/mm_gk20a.h"
24 24
25#include <nvgpu/bug.h> 25#include <nvgpu/bug.h>
26#include <nvgpu/dma.h>
26 27
27int vgpu_gp10b_init_mm_setup_hw(struct gk20a *g) 28int vgpu_gp10b_init_mm_setup_hw(struct gk20a *g)
28{ 29{
29 g->mm.bypass_smmu = true;
30 g->mm.disable_bigpage = true; 30 g->mm.disable_bigpage = true;
31 return 0; 31 return 0;
32} 32}
@@ -77,7 +77,7 @@ u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm,
77 77
78 /* FIXME: add support for sparse mappings */ 78 /* FIXME: add support for sparse mappings */
79 79
80 if (WARN_ON(!sgt) || WARN_ON(!g->mm.bypass_smmu)) 80 if (WARN_ON(!sgt) || WARN_ON(nvgpu_iommuable(g)))
81 return 0; 81 return 0;
82 82
83 if (space_to_skip & (page_size - 1)) 83 if (space_to_skip & (page_size - 1))
diff --git a/drivers/gpu/nvgpu/common/mm/gmmu.c b/drivers/gpu/nvgpu/common/mm/gmmu.c
index 53ec3029..78ec361e 100644
--- a/drivers/gpu/nvgpu/common/mm/gmmu.c
+++ b/drivers/gpu/nvgpu/common/mm/gmmu.c
@@ -501,7 +501,7 @@ static int __nvgpu_gmmu_do_update_page_table(struct vm_gk20a *vm,
501 * mapping is simple since the "physical" address is actually a virtual 501 * mapping is simple since the "physical" address is actually a virtual
502 * IO address and will be contiguous. 502 * IO address and will be contiguous.
503 */ 503 */
504 if (attrs->aperture == APERTURE_SYSMEM && !g->mm.bypass_smmu) { 504 if (attrs->aperture == APERTURE_SYSMEM && nvgpu_iommuable(g)) {
505 u64 io_addr = nvgpu_sgt_get_gpu_addr(g, sgt, sgt->sgl, attrs); 505 u64 io_addr = nvgpu_sgt_get_gpu_addr(g, sgt, sgt->sgl, attrs);
506 506
507 io_addr += space_to_skip; 507 io_addr += space_to_skip;
diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
index f472d2a0..73b6b2a7 100644
--- a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
+++ b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
@@ -96,7 +96,7 @@ u64 nvgpu_sgt_alignment(struct gk20a *g, struct nvgpu_sgt *sgt)
96 * and double check length of buffer later. Also, since there's an 96 * and double check length of buffer later. Also, since there's an
97 * IOMMU we know that this DMA address is contiguous. 97 * IOMMU we know that this DMA address is contiguous.
98 */ 98 */
99 if (!g->mm.bypass_smmu && 99 if (nvgpu_iommuable(g) &&
100 nvgpu_sgt_iommuable(g, sgt) && 100 nvgpu_sgt_iommuable(g, sgt) &&
101 nvgpu_sgt_get_dma(sgt, sgt->sgl)) 101 nvgpu_sgt_get_dma(sgt, sgt->sgl))
102 return 1ULL << __ffs(nvgpu_sgt_get_dma(sgt, sgt->sgl)); 102 return 1ULL << __ffs(nvgpu_sgt_get_dma(sgt, sgt->sgl));
diff --git a/drivers/gpu/nvgpu/include/nvgpu/mm.h b/drivers/gpu/nvgpu/include/nvgpu/mm.h
index 90c6946a..4999df2e 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/mm.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/mm.h
@@ -144,7 +144,6 @@ struct mm_gk20a {
144 bool use_full_comp_tag_line; 144 bool use_full_comp_tag_line;
145 bool ltc_enabled_current; 145 bool ltc_enabled_current;
146 bool ltc_enabled_target; 146 bool ltc_enabled_target;
147 bool bypass_smmu;
148 bool disable_bigpage; 147 bool disable_bigpage;
149 bool has_physical_mode; 148 bool has_physical_mode;
150 149