From 98da3f8eed914225e9ffe0f768d7647506e95cdc Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Mon, 29 Jan 2018 16:21:30 -0800 Subject: gpu: nvgpu: Cleanup usage of bypass_smmu The GPU has multiple different operating modes in respect to IOMMU'ability. As such there needs to be a clean way to tell the driver whether it is IOMMU'able or not. This state also does not always reflect what is possible: all becasue the GPU can generate IOMMU'ed memory requests doesn't mean it wants to. The nvgpu_iommuable() API has now existed for a little while which is a useful way to convey whether nvgpu should consider the GPU as IOMMU'able. However, there is also the g->mm.bypass_smmu flag which used to be able to override what the GPU decided it should do. Typically it was assigned the same value as nvgpu_iommuable() but that was not necessarily a requirment. This patch removes all the usages of g->mm.bypass_smmu and instead uses the nvgpu_iommuable() function. All places where the check against g->mm.bypass_smmu have been replaced with nvgpu_iommuable(). The code should now be much cleaner. Subsequently other checks can also be placed in the nvgpu_iommuable() function. For example, when NVLINK comes online and the GPU should no longer consider DMA addresses and instead use scatter-gather lists directly the ngpu_iommuable() function will be able to check the state of NVLINK and then act accordingly. Change-Id: I0da6262386de15709decac89d63d3eecfec20cd7 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1648332 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/gmmu.c | 2 +- drivers/gpu/nvgpu/common/mm/nvgpu_mem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/common/mm') diff --git a/drivers/gpu/nvgpu/common/mm/gmmu.c b/drivers/gpu/nvgpu/common/mm/gmmu.c index 53ec3029..78ec361e 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu.c @@ -501,7 +501,7 @@ static int __nvgpu_gmmu_do_update_page_table(struct vm_gk20a *vm, * mapping is simple since the "physical" address is actually a virtual * IO address and will be contiguous. */ - if (attrs->aperture == APERTURE_SYSMEM && !g->mm.bypass_smmu) { + if (attrs->aperture == APERTURE_SYSMEM && nvgpu_iommuable(g)) { u64 io_addr = nvgpu_sgt_get_gpu_addr(g, sgt, sgt->sgl, attrs); io_addr += space_to_skip; diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c index f472d2a0..73b6b2a7 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c @@ -96,7 +96,7 @@ u64 nvgpu_sgt_alignment(struct gk20a *g, struct nvgpu_sgt *sgt) * and double check length of buffer later. Also, since there's an * IOMMU we know that this DMA address is contiguous. */ - if (!g->mm.bypass_smmu && + if (nvgpu_iommuable(g) && nvgpu_sgt_iommuable(g, sgt) && nvgpu_sgt_get_dma(sgt, sgt->sgl)) return 1ULL << __ffs(nvgpu_sgt_get_dma(sgt, sgt->sgl)); -- cgit v1.2.2