From 17c581d75514c32d1e8c1e416beb33b3ccce22a5 Mon Sep 17 00:00:00 2001 From: Sunny He Date: Tue, 15 Aug 2017 12:01:04 -0700 Subject: gpu: nvgpu: SGL passthrough implementation The basic nvgpu_mem_sgl implementation provides support for OS specific scatter-gather list implementations by simply copying them node by node. This is inefficient, taking extra time and memory. This patch implements an nvgpu_mem_sgt struct to act as a header which is inserted at the front of any scatter- gather list implementation. This labels every struct with a set of ops which can be used to interact with the attached scatter gather list. Since nvgpu common code only has to interact with these function pointers, any sgl implementation can be used. Initialization only requires the allocation of a single struct, removing the need to copy or iterate through the sgl being converted. Jira NVGPU-186 Change-Id: I2994f804a4a4cc141b702e987e9081d8560ba2e8 Signed-off-by: Sunny He Reviewed-on: https://git-master.nvidia.com/r/1541426 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c') diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c index ee9b791a..d9324363 100644 --- a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c +++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c @@ -40,7 +40,7 @@ static inline int add_mem_desc(struct tegra_vgpu_mem_desc *mem_desc, static u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, u64 map_offset, - struct nvgpu_mem_sgl *sgl, + struct nvgpu_sgt *sgt, u64 buffer_offset, u64 size, int pgsz_idx, @@ -66,12 +66,13 @@ static u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, void *handle = NULL; size_t oob_size; u8 prot; + void *sgl; gk20a_dbg_fn(""); /* FIXME: add support for sparse mappings */ - if (WARN_ON(!sgl) || WARN_ON(!g->mm.bypass_smmu)) + if (WARN_ON(!sgt) || WARN_ON(!g->mm.bypass_smmu)) return 0; if (space_to_skip & (page_size - 1)) @@ -97,7 +98,7 @@ static u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, err = -EINVAL; goto fail; } - + sgl = sgt->sgl; while (sgl) { u64 phys_addr; u64 chunk_length; @@ -106,15 +107,15 @@ static u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, * Cut out sgl ents for space_to_skip. */ if (space_to_skip && - space_to_skip >= nvgpu_mem_sgl_length(sgl)) { - space_to_skip -= nvgpu_mem_sgl_length(sgl); - sgl = nvgpu_mem_sgl_next(sgl); + space_to_skip >= nvgpu_sgt_get_length(sgt, sgl)) { + space_to_skip -= nvgpu_sgt_get_length(sgt, sgl); + sgl = nvgpu_sgt_get_next(sgt, sgl); continue; } - phys_addr = nvgpu_mem_sgl_phys(sgl) + space_to_skip; + phys_addr = nvgpu_sgt_get_phys(sgt, sgl) + space_to_skip; chunk_length = min(size, - nvgpu_mem_sgl_length(sgl) - space_to_skip); + nvgpu_sgt_get_length(sgt, sgl) - space_to_skip); if (add_mem_desc(&mem_desc[mem_desc_count++], phys_addr, chunk_length, &oob_size)) { @@ -124,7 +125,7 @@ static u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, space_to_skip = 0; size -= chunk_length; - sgl = nvgpu_mem_sgl_next(sgl); + sgl = nvgpu_sgt_get_next(sgt, sgl); if (size == 0) break; -- cgit v1.2.2