From: sashiko-bot@kernel.org
To: "Dave Airlie" <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] nouveau/instmem: use iomapping interface for instmem handling (v3)
Date: Mon, 06 Jul 2026 03:16:08 +0000 [thread overview]
Message-ID: <20260706031609.4A6FD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706030520.857104-1-airlied@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional execution of io_mapping_init_wc() in check_io_mapping() causes severe ioremap_wc memory leaks during BAR2 bootstrapping.
--
commit 17419e048ef493385192b9b14726d1e9ad616fed
Author: Dave Airlie <airlied@redhat.com>
nouveau/instmem: use iomapping interface for instmem handling (v3)
This replaces constant ioremapping with the io_mapping interface to avoid
the constant need to ioremap when instobjs move. It delays creating the
mapping until first use to avoid resource mapping errors with simpledrm.
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
> index 6fbaa1e5876dc..f4489efc94a79 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
[ ... ]
> @@ -188,6 +190,16 @@ nv50_instobj_map(struct nvkm_memory *memory, u64 offset, struct nvkm_vmm *vmm,
> return nvkm_memory_map(memory, offset, vmm, vma, argv, argc);
> }
>
> +static bool
> +check_io_mapping(struct nv50_instmem *imem)
> +{
> + struct nvkm_device *device = imem->base.subdev.device;
> +
> + return io_mapping_init_wc(&imem->iomap,
> + device->func->resource_addr(device, NVKM_BAR2_INST),
> + device->func->resource_size(device, NVKM_BAR2_INST)) != NULL;
> +}
> +
[Severity: High]
Does this unconditionally initialize the mapping and leak the previous
ioremap_wc allocation if called more than once?
Since nv50_instobj_boot() acts as the .boot callback for BAR2 page tables,
it is invoked for every leaf page table during VMM bootstrap. Because BAR2
typically spans multiple page tables, check_io_mapping() gets executed
multiple times in a loop.
Should this check if the mapping is already initialized (e.g., checking if
imem->iomap.size is non-zero) before calling io_mapping_init_wc() to avoid
leaking the vmalloc space?
> static void
> nv50_instobj_release(struct nvkm_memory *memory)
> {
[ ... ]
> @@ -277,7 +289,12 @@ nv50_instobj_boot(struct nvkm_memory *memory, struct nvkm_vmm *vmm)
> iobj->lru.next = NULL;
> }
>
> - nv50_instobj_kmap(iobj, vmm);
> + /*
> + * boot is only called on BAR2, if we can't remap the complete
> + * BAR it's unlikely things are functioning well.
> + */
> + if (check_io_mapping(iobj->imem))
> + nv50_instobj_kmap(iobj, vmm);
> nvkm_instmem_boot(imem);
> mutex_unlock(&imem->mutex);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706030520.857104-1-airlied@gmail.com?part=1
next prev parent reply other threads:[~2026-07-06 3:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 3:05 [PATCH] nouveau/instmem: use iomapping interface for instmem handling (v3) Dave Airlie
2026-07-06 3:16 ` sashiko-bot [this message]
2026-07-12 16:14 ` Danilo Krummrich
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=20260706031609.4A6FD1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox