Commit 034142a3 authored by Ben Skeggs's avatar Ben Skeggs Committed by Danilo Krummrich

drm/nouveau: remove master

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.

A pending series to remove the "ioctl" layer between DRM and NVKM also
removes the need for object handle lookups, and hence this mutex, but
it's still required for the moment.
Signed-off-by: default avatarBen Skeggs <bskeggs@nvidia.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240726043828.58966-35-bskeggs@nvidia.com
parent 3543e84e
...@@ -208,11 +208,9 @@ nouveau_cli_fini(struct nouveau_cli *cli) ...@@ -208,11 +208,9 @@ nouveau_cli_fini(struct nouveau_cli *cli)
nvif_mmu_dtor(&cli->mmu); nvif_mmu_dtor(&cli->mmu);
cli->device.object.map.ptr = NULL; cli->device.object.map.ptr = NULL;
nvif_device_dtor(&cli->device); nvif_device_dtor(&cli->device);
if (cli != &cli->drm->master) { mutex_lock(&cli->drm->client_mutex);
mutex_lock(&cli->drm->master.lock); nvif_client_dtor(&cli->base);
nvif_client_dtor(&cli->base); mutex_unlock(&cli->drm->client_mutex);
mutex_unlock(&cli->drm->master.lock);
}
} }
static int static int
...@@ -245,11 +243,9 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname, ...@@ -245,11 +243,9 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
INIT_LIST_HEAD(&cli->worker); INIT_LIST_HEAD(&cli->worker);
mutex_init(&cli->lock); mutex_init(&cli->lock);
if (cli != &drm->master) { mutex_lock(&drm->client_mutex);
mutex_lock(&drm->master.lock); ret = nvif_client_ctor(&drm->_client, cli->name, &cli->base);
ret = nvif_client_ctor(&drm->master.base, cli->name, &cli->base); mutex_unlock(&drm->client_mutex);
mutex_unlock(&drm->master.lock);
}
if (ret) { if (ret) {
NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret); NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
goto done; goto done;
...@@ -602,7 +598,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) ...@@ -602,7 +598,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm)
mutex_unlock(&drm->clients_lock); mutex_unlock(&drm->clients_lock);
nouveau_cli_fini(&drm->client); nouveau_cli_fini(&drm->client);
nouveau_cli_fini(&drm->master);
destroy_workqueue(drm->sched_wq); destroy_workqueue(drm->sched_wq);
mutex_destroy(&drm->clients_lock); mutex_destroy(&drm->clients_lock);
} }
...@@ -618,13 +613,9 @@ nouveau_drm_device_init(struct nouveau_drm *drm) ...@@ -618,13 +613,9 @@ nouveau_drm_device_init(struct nouveau_drm *drm)
if (!drm->sched_wq) if (!drm->sched_wq)
return -ENOMEM; return -ENOMEM;
ret = nouveau_cli_init(drm, "DRM-master", &drm->master);
if (ret)
goto fail_wq;
ret = nouveau_cli_init(drm, "DRM", &drm->client); ret = nouveau_cli_init(drm, "DRM", &drm->client);
if (ret) if (ret)
goto fail_master; goto fail_wq;
INIT_LIST_HEAD(&drm->clients); INIT_LIST_HEAD(&drm->clients);
mutex_init(&drm->clients_lock); mutex_init(&drm->clients_lock);
...@@ -691,8 +682,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm) ...@@ -691,8 +682,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm)
fail_ttm: fail_ttm:
nouveau_vga_fini(drm); nouveau_vga_fini(drm);
nouveau_cli_fini(&drm->client); nouveau_cli_fini(&drm->client);
fail_master:
nouveau_cli_fini(&drm->master);
fail_wq: fail_wq:
destroy_workqueue(drm->sched_wq); destroy_workqueue(drm->sched_wq);
return ret; return ret;
...@@ -706,9 +695,10 @@ nouveau_drm_device_del(struct nouveau_drm *drm) ...@@ -706,9 +695,10 @@ nouveau_drm_device_del(struct nouveau_drm *drm)
nvif_mmu_dtor(&drm->mmu); nvif_mmu_dtor(&drm->mmu);
nvif_device_dtor(&drm->device); nvif_device_dtor(&drm->device);
nvif_client_dtor(&drm->master.base); nvif_client_dtor(&drm->_client);
nvif_parent_dtor(&drm->parent); nvif_parent_dtor(&drm->parent);
mutex_destroy(&drm->client_mutex);
kfree(drm); kfree(drm);
} }
...@@ -742,14 +732,15 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren ...@@ -742,14 +732,15 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
dev_set_drvdata(parent, drm); dev_set_drvdata(parent, drm);
nvif_parent_ctor(&nouveau_parent, &drm->parent); 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", ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug, "drm",
nouveau_name(drm->dev), &drm->master.base); nouveau_name(drm->dev), &drm->_client);
if (ret) if (ret)
goto done; goto done;
ret = nvif_device_ctor(&drm->master.base, "drmDevice", &drm->device); ret = nvif_device_ctor(&drm->_client, "drmDevice", &drm->device);
if (ret) { if (ret) {
NV_ERROR(drm, "Device allocation failed: %d\n", ret); NV_ERROR(drm, "Device allocation failed: %d\n", ret);
goto done; goto done;
...@@ -966,7 +957,7 @@ nouveau_do_suspend(struct nouveau_drm *drm, bool runtime) ...@@ -966,7 +957,7 @@ nouveau_do_suspend(struct nouveau_drm *drm, bool runtime)
} }
NV_DEBUG(drm, "suspending object tree...\n"); NV_DEBUG(drm, "suspending object tree...\n");
ret = nvif_client_suspend(&drm->master.base); ret = nvif_client_suspend(&drm->_client);
if (ret) if (ret)
goto fail_client; goto fail_client;
...@@ -991,7 +982,7 @@ nouveau_do_resume(struct nouveau_drm *drm, bool runtime) ...@@ -991,7 +982,7 @@ nouveau_do_resume(struct nouveau_drm *drm, bool runtime)
int ret = 0; int ret = 0;
NV_DEBUG(drm, "resuming object tree...\n"); NV_DEBUG(drm, "resuming object tree...\n");
ret = nvif_client_resume(&drm->master.base); ret = nvif_client_resume(&drm->_client);
if (ret) { if (ret) {
NV_ERROR(drm, "Client resume failed with error: %d\n", ret); NV_ERROR(drm, "Client resume failed with error: %d\n", ret);
return ret; return ret;
......
...@@ -203,10 +203,11 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) ...@@ -203,10 +203,11 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
struct nouveau_drm { struct nouveau_drm {
struct nvkm_device *nvkm; struct nvkm_device *nvkm;
struct nvif_parent parent; struct nvif_parent parent;
struct mutex client_mutex;
struct nvif_client _client;
struct nvif_device device; struct nvif_device device;
struct nvif_mmu mmu; struct nvif_mmu mmu;
struct nouveau_cli master;
struct nouveau_cli client; struct nouveau_cli client;
struct drm_device *dev; struct drm_device *dev;
......
...@@ -80,9 +80,9 @@ nouveau_mem_fini(struct nouveau_mem *mem) ...@@ -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[1]);
nvif_vmm_put(&mem->drm->client.vmm.vmm, &mem->vma[0]); 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); nvif_mem_dtor(&mem->mem);
mutex_unlock(&mem->drm->master.lock); mutex_unlock(&mem->drm->client_mutex);
} }
int int
...@@ -113,11 +113,11 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt) ...@@ -113,11 +113,11 @@ nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
else else
args.dma = tt->dma_address; 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, ret = nvif_mem_ctor_type(mmu, "ttmHostMem", mmu->mem, type, PAGE_SHIFT,
reg->size, reg->size,
&args, sizeof(args), &mem->mem); &args, sizeof(args), &mem->mem);
mutex_unlock(&drm->master.lock); mutex_unlock(&drm->client_mutex);
return ret; return ret;
} }
...@@ -130,7 +130,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page) ...@@ -130,7 +130,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
u64 size = ALIGN(reg->size, 1 << page); u64 size = ALIGN(reg->size, 1 << page);
int ret; int ret;
mutex_lock(&drm->master.lock); mutex_lock(&drm->client_mutex);
switch (mmu->mem) { switch (mmu->mem) {
case NVIF_CLASS_MEM_GF100: case NVIF_CLASS_MEM_GF100:
ret = nvif_mem_ctor_type(mmu, "ttmVram", mmu->mem, ret = nvif_mem_ctor_type(mmu, "ttmVram", mmu->mem,
...@@ -154,7 +154,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page) ...@@ -154,7 +154,7 @@ nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
WARN_ON(1); WARN_ON(1);
break; break;
} }
mutex_unlock(&drm->master.lock); mutex_unlock(&drm->client_mutex);
reg->start = mem->mem.addr >> PAGE_SHIFT; reg->start = mem->mem.addr >> PAGE_SHIFT;
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment