The only remaining nouveau_drm.master struct member that's being used is the mutex that protects its object tree. Move that into nouveau_drm and remove nouveau_drm.master entirely. Another patch series will make it possible to also remove the mutex, but it's still required for the moment. Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx> --- drivers/gpu/drm/nouveau/nouveau_drm.c | 42 +++++++++++---------------- drivers/gpu/drm/nouveau/nouveau_drv.h | 3 +- drivers/gpu/drm/nouveau/nouveau_mem.c | 12 ++++---- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index cfff32168fd5..74c4c1f4b22a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -208,11 +208,9 @@ nouveau_cli_fini(struct nouveau_cli *cli) nvif_mmu_dtor(&cli->mmu); cli->device.object.map.ptr = NULL; nvif_device_dtor(&cli->device); - if (cli != &cli->drm->master) { - mutex_lock(&cli->drm->master.lock); - nvif_client_dtor(&cli->base); - mutex_unlock(&cli->drm->master.lock); - } + mutex_lock(&cli->drm->client_mutex); + nvif_client_dtor(&cli->base); + mutex_unlock(&cli->drm->client_mutex); } static int @@ -245,11 +243,9 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname, INIT_LIST_HEAD(&cli->worker); mutex_init(&cli->lock); - if (cli != &drm->master) { - mutex_lock(&drm->master.lock); - ret = nvif_client_ctor(&drm->master.base, cli->name, &cli->base); - mutex_unlock(&drm->master.lock); - } + mutex_lock(&drm->client_mutex); + ret = nvif_client_ctor(&drm->_client, cli->name, &cli->base); + mutex_unlock(&drm->client_mutex); if (ret) { NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret); goto done; @@ -576,14 +572,15 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm) drm->nvkm = nvkm; nvif_parent_ctor(&nouveau_parent, &drm->parent); - drm->master.base.object.parent = &drm->parent; + mutex_init(&drm->client_mutex); + drm->_client.object.parent = &drm->parent; ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug, "drm", - nouveau_name(dev), &drm->master.base); + nouveau_name(dev), &drm->_client); if (ret) goto fail_alloc; - ret = nvif_device_ctor(&drm->master.base, "drmDevice", &drm->device); + ret = nvif_device_ctor(&drm->_client, "drmDevice", &drm->device); if (ret) { NV_ERROR(drm, "Device allocation failed: %d\n", ret); goto fail_nvif; @@ -614,13 +611,9 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm) goto fail_nvif; } - ret = nouveau_cli_init(drm, "DRM-master", &drm->master); - if (ret) - goto fail_wq; - ret = nouveau_cli_init(drm, "DRM", &drm->client); if (ret) - goto fail_master; + goto fail_wq; INIT_LIST_HEAD(&drm->clients); mutex_init(&drm->clients_lock); @@ -681,15 +674,14 @@ nouveau_drm_device_init(struct drm_device *dev, struct nvkm_device *nvkm) fail_ttm: nouveau_vga_fini(drm); nouveau_cli_fini(&drm->client); -fail_master: - nouveau_cli_fini(&drm->master); fail_wq: destroy_workqueue(drm->sched_wq); fail_nvif: nvif_mmu_dtor(&drm->mmu); nvif_device_dtor(&drm->device); - nvif_client_dtor(&drm->master.base); + nvif_client_dtor(&drm->_client); fail_alloc: + mutex_destroy(&drm->client_mutex); nvif_parent_dtor(&drm->parent); kfree(drm); return ret; @@ -741,11 +733,11 @@ nouveau_drm_device_fini(struct drm_device *dev) mutex_unlock(&drm->clients_lock); nouveau_cli_fini(&drm->client); - nouveau_cli_fini(&drm->master); destroy_workqueue(drm->sched_wq); nvif_mmu_dtor(&drm->mmu); nvif_device_dtor(&drm->device); - nvif_client_dtor(&drm->master.base); + mutex_destroy(&drm->client_mutex); + nvif_client_dtor(&drm->_client); nvif_parent_dtor(&drm->parent); mutex_destroy(&drm->clients_lock); kfree(drm); @@ -946,7 +938,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; @@ -971,7 +963,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 0b1cf2f2f9bc..c0b2bfaab4e8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -203,10 +203,11 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) struct nouveau_drm { struct nvkm_device *nvkm; struct nvif_parent parent; + struct mutex client_mutex; + struct nvif_client _client; struct nvif_device device; struct nvif_mmu mmu; - struct nouveau_cli master; struct nouveau_cli client; struct drm_device *dev; diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index b112b62dca3c..fac92fdbf9cc 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->client.vmm.vmm, &mem->vma[1]); nvif_vmm_put(&mem->drm->client.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 @@ -113,11 +113,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", mmu->mem, type, PAGE_SHIFT, reg->size, &args, sizeof(args), &mem->mem); - mutex_unlock(&drm->master.lock); + mutex_unlock(&drm->client_mutex); return ret; } @@ -130,7 +130,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page) u64 size = ALIGN(reg->size, 1 << page); int ret; - mutex_lock(&drm->master.lock); + mutex_lock(&drm->client_mutex); switch (mmu->mem) { case NVIF_CLASS_MEM_GF100: ret = nvif_mem_ctor_type(mmu, "ttmVram", mmu->mem, @@ -154,7 +154,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.44.0