summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/cde.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-06-05 15:53:16 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-06-22 13:04:16 -0400
commit840e039d57d4acfb2be2a82c4b95a6d25c7aacd4 (patch)
treea4a358cf6bb5d005e8f6db159d1b3b03ddbf94df /drivers/gpu/nvgpu/os/linux/cde.c
parent46666ed101847d9b87ea60cd432dea97afbef0b1 (diff)
gpu: nvgpu: Update Linux side VM code for API solidification
Update the Linux specific code to match the MM API docs in the previous patch. The user passed page size is plumbed through the Linux VM mapping calls but is ultimately ignored once the core VM code is called. This will be handled in the next patch. This also adds some code to make the CDE page size picking happen semi-intelligently. In many cases the CDE buffers can be mapped with large pages. Bug 2011640 Change-Id: I20e78e7d5a841e410864b474179e71da1c2482f4 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1740610 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
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,