mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 09:57:08 +03:00
gpu: nvgpu: Remove sg_phys() from GMMU code
Remove the last sg_phys() call from the GMMU code and replace it with a generic nvgpu_mem API. This new API, nvgpu_mem_get_phys_addr(), returns the physical address of an nvgpu_mem struct. Also, implement this new API in the Linux specific nvgpu_mem code since it requires access to the underlying SGT/SGL. JIRA NVGPU-68 Change-Id: Idf88701a2a8515464c658c26e0de493c82ff850d Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1542964 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
9d97af9e9f
commit
84f2356b13
@@ -284,6 +284,14 @@ static u64 nvgpu_mem_get_addr_sysmem(struct gk20a *g, struct nvgpu_mem *mem)
|
||||
* Return the base address of %mem. Handles whether this is a VIDMEM or SYSMEM
|
||||
* allocation.
|
||||
*
|
||||
* Note: this API does not make sense to use for _VIDMEM_ buffers with greater
|
||||
* than one scatterlist chunk. If there's more than one scatterlist chunk then
|
||||
* the buffer will not be contiguous. As such the base address probably isn't
|
||||
* very useful. This is true for SYSMEM as well, if there's no IOMMU.
|
||||
*
|
||||
* However! It _is_ OK to use this on discontiguous sysmem buffers _if_ there's
|
||||
* an IOMMU present and enabled for the GPU.
|
||||
*
|
||||
* %attrs can be NULL. If it is not NULL then it may be inspected to determine
|
||||
* if the address needs to be modified before writing into a PTE.
|
||||
*/
|
||||
@@ -305,6 +313,23 @@ u64 nvgpu_mem_get_addr(struct gk20a *g, struct nvgpu_mem *mem)
|
||||
return alloc->base;
|
||||
}
|
||||
|
||||
/*
|
||||
* This should only be used on contiguous buffers regardless of whether
|
||||
* there's an IOMMU present/enabled. This applies to both SYSMEM and
|
||||
* VIDMEM.
|
||||
*/
|
||||
u64 nvgpu_mem_get_phys_addr(struct gk20a *g, struct nvgpu_mem *mem)
|
||||
{
|
||||
/*
|
||||
* For a VIDMEM buf, this is identical to simply get_addr() so just fall
|
||||
* back to that.
|
||||
*/
|
||||
if (mem->aperture == APERTURE_VIDMEM)
|
||||
return nvgpu_mem_get_addr(g, mem);
|
||||
|
||||
return sg_phys(mem->priv.sgt->sgl);
|
||||
}
|
||||
|
||||
/*
|
||||
* Be careful how you use this! You are responsible for correctly freeing this
|
||||
* memory.
|
||||
|
||||
@@ -212,7 +212,7 @@ u64 nvgpu_pde_phys_addr(struct gk20a *g, struct nvgpu_gmmu_pd *pd)
|
||||
u64 page_addr;
|
||||
|
||||
if (g->mm.has_physical_mode)
|
||||
page_addr = sg_phys(pd->mem->priv.sgt->sgl);
|
||||
page_addr = nvgpu_mem_get_phys_addr(g, pd->mem);
|
||||
else
|
||||
page_addr = nvgpu_mem_get_addr(g, pd->mem);
|
||||
|
||||
|
||||
@@ -291,6 +291,7 @@ void nvgpu_memset(struct gk20a *g, struct nvgpu_mem *mem, u32 offset,
|
||||
u32 c, u32 size);
|
||||
|
||||
u64 nvgpu_mem_get_addr(struct gk20a *g, struct nvgpu_mem *mem);
|
||||
u64 nvgpu_mem_get_phys_addr(struct gk20a *g, struct nvgpu_mem *mem);
|
||||
|
||||
u32 __nvgpu_aperture_mask(struct gk20a *g, enum nvgpu_aperture aperture,
|
||||
u32 sysmem_mask, u32 vidmem_mask);
|
||||
|
||||
Reference in New Issue
Block a user