drm/nouveau: pass handle of vmm object to channel allocation ioctls
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:33 +0000 (13:32 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
17 files changed:
drivers/gpu/drm/nouveau/include/nvif/cl506e.h
drivers/gpu/drm/nouveau/include/nvif/cl506f.h
drivers/gpu/drm/nouveau/include/nvif/cl826e.h
drivers/gpu/drm/nouveau/include/nvif/cl826f.h
drivers/gpu/drm/nouveau/include/nvif/cl906f.h
drivers/gpu/drm/nouveau/include/nvif/cla06f.h
drivers/gpu/drm/nouveau/nouveau_chan.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/channv50.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/channv50.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c

index aa94b8cf9679e3cb5c5dd59dcd86beac5fb1412c..f5086601100298ee3757943df6522e36f4e4e727 100644 (file)
@@ -5,7 +5,7 @@ struct nv50_channel_dma_v0 {
        __u8  version;
        __u8  chid;
        __u8  pad02[6];
-       __u64 vm;
+       __u64 vmm;
        __u64 pushbuf;
        __u64 offset;
 };
index 3b7101966de43e054fc327ba664c9900104a1ead..0e5bbb55315839b44916e70954654d63b0139a04 100644 (file)
@@ -8,6 +8,6 @@ struct nv50_channel_gpfifo_v0 {
        __u32 ilength;
        __u64 ioffset;
        __u64 pushbuf;
-       __u64 vm;
+       __u64 vmm;
 };
 #endif
index 91e33db21a2fe47178781469929675cc91cda191..7f6a8ce5a418d0eed0722104b962592c4c9d7919 100644 (file)
@@ -5,7 +5,7 @@ struct g82_channel_dma_v0 {
        __u8  version;
        __u8  chid;
        __u8  pad02[6];
-       __u64 vm;
+       __u64 vmm;
        __u64 pushbuf;
        __u64 offset;
 };
index e34efd4ec5371e2c42a4c89fc3052757a96724ab..c4d35522331a4795437de2644465830900d85307 100644 (file)
@@ -8,7 +8,7 @@ struct g82_channel_gpfifo_v0 {
        __u32 ilength;
        __u64 ioffset;
        __u64 pushbuf;
-       __u64 vm;
+       __u64 vmm;
 };
 
 #define NV826F_V0_NTFY_NON_STALL_INTERRUPT                                 0x00
index a2d5410a491b8d434e3df8e65d4945f32c57e827..169161c1587f7e29e282d40ebaac9ebec32430c8 100644 (file)
@@ -7,7 +7,7 @@ struct fermi_channel_gpfifo_v0 {
        __u8  pad02[2];
        __u32 ilength;
        __u64 ioffset;
-       __u64 vm;
+       __u64 vmm;
 };
 
 #define NV906F_V0_NTFY_NON_STALL_INTERRUPT                                 0x00
index 2efa3d048bb9da20a220df3117c68c5babb45b3f..3e57089526e3a05c8738a910fd9cc70c38cf51bd 100644 (file)
@@ -22,7 +22,7 @@ struct kepler_channel_gpfifo_a_v0 {
        __u32 engines;
        __u32 ilength;
        __u64 ioffset;
-       __u64 vm;
+       __u64 vmm;
 };
 
 #define NVA06F_V0_NTFY_NON_STALL_INTERRUPT                                 0x00
index f3ed5896b8423fbe9784f3b98d950f6f305c7fd7..34dbcf5f7f4ed99fa68b844b5cacc42baf84deac 100644 (file)
@@ -205,6 +205,7 @@ static int
 nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
                    u32 engine, struct nouveau_channel **pchan)
 {
+       struct nouveau_cli *cli = (void *)device->object.client;
        static const u16 oclasses[] = { PASCAL_CHANNEL_GPFIFO_A,
                                        MAXWELL_CHANNEL_GPFIFO_A,
                                        KEPLER_CHANNEL_GPFIFO_B,
@@ -236,21 +237,21 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
                        args.kepler.engines = engine;
                        args.kepler.ilength = 0x02000;
                        args.kepler.ioffset = 0x10000 + chan->push.addr;
-                       args.kepler.vm = 0;
+                       args.kepler.vmm = nvif_handle(&cli->vmm.vmm.object);
                        size = sizeof(args.kepler);
                } else
                if (oclass[0] >= FERMI_CHANNEL_GPFIFO) {
                        args.fermi.version = 0;
                        args.fermi.ilength = 0x02000;
                        args.fermi.ioffset = 0x10000 + chan->push.addr;
-                       args.fermi.vm = 0;
+                       args.fermi.vmm = nvif_handle(&cli->vmm.vmm.object);
                        size = sizeof(args.fermi);
                } else {
                        args.nv50.version = 0;
                        args.nv50.ilength = 0x02000;
                        args.nv50.ioffset = 0x10000 + chan->push.addr;
                        args.nv50.pushbuf = nvif_handle(&chan->push.ctxdma);
-                       args.nv50.vm = 0;
+                       args.nv50.vmm = nvif_handle(&cli->vmm.vmm.object);
                        size = sizeof(args.nv50);
                }
 
index ac94b57777c4a0effbd2306e22bacbb6b260a4d5..d83485385934d86dc475662ccfef1c87de01fe3d 100644 (file)
@@ -27,7 +27,6 @@
 #include <core/gpuobj.h>
 #include <core/oproxy.h>
 #include <subdev/mmu.h>
-#include <subdev/mmu/priv.h>
 #include <engine/dma.h>
 
 struct nvkm_fifo_chan_object {
@@ -353,8 +352,8 @@ nvkm_fifo_chan_func = {
 int
 nvkm_fifo_chan_ctor(const struct nvkm_fifo_chan_func *func,
                    struct nvkm_fifo *fifo, u32 size, u32 align, bool zero,
-                   u64 vm, u64 push, u64 engines, int bar, u32 base, u32 user,
-                   const struct nvkm_oclass *oclass,
+                   u64 hvmm, u64 push, u64 engines, int bar, u32 base,
+                   u32 user, const struct nvkm_oclass *oclass,
                    struct nvkm_fifo_chan *chan)
 {
        struct nvkm_client *client = oclass->client;
@@ -387,8 +386,11 @@ nvkm_fifo_chan_ctor(const struct nvkm_fifo_chan_func *func,
        }
 
        /* channel address space */
-       if (!device->mmu->func->vmm.global) {
-               struct nvkm_vmm *vmm = client->vm;
+       if (hvmm) {
+               struct nvkm_vmm *vmm = nvkm_uvmm_search(client, hvmm);
+               if (IS_ERR(vmm))
+                       return PTR_ERR(vmm);
+
                if (vmm->mmu != device->mmu)
                        return -EINVAL;
 
index 1870310549e86b2e38a720f0a41a8d6eed7f0214..a5c998fe4485a938eb0f00351c14f98054c39db9 100644 (file)
@@ -229,15 +229,18 @@ g84_fifo_chan_func = {
 };
 
 int
-g84_fifo_chan_ctor(struct nv50_fifo *fifo, u64 vm, u64 push,
+g84_fifo_chan_ctor(struct nv50_fifo *fifo, u64 vmm, u64 push,
                   const struct nvkm_oclass *oclass,
                   struct nv50_fifo_chan *chan)
 {
        struct nvkm_device *device = fifo->base.engine.subdev.device;
        int ret;
 
+       if (!vmm)
+               return -EINVAL;
+
        ret = nvkm_fifo_chan_ctor(&g84_fifo_chan_func, &fifo->base,
-                                 0x10000, 0x1000, false, vm, push,
+                                 0x10000, 0x1000, false, vmm, push,
                                  (1ULL << NVKM_ENGINE_BSP) |
                                  (1ULL << NVKM_ENGINE_CE0) |
                                  (1ULL << NVKM_ENGINE_CIPHER) |
index 01453279dbc005bfe256871d811d27195c886fa2..85f7dbf53c997bc1bd62ea7008e8b91b350e7323 100644 (file)
@@ -228,15 +228,18 @@ nv50_fifo_chan_func = {
 };
 
 int
-nv50_fifo_chan_ctor(struct nv50_fifo *fifo, u64 vm, u64 push,
+nv50_fifo_chan_ctor(struct nv50_fifo *fifo, u64 vmm, u64 push,
                    const struct nvkm_oclass *oclass,
                    struct nv50_fifo_chan *chan)
 {
        struct nvkm_device *device = fifo->base.engine.subdev.device;
        int ret;
 
+       if (!vmm)
+               return -EINVAL;
+
        ret = nvkm_fifo_chan_ctor(&nv50_fifo_chan_func, &fifo->base,
-                                 0x10000, 0x1000, false, vm, push,
+                                 0x10000, 0x1000, false, vmm, push,
                                  (1ULL << NVKM_ENGINE_DMAOBJ) |
                                  (1ULL << NVKM_ENGINE_SW) |
                                  (1ULL << NVKM_ENGINE_GR) |
index a0c04c6329a837f317872da9e55e9ae5e1e8b7e3..d853056e040bfca8a158a4af9f5d1ba800f6e640 100644 (file)
@@ -17,14 +17,14 @@ struct nv50_fifo_chan {
        struct nvkm_gpuobj *engn[NVKM_SUBDEV_NR];
 };
 
-int nv50_fifo_chan_ctor(struct nv50_fifo *, u64 vm, u64 push,
+int nv50_fifo_chan_ctor(struct nv50_fifo *, u64 vmm, u64 push,
                        const struct nvkm_oclass *, struct nv50_fifo_chan *);
 void *nv50_fifo_chan_dtor(struct nvkm_fifo_chan *);
 void nv50_fifo_chan_fini(struct nvkm_fifo_chan *);
 void nv50_fifo_chan_engine_dtor(struct nvkm_fifo_chan *, struct nvkm_engine *);
 void nv50_fifo_chan_object_dtor(struct nvkm_fifo_chan *, int);
 
-int g84_fifo_chan_ctor(struct nv50_fifo *, u64 vm, u64 push,
+int g84_fifo_chan_ctor(struct nv50_fifo *, u64 vmm, u64 push,
                       const struct nvkm_oclass *, struct nv50_fifo_chan *);
 
 extern const struct nvkm_fifo_chan_oclass nv50_fifo_dma_oclass;
index caa91407475258451b0da09de9fdb5cdc54f49d3..fc34cddcd2f51df5d6f7d89cc5c16761cc5a878c 100644 (file)
@@ -44,9 +44,9 @@ g84_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        nvif_ioctl(parent, "create channel dma size %d\n", size);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel dma vers %d vm %llx "
+               nvif_ioctl(parent, "create channel dma vers %d vmm %llx "
                                   "pushbuf %llx offset %016llx\n",
-                          args->v0.version, args->v0.vm, args->v0.pushbuf,
+                          args->v0.version, args->v0.vmm, args->v0.pushbuf,
                           args->v0.offset);
                if (!args->v0.pushbuf)
                        return -EINVAL;
@@ -57,7 +57,7 @@ g84_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
                return -ENOMEM;
        *pobject = &chan->base.object;
 
-       ret = g84_fifo_chan_ctor(fifo, args->v0.vm, args->v0.pushbuf,
+       ret = g84_fifo_chan_ctor(fifo, args->v0.vmm, args->v0.pushbuf,
                                 oclass, chan);
        if (ret)
                return ret;
index 480bc3777be59d76e2eac937f804be997c5ebd49..8043718ad150491158949b5eecddd4233a9ba4eb 100644 (file)
@@ -44,9 +44,9 @@ nv50_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        nvif_ioctl(parent, "create channel dma size %d\n", size);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel dma vers %d vm %llx "
+               nvif_ioctl(parent, "create channel dma vers %d vmm %llx "
                                   "pushbuf %llx offset %016llx\n",
-                          args->v0.version, args->v0.vm, args->v0.pushbuf,
+                          args->v0.version, args->v0.vmm, args->v0.pushbuf,
                           args->v0.offset);
                if (!args->v0.pushbuf)
                        return -EINVAL;
@@ -57,7 +57,7 @@ nv50_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
                return -ENOMEM;
        *pobject = &chan->base.object;
 
-       ret = nv50_fifo_chan_ctor(fifo, args->v0.vm, args->v0.pushbuf,
+       ret = nv50_fifo_chan_ctor(fifo, args->v0.vmm, args->v0.pushbuf,
                                  oclass, chan);
        if (ret)
                return ret;
index 77c2f2a28bf3b41f44ec94eceab9c99b2238e32c..2121f517b1dda4ecad5427cf3caf2d750062317a 100644 (file)
@@ -45,10 +45,10 @@ g84_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
+               nvif_ioctl(parent, "create channel gpfifo vers %d vmm %llx "
                                   "pushbuf %llx ioffset %016llx "
                                   "ilength %08x\n",
-                          args->v0.version, args->v0.vm, args->v0.pushbuf,
+                          args->v0.version, args->v0.vmm, args->v0.pushbuf,
                           args->v0.ioffset, args->v0.ilength);
                if (!args->v0.pushbuf)
                        return -EINVAL;
@@ -59,7 +59,7 @@ g84_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
                return -ENOMEM;
        *pobject = &chan->base.object;
 
-       ret = g84_fifo_chan_ctor(fifo, args->v0.vm, args->v0.pushbuf,
+       ret = g84_fifo_chan_ctor(fifo, args->v0.vmm, args->v0.pushbuf,
                                 oclass, chan);
        if (ret)
                return ret;
index 78114068c6dd31eb73f84bbe0ba4d2cde5427805..75f9632789b33aeaa1528e2a548deb436f2ccd46 100644 (file)
@@ -225,10 +225,12 @@ gf100_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
+               nvif_ioctl(parent, "create channel gpfifo vers %d vmm %llx "
                                   "ioffset %016llx ilength %08x\n",
-                          args->v0.version, args->v0.vm, args->v0.ioffset,
+                          args->v0.version, args->v0.vmm, args->v0.ioffset,
                           args->v0.ilength);
+               if (!args->v0.vmm)
+                       return -EINVAL;
        } else
                return ret;
 
@@ -240,7 +242,7 @@ gf100_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
        INIT_LIST_HEAD(&chan->head);
 
        ret = nvkm_fifo_chan_ctor(&gf100_fifo_gpfifo_func, &fifo->base,
-                                 0x1000, 0x1000, true, args->v0.vm, 0,
+                                 0x1000, 0x1000, true, args->v0.vmm, 0,
                                  (1ULL << NVKM_ENGINE_CE0) |
                                  (1ULL << NVKM_ENGINE_CE1) |
                                  (1ULL << NVKM_ENGINE_GR) |
index 368f5f5138a36ada2e48ca03f1df3a8e38e7d296..80c87521bebee7e9fd6bb7a537c3294cdcc2b3ac 100644 (file)
@@ -231,7 +231,7 @@ struct gk104_fifo_chan_func {
 static int
 gk104_fifo_gpfifo_new_(const struct gk104_fifo_chan_func *func,
                       struct gk104_fifo *fifo, u32 *engmask, u16 *chid,
-                      u64 vm, u64 ioffset, u64 ilength,
+                      u64 vmm, u64 ioffset, u64 ilength,
                       const struct nvkm_oclass *oclass,
                       struct nvkm_object **pobject)
 {
@@ -241,6 +241,9 @@ gk104_fifo_gpfifo_new_(const struct gk104_fifo_chan_func *func,
        u64 subdevs = 0;
        u64 usermem;
 
+       if (!vmm)
+               return -EINVAL;
+
        /* Determine which downstream engines are present */
        for (i = 0; i < fifo->engine_nr; i++) {
                struct nvkm_engine *engine = fifo->engine[i].engine;
@@ -286,7 +289,7 @@ gk104_fifo_gpfifo_new_(const struct gk104_fifo_chan_func *func,
        INIT_LIST_HEAD(&chan->head);
 
        ret = nvkm_fifo_chan_ctor(&gk104_fifo_gpfifo_func, &fifo->base,
-                                 0x1000, 0x1000, true, vm, 0, subdevs,
+                                 0x1000, 0x1000, true, vmm, 0, subdevs,
                                  1, fifo->user.bar->addr, 0x200,
                                  oclass, &chan->base);
        if (ret)
@@ -358,18 +361,17 @@ gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
+               nvif_ioctl(parent, "create channel gpfifo vers %d vmm %llx "
                                   "ioffset %016llx ilength %08x engine %08x\n",
-                          args->v0.version, args->v0.vm, args->v0.ioffset,
+                          args->v0.version, args->v0.vmm, args->v0.ioffset,
                           args->v0.ilength, args->v0.engines);
                return gk104_fifo_gpfifo_new_(gk104_fifo_gpfifo, fifo,
                                              &args->v0.engines,
                                              &args->v0.chid,
-                                              args->v0.vm,
+                                              args->v0.vmm,
                                               args->v0.ioffset,
                                               args->v0.ilength,
                                              oclass, pobject);
-
        }
 
        return ret;
index c5a7de9db2596279f608d7a5907896f11494504b..d8f28ec1e4a81f71fa917455e3ffa30cce09aedb 100644 (file)
@@ -45,10 +45,10 @@ nv50_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
 
        nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
+               nvif_ioctl(parent, "create channel gpfifo vers %d vmm %llx "
                                   "pushbuf %llx ioffset %016llx "
                                   "ilength %08x\n",
-                          args->v0.version, args->v0.vm, args->v0.pushbuf,
+                          args->v0.version, args->v0.vmm, args->v0.pushbuf,
                           args->v0.ioffset, args->v0.ilength);
                if (!args->v0.pushbuf)
                        return -EINVAL;
@@ -59,7 +59,7 @@ nv50_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
                return -ENOMEM;
        *pobject = &chan->base.object;
 
-       ret = nv50_fifo_chan_ctor(fifo, args->v0.vm, args->v0.pushbuf,
+       ret = nv50_fifo_chan_ctor(fifo, args->v0.vmm, args->v0.pushbuf,
                                  oclass, chan);
        if (ret)
                return ret;