From 840e039d57d4acfb2be2a82c4b95a6d25c7aacd4 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 5 Jun 2018 20:53:16 +0100 Subject: 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 Reviewed-on: https://git-master.nvidia.com/r/1740610 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/cde.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/os/linux/cde.c') 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 return cde_ctx; } +static u32 gk20a_cde_mapping_page_size(struct vm_gk20a *vm, + u32 map_offset, u32 map_size) +{ + struct gk20a *g = gk20a_from_vm(vm); + + /* + * To be simple we will just make the map size depend on the + * iommu'ability of the driver. If there's an IOMMU we can rely on + * buffers being contiguous. If not, then we'll use 4k pages since we + * know that will work for any buffer. + */ + if (!nvgpu_iommuable(g)) + return SZ_4K; + + /* + * If map size or offset is not 64K aligned then use small pages. + */ + if (map_size & (vm->big_page_size - 1) || + map_offset & (vm->big_page_size - 1)) + return SZ_4K; + + return vm->big_page_size; +} + int gk20a_cde_convert(struct nvgpu_os_linux *l, struct dma_buf *compbits_scatter_buf, u64 compbits_byte_offset, @@ -1071,7 +1095,10 @@ __releases(&l->cde_app->mutex) err = nvgpu_vm_map_linux(cde_ctx->vm, compbits_scatter_buf, 0, NVGPU_VM_MAP_CACHEABLE | NVGPU_VM_MAP_DIRECT_KIND_CTRL, - NVGPU_KIND_INVALID, + gk20a_cde_mapping_page_size(cde_ctx->vm, + map_offset, + map_size), + NV_KIND_INVALID, compbits_kind, /* incompressible kind */ gk20a_mem_flag_none, map_offset, map_size, -- cgit v1.2.2