Commit ea94c8e2 authored by Ben Skeggs's avatar Ben Skeggs Committed by Danilo Krummrich

drm/nouveau: move allocation of root client out of nouveau_cli_init()

drm->master isn't really a nouveau_cli, and is mostly just used to get
at an nvif_mmu object to implement a hack around issues with the ioctl
interface to nvkm.

Later patches in this series allocate nvif_device/mmu objects in
nouveau_drm directly, removing the need for master.

A pending series to remove the "ioctl" layer between DRM and NVKM
removes the need for the above-mentioned hack entirely.

The only other member of drm->master that's needed is the nvif_client,
and is a dependency of device/mmu.  So the first step is to move its
allocation out of code handling nouveau_cli init.

v2:
- modified slightly due to the addition of tegra/pci cleanup patches
v3:
- move nvif init below drm_dev_alloc() to avoid changing nouveau_name()
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-7-bskeggs@nvidia.com
parent 6777264d
...@@ -209,9 +209,11 @@ nouveau_cli_fini(struct nouveau_cli *cli) ...@@ -209,9 +209,11 @@ nouveau_cli_fini(struct nouveau_cli *cli)
nouveau_vmm_fini(&cli->vmm); nouveau_vmm_fini(&cli->vmm);
nvif_mmu_dtor(&cli->mmu); nvif_mmu_dtor(&cli->mmu);
nvif_device_dtor(&cli->device); nvif_device_dtor(&cli->device);
if (cli != &cli->drm->master) {
mutex_lock(&cli->drm->master.lock); mutex_lock(&cli->drm->master.lock);
nvif_client_dtor(&cli->base); nvif_client_dtor(&cli->base);
mutex_unlock(&cli->drm->master.lock); mutex_unlock(&cli->drm->master.lock);
}
} }
static int static int
...@@ -253,10 +255,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname, ...@@ -253,10 +255,7 @@ 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) { if (cli != &drm->master) {
ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug,
cli->name, device, &cli->base);
} else {
mutex_lock(&drm->master.lock); mutex_lock(&drm->master.lock);
ret = nvif_client_ctor(&drm->master.base, cli->name, device, ret = nvif_client_ctor(&drm->master.base, cli->name, device,
&cli->base); &cli->base);
...@@ -626,7 +625,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm) ...@@ -626,7 +625,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm)
nouveau_cli_fini(&drm->client); nouveau_cli_fini(&drm->client);
nouveau_cli_fini(&drm->master); nouveau_cli_fini(&drm->master);
destroy_workqueue(drm->sched_wq); destroy_workqueue(drm->sched_wq);
nvif_parent_dtor(&drm->parent);
mutex_destroy(&drm->clients_lock); mutex_destroy(&drm->clients_lock);
} }
...@@ -636,15 +634,10 @@ nouveau_drm_device_init(struct nouveau_drm *drm) ...@@ -636,15 +634,10 @@ nouveau_drm_device_init(struct nouveau_drm *drm)
struct drm_device *dev = drm->dev; struct drm_device *dev = drm->dev;
int ret; int ret;
nvif_parent_ctor(&nouveau_parent, &drm->parent);
drm->master.base.object.parent = &drm->parent;
drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0, drm->sched_wq = alloc_workqueue("nouveau_sched_wq_shared", 0,
WQ_MAX_ACTIVE); WQ_MAX_ACTIVE);
if (!drm->sched_wq) { if (!drm->sched_wq)
ret = -ENOMEM; return -ENOMEM;
goto fail_alloc;
}
ret = nouveau_cli_init(drm, "DRM-master", &drm->master); ret = nouveau_cli_init(drm, "DRM-master", &drm->master);
if (ret) if (ret)
...@@ -726,8 +719,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm) ...@@ -726,8 +719,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm)
nouveau_cli_fini(&drm->master); nouveau_cli_fini(&drm->master);
fail_wq: fail_wq:
destroy_workqueue(drm->sched_wq); destroy_workqueue(drm->sched_wq);
fail_alloc:
nvif_parent_dtor(&drm->parent);
return ret; return ret;
} }
...@@ -737,6 +728,9 @@ nouveau_drm_device_del(struct nouveau_drm *drm) ...@@ -737,6 +728,9 @@ nouveau_drm_device_del(struct nouveau_drm *drm)
if (drm->dev) if (drm->dev)
drm_dev_put(drm->dev); drm_dev_put(drm->dev);
nvif_client_dtor(&drm->master.base);
nvif_parent_dtor(&drm->parent);
kfree(drm); kfree(drm);
} }
...@@ -762,6 +756,14 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren ...@@ -762,6 +756,14 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
drm->dev->dev_private = drm; drm->dev->dev_private = drm;
dev_set_drvdata(parent, drm); dev_set_drvdata(parent, drm);
nvif_parent_ctor(&nouveau_parent, &drm->parent);
drm->master.base.object.parent = &drm->parent;
ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug, "drm",
nouveau_name(drm->dev), &drm->master.base);
if (ret)
goto done;
done: done:
if (ret) { if (ret) {
nouveau_drm_device_del(drm); nouveau_drm_device_del(drm);
......
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