summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-08-16 18:12:53 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-04 05:19:06 -0400
commit84f2356b13fdad636c33d1d2908ff2e977a09bf0 (patch)
tree5d2ece0dd351bbedf3d5bca904897e3a0c2232b0 /drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
parent9d97af9e9fd461ed8e69cadb027fe639d7e3247b (diff)
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>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/nvgpu_mem.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/nvgpu_mem.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
index 8d8909dd..8cf3011e 100644
--- a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
+++ b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
@@ -284,6 +284,14 @@ static u64 nvgpu_mem_get_addr_sysmem(struct gk20a *g, struct nvgpu_mem *mem)
284 * Return the base address of %mem. Handles whether this is a VIDMEM or SYSMEM 284 * Return the base address of %mem. Handles whether this is a VIDMEM or SYSMEM
285 * allocation. 285 * allocation.
286 * 286 *
287 * Note: this API does not make sense to use for _VIDMEM_ buffers with greater
288 * than one scatterlist chunk. If there's more than one scatterlist chunk then
289 * the buffer will not be contiguous. As such the base address probably isn't
290 * very useful. This is true for SYSMEM as well, if there's no IOMMU.
291 *
292 * However! It _is_ OK to use this on discontiguous sysmem buffers _if_ there's
293 * an IOMMU present and enabled for the GPU.
294 *
287 * %attrs can be NULL. If it is not NULL then it may be inspected to determine 295 * %attrs can be NULL. If it is not NULL then it may be inspected to determine
288 * if the address needs to be modified before writing into a PTE. 296 * if the address needs to be modified before writing into a PTE.
289 */ 297 */
@@ -306,6 +314,23 @@ u64 nvgpu_mem_get_addr(struct gk20a *g, struct nvgpu_mem *mem)
306} 314}
307 315
308/* 316/*
317 * This should only be used on contiguous buffers regardless of whether
318 * there's an IOMMU present/enabled. This applies to both SYSMEM and
319 * VIDMEM.
320 */
321u64 nvgpu_mem_get_phys_addr(struct gk20a *g, struct nvgpu_mem *mem)
322{
323 /*
324 * For a VIDMEM buf, this is identical to simply get_addr() so just fall
325 * back to that.
326 */
327 if (mem->aperture == APERTURE_VIDMEM)
328 return nvgpu_mem_get_addr(g, mem);
329
330 return sg_phys(mem->priv.sgt->sgl);
331}
332
333/*
309 * Be careful how you use this! You are responsible for correctly freeing this 334 * Be careful how you use this! You are responsible for correctly freeing this
310 * memory. 335 * memory.
311 */ 336 */