summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/cde.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/cde.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/cde.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c
index 66a80403..052a1d21 100644
--- a/drivers/gpu/nvgpu/os/linux/cde.c
+++ b/drivers/gpu/nvgpu/os/linux/cde.c
@@ -975,6 +975,30 @@ static struct gk20a_cde_ctx *gk20a_cde_allocate_context(struct nvgpu_os_linux *l
975 return cde_ctx; 975 return cde_ctx;
976} 976}
977 977
978static u32 gk20a_cde_mapping_page_size(struct vm_gk20a *vm,
979 u32 map_offset, u32 map_size)
980{
981 struct gk20a *g = gk20a_from_vm(vm);
982
983 /*
984 * To be simple we will just make the map size depend on the
985 * iommu'ability of the driver. If there's an IOMMU we can rely on
986 * buffers being contiguous. If not, then we'll use 4k pages since we
987 * know that will work for any buffer.
988 */
989 if (!nvgpu_iommuable(g))
990 return SZ_4K;
991
992 /*
993 * If map size or offset is not 64K aligned then use small pages.
994 */
995 if (map_size & (vm->big_page_size - 1) ||
996 map_offset & (vm->big_page_size - 1))
997 return SZ_4K;
998
999 return vm->big_page_size;
1000}
1001
978int gk20a_cde_convert(struct nvgpu_os_linux *l, 1002int gk20a_cde_convert(struct nvgpu_os_linux *l,
979 struct dma_buf *compbits_scatter_buf, 1003 struct dma_buf *compbits_scatter_buf,
980 u64 compbits_byte_offset, 1004 u64 compbits_byte_offset,
@@ -1071,7 +1095,10 @@ __releases(&l->cde_app->mutex)
1071 err = nvgpu_vm_map_linux(cde_ctx->vm, compbits_scatter_buf, 0, 1095 err = nvgpu_vm_map_linux(cde_ctx->vm, compbits_scatter_buf, 0,
1072 NVGPU_VM_MAP_CACHEABLE | 1096 NVGPU_VM_MAP_CACHEABLE |
1073 NVGPU_VM_MAP_DIRECT_KIND_CTRL, 1097 NVGPU_VM_MAP_DIRECT_KIND_CTRL,
1074 NVGPU_KIND_INVALID, 1098 gk20a_cde_mapping_page_size(cde_ctx->vm,
1099 map_offset,
1100 map_size),
1101 NV_KIND_INVALID,
1075 compbits_kind, /* incompressible kind */ 1102 compbits_kind, /* incompressible kind */
1076 gk20a_mem_flag_none, 1103 gk20a_mem_flag_none,
1077 map_offset, map_size, 1104 map_offset, map_size,