summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
diff options
context:
space:
mode:
authorSami Kiminki <skiminki@nvidia.com>2017-08-22 09:14:56 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-09-15 18:45:45 -0400
commit5d09c908b0679f060bc89ae70eef681a6783ebbc (patch)
tree244177eb4425e765b9a043e66533ca624f0d3cbd /drivers/gpu/nvgpu/gk20a
parent2b7e8a2c2a5df041c9a434804d0f3f6d9df82737 (diff)
gpu: nvgpu: Direct GMMU PTE kind control
Allow userspace to control directly the PTE kind for the mappings by supplying NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL for MAP_BUFFER_EX. In particular, in this mode, the userspace will tell the kernel whether the kind is compressible, and if so, what is the incompressible fallback kind. By supplying only the compressible kind, the userspace can require that the map kind will not be demoted to the incompressible fallback kind in case of comptag allocation failure. Add also a GPU characteristics flag NVGPU_GPU_FLAGS_SUPPORT_MAP_DIRECT_KIND_CTRL to signal whether direct kind control is supported. Fix indentation of nvgpu_as_map_buffer_ex_args header comment. Bug 1705731 Change-Id: I317ab474ae53b78eb8fdd31bd6bca0541fcba9a4 Signed-off-by: Sami Kiminki <skiminki@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1543462 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c1
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c49
3 files changed, 43 insertions, 10 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
index 19433df9..2b37a62a 100644
--- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c
@@ -1929,6 +1929,7 @@ static int gk20a_perfbuf_map(struct dbg_session_gk20a *dbg_s,
1929 0, 1929 0,
1930 0, 1930 0,
1931 0, 1931 0,
1932 0,
1932 args->mapping_size, 1933 args->mapping_size,
1933 NULL); 1934 NULL);
1934 if (err) 1935 if (err)
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 455fa238..e9948c16 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -411,7 +411,8 @@ int gk20a_init_gpu_characteristics(struct gk20a *g)
411 gpu->available_big_page_sizes |= g->ops.mm.get_big_page_sizes(); 411 gpu->available_big_page_sizes |= g->ops.mm.get_big_page_sizes();
412 } 412 }
413 413
414 gpu->flags = NVGPU_GPU_FLAGS_SUPPORT_PARTIAL_MAPPINGS; 414 gpu->flags = NVGPU_GPU_FLAGS_SUPPORT_PARTIAL_MAPPINGS |
415 NVGPU_GPU_FLAGS_SUPPORT_MAP_DIRECT_KIND_CTRL;
415 416
416 if (IS_ENABLED(CONFIG_SYNC)) 417 if (IS_ENABLED(CONFIG_SYNC))
417 gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_SYNC_FENCE_FDS; 418 gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_SYNC_FENCE_FDS;
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index a6507d2d..97b7aa80 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -822,14 +822,11 @@ static void nvgpu_vm_unmap_user(struct vm_gk20a *vm, u64 offset,
822 nvgpu_mutex_release(&vm->update_gmmu_lock); 822 nvgpu_mutex_release(&vm->update_gmmu_lock);
823} 823}
824 824
825int setup_buffer_kind_and_compression(struct vm_gk20a *vm, 825static int setup_kind_legacy(struct vm_gk20a *vm, struct buffer_attrs *bfr,
826 u32 flags, 826 bool *pkind_compressible)
827 struct buffer_attrs *bfr,
828 enum gmmu_pgsz_gk20a pgsz_idx)
829{ 827{
830 bool kind_compressible;
831 struct gk20a *g = gk20a_from_vm(vm); 828 struct gk20a *g = gk20a_from_vm(vm);
832 int ctag_granularity = g->ops.fb.compression_page_size(g); 829 bool kind_compressible;
833 830
834 if (unlikely(bfr->kind_v == gmmu_pte_kind_invalid_v())) 831 if (unlikely(bfr->kind_v == gmmu_pte_kind_invalid_v()))
835 bfr->kind_v = gmmu_pte_kind_pitch_v(); 832 bfr->kind_v = gmmu_pte_kind_pitch_v();
@@ -840,7 +837,7 @@ int setup_buffer_kind_and_compression(struct vm_gk20a *vm,
840 } 837 }
841 838
842 bfr->uc_kind_v = gmmu_pte_kind_invalid_v(); 839 bfr->uc_kind_v = gmmu_pte_kind_invalid_v();
843 /* find a suitable uncompressed kind if it becomes necessary later */ 840 /* find a suitable incompressible kind if it becomes necessary later */
844 kind_compressible = gk20a_kind_is_compressible(bfr->kind_v); 841 kind_compressible = gk20a_kind_is_compressible(bfr->kind_v);
845 if (kind_compressible) { 842 if (kind_compressible) {
846 bfr->uc_kind_v = gk20a_get_uncompressed_kind(bfr->kind_v); 843 bfr->uc_kind_v = gk20a_get_uncompressed_kind(bfr->kind_v);
@@ -852,6 +849,36 @@ int setup_buffer_kind_and_compression(struct vm_gk20a *vm,
852 return -EINVAL; 849 return -EINVAL;
853 } 850 }
854 } 851 }
852
853 *pkind_compressible = kind_compressible;
854 return 0;
855}
856
857int setup_buffer_kind_and_compression(struct vm_gk20a *vm,
858 u32 flags,
859 struct buffer_attrs *bfr,
860 enum gmmu_pgsz_gk20a pgsz_idx)
861{
862 bool kind_compressible;
863 struct gk20a *g = gk20a_from_vm(vm);
864 int ctag_granularity = g->ops.fb.compression_page_size(g);
865
866 if (!bfr->use_kind_v)
867 bfr->kind_v = gmmu_pte_kind_invalid_v();
868 if (!bfr->use_uc_kind_v)
869 bfr->uc_kind_v = gmmu_pte_kind_invalid_v();
870
871 if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL) {
872 kind_compressible = (bfr->kind_v != gmmu_pte_kind_invalid_v());
873 if (!kind_compressible)
874 bfr->kind_v = bfr->uc_kind_v;
875 } else {
876 int err = setup_kind_legacy(vm, bfr, &kind_compressible);
877
878 if (err)
879 return err;
880 }
881
855 /* comptags only supported for suitable kinds, 128KB pagesize */ 882 /* comptags only supported for suitable kinds, 128KB pagesize */
856 if (kind_compressible && 883 if (kind_compressible &&
857 vm->gmmu_page_sizes[pgsz_idx] < g->ops.fb.compressible_page_size(g)) { 884 vm->gmmu_page_sizes[pgsz_idx] < g->ops.fb.compressible_page_size(g)) {
@@ -865,6 +892,9 @@ int setup_buffer_kind_and_compression(struct vm_gk20a *vm,
865 else 892 else
866 bfr->ctag_lines = 0; 893 bfr->ctag_lines = 0;
867 894
895 bfr->use_kind_v = (bfr->kind_v != gmmu_pte_kind_invalid_v());
896 bfr->use_uc_kind_v = (bfr->uc_kind_v != gmmu_pte_kind_invalid_v());
897
868 return 0; 898 return 0;
869} 899}
870 900
@@ -1649,7 +1679,8 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm,
1649 int dmabuf_fd, 1679 int dmabuf_fd,
1650 u64 *offset_align, 1680 u64 *offset_align,
1651 u32 flags, /*NVGPU_AS_MAP_BUFFER_FLAGS_*/ 1681 u32 flags, /*NVGPU_AS_MAP_BUFFER_FLAGS_*/
1652 int kind, 1682 s16 compr_kind,
1683 s16 incompr_kind,
1653 u64 buffer_offset, 1684 u64 buffer_offset,
1654 u64 mapping_size, 1685 u64 mapping_size,
1655 struct vm_gk20a_mapping_batch *batch) 1686 struct vm_gk20a_mapping_batch *batch)
@@ -1690,7 +1721,7 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm,
1690 } 1721 }
1691 1722
1692 ret_va = nvgpu_vm_map(vm, dmabuf, *offset_align, 1723 ret_va = nvgpu_vm_map(vm, dmabuf, *offset_align,
1693 flags, kind, true, 1724 flags, compr_kind, incompr_kind, true,
1694 gk20a_mem_flag_none, 1725 gk20a_mem_flag_none,
1695 buffer_offset, 1726 buffer_offset,
1696 mapping_size, 1727 mapping_size,