mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
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>
This commit is contained in:
committed by
mobile promotions
parent
84f2356b13
commit
2559fa295d
@@ -631,3 +631,10 @@ void nvgpu_free_sgtable(struct gk20a *g, struct sg_table **sgt)
|
||||
nvgpu_kfree(g, *sgt);
|
||||
*sgt = NULL;
|
||||
}
|
||||
|
||||
bool nvgpu_iommuable(struct gk20a *g)
|
||||
{
|
||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||
|
||||
return device_is_iommuable(l->dev);
|
||||
}
|
||||
|
||||
@@ -1276,8 +1276,7 @@ u64 gk20a_mm_smmu_vaddr_translate(struct gk20a *g, u64 iova)
|
||||
/* ensure it is not vidmem allocation */
|
||||
WARN_ON(is_vidmem_page_alloc(iova));
|
||||
|
||||
if (device_is_iommuable(dev_from_gk20a(g)) &&
|
||||
g->ops.mm.get_physical_addr_bits)
|
||||
if (nvgpu_iommuable(g) && g->ops.mm.get_physical_addr_bits)
|
||||
return iova | 1ULL << g->ops.mm.get_physical_addr_bits(g);
|
||||
|
||||
return iova;
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user