[PATCH 009/156] drm/nouveau: remove nouveau_drm.master
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:37:35 UTC 2024
- preparation for upcoming api changes
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 91 +++++++++++++--------------
drivers/gpu/drm/nouveau/nouveau_drv.h | 3 +-
drivers/gpu/drm/nouveau/nouveau_mem.c | 20 +++---
3 files changed, 56 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index da5bb7c51dab..ad5de7ed48ce 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -209,9 +209,9 @@ nouveau_cli_fini(struct nouveau_cli *cli)
nouveau_vmm_fini(&cli->vmm);
nvif_mmu_dtor(&cli->mmu);
nvif_device_dtor(&cli->device);
- mutex_lock(&cli->drm->master.lock);
+ mutex_lock(&cli->drm->client_mutex);
nvif_client_dtor(&cli->base);
- mutex_unlock(&cli->drm->master.lock);
+ mutex_unlock(&cli->drm->client_mutex);
}
static int
@@ -226,13 +226,6 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
{}
};
static const struct nvif_mclass
- mmus[] = {
- { NVIF_CLASS_MMU_GF100, -1 },
- { NVIF_CLASS_MMU_NV50 , -1 },
- { NVIF_CLASS_MMU_NV04 , -1 },
- {}
- };
- static const struct nvif_mclass
vmms[] = {
{ NVIF_CLASS_VMM_GP100, -1 },
{ NVIF_CLASS_VMM_GM200, -1 },
@@ -253,15 +246,10 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
INIT_LIST_HEAD(&cli->worker);
mutex_init(&cli->lock);
- if (cli == &drm->master) {
- ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug,
- cli->name, device, &cli->base);
- } else {
- mutex_lock(&drm->master.lock);
- ret = nvif_client_ctor(&drm->master.base, cli->name, device,
- &cli->base);
- mutex_unlock(&drm->master.lock);
- }
+ mutex_lock(&drm->client_mutex);
+ ret = nvif_client_ctor(&drm->_client, cli->name, device,
+ &cli->base);
+ mutex_unlock(&drm->client_mutex);
if (ret) {
NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
goto done;
@@ -278,13 +266,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
goto done;
}
- ret = nvif_mclass(&cli->device.object, mmus);
- if (ret < 0) {
- NV_PRINTK(err, cli, "No supported MMU class\n");
- goto done;
- }
-
- ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", mmus[ret].oclass,
+ ret = nvif_mmu_ctor(&cli->device.object, "drmMmu", drm->mmu.object.oclass,
&cli->mmu);
if (ret) {
NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
@@ -581,6 +563,13 @@ nouveau_parent = {
static int
nouveau_drm_device_init(struct drm_device *dev)
{
+ static const struct nvif_mclass
+ mmus[] = {
+ { NVIF_CLASS_MMU_GF100, -1 },
+ { NVIF_CLASS_MMU_NV50 , -1 },
+ { NVIF_CLASS_MMU_NV04 , -1 },
+ {}
+ };
struct nouveau_drm *drm;
int ret;
@@ -590,20 +579,16 @@ nouveau_drm_device_init(struct drm_device *dev)
drm->dev = dev;
nvif_parent_ctor(&nouveau_parent, &drm->parent);
- drm->master.base.object.parent = &drm->parent;
- drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0,
- WQ_MAX_ACTIVE);
- if (!drm->sched_wq) {
- ret = -ENOMEM;
- goto fail_alloc;
- }
+ mutex_init(&drm->client_mutex);
+ drm->_client.object.parent = &drm->parent;
- ret = nouveau_cli_init(drm, "DRM-master", &drm->master);
+ ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug, "drm", nouveau_name(dev),
+ &drm->_client);
if (ret)
- goto fail_wq;
+ goto fail_alloc;
- ret = nvif_device_ctor(&drm->master.base.object, "drmDevice", 0, NV_DEVICE,
+ ret = nvif_device_ctor(&drm->_client.object, "drmDevice", 0, NV_DEVICE,
&(struct nv_device_v0) {
.device = ~0,
.priv = true,
@@ -611,19 +596,31 @@ nouveau_drm_device_init(struct drm_device *dev)
&drm->device);
if (ret) {
NV_ERROR(drm, "Device allocation failed: %d\n", ret);
- goto fail_master;
+ goto fail_nvif;
+ }
+
+ ret = nvif_mclass(&drm->device.object, mmus);
+ if (ret < 0) {
+ NV_ERROR(drm, "No supported MMU class\n");
+ goto fail_nvif;
}
- ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", drm->master.mmu.object.oclass,
- &drm->mmu);
+ ret = nvif_mmu_ctor(&drm->device.object, "drmMmu", mmus[ret].oclass, &drm->mmu);
if (ret) {
NV_ERROR(drm, "MMU allocation failed: %d\n", ret);
goto fail_nvif;
}
+ drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0,
+ WQ_MAX_ACTIVE);
+ if (!drm->sched_wq) {
+ ret = -ENOMEM;
+ goto fail_nvif;
+ }
+
ret = nouveau_cli_init(drm, "DRM", &drm->cli);
if (ret)
- goto fail_nvif;
+ goto fail_wq;
nvxx_client(&drm->client.base)->debug =
nvkm_dbgopt(nouveau_debug, "DRM");
@@ -687,14 +684,14 @@ nouveau_drm_device_init(struct drm_device *dev)
fail_ttm:
nouveau_vga_fini(drm);
nouveau_cli_fini(&drm->cli);
+fail_wq:
+ destroy_workqueue(drm->sched_wq);
fail_nvif:
nvif_mmu_dtor(&drm->mmu);
nvif_device_dtor(&drm->device);
-fail_master:
- nouveau_cli_fini(&drm->master);
-fail_wq:
- destroy_workqueue(drm->sched_wq);
+ nvif_client_dtor(&drm->_client);
fail_alloc:
+ mutex_destroy(&drm->client_mutex);
nvif_parent_dtor(&drm->parent);
kfree(drm);
return ret;
@@ -746,10 +743,10 @@ nouveau_drm_device_fini(struct drm_device *dev)
mutex_unlock(&drm->clients_lock);
nouveau_cli_fini(&drm->cli);
+ destroy_workqueue(drm->sched_wq);
nvif_mmu_dtor(&drm->mmu);
nvif_device_dtor(&drm->device);
- nouveau_cli_fini(&drm->master);
- destroy_workqueue(drm->sched_wq);
+ mutex_destroy(&drm->client_mutex);
nvif_parent_dtor(&drm->parent);
mutex_destroy(&drm->clients_lock);
kfree(drm);
@@ -962,7 +959,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
}
NV_DEBUG(drm, "suspending object tree...\n");
- ret = nvif_client_suspend(&drm->master.base);
+ ret = nvif_client_suspend(&drm->_client);
if (ret)
goto fail_client;
@@ -987,7 +984,7 @@ nouveau_do_resume(struct drm_device *dev, bool runtime)
struct nouveau_drm *drm = nouveau_drm(dev);
NV_DEBUG(drm, "resuming object tree...\n");
- ret = nvif_client_resume(&drm->master.base);
+ ret = nvif_client_resume(&drm->_client);
if (ret) {
NV_ERROR(drm, "Client resume failed with error: %d\n", ret);
return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 8f04f3630936..683600db4ff9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -202,10 +202,11 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
struct nouveau_drm {
struct nvif_parent parent;
+ struct mutex client_mutex;
+ struct nvif_client _client;
struct nvif_device device;
struct nvif_mmu mmu;
- struct nouveau_cli master;
union {
struct nouveau_cli client;
struct nouveau_cli cli;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 4d9ac9f30f05..baea74899fcf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -80,9 +80,9 @@ nouveau_mem_fini(struct nouveau_mem *mem)
{
nvif_vmm_put(&mem->drm->cli.vmm.vmm, &mem->vma[1]);
nvif_vmm_put(&mem->drm->cli.vmm.vmm, &mem->vma[0]);
- mutex_lock(&mem->drm->master.lock);
+ mutex_lock(&mem->drm->client_mutex);
nvif_mem_dtor(&mem->mem);
- mutex_unlock(&mem->drm->master.lock);
+ mutex_unlock(&mem->drm->client_mutex);
}
int
@@ -90,8 +90,8 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
{
struct nouveau_mem *mem = nouveau_mem(reg);
struct nouveau_drm *drm = mem->drm;
- struct nouveau_cli *cli = &drm->master;
- struct nvif_mmu *mmu = &cli->mmu;
+ struct nouveau_cli *cli = &drm->cli;
+ struct nvif_mmu *mmu = &drm->mmu;
struct nvif_mem_ram_v0 args = {};
u8 type;
int ret;
@@ -114,11 +114,11 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
else
args.dma = tt->dma_address;
- mutex_lock(&drm->master.lock);
+ mutex_lock(&drm->client_mutex);
ret = nvif_mem_ctor_type(mmu, "ttmHostMem", cli->mem->oclass, type, PAGE_SHIFT,
reg->size,
&args, sizeof(args), &mem->mem);
- mutex_unlock(&drm->master.lock);
+ mutex_unlock(&drm->client_mutex);
return ret;
}
@@ -127,12 +127,12 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
{
struct nouveau_mem *mem = nouveau_mem(reg);
struct nouveau_drm *drm = mem->drm;
- struct nouveau_cli *cli = &drm->master;
- struct nvif_mmu *mmu = &cli->mmu;
+ struct nouveau_cli *cli = &drm->cli;
+ struct nvif_mmu *mmu = &drm->mmu;
u64 size = ALIGN(reg->size, 1 << page);
int ret;
- mutex_lock(&drm->master.lock);
+ mutex_lock(&drm->client_mutex);
switch (cli->mem->oclass) {
case NVIF_CLASS_MEM_GF100:
ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
@@ -156,7 +156,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
WARN_ON(1);
break;
}
- mutex_unlock(&drm->master.lock);
+ mutex_unlock(&drm->client_mutex);
reg->start = mem->mem.addr >> PAGE_SHIFT;
return ret;
--
2.41.0
More information about the Nouveau
mailing list