summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-08-16 18:53:55 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-04 05:19:08 -0400
commit2559fa295d0c478466e47496174fa2108ab01c33 (patch)
tree94d1c9f12edb985b984e8599653c38a836be2adb /drivers/gpu/nvgpu
parent84f2356b13fdad636c33d1d2908ff2e977a09bf0 (diff)
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 <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1542965 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Sourab Gupta <sourabg@nvidia.com> Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r--drivers/gpu/nvgpu/common/linux/dma.c7
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/dma.h14
3 files changed, 22 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c
index 67b58016..7b892731 100644
--- a/drivers/gpu/nvgpu/common/linux/dma.c
+++ b/drivers/gpu/nvgpu/common/linux/dma.c
@@ -631,3 +631,10 @@ void nvgpu_free_sgtable(struct gk20a *g, struct sg_table **sgt)
631 nvgpu_kfree(g, *sgt); 631 nvgpu_kfree(g, *sgt);
632 *sgt = NULL; 632 *sgt = NULL;
633} 633}
634
635bool nvgpu_iommuable(struct gk20a *g)
636{
637 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
638
639 return device_is_iommuable(l->dev);
640}
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index dc1e9688..3d1f8d28 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -1276,8 +1276,7 @@ u64 gk20a_mm_smmu_vaddr_translate(struct gk20a *g, u64 iova)
1276 /* ensure it is not vidmem allocation */ 1276 /* ensure it is not vidmem allocation */
1277 WARN_ON(is_vidmem_page_alloc(iova)); 1277 WARN_ON(is_vidmem_page_alloc(iova));
1278 1278
1279 if (device_is_iommuable(dev_from_gk20a(g)) && 1279 if (nvgpu_iommuable(g) && g->ops.mm.get_physical_addr_bits)
1280 g->ops.mm.get_physical_addr_bits)
1281 return iova | 1ULL << g->ops.mm.get_physical_addr_bits(g); 1280 return iova | 1ULL << g->ops.mm.get_physical_addr_bits(g);
1282 1281
1283 return iova; 1282 return iova;
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
@@ -51,6 +51,20 @@ struct nvgpu_mem;
51#define NVGPU_DMA_READ_ONLY (1 << 2) 51#define NVGPU_DMA_READ_ONLY (1 << 2)
52 52
53/** 53/**
54 * nvgpu_iommuable - Check if GPU is behind IOMMU
55 *
56 * @g - The GPU.
57 *
58 * Returns true if the passed GPU is behind an IOMMU; false otherwise. If the
59 * GPU is iommuable then the DMA address in nvgpu_mem_sgl is valid.
60 *
61 * Note that even if a GPU is behind an IOMMU that does not necessarily mean the
62 * GPU _must_ use DMA addresses. GPUs may still use physical addresses if it
63 * makes sense.
64 */
65bool nvgpu_iommuable(struct gk20a *g);
66
67/**
54 * nvgpu_dma_alloc - Allocate DMA memory 68 * nvgpu_dma_alloc - Allocate DMA memory
55 * 69 *
56 * @g - The GPU. 70 * @g - The GPU.