summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2016-06-16 17:32:59 +1000
committerJérôme Glisse <jglisse@redhat.com>2017-08-09 18:13:31 -0400
commitf43a4633c520fcb28d2c93bf3e67cd88cd108ea1 (patch)
treec918826750280743f7f379a899e8e9f731042d01
parent53db2fd5d053637b0f965d216e33b6f4b1210280 (diff)
mmu/nv50: allow implementation to be subclassed
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c32
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h16
2 files changed, 45 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c
index a1f8d65f0276..bbd56b2c9514 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c
@@ -21,7 +21,7 @@
*
* Authors: Ben Skeggs
*/
-#include "priv.h"
+#include "nv50.h"
#include <core/gpuobj.h>
#include <subdev/fb.h>
@@ -209,8 +209,15 @@ nv50_vm_create(struct nvkm_mmu *mmu, u64 offset, u64 length, u64 mm_offset,
return nvkm_vm_create(mmu, offset, length, mm_offset, block, key, pvm);
}
+static void *
+nv50_mmu_dtor(struct nvkm_mmu *base)
+{
+ return nv50_mmu(base);
+}
+
static const struct nvkm_mmu_func
-nv50_mmu = {
+nv50_mmu_ = {
+ .dtor = nv50_mmu_dtor,
.limit = (1ULL << 40),
.dma_bits = 40,
.pgt_bits = 29 - 12,
@@ -225,7 +232,26 @@ nv50_mmu = {
};
int
+nv50_mmu_new_(const struct nv50_mmu_func *func, struct nvkm_device *device,
+ int index, struct nvkm_mmu **pmmu)
+{
+ struct nv50_mmu *mmu;
+
+ if (!(mmu = kzalloc(sizeof(*mmu), GFP_KERNEL)))
+ return -ENOMEM;
+ mmu->func = func;
+ *pmmu = &mmu->base;
+
+ nvkm_mmu_ctor(&nv50_mmu_, device, index, &mmu->base);
+ return 0;
+}
+
+static const struct nv50_mmu_func
+nv50_mmu = {
+};
+
+int
nv50_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu)
{
- return nvkm_mmu_new_(&nv50_mmu, device, index, pmmu);
+ return nv50_mmu_new_(&nv50_mmu, device, index, pmmu);
}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h
new file mode 100644
index 000000000000..6a59e4262d4e
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h
@@ -0,0 +1,16 @@
+#ifndef __NV50_MMU_H__
+#define __NV50_MMU_H__
+#define nv50_mmu(p) container_of((p), struct nv50_mmu, base)
+#include "priv.h"
+
+struct nv50_mmu {
+ const struct nv50_mmu_func *func;
+ struct nvkm_mmu base;
+};
+
+struct nv50_mmu_func {
+};
+
+int nv50_mmu_new_(const struct nv50_mmu_func *, struct nvkm_device *, int,
+ struct nvkm_mmu **);
+#endif