All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@redhat.com>
To: Ben Skeggs <bskeggs@nvidia.com>
Cc: nouveau@lists.freedesktop.org
Subject: Re: [PATCH v2 34/37] drm/nouveau: remove master
Date: Tue, 9 Jul 2024 18:38:45 +0200	[thread overview]
Message-ID: <Zo1nlfrtZjPtHC6V@pollux> (raw)
In-Reply-To: <20240704183721.25778-35-bskeggs@nvidia.com>

On Fri, Jul 05, 2024 at 04:37:18AM +1000, Ben Skeggs wrote:
> 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.

It would be good to also mention what we're left with to protect and how we get
rid of that later on.

> 
> Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 39 +++++++++++----------------
>  drivers/gpu/drm/nouveau/nouveau_drv.h |  3 ++-
>  drivers/gpu/drm/nouveau/nouveau_mem.c | 12 ++++-----
>  3 files changed, 23 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index c6c9a528783a..85214d35fd5d 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;
> @@ -602,7 +598,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm)
>  	mutex_unlock(&drm->clients_lock);
>  
>  	nouveau_cli_fini(&drm->client);
> -	nouveau_cli_fini(&drm->master);
>  	destroy_workqueue(drm->sched_wq);
>  	mutex_destroy(&drm->clients_lock);
>  }
> @@ -618,13 +613,9 @@ nouveau_drm_device_init(struct nouveau_drm *drm)
>  	if (!drm->sched_wq)
>  		return -ENOMEM;
>  
> -	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);
> @@ -691,8 +682,6 @@ nouveau_drm_device_init(struct nouveau_drm *drm)
>  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);
>  	return ret;
> @@ -706,9 +695,10 @@ nouveau_drm_device_del(struct nouveau_drm *drm)
>  
>  	nvif_mmu_dtor(&drm->mmu);
>  	nvif_device_dtor(&drm->device);
> -	nvif_client_dtor(&drm->master.base);
> +	nvif_client_dtor(&drm->_client);
>  	nvif_parent_dtor(&drm->parent);
>  
> +	mutex_destroy(&drm->client_mutex);
>  	kfree(drm);
>  }
>  
> @@ -733,14 +723,15 @@ nouveau_drm_device_new(const struct drm_driver *drm_driver, struct device *paren
>  	drm->nvkm = device;
>  
>  	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(parent), &drm->master.base);
> +			       nouveau_name(parent), &drm->_client);
>  	if (ret)
>  		goto done;
>  
> -	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 done;
> @@ -966,7 +957,7 @@ nouveau_do_suspend(struct nouveau_drm *drm, 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;
>  
> @@ -991,7 +982,7 @@ nouveau_do_resume(struct nouveau_drm *drm, bool runtime)
>  	int ret = 0;
>  
>  	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 2535a50b99f3..630463668a76 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.45.1
> 


  reply	other threads:[~2024-07-09 16:38 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04 18:36 [PATCH v2 00/37] drm/nouveau: misc. cleanups and removal of unused apis Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 01/37] drm/nouveau: move nouveau_drm_device_fini() above init() Ben Skeggs
2024-07-09 14:48   ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 02/37] drm/nouveau: handle pci/tegra drm_dev_{alloc, register} from common code Ben Skeggs
2024-07-09 15:16   ` Danilo Krummrich
2024-07-18  7:14     ` Ben Skeggs
2024-07-19 11:10       ` Danilo Krummrich
2024-07-26  4:27         ` Ben Skeggs
2024-07-26 15:41           ` Danilo Krummrich
2024-07-26 13:07             ` Ben Skeggs
2024-07-27  1:54               ` Danilo Krummrich
2024-07-28 18:13               ` Jason Gunthorpe
2024-07-28 21:34                 ` Danilo Krummrich
2024-07-28 23:04                   ` Jason Gunthorpe
2024-07-29  0:55                     ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 03/37] drm/nouveau: replace drm_device* with nouveau_drm* as dev drvdata Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 04/37] drm/nouveau: create pci device once Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 05/37] drm/nouveau: store nvkm_device pointer in nouveau_drm Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 06/37] drm/nouveau: move allocation of root client out of nouveau_cli_init() Ben Skeggs
2024-07-09 15:33   ` Danilo Krummrich
2024-07-18  7:29     ` Ben Skeggs
2024-07-19 11:37       ` Danilo Krummrich
2024-07-26  4:29         ` Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 07/37] drm/nouveau: add nouveau_cli to nouveau_abi16 Ben Skeggs
2024-07-09 15:36   ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 08/37] drm/nouveau: handle limited nvif ioctl in abi16 Ben Skeggs
2024-07-09 16:03   ` Danilo Krummrich
2024-07-18  7:43     ` Ben Skeggs
2024-07-19 12:06       ` Danilo Krummrich
2024-07-04 18:36 ` [PATCH v2 09/37] drm/nouveau: remove abi16->device Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 10/37] drm/nouveau: remove abi16->handles Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 11/37] drm/nouveau/nvkm: remove detect/mmio/subdev_mask from device args Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 12/37] drm/nouveau/nvkm: remove perfmon Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 13/37] drm/nouveau/nvkm: remove nvkm_client_search() Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 14/37] drm/nouveau/nvif: remove support for userspace backends Ben Skeggs
2024-07-04 18:36 ` [PATCH v2 15/37] drm/nouveau/nvif: remove route/token Ben Skeggs
2024-07-09 16:11   ` Danilo Krummrich
2024-07-18  7:52     ` Ben Skeggs
2024-07-19 12:12       ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 16/37] drm/nouveau/nvif: remove nvxx_object() Ben Skeggs
2024-07-09 16:14   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 17/37] drm/nouveau/nvif: remove nvxx_client() Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 18/37] drm/nouveau/nvif: remove driver keep/fini Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 19/37] drm/nouveau/nvif: remove client device arg Ben Skeggs
2024-07-09 16:16   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 20/37] drm/nouveau/nvif: remove client version Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 21/37] drm/nouveau/nvif: remove client devlist Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 22/37] drm/nouveau/nvif: remove client fini Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 23/37] drm/nouveau/nvif: remove device args Ben Skeggs
2024-07-09 16:18   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 24/37] drm/nouveau: always map device Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 25/37] drm/nouveau/nvif: remove device rd/wr Ben Skeggs
2024-07-09 16:22   ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 26/37] drm/nouveau/nvif: remove disp chan rd/wr Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 27/37] drm/nouveau: move nvxx_* definitions to nouveau_drv.h Ben Skeggs
2024-07-09 16:31   ` Danilo Krummrich
2024-07-18  7:58     ` Ben Skeggs
2024-07-19 12:28       ` Danilo Krummrich
2024-07-26  4:35         ` Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 28/37] drm/nouveau: add nvif_mmu to nouveau_drm Ben Skeggs
2024-07-09 16:34   ` Danilo Krummrich
2024-07-18  8:10     ` Ben Skeggs
2024-07-19 12:47       ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 29/37] drm/nouveau: pass drm to nouveau_mem_new(), instead of cli Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 30/37] drm/nouveau: pass drm to nv50_dmac_create(), rather than device+disp Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 31/37] drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 32/37] drm/nouveau: remove nouveau_chan.device Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 33/37] drm/nouveau: remove chan->drm Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 34/37] drm/nouveau: remove master Ben Skeggs
2024-07-09 16:38   ` Danilo Krummrich [this message]
2024-07-18  8:12     ` Ben Skeggs
2024-07-19 12:49       ` Danilo Krummrich
2024-07-04 18:37 ` [PATCH v2 35/37] drm/nouveau: remove push pointer from nouveau_channel Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 36/37] drm/nouveau/kms: remove a few unused struct members and fn decls Ben Skeggs
2024-07-04 18:37 ` [PATCH v2 37/37] drm/nouveau/kms: remove push pointer from nv50_dmac Ben Skeggs
2024-07-09 14:44 ` [PATCH v2 00/37] drm/nouveau: misc. cleanups and removal of unused apis Danilo Krummrich
2024-07-18  7:00   ` Ben Skeggs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zo1nlfrtZjPtHC6V@pollux \
    --to=dakr@redhat.com \
    --cc=bskeggs@nvidia.com \
    --cc=nouveau@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.