u16 chid;
struct nvkm_gpuobj *inst;
struct nvkm_gpuobj *push;
- struct nvkm_vm *vm;
+ struct nvkm_vmm *vmm;
void __iomem *user;
u64 addr;
u32 size;
#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 {
if (chan->func->engine_dtor)
chan->func->engine_dtor(chan, engine);
nvkm_object_del(&engn->object);
- if (chan->vm)
- atomic_dec(&chan->vm->engref[engine->subdev.index]);
+ if (chan->vmm)
+ atomic_dec(&chan->vmm->engref[engine->subdev.index]);
}
}
.engine = oclass->engine,
};
- if (chan->vm)
- atomic_inc(&chan->vm->engref[engine->subdev.index]);
+ if (chan->vmm)
+ atomic_inc(&chan->vmm->engref[engine->subdev.index]);
if (engine->func->fifo.cclass) {
ret = engine->func->fifo.cclass(chan, &cclass,
if (chan->user)
iounmap(chan->user);
- nvkm_vm_ref(NULL, &chan->vm, NULL);
+ if (chan->vmm) {
+ nvkm_vmm_part(chan->vmm, chan->inst->memory);
+ nvkm_vmm_unref(&chan->vmm);
+ }
nvkm_gpuobj_del(&chan->push);
nvkm_gpuobj_del(&chan->inst);
{
struct nvkm_client *client = oclass->client;
struct nvkm_device *device = fifo->engine.subdev.device;
- struct nvkm_mmu *mmu = device->mmu;
struct nvkm_dmaobj *dmaobj;
unsigned long flags;
int ret;
}
/* channel address space */
- if (!vm && mmu) {
- if (!client->vm || client->vm->mmu == mmu) {
- ret = nvkm_vm_ref(client->vm, &chan->vm, NULL);
- if (ret)
- return ret;
- } else {
+ if (!device->mmu->func->vmm.global) {
+ struct nvkm_vmm *vmm = client->vm;
+ if (vmm->mmu != device->mmu)
return -EINVAL;
- }
- } else {
- return -ENOENT;
+
+ ret = nvkm_vmm_join(vmm, chan->inst->memory);
+ if (ret)
+ return ret;
+
+ chan->vmm = nvkm_vmm_ref(vmm);
}
/* allocate channel id */
if (ret)
return ret;
- ret = nvkm_ramht_new(device, 0x8000, 16, chan->base.inst, &chan->ramht);
- if (ret)
- return ret;
-
- return nvkm_vm_ref(chan->base.vm, &chan->vm, chan->base.inst->memory);
+ return nvkm_ramht_new(device, 0x8000, 16, chan->base.inst, &chan->ramht);
}
struct list_head head;
bool killed;
- struct nvkm_vm *vm;
-
struct {
struct nvkm_gpuobj *inst;
struct nvkm_vma vma;
struct list_head head;
bool killed;
- struct nvkm_vm *vm;
-
struct {
struct nvkm_gpuobj *inst;
struct nvkm_vma vma;
nv50_fifo_chan_dtor(struct nvkm_fifo_chan *base)
{
struct nv50_fifo_chan *chan = nv50_fifo_chan(base);
- if (chan->base.inst)
- nvkm_vm_ref(NULL, &chan->vm, chan->base.inst->memory);
nvkm_ramht_del(&chan->ramht);
nvkm_gpuobj_del(&chan->pgd);
nvkm_gpuobj_del(&chan->eng);
if (ret)
return ret;
- ret = nvkm_ramht_new(device, 0x8000, 16, chan->base.inst, &chan->ramht);
- if (ret)
- return ret;
-
- return nvkm_vm_ref(chan->base.vm, &chan->vm, chan->base.inst->memory);
+ return nvkm_ramht_new(device, 0x8000, 16, chan->base.inst, &chan->ramht);
}
struct nvkm_gpuobj *eng;
struct nvkm_gpuobj *pgd;
struct nvkm_ramht *ramht;
- struct nvkm_vm *vm;
struct nvkm_gpuobj *engn[NVKM_SUBDEV_NR];
};
if (ret)
return ret;
- ret = nvkm_vm_get(chan->vm, chan->engn[engn].inst->size, 12,
+ ret = nvkm_vm_get(chan->base.vmm, chan->engn[engn].inst->size, 12,
NV_MEM_ACCESS_RW, &chan->engn[engn].vma);
if (ret)
return ret;
- return nvkm_memory_map(chan->engn[engn].inst, 0, chan->vm,
+ return nvkm_memory_map(chan->engn[engn].inst, 0, chan->base.vmm,
&chan->engn[engn].vma, NULL, 0);
}
static void *
gf100_fifo_gpfifo_dtor(struct nvkm_fifo_chan *base)
{
- struct gf100_fifo_chan *chan = gf100_fifo_chan(base);
- if (chan->base.inst)
- nvkm_vm_ref(NULL, &chan->vm, chan->base.inst->memory);
- return chan;
+ return gf100_fifo_chan(base);
}
static const struct nvkm_fifo_chan_func
args->v0.chid = chan->base.chid;
- ret = nvkm_vm_ref(chan->base.vm, &chan->vm, chan->base.inst->memory);
- if (ret)
- return ret;
-
/* clear channel control registers */
usermem = chan->base.chid * 0x1000;
if (ret)
return ret;
- ret = nvkm_vm_get(chan->vm, chan->engn[engn].inst->size, 12,
+ ret = nvkm_vm_get(chan->base.vmm, chan->engn[engn].inst->size, 12,
NV_MEM_ACCESS_RW, &chan->engn[engn].vma);
if (ret)
return ret;
- return nvkm_memory_map(chan->engn[engn].inst, 0, chan->vm,
+ return nvkm_memory_map(chan->engn[engn].inst, 0, chan->base.vmm,
&chan->engn[engn].vma, NULL, 0);
}
static void *
gk104_fifo_gpfifo_dtor(struct nvkm_fifo_chan *base)
{
- struct gk104_fifo_chan *chan = gk104_fifo_chan(base);
- if (chan->base.inst)
- nvkm_vm_ref(NULL, &chan->vm, chan->base.inst->memory);
- return chan;
+ return gk104_fifo_chan(base);
}
static const struct nvkm_fifo_chan_func
*chid = chan->base.chid;
- ret = nvkm_vm_ref(chan->base.vm, &chan->vm, chan->base.inst->memory);
- if (ret)
- return ret;
-
/* Clear channel control registers. */
usermem = chan->base.chid * 0x200;
ilength = order_base_2(ilength / 8);
if (ret)
return ret;
- ret = nvkm_vm_get(fifoch->vm, 0x1000, 12, NV_MEM_ACCESS_RW |
+ ret = nvkm_vm_get(fifoch->vmm, 0x1000, 12, NV_MEM_ACCESS_RW |
NV_MEM_ACCESS_SYS, &chan->mmio_vma);
if (ret)
return ret;
- ret = nvkm_memory_map(chan->mmio, 0, fifoch->vm,
+ ret = nvkm_memory_map(chan->mmio, 0, fifoch->vmm,
&chan->mmio_vma, NULL, 0);
if (ret)
return ret;
if (ret)
return ret;
- ret = nvkm_vm_get(fifoch->vm,
+ ret = nvkm_vm_get(fifoch->vmm,
nvkm_memory_size(chan->data[i].mem), 12,
data->access, &chan->data[i].vma);
if (ret)
return ret;
- ret = nvkm_memory_map(chan->data[i].mem, 0, fifoch->vm,
+ ret = nvkm_memory_map(chan->data[i].mem, 0, fifoch->vmm,
&chan->data[i].vma, NULL, 0);
if (ret)
return ret;