diff options
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/dma.c | 7 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/dma.h | 14 |
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 | |||
635 | bool 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 | */ | ||
65 | bool 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. |