From a6e3403f460e835cd35d1b82e826aa440e5378e3 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 18 Apr 2018 21:14:50 +0100 Subject: gpu: nvgpu: Update __get_pte_size() to check IOMMU-ability When generating the PTE size for a given mapping the code must consider whether the GPU is being IOMMU'ed. The presence and usage of an IOMMU implies the buffers will appear contiguous to the GPU. Without an IOMMU we cannot assume that and therefor must use small pages regardless of the size of the buffer to be mapped. Bug 2011640 Change-Id: I6c64cbcd8844a7ed855116754b795d949a3003af Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1697891 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/mm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/common/mm/mm.c b/drivers/gpu/nvgpu/common/mm/mm.c index 3c083ab8..c9b2b493 100644 --- a/drivers/gpu/nvgpu/common/mm/mm.c +++ b/drivers/gpu/nvgpu/common/mm/mm.c @@ -77,10 +77,13 @@ static enum gmmu_pgsz_gk20a __get_pte_size_split_addr(struct vm_gk20a *vm, * - Attempt to find a reserved memory area and use the page size * based on that. * - If no reserved page size is available, default to small pages. - * o If the base is zero: + * o If the base is zero and we have an SMMU: * - If the size is larger than or equal to the big page size, use big * pages. * - Otherwise use small pages. + * o If there's no SMMU: + * - Regardless of buffer size use small pages since we have no + * - guarantee of contiguity. */ enum gmmu_pgsz_gk20a __get_pte_size(struct vm_gk20a *vm, u64 base, u64 size) { @@ -95,7 +98,8 @@ enum gmmu_pgsz_gk20a __get_pte_size(struct vm_gk20a *vm, u64 base, u64 size) if (base) return __get_pte_size_fixed_map(vm, base, size); - if (size >= vm->gmmu_page_sizes[gmmu_page_size_big]) + if (size >= vm->gmmu_page_sizes[gmmu_page_size_big] && + nvgpu_iommuable(g)) return gmmu_page_size_big; return gmmu_page_size_small; } -- cgit v1.2.2