From 2559fa295d0c478466e47496174fa2108ab01c33 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 16 Aug 2017 15:53:55 -0700 Subject: gpu: nvgpu: Add common vaddr translate function Add a function to do address translation for IOMMU capable GPUs. When an iGPU is behind and IOMMU it can pick whether to use that IOMMU for translation by adding a bit to physical addresses. This function takes care of that. However, this required an abstracted nvgpu_iommuable() API to check whether a GPU is behind an IOMMU. This patch adds that API for Linux. JIRA NVGPU-68 Change-Id: I489d14475167c019c294407372395df78c8b5feb Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1542965 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Sourab Gupta Reviewed-by: Konsta Holtta Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/include/nvgpu/dma.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/dma.h b/drivers/gpu/nvgpu/include/nvgpu/dma.h index 50681f8d..c0397b58 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/dma.h +++ b/drivers/gpu/nvgpu/include/nvgpu/dma.h @@ -50,6 +50,20 @@ struct nvgpu_mem; */ #define NVGPU_DMA_READ_ONLY (1 << 2) +/** + * nvgpu_iommuable - Check if GPU is behind IOMMU + * + * @g - The GPU. + * + * Returns true if the passed GPU is behind an IOMMU; false otherwise. If the + * GPU is iommuable then the DMA address in nvgpu_mem_sgl is valid. + * + * Note that even if a GPU is behind an IOMMU that does not necessarily mean the + * GPU _must_ use DMA addresses. GPUs may still use physical addresses if it + * makes sense. + */ +bool nvgpu_iommuable(struct gk20a *g); + /** * nvgpu_dma_alloc - Allocate DMA memory * -- cgit v1.2.2