]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau: allocate vmm object for every client
authorBen Skeggs <bskeggs@redhat.com>
Tue, 31 Oct 2017 17:56:20 +0000 (03:56 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 2 Nov 2017 03:32:32 +0000 (13:32 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_mem.h
drivers/gpu/drm/nouveau/nouveau_vmm.c
drivers/gpu/drm/nouveau/nouveau_vmm.h

index 2eddf19abb40927baf9eaceeec9ef9d2a4ca0229..a6aaddecd8c5ba61a760b8144863a96930fb7043 100644 (file)
@@ -134,6 +134,15 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
                { NVIF_CLASS_MMU_NV04 , -1 },
                {}
        };
+       static const struct nvif_mclass
+       vmms[] = {
+               { NVIF_CLASS_VMM_GP100, -1 },
+               { NVIF_CLASS_VMM_GM200, -1 },
+               { NVIF_CLASS_VMM_GF100, -1 },
+               { NVIF_CLASS_VMM_NV50 , -1 },
+               { NVIF_CLASS_VMM_NV04 , -1 },
+               {}
+       };
        u64 device = nouveau_name(drm->dev);
        int ret;
 
@@ -180,6 +189,23 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
                goto done;
        }
 
+       ret = nvif_mclass(&cli->mmu.object, vmms);
+       if (ret < 0) {
+               NV_ERROR(drm, "No supported VMM class\n");
+               goto done;
+       }
+
+       ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm);
+       if (ret) {
+               NV_ERROR(drm, "VMM allocation failed: %d\n", ret);
+               goto done;
+       }
+
+       if (1) {
+               cli->vm = cli->vmm.vm;
+               nvxx_client(&cli->base)->vm = cli->vm;
+       }
+
 done:
        if (ret)
                nouveau_cli_fini(cli);
@@ -486,20 +512,6 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 
        nouveau_vga_init(drm);
 
-       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
-               if (!nvxx_device(&drm->client.device)->mmu) {
-                       ret = -ENOSYS;
-                       goto fail_device;
-               }
-
-               ret = nouveau_vmm_init(&drm->client, 0, &drm->client.vmm);
-               if (ret)
-                       goto fail_device;
-
-               drm->client.vm = drm->client.vmm.vm;
-               nvxx_client(&drm->client.base)->vm = drm->client.vm;
-       }
-
        ret = nouveau_ttm_init(drm);
        if (ret)
                goto fail_ttm;
@@ -545,7 +557,6 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
        nouveau_ttm_fini(drm);
 fail_ttm:
        nouveau_vga_fini(drm);
-fail_device:
        nouveau_cli_fini(&drm->client);
        nouveau_cli_fini(&drm->master);
        kfree(drm);
@@ -881,15 +892,6 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
 
        cli->base.super = false;
 
-       if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
-               ret = nouveau_vmm_init(cli, 0, &cli->vmm);
-               if (ret)
-                       goto done;
-
-               cli->vm = cli->vmm.vm;
-               nvxx_client(&cli->base)->vm = cli->vm;
-       }
-
        fpriv->driver_priv = cli;
 
        mutex_lock(&drm->client.mutex);
index 6d6795b5b3efbc318357f5096fe671e77ac87543..25e0fb73747b12cdb4c763bd4867e163b9a22582 100644 (file)
@@ -43,6 +43,7 @@
 #include <nvif/device.h>
 #include <nvif/ioctl.h>
 #include <nvif/mmu.h>
+#include <nvif/vmm.h>
 
 #include <drm/drmP.h>
 
index 9f82b13293f546bafb751057c937138f5b9e1e7f..a600c4386c72b7048aa2e96e01c6fb0a2563f1d9 100644 (file)
@@ -33,6 +33,8 @@
 #include "nouveau_gem.h"
 #include "nouveau_vmm.h"
 
+#include <nvif/class.h>
+
 void
 nouveau_gem_object_del(struct drm_gem_object *gem)
 {
@@ -69,7 +71,7 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv)
        struct nouveau_vma *vma;
        int ret;
 
-       if (!cli->vm)
+       if (cli->vmm.vmm.object.oclass < NVIF_CLASS_VMM_NV50)
                return 0;
 
        ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL);
@@ -131,7 +133,7 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv)
        struct nouveau_vma *vma;
        int ret;
 
-       if (!cli->vm)
+       if (cli->vmm.vmm.object.oclass < NVIF_CLASS_VMM_NV50)
                return;
 
        ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL);
@@ -214,7 +216,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
        else
                rep->domain = NOUVEAU_GEM_DOMAIN_VRAM;
        rep->offset = nvbo->bo.offset;
-       if (cli->vm) {
+       if (cli->vmm.vmm.object.oclass >= NVIF_CLASS_VMM_NV50) {
                vma = nouveau_vma_find(nvbo, &cli->vmm);
                if (!vma)
                        return -EINVAL;
index 48388c538420e7a03bb06fddc4cac7c4c36776a0..3e34566116c461fbfc244817f66df0fe0b5a9d73 100644 (file)
@@ -29,11 +29,6 @@ struct nouveau_mem {
        struct nvkm_memory memory;
 };
 
-enum nvif_vmm_get {
-       PTES,
-       LAZY,
-};
-
 int nouveau_mem_new(struct nouveau_cli *, u8 kind, u8 comp,
                    struct ttm_mem_reg *);
 void nouveau_mem_del(struct ttm_mem_reg *);
index 6dc14f92b988274678a6c4e6b0fdb9d096f01452..656f43ad012d114c7b679fe4f8cb8edb5e1460a0 100644 (file)
@@ -114,13 +114,19 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
 void
 nouveau_vmm_fini(struct nouveau_vmm *vmm)
 {
-       nvkm_vm_ref(NULL, &vmm->vm, NULL);
+       nvif_vmm_fini(&vmm->vmm);
+       vmm->cli = NULL;
 }
 
 int
 nouveau_vmm_init(struct nouveau_cli *cli, s32 oclass, struct nouveau_vmm *vmm)
 {
+       int ret = nvif_vmm_init(&cli->mmu, oclass, PAGE_SIZE, 0, NULL, 0,
+                               &vmm->vmm);
+       if (ret)
+               return ret;
+
        vmm->cli = cli;
-       return nvkm_vm_new(nvxx_device(&cli->device), 0, (1ULL << 40),
-                          0x1000, NULL, &vmm->vm);
+       vmm->vm = nvkm_uvmm(vmm->vmm.object.priv)->vmm;
+       return 0;
 }
index 86ab599aafb20764ded8b6e801da59b7c0bdf625..c7b9c55bc53531a04d717f2b5929b79f92903f86 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __NOUVEAU_VMA_H__
 #define __NOUVEAU_VMA_H__
-#include <subdev/mmu.h>
+#include <subdev/mmu/uvmm.h>
+#include <nvif/vmm.h>
 struct nouveau_bo;
 struct nouveau_mem;
 
@@ -24,6 +25,7 @@ void nouveau_vma_unmap(struct nouveau_vma *);
 
 struct nouveau_vmm {
        struct nouveau_cli *cli;
+       struct nvif_vmm vmm;
        struct nvkm_vm *vm;
 };