summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/mm/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/vm.c')
-rw-r--r--drivers/gpu/nvgpu/common/mm/vm.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c
index b957e755..171a67ca 100644
--- a/drivers/gpu/nvgpu/common/mm/vm.c
+++ b/drivers/gpu/nvgpu/common/mm/vm.c
@@ -24,6 +24,8 @@
24#include <nvgpu/semaphore.h> 24#include <nvgpu/semaphore.h>
25#include <nvgpu/enabled.h> 25#include <nvgpu/enabled.h>
26 26
27#include <nvgpu/vgpu/vm.h>
28
27#include "gk20a/gk20a.h" 29#include "gk20a/gk20a.h"
28#include "gk20a/mm_gk20a.h" 30#include "gk20a/mm_gk20a.h"
29 31
@@ -209,10 +211,11 @@ static int nvgpu_init_sema_pool(struct vm_gk20a *vm)
209 * @vm - The VM to init. 211 * @vm - The VM to init.
210 * @big_page_size - Size of big pages associated with this VM. 212 * @big_page_size - Size of big pages associated with this VM.
211 * @low_hole - The size of the low hole (unaddressable memory at the bottom of 213 * @low_hole - The size of the low hole (unaddressable memory at the bottom of
212 * the address space. 214 * the address space).
213 * @kernel_reserved - Space reserved for kernel only allocations. 215 * @kernel_reserved - Space reserved for kernel only allocations.
214 * @aperture_size - Total size of the aperture. 216 * @aperture_size - Total size of the aperture.
215 * @big_pages - Ignored. Will be set based on other passed params. 217 * @big_pages - If true then big pages are possible in the VM. Note this does
218 * not guarantee that big pages will be possible.
216 * @name - Name of the address space. 219 * @name - Name of the address space.
217 * 220 *
218 * This function initializes an address space according to the following map: 221 * This function initializes an address space according to the following map:
@@ -284,10 +287,21 @@ int nvgpu_init_vm(struct mm_gk20a *mm,
284 vm->userspace_managed = userspace_managed; 287 vm->userspace_managed = userspace_managed;
285 vm->mmu_levels = g->ops.mm.get_mmu_levels(g, vm->big_page_size); 288 vm->mmu_levels = g->ops.mm.get_mmu_levels(g, vm->big_page_size);
286 289
290#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION
291 if (g->is_virtual && userspace_managed) {
292 nvgpu_err(g, "vGPU: no userspace managed addr space support");
293 return -ENOSYS;
294 }
295 if (g->is_virtual && vgpu_vm_init(g, vm)) {
296 nvgpu_err(g, "Failed to init vGPU VM!");
297 return -ENOMEM;
298 }
299#endif
300
287 /* Initialize the page table data structures. */ 301 /* Initialize the page table data structures. */
288 err = nvgpu_vm_init_page_tables(vm); 302 err = nvgpu_vm_init_page_tables(vm);
289 if (err) 303 if (err)
290 return err; 304 goto clean_up_vgpu_vm;
291 305
292 /* Setup vma limits. */ 306 /* Setup vma limits. */
293 if (kernel_reserved + low_hole < aperture_size) { 307 if (kernel_reserved + low_hole < aperture_size) {
@@ -445,6 +459,11 @@ clean_up_page_tables:
445 /* Cleans up nvgpu_vm_init_page_tables() */ 459 /* Cleans up nvgpu_vm_init_page_tables() */
446 nvgpu_vfree(g, vm->pdb.entries); 460 nvgpu_vfree(g, vm->pdb.entries);
447 free_gmmu_pages(vm, &vm->pdb); 461 free_gmmu_pages(vm, &vm->pdb);
462clean_up_vgpu_vm:
463#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION
464 if (g->is_virtual)
465 vgpu_vm_remove(vm);
466#endif
448 return err; 467 return err;
449} 468}
450 469
@@ -503,7 +522,7 @@ void __nvgpu_vm_remove(struct vm_gk20a *vm)
503 522
504#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION 523#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION
505 if (g->is_virtual) 524 if (g->is_virtual)
506 nvgpu_vm_remove_vgpu(vm); 525 vgpu_vm_remove(vm);
507#endif 526#endif
508 527
509 nvgpu_mutex_release(&vm->update_gmmu_lock); 528 nvgpu_mutex_release(&vm->update_gmmu_lock);