diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-04-06 18:30:01 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-20 19:14:32 -0400 |
commit | e32f62fadfcde413bcd9b5af61ad884e27ba2bf1 (patch) | |
tree | eff606a0826841eae6ade5906acd9da589d1179a /drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |
parent | 52bd58b560d0b3b49c03ef5c2637b67adeac8193 (diff) |
gpu: nvgpu: Move Linux nvgpu_mem fields
Hide the Linux specific nvgpu_mem fields so that in subsequent patches
core code can instead of using struct sg_table it can use mem_desc.
Routines for accessing system specific fields will be added as needed.
This is the first step in a fairly major overhaul of the GMMU mapping
routines. There are numerous issues with the current design (or lack
there of): massively coupled code, system dependencies, disorganization,
etc.
JIRA NVGPU-12
JIRA NVGPU-30
Change-Id: I2e7d3ae3a07468cfc17c1c642d28ed1b0952474d
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1464076
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 1db52c85..69e00c5e 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |||
@@ -817,27 +817,28 @@ static int alloc_gmmu_phys_pages(struct vm_gk20a *vm, u32 order, | |||
817 | gk20a_dbg(gpu_dbg_pte, "alloc_pages failed"); | 817 | gk20a_dbg(gpu_dbg_pte, "alloc_pages failed"); |
818 | goto err_out; | 818 | goto err_out; |
819 | } | 819 | } |
820 | entry->mem.sgt = nvgpu_kzalloc(g, sizeof(*entry->mem.sgt)); | 820 | entry->mem.priv.sgt = nvgpu_kzalloc(g, sizeof(*entry->mem.priv.sgt)); |
821 | if (!entry->mem.sgt) { | 821 | if (!entry->mem.priv.sgt) { |
822 | gk20a_dbg(gpu_dbg_pte, "cannot allocate sg table"); | 822 | gk20a_dbg(gpu_dbg_pte, "cannot allocate sg table"); |
823 | goto err_alloced; | 823 | goto err_alloced; |
824 | } | 824 | } |
825 | err = sg_alloc_table(entry->mem.sgt, 1, GFP_KERNEL); | 825 | err = sg_alloc_table(entry->mem.priv.sgt, 1, GFP_KERNEL); |
826 | if (err) { | 826 | if (err) { |
827 | gk20a_dbg(gpu_dbg_pte, "sg_alloc_table failed"); | 827 | gk20a_dbg(gpu_dbg_pte, "sg_alloc_table failed"); |
828 | goto err_sg_table; | 828 | goto err_sg_table; |
829 | } | 829 | } |
830 | sg_set_page(entry->mem.sgt->sgl, pages, len, 0); | 830 | sg_set_page(entry->mem.priv.sgt->sgl, pages, len, 0); |
831 | entry->mem.cpu_va = page_address(pages); | 831 | entry->mem.cpu_va = page_address(pages); |
832 | memset(entry->mem.cpu_va, 0, len); | 832 | memset(entry->mem.cpu_va, 0, len); |
833 | entry->mem.size = len; | 833 | entry->mem.size = len; |
834 | entry->mem.aperture = APERTURE_SYSMEM; | 834 | entry->mem.aperture = APERTURE_SYSMEM; |
835 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, sg_phys(entry->mem.sgt->sgl), len); | 835 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, |
836 | sg_phys(entry->mem.priv.sgt->sgl), len); | ||
836 | 837 | ||
837 | return 0; | 838 | return 0; |
838 | 839 | ||
839 | err_sg_table: | 840 | err_sg_table: |
840 | nvgpu_kfree(vm->mm->g, entry->mem.sgt); | 841 | nvgpu_kfree(vm->mm->g, entry->mem.priv.sgt); |
841 | err_alloced: | 842 | err_alloced: |
842 | __free_pages(pages, order); | 843 | __free_pages(pages, order); |
843 | err_out: | 844 | err_out: |
@@ -854,9 +855,9 @@ static void free_gmmu_phys_pages(struct vm_gk20a *vm, | |||
854 | free_pages((unsigned long)entry->mem.cpu_va, get_order(entry->mem.size)); | 855 | free_pages((unsigned long)entry->mem.cpu_va, get_order(entry->mem.size)); |
855 | entry->mem.cpu_va = NULL; | 856 | entry->mem.cpu_va = NULL; |
856 | 857 | ||
857 | sg_free_table(entry->mem.sgt); | 858 | sg_free_table(entry->mem.priv.sgt); |
858 | nvgpu_kfree(vm->mm->g, entry->mem.sgt); | 859 | nvgpu_kfree(vm->mm->g, entry->mem.priv.sgt); |
859 | entry->mem.sgt = NULL; | 860 | entry->mem.priv.sgt = NULL; |
860 | entry->mem.size = 0; | 861 | entry->mem.size = 0; |
861 | entry->mem.aperture = APERTURE_INVALID; | 862 | entry->mem.aperture = APERTURE_INVALID; |
862 | } | 863 | } |
@@ -864,16 +865,16 @@ static void free_gmmu_phys_pages(struct vm_gk20a *vm, | |||
864 | static int map_gmmu_phys_pages(struct gk20a_mm_entry *entry) | 865 | static int map_gmmu_phys_pages(struct gk20a_mm_entry *entry) |
865 | { | 866 | { |
866 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, | 867 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, |
867 | sg_phys(entry->mem.sgt->sgl), | 868 | sg_phys(entry->mem.priv.sgt->sgl), |
868 | entry->mem.sgt->sgl->length); | 869 | entry->mem.priv.sgt->sgl->length); |
869 | return 0; | 870 | return 0; |
870 | } | 871 | } |
871 | 872 | ||
872 | static void unmap_gmmu_phys_pages(struct gk20a_mm_entry *entry) | 873 | static void unmap_gmmu_phys_pages(struct gk20a_mm_entry *entry) |
873 | { | 874 | { |
874 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, | 875 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, |
875 | sg_phys(entry->mem.sgt->sgl), | 876 | sg_phys(entry->mem.priv.sgt->sgl), |
876 | entry->mem.sgt->sgl->length); | 877 | entry->mem.priv.sgt->sgl->length); |
877 | } | 878 | } |
878 | 879 | ||
879 | static int alloc_gmmu_pages(struct vm_gk20a *vm, u32 order, | 880 | static int alloc_gmmu_pages(struct vm_gk20a *vm, u32 order, |
@@ -941,7 +942,7 @@ int map_gmmu_pages(struct gk20a *g, struct gk20a_mm_entry *entry) | |||
941 | return 0; | 942 | return 0; |
942 | 943 | ||
943 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, | 944 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, |
944 | sg_phys(entry->mem.sgt->sgl), | 945 | sg_phys(entry->mem.priv.sgt->sgl), |
945 | entry->mem.size); | 946 | entry->mem.size); |
946 | } else { | 947 | } else { |
947 | int err = nvgpu_mem_begin(g, &entry->mem); | 948 | int err = nvgpu_mem_begin(g, &entry->mem); |
@@ -967,7 +968,7 @@ void unmap_gmmu_pages(struct gk20a *g, struct gk20a_mm_entry *entry) | |||
967 | return; | 968 | return; |
968 | 969 | ||
969 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, | 970 | FLUSH_CPU_DCACHE(entry->mem.cpu_va, |
970 | sg_phys(entry->mem.sgt->sgl), | 971 | sg_phys(entry->mem.priv.sgt->sgl), |
971 | entry->mem.size); | 972 | entry->mem.size); |
972 | } else { | 973 | } else { |
973 | nvgpu_mem_end(g, &entry->mem); | 974 | nvgpu_mem_end(g, &entry->mem); |
@@ -1028,9 +1029,9 @@ static int gk20a_zalloc_gmmu_page_table(struct vm_gk20a *vm, | |||
1028 | 1029 | ||
1029 | gk20a_dbg(gpu_dbg_pte, "entry = 0x%p, addr=%08llx, size %d, woff %x", | 1030 | gk20a_dbg(gpu_dbg_pte, "entry = 0x%p, addr=%08llx, size %d, woff %x", |
1030 | entry, | 1031 | entry, |
1031 | (entry->mem.sgt && entry->mem.aperture == APERTURE_SYSMEM) ? | 1032 | (entry->mem.priv.sgt && |
1032 | g->ops.mm.get_iova_addr(g, entry->mem.sgt->sgl, 0) | 1033 | entry->mem.aperture == APERTURE_SYSMEM) ? |
1033 | : 0, | 1034 | g->ops.mm.get_iova_addr(g, entry->mem.priv.sgt->sgl, 0) : 0, |
1034 | order, entry->woffset); | 1035 | order, entry->woffset); |
1035 | if (err) | 1036 | if (err) |
1036 | return err; | 1037 | return err; |
@@ -1726,7 +1727,7 @@ static struct sg_table *gk20a_vidbuf_map_dma_buf( | |||
1726 | { | 1727 | { |
1727 | struct gk20a_vidmem_buf *buf = attach->dmabuf->priv; | 1728 | struct gk20a_vidmem_buf *buf = attach->dmabuf->priv; |
1728 | 1729 | ||
1729 | return buf->mem->sgt; | 1730 | return buf->mem->priv.sgt; |
1730 | } | 1731 | } |
1731 | 1732 | ||
1732 | static void gk20a_vidbuf_unmap_dma_buf(struct dma_buf_attachment *attach, | 1733 | static void gk20a_vidbuf_unmap_dma_buf(struct dma_buf_attachment *attach, |
@@ -2398,7 +2399,7 @@ int gk20a_vm_map_compbits(struct vm_gk20a *vm, | |||
2398 | g->ops.mm.gmmu_map( | 2399 | g->ops.mm.gmmu_map( |
2399 | vm, | 2400 | vm, |
2400 | !fixed_mapping ? 0 : *compbits_win_gva, /* va */ | 2401 | !fixed_mapping ? 0 : *compbits_win_gva, /* va */ |
2401 | g->gr.compbit_store.mem.sgt, | 2402 | g->gr.compbit_store.mem.priv.sgt, |
2402 | cacheline_offset_start, /* sg offset */ | 2403 | cacheline_offset_start, /* sg offset */ |
2403 | mapped_buffer->ctag_map_win_size, /* size */ | 2404 | mapped_buffer->ctag_map_win_size, /* size */ |
2404 | small_pgsz_index, | 2405 | small_pgsz_index, |
@@ -2518,7 +2519,7 @@ static int gk20a_gmmu_clear_vidmem_mem(struct gk20a *g, struct nvgpu_mem *mem) | |||
2518 | if (g->mm.vidmem.ce_ctx_id == (u32)~0) | 2519 | if (g->mm.vidmem.ce_ctx_id == (u32)~0) |
2519 | return -EINVAL; | 2520 | return -EINVAL; |
2520 | 2521 | ||
2521 | alloc = get_vidmem_page_alloc(mem->sgt->sgl); | 2522 | alloc = get_vidmem_page_alloc(mem->priv.sgt->sgl); |
2522 | 2523 | ||
2523 | nvgpu_list_for_each_entry(chunk, &alloc->alloc_chunks, | 2524 | nvgpu_list_for_each_entry(chunk, &alloc->alloc_chunks, |
2524 | page_alloc_chunk, list_entry) { | 2525 | page_alloc_chunk, list_entry) { |
@@ -2580,14 +2581,14 @@ u64 gk20a_mem_get_base_addr(struct gk20a *g, struct nvgpu_mem *mem, | |||
2580 | u64 addr; | 2581 | u64 addr; |
2581 | 2582 | ||
2582 | if (mem->aperture == APERTURE_VIDMEM) { | 2583 | if (mem->aperture == APERTURE_VIDMEM) { |
2583 | alloc = get_vidmem_page_alloc(mem->sgt->sgl); | 2584 | alloc = get_vidmem_page_alloc(mem->priv.sgt->sgl); |
2584 | 2585 | ||
2585 | /* This API should not be used with > 1 chunks */ | 2586 | /* This API should not be used with > 1 chunks */ |
2586 | WARN_ON(alloc->nr_chunks != 1); | 2587 | WARN_ON(alloc->nr_chunks != 1); |
2587 | 2588 | ||
2588 | addr = alloc->base; | 2589 | addr = alloc->base; |
2589 | } else { | 2590 | } else { |
2590 | addr = g->ops.mm.get_iova_addr(g, mem->sgt->sgl, flags); | 2591 | addr = g->ops.mm.get_iova_addr(g, mem->priv.sgt->sgl, flags); |
2591 | } | 2592 | } |
2592 | 2593 | ||
2593 | return addr; | 2594 | return addr; |
@@ -2619,8 +2620,8 @@ static void gk20a_vidmem_clear_mem_worker(struct work_struct *work) | |||
2619 | while ((mem = get_pending_mem_desc(mm)) != NULL) { | 2620 | while ((mem = get_pending_mem_desc(mm)) != NULL) { |
2620 | gk20a_gmmu_clear_vidmem_mem(g, mem); | 2621 | gk20a_gmmu_clear_vidmem_mem(g, mem); |
2621 | nvgpu_free(mem->allocator, | 2622 | nvgpu_free(mem->allocator, |
2622 | (u64)get_vidmem_page_alloc(mem->sgt->sgl)); | 2623 | (u64)get_vidmem_page_alloc(mem->priv.sgt->sgl)); |
2623 | gk20a_free_sgtable(g, &mem->sgt); | 2624 | gk20a_free_sgtable(g, &mem->priv.sgt); |
2624 | 2625 | ||
2625 | WARN_ON(atomic64_sub_return(mem->size, | 2626 | WARN_ON(atomic64_sub_return(mem->size, |
2626 | &g->mm.vidmem.bytes_pending) < 0); | 2627 | &g->mm.vidmem.bytes_pending) < 0); |
@@ -2774,7 +2775,7 @@ u64 gk20a_pde_addr(struct gk20a *g, struct gk20a_mm_entry *entry) | |||
2774 | u64 base; | 2775 | u64 base; |
2775 | 2776 | ||
2776 | if (g->mm.has_physical_mode) | 2777 | if (g->mm.has_physical_mode) |
2777 | base = sg_phys(entry->mem.sgt->sgl); | 2778 | base = sg_phys(entry->mem.priv.sgt->sgl); |
2778 | else | 2779 | else |
2779 | base = gk20a_mem_get_base_addr(g, &entry->mem, 0); | 2780 | base = gk20a_mem_get_base_addr(g, &entry->mem, 0); |
2780 | 2781 | ||