summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
diff options
context:
space:
mode:
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 */