- transition from "ioctl" interface Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx> --- .../gpu/drm/nouveau/include/nvif/driverif.h | 3 ++ drivers/gpu/drm/nouveau/include/nvif/if0008.h | 12 ----- drivers/gpu/drm/nouveau/include/nvif/mmu.h | 6 +-- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +- drivers/gpu/drm/nouveau/nouveau_mem.c | 4 +- drivers/gpu/drm/nouveau/nvif/mmu.c | 31 ----------- .../gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c | 53 ++----------------- 7 files changed, 13 insertions(+), 100 deletions(-) delete mode 100644 drivers/gpu/drm/nouveau/include/nvif/if0008.h diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index fa08478cc38f..f387ec622a45 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -83,6 +83,7 @@ struct nvif_mmu_impl { u8 heap_nr; u8 type_nr; + u8 kind_inv; u16 kind_nr; struct { @@ -102,6 +103,8 @@ struct nvif_mmu_impl { u8 heap; } type[16]; + const u8 *kind; + struct { s32 oclass; } mem; diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0008.h b/drivers/gpu/drm/nouveau/include/nvif/if0008.h deleted file mode 100644 index 0413e7e4ca0c..000000000000 --- a/drivers/gpu/drm/nouveau/include/nvif/if0008.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __NVIF_IF0008_H__ -#define __NVIF_IF0008_H__ - -#define NVIF_MMU_V0_KIND 0x02 - -struct nvif_mmu_kind_v0 { - __u8 version; - __u8 kind_inv; - __u16 count; - __u8 data[]; -}; -#endif diff --git a/drivers/gpu/drm/nouveau/include/nvif/mmu.h b/drivers/gpu/drm/nouveau/include/nvif/mmu.h index 203328a2d611..f1e51a5544da 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/mmu.h +++ b/drivers/gpu/drm/nouveau/include/nvif/mmu.h @@ -8,10 +8,6 @@ struct nvif_mmu { const struct nvif_mmu_impl *impl; struct nvif_mmu_priv *priv; struct nvif_object object; - u8 kind_inv; - u16 kind_nr; - - u8 *kind; }; int nvif_mmu_ctor(struct nvif_device *, const char *name, struct nvif_mmu *); @@ -21,7 +17,7 @@ static inline bool nvif_mmu_kind_valid(struct nvif_mmu *mmu, u8 kind) { if (kind) { - if (kind >= mmu->kind_nr || mmu->kind[kind] == mmu->kind_inv) + if (kind >= mmu->impl->kind_nr || mmu->impl->kind[kind] == mmu->impl->kind_inv) return false; } return true; diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 08d522aaae38..0d946e31bccd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -250,7 +250,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, return ERR_PTR(-EINVAL); } - nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; + nvbo->comp = mmu->impl->kind[nvbo->kind] != nvbo->kind; } else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) { nvbo->kind = (tile_flags & 0x00007f00) >> 8; nvbo->comp = (tile_flags & 0x00030000) >> 16; @@ -299,7 +299,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, /* Disable compression if suitable settings couldn't be found. */ if (nvbo->comp && !vmm->page[pi].comp) { if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100) - nvbo->kind = mmu->kind[nvbo->kind]; + nvbo->kind = mmu->impl->kind[nvbo->kind]; nvbo->comp = 0; } nvbo->page = vmm->page[pi].shift; diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index 554500a650db..872d689db7ba 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c @@ -104,7 +104,7 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt) mem->comp = mem->kind = 0; if (mem->comp && !(mmu->impl->type[type].type & NVIF_MEM_COMP)) { if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100) - mem->kind = mmu->kind[mem->kind]; + mem->kind = mmu->impl->kind[mem->kind]; mem->comp = 0; } @@ -144,7 +144,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page) ret = nvif_mem_ctor_type(mmu, "ttmVram", drm->ttm.type_vram, page, size, &(struct nv50_mem_v0) { - .bankswz = mmu->kind[mem->kind] == 2, + .bankswz = mmu->impl->kind[mem->kind] == 2, .contig = contig, }, sizeof(struct nv50_mem_v0), &mem->mem); diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c index e727a6587658..d1d09e5a6909 100644 --- a/drivers/gpu/drm/nouveau/nvif/mmu.c +++ b/drivers/gpu/drm/nouveau/nvif/mmu.c @@ -24,7 +24,6 @@ #include <nvif/printf.h> #include <nvif/class.h> -#include <nvif/if0008.h> void nvif_mmu_dtor(struct nvif_mmu *mmu) @@ -32,7 +31,6 @@ nvif_mmu_dtor(struct nvif_mmu *mmu) if (!mmu->impl) return; - kfree(mmu->kind); mmu->impl->del(mmu->priv); mmu->impl = NULL; } @@ -44,7 +42,6 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu int ret; mmu->impl = NULL; - mmu->kind = NULL; ret = device->impl->mmu.new(device->priv, &mmu->impl, &mmu->priv, nvif_handle(&mmu->object)); @@ -53,33 +50,5 @@ nvif_mmu_ctor(struct nvif_device *device, const char *name, struct nvif_mmu *mmu return ret; nvif_object_ctor(&device->object, name ?: "nvifMmu", 0, oclass, &mmu->object); - - mmu->kind_nr = mmu->impl->kind_nr; - - mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind), - GFP_KERNEL); - if (!mmu->kind && mmu->kind_nr) - goto done; - - if (mmu->kind_nr) { - struct nvif_mmu_kind_v0 *kind; - size_t argc = struct_size(kind, data, mmu->kind_nr); - - if (ret = -ENOMEM, !(kind = kmalloc(argc, GFP_KERNEL))) - goto done; - kind->version = 0; - kind->count = mmu->kind_nr; - - ret = nvif_object_mthd(&mmu->object, NVIF_MMU_V0_KIND, - kind, argc); - if (ret == 0) - memcpy(mmu->kind, kind->data, kind->count); - mmu->kind_inv = kind->kind_inv; - kfree(kind); - } - -done: - if (ret) - nvif_mmu_dtor(mmu); return ret; } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c index 8be5b1034bc1..05ec276facd9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c @@ -25,9 +25,6 @@ #include <core/client.h> -#include <nvif/if0008.h> -#include <nvif/unpack.h> - static int nvkm_ummu_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *oclass) @@ -53,33 +50,6 @@ nvkm_ummu_sclass(struct nvkm_object *object, int index, return -EINVAL; } -static int -nvkm_ummu_kind(struct nvkm_ummu *ummu, void *argv, u32 argc) -{ - struct nvkm_mmu *mmu = ummu->mmu; - union { - struct nvif_mmu_kind_v0 v0; - } *args = argv; - const u8 *kind = NULL; - int ret = -ENOSYS, count = 0; - u8 kind_inv = 0; - - if (mmu->func->kind) - kind = mmu->func->kind(mmu, &count, &kind_inv); - - if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true))) { - if (argc != args->v0.count * sizeof(*args->v0.data)) - return -EINVAL; - if (args->v0.count > count) - return -EINVAL; - args->v0.kind_inv = kind_inv; - memcpy(args->v0.data, kind, args->v0.count); - } else - return ret; - - return 0; -} - static void nvkm_ummu_del(struct nvif_mmu_priv *ummu) { @@ -93,21 +63,8 @@ nvkm_ummu_impl = { .del = nvkm_ummu_del, }; -static int -nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc) -{ - struct nvif_mmu_priv *ummu = container_of(object, typeof(*ummu), object); - switch (mthd) { - case NVIF_MMU_V0_KIND: return nvkm_ummu_kind(ummu, argv, argc); - default: - break; - } - return -EINVAL; -} - static const struct nvkm_object_func nvkm_ummu = { - .mthd = nvkm_ummu_mthd, .sclass = nvkm_ummu_sclass, }; @@ -118,7 +75,6 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl, struct nvkm_mmu *mmu = device->mmu; struct nvif_mmu_priv *ummu; int kinds = 0; - u8 unused = 0; if (!(ummu = kzalloc(sizeof(*ummu), GFP_KERNEL))) return -ENOMEM; @@ -127,13 +83,9 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl, ummu->mmu = mmu; ummu->impl = nvkm_ummu_impl; - if (mmu->func->kind) - mmu->func->kind(mmu, &kinds, &unused); - ummu->impl.dmabits = mmu->dma_bits; ummu->impl.heap_nr = mmu->heap_nr; ummu->impl.type_nr = mmu->type_nr; - ummu->impl.kind_nr = kinds; for (int i = 0; i < mmu->heap_nr; i++) ummu->impl.heap[i].size = mmu->heap[i].size; @@ -152,6 +104,11 @@ nvkm_ummu_new(struct nvkm_device *device, const struct nvif_mmu_impl **pimpl, ummu->impl.type[i].heap = mmu->type[i].heap; } + if (mmu->func->kind) { + ummu->impl.kind = mmu->func->kind(mmu, &kinds, &ummu->impl.kind_inv); + ummu->impl.kind_nr = kinds; + } + ummu->impl.mem.oclass = mmu->func->mem.user.oclass; ummu->impl.vmm.oclass = mmu->func->vmm.user.oclass; -- 2.41.0