diff options
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv04.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv44.c | 22 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv44.c | 51 |
5 files changed, 67 insertions, 9 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild index cb48aa0dd423..685a2e2b54fc 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild @@ -10,3 +10,4 @@ nvkm-y += nvkm/subdev/mmu/gp100.o nvkm-y += nvkm/subdev/mmu/vmm.o nvkm-y += nvkm/subdev/mmu/vmmnv04.o nvkm-y += nvkm/subdev/mmu/vmmnv41.o +nvkm-y += nvkm/subdev/mmu/vmmnv44.o diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv04.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv04.h index 363e33b296d5..6b8f14c6db3d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv04.h +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv04.h @@ -5,7 +5,6 @@ struct nv04_mmu { struct nvkm_mmu base; - struct nvkm_vm *vm; dma_addr_t null; void *nullp; }; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv44.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv44.c index a648c2395545..d9eae6393851 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv44.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv44.c @@ -22,6 +22,7 @@ * Authors: Ben Skeggs */ #include "nv04.h" +#include "vmmnv04.h" #include <core/gpuobj.h> #include <core/option.h> @@ -172,16 +173,11 @@ nv44_mmu_oneinit(struct nvkm_mmu *base) mmu->null = 0; } - ret = nvkm_vm_create(&mmu->base, 0, NV44_GART_SIZE, 0, 4096, NULL, - &mmu->vm); - if (ret) - return ret; - ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, (NV44_GART_SIZE / NV44_GART_PAGE) * 4, 512 * 1024, true, - &mmu->vm->pgt[0].mem[0]); - mmu->vm->pgt[0].refcount[0] = 1; + &mmu->base.vmm->pgt[0].mem[0]); + mmu->base.vmm->pgt[0].refcount[0] = 1; return ret; } @@ -190,7 +186,7 @@ nv44_mmu_init(struct nvkm_mmu *base) { struct nv04_mmu *mmu = nv04_mmu(base); struct nvkm_device *device = mmu->base.subdev.device; - struct nvkm_memory *gart = mmu->vm->pgt[0].mem[0]; + struct nvkm_memory *gart = mmu->base.vmm->pgt[0].mem[0]; u32 addr; /* calculate vram address of this PRAMIN block, object must be @@ -210,6 +206,14 @@ nv44_mmu_init(struct nvkm_mmu *base) nvkm_wr32(device, 0x100800, addr | 0x00000010); } +static int +nv44_mmu_uvmm(struct nvkm_mmu *base, int i, const struct nvkm_vmm_user **puvmm) +{ + if (i == 0) + *puvmm = &nv44_vmm_user; + return 1; +} + static const struct nvkm_mmu_func nv44_mmu = { .dtor = nv04_mmu_dtor, @@ -223,6 +227,8 @@ nv44_mmu = { .map_sg = nv44_vm_map_sg, .unmap = nv44_vm_unmap, .flush = nv44_vm_flush, + .uvmm = nv44_mmu_uvmm, + .vmm_global = true, }; int diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h index e12013829f6e..d18334e0882e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h @@ -14,4 +14,5 @@ const struct nvkm_vmm_page *nv04_vmm_page(struct nvkm_vmm *); extern const struct nvkm_vmm_user nv04_vmm_user; extern const struct nvkm_vmm_user nv41_vmm_user; +extern const struct nvkm_vmm_user nv44_vmm_user; #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv44.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv44.c new file mode 100644 index 000000000000..8d3aa7d80932 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv44.c @@ -0,0 +1,51 @@ +/* + * Copyright 2017 Red Hat Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#include "vmmnv04.h" + +static const struct nvkm_vmm_func +nv44_vmm = { + .dtor = nv04_vmm_dtor, + .page = nv04_vmm_page, +}; + +static int +nv44_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc, + struct lock_class_key *key, struct nvkm_vmm **pvmm) +{ + struct nv04_vmm *vmm; + int ret; + + if (argc != 0) + return -ENOSYS; + + ret = nv04_vmm_new_(&nv44_vmm, mmu, 29, addr, size, key, &vmm); + *pvmm = vmm ? &vmm->base : NULL; + if (ret) + return ret; + + return 0; +} + +const struct nvkm_vmm_user +nv44_vmm_user = { + .ctor = nv44_vmm_new, +}; |