[PATCH 001/156] drm/nouveau: add nouveau_drm.device/mmu

Ben Skeggs bskeggs at nvidia.com
Tue Apr 16 23:37:27 UTC 2024


- removing nouveau_drm.master, and will transition to these

Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 25 ++++++++++++++++++++++++-
 drivers/gpu/drm/nouveau/nouveau_drv.h |  3 +++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a947e1d5f309..7e651779751d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -603,9 +603,27 @@ nouveau_drm_device_init(struct drm_device *dev)
 	if (ret)
 		goto fail_wq;
 
+	ret = nvif_device_ctor(&drm->master.base.object, "drmDevice", 0, NV_DEVICE,
+			       &(struct nv_device_v0) {
+					.device = ~0,
+					.priv = true,
+			       }, sizeof(struct nv_device_v0),
+			       &drm->device);
+	if (ret) {
+		NV_ERROR(drm, "Device allocation failed: %d\n", ret);
+		goto fail_master;
+	}
+
+	ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->master.mmu.object.oclass,
+			    &drm->mmu);
+	if (ret) {
+		NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
+		goto fail_nvif;
+	}
+
 	ret = nouveau_cli_init(drm, "DRM", &drm->client);
 	if (ret)
-		goto fail_master;
+		goto fail_nvif;
 
 	nvxx_client(&drm->client.base)->debug =
 		nvkm_dbgopt(nouveau_debug, "DRM");
@@ -669,6 +687,9 @@ nouveau_drm_device_init(struct drm_device *dev)
 fail_ttm:
 	nouveau_vga_fini(drm);
 	nouveau_cli_fini(&drm->client);
+fail_nvif:
+	nvif_mmu_dtor(&drm->mmu);
+	nvif_device_dtor(&drm->device);
 fail_master:
 	nouveau_cli_fini(&drm->master);
 fail_wq:
@@ -725,6 +746,8 @@ nouveau_drm_device_fini(struct drm_device *dev)
 	mutex_unlock(&drm->clients_lock);
 
 	nouveau_cli_fini(&drm->client);
+	nvif_mmu_dtor(&drm->mmu);
+	nvif_device_dtor(&drm->device);
 	nouveau_cli_fini(&drm->master);
 	destroy_workqueue(drm->sched_wq);
 	nvif_parent_dtor(&drm->parent);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index e239c6bf4afa..a7079efe42f3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -202,6 +202,9 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
 
 struct nouveau_drm {
 	struct nvif_parent parent;
+	struct nvif_device device;
+	struct nvif_mmu mmu;
+
 	struct nouveau_cli master;
 	struct nouveau_cli client;
 	struct drm_device *dev;
-- 
2.41.0



More information about the Nouveau mailing list