From: sashiko-bot@kernel.org
To: "Tomeu Vizoso" <tomeu@tomeuvizoso.net>
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v4 11/14] accel/thames: Install memory mappings populated and dirty
Date: Sun, 29 Nov 2026 11:56:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-239561@kernel.org> (raw)
In-Reply-To: <20261129-thames-v4-11-003b1e3365bf@tomeuvizoso.net>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] accel/thames: unzapped partial PFN mapping on error in
thames_gem_shmem_mmap()
--
commit 4ae1719a36f423f47f5340a069ad63c6b97c835f
Author: Tomeu Vizoso <tomeu@tomeuvizoso.net>
accel/thames: Install memory mappings populated and dirty
This commit replaces drm_gem_shmem_object_mmap() with a custom mmap
handler that populates page-backed buffers upfront using
remap_pfn_range() with dirty and writable PTEs.
> diff --git a/drivers/accel/thames/thames_gem.c b/drivers/accel/thames/thames_gem.c
> index 3c2846bb5297d..930444a732e78 100644
> --- a/drivers/accel/thames/thames_gem.c
> +++ b/drivers/accel/thames/thames_gem.c
> @@ -834,6 +834,50 @@ static void thames_gem_shmem_bo_free(struct drm_gem_object *obj)
> drm_gem_shmem_free(&bo->shmem);
> }
>
> +/*
> + * Every page installed now, dirty and writable: they are pinned for the
> + * object's life, and the helper would take two faults on each.
> + */
> +static int thames_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
> +{
> + struct thames_gem_object *bo = to_thames_bo(obj);
> + unsigned long addr = vma->vm_start;
> + struct scatterlist *sg;
> + pgprot_t prot;
> + unsigned int i;
> + int ret;
> +
> + if (vma_is_cow_mapping(vma))
> + return -EINVAL;
> +
> + vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP);
> +
> + prot = vm_get_page_prot(vma->vm_flags);
> + if (vma->vm_flags & VM_WRITE)
> + prot = pte_pgprot(pte_mkdirty(pte_mkwrite_novma(pfn_pte(0, prot))));
> + vma->vm_page_prot = prot;
> +
> + for_each_sgtable_sg(bo->shmem.sgt, sg, i) {
> + unsigned long len = min_t(unsigned long, sg->length, vma->vm_end - addr);
> +
> + ret = remap_pfn_range(vma, addr, page_to_pfn(sg_page(sg)), len, prot);
> + if (ret)
> + return ret;
[Severity: Medium]
If remap_pfn_range() fails after earlier scatterlist segments have
already been mapped, does returning without zapping [vma->vm_start, addr)
leave stale writable PTEs live while the GEM object is freed?
remap_pfn_range_notrack() only zaps the single [addr, addr + len) range
that failed, and VM_PFNMAP mappings do not hold page references. On
error, drm_gem_mmap_obj() and drm_gem_mmap() drop their references to obj
before __mmap_new_file_vma() calls unmap_region(). If another thread has
closed the GEM handle concurrently, drm_gem_object_put() frees the
backing shmem pages while other threads sharing vma->vm_mm can still
write to [vma->vm_start, addr). Calling zap_vma_ptes(vma, vma->vm_start,
addr - vma->vm_start) before returning on error would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129-thames-v4-0-003b1e3365bf@tomeuvizoso.net?part=11
next prev parent reply other threads:[~2026-11-29 11:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 11:35 [PATCH v4 00/14] New DRM accel driver for Texas Instruments' C7x DSPs Tomeu Vizoso
2026-11-29 11:35 ` [PATCH v4 01/14] dt-bindings: remoteproc: k3-dsp: Add the L2 auxiliary and DRU regions Tomeu Vizoso
2026-12-01 8:33 ` Krzysztof Kozlowski
2026-12-01 8:33 ` Krzysztof Kozlowski
2026-11-29 11:35 ` [PATCH v4 02/14] dt-bindings: remoteproc: k3-dsp: Allow a second sub-mailbox Tomeu Vizoso
2026-12-01 8:33 ` Krzysztof Kozlowski
2026-12-01 8:33 ` Krzysztof Kozlowski
2026-11-29 11:35 ` [PATCH v4 03/14] accel/thames: Add header with IPC definitions Tomeu Vizoso
2026-11-29 11:35 ` [PATCH v4 04/14] accel/thames: Add driver for the C7x DSPs in TI SoCs Tomeu Vizoso
2026-11-29 11:35 ` [PATCH v4 05/14] accel/thames: Create a context per client on device open Tomeu Vizoso
2026-11-29 11:53 ` sashiko-bot
2026-11-29 11:35 ` [PATCH v4 06/14] accel/thames: Add IOCTLs for BO creation and mapping Tomeu Vizoso
2026-11-29 11:52 ` sashiko-bot
2026-11-29 11:35 ` [PATCH v4 07/14] accel/thames: Add support for submitting DMA operations Tomeu Vizoso
2026-11-29 11:48 ` sashiko-bot
2026-11-29 11:35 ` [PATCH v4 08/14] accel/thames: Add IOCTLs for job creation and submission Tomeu Vizoso
2026-11-29 11:58 ` sashiko-bot
2026-11-29 11:35 ` [PATCH v4 09/14] accel/thames: Recover from faults and timeouts Tomeu Vizoso
2026-11-29 12:00 ` sashiko-bot
2026-11-29 11:35 ` [PATCH v4 10/14] accel/thames: Add IOCTL for memory synchronization Tomeu Vizoso
2026-11-29 11:35 ` [PATCH v4 11/14] accel/thames: Install memory mappings populated and dirty Tomeu Vizoso
2026-11-29 11:56 ` sashiko-bot [this message]
2026-11-29 11:35 ` [PATCH v4 12/14] Documentation: accel/thames: Add initial docs Tomeu Vizoso
2026-11-29 11:35 ` [PATCH v4 13/14] arm64: dts: ti: k3-j722s: Add the AUX L2 SRAM and DRU regions Tomeu Vizoso
2026-11-29 11:35 ` [PATCH v4 14/14] arm64: dts: ti: k3-j722s: Add second submailbox to the C7x cores Tomeu Vizoso
2026-11-29 12:06 ` sashiko-bot
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=sashiko-outbox-239561@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tomeu@tomeuvizoso.net \
/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.