All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhi Wang <zhiw@nvidia.com>
To: Ben Skeggs <bskeggs@nvidia.com>
Cc: <nouveau@lists.freedesktop.org>
Subject: Re: [PATCH v3 24/37] drm/nouveau: always map device
Date: Wed, 31 Jul 2024 20:21:13 +0300	[thread overview]
Message-ID: <20240731202113.00004bdf.zhiw@nvidia.com> (raw)
In-Reply-To: <20240726043828.58966-25-bskeggs@nvidia.com>

On Fri, 26 Jul 2024 14:38:15 +1000
Ben Skeggs <bskeggs@nvidia.com> wrote:

Reviewed-by: Zhi Wang <zhiw@nvidia.com>

I agree that to always map the device so that we can remove extra rd/wr
callbacks in patch 25 and patch 26.

Would you mind to point me the patch you mentioned to clean up this
later as well? I am interested to see the fate of this newly added
function.

> The next commit removes the nvif rd/wr methods from nvif_device, which
> were probably a bad idea, and mostly intended as a fallback if
> ioremap() failed (or wasn't available, as was the case in some tools
> I once used).
> 
> The nv04 KMS driver already mapped the device, because it's mostly
> been kept alive on life-support for many years and still directly
> bashes PRI a lot for modesetting.
> 
> Post-nv50, I tried pretty hard to keep PRI accesses out of the DRM
> code, but there's still a few random places where we do, and those
> were using the rd/wr paths prior to this commit.
> 
> This allocates and maps a new nvif_device (which will replace the
> usage of nouveau_drm.master.device later on), and replicates this
> pointer to all other possible users.
> 
> This will be cleaned up by the end of another patch series, after it's
> been made safe to do so.
> 
> Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
> ---
>  drivers/gpu/drm/nouveau/dispnv04/disp.c       |  5 -----
>  drivers/gpu/drm/nouveau/include/nvif/device.h |  1 +
>  drivers/gpu/drm/nouveau/nouveau_drm.c         | 16 ++++++++++++++++
>  drivers/gpu/drm/nouveau/nouveau_drv.h         |  2 ++
>  drivers/gpu/drm/nouveau/nvif/device.c         |  6 ++++++
>  5 files changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c
> b/drivers/gpu/drm/nouveau/dispnv04/disp.c index
> 13705c5f1497..e8b27bb135e7 100644 ---
> a/drivers/gpu/drm/nouveau/dispnv04/disp.c +++
> b/drivers/gpu/drm/nouveau/dispnv04/disp.c @@ -189,7 +189,6 @@ static
> void nv04_display_destroy(struct drm_device *dev)
>  {
>  	struct nv04_display *disp = nv04_display(dev);
> -	struct nouveau_drm *drm = nouveau_drm(dev);
>  	struct nouveau_encoder *encoder;
>  	struct nouveau_crtc *nv_crtc;
>  
> @@ -206,8 +205,6 @@ nv04_display_destroy(struct drm_device *dev)
>  
>  	nouveau_display(dev)->priv = NULL;
>  	vfree(disp);
> -
> -	nvif_object_unmap(&drm->client.device.object);
>  }
>  
>  int
> @@ -229,8 +226,6 @@ nv04_display_create(struct drm_device *dev)
>  
>  	disp->drm = drm;
>  
> -	nvif_object_map(&drm->client.device.object, NULL, 0);
> -
>  	nouveau_display(dev)->priv = disp;
>  	nouveau_display(dev)->dtor = nv04_display_destroy;
>  	nouveau_display(dev)->init = nv04_display_init;
> diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h
> b/drivers/gpu/drm/nouveau/include/nvif/device.h index
> f7c1b3a43c84..fec76f4733a4 100644 ---
> a/drivers/gpu/drm/nouveau/include/nvif/device.h +++
> b/drivers/gpu/drm/nouveau/include/nvif/device.h @@ -20,6 +20,7 @@
> struct nvif_device { 
>  int  nvif_device_ctor(struct nvif_client *, const char *name, struct
> nvif_device *); void nvif_device_dtor(struct nvif_device *);
> +int  nvif_device_map(struct nvif_device *);
>  u64  nvif_device_time(struct nvif_device *);
>  
>  /*XXX*/
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
> b/drivers/gpu/drm/nouveau/nouveau_drm.c index
> 22cdd987dd2f..316f7877047d 100644 ---
> a/drivers/gpu/drm/nouveau/nouveau_drm.c +++
> b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -206,6 +206,7 @@
> nouveau_cli_fini(struct nouveau_cli *cli) nouveau_vmm_fini(&cli->svm);
>  	nouveau_vmm_fini(&cli->vmm);
>  	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);
> @@ -267,6 +268,8 @@ nouveau_cli_init(struct nouveau_drm *drm, const
> char *sname, goto done;
>  	}
>  
> +	cli->device.object.map.ptr = drm->device.object.map.ptr;
> +
>  	ret = nvif_mclass(&cli->device.object, mmus);
>  	if (ret < 0) {
>  		NV_PRINTK(err, cli, "No supported MMU class\n");
> @@ -715,6 +718,7 @@ nouveau_drm_device_del(struct nouveau_drm *drm)
>  	if (drm->dev)
>  		drm_dev_put(drm->dev);
>  
> +	nvif_device_dtor(&drm->device);
>  	nvif_client_dtor(&drm->master.base);
>  	nvif_parent_dtor(&drm->parent);
>  
> @@ -751,6 +755,18 @@ nouveau_drm_device_new(const struct drm_driver
> *drm_driver, struct device *paren if (ret)
>  		goto done;
>  
> +	ret = nvif_device_ctor(&drm->master.base, "drmDevice",
> &drm->device);
> +	if (ret) {
> +		NV_ERROR(drm, "Device allocation failed: %d\n", ret);
> +		goto done;
> +	}
> +
> +	ret = nvif_device_map(&drm->device);
> +	if (ret) {
> +		NV_ERROR(drm, "Failed to map PRI: %d\n", ret);
> +		goto done;
> +	}
> +
>  done:
>  	if (ret) {
>  		nouveau_drm_device_del(drm);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h
> b/drivers/gpu/drm/nouveau/nouveau_drv.h index
> e7d072a9a477..80ffe15ba76b 100644 ---
> a/drivers/gpu/drm/nouveau/nouveau_drv.h +++
> b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -203,6 +203,8 @@
> u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
> struct nouveau_drm { struct nvkm_device *nvkm;
>  	struct nvif_parent parent;
> +	struct nvif_device device;
> +
>  	struct nouveau_cli master;
>  	struct nouveau_cli client;
>  	struct drm_device *dev;
> diff --git a/drivers/gpu/drm/nouveau/nvif/device.c
> b/drivers/gpu/drm/nouveau/nvif/device.c index
> b14bccb9a93f..24880931039f 100644 ---
> a/drivers/gpu/drm/nouveau/nvif/device.c +++
> b/drivers/gpu/drm/nouveau/nvif/device.c @@ -38,6 +38,12 @@
> nvif_device_time(struct nvif_device *device) return
> device->user.func->time(&device->user); }
>  
> +int
> +nvif_device_map(struct nvif_device *device)
> +{
> +	return nvif_object_map(&device->object, NULL, 0);
> +}
> +
>  void
>  nvif_device_dtor(struct nvif_device *device)
>  {


  reply	other threads:[~2024-09-29 21:29 UTC|newest]

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

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=20240731202113.00004bdf.zhiw@nvidia.com \
    --to=zhiw@nvidia.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.