diff options
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 15 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/vm.h | 14 |
2 files changed, 27 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index ee9d2e0b..e90437a3 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -109,6 +109,11 @@ u64 __nvgpu_vm_alloc_va(struct vm_gk20a *vm, u64 size, | |||
109 | 109 | ||
110 | vma = vm->vma[pgsz_idx]; | 110 | vma = vm->vma[pgsz_idx]; |
111 | 111 | ||
112 | if (vm->guest_managed) { | ||
113 | nvgpu_err(g, "Illegal GPU allocation on behalf of guest OS"); | ||
114 | return 0; | ||
115 | } | ||
116 | |||
112 | if (pgsz_idx >= gmmu_nr_page_sizes) { | 117 | if (pgsz_idx >= gmmu_nr_page_sizes) { |
113 | nvgpu_err(g, "(%s) invalid page size requested", vma->name); | 118 | nvgpu_err(g, "(%s) invalid page size requested", vma->name); |
114 | return 0; | 119 | return 0; |
@@ -237,7 +242,10 @@ static int nvgpu_init_sema_pool(struct vm_gk20a *vm) | |||
237 | return 0; | 242 | return 0; |
238 | } | 243 | } |
239 | 244 | ||
240 | static int __nvgpu_vm_init(struct mm_gk20a *mm, | 245 | /* |
246 | * Initialize a preallocated vm | ||
247 | */ | ||
248 | int __nvgpu_vm_init(struct mm_gk20a *mm, | ||
241 | struct vm_gk20a *vm, | 249 | struct vm_gk20a *vm, |
242 | u32 big_page_size, | 250 | u32 big_page_size, |
243 | u64 low_hole, | 251 | u64 low_hole, |
@@ -258,6 +266,9 @@ static int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
258 | if (WARN_ON(kernel_reserved + low_hole > aperture_size)) | 266 | if (WARN_ON(kernel_reserved + low_hole > aperture_size)) |
259 | return -ENOMEM; | 267 | return -ENOMEM; |
260 | 268 | ||
269 | if (WARN_ON(vm->guest_managed && kernel_reserved != 0)) | ||
270 | return -EINVAL; | ||
271 | |||
261 | nvgpu_log_info(g, "Init space for %s: valimit=0x%llx, " | 272 | nvgpu_log_info(g, "Init space for %s: valimit=0x%llx, " |
262 | "LP size=0x%x lowhole=0x%llx", | 273 | "LP size=0x%x lowhole=0x%llx", |
263 | name, aperture_size, | 274 | name, aperture_size, |
@@ -337,7 +348,7 @@ static int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
337 | 348 | ||
338 | if (WARN_ON(user_vma_start > user_vma_limit) || | 349 | if (WARN_ON(user_vma_start > user_vma_limit) || |
339 | WARN_ON(user_lp_vma_start > user_lp_vma_limit) || | 350 | WARN_ON(user_lp_vma_start > user_lp_vma_limit) || |
340 | WARN_ON(kernel_vma_start >= kernel_vma_limit)) { | 351 | WARN_ON(!vm->guest_managed && kernel_vma_start >= kernel_vma_limit)) { |
341 | err = -EINVAL; | 352 | err = -EINVAL; |
342 | goto clean_up_page_tables; | 353 | goto clean_up_page_tables; |
343 | } | 354 | } |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index e091f181..1689444c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h | |||
@@ -150,6 +150,7 @@ struct vm_gk20a { | |||
150 | 150 | ||
151 | bool big_pages; /* enable large page support */ | 151 | bool big_pages; /* enable large page support */ |
152 | bool enable_ctag; | 152 | bool enable_ctag; |
153 | bool guest_managed; /* whether the vm addr space is managed by guest */ | ||
153 | 154 | ||
154 | u32 big_page_size; | 155 | u32 big_page_size; |
155 | 156 | ||
@@ -284,6 +285,19 @@ int nvgpu_insert_mapped_buf(struct vm_gk20a *vm, | |||
284 | void nvgpu_remove_mapped_buf(struct vm_gk20a *vm, | 285 | void nvgpu_remove_mapped_buf(struct vm_gk20a *vm, |
285 | struct nvgpu_mapped_buf *mapped_buffer); | 286 | struct nvgpu_mapped_buf *mapped_buffer); |
286 | 287 | ||
288 | /* | ||
289 | * Initialize a preallocated vm | ||
290 | */ | ||
291 | int __nvgpu_vm_init(struct mm_gk20a *mm, | ||
292 | struct vm_gk20a *vm, | ||
293 | u32 big_page_size, | ||
294 | u64 low_hole, | ||
295 | u64 kernel_reserved, | ||
296 | u64 aperture_size, | ||
297 | bool big_pages, | ||
298 | bool userspace_managed, | ||
299 | char *name); | ||
300 | |||
287 | struct vm_gk20a *nvgpu_vm_init(struct gk20a *g, | 301 | struct vm_gk20a *nvgpu_vm_init(struct gk20a *g, |
288 | u32 big_page_size, | 302 | u32 big_page_size, |
289 | u64 low_hole, | 303 | u64 low_hole, |