summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2016-06-17 08:56:07 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-07-06 06:34:23 -0400
commitb8915ab5aabb02866019221c51d96f304658207f (patch)
tree16754368daa70c837dea7be8283cf0c5027b23f3 /drivers/gpu/nvgpu/gk20a/gr_gk20a.c
parent67fae6e547ca20c4171e1b3d0ad9d252c2e3c0ee (diff)
gpu: nvgpu: support in-kernel vidmem mappings
Propagate the buffer aperture flag in gk20a_locked_gmmu_map up so that buffers represented as a mem_desc and present in vidmem can be mapped to gpu. JIRA DNVGPU-18 JIRA DNVGPU-76 Change-Id: I46cf87e27229123016727339b9349d5e2c835b3e Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/1169308 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gr_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c66
1 files changed, 30 insertions, 36 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index bdc65cab..0d97e84c 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -1824,7 +1824,8 @@ int gr_gk20a_update_hwpm_ctxsw_mode(struct gk20a *g,
1824 &pm_ctx->mem.sgt, 1824 &pm_ctx->mem.sgt,
1825 pm_ctx->mem.size, 1825 pm_ctx->mem.size,
1826 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, 1826 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE,
1827 gk20a_mem_flag_none, true); 1827 gk20a_mem_flag_none, true,
1828 pm_ctx->mem.aperture);
1828 if (!pm_ctx->mem.gpu_va) { 1829 if (!pm_ctx->mem.gpu_va) {
1829 gk20a_err(dev_from_gk20a(g), 1830 gk20a_err(dev_from_gk20a(g),
1830 "failed to map pm ctxt buffer"); 1831 "failed to map pm ctxt buffer");
@@ -2046,7 +2047,8 @@ static int gr_gk20a_init_ctxsw_ucode_vaspace(struct gk20a *g)
2046 ucode_info->surface_desc.size, 2047 ucode_info->surface_desc.size,
2047 0, /* flags */ 2048 0, /* flags */
2048 gk20a_mem_flag_read_only, 2049 gk20a_mem_flag_read_only,
2049 false); 2050 false,
2051 ucode_info->surface_desc.aperture);
2050 if (!ucode_info->surface_desc.gpu_va) { 2052 if (!ucode_info->surface_desc.gpu_va) {
2051 gk20a_err(d, "failed to update gmmu ptes\n"); 2053 gk20a_err(d, "failed to update gmmu ptes\n");
2052 return -ENOMEM; 2054 return -ENOMEM;
@@ -2650,82 +2652,73 @@ static int gr_gk20a_map_global_ctx_buffers(struct gk20a *g,
2650 u64 *g_bfr_va = c->ch_ctx.global_ctx_buffer_va; 2652 u64 *g_bfr_va = c->ch_ctx.global_ctx_buffer_va;
2651 u64 *g_bfr_size = c->ch_ctx.global_ctx_buffer_size; 2653 u64 *g_bfr_size = c->ch_ctx.global_ctx_buffer_size;
2652 struct gr_gk20a *gr = &g->gr; 2654 struct gr_gk20a *gr = &g->gr;
2653 struct sg_table *sgt; 2655 struct mem_desc *mem;
2654 u64 size;
2655 u64 gpu_va; 2656 u64 gpu_va;
2656 u32 i; 2657 u32 i;
2657 gk20a_dbg_fn(""); 2658 gk20a_dbg_fn("");
2658 2659
2659 /* Circular Buffer */ 2660 /* Circular Buffer */
2660 if (!c->vpr || (gr->global_ctx_buffer[CIRCULAR_VPR].mem.sgt == NULL)) { 2661 if (!c->vpr || (gr->global_ctx_buffer[CIRCULAR_VPR].mem.sgt == NULL)) {
2661 sgt = gr->global_ctx_buffer[CIRCULAR].mem.sgt; 2662 mem = &gr->global_ctx_buffer[CIRCULAR].mem;
2662 size = gr->global_ctx_buffer[CIRCULAR].mem.size;
2663 } else { 2663 } else {
2664 sgt = gr->global_ctx_buffer[CIRCULAR_VPR].mem.sgt; 2664 mem = &gr->global_ctx_buffer[CIRCULAR_VPR].mem;
2665 size = gr->global_ctx_buffer[CIRCULAR_VPR].mem.size;
2666 } 2665 }
2667 2666
2668 gpu_va = gk20a_gmmu_map(ch_vm, &sgt, size, 2667 gpu_va = gk20a_gmmu_map(ch_vm, &mem->sgt, mem->size,
2669 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, 2668 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE,
2670 gk20a_mem_flag_none, true); 2669 gk20a_mem_flag_none, true, mem->aperture);
2671 if (!gpu_va) 2670 if (!gpu_va)
2672 goto clean_up; 2671 goto clean_up;
2673 g_bfr_va[CIRCULAR_VA] = gpu_va; 2672 g_bfr_va[CIRCULAR_VA] = gpu_va;
2674 g_bfr_size[CIRCULAR_VA] = size; 2673 g_bfr_size[CIRCULAR_VA] = mem->size;
2675 2674
2676 /* Attribute Buffer */ 2675 /* Attribute Buffer */
2677 if (!c->vpr || (gr->global_ctx_buffer[ATTRIBUTE_VPR].mem.sgt == NULL)) { 2676 if (!c->vpr || (gr->global_ctx_buffer[ATTRIBUTE_VPR].mem.sgt == NULL)) {
2678 sgt = gr->global_ctx_buffer[ATTRIBUTE].mem.sgt; 2677 mem = &gr->global_ctx_buffer[ATTRIBUTE].mem;
2679 size = gr->global_ctx_buffer[ATTRIBUTE].mem.size;
2680 } else { 2678 } else {
2681 sgt = gr->global_ctx_buffer[ATTRIBUTE_VPR].mem.sgt; 2679 mem = &gr->global_ctx_buffer[ATTRIBUTE_VPR].mem;
2682 size = gr->global_ctx_buffer[ATTRIBUTE_VPR].mem.size;
2683 } 2680 }
2684 2681
2685 gpu_va = gk20a_gmmu_map(ch_vm, &sgt, size, 2682 gpu_va = gk20a_gmmu_map(ch_vm, &mem->sgt, mem->size,
2686 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, 2683 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE,
2687 gk20a_mem_flag_none, false); 2684 gk20a_mem_flag_none, false, mem->aperture);
2688 if (!gpu_va) 2685 if (!gpu_va)
2689 goto clean_up; 2686 goto clean_up;
2690 g_bfr_va[ATTRIBUTE_VA] = gpu_va; 2687 g_bfr_va[ATTRIBUTE_VA] = gpu_va;
2691 g_bfr_size[ATTRIBUTE_VA] = size; 2688 g_bfr_size[ATTRIBUTE_VA] = mem->size;
2692 2689
2693 /* Page Pool */ 2690 /* Page Pool */
2694 if (!c->vpr || (gr->global_ctx_buffer[PAGEPOOL_VPR].mem.sgt == NULL)) { 2691 if (!c->vpr || (gr->global_ctx_buffer[PAGEPOOL_VPR].mem.sgt == NULL)) {
2695 sgt = gr->global_ctx_buffer[PAGEPOOL].mem.sgt; 2692 mem = &gr->global_ctx_buffer[PAGEPOOL].mem;
2696 size = gr->global_ctx_buffer[PAGEPOOL].mem.size;
2697 } else { 2693 } else {
2698 sgt = gr->global_ctx_buffer[PAGEPOOL_VPR].mem.sgt; 2694 mem = &gr->global_ctx_buffer[PAGEPOOL_VPR].mem;
2699 size = gr->global_ctx_buffer[PAGEPOOL_VPR].mem.size;
2700 } 2695 }
2701 2696
2702 gpu_va = gk20a_gmmu_map(ch_vm, &sgt, size, 2697 gpu_va = gk20a_gmmu_map(ch_vm, &mem->sgt, mem->size,
2703 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, 2698 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE,
2704 gk20a_mem_flag_none, true); 2699 gk20a_mem_flag_none, true, mem->aperture);
2705 if (!gpu_va) 2700 if (!gpu_va)
2706 goto clean_up; 2701 goto clean_up;
2707 g_bfr_va[PAGEPOOL_VA] = gpu_va; 2702 g_bfr_va[PAGEPOOL_VA] = gpu_va;
2708 g_bfr_size[PAGEPOOL_VA] = size; 2703 g_bfr_size[PAGEPOOL_VA] = mem->size;
2709 2704
2710 /* Golden Image */ 2705 /* Golden Image */
2711 sgt = gr->global_ctx_buffer[GOLDEN_CTX].mem.sgt; 2706 mem = &gr->global_ctx_buffer[GOLDEN_CTX].mem;
2712 size = gr->global_ctx_buffer[GOLDEN_CTX].mem.size; 2707 gpu_va = gk20a_gmmu_map(ch_vm, &mem->sgt, mem->size, 0,
2713 gpu_va = gk20a_gmmu_map(ch_vm, &sgt, size, 0, 2708 gk20a_mem_flag_none, true, mem->aperture);
2714 gk20a_mem_flag_none, true);
2715 if (!gpu_va) 2709 if (!gpu_va)
2716 goto clean_up; 2710 goto clean_up;
2717 g_bfr_va[GOLDEN_CTX_VA] = gpu_va; 2711 g_bfr_va[GOLDEN_CTX_VA] = gpu_va;
2718 g_bfr_size[GOLDEN_CTX_VA] = size; 2712 g_bfr_size[GOLDEN_CTX_VA] = mem->size;
2719 2713
2720 /* Priv register Access Map */ 2714 /* Priv register Access Map */
2721 sgt = gr->global_ctx_buffer[PRIV_ACCESS_MAP].mem.sgt; 2715 mem = &gr->global_ctx_buffer[PRIV_ACCESS_MAP].mem;
2722 size = gr->global_ctx_buffer[PRIV_ACCESS_MAP].mem.size; 2716 gpu_va = gk20a_gmmu_map(ch_vm, &mem->sgt, mem->size, 0,
2723 gpu_va = gk20a_gmmu_map(ch_vm, &sgt, size, 0, 2717 gk20a_mem_flag_none, true, mem->aperture);
2724 gk20a_mem_flag_none, true);
2725 if (!gpu_va) 2718 if (!gpu_va)
2726 goto clean_up; 2719 goto clean_up;
2727 g_bfr_va[PRIV_ACCESS_MAP_VA] = gpu_va; 2720 g_bfr_va[PRIV_ACCESS_MAP_VA] = gpu_va;
2728 g_bfr_size[PRIV_ACCESS_MAP_VA] = size; 2721 g_bfr_size[PRIV_ACCESS_MAP_VA] = mem->size;
2729 2722
2730 c->ch_ctx.global_ctx_buffer_mapped = true; 2723 c->ch_ctx.global_ctx_buffer_mapped = true;
2731 return 0; 2724 return 0;
@@ -2793,7 +2786,8 @@ int gr_gk20a_alloc_gr_ctx(struct gk20a *g,
2793 2786
2794 gr_ctx->mem.gpu_va = gk20a_gmmu_map(vm, &gr_ctx->mem.sgt, gr_ctx->mem.size, 2787 gr_ctx->mem.gpu_va = gk20a_gmmu_map(vm, &gr_ctx->mem.sgt, gr_ctx->mem.size,
2795 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE, 2788 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE,
2796 gk20a_mem_flag_none, true); 2789 gk20a_mem_flag_none, true,
2790 gr_ctx->mem.aperture);
2797 if (!gr_ctx->mem.gpu_va) 2791 if (!gr_ctx->mem.gpu_va)
2798 goto err_free_mem; 2792 goto err_free_mem;
2799 2793