diff options
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/cde.c | 8 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_as.c | 18 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vgpu/mm_vgpu.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vm.c | 44 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/gmmu.c | 8 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/gmmu_t19x.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 27 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm_area.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 8 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gp10b/gr_gp10b.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gv11b/gr_gv11b.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/vm.h | 12 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/vm_area.h | 6 |
14 files changed, 102 insertions, 49 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c index 143e5b75..c4f678b6 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.c +++ b/drivers/gpu/nvgpu/common/linux/cde.c | |||
@@ -1052,9 +1052,9 @@ __releases(&l->cde_app->mutex) | |||
1052 | /* map the destination buffer */ | 1052 | /* map the destination buffer */ |
1053 | get_dma_buf(compbits_scatter_buf); /* a ref for nvgpu_vm_map_linux */ | 1053 | get_dma_buf(compbits_scatter_buf); /* a ref for nvgpu_vm_map_linux */ |
1054 | err = nvgpu_vm_map_linux(cde_ctx->vm, compbits_scatter_buf, 0, | 1054 | err = nvgpu_vm_map_linux(cde_ctx->vm, compbits_scatter_buf, 0, |
1055 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE | | 1055 | NVGPU_VM_MAP_CACHEABLE | |
1056 | NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL, | 1056 | NVGPU_VM_MAP_DIRECT_KIND_CTRL, |
1057 | NV_KIND_INVALID, | 1057 | NVGPU_KIND_INVALID, |
1058 | compbits_kind, /* incompressible kind */ | 1058 | compbits_kind, /* incompressible kind */ |
1059 | gk20a_mem_flag_none, | 1059 | gk20a_mem_flag_none, |
1060 | map_offset, map_size, | 1060 | map_offset, map_size, |
@@ -1284,7 +1284,7 @@ static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx) | |||
1284 | /* map backing store to gpu virtual space */ | 1284 | /* map backing store to gpu virtual space */ |
1285 | vaddr = nvgpu_gmmu_map(ch->vm, &gr->compbit_store.mem, | 1285 | vaddr = nvgpu_gmmu_map(ch->vm, &gr->compbit_store.mem, |
1286 | g->gr.compbit_store.mem.size, | 1286 | g->gr.compbit_store.mem.size, |
1287 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 1287 | NVGPU_VM_MAP_CACHEABLE, |
1288 | gk20a_mem_flag_read_only, | 1288 | gk20a_mem_flag_read_only, |
1289 | false, | 1289 | false, |
1290 | gr->compbit_store.mem.aperture); | 1290 | gr->compbit_store.mem.aperture); |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_as.c b/drivers/gpu/nvgpu/common/linux/ioctl_as.c index 848fee04..8aea3d22 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_as.c | |||
@@ -32,6 +32,18 @@ | |||
32 | #include "ioctl_as.h" | 32 | #include "ioctl_as.h" |
33 | #include "os_linux.h" | 33 | #include "os_linux.h" |
34 | 34 | ||
35 | static u32 gk20a_as_translate_linux_flags(struct gk20a *g, u32 flags) | ||
36 | { | ||
37 | u32 core_flags = 0; | ||
38 | |||
39 | if (flags & NVGPU_AS_ALLOC_SPACE_FLAGS_FIXED_OFFSET) | ||
40 | core_flags |= NVGPU_VM_AREA_ALLOC_FIXED_OFFSET; | ||
41 | if (flags & NVGPU_AS_ALLOC_SPACE_FLAGS_SPARSE) | ||
42 | core_flags |= NVGPU_VM_AREA_ALLOC_SPARSE; | ||
43 | |||
44 | return core_flags; | ||
45 | } | ||
46 | |||
35 | static int gk20a_as_ioctl_bind_channel( | 47 | static int gk20a_as_ioctl_bind_channel( |
36 | struct gk20a_as_share *as_share, | 48 | struct gk20a_as_share *as_share, |
37 | struct nvgpu_as_bind_channel_args *args) | 49 | struct nvgpu_as_bind_channel_args *args) |
@@ -62,9 +74,13 @@ static int gk20a_as_ioctl_alloc_space( | |||
62 | struct gk20a_as_share *as_share, | 74 | struct gk20a_as_share *as_share, |
63 | struct nvgpu_as_alloc_space_args *args) | 75 | struct nvgpu_as_alloc_space_args *args) |
64 | { | 76 | { |
77 | struct gk20a *g = gk20a_from_vm(as_share->vm); | ||
78 | |||
65 | gk20a_dbg_fn(""); | 79 | gk20a_dbg_fn(""); |
66 | return nvgpu_vm_area_alloc(as_share->vm, args->pages, args->page_size, | 80 | return nvgpu_vm_area_alloc(as_share->vm, args->pages, args->page_size, |
67 | &args->o_a.offset, args->flags); | 81 | &args->o_a.offset, |
82 | gk20a_as_translate_linux_flags(g, | ||
83 | args->flags)); | ||
68 | } | 84 | } |
69 | 85 | ||
70 | static int gk20a_as_ioctl_free_space( | 86 | static int gk20a_as_ioctl_free_space( |
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c index 9eb140a3..8c5a6d27 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_mm_gp10b.c | |||
@@ -165,7 +165,7 @@ u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, | |||
165 | p->pgsz_idx = pgsz_idx; | 165 | p->pgsz_idx = pgsz_idx; |
166 | p->iova = 0; | 166 | p->iova = 0; |
167 | p->kind = kind_v; | 167 | p->kind = kind_v; |
168 | p->cacheable = (flags & NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE) ? 1 : 0; | 168 | p->cacheable = (flags & NVGPU_VM_MAP_CACHEABLE) ? 1 : 0; |
169 | p->prot = prot; | 169 | p->prot = prot; |
170 | p->ctag_offset = ctag_offset; | 170 | p->ctag_offset = ctag_offset; |
171 | p->clear_ctags = clear_ctags; | 171 | p->clear_ctags = clear_ctags; |
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/mm_vgpu.c b/drivers/gpu/nvgpu/common/linux/vgpu/mm_vgpu.c index f8c5c406..bc0fe575 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/mm_vgpu.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/mm_vgpu.c | |||
@@ -148,7 +148,7 @@ u64 vgpu_locked_gmmu_map(struct vm_gk20a *vm, | |||
148 | p->pgsz_idx = pgsz_idx; | 148 | p->pgsz_idx = pgsz_idx; |
149 | p->iova = mapping ? 1 : 0; | 149 | p->iova = mapping ? 1 : 0; |
150 | p->kind = kind_v; | 150 | p->kind = kind_v; |
151 | p->cacheable = (flags & NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE) ? 1 : 0; | 151 | p->cacheable = (flags & NVGPU_VM_MAP_CACHEABLE) ? 1 : 0; |
152 | p->prot = prot; | 152 | p->prot = prot; |
153 | p->ctag_offset = ctag_offset; | 153 | p->ctag_offset = ctag_offset; |
154 | p->clear_ctags = clear_ctags; | 154 | p->clear_ctags = clear_ctags; |
diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index 8e464627..4529a322 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.c | |||
@@ -37,6 +37,30 @@ | |||
37 | #include "os_linux.h" | 37 | #include "os_linux.h" |
38 | #include "dmabuf.h" | 38 | #include "dmabuf.h" |
39 | 39 | ||
40 | static u32 nvgpu_vm_translate_linux_flags(struct gk20a *g, u32 flags) | ||
41 | { | ||
42 | u32 core_flags = 0; | ||
43 | |||
44 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) | ||
45 | core_flags |= NVGPU_VM_MAP_FIXED_OFFSET; | ||
46 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE) | ||
47 | core_flags |= NVGPU_VM_MAP_CACHEABLE; | ||
48 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_IO_COHERENT) | ||
49 | core_flags |= NVGPU_VM_MAP_IO_COHERENT; | ||
50 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_UNMAPPED_PTE) | ||
51 | core_flags |= NVGPU_VM_MAP_UNMAPPED_PTE; | ||
52 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_L3_ALLOC) | ||
53 | core_flags |= NVGPU_VM_MAP_L3_ALLOC; | ||
54 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL) | ||
55 | core_flags |= NVGPU_VM_MAP_DIRECT_KIND_CTRL; | ||
56 | |||
57 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_MAPPABLE_COMPBITS) | ||
58 | nvgpu_warn(g, "Ignoring deprecated flag: " | ||
59 | "NVGPU_AS_MAP_BUFFER_FLAGS_MAPPABLE_COMPBITS"); | ||
60 | |||
61 | return core_flags; | ||
62 | } | ||
63 | |||
40 | static struct nvgpu_mapped_buf *__nvgpu_vm_find_mapped_buf_reverse( | 64 | static struct nvgpu_mapped_buf *__nvgpu_vm_find_mapped_buf_reverse( |
41 | struct vm_gk20a *vm, struct dma_buf *dmabuf, u32 kind) | 65 | struct vm_gk20a *vm, struct dma_buf *dmabuf, u32 kind) |
42 | { | 66 | { |
@@ -102,7 +126,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm, | |||
102 | struct gk20a *g = gk20a_from_vm(vm); | 126 | struct gk20a *g = gk20a_from_vm(vm); |
103 | struct nvgpu_mapped_buf *mapped_buffer = NULL; | 127 | struct nvgpu_mapped_buf *mapped_buffer = NULL; |
104 | 128 | ||
105 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { | 129 | if (flags & NVGPU_VM_MAP_FIXED_OFFSET) { |
106 | mapped_buffer = __nvgpu_vm_find_mapped_buf(vm, map_addr); | 130 | mapped_buffer = __nvgpu_vm_find_mapped_buf(vm, map_addr); |
107 | if (!mapped_buffer) | 131 | if (!mapped_buffer) |
108 | return NULL; | 132 | return NULL; |
@@ -167,7 +191,7 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm, | |||
167 | u64 map_addr = 0ULL; | 191 | u64 map_addr = 0ULL; |
168 | int err = 0; | 192 | int err = 0; |
169 | 193 | ||
170 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) | 194 | if (flags & NVGPU_VM_MAP_FIXED_OFFSET) |
171 | map_addr = offset_align; | 195 | map_addr = offset_align; |
172 | 196 | ||
173 | sgt = gk20a_mm_pin(dev, dmabuf); | 197 | sgt = gk20a_mm_pin(dev, dmabuf); |
@@ -229,15 +253,16 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm, | |||
229 | u64 mapping_size, | 253 | u64 mapping_size, |
230 | struct vm_gk20a_mapping_batch *batch) | 254 | struct vm_gk20a_mapping_batch *batch) |
231 | { | 255 | { |
232 | int err = 0; | 256 | struct gk20a *g = gk20a_from_vm(vm); |
233 | struct dma_buf *dmabuf; | 257 | struct dma_buf *dmabuf; |
234 | u64 ret_va; | 258 | u64 ret_va; |
259 | int err = 0; | ||
235 | 260 | ||
236 | /* get ref to the mem handle (released on unmap_locked) */ | 261 | /* get ref to the mem handle (released on unmap_locked) */ |
237 | dmabuf = dma_buf_get(dmabuf_fd); | 262 | dmabuf = dma_buf_get(dmabuf_fd); |
238 | if (IS_ERR(dmabuf)) { | 263 | if (IS_ERR(dmabuf)) { |
239 | nvgpu_warn(gk20a_from_vm(vm), "%s: fd %d is not a dmabuf", | 264 | nvgpu_warn(g, "%s: fd %d is not a dmabuf", |
240 | __func__, dmabuf_fd); | 265 | __func__, dmabuf_fd); |
241 | return PTR_ERR(dmabuf); | 266 | return PTR_ERR(dmabuf); |
242 | } | 267 | } |
243 | 268 | ||
@@ -250,9 +275,9 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm, | |||
250 | */ | 275 | */ |
251 | if ((mapping_size > dmabuf->size) || | 276 | if ((mapping_size > dmabuf->size) || |
252 | (buffer_offset > (dmabuf->size - mapping_size))) { | 277 | (buffer_offset > (dmabuf->size - mapping_size))) { |
253 | nvgpu_err(gk20a_from_vm(vm), | 278 | nvgpu_err(g, |
254 | "buf size %llx < (offset(%llx) + map_size(%llx))\n", | 279 | "buf size %llx < (offset(%llx) + map_size(%llx))\n", |
255 | (u64)dmabuf->size, buffer_offset, mapping_size); | 280 | (u64)dmabuf->size, buffer_offset, mapping_size); |
256 | return -EINVAL; | 281 | return -EINVAL; |
257 | } | 282 | } |
258 | 283 | ||
@@ -263,7 +288,8 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm, | |||
263 | } | 288 | } |
264 | 289 | ||
265 | err = nvgpu_vm_map_linux(vm, dmabuf, *offset_align, | 290 | err = nvgpu_vm_map_linux(vm, dmabuf, *offset_align, |
266 | flags, compr_kind, incompr_kind, | 291 | nvgpu_vm_translate_linux_flags(g, flags), |
292 | compr_kind, incompr_kind, | ||
267 | gk20a_mem_flag_none, | 293 | gk20a_mem_flag_none, |
268 | buffer_offset, | 294 | buffer_offset, |
269 | mapping_size, | 295 | mapping_size, |
diff --git a/drivers/gpu/nvgpu/common/mm/gmmu.c b/drivers/gpu/nvgpu/common/mm/gmmu.c index 8ad7dac7..4d622412 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu.c | |||
@@ -20,8 +20,6 @@ | |||
20 | * DEALINGS IN THE SOFTWARE. | 20 | * DEALINGS IN THE SOFTWARE. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <uapi/linux/nvgpu.h> | ||
24 | |||
25 | #include <nvgpu/log.h> | 23 | #include <nvgpu/log.h> |
26 | #include <nvgpu/list.h> | 24 | #include <nvgpu/list.h> |
27 | #include <nvgpu/dma.h> | 25 | #include <nvgpu/dma.h> |
@@ -682,12 +680,12 @@ u64 gk20a_locked_gmmu_map(struct vm_gk20a *vm, | |||
682 | .pgsz = pgsz_idx, | 680 | .pgsz = pgsz_idx, |
683 | .kind_v = kind_v, | 681 | .kind_v = kind_v, |
684 | .ctag = (u64)ctag_offset * (u64)ctag_granularity, | 682 | .ctag = (u64)ctag_offset * (u64)ctag_granularity, |
685 | .cacheable = flags & NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 683 | .cacheable = flags & NVGPU_VM_MAP_CACHEABLE, |
686 | .rw_flag = rw_flag, | 684 | .rw_flag = rw_flag, |
687 | .sparse = sparse, | 685 | .sparse = sparse, |
688 | .priv = priv, | 686 | .priv = priv, |
689 | .coherent = flags & NVGPU_AS_MAP_BUFFER_FLAGS_IO_COHERENT, | 687 | .coherent = flags & NVGPU_VM_MAP_IO_COHERENT, |
690 | .valid = !(flags & NVGPU_AS_MAP_BUFFER_FLAGS_UNMAPPED_PTE), | 688 | .valid = !(flags & NVGPU_VM_MAP_UNMAPPED_PTE), |
691 | .aperture = aperture | 689 | .aperture = aperture |
692 | }; | 690 | }; |
693 | 691 | ||
diff --git a/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c b/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c index 9f9c188d..f2386b3f 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu_t19x.c | |||
@@ -20,12 +20,10 @@ | |||
20 | * DEALINGS IN THE SOFTWARE. | 20 | * DEALINGS IN THE SOFTWARE. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <uapi/linux/nvgpu.h> | ||
24 | |||
25 | #include <nvgpu/gmmu.h> | 23 | #include <nvgpu/gmmu.h> |
24 | #include <nvgpu/vm.h> | ||
26 | 25 | ||
27 | void nvgpu_gmmu_add_t19x_attrs(struct nvgpu_gmmu_attrs *attrs, u32 flags) | 26 | void nvgpu_gmmu_add_t19x_attrs(struct nvgpu_gmmu_attrs *attrs, u32 flags) |
28 | { | 27 | { |
29 | attrs->t19x_attrs.l3_alloc = (bool)(flags & | 28 | attrs->t19x_attrs.l3_alloc = (bool)(flags & NVGPU_VM_MAP_L3_ALLOC); |
30 | NVGPU_AS_MAP_BUFFER_FLAGS_L3_ALLOC); | ||
31 | } | 29 | } |
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index ebe8e381..637632e0 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -21,8 +21,6 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <nvgpu/bug.h> | 23 | #include <nvgpu/bug.h> |
24 | #include <uapi/linux/nvgpu.h> | ||
25 | |||
26 | #include <nvgpu/log.h> | 24 | #include <nvgpu/log.h> |
27 | #include <nvgpu/dma.h> | 25 | #include <nvgpu/dma.h> |
28 | #include <nvgpu/vm.h> | 26 | #include <nvgpu/vm.h> |
@@ -765,7 +763,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
765 | u8 pte_kind; | 763 | u8 pte_kind; |
766 | 764 | ||
767 | if (vm->userspace_managed && | 765 | if (vm->userspace_managed && |
768 | !(flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET)) { | 766 | !(flags & NVGPU_VM_MAP_FIXED_OFFSET)) { |
769 | nvgpu_err(g, | 767 | nvgpu_err(g, |
770 | "non-fixed-offset mapping not available on " | 768 | "non-fixed-offset mapping not available on " |
771 | "userspace managed address spaces"); | 769 | "userspace managed address spaces"); |
@@ -774,11 +772,12 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
774 | 772 | ||
775 | binfo.flags = flags; | 773 | binfo.flags = flags; |
776 | binfo.size = nvgpu_os_buf_get_size(os_buf); | 774 | binfo.size = nvgpu_os_buf_get_size(os_buf); |
777 | binfo.compr_kind = (vm->enable_ctag && compr_kind != NV_KIND_INVALID ? | 775 | binfo.compr_kind = |
778 | compr_kind : NV_KIND_INVALID); | 776 | (vm->enable_ctag && compr_kind != NVGPU_KIND_INVALID ? |
777 | compr_kind : NVGPU_KIND_INVALID); | ||
779 | binfo.incompr_kind = incompr_kind; | 778 | binfo.incompr_kind = incompr_kind; |
780 | 779 | ||
781 | if (compr_kind != NV_KIND_INVALID) | 780 | if (compr_kind != NVGPU_KIND_INVALID) |
782 | map_key_kind = compr_kind; | 781 | map_key_kind = compr_kind; |
783 | else | 782 | else |
784 | map_key_kind = incompr_kind; | 783 | map_key_kind = incompr_kind; |
@@ -830,7 +829,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
830 | /* | 829 | /* |
831 | * Check if we should use a fixed offset for mapping this buffer. | 830 | * Check if we should use a fixed offset for mapping this buffer. |
832 | */ | 831 | */ |
833 | if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { | 832 | if (flags & NVGPU_VM_MAP_FIXED_OFFSET) { |
834 | err = nvgpu_vm_area_validate_buffer(vm, | 833 | err = nvgpu_vm_area_validate_buffer(vm, |
835 | map_addr, | 834 | map_addr, |
836 | map_size, | 835 | map_size, |
@@ -848,7 +847,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
848 | goto clean_up; | 847 | goto clean_up; |
849 | } | 848 | } |
850 | 849 | ||
851 | if (binfo.compr_kind != NV_KIND_INVALID) { | 850 | if (binfo.compr_kind != NVGPU_KIND_INVALID) { |
852 | struct gk20a_comptags comptags = { 0 }; | 851 | struct gk20a_comptags comptags = { 0 }; |
853 | 852 | ||
854 | /* | 853 | /* |
@@ -903,14 +902,14 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
903 | /* | 902 | /* |
904 | * Figure out the kind and ctag offset for the GMMU page tables | 903 | * Figure out the kind and ctag offset for the GMMU page tables |
905 | */ | 904 | */ |
906 | if (binfo.compr_kind != NV_KIND_INVALID && ctag_offset) { | 905 | if (binfo.compr_kind != NVGPU_KIND_INVALID && ctag_offset) { |
907 | /* | 906 | /* |
908 | * Adjust the ctag_offset as per the buffer map offset | 907 | * Adjust the ctag_offset as per the buffer map offset |
909 | */ | 908 | */ |
910 | ctag_offset += phys_offset >> | 909 | ctag_offset += phys_offset >> |
911 | ilog2(g->ops.fb.compression_page_size(g)); | 910 | ilog2(g->ops.fb.compression_page_size(g)); |
912 | pte_kind = binfo.compr_kind; | 911 | pte_kind = binfo.compr_kind; |
913 | } else if (binfo.incompr_kind != NV_KIND_INVALID) { | 912 | } else if (binfo.incompr_kind != NVGPU_KIND_INVALID) { |
914 | /* | 913 | /* |
915 | * Incompressible kind, ctag offset will not be programmed | 914 | * Incompressible kind, ctag offset will not be programmed |
916 | */ | 915 | */ |
@@ -1093,7 +1092,7 @@ void nvgpu_vm_unmap(struct vm_gk20a *vm, u64 offset, | |||
1093 | if (!mapped_buffer) | 1092 | if (!mapped_buffer) |
1094 | goto done; | 1093 | goto done; |
1095 | 1094 | ||
1096 | if (mapped_buffer->flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { | 1095 | if (mapped_buffer->flags & NVGPU_VM_MAP_FIXED_OFFSET) { |
1097 | if (nvgpu_vm_unmap_sync_buffer(vm, mapped_buffer)) | 1096 | if (nvgpu_vm_unmap_sync_buffer(vm, mapped_buffer)) |
1098 | /* | 1097 | /* |
1099 | * Looks like we have failed... Better not continue in | 1098 | * Looks like we have failed... Better not continue in |
@@ -1118,7 +1117,7 @@ done: | |||
1118 | static int nvgpu_vm_compute_compression(struct vm_gk20a *vm, | 1117 | static int nvgpu_vm_compute_compression(struct vm_gk20a *vm, |
1119 | struct nvgpu_ctag_buffer_info *binfo) | 1118 | struct nvgpu_ctag_buffer_info *binfo) |
1120 | { | 1119 | { |
1121 | bool kind_compressible = (binfo->compr_kind != NV_KIND_INVALID); | 1120 | bool kind_compressible = (binfo->compr_kind != NVGPU_KIND_INVALID); |
1122 | struct gk20a *g = gk20a_from_vm(vm); | 1121 | struct gk20a *g = gk20a_from_vm(vm); |
1123 | 1122 | ||
1124 | if (kind_compressible && | 1123 | if (kind_compressible && |
@@ -1127,7 +1126,7 @@ static int nvgpu_vm_compute_compression(struct vm_gk20a *vm, | |||
1127 | /* | 1126 | /* |
1128 | * Let's double check that there is a fallback kind | 1127 | * Let's double check that there is a fallback kind |
1129 | */ | 1128 | */ |
1130 | if (binfo->incompr_kind == NV_KIND_INVALID) { | 1129 | if (binfo->incompr_kind == NVGPU_KIND_INVALID) { |
1131 | nvgpu_err(g, | 1130 | nvgpu_err(g, |
1132 | "Unsupported page size for compressible " | 1131 | "Unsupported page size for compressible " |
1133 | "kind, but no fallback kind"); | 1132 | "kind, but no fallback kind"); |
@@ -1136,7 +1135,7 @@ static int nvgpu_vm_compute_compression(struct vm_gk20a *vm, | |||
1136 | nvgpu_log(g, gpu_dbg_map, | 1135 | nvgpu_log(g, gpu_dbg_map, |
1137 | "Unsupported page size for compressible " | 1136 | "Unsupported page size for compressible " |
1138 | "kind, demoting to incompressible"); | 1137 | "kind, demoting to incompressible"); |
1139 | binfo->compr_kind = NV_KIND_INVALID; | 1138 | binfo->compr_kind = NVGPU_KIND_INVALID; |
1140 | kind_compressible = false; | 1139 | kind_compressible = false; |
1141 | } | 1140 | } |
1142 | } | 1141 | } |
diff --git a/drivers/gpu/nvgpu/common/mm/vm_area.c b/drivers/gpu/nvgpu/common/mm/vm_area.c index b6286c43..5ed2626f 100644 --- a/drivers/gpu/nvgpu/common/mm/vm_area.c +++ b/drivers/gpu/nvgpu/common/mm/vm_area.c | |||
@@ -20,8 +20,6 @@ | |||
20 | * DEALINGS IN THE SOFTWARE. | 20 | * DEALINGS IN THE SOFTWARE. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <uapi/linux/nvgpu.h> | ||
24 | |||
25 | #include <nvgpu/vm.h> | 23 | #include <nvgpu/vm.h> |
26 | #include <nvgpu/vm_area.h> | 24 | #include <nvgpu/vm_area.h> |
27 | 25 | ||
@@ -121,7 +119,7 @@ int nvgpu_vm_area_alloc(struct vm_gk20a *vm, u32 pages, u32 page_size, | |||
121 | goto clean_up_err; | 119 | goto clean_up_err; |
122 | 120 | ||
123 | vma = vm->vma[pgsz_idx]; | 121 | vma = vm->vma[pgsz_idx]; |
124 | if (flags & NVGPU_AS_ALLOC_SPACE_FLAGS_FIXED_OFFSET) | 122 | if (flags & NVGPU_VM_AREA_ALLOC_FIXED_OFFSET) |
125 | vaddr_start = nvgpu_alloc_fixed(vma, *addr, | 123 | vaddr_start = nvgpu_alloc_fixed(vma, *addr, |
126 | (u64)pages * | 124 | (u64)pages * |
127 | (u64)page_size, | 125 | (u64)page_size, |
@@ -143,7 +141,7 @@ int nvgpu_vm_area_alloc(struct vm_gk20a *vm, u32 pages, u32 page_size, | |||
143 | 141 | ||
144 | nvgpu_mutex_acquire(&vm->update_gmmu_lock); | 142 | nvgpu_mutex_acquire(&vm->update_gmmu_lock); |
145 | 143 | ||
146 | if (flags & NVGPU_AS_ALLOC_SPACE_FLAGS_SPARSE) { | 144 | if (flags & NVGPU_VM_AREA_ALLOC_SPARSE) { |
147 | u64 map_addr = g->ops.mm.gmmu_map(vm, vaddr_start, | 145 | u64 map_addr = g->ops.mm.gmmu_map(vm, vaddr_start, |
148 | NULL, | 146 | NULL, |
149 | 0, | 147 | 0, |
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index fc008169..03e1d567 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c | |||
@@ -1728,7 +1728,7 @@ int gr_gk20a_update_hwpm_ctxsw_mode(struct gk20a *g, | |||
1728 | pm_ctx->mem.gpu_va = nvgpu_gmmu_map(c->vm, | 1728 | pm_ctx->mem.gpu_va = nvgpu_gmmu_map(c->vm, |
1729 | &pm_ctx->mem, | 1729 | &pm_ctx->mem, |
1730 | pm_ctx->mem.size, | 1730 | pm_ctx->mem.size, |
1731 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 1731 | NVGPU_VM_MAP_CACHEABLE, |
1732 | gk20a_mem_flag_none, true, | 1732 | gk20a_mem_flag_none, true, |
1733 | pm_ctx->mem.aperture); | 1733 | pm_ctx->mem.aperture); |
1734 | if (!pm_ctx->mem.gpu_va) { | 1734 | if (!pm_ctx->mem.gpu_va) { |
@@ -2623,7 +2623,7 @@ static int gr_gk20a_map_global_ctx_buffers(struct gk20a *g, | |||
2623 | } | 2623 | } |
2624 | 2624 | ||
2625 | gpu_va = nvgpu_gmmu_map(ch_vm, mem, mem->size, | 2625 | gpu_va = nvgpu_gmmu_map(ch_vm, mem, mem->size, |
2626 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 2626 | NVGPU_VM_MAP_CACHEABLE, |
2627 | gk20a_mem_flag_none, true, mem->aperture); | 2627 | gk20a_mem_flag_none, true, mem->aperture); |
2628 | if (!gpu_va) | 2628 | if (!gpu_va) |
2629 | goto clean_up; | 2629 | goto clean_up; |
@@ -2641,7 +2641,7 @@ static int gr_gk20a_map_global_ctx_buffers(struct gk20a *g, | |||
2641 | } | 2641 | } |
2642 | 2642 | ||
2643 | gpu_va = nvgpu_gmmu_map(ch_vm, mem, mem->size, | 2643 | gpu_va = nvgpu_gmmu_map(ch_vm, mem, mem->size, |
2644 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 2644 | NVGPU_VM_MAP_CACHEABLE, |
2645 | gk20a_mem_flag_none, false, mem->aperture); | 2645 | gk20a_mem_flag_none, false, mem->aperture); |
2646 | if (!gpu_va) | 2646 | if (!gpu_va) |
2647 | goto clean_up; | 2647 | goto clean_up; |
@@ -2659,7 +2659,7 @@ static int gr_gk20a_map_global_ctx_buffers(struct gk20a *g, | |||
2659 | } | 2659 | } |
2660 | 2660 | ||
2661 | gpu_va = nvgpu_gmmu_map(ch_vm, mem, mem->size, | 2661 | gpu_va = nvgpu_gmmu_map(ch_vm, mem, mem->size, |
2662 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 2662 | NVGPU_VM_MAP_CACHEABLE, |
2663 | gk20a_mem_flag_none, true, mem->aperture); | 2663 | gk20a_mem_flag_none, true, mem->aperture); |
2664 | if (!gpu_va) | 2664 | if (!gpu_va) |
2665 | goto clean_up; | 2665 | goto clean_up; |
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c index 08988ac8..6ff1522b 100644 --- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c | |||
@@ -914,7 +914,7 @@ int gr_gp10b_alloc_buffer(struct vm_gk20a *vm, size_t size, | |||
914 | mem->gpu_va = nvgpu_gmmu_map(vm, | 914 | mem->gpu_va = nvgpu_gmmu_map(vm, |
915 | mem, | 915 | mem, |
916 | mem->aligned_size, | 916 | mem->aligned_size, |
917 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 917 | NVGPU_VM_MAP_CACHEABLE, |
918 | gk20a_mem_flag_none, | 918 | gk20a_mem_flag_none, |
919 | false, | 919 | false, |
920 | mem->aperture); | 920 | mem->aperture); |
diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c index 3d817d7e..68ac8f51 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c | |||
@@ -1350,7 +1350,7 @@ int gr_gv11b_alloc_buffer(struct vm_gk20a *vm, size_t size, | |||
1350 | mem->gpu_va = nvgpu_gmmu_map(vm, | 1350 | mem->gpu_va = nvgpu_gmmu_map(vm, |
1351 | mem, | 1351 | mem, |
1352 | size, | 1352 | size, |
1353 | NVGPU_AS_MAP_BUFFER_FLAGS_CACHEABLE, | 1353 | NVGPU_VM_MAP_CACHEABLE, |
1354 | gk20a_mem_flag_none, | 1354 | gk20a_mem_flag_none, |
1355 | false, | 1355 | false, |
1356 | mem->aperture); | 1356 | mem->aperture); |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index 7009ddf4..e091f181 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h | |||
@@ -199,6 +199,18 @@ struct vm_gk20a { | |||
199 | u64 syncpt_ro_map_gpu_va; | 199 | u64 syncpt_ro_map_gpu_va; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | /* | ||
203 | * Mapping flags. | ||
204 | */ | ||
205 | #define NVGPU_VM_MAP_FIXED_OFFSET (1 << 0) | ||
206 | #define NVGPU_VM_MAP_CACHEABLE (1 << 1) | ||
207 | #define NVGPU_VM_MAP_IO_COHERENT (1 << 2) | ||
208 | #define NVGPU_VM_MAP_UNMAPPED_PTE (1 << 3) | ||
209 | #define NVGPU_VM_MAP_DIRECT_KIND_CTRL (1 << 4) | ||
210 | #define NVGPU_VM_MAP_L3_ALLOC (1 << 5) | ||
211 | |||
212 | #define NVGPU_KIND_INVALID -1 | ||
213 | |||
202 | void nvgpu_vm_get(struct vm_gk20a *vm); | 214 | void nvgpu_vm_get(struct vm_gk20a *vm); |
203 | void nvgpu_vm_put(struct vm_gk20a *vm); | 215 | void nvgpu_vm_put(struct vm_gk20a *vm); |
204 | 216 | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm_area.h b/drivers/gpu/nvgpu/include/nvgpu/vm_area.h index 7fc77b29..92852633 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm_area.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm_area.h | |||
@@ -57,6 +57,12 @@ nvgpu_vm_area_from_vm_area_list(struct nvgpu_list_node *node) | |||
57 | vm_area_list)); | 57 | vm_area_list)); |
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* | ||
61 | * Alloc space flags. | ||
62 | */ | ||
63 | #define NVGPU_VM_AREA_ALLOC_FIXED_OFFSET (1 << 0) | ||
64 | #define NVGPU_VM_AREA_ALLOC_SPARSE (1 << 1) | ||
65 | |||
60 | int nvgpu_vm_area_alloc(struct vm_gk20a *vm, u32 pages, u32 page_size, | 66 | int nvgpu_vm_area_alloc(struct vm_gk20a *vm, u32 pages, u32 page_size, |
61 | u64 *addr, u32 flags); | 67 | u64 *addr, u32 flags); |
62 | int nvgpu_vm_area_free(struct vm_gk20a *vm, u64 addr); | 68 | int nvgpu_vm_area_free(struct vm_gk20a *vm, u64 addr); |