From d73ad6c07da23636c00c60effeeb53ea35847ee8 Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Tue, 28 Nov 2017 18:12:12 +0200 Subject: gpu: nvgpu: Alignment check for compressible fixed-address mappings Add an alignment check for compressible-kind fixed-address mappings. If we're using page size smaller than the comptag line coverage window, the GPU VA and the physical buffer offset must be aligned in respect to that window. Bug 1995897 Bug 2011640 Bug 2011668 Change-Id: If68043ee2828d54b9398d77553d10d35cc319236 Signed-off-by: Sami Kiminki Reviewed-on: https://git-master.nvidia.com/r/1606439 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/vm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'drivers/gpu/nvgpu/common/mm') diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 637632e0..f85089d5 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c @@ -847,6 +847,29 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, goto clean_up; } + if ((binfo.compr_kind != NVGPU_KIND_INVALID) && + (flags & NVGPU_VM_MAP_FIXED_OFFSET)) { + /* + * Fixed-address compressible mapping is + * requested. Make sure we're respecting the alignment + * requirement for virtual addresses and buffer + * offsets. + * + * This check must be done before we may fall back to + * the incompressible kind. + */ + + const u64 offset_mask = g->ops.fb.compression_align_mask(g); + + if ((map_addr & offset_mask) != (phys_offset & offset_mask)) { + nvgpu_log(g, gpu_dbg_map, + "Misaligned compressible-kind fixed-address " + "mapping"); + err = -EINVAL; + goto clean_up; + } + } + if (binfo.compr_kind != NVGPU_KIND_INVALID) { struct gk20a_comptags comptags = { 0 }; -- cgit v1.2.2